/* ============================================================
   KTM REGISTRO — sistema visual
   Base: premium-ui-system (tokens, motion, a11y). Forkeado de PRUEBA_DE_MANEJO.

   Paleta muestreada del arte del cliente (carpeta de Drive "REGISTRO KTM"):
     naranja   #FF6A00  <- titulo REGISTRO, pestañas de icono, boton CONTINUAR
     brasa     #C94400  <- sombra del naranja, degradados
     asfalto   #0B0706  <- base (negro calido del piso mojado, no gris)
     caja      #141111  <- relleno de los campos

   Contrastes sobre la caja #141111:
     texto  #F4EFEA ......... 16.9:1
     apoyo  #B5A9A0 .......... 8.1:1
     naranja #FF6A00 ......... 6.4:1  (valido para texto)
   ============================================================ */

@font-face {
  font-family: "Archivo";
  font-style: normal;
  font-weight: 400 800;
  font-stretch: 62% 125%;
  font-display: swap;
  src: url("/fonts/archivo-latin.woff2") format("woff2");
  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;
}
@font-face {
  font-family: "Archivo";
  font-style: normal;
  font-weight: 400 800;
  font-stretch: 62% 125%;
  font-display: swap;
  src: url("/fonts/archivo-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308,
    U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113,
    U+2C60-2C7F, U+A720-A7FF;
}

:root {
  color-scheme: dark;

  /* ---------- TIER 1: primitivos ---------- */
  --naranja: #ff6a00;
  --brasa: #c94400;
  --asfalto: #0b0706;
  --caja: #141111;
  --blanco: #f4efea;
  --apoyo: #b5a9a0;
  --rojo: #ff4d5e;

  --space-1: 4px;   --space-2: 8px;   --space-3: 12px;  --space-4: 16px;
  --space-5: 24px;  --space-6: 32px;  --space-7: 48px;  --space-8: 64px;

  --text--1: clamp(0.8125rem, 0.77rem + 0.19vw, 0.875rem);
  --text-0:  clamp(0.9375rem, 0.87rem + 0.31vw, 1.0625rem);
  --text-1:  clamp(1.0625rem, 0.96rem + 0.47vw, 1.25rem);
  --text-2:  clamp(1.25rem, 1.08rem + 0.78vw, 1.5625rem);

  --font-body: "Archivo", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;

  --corte: 10px;
  --corte-grande: 16px;

  /* Motion — valores de casa, no se inventan otros */
  --dur-instant: 120ms;
  --dur-toggle: 240ms;
  --dur-modal: 400ms;
  --dur-page: 500ms;
  --ease-out: cubic-bezier(0.33, 1, 0.68, 1);
  --ease-out-strong: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in: cubic-bezier(0.32, 0, 0.67, 0);
  --ease-in-out: cubic-bezier(0.45, 0, 0.55, 1);

  /* ---------- TIER 2: semanticos ---------- */
  --texto: var(--blanco);
  --texto-apoyo: var(--apoyo);
  --borde: color-mix(in srgb, var(--naranja) 70%, #000);

  --glow: drop-shadow(0 0 3px color-mix(in srgb, var(--naranja) 60%, transparent))
          drop-shadow(0 0 12px color-mix(in srgb, var(--naranja) 30%, transparent));
  --glow-fuerte: drop-shadow(0 0 4px color-mix(in srgb, var(--naranja) 85%, transparent))
                 drop-shadow(0 0 18px color-mix(in srgb, var(--naranja) 55%, transparent));
}

/* ---------------------------------------------------------------- reset */

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  min-height: 100svh;
  background: #000;
  color: var(--texto);
  font-family: var(--font-body);
  font-size: var(--text-0);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

[hidden] { display: none !important; }

img, video, canvas { display: block; max-width: 100%; }
button, input, select { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--naranja); outline-offset: 3px; border-radius: 2px; }

.oculto-visual {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
.trampa { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.noscript {
  position: fixed; inset: auto 0 0; padding: var(--space-4);
  background: var(--brasa); color: #fff; text-align: center; font-size: var(--text--1);
}

/* ---------------------------------------------------------------- marco 9:16 */

.marco {
  width: min(100vw, calc(100svh * 9 / 16));
  height: 100svh;
  margin-inline: auto;
  position: relative;
  overflow: hidden;
  background: var(--asfalto);
  /* Las medidas que dependen del arte van en cqw: el fondo escala con el ANCHO del marco,
     asi que la posicion del formulario tambien. */
  container-type: inline-size;
}

.escenario { position: absolute; inset: 0; }

/* ---------------------------------------------------------------- pantallas */

.pantalla {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: max(var(--space-5), env(safe-area-inset-top)) var(--space-4)
           max(var(--space-4), env(safe-area-inset-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;

  /* El fondo del cliente al ANCHO, pegado arriba. En un celular mas alto que 9:16 sobra
     pantalla por abajo: la cubre el color del asfalto, que es donde el arte ya termina. */
  background-color: var(--asfalto);
  /* El arte mide 177.8cqw de alto; el degradado funde su borde inferior con el asfalto. */
  background-image: linear-gradient(to bottom, transparent 140cqw, var(--asfalto) 177cqw), url("/brand/fondo-1080.webp");
  background-size: 100% 178cqw, 100% auto;
  background-position: center top, center top;
  background-repeat: no-repeat;

  opacity: 0;
  transform: translate3d(22px, 0, 0);
  pointer-events: none;
  transition: opacity var(--dur-toggle) var(--ease-out),
              transform var(--dur-page) var(--ease-out-strong);
}
.pantalla.is-activa { opacity: 1; transform: none; pointer-events: auto; }
.pantalla.is-saliendo {
  opacity: 0;
  transform: translate3d(-14px, 0, 0);
  transition-timing-function: var(--ease-in);
}

@keyframes sube {
  from { opacity: 0; transform: translate3d(0, 14px, 0); }
  to   { opacity: 1; transform: none; }
}

/* ---------------------------------------------------------------- 1. registro */

/* El titulo REGISTRO del arte termina al 92% del ancho (y=995 de 1080). El formulario
   arranca justo debajo, como en la referencia. */
.pantalla--registro {
  padding-top: 93cqw;
  /* Margen lateral de la referencia: las casillas empatan con el ancho del titulo REGISTRO (7% por lado), no con todo el PNG. */
  padding-inline: 7cqw;
}

.forma {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  flex: 1 1 auto;
}

.rejilla {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  /* En celulares altos el aire sobrante se reparte entre filas en vez de quedar abajo. */
  gap: clamp(10px, 2.2svh, 22px) 10px;
}
.rejilla > .campo { animation: sube var(--dur-modal) var(--ease-out-strong) both; }
.rejilla > .campo:nth-child(2) { animation-delay: 40ms; }
.rejilla > .campo:nth-child(3) { animation-delay: 80ms; }
.rejilla > .campo:nth-child(4) { animation-delay: 120ms; }
.rejilla > .campo:nth-child(5) { animation-delay: 160ms; }
.rejilla > .campo:nth-child(6) { animation-delay: 200ms; }

.campo { display: flex; flex-direction: column; min-width: 0; }
.campo--ancho { grid-column: 1 / -1; }

/* Pieza completa = insignia naranja del cliente + caja oscura con filo naranja.
   La insignia va encima y monta sobre el borde izquierdo de la caja, como la pestaña de
   la referencia. */
.campo__marco {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 56px;
  cursor: text;
}

.campo__icono {
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
  height: 50px;
  width: auto;
  margin-right: -8px;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.6));
}

/* Caja de dos capas: el fondo de la capa exterior hace de trazo (clip-path recorta
   border y box-shadow, por eso no se usan). */
.campo__caja {
  --c: var(--corte);
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 var(--space-2) 0 calc(var(--space-2) + 8px);
  background:
    linear-gradient(var(--caja), var(--caja)) padding-box,
    linear-gradient(100deg, var(--naranja), var(--brasa) 60%, #3a1a08) border-box;
  border: 1.5px solid transparent;
  clip-path: polygon(0 0, calc(100% - var(--c)) 0, 100% var(--c), 100% 100%, var(--c) 100%, 0 calc(100% - var(--c)));
  transition: filter var(--dur-toggle) var(--ease-out);
}
.campo__marco:focus-within .campo__caja {
  background:
    linear-gradient(#1b1512, #1b1512) padding-box,
    linear-gradient(100deg, #ff8a2a, var(--naranja)) border-box;
}
.campo.is-mal .campo__caja {
  background:
    linear-gradient(var(--caja), var(--caja)) padding-box,
    linear-gradient(100deg, var(--rojo), #7a1520) border-box;
}

.campo__etiqueta {
  font-size: 0.75rem;
  line-height: 1;
  color: var(--texto-apoyo);
  padding-top: 7px;
}

.campo input,
.campo select {
  width: 100%;
  min-width: 0;
  background: none;
  border: 0;
  padding: var(--space-3) 0;
  /* 16px reales: por debajo, Safari en iOS hace zoom al enfocar. */
  font-size: 16px;
  font-weight: 500;
  font-stretch: 78%;
  color: var(--texto);
  appearance: none;
  text-overflow: ellipsis;
  outline: none;
}
.campo__caja--etiqueta input { padding: 2px 0 7px; font-size: 1.125rem; letter-spacing: 0.02em; }
.campo input::placeholder { color: #d8d0ca; font-weight: 400; opacity: 1; }
.campo__caja--etiqueta input::placeholder { color: var(--texto-apoyo); }
.campo select { cursor: pointer; white-space: nowrap; overflow: hidden; }
.campo select:invalid { color: #d8d0ca; font-weight: 400; }
.campo select option { background: var(--caja); color: var(--texto); }

.campo__error {
  font-size: var(--text--1);
  font-weight: 600;
  line-height: 1.3;
  color: var(--rojo);
  padding: 5px var(--space-1) 0;
  text-shadow: 0 1px 3px #000;
}
.campo__error:empty { display: none; }

.forma__error {
  font-size: var(--text--1);
  font-weight: 600;
  color: var(--rojo);
  text-align: center;
  padding: var(--space-2);
}
.forma__error:empty { display: none; }

/* El boton CONTINUAR del cliente, al ancho de la rejilla. */
.boton-arte {
  display: block;
  width: 86%;
  margin-inline: auto;
  margin-top: clamp(8px, 3svh, 32px);
  filter: drop-shadow(0 6px 16px rgba(255, 106, 0, 0.28));
  transition: transform var(--dur-instant) var(--ease-out), filter var(--dur-toggle) var(--ease-out);
  animation: sube var(--dur-modal) var(--ease-out-strong) 240ms both;
}
.boton-arte:active { transform: scale(0.975); filter: var(--glow-fuerte); }
.boton-arte img { width: 100%; height: auto; }
.boton-arte[disabled] { opacity: 0.6; pointer-events: none; }

/* ---------------------------------------------------------------- botones */

.acciones { display: flex; flex-direction: column; gap: var(--space-3); margin-top: auto; padding-top: var(--space-5); }

.boton {
  --c: var(--corte-grande);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  min-height: 58px;
  padding: var(--space-3) var(--space-5);
  clip-path: polygon(var(--c) 0, 100% 0, 100% calc(100% - var(--c)), calc(100% - var(--c)) 100%, 0 100%, 0 var(--c));
  font-weight: 800;
  font-style: italic;
  font-stretch: 80%;
  font-size: var(--text-1);
  letter-spacing: 0.05em;
  color: #0b0706;
  transition: transform var(--dur-instant) var(--ease-out), opacity var(--dur-toggle) var(--ease-out);
}
.boton--primario { background: linear-gradient(180deg, #ff8a2a 0%, var(--naranja) 45%, var(--brasa) 100%); }
.boton--fantasma {
  background: none;
  min-height: 50px;
  font-size: var(--text-0);
  color: var(--texto-apoyo);
  clip-path: none;
}
.boton:active { transform: scale(0.978); }
.boton[disabled] { opacity: 0.55; pointer-events: none; }

.boton__giro { display: none; }
.boton.is-cargando .boton__txt { display: none; }
.boton.is-cargando .boton__giro { display: flex; animation: gira 900ms linear infinite; }
@keyframes gira { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- confirmacion */

.confirma {
  --c: var(--corte-grande);
  width: min(92vw, 380px);
  max-height: 88svh;
  overflow-y: auto;
  margin: auto;
  padding: 0;
  border: 1.5px solid var(--naranja);
  background: var(--caja);
  color: var(--texto);
  clip-path: polygon(0 0, calc(100% - var(--c)) 0, 100% var(--c), 100% 100%, var(--c) 100%, 0 calc(100% - var(--c)));
}
.confirma::backdrop { background: rgba(5, 3, 2, 0.84); }
.confirma[open] { display: flex; flex-direction: column; gap: var(--space-3); }

.confirma__titulo {
  font-size: var(--text-2);
  font-weight: 800;
  font-style: italic;
  font-stretch: 74%;
  letter-spacing: 0.02em;
  text-align: center;
  color: var(--naranja);
  padding: var(--space-5) var(--space-5) 0;
}
.confirma__nota {
  font-size: var(--text--1);
  color: var(--texto-apoyo);
  text-align: center;
  padding: 0 var(--space-5);
}

.confirma__lista { display: flex; flex-direction: column; padding: var(--space-2) var(--space-5); }
.confirma__lista > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-4);
  padding: var(--space-3) 0;
  border-bottom: 1px solid color-mix(in srgb, var(--naranja) 22%, transparent);
}
.confirma__lista > div:last-child { border-bottom: 0; }
.confirma__lista dt {
  flex: 0 0 auto;
  font-size: var(--text--1);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--texto-apoyo);
}
.confirma__lista dd {
  flex: 1 1 auto;
  min-width: 0;
  text-align: right;
  font-weight: 700;
  color: var(--texto);
  overflow-wrap: anywhere;
}

.confirma__acciones {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-5) var(--space-5);
}

/* ---------------------------------------------------------------- 2. gracias */

.pantalla--gracias { padding-top: 91cqw; }

.gracias {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-5);
  text-align: center;
  min-height: 0;
  animation: sube var(--dur-modal) var(--ease-out-strong) both;
}

.gracias__sello {
  --c: 14px;
  display: grid;
  place-items: center;
  width: 104px;
  height: 104px;
  flex: 0 0 auto;
  background: linear-gradient(180deg, #ff8a2a 0%, var(--naranja) 45%, var(--brasa) 100%);
  clip-path: polygon(var(--c) 0, calc(100% - var(--c)) 0, 100% var(--c), 100% calc(100% - var(--c)),
    calc(100% - var(--c)) 100%, var(--c) 100%, 0 calc(100% - var(--c)), 0 var(--c));
  color: #fff;
  animation: sella var(--dur-modal) var(--ease-out-strong) both;
}

@keyframes sella {
  0%   { opacity: 0; transform: scale(0.82); }
  60%  { opacity: 1; transform: scale(1.04); }
  100% { opacity: 1; transform: scale(1); }
}

.titular {
  font-size: clamp(2.25rem, 11.5cqw, 4rem);
  font-weight: 800;
  font-style: italic;
  font-stretch: 70%;
  line-height: 0.95;
  text-align: center;
  color: var(--texto);
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.8);
}
.titular--apilado em { font-style: italic; color: var(--naranja); }

.gracias__nombre {
  font-size: var(--text-1);
  color: var(--texto);
  max-width: 26ch;
  overflow-wrap: anywhere;
  text-shadow: 0 1px 6px #000;
}
.gracias__nombre:empty { display: none; }

/* ---------------------------------------------------------------- accesibilidad */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Celulares estrechos (<= 360 px): la insignia se encoge para dejar sitio al texto. */
@media (max-width: 370px) {
  .campo__icono { height: 48px; margin-right: -8px; }
  .campo__marco { min-height: 50px; }
  .campo__caja { padding-left: 12px; padding-right: 4px; }
  .campo input, .campo select { letter-spacing: -0.02em; }
  .campo__caja { padding-left: 10px; }
  .rejilla { column-gap: 8px; }
  .pantalla--registro { padding-inline: 6cqw; }
}
