/* Light Lab POC-02.2, the corrective round of POC-02.1 (itself a premium polish of POC-02). The light is still the narrator: it travels to the part that
   matches the chosen warning light. Every state lives here, driven by checked radios, so the lab, the repairs diagram
   and the Paint Studio work without JavaScript; lab.js only adds the light's path, the way in, the comparison and
   announcements. */
@font-face {
  font-family: Sora;
  src: url(../fuentes/Sora-variable.woff) format("woff");
  font-weight: 100 800;
  font-display: optional;
}

/* Registered, so the browser interpolates the focus and retargets it mid-flight when another light is chosen. */
@property --fx { syntax: "<percentage>"; inherits: true; initial-value: 60%; }
@property --fy { syntax: "<percentage>"; inherits: true; initial-value: 60%; }
@property --frx { syntax: "<percentage>"; inherits: true; initial-value: 0%; }
@property --fry { syntax: "<percentage>"; inherits: true; initial-value: 0%; }
@property --barrido { syntax: "<percentage>"; inherits: false; initial-value: 140%; }
@property --brillo { syntax: "<number>"; inherits: true; initial-value: 1.8; }

:root {
  --noche: #0b0c0e;
  --carbon: #131518;
  --grafito: #1c1f23;
  --borde: #6a665f;
  --marfil: #ece6db;
  --niebla: #c9c2b6;
  --naranja: #ff6a2b;
  --tinta: #120c08;
  --rojo: #ff5847;
  --ambar: #ffb01f;
  --hielo: #b9dff0;
  --gutter: clamp(16px, 4.6vw, 72px);
  --curva: cubic-bezier(.77, 0, .175, 1);
  --salida: cubic-bezier(.23, 1, .32, 1);
  --viaje: 640ms;
  /* Portrait: the stage stays pinned while the words scroll under it, so focus must land below it. */
  --escenario: min(76.85vw, 46svh);
  color-scheme: dark;
}
:root[data-modo="teclado"] { --viaje: 280ms; }

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--noche); -webkit-text-size-adjust: 100%; }
/* Portrait: whatever takes focus inside the lab scrolls clear of the pinned stage; other sections are unaffected. */
#cuadro, .lab :is(button, .ficha) { scroll-margin-top: calc(var(--escenario) + 12px); }
.lab .testigo input { scroll-margin-top: calc(var(--escenario) + 12px); }
body {
  margin: 0;
  background: var(--noche);
  color: var(--marfil);
  font-family: Sora, "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}
p, h1, h2, h3, dl, dd, figure { margin: 0; }
/* Two rings, so the focus reads over the black studio and over the lit car alike. */
:focus-visible { outline: 2px solid var(--marfil); outline-offset: 3px; box-shadow: 0 0 0 6px rgb(11 12 14 / .85); border-radius: 6px; }
.oculto { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
[hidden] { display: none !important; }

.salto {
  position: absolute; left: 12px; top: 0; z-index: 40;
  translate: 0 -100%;
  background: var(--marfil); color: var(--tinta);
  padding: 12px 16px; border-radius: 8px; font-weight: 600; text-decoration: none;
}
.salto:focus { top: 12px; translate: none; }

/* Top bar: the internal-use notice and three section links. */
.barra {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0 18px;
  padding: 4px var(--gutter);
  background: var(--carbon);
}
.aviso { padding: 6px 0; color: var(--niebla); font-size: .8125rem; }
.secciones { display: flex; flex-wrap: wrap; gap: 0 16px; }
.secciones a { display: inline-block; padding: 8px 0; color: var(--marfil); font-size: .8125rem; font-weight: 600; text-decoration: none; border-bottom: 1px solid transparent; }
@media (hover: hover) and (pointer: fine) {
  .secciones a:hover { border-bottom-color: var(--marfil); }
}

/* ---------- the lab, portrait first: words, then the car, then the dashboard ---------- */
.lab {
  position: relative;
  display: flex; flex-direction: column;
  isolation: isolate;
  /* Where the light lands on the 4:5 plate: 3D points on the car projected through the render camera
     (render/tools/zonas.py, AS-01 car). Radii are 1.55 times the part (1.3 for the bonnet) so the light reads. */
  --reposo-x: 59.07%; --reposo-y: 73.19%;
  --frenos-x: 63.05%; --frenos-y: 79.26%; --frenos-rx: 13.3%; --frenos-ry: 10.64%;
  --motor-x: 36.27%; --motor-y: 66.27%; --motor-rx: 20.2%; --motor-ry: 16.16%;
  --electrico-x: 46.98%; --electrico-y: 72.32%; --electrico-rx: 12.6%; --electrico-ry: 10.08%;
  --neumaticos-x: 89.97%; --neumaticos-y: 74.92%; --neumaticos-rx: 14.1%; --neumaticos-ry: 11.28%;
  --fx: var(--reposo-x); --fy: var(--reposo-y); --frx: 0%; --fry: 0%; --brillo: 1.8;
  /* Studio key lights on front, bonnet, flares, wheels and wing: 3D points projected through the plate camera. */
  --esculpido: radial-gradient(ellipse 18.9% 15.1% at 31.5% 75.9%, rgb(0 0 0 / .85), rgb(0 0 0 / .38) 55%, transparent),
    radial-gradient(ellipse 17.2% 13.8% at 36.7% 66.3%, rgb(0 0 0 / .75), rgb(0 0 0 / .34) 55%, transparent),
    radial-gradient(ellipse 13.9% 11.1% at 63.3% 73%, rgb(0 0 0 / .9), rgb(0 0 0 / .41) 55%, transparent),
    radial-gradient(ellipse 12.6% 10.1% at 90.4% 70.2%, rgb(0 0 0 / .9), rgb(0 0 0 / .41) 55%, transparent),
    radial-gradient(ellipse 10.5% 8.4% at 63% 79.1%, #000, rgb(0 0 0 / .45) 55%, transparent),
    radial-gradient(ellipse 8.2% 6.6% at 89.9% 75.3%, #000, rgb(0 0 0 / .45) 55%, transparent),
    radial-gradient(ellipse 13.2% 10.6% at 85.7% 55.5%, rgb(0 0 0 / .85), rgb(0 0 0 / .38) 55%, transparent);
  transition: --fx var(--viaje) var(--curva), --fy var(--viaje) var(--curva), --frx 520ms var(--salida), --fry 520ms var(--salida), --brillo 420ms var(--salida);
}
.cabeza { position: relative; z-index: 2; padding: 20px var(--gutter) 0; }
.antetitulo { color: var(--niebla); font-size: .75rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; margin-bottom: 10px; }
h1 { font-size: min(clamp(2.5rem, 13vw, 5.5rem), 17vw); line-height: 1; font-weight: 700; letter-spacing: -.035em; }
.punto { color: var(--naranja); }
.entrada { margin-top: 12px; max-width: 30em; color: var(--niebla); }

/* The stage frames the car on the 4:5 plate and pins itself to the top while the card is read. */
.escena-marco {
  position: sticky; top: 0; z-index: 3;
  overflow: hidden;
  aspect-ratio: 1080 / 830; max-height: 46svh;
  margin-top: 8px;
  background: var(--noche);
}
.escena { position: absolute; left: 0; top: 55%; width: 100%; aspect-ratio: 4 / 5; translate: 0 -70%; }
.escena picture { display: contents; }
.placa { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; color: transparent; }

/* Ambient light: the whole car, softly. It steps back when a part takes the light. */
.placa-ambiente { opacity: .5; transition: opacity 700ms var(--salida); }
/* Sculpted light: the lit plate once more, only where the eye should land first. It bows out when a part takes the light. */
.placa-escultura {
  -webkit-mask-image: var(--esculpido);
  mask-image: var(--esculpido);
  opacity: .85;
  filter: brightness(1.25);
  transition: opacity 700ms var(--salida);
}
/* The focus: the lit plate again, seen through a moving ellipse. Plates are registered, so nothing shifts. */
.placa-foco {
  -webkit-mask-image: radial-gradient(ellipse var(--frx) var(--fry) at var(--fx) var(--fy), #000 0%, #000 42%, rgb(0 0 0 / .5) 70%, transparent 100%);
  mask-image: radial-gradient(ellipse var(--frx) var(--fry) at var(--fx) var(--fy), #000 0%, #000 42%, rgb(0 0 0 / .5) 70%, transparent 100%);
  /* Per part: the bonnet already carries bright reflections and would clip at the gain the wheels need. */
  filter: brightness(var(--brillo)) contrast(1.04);
}
/* A faint pool of air lit around the part, so the light reads as light and not only as a brighter photo. */
.escena::after {
  content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background: radial-gradient(ellipse var(--frx) var(--fry) at var(--fx) var(--fy), rgb(255 240 222 / .13), rgb(255 240 222 / .04) 60%, transparent 100%);
  mix-blend-mode: screen;
}
/* The lamps are light added to the image, so they only need an additive blend. */
.placa-faros { opacity: 0; mix-blend-mode: screen; mix-blend-mode: plus-lighter; transition: opacity 480ms var(--salida); }

/* Precision reticle on the part. It travels with the light and opens with it. Its layer is the size of the stage and is
   moved with a transform (translate in % of itself, so % of the stage): the travel is never a layout shift. */
.reticula-marco { position: absolute; inset: 0; z-index: 3; pointer-events: none; translate: var(--fx) var(--fy); }
.reticula {
  position: absolute; left: 0; top: 0;
  width: calc(var(--frx) * 1.25); aspect-ratio: 1;
  translate: -50% -50%; scale: .9;
  opacity: 0;
  color: var(--tono, var(--marfil));
  fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round;
  pointer-events: none;
  transition: opacity 200ms var(--salida), scale 260ms var(--salida);
}
.reticula .aro-fino { stroke-dasharray: 2 5; opacity: .7; }
.reticula .marcas { stroke-width: 3; }

/* ---------- the dashboard ---------- */
.mando { position: relative; z-index: 2; padding: 14px var(--gutter) 32px; }
.cuadro { container-type: inline-size; }
.cuadro fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.cuadro legend { float: left; width: 100%; padding: 0; margin-bottom: 10px; color: var(--niebla); font-size: .75rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; }
/* Four lights in a row when they fit, two by two otherwise (also when the text is enlarged, since the query is in rem). */
.testigos { clear: both; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@container (min-width: 25rem) {
  .testigos { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
/* One per row when even two would split «Neumáticos»; in rem, so it follows enlarged text. */
@container (max-width: 13rem) {
  .testigos { grid-template-columns: 1fr; }
}
.testigo {
  position: relative;
  min-height: 4.75rem;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 6px;
  border: 1px solid rgb(236 230 219 / .18); border-radius: 14px;
  background: rgb(19 21 24 / .84);
  color: var(--niebla);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 160ms var(--salida), background-color 160ms var(--salida), transform 140ms var(--salida);
}
/* The hidden input spans its light: focusing it brings the whole light into view, not a 1 px point at its centre. */
.testigo input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; pointer-events: none; scroll-margin-bottom: 10px; }
.testigo svg { width: 2rem; height: 2rem; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; transition: color 160ms var(--salida), filter 220ms var(--salida); }
.testigo .lleno { fill: currentColor; stroke: none; }
.testigo span { color: var(--marfil); font-size: .875rem; font-weight: 600; text-align: center; overflow-wrap: break-word; hyphens: manual; }
.testigo:active { transform: scale(.97); }
.t-frenos { --auto: var(--rojo); }
.t-motor { --auto: var(--ambar); }
.t-electrico { --auto: var(--rojo); }
.t-neumaticos { --auto: var(--ambar); }
.testigo:has(input:checked) { border-color: var(--auto); background: rgb(28 31 35 / .94); }
.testigo:has(input:checked) svg { color: var(--auto); filter: drop-shadow(0 0 7px var(--auto)); }
/* WebKit drops :focus-visible when arrow keys move focus inside a radio group; lab.js marks keyboard use on the root. */
.testigo:has(input:focus-visible),
:root[data-modo="teclado"] .testigo:has(input:focus) { outline: 2px solid var(--marfil); outline-offset: 3px; box-shadow: 0 0 0 6px rgb(11 12 14 / .85); }
@media (hover: hover) and (pointer: fine) {
  .testigo:hover { border-color: rgb(236 230 219 / .45); }
}

/* All cards share one cell and stretch to the longest, so the block never changes size and nothing moves. */
.fichas { display: grid; margin-top: 14px; }
.ficha {
  grid-area: 1 / 1;
  padding: 16px 18px 18px;
  border: 1px solid rgb(236 230 219 / .14); border-radius: 14px;
  background: rgb(17 19 22 / .9);
  opacity: 0; visibility: hidden;
  transform: translateY(6px); filter: blur(2px);
  transition: opacity 140ms ease-out, transform 140ms ease-out, filter 140ms ease-out, visibility 0s linear 140ms;
}
.ficha-t { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-bottom: 10px; color: var(--marfil); font-weight: 600; }
.nivel { padding: 1px 8px; border: 1px solid currentColor; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.nivel-rojo { color: var(--rojo); }
.nivel-ambar { color: var(--ambar); }
.ficha dl { display: grid; gap: 6px; }
.ficha dt { padding-top: 8px; border-top: 1px solid rgb(236 230 219 / .12); color: var(--niebla); font-size: .75rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.ficha dd { margin-bottom: 4px; color: var(--marfil); font-size: .9375rem; }
.nota-orientativa { grid-area: 2 / 1; margin-top: 8px; color: var(--niebla); font-size: .8125rem; }

.lab:not(:has(.cuadro input:checked)) .ficha-inicio,
.lab:has(#t-frenos:checked) .ficha-frenos,
.lab:has(#t-motor:checked) .ficha-motor,
.lab:has(#t-electrico:checked) .ficha-electrico,
.lab:has(#t-neumaticos:checked) .ficha-neumaticos {
  opacity: 1; visibility: visible; transform: none; filter: none;
  transition: opacity 240ms var(--salida) 140ms, transform 300ms var(--salida) 140ms, filter 240ms ease 140ms, visibility 0s;
}

.acciones { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.cta, .apagar, .nota button, .servicio-cta {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 10px 20px;
  border-radius: 999px;
  font-family: inherit; font-size: .9375rem; font-weight: 600; line-height: 1.2;
  cursor: pointer;
  transition: transform 140ms var(--salida), background-color 160ms ease, border-color 160ms ease;
}
.cta { border: 0; background: var(--marfil); color: var(--tinta); }
.apagar, .nota button, .servicio-cta { border: 1px solid var(--borde); background: var(--noche); color: var(--marfil); }
.cta:active, .apagar:active, .nota button:active, .servicio-cta:active { transform: scale(.97); }
@media (hover: hover) and (pointer: fine) {
  .cta:hover { background: #fff; }
  .apagar:hover, .nota button:hover, .servicio-cta:hover { border-color: var(--marfil); }
}

.nota {
  max-width: min(24rem, calc(100vw - 32px));
  padding: 18px 20px;
  border: 1px solid var(--borde); border-radius: 14px;
  background: var(--carbon); color: var(--niebla);
  opacity: 1; translate: 0 0;
  transition: opacity 180ms var(--salida), translate 220ms var(--salida);
}
@starting-style { .nota:popover-open { opacity: 0; translate: 0 6px; } }
.nota::backdrop { background: rgb(0 0 0 / .45); }
.nota .ficha-t { margin-bottom: 6px; }
.nota button { margin-top: 14px; }

/* ---------- states: one rule per warning light ---------- */
.lab:has(#t-frenos:checked) { --fx: var(--frenos-x); --fy: var(--frenos-y); --frx: var(--frenos-rx); --fry: var(--frenos-ry); --tono: var(--rojo); }
.lab:has(#t-motor:checked) { --fx: var(--motor-x); --fy: var(--motor-y); --frx: var(--motor-rx); --fry: var(--motor-ry); --tono: var(--ambar); --brillo: 1.15; }
.lab:has(#t-electrico:checked) { --fx: var(--electrico-x); --fy: var(--electrico-y); --frx: var(--electrico-rx); --fry: var(--electrico-ry); --tono: var(--rojo); }
.lab:has(#t-neumaticos:checked) { --fx: var(--neumaticos-x); --fy: var(--neumaticos-y); --frx: var(--neumaticos-rx); --fry: var(--neumaticos-ry); --tono: var(--ambar); }
.lab:has(.cuadro input:checked) .placa-ambiente { opacity: .16; }
.lab:has(.cuadro input:checked) .placa-escultura { opacity: 0; }
.lab:has(.cuadro input:checked) .reticula { opacity: 1; scale: 1; transition-delay: 180ms; }
.lab:has(#t-electrico:checked) .placa-faros { opacity: 1; }

/* ---------- the way in: one sweep, then the dashboard checks its lights, as a car does at ignition ----------
   The markup starts with .intro, held paused, so the lit plate can never flash before the sweep; lab.js lets it run
   once the plate is decoded. Without scripting none of this applies and the car is simply lit. */
@media (scripting: enabled) {
  .lab.intro .placa-ambiente {
    -webkit-mask-image: linear-gradient(100deg, #000 calc(var(--barrido) - 35%), transparent var(--barrido));
    mask-image: linear-gradient(100deg, #000 calc(var(--barrido) - 35%), transparent var(--barrido));
    animation: barrido 1500ms cubic-bezier(.35, 0, .25, 1) both paused;
  }
  .lab.intro .testigo svg { animation: autotest 900ms ease-out 1000ms both paused; }
  .lab.intro .t-motor svg { animation-delay: 1060ms; }
  .lab.intro .t-electrico svg { animation-delay: 1120ms; }
  .lab.intro .t-neumaticos svg { animation-delay: 1180ms; }
  .lab.intro .placa-escultura { animation: esculpir 1000ms ease-out 1300ms both paused; }
  .lab.intro.viva .placa-ambiente, .lab.intro.viva .testigo svg, .lab.intro.viva .placa-escultura { animation-play-state: running; }
}
@keyframes esculpir { from { opacity: 0; } to { opacity: .85; } }
@keyframes barrido { from { --barrido: 15%; } to { --barrido: 150%; } }
@keyframes autotest {
  0%, 100% { color: var(--niebla); filter: none; }
  20%, 55% { color: var(--auto); filter: drop-shadow(0 0 7px var(--auto)); }
}

/* ---------- the path from the dashboard to the car (drawn by lab.js) ---------- */
.trayectoria { position: fixed; inset: 0; z-index: 6; pointer-events: none; }
.trayectoria svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.trayectoria path { fill: none; stroke: var(--tono-trazo, var(--marfil)); stroke-width: 1.5; stroke-linecap: round; opacity: 0; }
.foton {
  position: absolute; left: 0; top: 0;
  width: 10px; height: 10px; border-radius: 50%;
  background: #fff; box-shadow: 0 0 14px 5px var(--tono-trazo, var(--marfil));
  opacity: 0;
  offset-anchor: center; offset-rotate: 0deg;
}

/* ---------- shared section heads ---------- */
.servicios, .pintura { position: relative; padding: clamp(56px, 9vw, 112px) var(--gutter); border-top: 1px solid var(--grafito); }
.seccion-cabeza { max-width: 46rem; margin-bottom: clamp(24px, 4vw, 44px); }
h2 { font-size: min(clamp(2rem, 6.4vw, 3.6rem), 12vw); line-height: 1.02; font-weight: 700; letter-spacing: -.03em; }

/* ---------- repairs and maintenance: its rules live in css/taller.css, which lab.js adds after the first paint
   (noscript keeps a normal link). Until they arrive the block stays hidden, so it is never seen unstyled. ---------- */
.taller { visibility: hidden; }

/* ---------- Paint Studio ---------- */
.pintura-cuerpo { display: grid; gap: 20px; }
.pintura-escena {
  position: relative; aspect-ratio: 16 / 9; overflow: hidden;
  border: 1px solid rgb(236 230 219 / .12); border-radius: 16px;
  background: var(--noche);
  isolation: isolate;
}
.capa { position: absolute; inset: 0; }
.color { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; color: transparent; }
/* The chosen paint fades in over the previous one, which only disappears afterwards: no dip to black. */
.capa-actual .color { z-index: 1; opacity: 0; transition: opacity 0s linear 320ms; }
.pintura:has(#c-0:checked) .capa-actual .c0,
.pintura:has(#c-1:checked) .capa-actual .c1,
.pintura:has(#c-2:checked) .capa-actual .c2,
.pintura:has(#c-3:checked) .capa-actual .c3,
.pintura:has(#c-4:checked) .capa-actual .c4 { z-index: 2; opacity: 1; transition: opacity 320ms var(--salida); }
/* Comparison: the reference paint is shown left of the line. */
.capa-referencia { z-index: 3; display: none; clip-path: inset(0 calc(100% - var(--corte, 50%)) 0 0); }
.capa-referencia .color { opacity: 0; }
.pintura-escena[data-ref="0"] .capa-referencia .c0,
.pintura-escena[data-ref="1"] .capa-referencia .c1,
.pintura-escena[data-ref="2"] .capa-referencia .c2,
.pintura-escena[data-ref="3"] .capa-referencia .c3,
.pintura-escena[data-ref="4"] .capa-referencia .c4 { opacity: 1; }
.divisor { position: absolute; z-index: 4; top: 0; bottom: 0; left: var(--corte, 50%); width: 2px; translate: -1px 0; background: var(--marfil); display: none; pointer-events: none; }
.divisor span { position: absolute; top: 50%; left: 50%; width: 36px; height: 36px; translate: -50% -50%; border: 2px solid var(--marfil); border-radius: 50%; background: rgb(11 12 14 / .7); }
.divisor span::before, .divisor span::after { content: ""; position: absolute; top: 50%; width: 0; height: 0; translate: 0 -50%; border: 5px solid transparent; }
.divisor span::before { left: 4px; border-right-color: var(--marfil); }
.divisor span::after { right: 4px; border-left-color: var(--marfil); }
.etiqueta { position: absolute; z-index: 4; top: 12px; display: none; padding: 4px 10px; border-radius: 999px; background: rgb(11 12 14 / .78); color: var(--marfil); font-size: .75rem; font-weight: 600; pointer-events: none; }
.etiqueta-ref { left: 12px; }
.etiqueta-act { right: 12px; }
/* The two labels never share space: each keeps to its half, and on a narrow scene (or with enlarged text) «Ahora» moves
   to the lower corner, diagonal to «Antes»; the colour caption there is hidden while comparing. */
.pintura-escena { container-type: inline-size; }
.etiqueta { max-width: calc(50% - 18px); overflow-wrap: break-word; }
@container (max-width: 21rem) {
  .etiqueta { max-width: calc(100% - 24px); }
  .etiqueta-act { top: auto; bottom: 12px; }
}
.pintura-escena.comparando :is(.capa-referencia, .divisor, .etiqueta) { display: block; }
.comparador { position: absolute; z-index: 5; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: ew-resize; touch-action: pan-y; }
.pintura-escena:has(.comparador:focus-visible) { outline: 2px solid var(--marfil); outline-offset: 3px; }
.pintura-pie { position: absolute; z-index: 4; left: 12px; bottom: 12px; padding: 4px 10px; border-radius: 999px; background: rgb(11 12 14 / .78); font-size: .8125rem; font-weight: 600; }
.pie-color { display: none; }
.pintura:has(#c-0:checked) .p0, .pintura:has(#c-1:checked) .p1, .pintura:has(#c-2:checked) .p2,
.pintura:has(#c-3:checked) .p3, .pintura:has(#c-4:checked) .p4 { display: inline; }
.pintura-escena.comparando .pintura-pie { display: none; }

.colores fieldset { border: 0; margin: 0; padding: 0; min-width: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.colores legend { padding: 0; margin-bottom: 10px; color: var(--niebla); font-size: .75rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; }
.opcion {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px;
  min-height: 44px; padding: 10px 4px;
  border: 1px solid rgb(236 230 219 / .14); border-radius: 14px;
  cursor: pointer; text-align: center;
  transition: border-color 160ms var(--salida), transform 140ms var(--salida);
}
.opcion input { position: absolute; top: 50%; left: 50%; width: 1px; height: 1px; margin: 0; opacity: 0; }
.opcion:active { transform: scale(.97); }
.opcion:has(input:checked) { border-color: var(--marfil); background: rgb(28 31 35 / .9); }
.opcion:has(input:focus-visible),
:root[data-modo="teclado"] .opcion:has(input:focus) { outline: 2px solid var(--marfil); outline-offset: 3px; box-shadow: 0 0 0 6px rgb(11 12 14 / .85); }
.muestra { width: 34px; height: 34px; flex: none; border-radius: 50%; border: 1px solid rgb(236 230 219 / .35); }
.o0 .muestra { background: radial-gradient(circle at 35% 30%, #4b5059, #0d0f12 70%); }
.o1 .muestra { background: radial-gradient(circle at 35% 30%, #ff6b5c, #9a1208 72%); }
.o2 .muestra { background: radial-gradient(circle at 35% 30%, #74a9ff, #0b2f9b 72%); }
.o3 .muestra { background: radial-gradient(circle at 35% 30%, #dde1e6, #5a5f67 72%); }
.o4 .muestra { background: radial-gradient(circle at 35% 30%, #ffffff, #cdc8bf 72%); }
.opcion-texto { display: flex; flex-direction: column; color: var(--marfil); font-size: .75rem; font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.opcion-texto small { color: var(--niebla); font-size: .6875rem; font-weight: 500; }
@media (hover: hover) and (pointer: fine) {
  .opcion:hover { border-color: rgb(236 230 219 / .45); }
}
.pintura-mando { display: grid; gap: 18px; align-content: start; }
.comparar { display: grid; gap: 6px; }
.interruptor { display: inline-flex; align-items: center; gap: 12px; min-height: 44px; cursor: pointer; font-weight: 600; }
.interruptor input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.interruptor-pista { position: relative; width: 44px; height: 26px; flex: none; border-radius: 999px; border: 1px solid var(--borde); background: var(--noche); transition: background-color 160ms ease, border-color 160ms ease; }
.interruptor-pista::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--niebla); transition: translate 180ms var(--salida), background-color 160ms ease; }
.interruptor input:checked + .interruptor-pista { background: var(--marfil); border-color: var(--marfil); }
.interruptor input:checked + .interruptor-pista::after { translate: 18px 0; background: var(--tinta); }
.interruptor input:focus-visible + .interruptor-pista { outline: 2px solid var(--marfil); outline-offset: 3px; }
.comparar-ayuda, .pintura-nota { color: var(--niebla); font-size: .8125rem; }

/* Touch and narrow screens: a bigger handle for the comparison line. */
@media (max-width: 559px), (pointer: coarse) {
  .divisor span { width: 46px; height: 46px; }
}

/* ---------- KJ Digital signature ---------- */
.pie {
  display: grid; gap: 22px;
  padding: clamp(40px, 6vw, 72px) var(--gutter) 40px;
  background: #080d17; border-top: 1px solid #172131;
}
.pie-firma { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 28px; }
/* The approved master logo, unaltered; its clear space (a quarter of the monogram) is the margin. */
.logo { display: block; width: clamp(240px, 22vw, 300px); height: auto; margin: 13px; }
.lema { color: var(--hielo); font-size: .9375rem; font-weight: 600; letter-spacing: .06em; }
.pie-texto { display: grid; gap: 8px; max-width: 62rem; }
.pie-autoria { color: #f0f3f8; font-weight: 600; }
.pie-nota { color: var(--niebla); font-size: .8125rem; }

/* ---------- landscape: the car fills the screen and stays; the words sit on the dark side, clear of the car ---------- */
@media (orientation: landscape) and (min-width: 560px) {
  #cuadro, .lab :is(button, .ficha), .lab .testigo input { scroll-margin-top: 0; }
  .barra { position: absolute; inset: 0 0 auto; z-index: 7; background: none; }
  .lab {
    display: grid;
    grid-template-columns: var(--gutter) minmax(0, 1fr) var(--gutter);
    grid-template-rows: auto 1fr;
    min-height: 100svh;
    /* The car's nose starts at 41 % of the 16:9 plate; the column ends before it. */
    --columna: min(32vw, 28rem);
    --reposo-x: 70.94%; --reposo-y: 55.97%;
    --frenos-x: 72.78%; --frenos-y: 64.56%; --frenos-rx: 8.4%; --frenos-ry: 14.93%;
    --motor-x: 56.52%; --motor-y: 46.19%; --motor-rx: 12.6%; --motor-ry: 22.4%;
    --electrico-x: 60.67%; --electrico-y: 54.77%; --electrico-rx: 8%; --electrico-ry: 14.22%;
    --neumaticos-x: 93.77%; --neumaticos-y: 58.36%; --neumaticos-rx: 8.8%; --neumaticos-ry: 15.64%;
    --esculpido: radial-gradient(ellipse 11.9% 21.1% at 51.7% 59.6%, rgb(0 0 0 / .85), rgb(0 0 0 / .38) 55%, transparent),
      radial-gradient(ellipse 10.7% 19% at 56.9% 46.2%, rgb(0 0 0 / .75), rgb(0 0 0 / .34) 55%, transparent),
      radial-gradient(ellipse 8.9% 15.8% at 72.4% 55.8%, rgb(0 0 0 / .9), rgb(0 0 0 / .41) 55%, transparent),
      radial-gradient(ellipse 7.9% 14% at 94% 51.8%, rgb(0 0 0 / .9), rgb(0 0 0 / .41) 55%, transparent),
      radial-gradient(ellipse 6.7% 11.9% at 72.2% 64.4%, #000, rgb(0 0 0 / .45) 55%, transparent),
      radial-gradient(ellipse 5.1% 9.1% at 93.7% 58.9%, #000, rgb(0 0 0 / .45) 55%, transparent),
      radial-gradient(ellipse 8.2% 14.5% at 91.8% 31.6%, rgb(0 0 0 / .85), rgb(0 0 0 / .38) 55%, transparent);
  }
  .escena-marco { grid-column: 1 / -1; grid-row: 1 / -1; align-self: start; z-index: 0; height: 100svh; max-height: none; aspect-ratio: auto; margin: 0; }
  .escena { top: 50%; aspect-ratio: 16 / 9; translate: 0 -50%; }
  .escena-marco::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgb(11 12 14 / .78) 0%, rgb(11 12 14 / .4) 26%, transparent 40%); pointer-events: none; }
  .reticula { stroke-width: 1.4; }
  .reticula .marcas { stroke-width: 2; }
  .cabeza { grid-column: 2; grid-row: 1; width: var(--columna); padding: clamp(56px, 11vh, 128px) 0 0; }
  .mando { grid-column: 2; grid-row: 2; width: var(--columna); padding: 18px 0 40px; }
  h1 { font-size: min(clamp(2.5rem, min(5.7vw, 11vh), 6.25rem), 8.5vw); }
}
/* Wide and tall enough: the card becomes a strip under the car, so the whole story fits in one screen. */
@media (orientation: landscape) and (min-width: 900px) and (min-height: 600px) {
  .mando { width: auto; display: grid; grid-template-columns: var(--columna) minmax(0, 1fr); grid-template-rows: auto auto 1fr auto; padding-bottom: clamp(16px, 3vh, 32px); }
  .cuadro { grid-column: 1; grid-row: 1; }
  .acciones { grid-column: 1; grid-row: 2; }
  .fichas { grid-column: 1 / -1; grid-row: 4; margin-top: 20px; }
  .ficha { padding: 14px 22px 16px; background: rgb(15 16 19 / .86); }
  .ficha dl { grid-auto-flow: column; grid-template-rows: auto 1fr; grid-auto-columns: minmax(0, 1fr); column-gap: 28px; row-gap: 6px; }
  .ficha dd { margin: 0; font-size: .875rem; }
}
/* Short landscape, a phone on its side: smaller words, the card scrolls in the column over the pinned car. */
@media (orientation: landscape) and (min-width: 560px) and (max-height: 520px) {
  .barra { position: static; background: var(--carbon); }
  .cabeza { padding-top: 14px; }
  .antetitulo { margin-bottom: 4px; }
  h1 { font-size: min(clamp(2rem, 11vh, 3rem), 8.5vw); }
  .entrada { margin-top: 6px; font-size: .875rem; }
  .testigo { min-height: 3.75rem; }
}
/* Narrow screens: a 4:3 crop keeps the whole car (it spans 22-76 % of the 16:9 render) and shows it larger,
   and the paints become a row of swatches; the chosen paint is named on the image, every name stays readable by
   screen readers. */
@media (max-width: 559px) {
  .pintura-escena { aspect-ratio: 4 / 3; }
  .opcion { padding: 8px 2px; min-height: 52px; justify-content: center; }
  .muestra { width: 36px; height: 36px; }
  .opcion-texto { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}
/* Paint Studio beside its controls when there is room. */
@media (orientation: landscape) and (min-width: 1000px) {
  .pintura-cuerpo { grid-template-columns: minmax(0, 1.75fr) minmax(17rem, 1fr); align-items: start; }
  .colores fieldset { grid-template-columns: 1fr; gap: 8px; }
  .opcion { flex-direction: row; justify-content: flex-start; gap: 14px; padding: 10px 14px; text-align: left; }
  .opcion-texto { font-size: .9375rem; }
  .opcion-texto small { font-size: .75rem; }
}

/* ---------- reduced motion: the same states, without travel ---------- */
@media (prefers-reduced-motion: reduce) {
  .lab { transition: none; }
  .placa-ambiente, .placa-faros { transition: opacity 120ms linear; }
  .lab.intro .placa-ambiente, .lab.intro .testigo svg { animation: none; -webkit-mask-image: none; mask-image: none; }
  .lab.intro .placa-escultura { animation: none; }
  .placa-escultura { transition: opacity 120ms linear; }
  .reticula { scale: 1; transition: opacity 120ms linear; }
  .lab:has(.cuadro input:checked) .reticula { transition-delay: 0ms; }
  .ficha { transform: none; filter: none; transition: opacity 120ms linear, visibility 0s linear 120ms; }
  .lab:not(:has(.cuadro input:checked)) .ficha-inicio,
  .lab:has(#t-frenos:checked) .ficha-frenos,
  .lab:has(#t-motor:checked) .ficha-motor,
  .lab:has(#t-electrico:checked) .ficha-electrico,
  .lab:has(#t-neumaticos:checked) .ficha-neumaticos { transition: opacity 120ms linear, visibility 0s; }
  .testigo, .cta, .apagar, .nota, .nota button, .servicio-cta, .opcion, .interruptor-pista, .interruptor-pista::after { transition: none; }
  .testigo:active, .cta:active, .apagar:active, .nota button:active, .servicio-cta:active, .opcion:active { transform: none; }
  /* The per-colour rules carry an ID in :has(), which outranks this override without !important: the new paint appears
     at once and the old one goes in the same frame, so there is no fade and no dip to black. */
  .capa-actual .color, .pintura:has(:checked) .capa-actual .color { transition: none !important; }
}
@media (forced-colors: active) {
  .testigo:has(input:checked), .opcion:has(input:checked), .servicio:has(.servicio-radio:checked) { outline: 3px solid Highlight; }
  .reticula { color: CanvasText; }
}
