/* app.css — mobile-first, "bento" layout: a toned page with rounded tiles,
   one blue accent, Plus Jakarta Sans. Follows the system theme; dark is the
   fallback because this is largely a camera app, and a white flash before the
   viewfinder is unpleasant outdoors at night. */

/* Self-hosted rather than from Google Fonts: the page is cross-origin isolated
   (COEP require-corp), works offline from the service worker, and promises
   that nothing but registry lookups leaves the phone. Latin subset only — the
   Hebrew in vehicle names falls through to the system font, as does ₪. */
@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('../fonts/plus-jakarta-sans-latin.woff2') format('woff2');
}

/* Hebrew, from fonts already on the device (nothing is downloaded). Windows
   answers 'Segoe UI' and Arial at weight 800 with their Black faces, which have
   no Hebrew, and Chromium then draws the Hebrew in Times New Roman. These map
   every heavy weight to the regular bold face instead. Where none of the local
   names exist (phones), the face does not load and the stack below carries on
   to the system font as before. */
@font-face {
  font-family: 'Rechev Hebrew';
  font-weight: 700 900;
  unicode-range: U+0590-05FF, U+FB1D-FB4F;
  src: local('Segoe UI Bold'), local('SegoeUI-Bold'), local('Arial Bold'), local('Arial-BoldMT');
}
@font-face {
  font-family: 'Rechev Hebrew';
  font-weight: 100 600;
  unicode-range: U+0590-05FF, U+FB1D-FB4F;
  src: local('Segoe UI'), local('SegoeUI'), local('Arial'), local('ArialMT');
}

/* Contrast contract (WCAG AA): every text colour below — --text, --muted,
   --dim and the three status colours — clears 4.5:1 against all three of
   --bg, --surface and --surface-2, in both themes, so a class can move between
   a tile and the page without being re-checked. White text only ever sits on
   the *-fill colours, which clear 4.5:1 against it. */
:root {
  /* Native UI (scrollbars, the plate field, autofill, the caret) takes the
     same theme as the tokens below; without it they stay light on dark. */
  color-scheme: dark light;
  --bg: #0e1014;
  --surface: #1a1d23;
  --surface-2: #252932;
  --border: #2c313b;
  --text: #eceef2;
  --muted: #b4b9c3;
  --dim: #9aa0ab;
  /* A stroke/text blue that reads on dark tiles (focus ring, spinner, links). */
  --accent: #7c97ff;
  /* Fills under white text: the scan tile, the hero, the go button. */
  --accent-fill: #3056e0;
  --accent-fill-strong: #2a4cc7;
  --green: #5cc98f;
  --yellow: #e3b341;
  --red: #f08a8a;
  --red-fill: #b83a3a;
  /* Ownership bar: earlier holders alternate two tints, the current one is solid. */
  --seg-a: #3a4a86;
  --seg-b: #5b75d8;
  --seg-current: var(--text);
  --radius: 14px;
  --tile-radius: 24px;
  --hero-radius: 28px;
  --tap: 48px;

  /* Motion tokens — the transitions.dev scale. Every duration, easing, travel
     and blur below reads from these, and js/motion.js reads the resulting
     computed transitions rather than keeping its own copy of the timings. */
  --duration-stagger: 40ms;    /* per-item stagger offset */
  --duration-micro: 80ms;      /* intent delay, shake segment */
  --duration-quick: 150ms;     /* close, text swap */
  --duration-fast: 250ms;      /* open, page slide */
  --duration-medium: 350ms;    /* panel close, toast close */
  --duration-slow: 400ms;      /* panel open, content reveal */
  --duration-very-slow: 500ms; /* emphasis moments */
  --ease-smooth-out: cubic-bezier(0.22, 1, 0.36, 1); /* open/close, slide */
  --ease-in-out: ease-in-out;  /* text swap, content reveal */
  --ease-linear: linear;       /* spinner */
  --distance-micro: 4px;       /* text swap */
  --distance-base: 8px;        /* page slide */
  --scale-medium: 0.97;        /* toast */
  --blur-small: 2px;           /* text swap, content reveal, toast */
  --blur-medium: 3px;          /* page slide */
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #eef0f3;
    --surface: #ffffff;
    --surface-2: #e6e9ee;
    --border: #e1e4ea;
    --text: #15171c;
    --muted: #4d5360;
    --dim: #5b616d;
    --accent: #2f5bea;
    --accent-fill: #2f5bea;
    --accent-fill-strong: #2549c9;
    --green: #1b7146;
    --yellow: #8a6100;
    --red: #c0352f;
    --red-fill: #c0352f;
    --seg-a: #b7c3ec;
    --seg-b: #7f98ee;
    --seg-current: var(--text);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  /* Latin from the app font, Hebrew from 'Rechev Hebrew' (above), then the system's. */
  font-family: 'Plus Jakarta Sans', 'Rechev Hebrew', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.45;
  overscroll-behavior-y: contain;
  touch-action: manipulation; /* removes the legacy 300ms tap delay */
  overflow-x: clip; /* a page sliding in 8px must not flash a horizontal scrollbar */
}

.view {
  padding:
    calc(env(safe-area-inset-top) + 20px)
    calc(env(safe-area-inset-right) + 16px)
    calc(env(safe-area-inset-bottom) + 32px)
    calc(env(safe-area-inset-left) + 16px);
  max-width: 640px;
  margin: 0 auto;
  transition:
    opacity   var(--duration-fast) var(--ease-smooth-out),
    transform var(--duration-fast) var(--ease-smooth-out),
    filter    var(--duration-fast) var(--ease-smooth-out);
}

/* Home <-> results. Only the arriving page moves: the views are in normal flow
   on a scrolling document, so animating the departing one as well would mean
   lifting it out of flow first. Forward arrives from the right, Back from the
   left, so the direction still reads. Same timing both ways — a page slide is
   one reversible motion, not an open/close pair. No will-change: a lingering
   transform would make the view a containing block for fixed descendants. */
.view.is-page-enter-forward,
.view.is-page-enter-back {
  opacity: 0;
  filter: blur(var(--blur-medium));
  transition: none;
}
.view.is-page-enter-forward { transform: translateX(var(--distance-base)); }
.view.is-page-enter-back { transform: translateX(calc(var(--distance-base) * -1)); }

/* --- page transitions (js/page-fx.js) ---

   Between documents (the landing pages, their tabs, the brand link home) the
   browser keeps the old page on screen until the new one can paint, and the
   blocks both pages share (header, scan tile, search) hold their place. The
   opt-in for that is an inline <style> in index.html's head, not here (it says
   why). Chrome and Safari; elsewhere a plain navigation. */

::view-transition-group(*) {
  animation-duration: var(--duration-slow);
  animation-timing-function: var(--ease-smooth-out);
}

/* Home <-> results: each block of the page is its own layer. A block only one
   page has sinks out quickly or rises in slowly, in reading order, so the new
   page assembles itself instead of appearing. What is left unnamed (cards below
   the fold, hints) rides on the root, which keeps the browser's own cross-fade:
   both snapshots carry the page background, so the blend never shows a gap. */
.app-header { view-transition-name: fx-h1; }
.tile-scan { view-transition-name: fx-h2; }
.search { view-transition-name: fx-h3; }
.recent { view-transition-name: fx-h4; }
.results-header { view-transition-name: fx-r1; }
.tile-hero { view-transition-name: fx-r2; }
.stat-grid { view-transition-name: fx-r3; }

::view-transition-old(*):only-child {
  animation: fx-sink var(--duration-quick) var(--ease-in-out) both;
}
::view-transition-new(*):only-child {
  animation: fx-rise var(--duration-very-slow) var(--ease-smooth-out) both;
}
/* Reading order. The first block waits out the old page's sink. */
::view-transition-new(fx-h1), ::view-transition-new(fx-r1) { animation-delay: calc(var(--duration-stagger) * 2); }
::view-transition-new(fx-h2), ::view-transition-new(fx-r2) { animation-delay: calc(var(--duration-stagger) * 4); }
::view-transition-new(fx-h3), ::view-transition-new(fx-r3) { animation-delay: calc(var(--duration-stagger) * 6); }
::view-transition-new(fx-h4) { animation-delay: calc(var(--duration-stagger) * 8); }

/* The tapped Recent tile and the hero share one name for the length of the
   transition (page-fx.js nameAsHero), so the tile grows into the hero — both
   wear the car's paint — and shrinks back into the grid on Back. */
::view-transition-group(fx-hero) { animation-duration: var(--duration-very-slow); }

@keyframes fx-sink {
  to { opacity: 0; transform: translateY(calc(var(--distance-base) * -0.75)) scale(0.98); filter: blur(var(--blur-small)); }
}
@keyframes fx-rise {
  from { opacity: 0; transform: translateY(calc(var(--distance-base) * 2)); filter: blur(calc(var(--blur-medium) * 2)); }
}

[hidden] { display: none !important; }

.rtl {
  direction: rtl;
  unicode-bidi: isolate;
  text-align: right;
}

/* --- tiles --- */

/* The one surface everything sits on. Also given .card's reveal (below), since
   the enrichment tiles arrive after the page. */
.tile {
  background: var(--surface);
  border-radius: var(--tile-radius);
  padding: 18px;
  transition:
    opacity var(--duration-fast) var(--ease-in-out),
    filter  var(--duration-fast) var(--ease-in-out);
}
.tile.is-entering { opacity: 0; filter: blur(var(--blur-small)); transition: none; }
button.tile { border: 0; font: inherit; color: inherit; text-align: left; cursor: pointer; }
button.tile:active { transform: scale(0.985); }

.view-home, .view-results { display: flex; flex-direction: column; gap: 12px; }
.view-home > .hint { margin-top: -4px; }

/* --- header --- */

.app-header { padding: 4px 4px 8px; display: flex; flex-direction: column; gap: 2px; }
.brand { font-size: 0.9rem; font-weight: 700; color: var(--muted); letter-spacing: 0.01em; }
.app-header h1 { margin: 0; font-size: 2rem; font-weight: 800; line-height: 1.1; letter-spacing: -0.02em; text-wrap: balance; }
.section-title { margin: 12px 4px 8px; font-size: 0.8rem; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--dim); font-weight: 700; }

/* --- search landing pages (/test/, /recall/, /owners/, /scan/) ---
   The home view is RTL on these Hebrew pages (the generator marks it); the
   results follow the device language. The brand is a link home here.
   Both links are 44px tall to tap, without growing the text. */

a.brand {
  text-decoration: none; align-self: flex-start;
  display: inline-flex; align-items: center; min-height: 44px; min-width: 44px;
}
.landing-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.landing-tabs a {
  display: inline-flex; align-items: center; min-height: 44px;
  /* 12px sides: five tabs fit one row on a 360px phone. */
  padding: 6px 12px; border-radius: 999px; background: var(--surface); color: var(--muted);
  text-decoration: none; font-weight: 600; font-size: 0.9rem;
}
.landing-tabs a[aria-current="page"] { background: var(--accent-fill); color: #fff; }
.landing-copy { line-height: 1.6; color: var(--muted); }
.landing-copy p { margin: 0 0 10px; text-wrap: pretty; }
.landing-copy h2 { margin: 16px 0 8px; font-size: 1rem; color: var(--text); }
/* FAQ: native <details>, no JS. Each question is a soft row with a chevron
   that turns as it opens. Where the browser can animate <details>
   (::details-content + interpolate-size), the answer's height glides open;
   elsewhere it opens at once and the answer fades and lifts in. */
.landing-copy details {
  background: var(--surface-2);
  border-radius: var(--radius);
  margin: 0 0 8px;
  transition: background var(--duration-fast) var(--ease-smooth-out);
  interpolate-size: allow-keywords;
}
.landing-copy details[open] { background: color-mix(in srgb, var(--surface-2) 90%, var(--accent)); }
.landing-copy summary {
  list-style: none;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: var(--tap);
  padding: 10px 14px;
  cursor: pointer; color: var(--text); font-weight: 600;
  border-radius: var(--radius);
  -webkit-tap-highlight-color: transparent;
}
.landing-copy summary::-webkit-details-marker { display: none; }
.landing-copy summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* The chevron: two borders of a square, turned. Points down when closed,
   up when open; flex order puts it at the row's far end in RTL too. */
.landing-copy summary::after {
  content: '';
  flex: none;
  width: 8px; height: 8px;
  margin-block-start: -4px;
  /* Physical sides on purpose: logical ones flip in RTL and the chevron would
     point sideways instead of down. */
  border-right: 2px solid var(--dim);
  border-bottom: 2px solid var(--dim);
  transform: rotate(45deg);
  transition: transform var(--duration-fast) var(--ease-smooth-out), border-color var(--duration-fast) var(--ease-smooth-out);
}
.landing-copy details[open] > summary::after {
  transform: translateY(4px) rotate(225deg);
  border-color: var(--accent);
}
.landing-copy details p { margin: 0; padding: 0 14px 14px; }
.landing-copy details[open] p { animation: faq-reveal var(--duration-slow) var(--ease-smooth-out) both; }
@keyframes faq-reveal {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}
@supports selector(::details-content) {
  .landing-copy details::details-content {
    block-size: 0;
    overflow: clip;
    transition:
      block-size var(--duration-slow) var(--ease-smooth-out),
      content-visibility var(--duration-slow) allow-discrete;
  }
  .landing-copy details[open]::details-content { block-size: auto; }
}
.landing-copy a { color: var(--accent); }
.landing-more { margin-top: 12px !important; font-size: 0.9rem; }
/* The homepage's one line of links to those pages, under the search form. Quiet
   like .landing-more: inline links in a paragraph, not another row of buttons. */
.home-checks { padding: 0 4px; color: var(--muted); font-size: 0.9rem; line-height: 1.6; }
.home-checks p { margin: 0; text-wrap: pretty; }
.home-checks a { color: var(--accent); }

/* The section a landing page is named after, placed first in the result. */
.focus-card { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- scan tile --- */

.tile.tile-scan {  /* .tile.x: must outrank button.tile's color: inherit */
  min-height: 212px; padding: 22px;
  border-radius: var(--hero-radius);
  background: var(--accent-fill); color: #fff;
  display: flex; flex-direction: column; justify-content: space-between; align-items: flex-start;
}
.tile-scan:disabled { opacity: 0.5; cursor: default; }
.tile-scan-icon {
  width: 56px; height: 56px; border-radius: 18px;
  background: #fff; color: var(--accent-fill);
  display: flex; align-items: center; justify-content: center;
}
.tile-scan-text { display: flex; flex-direction: column; gap: 6px; }
.tile-scan-title { font-size: 1.5rem; font-weight: 700; }
.tile-scan-lead { font-size: 0.95rem; line-height: 1.4; }

/* --- search --- */

.search { display: flex; flex-direction: column; gap: 12px; }
.search-label { font-size: 0.95rem; font-weight: 700; }
.search-row { display: flex; gap: 8px; }

.plate-input {
  flex: 1 1 auto; min-width: 0;
  height: 56px; padding: 0 18px;
  border: 2px solid transparent;
  border-radius: 18px;
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 1.4rem;   /* >=16px stops iOS Safari zooming on focus */
  font-weight: 700;
  letter-spacing: 0.04em;
}
.plate-input::placeholder { color: var(--dim); font-weight: 500; }
.plate-input:focus { outline: none; border-color: var(--accent); }

.btn-icon {
  flex: 0 0 auto;
  width: var(--tap); height: var(--tap);
  border: 0; border-radius: 16px;
  background: var(--surface); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.btn-go { width: 56px; height: 56px; border-radius: 18px; background: var(--text); color: var(--bg); }
.btn-icon:disabled { opacity: 0.45; cursor: default; }
.btn-icon:focus-visible, .tile:focus-visible, .btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
/* A heading given focus on a page change (main.js focusHeading) is a reading
   position for assistive tech, not a control: no ring. */
h1[tabindex="-1"]:focus, h2[tabindex="-1"]:focus { outline: none; }

/* Still used by the scanner controls, the debug panel, recall actions and the toast. */
.btn {
  min-height: var(--tap);
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-2);
  cursor: pointer;
}
.btn:disabled { opacity: 0.45; cursor: default; }
.btn:active:not(:disabled) { transform: scale(0.985); }
.btn-ghost { background: transparent; color: var(--muted); }

.hint { margin: 8px 0 0; font-size: 0.85rem; color: var(--dim); text-align: center; }

/* --- install --- */

.install { display: grid; grid-template-columns: auto 1fr; gap: 12px 14px; align-items: center; }
.install-icon img { display: block; width: 40px; height: 40px; border-radius: 10px; }
.install-text { min-width: 0; }
.install-title { margin: 0; font-size: 1rem; font-weight: 800; }
.install-lead { margin: 4px 0 0; font-size: 0.85rem; line-height: 1.4; color: var(--muted); }
.install-share { display: inline-block; vertical-align: -3px; }
.install-actions { grid-column: 1 / -1; display: flex; gap: 8px; justify-content: flex-end; }
.install-btn { background: var(--text); color: var(--bg); }

/* --- recents --- */

.chips { display: flex; flex-wrap: wrap; gap: 8px; }  /* ?debug=1 panel buttons */
.recent-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.recent-tile {
  min-height: 116px; padding: 16px;
  display: flex; flex-direction: column; justify-content: space-between; gap: 10px;
}
/* A known car colour (--car, set by render.js paintTile) paints a Recent tile
   and the results hero alike: the whole tile, with a
   sheen so it reads as paint. The text takes the ink render.js picks for that
   paint (data-ink, from carInk, held to 4.5:1 by tests/car-color.test.mjs), and
   the faint ring keeps a black car visible on dark and a white one on light. */
.tile.painted {  /* .tile.x: must outrank .tile's background */
  --ink: #f4f5f7;
  background: var(--car);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--text) 14%, transparent);
  position: relative; isolation: isolate;
}
.painted[data-ink="dark"] { --ink: #15171c; }
.painted::after {
  content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; pointer-events: none;
  background: linear-gradient(155deg, rgb(255 255 255 / 0.22), rgb(255 255 255 / 0) 42%, rgb(0 0 0 / 0.14));
}
.painted .recent-year { color: var(--ink); opacity: 0.8; }
/* The hero's pills sit on the paint, so they take the ink too; the white plate
   badge gets a rim so it still stands off a white car. */
.painted .hero-tag {
  background: color-mix(in srgb, var(--ink) 14%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink) 40%, transparent);
}
.painted .plate-badge { box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.2); }
.painted .recent-badge {
  color: var(--ink); background: color-mix(in srgb, var(--ink) 14%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink) 40%, transparent);
}
/* Multi-coloured: the families' own paints as one sweep, under light ink. The
   orange and gold stops are too light for it on their own, hence the shade. */
.tile.painted[data-color="multi"] {
  background: linear-gradient(rgb(0 0 0 / 0.28), rgb(0 0 0 / 0.28)),
    linear-gradient(135deg, #c8323b, #de7a2b 25%, #c7a44b 45%, #3f7d4b 65%, #2f5fb5 85%, #6c4aa3);
}
.recent-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.recent-badge {
  flex: none; padding: 2px 8px; border-radius: 999px;
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.02em;
  color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent);
}
.recent-badge[data-rarity="6"] {
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 55%, transparent),
    0 0 8px color-mix(in srgb, var(--accent) 30%, transparent);
}
.recent-plate { font-size: 1.05rem; font-weight: 800; letter-spacing: 0.03em; font-variant-numeric: tabular-nums; }
.recent-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.recent-name { font-size: 0.9rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-name.rtl { text-align: left; }
.recent-year { font-size: 0.8rem; color: var(--muted); }

/* --- scanner --- */

/* touch-action: none so a pinch reaches the scanner's own handler instead of
   being taken by the browser as a page zoom. Magnifying the page magnifies the
   same small plate — only zooming the camera changes what the detector sees.
   Note `body` sets `touch-action: manipulation`, which permits pinch-zoom, so
   this override is what actually stops it.

   Set on the container as well as the video because a pinch's two touch points
   do not reliably land on the same element and the browser consults the
   hit-tested one. Scoped to the scanner: the rest of the app still zooms. */
.scanner {
  position: fixed; inset: 0; background: #000; z-index: 100;
  touch-action: none;
  transition: opacity var(--duration-fast) var(--ease-smooth-out);
}

/* A plain fade, deliberately without the panel reveal's travel and blur: the
   overlay covers the whole screen, so sliding it would expose an edge, and
   blurring a live camera feed is expensive on exactly the phones that scan.
   The page underneath stays visible until the fade covers it (main.js), and is
   tappable again the moment a close starts. */
.scanner.is-entering { opacity: 0; transition: none; }
.scanner.is-closing {
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-fast) var(--ease-smooth-out);
}

.camera {
  width: 100%; height: 100%; object-fit: cover; display: block;
  touch-action: none;
}

.scanner-mask { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }

/* Where the detector's box is drawn: corner brackets that snap to the plate,
   with the rest of the frame dimmed (scanner.js _drawBox). Sits above the
   video, below the controls. */
.detection-overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

/* Always the bright green: the camera is dark whatever the theme, and the
   light theme's --green is too deep to read over it. */
.scanner { --green: #4ade80; }

/* An aiming guide, not a crop boundary — the detector finds the plate anywhere
   in frame, so this only suggests where to point: four faint corner marks, no
   dimming. The detected plate gets the bright brackets and the dimming. */
.reticle {
  width: min(78vw, 420px);
  aspect-ratio: 4.5 / 1;   /* Israeli plates are ~520x110mm */
  --c: rgba(255, 255, 255, 0.5);
  background:
    linear-gradient(var(--c) 0 0) top left / 22px 3px,
    linear-gradient(var(--c) 0 0) top left / 3px 22px,
    linear-gradient(var(--c) 0 0) top right / 22px 3px,
    linear-gradient(var(--c) 0 0) top right / 3px 22px,
    linear-gradient(var(--c) 0 0) bottom left / 22px 3px,
    linear-gradient(var(--c) 0 0) bottom left / 3px 22px,
    linear-gradient(var(--c) 0 0) bottom right / 22px 3px,
    linear-gradient(var(--c) 0 0) bottom right / 3px 22px;
  background-repeat: no-repeat;
}

/* The read, painted in as agreement accrues toward a lock, in a fixed panel
   above the controls with a progress bar under it. Not mid-frame: the plate
   can be anywhere, and digits drawn over it hide both. */
.scan-paint {
  position: absolute;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 124px);
  transform: translateX(-50%);
  display: flex; justify-content: center; gap: 3px;
  padding: 12px 20px 20px;
  border-radius: 18px;
  background: rgba(20, 22, 26, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  font-family: ui-monospace, 'SF Mono', 'Cascadia Mono', Consolas, monospace;
  font-size: 1.7rem; font-weight: 700; letter-spacing: 0.04em;
  pointer-events: none;
}
.scan-paint::after {
  content: '';
  position: absolute; left: 20px; right: 20px; bottom: 9px;
  height: 3px; border-radius: 2px;
  background: linear-gradient(to right,
    var(--green) calc(var(--progress, 0) * 100%),
    rgba(255, 255, 255, 0.2) 0);
}

/* Two stacked copies of each character: a dim one that is always there, and a
   bright one clipped from the left. Filling rather than fading matters — a
   fade-in is indistinguishable from the page rendering slowly, whereas a
   left-to-right fill reads as progress toward something. */
.scan-paint-char {
  position: relative;
  color: rgba(255, 255, 255, 0.3);
}
.scan-paint-char::after {
  content: attr(data-character);
  position: absolute; inset: 0;
  color: var(--green);
  clip-path: inset(0 calc(100% - var(--fill, 0) * 100%) 0 0);
}

/* A pill at the top. Its dot is the state at a glance: grey while looking,
   amber while a read is being confirmed, green on lock (main.js is-locked). */
.scan-status {
  position: absolute;
  left: 0; right: 0;
  top: calc(env(safe-area-inset-top) + 16px);
  width: fit-content; max-width: calc(100% - 32px);
  margin: 0 auto;
  padding: 7px 14px 7px 12px;
  border-radius: 999px;
  background: rgba(20, 22, 26, 0.72);
  backdrop-filter: blur(10px);
  color: #fff; font-size: 0.85rem;
  display: flex; align-items: center; gap: 8px;
}
.scan-status:empty { display: none; }
.scan-status::before {
  content: ''; flex: none;
  width: 7px; height: 7px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  transition: background var(--duration-fast) var(--ease-in-out);
}
.scanner:has(.scan-paint:not([hidden])) .scan-status::before { background: #f5b942; }
.scanner.is-locked .scan-status::before { background: var(--green); }

/* ?debug=1 only. Below the status pill. */
.debug-stats {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 64px);
  left: 12px; margin: 0; padding: 8px 10px;
  background: rgba(0, 0, 0, 0.65); color: #7dffa8;
  font-family: ui-monospace, Consolas, monospace; font-size: 11px;
  line-height: 1.5; border-radius: 8px;
}

/* The ?debug=1 telemetry panel on the home view. Reuses .debug-stats' monospace
   readout, but in flow rather than floating over the camera. */
.debug-telemetry { margin-top: 28px; }
.debug-stats-inline {
  position: static;
  overflow-x: auto;
  margin: 0 0 12px;
  white-space: pre;
}
.debug-dump { max-height: 45vh; overflow-y: auto; margin-top: 12px; }

/* Camera-app controls: a large close button in the middle, torch to its left
   and zoom to its right. Placed by grid column, so a phone with no torch or no
   zoom leaves its cell empty and the close button stays centred. */
.scanner-controls {
  position: absolute;
  left: 0; right: 0;
  bottom: calc(env(safe-area-inset-bottom) + 28px);
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 28px;
  padding: 0 24px;
}
.scanner-controls .btn {
  min-height: 0; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  backdrop-filter: blur(8px);
}
.scanner-controls .btn.active { background: var(--accent-fill); }
/* Icon-only on screen; the label stays for screen readers. */
.scan-label {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}
.scan-close {
  grid-column: 2; width: 68px; height: 68px;
  border: 3px solid #fff;
}
.scanner-controls .scan-close { background: transparent; backdrop-filter: none; }
.scan-torch { grid-column: 1; justify-self: end; width: 48px; height: 48px; }
/* Labelled with the zoom in use (main.js). */
.scan-zoom {
  grid-column: 3; justify-self: start; width: 48px; height: 48px;
  font-size: 0.9rem; font-variant-numeric: tabular-nums;
}
.scanner-controls .scan-zoom[aria-pressed="true"] { background: #fff; color: #111; }

/* --- results --- */

.shared-note { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 12px; color: var(--muted); font-size: 0.9rem; }
.cancelled-note { margin: 0 0 12px; padding: 12px 16px; border-radius: 12px; border: 1px solid currentColor; color: var(--red, #c0392b); font-size: 0.95rem; font-weight: 600; }
/* The same note for a car found outside the main registry (render.js
   registryNote): a personal import is on the road, an inactive car is not. */
.cancelled-note[data-tone="info"] { color: var(--accent); }
.cancelled-note[data-tone="warn"] { color: var(--yellow); }
.shared-own { min-height: var(--tap); padding-inline: 12px; background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; }
.results-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 0 4px 4px; }

.btn-share { margin-inline-start: auto; }
.btn-share[aria-busy="true"] { opacity: 0.6; pointer-events: none; }
/* Rare and up (data-cue 4-6, set in main.js once the fleet count lands): the
   icon takes the accent, the button gets the rarity tile's hairline ring, and a
   soft halo breathes behind it while the result is on screen. Stronger the
   rarer the car. The halo is a pseudo-element animated on opacity only, so it
   stays on the compositor; the fade-in waits out the meter's fill. */
.btn-share {
  position: relative;
  isolation: isolate;
  --glow: 0%;
  --glow-blur: 0px;
  transition: background var(--duration-fast) var(--ease-smooth-out), color var(--duration-fast) var(--ease-smooth-out);
}
.btn-share[data-cue="4"] { --glow: 28%; --glow-blur: 10px; }
.btn-share[data-cue="5"] { --glow: 38%; --glow-blur: 12px; }
.btn-share[data-cue="6"] { --glow: 50%; --glow-blur: 14px; }
.btn-share[data-cue] {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent);
}
.btn-share::after {
  content: '';
  position: absolute; inset: 0; z-index: -1;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: 0 0 var(--glow-blur) 2px color-mix(in srgb, var(--accent) var(--glow), transparent);
  opacity: 0;
}
.btn-share[data-cue]::after {
  opacity: 0.55;
  animation:
    share-glow-in 600ms var(--ease-smooth-out) var(--duration-fast) both,
    share-glow 4s var(--ease-in-out) calc(600ms + var(--duration-fast)) infinite;
}
@keyframes share-glow-in { from { opacity: 0; } to { opacity: 0.55; } }
@keyframes share-glow { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }
.share-status { flex-basis: 100%; margin: 4px 0 0; font-size: 0.85rem; color: var(--muted); overflow-wrap: anywhere; }
.share-status .btn { margin-block-start: 8px; }
.share-status[data-tone="error"] { color: var(--red); }

.tile-hero {
  border-radius: var(--hero-radius);
  background: var(--accent-fill); color: #fff;
  padding: 22px;
  display: flex; flex-direction: column; align-items: flex-start; gap: 12px;
}
.plate-badge {
  padding: 6px 12px;
  border-radius: 10px;
  background: #fff; color: #15171c;
  font-size: 1.1rem; font-weight: 800; letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
/* balance: a long model name otherwise leaves one word alone on the last line. */
.result-title { margin: 0; font-size: 2rem; font-weight: 800; line-height: 1.08; letter-spacing: -0.02em; text-wrap: balance; }
.result-title.rtl, .result-subtitle.rtl { text-align: left; }
/* A Hebrew result (i18n.js sets dir="rtl" on the view) starts at the right. */
[dir="rtl"] .result-title.rtl, [dir="rtl"] .result-subtitle.rtl { text-align: right; }
/* The back chevron and the history arrow point the way the view reads. */
[dir="rtl"] #back-btn svg, [dir="rtl"] .history-arrow, [dir="rtl"] .btn-go svg { display: inline-block; transform: scaleX(-1); }
.result-subtitle { margin: -6px 0 0; font-size: 0.95rem; }
.result-subtitle:empty { display: none; }
/* Electric / plug-in / hybrid and horsepower, as pills on the hero. White on
   --accent-fill-strong, a step darker than the hero, so the text keeps the
   contrast it has on the hero itself. */
.hero-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: -2px 0 0; }
.hero-tag {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-fill-strong);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28);
  font-size: 0.85rem; font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.stat-wide { grid-column: 1 / -1; }
/* Rarity: six segments fill from the common end; the two rarest tiers also warm
   the tile. Accent blue throughout, never a status colour, so rare is not
   read as good or bad. */
.rarity-meter { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.rarity-meter i { height: 10px; border-radius: 4px; background: var(--surface-2); transition: background var(--duration-fast) var(--ease-smooth-out); }
.rarity-meter i.on { background: var(--accent-fill); }
#stat-fleet[data-rarity="5"],
#stat-fleet[data-rarity="6"] { background: color-mix(in srgb, var(--accent) 10%, var(--surface)); box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent); }
#stat-fleet[data-rarity="6"] .rarity-meter i.on { box-shadow: 0 0 10px color-mix(in srgb, var(--accent) 45%, transparent); }
.stat { padding: 16px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.stat-label { font-size: 0.8rem; font-weight: 700; color: var(--muted); }
.stat-value {
  font-size: 1.75rem; font-weight: 800; line-height: 1.05;
  font-variant-numeric: tabular-nums; word-break: break-word;
}
.stat-caption { font-size: 0.8rem; color: var(--muted); }

.tile-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.tile-head .card-title { margin: 0; }
.tile-head-meta { font-size: 0.85rem; color: var(--muted); }

/* Kept for the enrichment reveal in js/motion.js, which keys on .card. */
.card { transition: opacity var(--duration-fast) var(--ease-in-out), filter var(--duration-fast) var(--ease-in-out); }
.card.is-entering { opacity: 0; filter: blur(var(--blur-small)); transition: none; }
.card-title {
  margin: 0 0 8px; font-size: 1.05rem; font-weight: 800; color: var(--text);
}

/* An open recall is a safety matter, so it gets the one alarming treatment in
   the app — a red-bordered tile, not a full red fill, so the detail stays
   readable. */
.card-alert { box-shadow: inset 0 0 0 2px var(--red); }
.card-title-alert { color: var(--red); display: flex; align-items: center; gap: 8px; }
.recall-lead { margin: 0 0 12px; font-size: 0.9rem; color: var(--muted); }

.recall-item { padding: 12px 0; border-top: 1px solid var(--border); }
.recall-item:first-child { border-top: none; padding-top: 0; }
.recall-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin-bottom: 6px;
}
.recall-title { font-weight: 700; font-size: 0.95rem; }
/* A Hebrew title in an English card: take the row's width so it sits on the
   right, in line with its Hebrew description below, not on the left. */
.recall-title.rtl { flex: 1 1 auto; }
.recall-date { flex: 0 0 auto; font-size: 0.8rem; color: var(--dim); font-variant-numeric: tabular-nums; }
.recall-desc { margin: 0 0 8px; font-size: 0.9rem; line-height: 1.5; text-wrap: pretty; }

.recall-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.recall-actions .btn { flex: 1 1 auto; text-align: center; text-decoration: none; display: inline-flex;
  align-items: center; justify-content: center; border-radius: 16px; }
.btn-call { background: var(--red-fill); color: #fff; }

.row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.row:last-child { border-bottom: none; }
.row-label { flex: 0 0 auto; color: var(--muted); font-size: 0.85rem; }
.row-value { flex: 1 1 auto; text-align: end; font-size: 0.95rem; word-break: break-word; }
.stat .row-value { flex: 0 0 auto; text-align: start; }
/* A Hebrew value keeps to the row's far edge: right in an English view, left
   in a Hebrew one (its own direction is rtl either way, so not `end`). */
.row-value.rtl { text-align: right; }
[dir="rtl"] .row-value.rtl { text-align: left; }

/* "Loading…" -> the value: the placeholder lifts out, the value rises in. */
.text-swap {
  transition:
    opacity   var(--duration-quick) var(--ease-in-out),
    transform var(--duration-quick) var(--ease-in-out),
    filter    var(--duration-quick) var(--ease-in-out);
}
.text-swap.is-swap-exit {
  opacity: 0;
  transform: translateY(calc(var(--distance-micro) * -1));
  filter: blur(var(--blur-small));
}
.text-swap.is-swap-enter {
  opacity: 0;
  transform: translateY(var(--distance-micro));
  filter: blur(var(--blur-small));
  transition: none;
}

.status-green { color: var(--green); }
.status-yellow { color: var(--yellow); }
.status-red { color: var(--red); }
.status-dim { color: var(--dim); }
.caption { font-size: 0.8rem; margin-top: 6px; }

.pollution-scale { font-size: 0.7rem; letter-spacing: -1px; }
.pollution-category { font-size: 0.85rem; }
.pollution-excellent { color: var(--green); }
.pollution-good { color: var(--green); }
.pollution-fair { color: var(--yellow); }
.pollution-moderate { color: var(--yellow); }
.pollution-poor { color: var(--red); }

/* --- ownership history --- */

.owner-bar { display: flex; gap: 3px; height: 12px; margin: 14px 0 6px; border-radius: 6px; overflow: hidden; }
.owner-seg { min-width: 3px; background: var(--seg-a); }
.owner-seg:nth-child(even) { background: var(--seg-b); }
.owner-seg-current, .owner-seg-current:nth-child(even) { background: var(--seg-current); }

.history-item {
  display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
  padding: 11px 0; border-bottom: 1px solid var(--border);
}
.history-item:last-child { border-bottom: none; }
.history-item.current-owner { font-weight: 700; }
.history-period {
  display: flex; align-items: baseline; gap: 8px;
  font-size: 0.9rem; font-variant-numeric: tabular-nums;
}
.history-arrow { color: var(--dim); }
.history-owner { font-size: 0.9rem; color: var(--muted); }
.history-note { margin: 10px 0 0; font-size: 0.9rem; color: var(--muted); }
.history-note:first-child { margin-top: 0; }

/* --- depreciation chart --- */

.price-summary { font-size: 0.95rem; padding: 8px 0 14px; }
.price-chart { padding-bottom: 10px; }

.dep-row { display: grid; grid-template-columns: 42px 1fr 44px; align-items: center; gap: 10px; padding: 3px 0; }
.dep-current { font-weight: 700; }
.dep-year { font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.dep-track { height: 9px; border-radius: 5px; background: var(--surface-2); overflow: hidden; }
.dep-fill { height: 100%; border-radius: 5px; }
.dep-pct { font-size: 0.8rem; text-align: end; font-variant-numeric: tabular-nums; color: var(--muted); }
.dep-high { background: var(--green); }
.dep-mid { background: var(--yellow); }
.dep-low { background: #d98a4a; }
.dep-vlow { background: var(--red); }

/* --- transient states --- */

.loading {
  position: fixed; inset: 0; z-index: 90;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  color: var(--muted);
  /* The delay is an intent gate: a cached lookup finishes in the same task, and
     without it the scrim flashes for a frame on every one of them. */
  transition: opacity var(--duration-fast) var(--ease-smooth-out) var(--duration-micro);
  /* A veil, not a wall: the lookup can take many seconds, and Back, the header
     and the field must stay reachable while it waits. */
  pointer-events: none;
}
.loading.is-entering { opacity: 0; transition: none; }
.loading.is-closing {
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-quick) var(--ease-smooth-out);
}
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s var(--ease-linear) infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.panel {
  position: fixed; z-index: 110;
  left: 16px; right: 16px;
  bottom: calc(env(safe-area-inset-bottom) + 16px);
  padding: 14px 16px;
  border-radius: var(--radius);
  display: flex; align-items: center; gap: 12px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  transition:
    opacity   var(--duration-fast) var(--ease-smooth-out),
    transform var(--duration-fast) var(--ease-smooth-out),
    filter    var(--duration-fast) var(--ease-smooth-out);
}

/* A toast: rises from the bottom edge, and leaves faster than it arrived. */
.panel.is-entering,
.panel.is-closing {
  opacity: 0;
  transform: translateY(16px) scale(var(--scale-medium));
  filter: blur(var(--blur-small));
}
.panel.is-entering { transition: none; }
.panel.is-closing {
  pointer-events: none;
  transition:
    opacity   var(--duration-quick) var(--ease-smooth-out),
    transform var(--duration-quick) var(--ease-smooth-out),
    filter    var(--duration-quick) var(--ease-smooth-out);
}
.panel p { margin: 0; flex: 1; font-size: 0.9rem; }
.panel-error { background: var(--red-fill); color: #fff; }
/* Full --tap height: this is the one control on a toast that must be hit first
   time, often one-handed. */
.panel-error .btn { color: #fff; flex: 0 0 auto; min-height: var(--tap); padding: 6px 14px; }

/* --- tilt: the hero cards lean with the phone --- */

/* js/tilt.js keeps --tilt-x / --tilt-y (-1..1) on <html> and adds .has-tilt once
   the motion sensor speaks; nothing here applies before that, and tilt.js does
   not start for reduced motion. The Scan card and the Recent tiles move as
   solid cards, their content fixed to them: a 5deg lean under a close 600px
   perspective, and a shadow that slides against the lean, which is what lifts
   them off the page. The results hero leans 3deg and its plate badge drifts
   5px above it. On all of them a soft sheen slides the opposite way, like
   light held still while the card turns.
   The sheen is ::before, under the text (z-index -1 inside the isolated card):
   ::after is already the paint gloss of a painted tile or hero. */
.has-tilt :is(.tile-scan, .tile-hero, .recent-tile) {
  --lean: 3deg;
  --depth: 900px;
  --press: 1;
  position: relative; isolation: isolate;
  transform: perspective(var(--depth))
    rotateX(calc(var(--tilt-y, 0) * var(--lean) * -1))
    rotateY(calc(var(--tilt-x, 0) * var(--lean)))
    scale(var(--press));
}
.has-tilt :is(.tile-scan, .recent-tile) {
  --lean: 5deg;
  --depth: 600px;
  --lift: calc(var(--tilt-x, 0) * -7px) calc(5px + var(--tilt-y, 0) * -7px) 16px rgb(0 0 0 / 0.38);
  box-shadow: var(--lift);
}
.has-tilt .recent-tile.painted {  /* keep the paint's ring */
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--text) 14%, transparent), var(--lift);
}
.has-tilt :is(.tile-scan, .recent-tile):active:not(:disabled) { --press: 0.985; }
.has-tilt .plate-badge {
  translate: calc(var(--tilt-x, 0) * 5px) calc(var(--tilt-y, 0) * 5px);
}
.has-tilt :is(.tile-scan, .tile-hero, .recent-tile)::before {
  --shine: 0.16;
  content: "";
  position: absolute; inset: 0; z-index: -1;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(
    circle at calc(50% - var(--tilt-x, 0) * 45%) calc(30% - var(--tilt-y, 0) * 45%),
    rgb(255 255 255 / var(--shine)), transparent 60%);
}
.has-tilt .recent-tile:not(.painted)::before { --shine: 0.1; }  /* on the dark surface */

/* Named rules rather than a global 0.01ms override. That override still ran
   every animation — the spinner kept flickering through its rotation — whereas
   `transition: none` reads back as a zero duration, which js/motion.js takes
   as "hide and swap immediately". The scanner's box and digit fill handle
   reduced motion in JS (box-smoothing.js, paint-progress.js). */
@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
  .btn-share[data-cue]::after { animation: none; opacity: 0.8; } /* the halo, held still */
  .btn-share[data-cue] { transition: none; }
  .btn:active:not(:disabled) { transform: none; }
  .view, .scanner, .loading, .panel, .card, .tile, .text-swap { transition: none !important; }
  button.tile:active { transform: none; }
  .landing-copy details, .landing-copy summary::after { transition: none; }
  .landing-copy details[open] p { animation: none; }
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) { animation: none !important; }
}
/* Apart from the rule above: a browser that does not know ::details-content
   drops every selector in a list that names it. */
@media (prefers-reduced-motion: reduce) {
  .landing-copy details::details-content { transition: none; }
}
