@font-face {
  font-family: "Archivo";
  src: url("assets/fonts/archivo-latin.woff2") format("woff2");
  font-weight: 400 900;
  font-stretch: 62% 125%;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* Pit board: brushed aluminum, black slide-in plates, the garage at dusk around them */
  --alu: url("assets/textures/aluminio.jpg");
  --plate-tex: url("assets/textures/placa.jpg");
  --alu-ink: #24272b;   /* engraved labels on aluminum */
  --plate: #17181a;
  --plate-ink: #f3f2ee;
  --p1: #f26b22;        /* only the P1 plate and the primary action */
  --flag: #eab51f;      /* only Reservada */
  --garage: #1b1714;
  --garage-lo: #120f0d;
  --ink: #ece6dc;
  --ink-soft: #b9b0a3;
  --fondo-stock: none;  /* main.js puts the animation's last frame here */
  --gut: 16px;
  --rivet: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cdefs%3E%3CradialGradient id='g' cx='.35' cy='.3' r='.75'%3E%3Cstop offset='0' stop-color='%23f4f5f6'/%3E%3Cstop offset='.55' stop-color='%23a2a6ab'/%3E%3Cstop offset='1' stop-color='%23575b60'/%3E%3C/radialGradient%3E%3C/defs%3E%3Ccircle cx='8' cy='8.6' r='7' fill='%23000' opacity='.35'/%3E%3Ccircle cx='8' cy='8' r='6.5' fill='url(%23g)'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; color-scheme: dark; scrollbar-color: #a7abb0 var(--garage-lo); }
body {
  margin: 0;
  background: var(--garage);
  color: var(--ink);
  font-family: "Archivo", system-ui, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--plate-ink); color: var(--plate); }
img { max-width: 100%; display: block; }
a { color: inherit; text-underline-offset: .2em; }
:focus-visible { outline: 3px solid var(--plate-ink); outline-offset: 3px; box-shadow: 0 0 0 6px var(--plate); }
.wrap { width: min(1240px, 100% - 2 * var(--gut)); margin-inline: auto; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.icon { width: 1.15em; height: 1.15em; flex: none; }

/* ---------- The board: brushed aluminum sheet, rivets in the corners ---------- */
.board {
  position: relative;
  padding: 16px 16px 14px;
  border-radius: 5px;
  background:
    linear-gradient(170deg, rgba(255,255,255,.22), rgba(255,255,255,0) 40%, rgba(0,0,0,.12)),
    var(--alu) center / 520px;
  box-shadow: 0 1px 1px rgba(0,0,0,.35), 0 22px 44px -14px rgba(0,0,0,.7);
  display: grid;
  gap: 8px;
}
.board::before {
  content: ""; position: absolute; inset: 5px; pointer-events: none;
  background: var(--rivet) top left / 8px no-repeat, var(--rivet) top right / 8px no-repeat,
              var(--rivet) bottom left / 8px no-repeat, var(--rivet) bottom right / 8px no-repeat;
}

/* A rail is the channel the plates slide into; one tile per letter */
.rail {
  container-type: inline-size;
  position: relative;
  margin: 0;
  min-height: calc(1em + 14px);
  padding: 4px;
  border-radius: 3px;
  background: linear-gradient(rgba(0,0,0,.42), rgba(0,0,0,.26)), var(--alu) center / 520px;
  box-shadow: inset 0 2px 4px rgba(0,0,0,.55), inset 0 -1px 1px rgba(255,255,255,.35);
  overflow: hidden;
  font-size: 1rem;
}
.rail-in {
  display: flex; gap: 3px;
  font-size: min(2.6rem, calc((100cqw - (var(--n) - 1) * 3px) / var(--n) * 1.25));
}
.tile {
  flex: 0 0 calc(1em * .8);
  height: 1.12em;
  display: grid; place-items: center;
  background: linear-gradient(rgba(255,255,255,.07), rgba(0,0,0,.15)), var(--plate-tex) center / 300px, var(--plate);
  color: var(--plate-ink);
  border-radius: 2px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.14), 0 1px 3px rgba(0,0,0,.6);
  font-weight: 900;
  font-stretch: 62%;
  line-height: 1;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
}
.tile.gap { background: transparent; box-shadow: none; }

/* Plates: a whole word on one plate (controls and tags) */
.plate {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  padding: .55em .9em .5em;
  border: 0;
  border-radius: 3px;
  background: linear-gradient(rgba(255,255,255,.08), rgba(0,0,0,.18)), var(--plate-tex) center / 300px, var(--plate);
  color: var(--plate-ink);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.16), 0 2px 4px rgba(0,0,0,.55);
  font: inherit;
  font-weight: 900;
  font-stretch: 70%;
  font-size: 1.05rem;
  letter-spacing: .03em;
  text-transform: uppercase;
  text-decoration: none;
  line-height: 1;
  cursor: pointer;
  transition: transform .12s ease-out, box-shadow .12s ease-out;
}
a.plate:hover, button.plate:hover { transform: translateY(-1px); box-shadow: inset 0 1px 0 rgba(255,255,255,.16), 0 4px 8px rgba(0,0,0,.55); }
a.plate:active, button.plate:active { transform: translateY(1px); box-shadow: inset 0 1px 0 rgba(255,255,255,.1), 0 1px 2px rgba(0,0,0,.5); }
/* Black on orange, like a real P1 board: white on this orange fails contrast */
.plate-p1 {
  background: linear-gradient(rgba(242,107,34,.9), rgba(226,94,24,.92)), var(--plate-tex) center / 300px;
  color: var(--plate);
}
.plate-flag { background: linear-gradient(rgba(234,181,31,.92), rgba(220,168,24,.94)), var(--plate-tex) center / 300px; color: #241a02; }

/* ---------- Top bar: a small board, out of the way while reading the stock ---------- */
.topbar {
  position: fixed; top: 12px; left: var(--gut); z-index: 20;
  display: flex; align-items: center; gap: 24px;
  padding: 12px 16px 12px 24px;
  transition: transform .35s cubic-bezier(.16,1,.3,1);
}
.topbar.is-away { transform: translateY(calc(-100% - 20px)); }
.topbar-badge img { width: auto; height: 70px; }
.plate-link { font-size: 1.66rem; }

/* ---------- Hero: the ride ---------- */
.hero { height: 520vh; position: relative; }
.no-gsap .hero { height: auto; }
.no-gsap .shutter, .no-gsap .hero-hint { display: none; }
.hero-sticky { position: sticky; top: 0; height: 100vh; height: 100svh; overflow: hidden; }
.hero-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.hero-sticky::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, rgba(0,0,0,.3), transparent 22%, transparent 55%, rgba(0,0,0,.5));
}
.hero-load { position: absolute; inset: 0 0 auto; height: 3px; z-index: 2; }
.hero-load span { display: block; height: 100%; background: var(--plate-ink); transform: scaleX(0); transform-origin: left; transition: transform .2s linear, opacity .4s; }

.hero-board {
  position: absolute; z-index: 3;
  left: clamp(var(--gut), 4vw, 64px);
  bottom: clamp(56px, 9vh, 96px);
  /* capped at the width of a full 13-tile row, so rails don't run half empty on wide screens */
  width: clamp(320px, 38vw, 520px);
}
.rail-action { display: flex; padding: 4px 0 0; }
.rail-action .plate { font-size: 1.25rem; padding: .65em 1.1em .6em; }
/* the flex gap is the only space before "·", so it matches a word space */
.hero-board .plate-p1 { gap: .28em; }
.hero-hint {
  position: absolute; z-index: 3; right: clamp(var(--gut), 4vw, 64px); bottom: clamp(56px, 9vh, 96px);
  margin: 0; display: flex; align-items: center; gap: .4em;
  font-size: .95rem; color: var(--ink);
  text-shadow: 0 1px 8px rgba(0,0,0,.7);
}
.hero-hint .icon { animation: nudge 1.8s cubic-bezier(.16,1,.3,1) infinite; }
@keyframes nudge { 50% { transform: translateY(4px); } }

/* ---------- Boxes: the stock ---------- */
.boxes {
  position: relative;
  padding: clamp(110px, 15vh, 170px) 0 clamp(80px, 12vh, 140px);
  background:
    linear-gradient(rgba(27,23,20,.74), rgba(18,15,13,.9) 45%, rgba(18,15,13,.97)),
    var(--fondo-stock) center top / cover no-repeat,
    var(--garage);
  overflow: hidden;
}
/* The boxes' roller door rolls up as you arrive */
.shutter {
  position: absolute; inset: 0 0 auto; height: 100vh; z-index: 5; pointer-events: none;
  background: url("assets/textures/persiana.jpg") center top / max(100%, 1200px) auto repeat-y, #9da1a6;
  box-shadow: inset 0 -16px 18px -6px rgba(0,0,0,.6);
}
/* Bottom bar and pull handle of the roller door */
.shutter::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 22px;
  background: linear-gradient(rgba(0,0,0,.35), rgba(0,0,0,.6)), var(--alu) center / 520px;
  box-shadow: 0 6px 14px rgba(0,0,0,.55);
}
.shutter::before {
  content: ""; position: absolute; z-index: 1; left: 50%; bottom: 6px; width: 120px; height: 10px; margin-left: -60px;
  border-radius: 5px; background: linear-gradient(#2a2c2f, #0e0f10);
  box-shadow: 0 1px 0 rgba(255,255,255,.25);
}
.boxes-head { display: grid; gap: 18px; justify-items: start; margin-bottom: 28px; }
.board-title { width: min(420px, 100%); }
.boxes-lede { margin: 0; max-width: 46ch; color: var(--ink-soft); font-size: 1.125rem; }
.boxes-lede strong { color: var(--ink); }

.board-filters { display: inline-flex; flex-wrap: wrap; gap: 8px; padding: 12px; margin-bottom: 36px; }
.board-filters .plate[aria-pressed="true"] {
  background: linear-gradient(rgba(255,255,255,.96), rgba(233,233,230,.96)), var(--plate-tex) center / 300px;
  color: var(--plate);
  transform: translateY(1px);
  box-shadow: inset 0 1px 0 #fff, 0 1px 2px rgba(0,0,0,.4);
}

.boxes-status { color: var(--ink-soft); max-width: 46ch; }
.boxes-status:empty { display: none; }
.boxes-status .plate { margin-top: 16px; }

.boxes-grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: clamp(22px, 3vw, 40px);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
}

/* One bike = one pit board: the rails carry it, the photo is a window in the sheet */
.bike { padding: 14px; gap: 7px; display: flex; flex-direction: column; }
.bike > .rail-action { margin-top: auto; }
/* P1: the newest arrival gets its own rail of orange plates, at name scale */
.rail-p1 .tile { background: linear-gradient(rgba(242,107,34,.92), rgba(226,94,24,.94)), var(--plate-tex) center / 300px; color: var(--plate); }
.bike-tags { display: flex; flex-wrap: wrap; gap: 6px; padding: 5px; min-height: 0; }
.bike-tags .plate { font-size: .85rem; padding: .45em .7em .4em; cursor: default; }
.bike-photo {
  position: relative; aspect-ratio: 16 / 9; border-radius: 3px; overflow: hidden; margin: 2px 0;
  background: radial-gradient(circle at 50% 35%, #34302c, #191613);
  box-shadow: inset 0 2px 6px rgba(0,0,0,.7), 0 0 0 1px rgba(0,0,0,.25);
}
/* contain: the stock photos come from phones, often upright; the whole bike shows and the dark window fills the sides */
.bike-photo img { width: 100%; height: 100%; object-fit: contain; }
.bike-photo .no-photo { position: absolute; inset: 0; margin: auto; width: 26%; height: auto; opacity: .3; object-fit: contain; }
/* With photos the window opens the viewer; a plate in the corner says how many */
button.bike-photo { display: block; width: 100%; padding: 0; border: 0; font: inherit; cursor: zoom-in; }
.bike-photo-count { position: absolute; right: 8px; bottom: 8px; font-size: .85rem; padding: .45em .7em .4em; }
.bike h3 { margin: 0; }
.bike-data { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; margin: 0; }
.bike-data div { display: grid; gap: 3px; align-content: start; }
.bike-data dt {
  font-size: .75rem; font-weight: 800; font-stretch: 80%; letter-spacing: .04em;
  color: var(--alu-ink); text-shadow: 0 1px 0 rgba(255,255,255,.45);
}
.bike-data dd { margin: 0; }
.bike .rail-action { justify-content: flex-end; }
.bike .rail-action .plate { font-size: 1.1rem; padding: .75em 1.4em .7em; }

/* ---------- Photo viewer: one board over the page, the photos slide sideways ---------- */
body:has(.visor[open]) { overflow: hidden; }
.visor { width: min(1100px, 100% - 2 * var(--gut)); max-width: none; max-height: none; padding: 12px; border: 0; color: var(--ink); }
/* .board sets position: relative and display: grid, which beat the dialog's own fixed position and closed display: none */
.visor { position: fixed; }
.visor:not([open]) { display: none; }
.visor::backdrop { background: rgba(12, 10, 9, .9); }
.visor-fotos {
  display: flex; min-height: 0; margin: 0; padding: 0; list-style: none;
  overflow-x: auto; scroll-snap-type: x mandatory; overscroll-behavior-x: contain; scrollbar-width: none;
  border-radius: 3px;
  background: radial-gradient(circle at 50% 35%, #34302c, #191613);
  box-shadow: inset 0 2px 6px rgba(0,0,0,.7);
}
.visor-fotos li { flex: 0 0 100%; scroll-snap-align: center; height: min((min(1100px, 100vw - 2 * var(--gut)) - 24px) * .75, 100svh - 150px - var(--notas-h, 0px)); }
.visor-fotos img { width: 100%; height: 100%; object-fit: contain; }
.visor-bar { display: flex; align-items: center; gap: 8px; }
.visor-bar .plate { min-width: 48px; min-height: 44px; }
.visor-count {
  margin: 0 auto 0 4px; font-weight: 900; font-stretch: 70%; font-variant-numeric: tabular-nums;
  color: var(--alu-ink); text-shadow: 0 1px 0 rgba(255,255,255,.45);
}
.visor.is-single :is(.visor-count, .visor-prev, .visor-next) { visibility: hidden; }
/* Observaciones: engraved label on the aluminum, then a black plate with one row per line typed in the Form */
.visor-notas { display: grid; gap: 4px; }
.visor-notas[hidden] { display: none; }
.visor-notas h2 {
  margin: 0 0 0 4px; font-size: .75rem; font-weight: 800; font-stretch: 80%; letter-spacing: .04em;
  color: var(--alu-ink); text-shadow: 0 1px 0 rgba(255,255,255,.45);
}
.visor-notas ul {
  margin: 0; padding: 2px 14px; list-style: none; max-height: 30svh; overflow-y: auto;
  border-radius: 3px; color: var(--plate-ink); line-height: 1.4;
  background: linear-gradient(rgba(255,255,255,.07), rgba(0,0,0,.15)), var(--plate-tex) center / 300px, var(--plate);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.14), 0 1px 3px rgba(0,0,0,.6);
}
.visor-notas li { padding: 7px 0; }
.visor-notas li + li { border-top: 1px solid rgba(243,242,238,.12); }

/* ---------- Exit ---------- */
.pit-exit { background: var(--garage-lo); padding: 64px 0 24px; box-shadow: inset 0 6px 6px -4px rgba(0,0,0,.6); }
.pit-exit-in { display: flex; gap: 28px; align-items: center; flex-wrap: wrap; }
.pit-exit h2 { margin: 0 0 .25em; font-weight: 900; font-stretch: 70%; font-size: clamp(1.8rem, 4vw, 2.6rem); line-height: 1; text-transform: uppercase; }
.pit-exit p { margin: .3em 0; color: var(--ink-soft); }
.pit-exit-links { display: flex; gap: 20px; flex-wrap: wrap; }
.pit-exit-links a { color: var(--ink); font-weight: 600; }
.pit-exit .pit-exit-note { margin-top: 12px; color: var(--ink); font-size: .9rem; font-weight: 600; }
.pit-exit .pit-exit-legal { margin: 40px auto 0; font-size: .85rem; color: var(--ink-soft); }

@media (max-width: 720px) {
  /* On a phone the rider sits low in the frame, so the board hangs from the top */
  .hero-board { width: auto; right: var(--gut); top: 112px; bottom: auto; }
  /* inside the boxes the ZM sign sits where the board hangs, so the board drops over the handlebars */
  .hero-board.is-final { top: auto; bottom: 32px; animation: board-drop .45s cubic-bezier(.16,1,.3,1); }
  @keyframes board-drop { from { opacity: 0; transform: translateY(-24px); } }
  .hero-hint { left: var(--gut); right: auto; bottom: 24px; }
  .topbar { right: var(--gut); gap: 12px; justify-content: space-between; }
  .topbar-badge img { height: 60px; }
  /* On a phone the viewer spans edge to edge; bike photos are landscape, so it stays as tall as the photo */
  .visor { width: 100%; border-radius: 0; }
  .visor-fotos li { height: min((100vw - 24px) * .75, 100svh - 150px - var(--notas-h, 0px)); }
}

/* Without motion: still poster, the board shows the whole message */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .plate, .topbar, .hero-board, .hero-hint .icon { transition: none; animation: none; }
}
