/* Car Project Page — Tema Noturno
   Layout CSS implementing references/car-project-layout.md from the nfsu2-design
   skill. This file is SHARED across every client page — it defines section
   structure, grid and breakpoints only. It never contains client data or a
   client's chosen accent color (that's one line in the project's own <style>
   block or a data attribute — see index.html).
   Requires nfsu2-tokens.css loaded first.
*/

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  overflow-x: hidden;
}
img { max-width: 100%; display: block; }

/* ============ Motion (per nfsu2-design/references/motion.md) ============ */

/* Ambient scanline drift — barely perceptible, subconsciously reads as a live
   screen rather than a static image. Reduced-motion kills it via tokens.css. */
.u2-atmosphere { animation: u2-drift 5s linear infinite; }

/* Scroll entrance: element starts hidden, JS adds .u2-enter (already defined
   in tokens.css as the rail-slide keyframe) once its section scrolls into
   view. One-time — not a repeating scroll effect. */
.u2-reveal { opacity: 0; }
.u2-reveal.u2-enter { opacity: 1; }

.wrap {
  max-width: 1280px;
  margin-inline: auto;
  padding-inline: 16px;
}
@media (min-width: 640px)  { .wrap { padding-inline: 32px; } }
@media (min-width: 1024px) { .wrap { padding-inline: 64px; } }

/* Anchor targets: offset by the sticky topbar height so a #numeros / #pecas jump
   doesn't land under it. Keep in sync with .cp-topbar height (56px / 64px). */
#numeros, #pecas, #ficha, #projeto, #galeria {
  scroll-margin-top: 64px;
}
@media (min-width: 1024px) {
  #numeros, #pecas, #ficha, #projeto, #galeria { scroll-margin-top: 72px; }
}

/* Skip link — visually hidden until focused */
.cp-skip-link {
  position: absolute; left: 16px; top: -48px; z-index: 300;
  background: var(--u2-steel-500); color: var(--u2-text);
  padding: 10px 18px; font-family: var(--u2-font-ui); font-weight: 600;
  font-size: .8125rem; text-transform: uppercase; letter-spacing: .12em;
  text-decoration: none;
  transition: top var(--u2-t-fast);
}
.cp-skip-link:focus-visible { top: 16px; }

/* Tap feedback across the whole page — dark theme reads badly with the default
   translucent-blue mobile tap highlight, and buttons should react to tap
   immediately, not wait out the double-tap-zoom delay. */
a, button, .cp-gallery__item {
  touch-action: manipulation;
  -webkit-tap-highlight-color: color-mix(in srgb, var(--u2-cyan) 25%, transparent);
}

/* ============ 1. TOPO ============ */

.cp-topbar {
  position: sticky; top: 0; z-index: 100;
  height: 56px;
  padding-top: env(safe-area-inset-top, 0px);
  background: var(--u2-asphalt);
  border-bottom: 1px solid color-mix(in srgb, var(--u2-accent) 50%, transparent);
  box-shadow: 0 1px 0 0 var(--u2-accent), 0 8px 24px -8px color-mix(in srgb, var(--u2-accent) 40%, transparent);
  display: flex; align-items: center; justify-content: space-between;
  transition: background var(--u2-t-fast);
}
@media (min-width: 1024px) { .cp-topbar { height: 64px; } }

.cp-topbar__inner {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
}
.cp-topbar .u2-wedge { font-size: .95rem; }
.cp-topbar__links { display: none; gap: var(--u2-s3); }
@media (min-width: 1024px) { .cp-topbar__links { display: flex; } }
/* Scroll-spy active state — current section gets the accent treatment a ghost
   button otherwise only shows on hover, so it reads as "here" not just "hoverable". */
.cp-topbar__links a[aria-current="true"] {
  color: var(--u2-accent);
  border-bottom-color: var(--u2-accent);
  text-shadow: 0 0 12px color-mix(in srgb, var(--u2-accent) 50%, transparent);
}

.cp-topbar__menu-btn { display: inline-flex; }
@media (min-width: 1024px) { .cp-topbar__menu-btn { display: none; } }

.cp-mobile-nav {
  position: fixed; inset: 0; z-index: 200;
  background: var(--u2-void);
  padding: 24px;
  display: none;
  flex-direction: column;
  gap: var(--u2-s2);
}
.cp-mobile-nav.is-open { display: flex; }
.cp-mobile-nav .u2-row { justify-content: space-between; }
.cp-mobile-nav__close { align-self: flex-end; }

/* ============ 2. HERO ============ */

/* Mobile/tablet: the photo box takes the photo's OWN proportion (3:4, same
   as hero-mobile.webp), so the image shows whole — no side crop, no empty
   band. Forcing the hero to fill the screen can't work: a phone viewport
   is ~1:2, the photo is 3:4, and something has to give (cropped car with
   cover, empty bar with contain). The text then overlaps only the bottom
   strip of the photo, which is wet asphalt, below the car.
   Desktop switches to the side-by-side split further down. */
.cp-hero {
  position: relative;
  display: flex; flex-direction: column;
}
@media (min-width: 1024px) {
  .cp-hero { flex-direction: row-reverse; align-items: stretch; min-height: 82vh; }
}

.cp-hero__media {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  /* Tablets (640-1023px) would get a 3:4 box taller than the screen; cap it
     and let cover trim ceiling/asphalt, which the car doesn't touch. */
  max-height: 78vh;
  max-height: 78svh;
  background: var(--u2-void);
  overflow: hidden;
}
@media (min-width: 1024px) {
  /* Keep the desktop photo's own 4:3 box. With aspect-ratio:auto the box took the
     row's height and cover trimmed ~20% off the sides, clipping nose and tail. */
  .cp-hero__media { flex: 0 0 55%; width: auto; aspect-ratio: 4 / 3; max-height: 82svh; align-self: center; }
}

/* <picture> stays an unstyled wrapper — Safari has a history of quirks with
   object-fit when sizing/positioning is split across <picture> and <img>. */
.cp-hero__media picture { display: block; }
.cp-hero__media img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover; object-position: center 50%;
}
@media (min-width: 1024px) {
  .cp-hero__media img { object-position: center 65%; }
}

/* Mobile: photo fades into the page background at the bottom, so the text
   sitting over that strip reads cleanly and there's no hard photo edge. */
.cp-hero__media::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 55%, rgba(5,7,10,.72) 82%, var(--u2-void) 100%);
}
@media (min-width: 1024px) {
  .cp-hero__media::after {
    background: radial-gradient(ellipse 120% 70% at 50% 100%, rgba(5,7,10,.85) 0%, transparent 55%);
  }
}

.cp-hero__body {
  position: relative; z-index: 2;
  margin-top: -88px;
  padding: 0 var(--u2-s5) var(--u2-s6);
}
@media (min-width: 1024px) {
  .cp-hero__body {
    margin-top: 0;
    flex: 0 0 45%;
    display: flex; flex-direction: column; justify-content: center;
    padding: var(--u2-s7);
  }
}

.cp-hero__tag { margin-bottom: var(--u2-s2); }
.cp-hero__title { margin: 0 0 var(--u2-s5); text-wrap: balance; }
.cp-hero__line { color: var(--u2-text-dim); font-size: 1rem; margin: 0 0 var(--u2-s5); text-wrap: pretty; }

/* ============ 3. NÚMEROS ============ */

.cp-numbers { padding-block: var(--u2-s7); }
.cp-numbers__title { margin-bottom: var(--u2-s5); }

.cp-numbers__row {
  display: flex; gap: var(--u2-s4);
  overflow-x: auto; scroll-snap-type: x mandatory;
  padding-bottom: var(--u2-s2);
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
}
/* Focusable on mobile so keyboard/switch users can scroll it (arrow keys),
   set via tabindex in the HTML when the row overflows; harmless no-op on lg
   where it becomes a static grid. */
.cp-numbers__row:focus-visible { outline: 2px solid var(--u2-accent); outline-offset: 4px; }
.cp-numbers__row::-webkit-scrollbar { display: none; }
.cp-numbers__row .u2-panel { flex: 0 0 78vw; scroll-snap-align: start; }

@media (min-width: 1024px) {
  .cp-numbers__row {
    display: grid; grid-template-columns: repeat(4, 1fr);
    overflow: visible;
  }
  .cp-numbers__row .u2-panel { flex: initial; }
}

/* Staggered entrance — each stat card ships with .u2-enter; delay them 60ms apart
   so they read as a sequence instead of popping in all at once. */
.cp-stat:nth-child(1) { animation-delay: 0ms; }
.cp-stat:nth-child(2) { animation-delay: 60ms; }
.cp-stat:nth-child(3) { animation-delay: 120ms; }
.cp-stat:nth-child(4) { animation-delay: 180ms; }

.cp-stat__watermark { position: relative; }
.cp-stat__watermark::before {
  content: attr(data-value);
  position: absolute; right: -.1em; bottom: -.15em;
  font-family: var(--u2-font-display); font-style: italic; font-weight: 800;
  font-size: 3.4em; color: var(--u2-text); opacity: .05; z-index: 0;
  pointer-events: none; white-space: nowrap;
}
.cp-stat__value { position: relative; z-index: 1; }
.cp-stat__delta {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--u2-font-mono); font-size: .75rem; letter-spacing: .08em;
  margin-top: var(--u2-s2);
}
.cp-stat__delta--gain { color: var(--u2-lime); }

/* ============ 4. PEÇAS ============ */

.cp-parts { padding-block: var(--u2-s7); }
.cp-parts__title { margin-bottom: var(--u2-s5); }
.cp-parts__systems { display: flex; flex-direction: column; gap: var(--u2-s4); }

@media (min-width: 1024px) {
  .cp-parts__systems {
    display: grid; grid-template-columns: repeat(2, 1fr); align-items: start;
  }
}

.cp-system__header {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; background: none; border: 0; padding: 0; margin-bottom: var(--u2-s4);
}
@media (min-width: 1024px) { .cp-system__header { cursor: default; } }

.cp-system__chevron { transition: transform var(--u2-t-fast); color: var(--u2-accent); }
.cp-system.is-collapsed .cp-system__chevron { transform: rotate(-90deg); }
@media (min-width: 1024px) { .cp-system__chevron { display: none; } }

.cp-system__items { display: flex; flex-direction: column; gap: 2px; }
.cp-system.is-collapsed .cp-system__items { display: none; }
@media (min-width: 1024px) { .cp-system.is-collapsed .cp-system__items { display: flex; } }

.cp-part__name { flex: 1; min-width: 0; font-size: .875rem; overflow-wrap: break-word; }
.cp-part__spec { display: block; color: var(--u2-text-dim); font-size: .75rem; font-weight: 500; }

.cp-tier {
  flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  height: 22px; padding: 0 10px;
  font-family: var(--u2-font-mono); font-size: .625rem; letter-spacing: .1em;
  clip-path: polygon(6px 0, 100% 0, 100% 100%, 0 100%, 0 6px);
}
.cp-tier--1 { background: var(--u2-steel-300); color: var(--u2-void); }
.cp-tier--2 { border: 1px solid var(--u2-cyan); color: var(--u2-cyan); }
.cp-tier--3 { background: var(--u2-accent); color: #04121B; box-shadow: var(--u2-glow-soft); font-weight: 700; }

/* ============ 5. FICHA TÉCNICA ============ */

.cp-specs { padding-block: var(--u2-s7); }
.cp-specs__title { margin-bottom: var(--u2-s5); }
.cp-specs__blocks { display: flex; flex-direction: column; gap: var(--u2-s5); }
@media (min-width: 1024px) {
  .cp-specs__blocks { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--u2-s4); }
}

.cp-specs__block-title { margin-bottom: var(--u2-s3); display: block; }
.cp-specs__row {
  display: flex; flex-direction: column; gap: 2px;
  padding-block: var(--u2-s2);
  border-bottom: 1px solid color-mix(in srgb, var(--u2-steel-300) 60%, transparent);
}
@media (min-width: 1024px) {
  .cp-specs__row { flex-direction: row; align-items: baseline; justify-content: space-between; gap: var(--u2-s3); }
}
.cp-specs__row .u2-label { font-size: .6875rem; }
.cp-specs__row .u2-num { font-size: .9375rem; text-align: right; }

/* ============ 6. O PROJETO ============ */

.cp-story { padding-block: var(--u2-s7); }
.cp-story__grid { display: flex; flex-direction: column; gap: var(--u2-s5); }
@media (min-width: 1024px) {
  .cp-story__grid { flex-direction: row; align-items: flex-start; gap: var(--u2-s6); }
}

.cp-story__text {
  font-size: 1rem; line-height: 1.65; max-width: 68ch;
  display: flex; flex-direction: column; gap: var(--u2-s4);
}
.cp-story__text p { margin: 0; }

.cp-story__feature { flex-shrink: 0; }
@media (min-width: 1024px) {
  .cp-story__feature { width: 35%; position: sticky; top: 96px; }
}
.cp-story__feature-media {
  aspect-ratio: 4 / 5; overflow: hidden; padding: 0;
}
.cp-story__feature-media img { width: 100%; height: 100%; object-fit: cover; }

/* ============ 7. GALERIA ============ */

.cp-gallery { padding-block: var(--u2-s7); }
.cp-gallery__title { margin-bottom: var(--u2-s5); }
.cp-gallery__grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
}
@media (min-width: 640px)  { .cp-gallery__grid { grid-template-columns: repeat(3, 1fr); gap: 16px; } }
@media (min-width: 1024px) { .cp-gallery__grid { grid-template-columns: repeat(4, 1fr); } }

.cp-gallery__item {
  position: relative;
  aspect-ratio: 1 / 1; overflow: hidden; cursor: pointer;
  background: var(--u2-steel-900);
  border: 0; padding: 0;
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
  transition: transform var(--u2-t-snap);
}
.cp-gallery__item img { width: 100%; height: 100%; object-fit: cover; transition: transform var(--u2-t-panel); }

/* Desktop/mouse: the classic hover — image zooms slightly under a static frame. */
@media (hover: hover) and (pointer: fine) {
  .cp-gallery__item:hover img { transform: scale(1.05); }
  .cp-gallery__item .cp-gallery__zoom-icon { opacity: 0; transition: opacity var(--u2-t-fast); }
  .cp-gallery__item:hover .cp-gallery__zoom-icon { opacity: 1; }
}

/* Touch: no hover to announce "this opens something", so the affordance icon
   stays always visible (low-key) instead, and press gives an immediate,
   layout-safe scale-down — image zoom-on-hover doesn't translate to tap. */
@media (hover: none), (pointer: coarse) {
  .cp-gallery__item .cp-gallery__zoom-icon { opacity: .85; }
}
.cp-gallery__item:active { transform: scale(.96); }

.cp-gallery__zoom-icon {
  position: absolute; right: 6px; bottom: 6px; z-index: 1;
  width: 26px; height: 26px; border-radius: 2px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(5,7,10,.55);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  border: 1px solid color-mix(in srgb, var(--u2-accent) 40%, transparent);
  color: var(--u2-chrome);
  pointer-events: none;
}

/* Nav/close/counter sit inside the dialog's own box (never negatively offset
   outside it) so no UA ever needs to give the <dialog> a scrollable overflow
   to reveal them — that scrollbar was the actual bug here.

   Below 768px: prev/next live in a control bar BELOW the photo, not overlaid
   on it — on a narrow screen the side arrows cover the car, and it's mobile
   where swipe is the primary way to move between photos anyway, so the
   buttons are a secondary affordance, not spatially urgent like on desktop.
   From 768px up: back to the classic side-overlay arrows (plenty of clear
   image either side of a landscape/portrait photo at that size). */
.cp-lightbox {
  border: 0; background: transparent;
  padding: 44px 16px 12px;
  max-width: 100vw; max-height: 100vh;
  width: 94vw; height: 90vh;
  overflow: hidden;
  overscroll-behavior: contain;
}
@media (min-width: 768px) {
  .cp-lightbox { padding: 48px 44px 40px; width: 92vw; height: 92vh; }
}
.cp-lightbox::backdrop { background: rgba(5,7,10,.82); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.cp-lightbox__inner {
  width: 100%; height: 100%;
  display: flex; flex-direction: column; gap: var(--u2-s3);
}
@media (min-width: 768px) {
  .cp-lightbox__inner { position: relative; align-items: center; justify-content: center; }
}

.cp-lightbox__stage {
  position: relative; flex: 1; min-height: 0;
  display: flex; align-items: center; justify-content: center;
}
@media (min-width: 768px) { .cp-lightbox__stage { width: 100%; height: 100%; } }

.cp-lightbox img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; }

/* Side overlay arrows — desktop only, hidden below 768px in favor of the bar. */
.cp-lightbox__nav { display: none; }
@media (min-width: 768px) {
  .cp-lightbox__nav {
    display: inline-flex;
    position: absolute; top: 50%; transform: translateY(-50%);
  }
  .cp-lightbox__nav--prev { left: 0; }
  .cp-lightbox__nav--next { right: 0; }
}

/* Bottom control bar — mobile only. */
.cp-lightbox__controls {
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--u2-s4);
}
@media (min-width: 768px) { .cp-lightbox__controls { display: none; } }

.cp-lightbox__counter {
  font-family: var(--u2-font-mono); font-size: .75rem; color: var(--u2-text-dim);
}
.cp-lightbox__close { position: absolute; top: 4px; right: 4px; z-index: 1; }

/* ============ 8. RODAPÉ ============ */

.cp-footer {
  padding-block: var(--u2-s7);
  border-top: 1px solid color-mix(in srgb, var(--u2-accent) 40%, transparent);
  background: var(--u2-asphalt);
}
.cp-footer__grid {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--u2-s6);
}
@media (min-width: 1024px) {
  .cp-footer__grid {
    flex-direction: row; align-items: flex-start; text-align: left; justify-content: space-between;
  }
}
.cp-footer__qr {
  width: 160px; height: 160px;
  padding: 10px;
  background: var(--u2-chrome-hi);
  box-shadow: var(--u2-bevel), 0 0 0 1px color-mix(in srgb, var(--u2-accent) 50%, transparent), var(--u2-glow-soft);
  clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
}
.cp-footer__qr-url { margin-top: var(--u2-s2); font-family: var(--u2-font-mono); font-size: .7rem; color: var(--u2-text-mute); }
.cp-footer__credit a { color: var(--u2-accent); text-decoration: none; }
.cp-footer__sponsors {
  display: flex; flex-wrap: wrap; gap: var(--u2-s3); justify-content: center;
}
@media (min-width: 1024px) { .cp-footer__sponsors { justify-content: flex-end; } }
.cp-footer__sponsors img { height: 28px; filter: grayscale(1) opacity(.6); transition: filter var(--u2-t-fast); }
@media (hover: hover) and (pointer: fine) {
  .cp-footer__sponsors a:hover img { filter: grayscale(0) opacity(1); }
}
.cp-footer__sponsors a:active img { filter: grayscale(0) opacity(1); }
