/* Hanetic theme — cars.css (Phase 1)
   ------------------------------------------------------------------
   Dark garage archive for cars.html. Covers every class the page uses
   (it no longer loads legacy styles.css). Sticky section tabs derive
   their offset from safe-area per AGENTS.md (no raw top: 8px). */

body.cars-archive-body {
  min-height: 100vh;
  color: var(--hx-dark-ink);
  background:
    radial-gradient(circle at 50% -10%, rgba(78, 97, 92, 0.34), transparent 36%),
    radial-gradient(circle at 18% 14%, rgba(47, 139, 101, 0.18), transparent 28%),
    linear-gradient(180deg, #050708 0%, #0a0f10 48%, #111413 100%);
}

html:has(body.cars-archive-body) {
  background: #050708;
}

.car-grid-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.62), transparent 82%);
  -webkit-mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.62), transparent 82%);
}

/* ---- Hero ---- */
.car-hero {
  position: relative;
  min-height: min(720px, calc(100svh - 128px));
  overflow: hidden;
  border: 1px solid var(--hx-dark-line-soft);
  border-radius: var(--hx-radius-hero);
  background: #080b0c;
  box-shadow: 0 28px 92px rgba(0, 0, 0, 0.34);
}

.car-hero > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.72;
}

/* Interaction identity (Phase I-2): hx-parallax mount, live (mirrors
   portal.css's `.portal-photo-hero > img` mount 1:1 against `.car-hero > img`).
   scripts/webkit_probe.swift (no freeze instrumentation) verified this
   design correct: true scroll=0 resolves to `scale:"1"` / `translate:"0px"`;
   scrolling showed correct linear interpolation and correct end-of-range
   holding. `.car-hero` has overflow:hidden so this never spills into
   layout.

   Was rolled back once because scripts/webkit_baseline.swift's screenshot
   freeze rendered this scroll-driven animation at its fill-forwards end
   state regardless of scroll position; fixed at the root in
   webkit_baseline.swift instead of unmounting — see
   reports/phaseI2/NOTES.md for details. */

@supports (animation-timeline: scroll()) {
  @media (prefers-reduced-motion: no-preference) {
    .car-hero > img {
      animation: hx-parallax-pan linear both;
      animation-timeline: scroll(root block);
      animation-range: 0px 600px;
      --hx-parallax-shift: 20px;
    }

    @media (min-width: 1181px) {
      .car-hero > img {
        --hx-parallax-shift: 40px;
      }
    }

    @media (orientation: landscape) and (max-height: 560px) {
      .car-hero > img {
        --hx-parallax-shift: 20px;
      }
    }
  }
}

.car-hero-shade {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(5, 7, 8, 0.92), rgba(5, 7, 8, 0.5) 46%, rgba(5, 7, 8, 0.14)),
    linear-gradient(180deg, rgba(5, 7, 8, 0.12), rgba(5, 7, 8, 0.86));
}

.car-hero-copy {
  position: relative;
  z-index: 1;
  display: grid;
  align-content: end;
  /* Reserve the specification column even when the viewport is tablet-wide. */
  max-width: min(780px, calc(100% - min(380px, 36%) - 24px));
  min-height: inherit;
  padding: clamp(26px, 6vw, 64px);
}

.car-kicker {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  color: var(--hx-dark-ink-soft);
}

.car-hero h1 {
  /* Keep the full model readable when zoom leaves less than one word of width. */
  overflow-wrap: anywhere;
  margin-top: 18px;
  font-size: clamp(4rem, 8.4vw, 9rem);
  line-height: 0.88;
  letter-spacing: -0.03em;
}

.car-hero p {
  max-width: 660px;
  margin-top: 18px;
  color: var(--hx-dark-ink-soft);
  font-size: var(--hx-text-lede);
  line-height: 1.58;
}

.car-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 26px;
}

.car-hero-actions a {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--hx-radius-pill);
  padding: 11px 15px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--hx-dark-ink);
  font-weight: 820;
  text-decoration: none;
  transition: background var(--hx-dur-fast) ease, transform var(--hx-dur-fast) ease;
}

.car-hero-actions a:hover,
.car-hero-actions a:focus-visible {
  background: rgba(255, 255, 255, 0.18);
  transform: translateY(-1px);
}

.car-hero-spec {
  position: absolute;
  right: 24px;
  bottom: 24px;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 10px;
  width: min(380px, 36%);
}

/* ---- Shared dark tiles ---- */
.car-hero-spec div,
.car-spec-grid div,
.build-sheet-grid article,
.maintenance-grid article {
  min-width: 0;
  border: 1px solid var(--hx-dark-line-soft);
  border-radius: var(--hx-radius-md);
  padding: 14px;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: var(--hx-hairline-dark);
  backdrop-filter: blur(18px) saturate(1.1);
  -webkit-backdrop-filter: blur(18px) saturate(1.1);
}

.car-hero-spec span,
.car-spec-grid dt,
.build-sheet-grid span,
.maintenance-grid span {
  color: var(--hx-dark-ink-faint);
  font-size: var(--hx-text-label);
  font-weight: 860;
  text-transform: uppercase;
}

.car-hero-spec strong,
.car-spec-grid dd,
.build-sheet-grid strong,
.maintenance-grid strong {
  display: block;
  margin: 5px 0 0;
  color: #fff;
  font-size: 1.08rem;
  font-weight: 880;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

/* ---- Sticky section tabs (safe-area aware) ---- */
.car-section-tabs {
  position: sticky;
  top: calc(var(--hx-child-height) + 8px);
  z-index: 12;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  border: 1px solid var(--hx-dark-line-soft);
  border-radius: var(--hx-radius-pill);
  padding: 8px;
  background: rgba(8, 11, 12, 0.72);
  box-shadow: 0 18px 54px rgba(0, 0, 0, 0.24);
  backdrop-filter: var(--hx-blur);
  -webkit-backdrop-filter: var(--hx-blur);
  scrollbar-width: none;
}

.car-section-tabs::-webkit-scrollbar {
  display: none;
}

.car-section-tabs a {
  flex: 0 0 auto;
  border-radius: var(--hx-radius-pill);
  padding: 10px 14px;
  color: var(--hx-dark-ink-soft);
  font-size: 0.82rem;
  font-weight: 820;
  text-decoration: none;
  transition: background var(--hx-dur-fast) ease, color var(--hx-dur-fast) ease;
}

.car-section-tabs a:hover,
.car-section-tabs a:focus-visible {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

/* Anchor jumps must not land under the sticky tabs. */
.car-panel {
  scroll-margin-top: calc(var(--hx-child-height) + 76px);
}

/* ---- Panels ---- */
.car-panel {
  display: grid;
  gap: var(--hx-space-4);
  border: 1px solid var(--hx-dark-line-soft);
  border-radius: 30px;
  padding: clamp(18px, 4vw, 34px);
  background:
    radial-gradient(circle at 92% 10%, rgba(47, 139, 101, 0.12), transparent 28%),
    rgba(255, 255, 255, 0.055);
  box-shadow: var(--hx-shadow-dark), var(--hx-hairline-dark);
}

.car-panel-head h2 {
  margin-top: 10px;
  font-size: clamp(2rem, 5vw, 4.4rem);
  line-height: 0.98;
  text-wrap: balance;
}

.car-panel-head p {
  max-width: 760px;
  margin-top: 12px;
  color: rgba(244, 247, 245, 0.66);
  line-height: 1.62;
}

.car-spec-grid,
.build-sheet-grid,
.maintenance-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.maintenance-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

/* ---- Panel variants ------------------------------------------------------
   Each section of the archive carries its own accent so the page reads as
   chapters instead of identical boxes. */

/* Identity chapter: strongest brand-green presence. */
.car-panel.car-overview {
  background:
    radial-gradient(circle at 8% 0%, rgba(47, 139, 101, 0.18), transparent 34%),
    radial-gradient(circle at 92% 10%, rgba(47, 139, 101, 0.08), transparent 28%),
    rgba(255, 255, 255, 0.055);
}

/* Media chapter: darker stage so photos carry the light. */
.car-panel.media-panel {
  background:
    radial-gradient(circle at 92% 10%, rgba(47, 139, 101, 0.08), transparent 28%),
    rgba(0, 0, 0, 0.3);
}

/* Maintenance chapter: warm "next actions" tint, matches status warn hue. */
.car-panel.maintenance-panel {
  background:
    radial-gradient(circle at 92% 10%, rgba(183, 122, 24, 0.14), transparent 30%),
    rgba(255, 255, 255, 0.05);
}

.car-panel.maintenance-panel .car-kicker {
  border-color: rgba(240, 196, 108, 0.34);
  color: #f0c46c;
}

/* Interaction identity (Phase I-3): pointer pipeline mount — "flashlight
   照車庫" full-page spotlight, wider radius/stronger intensity than
   Portal's dock (320px/8% vs 240px/6%, per the brief's Cars list).
   Equivalent to motion.css's .hx-spotlight, mounted via direct selector
   instead of the class for both halves:
   - `.car-panel[data-hx-pointer]` — I-3's allowed HTML edit for cars.html
     is the data-hx-pointer attribute only, added to the five (static,
     never JS-replaced) <section class="car-panel"> elements. Uses ::after
     (no existing user on this element).
   - `.media-grid figure` — these six figures ARE replaced wholesale by
     js/cars/main.js's innerHTML swap from /data/cars.json, which this
     phase cannot touch (outside I-3's allowed-files list), so there is no
     HTML attribute to select on here. js/lib/pointer-fx.js's own
     SELECTOR constant carries the identical `.media-grid figure`
     structural fallback for this exact reason — see its header comment.
     Uses ::before instead of ::after: every figure already carries
     hx-sheen, which owns ::after for its hover sweep (motion.css) —
     ::before keeps both effects layered instead of one clobbering the
     other's pseudo-element.
   No tilt here — the brief's Cars list is spotlight-only. Positioning
   context (`position: relative`) is scoped inside the same media gate as
   the pseudo-element itself, not left unconditional: touch and reduced-
   motion contexts get zero side effects from this mount, not even an
   invisible one. */
@media (hover: hover) and (pointer: fine) {
  @media (prefers-reduced-motion: no-preference) {
    .car-panel[data-hx-pointer],
    .media-grid figure {
      position: relative;
    }

    .car-panel[data-hx-pointer]::after,
    .media-grid figure::before {
      content: "";
      position: absolute;
      inset: 0;
      border-radius: inherit;
      pointer-events: none;
      opacity: 0;
      transition: opacity var(--hx-dur-med) ease;
      background: radial-gradient(320px at calc(var(--hx-mx, 0.5) * 100%) calc(var(--hx-my, 0.5) * 100%), rgba(255, 255, 255, 0.08), transparent 70%);
    }

    .car-panel[data-hx-pointer]:hover::after,
    .car-panel[data-hx-pointer]:focus-visible::after,
    .media-grid figure:hover::before,
    .media-grid figure:focus-visible::before {
      opacity: 1;
    }
  }
}

/* ---- Timeline ---- */
.car-timeline {
  display: grid;
  gap: 12px;
}

.car-event {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding-top: 18px;
}

.car-event time {
  color: #7acb8f;
  font-weight: 900;
}

.car-event h3 {
  color: #fff;
  font-size: 1.35rem;
}

.car-event p {
  margin-top: 8px;
  color: rgba(244, 247, 245, 0.66);
  line-height: 1.58;
}

.car-event span,
.build-sheet-grid small,
.maintenance-grid small {
  display: block;
  margin-top: 8px;
  color: var(--hx-dark-ink-faint);
  font-weight: 760;
}

/* ---- Media grid ---- */
.media-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.media-grid figure {
  overflow: hidden;
  border: 1px solid var(--hx-dark-line-soft);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.06);
}

.media-grid img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  transition: transform var(--hx-dur-med) var(--hx-ease);
}

.media-grid figure:hover img {
  transform: scale(1.03);
}

.media-grid figcaption {
  padding: 11px 12px 13px;
  color: var(--hx-dark-ink-soft);
  font-size: 0.86rem;
  font-weight: 800;
}

/* Interaction identity (Phase I-4): figcaption opacity curve — pairs with
   the existing hover-zoom above (60% resting, 100% on the same hover that
   triggers the image scale, so caption and photo focus together). Base
   opacity sits outside the media gate (always applied — this is the
   at-rest reading state, not a hover-only reveal, so no-hover/reduced-
   motion users still get 60%, just without the transition/brighten). */
.media-grid figcaption {
  opacity: 0.6;
}

@media (hover: hover) and (pointer: fine) {
  @media (prefers-reduced-motion: no-preference) {
    .media-grid figcaption {
      transition: opacity var(--hx-dur-med) var(--hx-ease);
    }

    .media-grid figure:hover figcaption,
    .media-grid figure:focus-within figcaption {
      opacity: 1;
    }
  }
}

/* ---- Media grid: video / audio (Phase 8) ----
   Same tile shell as photos (.media-grid figure already owns border/radius/
   background); these two rules only size the video/audio element itself. */
.media-grid video {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #000;
}

.media-grid figure.media-audio {
  display: grid;
  min-height: 0;
  align-content: center;
  aspect-ratio: 4 / 3;
  padding: 0 16px;
  background: rgba(255, 255, 255, 0.04);
}

.media-grid figure.media-audio audio {
  width: 100%;
}

/* ---- Tablet 761–1180 ---- */
@media (min-width: 761px) and (max-width: 1180px) {
  .car-spec-grid,
  .build-sheet-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .media-grid,
  .maintenance-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .car-hero h1 {
    font-size: clamp(3.2rem, 9vw, 6.4rem);
  }
}

/* ---- Phone ≤760 ---- */
@media (max-width: 760px) {
  .car-hero {
    display: grid;
    min-height: auto;
    align-content: start;
    padding: 22px;
  }

  .car-hero-copy {
    max-width: 100%;
    min-height: auto;
    align-content: start;
    padding: 0;
  }

  .car-hero h1 {
    font-size: clamp(2.7rem, 14vw, 5.2rem);
  }

  .car-hero-spec {
    position: relative;
    inset: auto;
    z-index: 2;
    width: 100%;
    margin-top: 18px;
    /* At most two columns; fall back to one when zoom leaves less than 7rem per value. */
    grid-template-columns: repeat(auto-fit, minmax(min(100%, max(7rem, calc((100% - 10px) / 2))), 1fr));
  }

  .car-spec-grid,
  .build-sheet-grid,
  .maintenance-grid,
  .media-grid {
    grid-template-columns: 1fr;
  }

  .car-event {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}

/* ---- Short landscape ---- */
@media (orientation: landscape) and (max-height: 560px) {
  .car-hero {
    min-height: 520px;
  }
}

/* ---- Interaction identity (Phase I-1) ----
   Build Sheet / Maintenance cards mount motion.css's .hx-lift behavior via
   a direct selector rather than an HTML class: both grids are re-rendered
   from /data/cars.json by js/cars/main.js (the static markup in cars.html
   is only the fetch-failure fallback), so a class written into that
   fallback markup would never reach the normal render path. This is the
   same "CSS-only mount, no HTML change" technique the Interaction
   Identity Brief sanctions for Travel's date-chip — kept in sync by hand
   with motion.css's .hx-lift if that definition changes. Hover-only (no
   :focus-visible): these are informational display cards, not links or
   controls, so they are never keyboard-focusable. */
.build-sheet-grid article,
.maintenance-grid article {
  position: relative;
}

.build-sheet-grid article::before,
.maintenance-grid article::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  box-shadow: var(--hx-shadow-float);
  opacity: 0;
  pointer-events: none;
}

@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  .build-sheet-grid article,
  .maintenance-grid article {
    transition: transform var(--hx-dur-fast) var(--hx-ease);
  }

  .build-sheet-grid article::before,
  .maintenance-grid article::before {
    transition: opacity var(--hx-dur-fast) var(--hx-ease);
  }

  .build-sheet-grid article:hover,
  .maintenance-grid article:hover {
    transform: translateY(-4px);
  }

  .build-sheet-grid article:hover::before,
  .maintenance-grid article:hover::before {
    opacity: 1;
  }
}

/* Tap feedback (hover:none only — hover-capable devices get the lift
   above instead, so this never doubles up). .media-grid figure is also
   JS-rendered from cars.json, same reasoning as above. */
@media (hover: none) {
  .media-grid figure:active {
    transform: scale(0.98);
  }
}

@media (hover: none) and (prefers-reduced-motion: no-preference) {
  .media-grid figure {
    transition: transform var(--hx-dur-fast) var(--hx-ease);
  }
}
.cars-archive-body { --hx-child-bg: var(--hx-theme-deep); }
