/* =========================================================================
   Can I afford an EV? — design tokens

   The subject: three ways to pay for the same car (novated lease, car loan,
   cash), which this tool tracks like three lines on a Melbourne transit
   map — each gets one identity colour, used consistently everywhere that
   option appears (now: the legend; later: the crossover chart and car
   cards). Numeric readouts use a monospaced face, a nod to a station
   departure board — the numbers you actually came here for.
   ========================================================================= */

:root {
  /* Surfaces */
  --paper: #eef1ee;
  --paper-raised: #ffffff;
  --hairline: #d3d9d2;

  /* Text */
  --ink: #161b1f;
  --ink-soft: #4b5560;
  --ink-faint: #7a8480;

  /* The three "lines": novated lease, car loan, cash.
     loan and cash were re-picked together (Task 19 review, issue 4): the
     old navy (#2b5c86) and teal (#1f7a5c) sit only ~13 ΔE apart in OKLab
     under normal vision — below the 15 floor a full-colour reader needs to
     tell two hues apart — and both fall below the OKLCH chroma floor that
     keeps a colour reading as a colour rather than a gray. loan moved to a
     deeper, more saturated blue at nearly the same hue (chroma 0.087→0.115,
     L 0.461→0.441); cash moved off teal entirely to a violet
     (H 166°→302°), pushed away in hue AND lightness rather than nudged, so
     it clears both the CVD-simulated (protan/deutan, ΔE >= 11.9) and
     normal-vision (ΔE 19.8) separation floors against loan. Validated with
     dataviz's validate_palette.js — all checks pass, --pairs adjacent and
     --pairs all, since any two lines can end up adjacent on the chart). */
  --line-lease: #b96a1e;
  --line-lease-bg: #f7e9d8;
  --line-loan: #10558f;
  --line-loan-bg: #d8e6f5;
  --line-cash: #8f59d1;
  --line-cash-bg: #e8e0f9;

  /* System */
  --warn: #9c2f22;
  --warn-bg: #f6e2de;
  --focus-ring: #2b5c86;

  /* Type */
  --font-text: 'IBM Plex Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;

  /* The type scale. Six steps, and nothing outside them.

     This page had accumulated 24 distinct font sizes across 60 declarations —
     0.66, 0.68, 0.7, 0.72, 0.75, 0.78, 0.8, 0.82, 0.85rem all in play at once,
     which is nine ways of saying "smaller than body" and no way of telling them
     apart. A single car card used eight of them. Sizes that close together do
     not read as hierarchy, they read as drift.
     Six steps at roughly a 1.15 ratio, on the 16px root (rem tracks the root
     element, so setting body below does not move them):
       display  24px  the wordmark, and nothing else
       xl       20px  the one headline that carries the answer
       lg       17px  section headings, card titles, the verdict's three figures
       md       15px  body: prose, inputs, the figure a reader acts on
       sm       13px  labels, secondary lines, notes, most of the interface
       xs       11px  eyebrows, captions, units, provenance
     Where two things share a step, weight and colour separate them — a label at
     500/ink-soft against its hint at 400/ink-faint. That is a firmer hierarchy
     than a 1px size difference nobody can see.
     The four sizes inside .crossover-chart are deliberately NOT on this scale:
     they are SVG viewBox units scaled by the chart's own transform, and two are
     paired with hand-measured character widths in ui/crossover-chart.js. */
  --text-display: 1.5rem;
  --text-xl: 1.25rem;
  --text-lg: 1.0625rem;
  --text-md: 0.9375rem;
  --text-sm: 0.8125rem;
  --text-xs: 0.6875rem;

  /* Rhythm */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --radius: 10px;

  color-scheme: light;
}

/* =========================================================================
   Reset & base
   ========================================================================= */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: var(--text-md);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, textarea, input, select, button {
  font-family: inherit;
}

img, svg { display: block; max-width: 100%; }

button { font: inherit; }

a { color: var(--line-loan); }

/* Numeric / data readouts get the mono face throughout */
input[type='number'],
input[type='date'],
.num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--ink);
  color: var(--paper-raised);
  padding: var(--space-2) var(--space-3);
  border-radius: 0 0 6px 0;
  z-index: 100;
}

.skip-link:focus {
  left: 0;
}

:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

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

/* =========================================================================
   Header
   ========================================================================= */

/* No border-bottom here: the tablist (the header's last child — see
   index.html) supplies the header's terminating edge instead, via its own
   border-bottom below, so the selected tab's underline can be the last
   line before <main> rather than fighting a second hairline immediately
   under it. */
.site-header {
  background: var(--paper-raised);
}

.site-header__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-5) var(--space-4) var(--space-4);
  /* Titles left, provenance right. Stacks on narrow screens rather than
     squeezing the stats into a column too thin to read. */
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2) var(--space-5);
}

.site-header__titles { min-width: min(100%, 28ch); }

/* How much data stands behind the answers, and how fresh it is. Quiet: it is
   provenance, not a headline. */
.site-header__stats {
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--ink-faint);
  text-align: right;
}

@media (max-width: 599px) {
  .site-header__stats { text-align: left; }
}

.wordmark {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: 0;
  font-size: var(--text-display);
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* The mark: an EV outline with a charging bolt, inside three rings in the
   lease, loan and cash line colours.
   logo.svg's viewBox is cropped to the drawn circle, so the image fills the
   round frame with no offsets. Fixed size, so the header never reflows once
   the image loads. */
.wordmark__logo {
  flex: 0 0 auto;
  display: block;
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 50%;
  overflow: hidden;
  background: var(--paper-raised);
}

.wordmark__logo img {
  display: block;
  width: 100%;
  height: 100%;
}

.wordmark__mark {
  color: var(--line-lease);
}

.site-header__subhead {
  margin: var(--space-1) 0 0;
  color: var(--ink-soft);
  font-size: var(--text-md);
  max-width: 46ch;
}

/* The route-map fragment: three lines meeting, the visual signature that
   recurs wherever the three payment options are compared. */
.route-rule {
  display: flex;
  height: 4px;
  max-width: 1200px;
  margin: 0 auto;
}

.route-rule__seg { flex: 1; }
.route-rule__seg--lease { background: var(--line-lease); }
.route-rule__seg--loan { background: var(--line-loan); }
.route-rule__seg--cash { background: var(--line-cash); }

/* =========================================================================
   Layout — mobile-first stack, three columns from 900px
   ========================================================================= */

.sections {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.sections > section,
.sections__flow > section {
  background: var(--paper-raised);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: var(--space-5);
}

/* Steps 2 and 3, stacked. On mobile this is a transparent pass-through: the
   wrapper repeats .sections' own column + gap, so the three cards read as one
   evenly spaced stack exactly as before. It earns its keep at 900px, below. */
.sections__flow {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  /* Grid items floor at min-content width; without this the chart's wide
     geometry inside step 2 could push the column past its 1fr share. */
  min-width: 0;
}

@media (min-width: 900px) {
  .sections {
    display: grid;
    /* Two columns, not three. Step 1 stays a fixed rail — it is a form, and a
       form does not get better with more width — and step 2 takes the rest.
       Measured before changing: three columns gave steps 2 and 3 just 293px each
       at a 900px container, narrower than a phone, and 483px at 1280px. The
       chart needs 620px of container for its wide geometry, so under three
       columns it was compact at every realistic desktop width; under two it goes
       wide from a ~970px page up (the column loses 250px to the rail, 32px of
       page padding, the 16px gap and 48px of its own padding, so 620 + 346).
       Step 3 spans both columns below, where the shortlist can use the whole
       width instead of a 293px slot — which also disposes of the ~400-500px of
       dead column that sat beside it, since the two tall panels are no longer
       trying to be the same height as a short form. */
    grid-template-columns: 250px 1fr;
    gap: 1rem;
    align-items: start;
  }

  /* Step 3 used to span both columns on its own grid row, which meant it began
     below the taller of steps 1 and 2 — and step 1 is the one that grows, by
     several hundred pixels, every time the reader opens one of its <details>.
     Expanding the options pushed the shortlist off the fold even though step 2,
     the thing it belongs under, had not moved at all. Wrapping 2 and 3 in
     .sections__flow takes step 3 out of the grid's row sizing entirely: the
     wrapper is the single column-2 item, and inside it the shortlist simply
     follows step 2's bottom edge at the same width, whatever step 1 does. */
  .sections__flow {
    gap: 1rem;
  }
}

.section-heading {
  display: flex;
  /* Centred, not baseline: the step number is now a filled disc rather than
     a text-sized outline, so baseline alignment would hang it below the
     heading's cap height. */
  align-items: center;
  gap: var(--space-3);
  margin: 0 0 var(--space-4);
  font-size: var(--text-lg);
  font-weight: 600;
}

/* The three steps are the app's spine — you answer 1, read 2, choose from 3 —
   so the numerals are a filled disc rather than a faint outline. Deliberately
   monochrome: the orange/blue/purple in the header rule already means
   lease/loan/cash, and reusing those hues here would imply a mapping between
   step and payment option that does not exist. */
.section-heading__eyebrow {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  width: 1.7em;
  height: 1.7em;
  font-family: var(--font-mono);
  font-size: var(--text-md);
  font-weight: 600;
  line-height: 1;
  color: var(--paper-raised);
  background: var(--ink);
  border-radius: 50%;
}

/* =========================================================================
   Section 1 — about you
   ========================================================================= */

.field-group + .field-group { margin-top: var(--space-5); }

/* The preference block sits below the financial fields and is visually
   separated: step 1 asks two different kinds of question, and the split makes
   the second one findable. */
.field-group--prefs {
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--hairline);
}

/* The numeric group above gets its spacing from a grid gap; this group is a
   plain flow of fields and had none, so each field's hint sat ~19px above the
   *next* field's label against ~35px between fields elsewhere — close enough
   that every hint read as a caption for the field below it rather than the one
   it belongs to. The `:not(.field--choices)` is because the body-type fieldset
   already carries a larger bottom margin of its own; without it that one gap
   would be the sum of both. */
.field-group--prefs .field:not(.field--choices) + .field,
.phev-options .field + .field {
  margin-top: var(--space-4);
}

/* Also the <summary> of the collapsible preference block, so it carries the
   pointer affordance and keeps the heading weight it had as an <h3>. */
.field-group__heading {
  margin: 0 0 var(--space-4);
  font-size: var(--text-md);
  font-weight: 600;
  cursor: pointer;
}

/* Says the block can be skipped, which is the whole reason it is collapsed. */
.field-group__optional {
  margin-left: 0.4em;
  font-size: var(--text-xs);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
}

/* A closed <details> has no need of the bottom margin its summary carries as a
   heading; only an open one does. */
.field-group--prefs:not([open]) .field-group__heading {
  margin-bottom: 0;
}

.field--choices {
  border: none;
  padding: 0;
  margin: 0 0 var(--space-5);
}

.field--choices legend {
  padding: 0;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink-soft);
  margin-bottom: var(--space-2);
}

.checkbox-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-3);
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  font-size: var(--text-sm);
  color: var(--ink);
  cursor: pointer;
}

/* The scalar-input rules below now exclude checkboxes, so this no longer has
   to out-specify anything — it just zeroes the browser's default margin so the
   gap above is the only spacing. */
.checkbox input {
  margin: 0;
  flex: none;
}

.field-group--numeric {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}

/* :not(.checkbox) because a checkbox's label is not a caption sitting above
   its control — it is the word beside the box, and it owns the box. Without
   the exclusion this rule beat `.checkbox`'s own inline-flex on specificity
   (0,1,1 against 0,1,0) and stacked every tick-box above its text. */
.field label:not(.checkbox) {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink-soft);
  margin-bottom: var(--space-1);
}

.field__hint {
  margin: var(--space-1) 0 0;
  font-size: var(--text-sm);
  line-height: 1.4;
  color: var(--ink-faint);
}

/* Restates a typed number, formatted, because type="number" cannot show
   thousands separators. Quiet — it is a check on what you typed, not a second
   label — and mono so the digits line up under the box's own. */
.field__echo {
  display: block;
  margin-top: 0.2em;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--ink-faint);
}

/* Presets that answer "how much boot?" in the terms people actually think in.
   Above the box rather than below it: they are the expected way in, and the
   number field is the escape hatch for anyone who knows their figure. */
.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.preset {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35em;
  padding: 0.3em 0.6em;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink-soft);
  font-size: var(--text-sm);
  line-height: 1.3;
  cursor: pointer;
}

.preset:hover {
  border-color: var(--ink-faint);
  color: var(--ink);
}

/* The figure a preset stands for, carried on the button so the reader learns
   the unit rather than being asked to guess it. */
.preset__value {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--ink-faint);
}

.preset.is-active {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper-raised);
}

.preset.is-active .preset__value { color: var(--paper); }

/* Full width suits a value you type into. A tick-box has an intrinsic size,
   and stretching it to the column width pushed its own label onto the next
   line — this rule tied with `.checkbox input { width: auto }` on specificity
   and won on source order. */
.field input:not([type="checkbox"]),
.field select {
  width: 100%;
  padding: 0.5em 0.7em;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  font-size: var(--text-md);
}

.field select { font-family: var(--font-text); }

.field input:not([type="checkbox"]):focus,
.field select:focus {
  background: var(--paper-raised);
}

.field__input {
  display: flex;
  align-items: center;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  background: var(--paper);
  padding-inline: 0.6em;
}

.field__input input {
  border: none;
  background: transparent;
  padding-block: 0.5em;
  padding-inline: 0.2em;
}

.field__input input:focus { outline-offset: -2px; }

.field__input:focus-within { background: var(--paper-raised); }

.field__prefix, .field__suffix {
  color: var(--ink-faint);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

/* Indented under the toggle that reveals it, so the relationship is visible
   rather than implied by proximity alone. */
.phev-options {
  margin-top: var(--space-3);
  padding-left: var(--space-3);
  border-left: 2px solid var(--hairline);
}

.phev-options[hidden] { display: none; }

/* Brief highlight used when parsing free text fills a field in, so the
   hand-off from prose to numbers is visible. */
.field-updated {
  animation: field-updated-flash 1.6s ease-out;
}

@keyframes field-updated-flash {
  0% { background-color: var(--line-lease-bg); }
  100% { background-color: transparent; }
}

/* =========================================================================
   Section 2 — what you can afford
   ========================================================================= */

.verdict-panel {
  min-height: 4rem;
}

/* The winner block. The option's colour arrives as a rule above the headline —
   the route-rule motif from the header, one segment wide — which is what
   replaced the trophy emoji. Same --option-line the tiles below use, so a cash
   win is purple here and purple there. */
.verdict-panel .winner--novated { --option-line: var(--line-lease); }
.verdict-panel .winner--loan { --option-line: var(--line-loan); }
.verdict-panel .winner--upfront { --option-line: var(--line-cash); }

.verdict-panel .winner::before {
  content: '';
  display: block;
  width: 3rem;
  height: 4px;
  margin-bottom: var(--space-2);
  background: var(--option-line, var(--line-lease));
}

/* Sits above the headline, in the warning colour but at footnote size: it has to
   be noticed before the figure it qualifies is read, without competing with it.
   Disappears the moment a salary is entered. */
.verdict-panel .winner__example {
  margin: 0 0 var(--space-1);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--warn);
}

.verdict-panel .winner__headline {
  margin: 0;
  font-size: var(--text-xl);
  font-weight: 700;
  line-height: 1.25;
}

/* Not footnote grey. The complaint this answers is that a ceiling on its own
   reads as affordability, so the thing that makes it a commitment has to be
   legible at a glance rather than found. */
.verdict-panel .winner__commitment {
  margin: var(--space-1) 0 0;
  font-size: var(--text-md);
  font-weight: 500;
  color: var(--ink-soft);
}

.verdict-panel .detail {
  margin-top: var(--space-1);
  color: var(--ink-soft);
}

.verdict-panel .totals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.verdict-panel .total {
  display: flex;
  flex-direction: column;
  gap: 0.2em;
  padding: var(--space-3);
  border: 1px solid var(--hairline);
  border-radius: 8px;
}

.verdict-panel .total span {
  font-size: var(--text-sm);
  color: var(--ink-soft);
}

.verdict-panel .total strong {
  font-family: var(--font-mono);
  font-size: var(--text-lg);
}

/* What this way of paying commits you to, beyond the ceiling above. Three
   tiles used to repeat one identical sentence; these lines differ per option,
   so they are worth the space. Unbulleted — these are half-width columns now,
   and the marker plus its indent cost about four characters per line, which
   is a wrapped line the tile cannot spare. */
.verdict-panel .total__parts {
  margin: 0.15em 0 0;
  padding: 0;
  list-style: none;
}

.verdict-panel .total__parts li {
  font-size: var(--text-xs);
  line-height: 1.4;
  color: var(--ink-soft);
}

/* The winning option's obligation, promoted. On a lease this line is the
   balloon payment — a five-figure bill due on the last day of the term — and at
   0.75rem grey it was the smallest text in the panel while being the fact most
   likely to change someone's mind. */
.verdict-panel .total.is-winner .total__parts li {
  font-size: var(--text-sm);
  color: var(--ink);
}

/* The lever that would unblock an out-of-reach option. Quieter than the
   option label above it — it is a footnote to "out of reach", not a heading. */
.verdict-panel .total__blocker {
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  color: var(--ink-faint);
}

/* Each way of paying owns a hue — orange for a lease, blue for a loan, purple
   for cash — and the legend directly below this panel says so. The winner tile
   therefore has to be tinted in the *winning* option's hue: hardcoding the
   lease colour here meant a cash win was highlighted in the colour the legend
   forty pixels lower assigns to leasing. Carried as a pair of custom
   properties per option so `.is-winner` stays one rule rather than three. */
.verdict-panel .total--novated { --option-line: var(--line-lease); --option-tint: var(--line-lease-bg); }
.verdict-panel .total--loan    { --option-line: var(--line-loan);  --option-tint: var(--line-loan-bg); }
.verdict-panel .total--upfront { --option-line: var(--line-cash);  --option-tint: var(--line-cash-bg); }

.verdict-panel .total.is-winner {
  border-color: var(--option-line, var(--line-lease));
  background: var(--option-tint, var(--line-lease-bg));
}

/* An option the reader has told us they cannot use. Dimmed rather than removed:
   the figures are real and knowing what a lease would have reached is worth
   something, but it must not compete with the options actually on the table.
   Deliberately not `display: none` — a missing third option looks like a bug. */
.verdict-panel .total.is-unavailable {
  opacity: 0.55;
}

.verdict-panel .total.is-unavailable strong {
  font-weight: 400;
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

/* Same treatment, applied from the section down: one class on #afford / #cars
   (ui/app.js) reaches the chart's lease line and the shortlist's novated rows
   without either renderer needing to know about eligibility. */
/* .line-novated, not .line-lease: the chart names its polylines after the option
   key (`line-${option}`), while the colour tokens are named after the transit-map
   metaphor. Two naming schemes for one concept, and picking the wrong one here
   made the rule silently match nothing. */
.novated-unavailable .line-novated,
.novated-unavailable .line-legend__item--lease,
.novated-unavailable .cost-row--novated {
  opacity: 0.45;
}

.disclaimer {
  margin: var(--space-4) 0 0;
  padding: var(--space-3) var(--space-4);
  background: var(--paper);
  border-left: 3px solid var(--ink-faint);
  border-radius: 0 6px 6px 0;
  font-size: var(--text-sm);
  line-height: 1.55;
  color: var(--ink-soft);
}

.disclaimer strong { color: var(--ink); }

.disclaimer__lead { margin: 0; }

/* Bulleted rather than three runs of prose: these are separate, unrelated
   limitations, and a reader scanning for "does this apply to me" should be
   able to find the relevant one without reading the other two. */
.disclaimer__list {
  margin: var(--space-2) 0 0;
  padding-left: 1.1em;
}

.disclaimer__list li + li { margin-top: var(--space-2); }

/* A <ul> since item 27: it is a list of three things, and that is what tells a
   screen reader how many there are. list-style and padding-left are reset
   because the coloured dots are the markers. */
.line-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin: var(--space-5) 0 0;
  padding-top: var(--space-4);
  padding-left: 0;
  list-style: none;
  border-top: 1px solid var(--hairline);
}

.line-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  font-size: var(--text-sm);
  color: var(--ink-soft);
}

.line-legend__dot {
  width: 0.65em;
  height: 0.65em;
  border-radius: 50%;
  display: inline-block;
}

.line-legend__dot--lease { background: var(--line-lease); }
.line-legend__dot--loan { background: var(--line-loan); }
.line-legend__dot--cash { background: var(--line-cash); }

.crossover-panel, .rates-panel {
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--hairline);
  min-height: 3rem;
}

/* The one range input the design calls "the slider" — drags it and the
   verdict/chart/shortlist below recompute locally (debounced, see
   ui/app.js), with no network call. */
.budget-slider {
  margin-bottom: var(--space-4);
}

/* Label, help toggle, then the live figure pushed to the far end. Was a single
   flexed <label> with the output inside it; the toggle needs to sit beside the
   words rather than inside the label, where clicking it would also focus the
   slider. */
/* The positioning context for the help panel, so it opens directly beneath the
   row holding the "?" rather than below the whole slider block — anchored to the
   slider it sat some 80px from its own trigger and clipped the hint underneath.
   Being a block-level flex row, it is already the slider's full width, which is
   what the panel spans. */
.budget-slider__head {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.4em;
  margin-bottom: var(--space-2);
}

.budget-slider label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink-soft);
}

.budget-slider output {
  margin-left: auto;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--ink);
}

/* =========================================================================
   Help disclosure — a "?" that opens a paragraph.
   For copy that a reader needs once and never again: the three-ways-to-pay
   definition was four lines of prose above the slider, read by everyone,
   useful to a first-timer. Behind the toggle it costs one glyph.
   ========================================================================= */

.help {
  /* Keeps the toggle from stretching in the flex row above. */
  flex: 0 0 auto;
  line-height: 1;
}

.help__toggle {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 1.15rem;
  height: 1.15rem;
  border: 1px solid var(--hairline);
  border-radius: 50%;
  background: var(--paper);
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: pointer;
  /* The default disclosure triangle would sit beside the "?" and read as a
     second, unrelated mark. */
  list-style: none;
}

.help__toggle::-webkit-details-marker { display: none; }

/* The visible disc is 18px, because a larger one would overpower the 0.85rem
   label beside it — but 18px is under the 24x24 minimum target size, and this is
   a control people tap on a phone. Grows the hit area without growing the mark. */
.help__toggle::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 28px;
  height: 28px;
  transform: translate(-50%, -50%);
}

.help__toggle:hover,
.help[open] .help__toggle {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper-raised);
}

/* Spans the label row rather than the toggle, and overlays what follows instead
   of pushing it down — opening an explanation should not move the numbers the
   reader is looking at. */
.help__body {
  position: absolute;
  z-index: 15;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--hairline);
  border-radius: 6px;
  background: var(--paper-raised);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
}

.help__body p {
  margin: 0;
  max-width: 62ch;
  color: var(--ink-soft);
  font-size: var(--text-sm);
  line-height: 1.55;
}

.help__body strong { color: var(--ink); }

/* Reachable by a screen reader, absent from the page. The "?" carries no meaning
   on its own, so the toggle's real name lives in one of these. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.budget-slider input[type='range'] {
  width: 100%;
  accent-color: var(--line-lease);
}

/* =========================================================================
   Crossover chart — Task 19. Two renderings of one series, chosen in JS by
   container width at the project's 900px breakpoint:
     - desktop: three SVG lines, cost against budget.
     - mobile: a single "winner band" — three thin lines in ~96px of height
       don't read on a phone, so the whole width becomes coloured segments
       showing who's cheapest at each point on the budget slider.
   Colours match the .line-legend dots above (lease/loan/cash). Colour is
   never the only identity channel: the desktop lines also carry a stroke
   pattern (solid / dashed / dotted), and both renderings carry direct
   text labels.
   ========================================================================= */

.crossover-chart {
  width: 100%;
  height: auto;
  overflow: visible;
}

.crossover-chart .grid-line {
  stroke: var(--hairline);
  stroke-width: 1;
}

/* The vertical marker at a crossover — where the cheapest option flips.
   Dashed on purpose: this is a threshold annotation, not chart grid. */
/* Currently unused: leader-change markers are suspended while crossoverSeries
   still prices each option against a different car (see the note in
   ui/crossover-chart.js). Kept alongside layoutCrossoverLabels for when the
   markers return. */
.crossover-chart .crossover-line {
  stroke: var(--ink-faint);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}

/* 13.5 viewBox units lands at about 10.8px on screen — 9 rendered at 7.2px,
   which is below what anyone should be asked to read for a dollar figure. */
.crossover-chart .axis-label {
  fill: var(--ink-faint);
  font-family: var(--font-mono);
  font-size: 13.5px;
}

/* The FBT cliff. Warn-coloured because it marks a discontinuity in the tax
   treatment, not another crossover — the novated line stops climbing here
   for a legal reason rather than a financial one. */
/* An annotation, not a control: no pointer cursor, not in the tab order, and
   nothing to click. Hovering anywhere on the marker reveals the explanation
   with no transition delay — a native <title> waits about a second first,
   which is long enough that most people never see it. */
.crossover-chart .chart-marker { cursor: default; }

.crossover-chart .chart-marker__hit {
  fill: transparent;
  pointer-events: all;
}

/* The hidden panel behind the "i" markers. The axis explainers used to share
   it; they are HTML now (see .axis-key__tip) and have their own. */
.crossover-chart .chart-tip {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.crossover-chart .chart-marker:hover .chart-tip {
  opacity: 1;
  visibility: visible;
}

/* A hovered marker's tooltip must sit above the other marker's badge and
   rule, not behind them. */
.crossover-chart .chart-marker:hover { isolation: isolate; }

.crossover-chart .chart-tip__box {
  fill: var(--ink);
  opacity: 0.96;
}

/* 16.4 viewBox units, not pixels: the chart's 752-unit viewBox renders at
   about 600px, so this lands at roughly 13.1px on screen — the same as
   .disclaimer. Paired with TIP_CHAR_WIDTH in ui/crossover-chart.js, which
   sizes the box around the text; change the two together. */
.crossover-chart .chart-tip__text {
  fill: #fff;
  font-family: var(--font-text);
  font-size: 16.4px;
}

.crossover-chart .chart-marker__line {
  stroke-width: 1;
  stroke-dasharray: 1 3;
  opacity: 0.7;
}

/* The cliff is warn-coloured: it marks a discontinuity in the tax treatment,
   something to be careful of. The entry point is not a hazard — it just says
   where a line begins — so it takes that option's own identity colour
   instead, tying the badge to the line it explains. */
.crossover-chart .chart-marker--cliff .chart-marker__line { stroke: var(--warn); }
.crossover-chart .chart-marker--cliff .chart-marker__badge { fill: var(--warn); }

.crossover-chart .chart-marker--entry .chart-marker__line { stroke: var(--line-loan); }
.crossover-chart .chart-marker--entry .chart-marker__badge { fill: var(--line-loan); }

.crossover-chart .chart-marker__glyph {
  fill: #fff;
  font-family: var(--font-text);
  font-size: 9px;
  font-weight: 700;
  font-style: italic;
  pointer-events: none;
}

.crossover-chart .chart-marker:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* Names what each axis measures, below the chart rather than on it. Quieter
   than the tick values themselves — you read a tick to get a number, the key
   only once to orient. Real CSS pixels now, not viewBox units, so it no
   longer has to be pre-divided by the chart's scale factor. */
.axis-key {
  margin: var(--space-3) 0 0;
  display: grid;
  gap: 0.2em;
  font-size: var(--text-xs);
  line-height: 1.4;
  color: var(--ink-soft);
}

.axis-key__row {
  display: flex;
  gap: 0.4em;
  /* Each row is the affordance for its own explainer. */
  cursor: help;
}

.axis-key__axis {
  font-family: var(--font-mono);
  color: var(--ink-faint);
  white-space: nowrap;
}

.axis-key__label {
  margin: 0;
}

/* Fixed, so it escapes the chart panel and is positioned straight from the
   pointer's client coordinates by bindAxisKeyTracking — same down-and-right
   offset the SVG tooltips use, so the cursor never covers the first words. */
.axis-key__tip {
  position: fixed;
  z-index: 20;
  max-width: min(30rem, calc(100vw - 2rem));
  padding: 0.5em 0.7em;
  border-radius: 4px;
  background: var(--ink);
  color: #fff;
  font-size: var(--text-sm);
  line-height: 1.45;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.axis-key__row:hover .axis-key__tip {
  opacity: 0.96;
  visibility: visible;
}

/* =========================================================================
   Chart notes — the same explanations the hover tooltips carry, in text.
   A tooltip needs a pointer, and the viewport where this chart is smallest and
   hardest to read is the one with no pointer at all. Closed by default: four
   paragraphs under a chart most readers will simply look at.
   ========================================================================= */

.chart-notes {
  margin-top: var(--space-3);
  font-size: var(--text-sm);
  line-height: 1.5;
  color: var(--ink-soft);
}

.chart-notes__summary {
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink);
}

.chart-notes__list {
  margin: var(--space-3) 0 0;
  display: grid;
  gap: var(--space-3);
}

.chart-notes__term {
  display: flex;
  align-items: baseline;
  gap: 0.4em;
  font-weight: 600;
  color: var(--ink);
}

.chart-notes__body {
  margin: 0.15em 0 0;
  max-width: 62ch;
}

/* The glyph its badge draws on the chart, at the size the badge draws it — this
   is the key those two markers never had. Both used to be a lowercase "i" in
   different colours, so there was nothing to key. */
.chart-notes__glyph {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  width: 1.25em;
  height: 1.25em;
  border-radius: 50%;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 700;
  color: #fff;
}

.chart-notes__glyph--cliff { background: var(--warn); }
.chart-notes__glyph--entry { background: var(--line-loan); }

.crossover-chart .axis-label--crossover {
  fill: var(--ink-soft);
  font-weight: 600;
}

.crossover-chart .line {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.crossover-chart .line-novated { stroke: var(--line-lease); }
.crossover-chart .line-loan { stroke: var(--line-loan); }
.crossover-chart .line-upfront { stroke: var(--line-cash); }

.crossover-chart .marker,
.crossover-chart .end-dot {
  stroke: var(--paper-raised);
  stroke-width: 2;
}

.crossover-chart .marker-novated,
.crossover-chart .end-dot-novated { fill: var(--line-lease); }
.crossover-chart .marker-loan,
.crossover-chart .end-dot-loan { fill: var(--line-loan); }
.crossover-chart .marker-upfront,
.crossover-chart .end-dot-upfront { fill: var(--line-cash); }

.crossover-chart .leader-line {
  stroke: var(--ink-faint);
  stroke-width: 1;
}

/* Direct end-labels render in ink, never the series colour — the adjacent
   dot carries identity, so the text itself stays legible as text. */
/* 15 viewBox units, about 12px on screen. These name the lines, so they are
   the labels most worth reading at a glance. */
.crossover-chart .end-label {
  fill: var(--ink-soft);
  font-family: var(--font-text);
  font-size: 15px;
  font-weight: 600;
}

/* I7: marks where the user's own budget sits on the chart. Solid and flagged
   rather than dashed, so it reads as "you are here" and not as another
   threshold — now the only vertical rule besides the FBT cliff, since the
   leader-change markers are suspended. */
.crossover-chart .budget-marker__line {
  stroke: var(--ink);
  stroke-width: 1.5;
}

.crossover-chart .budget-marker__flag {
  fill: var(--ink);
}

/* Issue 3: nothing affordable at any sampled budget. Deliberately neutral
   (ink-soft, not one of the three option hues) plus a diagonal hatch — a
   texture channel, not just another flat colour — so this reads as "no
/* 1.2rem/700 clears the WCAG large-text bold threshold (14pt / 18.66px),
   which matters here: white text is ~4.1:1 on lease, ~7.7:1 on loan and
   ~4.6:1 on cash — all clear the large-text floor, none clear body-size
   (4.5:1), which is why this stays bold/large rather than shrinking. Every
   band always carries this label — a full word at >=16% width, a one- or
   two-character abbreviation (OPTION_ABBR) below that — so identity never
/* I7: same budget marker as the desktop chart's .budget-marker__line,
   expressed as an absolutely-positioned strip since the winner band isn't
   SVG. A thin light stripe plus a small triangular flag at the top reads
.rates-panel__intro {
  margin: 0 0 var(--space-4);
  font-size: var(--text-sm);
  color: var(--ink-soft);
}

/* The grid sits on the disclosure body, not on .rates-panel, so wrapping the
   fields in <details> doesn't leave the grid with a single child. */
.rates-disclosure__body {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
  margin-top: var(--space-4);
}

.rates-disclosure__body .rates-panel__intro {
  grid-column: 1 / -1;
}

.rates-disclosure__summary {
  cursor: pointer;
  font-weight: 600;
  font-size: var(--text-md);
  color: var(--ink);
  list-style: none;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.rates-disclosure__summary::-webkit-details-marker { display: none; }

/* Own triangle, so the affordance is identical across browsers and rotates
   to signal state. */
.rates-disclosure__summary::before {
  content: '';
  width: 0;
  height: 0;
  border-left: 5px solid currentColor;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform 120ms ease;
}

.rates-disclosure[open] > .rates-disclosure__summary::before {
  transform: rotate(90deg);
}

.rates-disclosure__summary:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 3px;
  border-radius: 4px;
}

.rate-field__provenance {
  margin: var(--space-1) 0 0;
  font-size: var(--text-xs);
  line-height: 1.45;
  color: var(--ink-faint);
}

.rate-field__reset {
  margin-top: var(--space-2);
  border: none;
  background: none;
  padding: 0;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--line-loan);
  cursor: pointer;
}

.rate-field__reset:hover { text-decoration: underline; }

@media (min-width: 640px) {
  .rates-disclosure__body { grid-template-columns: repeat(2, 1fr); }
}

.skeleton-note {
  margin: 0;
  color: var(--ink-faint);
  font-size: var(--text-sm);
  line-height: 1.5;
}

/* =========================================================================
   Section 3 — cars that match
   ========================================================================= */

.car-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* Step 3 spans the full page width from 900px (see the layout section), so the
   shortlist becomes a grid rather than one long column of cards in a wide, mostly
   empty panel. minmax so it reflows with the width instead of needing a
   breakpoint per column count.

   This has to sit AFTER the flex rule above, not in the layout section's media
   query where it started: a media query adds no specificity, so `.car-list`
   declared later in the file simply won — the grid never applied and the cards
   stayed in a single column. */
@media (min-width: 900px) {
  .car-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    align-items: start;
  }
}

.car-card {
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  /* The figure below is full-bleed to the card's edges; overflow clips its
     square corners against the card's own rounded ones. */
  overflow: hidden;
}

/* Full-bleed across the top of the card, not beside the text: a card has
   height to spare and not width, which is the same reasoning that removed
   the old body-type silhouette (see renderCards) but points the other way
   for a photograph sized to fill a lane rather than sit inline with a line
   of text. */
.car-figure {
  margin: 0;
  /* Matches .car-card's corners, which is the whole requirement — the figure
     is full-bleed to the card's top edge, so a mismatch shows as a sliver of
     card behind the image. Both are var(--radius) now; the card carried a
     literal 8px against the token's 10px until the two were harmonised. */
  border-radius: var(--radius) var(--radius) 0 0;
  overflow: hidden;
  background: var(--paper);
  aspect-ratio: 3 / 2;
}

.car-figure img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.car-body {
  /* Was on .car-card itself, which would inset the figure above by the same
     amount and break the full-bleed effect. The card's own edge stays bare;
     only the text content gets breathing room. */
  padding: var(--space-3);
}

/* Three totals for one car: the comparison step 2 cannot make, because there
   every option priced a different vehicle. */
.car-costs {
  width: 100%;
  margin-top: var(--space-2);
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.car-costs caption {
  text-align: left;
  color: var(--ink-faint);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding-bottom: var(--space-1);
}

.car-costs th {
  text-align: left;
  vertical-align: top;
  font-weight: 400;
  color: var(--ink-soft);
  padding: 0.2em var(--space-2) 0.2em 0;
  white-space: nowrap;
}

.car-costs td {
  text-align: right;
  padding: 0.2em 0;
}

/* The headline figure for the row: a monthly cost for the two financed
   options, the up-front outlay for cash. This is the mono treatment the term
   total used to have — the table now leads with the number the reader can
   check against the budget slider, and the total supports it. */
.car-costs__lead {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--text-md);
  color: var(--ink);
}

/* A requirement rather than a cost. Quieter than the figures around it: the
   number is what this option would need, not what the reader would pay, and it
   should not be read down the column alongside real totals. */
.car-costs__lead--blocked {
  font-size: var(--text-sm);
  color: var(--ink-faint);
}

/* Cash's running cost. Its own line rather than part of the headline: the two
   numbers are different kinds of money and reading them as one total is the
   mistake this row exists to prevent. */
.car-costs__aside {
  display: block;
  font-family: var(--font-mono);
  color: var(--ink-soft);
}

/* Demoted from the headline. Still mono — it is a figure people compare across
   cards — but no longer the first thing the eye lands on. */
.car-costs__total {
  display: block;
  font-family: var(--font-mono);
  color: var(--ink-soft);
}

/* The period and the after-resale qualifier, said once for the whole table.
   Not uppercased with the rest of the caption: it is a sentence, and small
   caps at 0.68rem is where legibility goes to die. */
.car-costs__caption-note {
  display: block;
  margin-top: 0.15em;
  text-transform: none;
  letter-spacing: 0;
  font-size: var(--text-xs);
}

.car-costs tr.is-winner th,
.car-costs tr.is-winner td {
  font-weight: 600;
  color: var(--ink);
}

/* How much of each dollar survives as resale. Quieter than the total: it is a
   tiebreaker between similarly-priced cars, not the headline. */
.car-costs__ratio {
  display: block;
  color: var(--ink-faint);
  font-size: var(--text-xs);
  line-height: 1.3;
}

/* The residual is a lump sum due on the last day of the term, and nothing in
   the monthly affordability test accounts for it. */
.car-balloon {
  margin: var(--space-2) 0 0;
  font-size: var(--text-sm);
  line-height: 1.4;
  color: var(--ink-soft);
}

.car-balloon.is-short {
  color: var(--warn);
  font-weight: 500;
}

/* A PHEV keeps its price band, banded on list price like everything else, so
   this is the only place a real monthly cost above the budget surfaces. */
.cost-row__warn {
  display: block;
  font-size: var(--text-xs);
  color: var(--warn);
  font-weight: 500;
}

/* Sits under the cost table rather than the specs line, because it explains
   the novated figures just above it, not the car itself. */
.car-phev-note {
  margin: var(--space-2) 0 0;
  font-size: var(--text-sm);
  line-height: 1.4;
  color: var(--warn);
}

/* The cards are not in price order — the at-budget ones lead — so each says
   where it sits rather than leaving the reader to infer it from the sequence. */
.car-card__band {
  margin: 0 0 var(--space-1);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* At-budget cars answer the question the page has been working out, so they
   lead the list and carry the same accent as the winning option tile. */
.car-card--at {
  border-color: var(--line-lease);
}

.car-card--at .car-card__band {
  color: var(--line-lease);
}

/* Above budget is not affordable — dashed so it never reads as a
   recommendation, especially now that it is no longer last by price alone. */
.car-card--above {
  border-style: dashed;
}

.car-body h3 {
  margin: 0;
  font-size: var(--text-lg);
}

.car-specs {
  margin: 0.2em 0 0;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--ink-soft);
}

.car-reason {
  margin: 0.3em 0 0;
  font-size: var(--text-sm);
  color: var(--ink-faint);
}

.car-other-trims {
  margin: 0.2em 0 0;
  font-size: var(--text-xs);
  color: var(--ink-faint);
  font-style: italic;
}

/* The review disclosure had no size of its own, so it inherited the body — which
   made "Why this one" the largest text on the card after its title, above the
   figures the card exists to show. It is a way in to more detail, not a heading. */
.car-body details {
  margin-top: var(--space-2);
  font-size: var(--text-sm);
}

.car-body details summary {
  cursor: pointer;
  color: var(--ink-soft);
}

.car-body details p {
  margin: var(--space-2) 0 0;
  color: var(--ink-soft);
}

.car-body .pros,
.car-body .cons,
.car-body .sources {
  margin: var(--space-2) 0 0;
  padding-left: 1.1em;
  color: var(--ink-soft);
}

.car-body .sources {
  padding-left: 0;
  font-size: var(--text-xs);
  list-style: none;
}

/* =========================================================================
   Sticky mobile summary bar — visible only below 900px
   ========================================================================= */

/* A <button> since item 28, so the scroll it performs has a keyboard path. The
   first three declarations undo what being a button brings with it — a shrink-to
   -fit box, a platform border, and centred text — none of which this full-width
   bar wants. `font: inherit` is already handled by the base reset. */
.summary-bar {
  width: 100%;
  border: none;
  text-align: left;
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--ink);
  color: var(--paper-raised);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.12);
}

/* Same rule as the verdict tiles: the bar names a winning option in words, so
   its one piece of colour has to be that option's own. The modifier is written
   by ui/app.js's renderSummaryBar.

   The pale tints rather than the line colours, though: this bar's ground is
   --ink, and --line-loan (#10558f) on #161b1f is two dark colours on top of
   each other. The tints were mixed to sit against paper, but as a foreground
   on near-black they are exactly what a small glyph needs, and they keep
   enough hue to still read as orange/blue/purple. */
.summary-bar--novated { --option-tint: var(--line-lease-bg); }
.summary-bar--loan { --option-tint: var(--line-loan-bg); }
.summary-bar--upfront { --option-tint: var(--line-cash-bg); }

/* Fallback for the states that name no winner at all — no salary entered yet,
   or nothing reachable — where the arrow belongs to no option. */
.summary-bar__arrow { color: var(--option-tint, var(--paper)); font-weight: 700; }

@media (min-width: 900px) {
  .summary-bar { display: none; }
}

/* =========================================================================
   Footer
   ========================================================================= */

.site-footer {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-5) var(--space-4) var(--space-6);
  color: var(--ink-soft);
  font-size: var(--text-sm);
  text-align: center;
}

.site-footer p { margin: 0; }

/* Selector carries the element too, so it out-specifies `.site-footer p`
   above without reaching for !important. */
.site-footer p.site-footer__colophon {
  margin-top: var(--space-2);
  color: var(--ink-faint);
}

/* Same reasoning as .site-footer__colophon above: without its own
   margin-top this paragraph sits flush against the colophon line rather
   than reading as a third, separate line. */
.site-footer p.site-footer__credits {
  margin-top: var(--space-2);
}

/* =========================================================================
   Tabs — "Find a car" / "Compare". Task 6 built the roving-tabindex
   behaviour (ui/tabs.js) and the markup. Originally styled as a bare strip
   between </header> and <main>; moved into <header class="site-header">
   (index.html) as header furniture instead — it now sits right after
   .route-rule and supplies the header's own terminating edge, rather than
   reading as scaffolding bolted on below a header that already looked
   finished on its own.
   ========================================================================= */

.tablist {
  display: flex;
  gap: var(--space-2);
  max-width: 1200px;
  margin: 0 auto;
  /* No horizontal padding: .tab-button's own padding-left already supplies
     a var(--space-4) inset. .site-header__inner and .sections share this
     same max-width + `margin: 0 auto`, so their content also starts one
     var(--space-4) in from the shared box edge — giving the tablist a
     second var(--space-4) of its own, on top of the button's, is exactly
     what put the first tab's label one --space-4 further in than the
     wordmark above it and the cards below it. */
  padding: var(--space-3) 0 0;
  /* The header's terminating edge (.site-header no longer carries its own
     border-bottom) — so the selected tab's underline below is the last
     line before <main>, not a second hairline stacked under an existing
     one. */
  border-bottom: 1px solid var(--hairline);
}

.tab-button {
  padding: var(--space-3) var(--space-4);
  border: none;
  /* Invisible on the unselected/transparent-fill buttons, but gives the
     selected tab's --paper fill (below) rounded top corners, so it reads
     as a distinct tab shape poking up into the header rather than a flat
     rectangle. */
  border-radius: var(--radius) var(--radius) 0 0;
  /* Sits on the tablist's own hairline rather than adding a second one, so a
     selected tab's border below can replace it exactly rather than stacking
     on top of it. */
  margin-bottom: -1px;
  border-bottom: 3px solid transparent;
  background: none;
  font-size: var(--text-md);
  font-weight: 500;
  color: var(--ink-soft);
  cursor: pointer;
}

.tab-button:hover { color: var(--ink); }

/* Colour is not the identity channel here — a reader in greyscale, or one
   who cannot tell --ink from --ink-soft at a glance, still gets a heavier
   weight, a solid underline, AND a filled shape: the selected tab's own
   background switches from the header's --paper-raised to --paper — the
   page body's own background colour — so it visually reads as part of the
   page reaching up into the header, not just a coloured label. Three
   non-colour channels for one state, on purpose. aria-selected (not a
   class) because applyTab (ui/tabs.js) sets the attribute directly; this
   only reads it. */
.tab-button[aria-selected="true"] {
  background: var(--paper);
  color: var(--ink);
  font-weight: 700;
  border-bottom-color: var(--ink);
}

/* The hiding bug: #panel-find carries `class="tab-panel sections"`, and
   .sections sets `display: flex` (and `display: grid` from 900px). An
   author-origin declaration always beats the user-agent `[hidden] {
   display: none }` rule, at any specificity, so plain `.sections` alone
   never actually hid the Find panel — it stayed laid out, stacked above
   whichever panel was "showing". #panel-compare never had the problem
   because it carries only `tab-panel` and wraps its own content in a
   separate `.sections` div (`#compare-panel`, below).
   `.sections` alone is one class in specificity terms (0,1,0);
   `.tab-panel[hidden]` combines a class and an attribute selector (0,2,0),
   which outranks it regardless of source order — and regardless of how
   many more display-setting classes a future panel picks up, since it
   would need two of them at once to tie. Same fix pattern as
   `.phev-options[hidden]` above, generalised from one class to any. */
.tab-panel[hidden] { display: none; }

/* =========================================================================
   Compare tab — Tasks 5-9 built the behaviour; this is its only styling.
   ========================================================================= */

/* #compare-panel reuses `.sections` for the max-width/padding/gap it shares
   with the Find tab's own wrapper — but the Find tab's `.sections` grid
   (900px+, see the Layout section above) was built for *three* section
   children (a 250px rail, a 1fr column, and a full-width row), sized and
   spanned accordingly. #compare-panel holds exactly one section. Left
   alone, that section would simply land in the grid's first cell — the
   250px rail — and the whole tab would run in a phone-width column on a
   1280px screen. An id selector (1,0,0) always outranks a class (0,1,0), so
   `#compare-panel` overrides `.sections` here regardless of viewport,
   dropping the grid back to a plain block — and the one child section is
   free to lay itself out using its own full width. */
@media (min-width: 900px) {
  #compare-panel { display: block; }
}

/* Slots — up to three search boxes, one per car. Stacked on a phone; three
   across from the same 701px point the row-count breakpoint below uses, so
   the whole tab settles into its "mobile" shape at one width rather than
   several. */
.compare-slots {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

@media (min-width: 701px) {
  .compare-slots {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }
}

/* The positioning context for its suggestion listbox (.ac__list, below) —
   the dropdown belongs to this card, not to the page. */
.compare-slot {
  position: relative;
  padding: var(--space-3);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: var(--paper-raised);
}

.compare-slot--filled {
  display: flex;
  flex-direction: column;
  gap: 0.2em;
}

.compare-slot__label {
  display: block;
  margin-bottom: var(--space-1);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink-soft);
}

/* Matches `.field input` (Section 1) exactly — a search box is still a text
   field, and the two should not read as different controls. */
.compare-slot__input {
  width: 100%;
  padding: 0.5em 0.7em;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  font-size: var(--text-md);
}

.compare-slot__input:focus { background: var(--paper-raised); }

.compare-slot__name {
  margin: 0;
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--ink);
}

.compare-slot__variant {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--ink-soft);
}

.compare-slot__clear {
  align-self: flex-start;
  margin-top: var(--space-2);
  padding: 0.3em 0.7em;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink-soft);
  font-size: var(--text-xs);
  cursor: pointer;
}

.compare-slot__clear:hover {
  border-color: var(--ink-faint);
  color: var(--ink);
}

/* Suggestions — the listbox for one slot's combobox. Absolutely positioned
   under its input, above everything below it on the page (the table can
   otherwise sit right underneath a short slot card). z-index 20 matches
   .axis-key__tip elsewhere in this file — the same "floats over the page"
   tier, reused rather than inventing a new one. */
.ac__list {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 20;
  margin-top: var(--space-1);
  /* A scroll cap: SEARCH_LIMIT (ui/vehicle-search.js) allows up to eight
     results, and eight full rows would push the bench and table around
     every time someone typed. The list scrolls internally instead. */
  max-height: 16rem;
  overflow-y: auto;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  background: var(--paper-raised);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}

.ac__group + .ac__group { border-top: 1px solid var(--hairline); }

/* Visually subordinate to the options it groups — a caption, not a second
   tier of result. Same treatment as .car-costs caption and
   .field-group__optional: uppercase, letter-spaced, faint, smallest step. */
.ac__group-label {
  margin: 0;
  padding: var(--space-2) var(--space-2) var(--space-1);
  background: var(--paper);
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
}

.ac__option {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2);
  font-size: var(--text-sm);
  color: var(--ink);
  cursor: pointer;
}

.ac__option:hover,
.ac__option[aria-selected="true"] {
  background: var(--paper);
}

/* The virtual-focus marker for the arrow-key-driven option (tracked by
   aria-activedescendant, not real DOM focus — see bindAutocomplete's own
   comment on why aria-activedescendant exists at all). Weight, not colour
   alone, carries "this is the one Enter would pick". */
.ac__option[aria-selected="true"] { font-weight: 600; }

/* The variant name is the part of the option a reader scans for; .ac__meta
   (body type, price, PHEV tag) is the supporting detail beside it. */
.ac__variant { font-weight: 500; }

.ac__meta {
  flex: 0 0 auto;
  font-size: var(--text-xs);
  color: var(--ink-faint);
}

.ac__empty {
  margin: 0;
  padding: var(--space-2);
  font-size: var(--text-sm);
  color: var(--ink-faint);
}

/* Bench — pill chips above the table, one per car, shown only once three are
   picked. Matches .preset's pill treatment (Section 1) rather than
   inventing a second button shape for the same idea. */
.compare-bench {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  margin-bottom: var(--space-4);
}

/* renderBench (ui/compare-tab.js) sets this container's innerHTML to '' —
   not `hidden` — whenever there is no bench to show. Without :empty the
   margin above would still open a gap for a chip row that isn't there. */
.compare-bench:empty { display: none; margin-bottom: 0; }

.compare-bench__hint {
  flex-basis: 100%;
  margin: 0;
  font-size: var(--text-sm);
  color: var(--ink-faint);
}

.compare-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.3em 0.8em;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: var(--paper-raised);
  color: var(--ink);
  font-size: var(--text-sm);
  cursor: pointer;
}

.compare-chip:hover { border-color: var(--ink-faint); }

/* The car currently off screen. Dashed border plus dimmed text — two
   non-colour channels — rather than a colour swap, so "this one is benched"
   survives greyscale the same way the table's winner marker has to. */
.compare-chip--benched {
  border-style: dashed;
  color: var(--ink-faint);
}

/* Warns that the benched car appears in a callout below — same family of
   fact as .compare-caveat, so it borrows the same accent rather than
   introducing a second "pay attention" colour. */
.compare-chip__dot {
  width: 0.5em;
  height: 0.5em;
  border-radius: 50%;
  background: var(--warn);
}

/* Table. Row-label column fixed, the car columns splitting whatever is
   left — table-layout: fixed does that on its own once one column has an
   explicit width, but only reads that width from the FIRST row (the CSS2.1
   fixed-layout algorithm), which is why the width sits on the header row's
   cell rather than on .compare-row__label. Wrapped in its own scrolling
   container (below) as a last resort, but width: 100% plus the fixed
   layout is what keeps it from ever needing to. */
.compare-table {
  margin-top: var(--space-4);
  /* Never the page body: if three money columns and a label ever don't fit
     a narrow viewport, this is where the scrollbar has to appear instead. */
  overflow-x: auto;
}

.compare-grid {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: var(--text-sm);
}

.compare-grid thead th:first-child { width: 6.5rem; }

.compare-head {
  padding: var(--space-2) var(--space-3);
  text-align: left;
  font-weight: 700;
  color: var(--ink);
}

.compare-head__variant {
  display: block;
  font-weight: 400;
  font-size: var(--text-xs);
  color: var(--ink-faint);
}

/* Rounded on all four corners, unlike .car-figure: this image sits inside a
   plain <th> with padding around it rather than full-bleed against a card
   edge, so there is no top edge for it to meet. */
.compare-head__img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  border-radius: var(--radius);
  margin-bottom: var(--space-2);
}

.compare-group__label {
  padding: var(--space-3) var(--space-2) var(--space-1);
  background: var(--paper);
  text-align: left;
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
}

.compare-row__label {
  padding: var(--space-2) var(--space-3) var(--space-2) 0;
  border-top: 1px solid var(--hairline);
  text-align: left;
  vertical-align: top;
  font-weight: 500;
  color: var(--ink-soft);
}

.compare-cell {
  padding: var(--space-2) var(--space-3);
  border-top: 1px solid var(--hairline);
  text-align: right;
  vertical-align: top;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

/* The best value in the row. Weight plus a glyph — not a colour swap — so
   this survives greyscale exactly like the selected tab has to; a chequered
   background alone would vanish under the colour-filter check in the
   verification steps. */
.compare-cell--win {
  font-weight: 700;
  background: rgba(22, 27, 31, 0.045); /* --ink, tinted, matching the
    rgba(0,0,0,…) shadows already used elsewhere in this file rather than a
    new named colour */
}

.compare-cell--win::before {
  content: '✓';
  margin-right: 0.35em;
  color: var(--ink-soft);
}

/* Caveats and the off-screen note share this row shape (see the comment on
   caveatMarkup in ui/compare-tab.js — compare-caveat-row is load-bearing for
   both), but the two callouts say different things and must not be
   mistaken for one another:
     .compare-caveat    — this row can't be read straight across (amber,
                           the same --warn pairing the rest of the app uses
                           for "pay attention", never introduced for this
                           feature alone).
     .compare-offscreen — the benched car would have won this row (neutral
                           grey, and italic, so the distinction survives
                           even in greyscale where the tint alone would not).
   Both span the full row via colspan, set by ui/compare-tab.js. */
.compare-caveat,
.compare-offscreen {
  padding: var(--space-2) var(--space-3);
  text-align: left;
  font-size: var(--text-sm);
  line-height: 1.4;
}

.compare-caveat {
  border-left: 3px solid var(--warn);
  background: var(--warn-bg);
  color: var(--ink-soft);
}

.compare-offscreen {
  border-left: 3px dashed var(--ink-faint);
  background: var(--paper);
  color: var(--ink-faint);
  font-style: italic;
}

/* compare-caveat-row itself carries no rule here: the <tr> paints nothing —
   the colspan'd <td> above does all of it. The class stays on the <tr> in
   the markup (ui/compare-tab.js) anyway, as the named hook through which
   anything that ever needs to address "an annotation row" as a whole (both
   kinds) can reach. */

/* Prose — one section per car, always rendered for every filled slot
   (renderComparison keeps the benched car's prose in the DOM so bringing it
   back on screen doesn't need a re-render of anything but the table and
   bench). Side by side once there's room; stacked on a phone.

   701px matches COMPARE_TWO_UP_MAX_PX in ui/app.js — that constant decides
   whether the table itself is showing two cars or three, and this has to
   agree or the prose below the table would be arguing with it about how
   many cars are actually on screen. Change one, change the other. */
.compare-prose {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-top: var(--space-5);
}

@media (min-width: 701px) {
  .compare-prose {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  }
}

/* The car ui/app.js has benched below 701px. Its prose stays in the DOM (see
   above) so tapping its chip can bring it straight back with no re-render;
   until then it costs nothing on screen. */
.compare-prose__car[data-benched="true"] { display: none; }

.compare-prose__car {
  padding: var(--space-4);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: var(--paper-raised);
}

.compare-prose__car h3 {
  margin: 0 0 var(--space-2);
  font-size: var(--text-lg);
}

.compare-prose__car > p {
  margin: 0 0 var(--space-2);
  font-size: var(--text-sm);
  color: var(--ink-soft);
}

.compare-pros,
.compare-cons {
  margin: var(--space-2) 0 0;
  padding-left: 1.1em;
  font-size: var(--text-sm);
  color: var(--ink-soft);
}

.compare-prose__car details {
  margin-top: var(--space-2);
  font-size: var(--text-sm);
}

.compare-prose__car summary {
  cursor: pointer;
  color: var(--ink-soft);
}

/* =========================================================================
   Credits page (public/credits.html) — the licence-attribution list for the
   Wikimedia Commons photographs. Everything else on that page (the header,
   the wordmark, .section-heading, .skeleton-note) reuses rules that already
   exist above; these are the only new ones, and only this page uses them.
   All values are existing tokens — no new colour, size or spacing is
   introduced here.
   ========================================================================= */

.credits-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* Same card look as .sections > section on the main page (paper-raised
   panel, hairline border, one radius) but written as its own rule rather
   than reusing .sections: that class switches to a fixed 250px + 1fr grid
   at 900px (sized for the calculator's three-section layout), which would
   crush this page's single section into the narrow rail column. */
.credits-panel {
  background: var(--paper-raised);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: var(--space-5);
}

.credits-intro {
  max-width: 60ch;
  margin: 0 0 var(--space-4);
  color: var(--ink-soft);
}

.credits-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.credit-item {
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--hairline);
}

.credit-item:last-child {
  padding-bottom: 0;
  border-bottom: none;
}

.credit-item__car {
  margin: 0 0 var(--space-1);
  font-size: var(--text-lg);
  font-weight: 600;
}

.credit-item__meta {
  margin: 0;
  color: var(--ink-soft);
  font-size: var(--text-sm);
}

.credit-item__note {
  margin: var(--space-1) 0 0;
  color: var(--ink-faint);
  font-size: var(--text-xs);
}

.credits-empty {
  color: var(--ink-faint);
}

.credits-back {
  margin: 0;
}
