/* Link Finder's own styles (docs/linkfinder/spec.md §9).
 *
 * main.css is a read-only copy of the site's stylesheet and provides the
 * chrome, the type scale and the colours; everything here is what this tool
 * adds and nothing the site already has.
 *
 * Three requirements from §9 are structural rather than decorative, and each
 * is marked where it is met: the anchor highlight must not rely on colour
 * alone, the export bar sticks to the bottom on a phone, and nothing may
 * scroll horizontally at 360 px.
 */

:root {
  --lf-accent: #ff6a32;
  --lf-accent-deep: #b8440f;
  --lf-ink: #17130f;
  --lf-body: #4a4238;
  --lf-muted: #6b6155;
  --lf-line: rgba(23, 19, 15, 0.14);
  --lf-line-soft: rgba(23, 19, 15, 0.08);
  --lf-surface: #fffaf5;
  --lf-cream: #fdfaf7;
  --lf-error: #b3261e;
  --lf-good: #1f7a4d;
  /* 44 px, as §9 requires for a touch target. */
  --lf-touch: 2.75rem;
}

.light-page main {
  padding-bottom: 6rem; /* room for the sticky export bar */
}

.lf-skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--lf-ink);
  color: #fff;
  padding: 0.75rem 1rem;
  z-index: 50;
}
.lf-skip:focus {
  left: 0;
}

/* --- shared wrappers ------------------------------------------------------ */
.lf-hero,
.lf-form,
.lf-progress,
.lf-empty,
.lf-results,
.lf-guide,
.lf-prose {
  width: 100%;
  max-width: 54rem;
  margin-inline: auto;
  /* Side padding set once, on the wrapper, so there is a gutter at every
     width and nothing needs its own. */
  padding-inline: 1.25rem;
  box-sizing: border-box;
}

/* --- hero ----------------------------------------------------------------- */
.lf-hero {
  padding-block: 3rem 1.5rem;
}
.lf-eyebrow {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.85rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--lf-accent);
  font-weight: 700;
  margin: 0 0 0.75rem;
}
.lf-badge {
  letter-spacing: 0.08em;
  background: rgba(255, 106, 50, 0.12);
  color: var(--lf-accent-deep);
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  font-size: 0.72rem;
}
.lf-hero h1 {
  font-size: clamp(2.1rem, 4vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.1;
  margin: 0 0 0.75rem;
  color: var(--lf-ink);
}
.lf-lead {
  font-size: 1.15rem;
  color: var(--lf-body);
  margin: 0 0 1.25rem;
}

/* The promise, on the page itself (spec §1). */
.lf-promise {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.95rem;
  color: var(--lf-muted);
}
.lf-promise li::before {
  content: '✓';
  color: var(--lf-good);
  font-weight: 700;
  margin-right: 0.4rem;
}

/* --- form ----------------------------------------------------------------- */
.lf-form {
  padding-block: 1rem 2rem;
}
.lf-modes {
  border: 1px solid var(--lf-line);
  border-radius: 0.75rem;
  padding: 1rem;
  margin: 0 0 1.5rem;
  background: var(--lf-surface);
}
.lf-modes legend {
  font-weight: 700;
  padding-inline: 0.4rem;
  color: var(--lf-ink);
}
.lf-radio {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.4rem 0;
  min-height: var(--lf-touch);
}
.lf-radio input {
  margin-top: 0.3rem;
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--lf-accent);
  flex: none;
}
.lf-radio label {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  cursor: pointer;
}
.lf-radio-title {
  font-weight: 600;
  color: var(--lf-ink);
}
.lf-radio-note {
  font-size: 0.9rem;
  color: var(--lf-muted);
}

.lf-field {
  margin: 0 0 1.25rem;
}
.lf-field-narrow {
  max-width: 16rem;
}
.lf-field label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--lf-ink);
}
.lf-field input,
.lf-field select,
.lf-field textarea {
  width: 100%;
  box-sizing: border-box;
  min-height: var(--lf-touch);
  padding: 0.6rem 0.75rem;
  font: inherit;
  color: var(--lf-ink);
  background: #fff;
  border: 1px solid var(--lf-line);
  border-radius: 0.5rem;
}
.lf-field textarea {
  min-height: 9rem;
  resize: vertical;
}
.lf-field input:focus-visible,
.lf-field select:focus-visible,
.lf-field textarea:focus-visible,
.lf-button:focus-visible,
.lf-tabs button:focus-visible,
.lf-card-actions button:focus-visible {
  outline: 3px solid var(--lf-accent);
  outline-offset: 2px;
}
.lf-field input[aria-invalid='true'] {
  border-color: var(--lf-error);
}
.lf-hint {
  margin: 0.4rem 0 0;
  font-size: 0.9rem;
  color: var(--lf-muted);
}
.lf-error {
  margin: 0.4rem 0 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--lf-error);
}

.lf-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.lf-button {
  min-height: var(--lf-touch);
  padding: 0.6rem 1.4rem;
  font: inherit;
  font-weight: 600;
  color: var(--lf-ink);
  background: #fff;
  border: 1px solid var(--lf-line);
  border-radius: 999px;
  cursor: pointer;
}
.lf-button:hover {
  border-color: var(--lf-accent);
}
.lf-button-primary {
  background: var(--lf-accent);
  border-color: var(--lf-accent);
  color: #fff;
}
.lf-button-primary:hover {
  background: var(--lf-accent-deep);
  border-color: var(--lf-accent-deep);
}
.lf-button[disabled] {
  opacity: 0.55;
  cursor: progress;
}

/* --- progress and empty --------------------------------------------------- */
.lf-progress,
.lf-empty {
  padding-block: 0.75rem;
  font-size: 1rem;
  color: var(--lf-body);
}
.lf-progress {
  font-variant-numeric: tabular-nums;
}
.lf-progress-error {
  font-weight: 600;
  color: var(--lf-error);
}
.lf-empty {
  color: var(--lf-muted);
}

/* --- results -------------------------------------------------------------- */
.lf-results {
  padding-block: 1rem 2rem;
}
.lf-results h2 {
  font-size: 1.6rem;
  margin: 0 0 0.5rem;
  color: var(--lf-ink);
}
.lf-results h2:focus-visible {
  outline: 3px solid var(--lf-accent);
  outline-offset: 4px;
}
.lf-summary {
  margin: 0 0 1.5rem;
  color: var(--lf-body);
}

.lf-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 1.25rem;
  border-bottom: 1px solid var(--lf-line-soft);
}
.lf-tabs button {
  min-height: var(--lf-touch);
  padding: 0.5rem 1rem;
  font: inherit;
  font-weight: 600;
  color: var(--lf-muted);
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
}
.lf-tabs button[aria-selected='true'] {
  color: var(--lf-ink);
  border-bottom-color: var(--lf-accent);
}

/* --- cards ---------------------------------------------------------------- */
.lf-cards {
  display: grid;
  gap: 1.25rem;
}
.lf-card {
  border: 1px solid var(--lf-line);
  border-radius: 0.85rem;
  padding: 1.1rem;
  background: #fff;
}
.lf-card-selected {
  border-color: var(--lf-good);
  box-shadow: inset 4px 0 0 var(--lf-good);
}
.lf-card-rejected {
  opacity: 0.55;
  box-shadow: inset 4px 0 0 var(--lf-line);
}
.lf-card-head {
  margin-bottom: 0.75rem;
}
.lf-card-label {
  display: inline-block;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--lf-muted);
  margin-right: 0.5rem;
}
.lf-card-source,
.lf-card-target {
  margin: 0 0 0.35rem;
  /* A long URL must not widen the card at 360 px (spec §9). */
  overflow-wrap: anywhere;
}
.lf-card-heading {
  margin: 0;
  font-size: 0.9rem;
  color: var(--lf-muted);
}
.lf-card-url {
  display: block;
  font-size: 0.85rem;
  color: var(--lf-muted);
  overflow-wrap: anywhere;
}

.lf-passage {
  margin: 0 0 0.5rem;
  padding: 0.85rem 1rem;
  background: var(--lf-cream);
  border-left: 3px solid var(--lf-line);
  border-radius: 0 0.5rem 0.5rem 0;
  font-size: 1.02rem;
  line-height: 1.6;
  color: var(--lf-ink);
}
.lf-ctx {
  color: var(--lf-muted);
}

/*
 * The anchor highlight.
 *
 * Bold AND underlined, not colour alone (spec §5, WCAG 1.4.1): the whole point
 * of the card is that a reviewer can see exactly which words would become the
 * link, and a reader who cannot distinguish the background tint still can.
 */
.lf-passage mark {
  background: rgba(255, 106, 50, 0.22);
  color: var(--lf-ink);
  font-weight: 700;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 2px;
  padding: 0 0.1rem;
  border-radius: 0.2rem;
}

.lf-occurrence {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  color: var(--lf-muted);
}
.lf-reason {
  margin: 0 0 1rem;
  font-size: 0.95rem;
  color: var(--lf-body);
}

.lf-card-actions {
  display: flex;
  gap: 0.6rem;
}
.lf-card-actions button {
  min-height: var(--lf-touch);
  min-width: 6rem;
  padding: 0.5rem 1.1rem;
  font: inherit;
  font-weight: 600;
  border-radius: 999px;
  border: 1px solid var(--lf-line);
  background: #fff;
  color: var(--lf-ink);
  cursor: pointer;
}
.lf-card-actions button[aria-pressed='true'] {
  color: #fff;
}
.lf-select[aria-pressed='true'] {
  background: var(--lf-good);
  border-color: var(--lf-good);
}
.lf-reject[aria-pressed='true'] {
  background: var(--lf-muted);
  border-color: var(--lf-muted);
}

/* --- coverage ------------------------------------------------------------- */
.lf-coverage {
  margin-top: 2rem;
  border: 1px solid var(--lf-line-soft);
  border-radius: 0.75rem;
  background: var(--lf-surface);
  padding: 0.5rem 1rem;
}
.lf-coverage summary {
  min-height: var(--lf-touch);
  display: flex;
  align-items: center;
  font-weight: 600;
  cursor: pointer;
  color: var(--lf-ink);
}
.lf-coverage h3 {
  font-size: 1rem;
  margin: 1rem 0 0.5rem;
}
.lf-coverage-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.88rem;
}
.lf-coverage-list li {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--lf-line-soft);
}
.lf-coverage-url {
  overflow-wrap: anywhere;
  color: var(--lf-body);
}
.lf-coverage-reason {
  color: var(--lf-muted);
  font-style: italic;
}
.lf-coverage-note {
  margin: 0 0 0.6rem;
  font-size: 0.88rem;
  color: var(--lf-muted);
}

/* Rejection counts, grouped by reason. Counts only - no rejected sentence is
   sent to the browser or stored (spec §3). */
.lf-rejections {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.9rem;
}
.lf-rejections li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--lf-line-soft);
}
.lf-rej-label {
  color: var(--lf-body);
}
.lf-rej-count {
  flex: none;
  font-weight: 700;
  color: var(--lf-ink);
  /* Tabular figures so a column of counts lines up. */
  font-variant-numeric: tabular-nums;
}

/* --- export bar ----------------------------------------------------------- */
.lf-exportbar {
  position: sticky;
  bottom: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  max-width: 54rem;
  margin-inline: auto;
  padding: 0.75rem 1.25rem;
  box-sizing: border-box;
  background: #fff;
  border-top: 1px solid var(--lf-line);
  box-shadow: 0 -6px 18px rgba(23, 19, 15, 0.08);
}
.lf-selected {
  font-weight: 600;
  color: var(--lf-ink);
}
.lf-exportbar-actions {
  display: flex;
  gap: 0.6rem;
}

/* --- guide and prose ------------------------------------------------------ */
.lf-guide {
  padding-block: 2rem 3rem;
  border-top: 1px solid var(--lf-line-soft);
}
.lf-guide h2 {
  font-size: 1.35rem;
  margin: 0 0 1rem;
  color: var(--lf-ink);
}
.lf-guide ul {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--lf-body);
}
.lf-guide li {
  margin-bottom: 0.6rem;
}

.lf-prose {
  padding-block: 3rem;
  color: var(--lf-body);
}
.lf-prose h1 {
  font-size: clamp(2rem, 4vw, 2.6rem);
  color: var(--lf-ink);
  margin: 0 0 1rem;
}
.lf-prose h2 {
  font-size: 1.3rem;
  color: var(--lf-ink);
  margin: 2rem 0 0.75rem;
}
.lf-prose code {
  background: var(--lf-surface);
  border: 1px solid var(--lf-line-soft);
  border-radius: 0.3rem;
  padding: 0.1rem 0.35rem;
  font-size: 0.92em;
  overflow-wrap: anywhere;
}
.lf-prose ul {
  padding-left: 1.2rem;
}
.lf-prose li {
  margin-bottom: 0.5rem;
}

/* --- narrow screens ------------------------------------------------------- */
/* Single column under 768 px (spec §9). The layout is one column throughout,
   so this only has to stack the rows that sit side by side. */
@media (max-width: 768px) {
  .lf-hero {
    padding-block: 2rem 1rem;
  }
  .lf-actions .lf-button,
  .lf-exportbar-actions .lf-button {
    flex: 1 1 10rem;
  }
  .lf-exportbar {
    justify-content: center;
  }
  .lf-card-actions button {
    flex: 1 1 auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
