/* A car's own page (src/app/car/). The first screen is the car: its name as large as the screen, and in front
   of it the car at true scale, then what it is, its price, and the two acts under the thumb. Then the answers.
   It places the app's pieces and redefines no token.

   Scale. Every car's page shows its car at one scale: `--span` millimetres take the width of the stage (5,40 m,
   or the car's own length when it is longer). A city car looks small here, a pick-up fills the width.

   Wide screens: the car stays in view on the left while the answers scroll on the right. */

/* The dock's height lives on the page's root: the frame's toast, a child of the body, reads it too (on .car alone,
   the toast's position was invalid and it fell to the end of the page, out of sight). */
.app { --dock-h: 68px; }
.car { max-width: 1180px; margin: 0 auto; }
.car-first { display: flex; flex-direction: column; padding: 0 var(--pad) 8px; }
.car-rest { padding: 0 var(--pad) calc(var(--dock-h) + var(--sp-5)); }

/* ── What changes against the car held: the rule of the app, first under the bar ─────────────────────── */

/* A car is held on this device: the room of the band (two lines of chips on a phone) is kept from the first paint,
   so that nothing moves when it is written. */
:root[data-held] .car-band-slot { min-height: 90px; display: grid; }
/* The car held is this very car: no band (the dock says it), and no room kept for one. */
:root[data-held] .car-band-slot[data-self], .car-band-slot[data-self] { display: none; min-height: 0; }
/* The band: what changes as signed chips (the app's .gap), and the way to the face-to-face. It does not name the car
   held: the strip at the bottom of a phone does, and the top bar's chip with room (once on a screen). */
.car-band { position: relative; display: grid; align-content: center; gap: 10px; padding: 12px calc(var(--pad) + 30px) 13px var(--pad); border-bottom: 1.5px solid var(--ink); background: var(--card); color: inherit; text-decoration: none; transition: background-color var(--quick); }
.car-band:active { background: var(--sunk); }
.car-band-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 6px; }
/* The chevron stands at the band's end, at mid-height, out of the chips' lines: it never takes a line of its own. */
.car-band-row > .gaps { display: contents; }
.car-band-go { position: absolute; right: calc(var(--pad) - 2px); top: 50%; translate: 0 -50%; display: inline-flex; color: var(--soft); }
.car-band-go .ic { width: 18px; height: 18px; }
.car-band:focus-visible { outline-offset: -4px; }
/* With room the chips hold on one line. */
@media (min-width: 760px) {
  :root[data-held] .car-band-slot { min-height: 64px; }
}

/* ── The first screen ────────────────────────────────────────────────────────────────────────────────── */

.car-hero { display: grid; padding-top: 14px; container-type: inline-size; }
.car-h { display: grid; gap: 6px; position: relative; z-index: 0; }
.car-make { justify-self: start; display: inline-flex; align-items: center; min-width: 24px; min-height: 24px; text-decoration: none; }
.car-make::after { content: ""; position: absolute; left: 0; top: -10px; width: 9em; height: 44px; }
/* The name: its longest line fills five sixths of the room (its width in ems, measured: `--w`, src/app/car/page.ts),
   never larger than a wall. */
.car-name { display: block; font: 800 1rem/0.88 var(--names); letter-spacing: -0.038em; font-size: clamp(2.25rem, calc((100vw - 2 * var(--pad)) * 0.83 / var(--w)), 4.75rem); text-wrap: balance; }
@supports (width: 1cqw) {
  .car-name { font-size: clamp(2.25rem, calc(100cqw * 0.83 / var(--w)), 5.75rem); }
}

/* The stage: the flat car at true scale, and the 3D that takes its place. It rises into the name.
   The flat car is the stage's own poster (src/site/stage-slot.ts), set here at the page's scale and on the page's
   ground: the 3D car arrives exactly where the poster's car stands, at its size (src/stage/mount.ts), so the
   picture comes alive without a jump. The poster's car spans 316 of its 340 units, and stands 14 units above
   its bottom edge: the two numbers below. */
.car-stagebox { position: relative; z-index: 1; aspect-ratio: 3 / 2; margin: -74px calc(var(--pad) * -1) 0; container-type: inline-size; }
.car-stagebox::before { content: ""; position: absolute; inset: auto 0 0; height: 46%; background: radial-gradient(58% 54% at 50% 62%, var(--road), transparent 100%); pointer-events: none; }
.car-stagebox > * { --mm: calc(90cqw / var(--span)); --ground: calc(14% + 21px); }
.car-stagebox .stage { position: absolute; inset: 0; max-width: none; margin: 0; }
.car-stagebox .stage-view { height: 100%; aspect-ratio: auto; border: 0; background: none; }
.car-stagebox .stage-poster { --pw: calc(var(--L) * var(--mm) * 340 / 316); }
.car-stagebox .stage-poster > svg { left: 50%; top: auto; bottom: calc(var(--ground) - var(--pw) * 14 / 340); width: var(--pw); height: auto; translate: -50% 0; overflow: visible; }
/* The poster of a car without pictures is its drawing: the app's own strokes (as `.carfig` in app.css). */
.car-stagebox .stage-poster .car-shadow { fill: var(--ink); opacity: 0.16; filter: blur(3px); }
.car-stagebox .stage-poster .car-body { fill: var(--car); stroke: var(--ink); stroke-width: 1.4px; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.car-stagebox .stage-poster .car-glass { fill: var(--glass); stroke: var(--ink); stroke-width: 0.9px; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.car-stagebox .stage-poster .car-pillar { stroke: var(--car); }
.car-stagebox .stage-poster .car-seam { stroke: var(--ink); stroke-width: 0.7px; opacity: 0.45; vector-effect: non-scaling-stroke; }
.car-stagebox .stage-poster .car-lamp { stroke: var(--ink); stroke-width: 0.8px; vector-effect: non-scaling-stroke; }
.car-stagebox .stage-poster .car-head { fill: var(--card); }
.car-stagebox .stage-poster .car-tail { fill: var(--bad); }
.car-stagebox .stage-poster .car-tyre { fill: var(--tyre); }
.car-stagebox .stage-poster .car-rim { fill: var(--line); }
.car-stagebox .stage-poster .car-hub { fill: var(--tyre); }
/* Its length, as a dimension line under it: the scale, said. It leaves with the flat car. */
.car-len { position: absolute; left: 50%; bottom: 14%; translate: -50% 0; display: block; width: calc(var(--L) * var(--mm)); height: 9px; border: solid var(--edge); border-width: 0 1.5px; transition: opacity 0.2s ease-out 0.2s, visibility 0s; }
.car-len::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 1.5px solid var(--edge); }
.car-len i { position: absolute; left: 50%; top: 50%; translate: -50% -50%; padding: 0 7px; background: var(--paper); font: 600 0.71875rem/1 var(--label); font-style: normal; color: var(--soft); white-space: nowrap; font-variant-numeric: tabular-nums; }
.car-stagebox:has(.stage[data-stage-state="live"]) .car-len { opacity: 0; visibility: hidden; transition: opacity 0.2s ease-out 0.2s, visibility 0s 0.4s; }
/* A pictured car the source gives no length for: its picture alone, at its own measures, just under its name. */
.car-stagebox.is-flat { aspect-ratio: auto; margin-top: -10px; padding: 0 0 12px; }
.car-stagebox.is-flat .car-flat { display: grid; justify-items: center; }
.car-turn { flex: none; display: inline-flex; align-items: center; gap: 7px; min-height: 44px; padding: 0 14px 0 11px; border: 1.5px solid var(--edge); border-radius: var(--r-pill); background: none; font: 650 0.8125rem/1 var(--body); position: relative; transition: scale var(--quick), border-color var(--quick); }
.car-turn .ic { width: 18px; height: 18px; }
.car-turn:active { scale: 0.95; }
.car-hero:has(.car-stagebox.is-auto) .car-turn, .car-hero:has(.stage[data-stage-state="live"]) .car-turn, .car-hero:has(.stage[data-stage-state="flat"]) .car-turn { display: none; }
.car-turn[aria-busy="true"] { color: var(--soft); }
/* A car the source gives neither picture nor measure for: an empty place, said as one. */
.car-stagebox.is-empty { aspect-ratio: auto; margin: 8px 0 0; padding: 22px 18px; border: 2px dashed var(--edge); border-radius: var(--r-l); display: grid; place-items: center; min-height: 168px; }
.car-stagebox.is-empty::before { display: none; }
.car-empty { max-width: 26em; font: 400 0.875rem/1.45 var(--body); color: var(--soft); text-align: center; }
.car-empty b { display: block; margin-bottom: 4px; font: 750 1.0625rem/1.2 var(--display); color: var(--ink); }
.car-shown { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: center; gap: 0 14px; margin-top: -2px; }
.car-shown .whence { min-width: 0; }
.car-shown:has(.car-turn) .whence:not([open]) { flex: 0 1 auto; }
.car-shown .whence[open] { flex: 1 1 100%; }
.car-shown .whence summary { font: 500 0.71875rem/1.2 var(--label); font-variant-numeric: tabular-nums; }
.car-shown .whence-body { max-width: 34em; margin-bottom: 6px; }

.car-id { display: grid; gap: 4px; }
.car-what { display: grid; gap: 2px; }
.car-what b { font: 750 1.25rem/1.15 var(--display); letter-spacing: -0.017em; }
.car-what span { font: 500 0.9375rem/1.35 var(--body); color: var(--soft); text-wrap: balance; }
.car-price { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0 14px; margin-top: 8px; }
.car-month { display: inline-flex; align-items: center; gap: 0.3em; min-height: 44px; font: 500 0.875rem/1.2 var(--body); color: var(--soft); text-decoration: underline dotted; text-decoration-thickness: 1px; text-underline-offset: 4px; white-space: nowrap; }
.car-month b { color: var(--ink); font: 750 0.9375rem/1 var(--display); letter-spacing: -0.008em; }
.car-read { margin-top: -4px; }
.car-promo { display: inline-flex; align-items: center; min-height: 44px; margin: -6px 0; font: 600 0.8125rem/1.3 var(--body); text-underline-offset: 4px; text-decoration-thickness: 1px; }
.car-switch { margin-top: 12px; }
.car-switch small { margin-left: 4px; padding: 2px 7px; border-radius: 9px; background: color-mix(in srgb, var(--ink) 9%, transparent); font: 600 0.71875rem/1 var(--label); font-variant-numeric: tabular-nums; }

/* The two acts of the whole product, under the thumb on every screen of the page. */
.car-dock { position: fixed; z-index: 15; left: 0; right: 0; bottom: var(--held-h); display: flex; justify-content: center; gap: 8px; padding: 18px var(--pad) calc(10px + env(safe-area-inset-bottom, 0px)); background: linear-gradient(to top, var(--paper) 58%, transparent); pointer-events: none; }
:root[data-held] .car-dock { padding-bottom: 10px; }
.car-dock > * { pointer-events: auto; box-shadow: var(--lift-1); }
.car-dock .btn { padding-inline: 16px; white-space: nowrap; }
.car-dock-hold { flex: 1 1 auto; max-width: 300px; }
.car-dock .btn-line { background: var(--paper); }
.car-dock .btn-line[aria-pressed="true"] { background: var(--ink); }
/* Kept, its heart is yellow inside; held, its pin is filled. */
.car-dock-keep[aria-pressed="true"] .ic { --ic-in: var(--paint); }
.car-dock-hold[aria-pressed="true"] .ic { --ic-in: currentColor; }
.car-dock-hold .when-on, .car-dock-hold[aria-pressed="true"] .when-off { display: none; }
.car-dock-hold[aria-pressed="true"] .when-on { display: inline; }
.car-dock-face { flex: 1 1 auto; max-width: 300px; }
/* Another car is held: the face-to-face leads, and the two acts stand beside it as their icons (their names stay for whoever cannot see). */
.car-dock[data-facing] .car-dock-hold, .car-dock[data-facing] .car-dock-keep { flex: none; width: 48px; padding: 0; }
.car-dock[data-facing] .car-dock-hold span, .car-dock[data-facing] .car-dock-keep span { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* A phone: the two names side by side, in the room there is. */
@media (max-width: 389px) {
  .car-dock { gap: 6px; }
  .car-dock .btn { padding-inline: 13px; font-size: 0.875rem; }
}
/* A very narrow screen: "Favori" keeps its heart, and its name for whoever cannot see. */
@media (max-width: 349px) {
  .car-dock-keep { flex: none; width: 48px; padding: 0; }
  .car-dock-keep span { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}

/* The answers, folded, then the card, then what to do, and the sources last: one rhythm between them. */
.car-rest > .answers { margin-top: 14px; }
.car-rest > .answers:first-child { margin-top: 6px; }
.car-shown .stage-credit { margin: 6px 0 0; text-align: left; }
/* A word from the frame is said above the dock, not over it. */
.app:has(.car-dock) .toast { bottom: calc(var(--held-h) + var(--dock-h) + 16px + env(safe-area-inset-bottom, 0px)); }

/* ── Its versions, one tap away ──────────────────────────────────────────────────────────────────────── */

dialog.car-versions[open] { display: flex; flex-direction: column; }
.car-versions-head { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 6px 8px var(--pad); }
.car-versions-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 0 calc(18px + env(safe-area-inset-bottom, 0px)); }
.car-versions-body h3 { padding: 14px var(--pad) 6px; }
.car-versions-body .row[aria-current] { background: var(--sunk); }
.car-versions-body mark { font: 650 0.6875rem/1 var(--body); padding: 0.2em 0.45em; white-space: nowrap; }
.car-versions-body .row-top { align-items: center; }

/* ── Wide screens ────────────────────────────────────────────────────────────────────────────────────── */

@media (min-width: 1000px) {
  /* The car on the left; on the right the band, then the answers. */
  .car { display: grid; grid-template-columns: minmax(0, 452px) minmax(0, 1fr); grid-template-areas: "first band" "first rest"; grid-template-rows: auto 1fr; align-items: start; gap: 0 56px; padding: 0 32px; }
  .car-first { grid-area: first; padding: 0 0 16px; }
  .car-band-slot { grid-area: band; max-width: 720px; }
  :root[data-held] .car-band-slot { min-height: 82px; padding-top: 18px; }
  :root[data-held] .car-band-slot[data-self] { display: none; min-height: 0; }
  .car-band { padding: 14px 46px 14px 18px; border: 1.5px solid var(--ink); border-radius: var(--r-l); }
  .car-band-go { right: 16px; }
  .car-rest { grid-area: rest; max-width: 720px; padding: 18px 0 calc(var(--dock-h) + var(--sp-6)); }
  :root[data-held] .car-rest { padding-top: 14px; }
  .car-stagebox { margin: -84px 0 0; }
}
/* With room in height too, the car stays in view while the answers scroll, and its two acts stand under it. */
@media (min-width: 1000px) and (min-height: 760px) {
  .car-first { position: sticky; top: calc(var(--bar-h) + 4px); }
  .car-rest { padding-bottom: var(--sp-7); }
  .car-dock { position: static; justify-content: flex-start; padding: 16px 0 0; background: none; }
  .car-dock > * { box-shadow: none; }
  .app:has(.car-dock) .toast { bottom: calc(var(--held-h) + 14px); }
}
/* A screen that is wide and not tall: the stage gives its height, so that the column ends above the car held. */
@media (min-width: 1000px) and (min-height: 760px) and (max-height: 860px) {
  .car-stagebox { aspect-ratio: 2 / 1; margin-top: -44px; }
  :root[data-held] .car-stagebox { aspect-ratio: 5 / 2; margin-top: -8px; }
}

/* ── A laptop: the two acts in the right column ──────────────────────────────────────────────────────────

   A laptop is LAPTOP of src/app/ui/laptop.ts (a test holds the two together). There the two acts stand in the right column, under the band
   and over the answers, as on the street's docked answers: the car held and what the app says, then the acts,
   then the answers. They stay under the top bar while the answers go by, and float over nothing. */
@media (min-width: 1024px) and (min-height: 540px) and (hover: hover) and (pointer: fine) {
  .car { grid-template-areas: "first band" "first dock" "first rest"; grid-template-rows: auto auto 1fr; }
  .car-first { display: contents; }
  .car-hero { grid-area: first; align-self: start; padding-bottom: 16px; }
  .car-dock {
    grid-area: dock; position: sticky; z-index: 5; top: var(--bar-h); left: auto; right: auto; bottom: auto;
    max-width: 720px; justify-content: flex-start; padding: 14px 0 12px; background: var(--paper); pointer-events: auto;
    container-type: scroll-state;
  }
  :root[data-held] .car-dock { padding-top: 16px; }
  .car-dock > * { box-shadow: none; }
  /* Stuck under the top bar, it has an edge: what scrolls goes under it, not through it. */
  @container scroll-state(stuck: top) {
    .car-dock-face, .car-dock-hold, .car-dock-keep { box-shadow: var(--lift-1); }
  }
  .car-rest { padding-top: 6px; padding-bottom: var(--sp-7); }
  :root[data-held] .car-rest { padding-top: 6px; }
  .app:has(.car-dock) .toast { bottom: 24px; }
  /* With room the car held is the top bar's chip, which names it and lets it go: no strip over the page. */
  .app:has(.car-band-slot) > .held { display: none; }
  .app.is-page:has(.car-band-slot) > .main { padding-bottom: var(--sp-6); }
}
@media (min-width: 1024px) and (min-height: 760px) and (hover: hover) and (pointer: fine) {
  .car-hero { position: sticky; top: calc(var(--bar-h) + 4px); }
}

/* Opened from the street on a laptop, the car is carried here: its picture, its name and its price move from
   where they stood to where they stand on this page (src/app/ui/carry.ts). */
@media (prefers-reduced-motion: no-preference) {
  ::view-transition-group(car-pic), ::view-transition-group(car-name), ::view-transition-group(car-price) { animation-duration: var(--settle); animation-timing-function: var(--ease); }
}

@media (hover: hover) {
  .car-band:hover { background-color: var(--sunk); }
  .car-turn:hover { border-color: var(--ink); }
  .car-month:hover, .car-make:hover { color: var(--ink); }
}
@media (prefers-reduced-motion: reduce) {
  .car-len, .car-turn { transition: none; }
  .car-turn:active { scale: 1; }
}

/* The car's five figures, in a row under it (src/app/car/spots.ts): each opens its label, as its dot on the 3D car
   does. Light: five figures between hairlines, no boxes. Without scripts or without 3D, the row is the whole of it,
   and its labels still open (popovers). */
.car-spots-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); margin: 2px 0 6px; padding: 0; list-style: none; border-block: 1px solid var(--line); }
.car-spots-row li + li { border-left: 1px solid var(--line); }
.car-spot {
  display: grid; align-content: center; justify-items: center; gap: 3px; width: 100%; min-height: 48px; padding: 6px 2px;
  border: 0; border-radius: 0; background: none; color: var(--ink); text-align: center;
  transition: box-shadow var(--quick), scale var(--quick);
}
/* The same type as the app's facts row (.fact-l, .fact-f in app.css): the two rows are one family. */
.car-spot-n { font: 550 0.6875rem/1.2 var(--body); color: var(--soft); }
.car-spot-f { font: 800 0.9375rem/1.2 var(--display); letter-spacing: -0.017em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.car-spot.is-unknown .car-spot-f { color: var(--soft); }
.car-spot.is-open { box-shadow: inset 0 -3px 0 var(--paint); }
.car-spot:active { scale: 0.96; }
@media (hover: hover) {
  .car-spot:hover .car-spot-n { color: var(--ink); }
}

/* A label: the figure, one sentence, its source a tap away; against the car held, what changes. A popover: in the
   middle of the window by itself; once the page's script places it (src/stage/label.ts), beside its dot or as a card
   along the bottom of the car's area, never over the name, the price, the dock or the car held. Compact, so that the
   car stays in sight. */
.spot-label {
  width: min(15rem, calc(100vw - 24px)); max-height: calc(100dvh - var(--bar-h) - 24px); overflow: auto; margin: auto;
  padding: 10px 12px 0; border: 1.5px solid var(--line); border-radius: var(--r-l);
  background: var(--card); color: var(--ink); box-shadow: var(--lift-2); overscroll-behavior: contain;
}
.spot-label[data-placing] { visibility: hidden; }
.spot-label::backdrop { background: transparent; }
.spot-q { padding-right: 34px; font: 500 0.84375rem/1.15 var(--voice); color: var(--soft); letter-spacing: -0.01em; }
.spot-fig { margin-top: 2px; font: 800 1.625rem/1 var(--display); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.spot-fig small { font: 600 0.75rem/1 var(--body); letter-spacing: 0; color: var(--soft); }
.spot-fig .a-fig-pre { font-weight: 650; }
.spot-none { font-size: 1.25rem; letter-spacing: -0.017em; color: var(--soft); }
.spot-say { margin-top: 6px; font: 400 0.875rem/1.22 var(--voice); text-wrap: pretty; letter-spacing: -0.005em; }
.spot-label .a-face { margin-top: 8px; }
.spot-label .whence { margin-top: 0; }
.spot-close { position: absolute; top: 0; right: 0; }
.spot-close .ic { width: 18px; height: 18px; }
/* As a card (a phone, or opened from the row): the name and the figure on one line, the sentence beside the room it has. */
.spot-label[data-card] .spot-q { display: inline; padding-right: 8px; }
.spot-label[data-card] .spot-fig { display: inline; margin: 0; }
.spot-label[data-card] { padding-top: 8px; }
.spot-label[data-card] .spot-fig + .spot-say { margin-top: 4px; }
.spot-label[data-card] .a-face { margin-top: 6px; }
.spot-label[data-card] .whence summary { min-height: 40px; }
@media (prefers-reduced-motion: no-preference) {
  .spot-label:popover-open { transition: opacity var(--quick) ease-out, translate var(--quick) var(--ease); }
  @starting-style {
    .spot-label:popover-open { opacity: 0; translate: 0 4px; }
  }
}
/* A figure the source does not give: the bird says it does not know, beside the words that say so (CRIES.unsaid). */
.spot-label.is-unknown .spot-fig { display: flex; align-items: center; gap: 8px; }
.spot-bird { margin: -6px 0 -6px -4px; }
