/* ============================================================
   Retornex · retornex.com/feria
   La página del QR del folleto: una pantalla, una cifra.
   La hoja de noche de retornex.com en pequeño: la caja de las
   cajas es la celda activa; lo que pierdes, en rojo de
   diferencia; lo que ganas, en el verde de lo que cuadra.
   ============================================================ */

@font-face {
  font-family: 'Archivo';
  font-style: normal;
  font-weight: 400 900;
  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+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'InterVar';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('../fonts/inter-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+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --noche: #071724;
  --noche-panel: #0a1d2c;
  --noche-cabecera: #0b2131;
  --noche-linea: #12304a;
  --noche-linea-fuerte: #1b3d58;
  --tinta: #eef4f8;
  --tinta-2: #a9bccb;
  --tinta-3: #8197a9;
  --verde: #45bd72;           /* el verde del logo, para fondo oscuro */
  --verde-boton: #1f7a42;
  --verde-boton-hover: #17633a;
  --pierdes: #ff6b5e;          /* el bolígrafo rojo, el mismo de toda la web */
  --pierdes-relleno: rgba(255, 107, 94, 0.15);
  --ganas-relleno: rgba(69, 189, 114, 0.17);
  --error: #ff6b5e;
  --ambar-texto: #f3c86a;
  --ambar-relleno: rgba(245, 182, 56, 0.16);

  --display: 'Archivo', 'Helvetica Neue', Arial, sans-serif;
  --texto: 'InterVar', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --fila: 1.75rem;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  color-scheme: dark;
  accent-color: var(--verde);
  height: 100%;
}
body {
  margin: 0;
  min-height: 100%;
  background-color: var(--noche);
  color: var(--tinta);
  font-family: var(--texto);
  font-size: 15px;
  line-height: 1.45;
  font-feature-settings: 'cv05' 1;
  -webkit-font-smoothing: antialiased;
}
h1, h2, p, dl, dd { margin: 0; }
img, svg { display: block; max-width: 100%; }
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
a { color: inherit; text-underline-offset: 0.2em; }
:focus-visible { outline: 2px solid var(--verde); outline-offset: 2px; border-radius: 1px; }
::selection { background: rgba(69, 189, 114, 0.35); color: #fff; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.num { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum' 1, 'cv05' 1; }
.verde { color: var(--verde); }
.hueco { background: var(--ambar-relleno); color: var(--ambar-texto); outline: 1px dashed var(--ambar-texto); outline-offset: 1px; padding: 0 0.3em; font-weight: 650; }

/* ---------- Una pantalla ---------- */

.feria {
  min-height: 100svh;
  max-width: 34rem;
  margin: 0 auto;
  padding: max(0.75rem, env(safe-area-inset-top)) 1rem max(0.9rem, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: clamp(0.6rem, 2.1vh, 1.25rem);
  /* La rejilla de la hoja, anclada al borde del contenido: cuatro columnas */
  background-image:
    linear-gradient(var(--noche-linea) 1px, transparent 1px),
    linear-gradient(90deg, var(--noche-linea) 1px, transparent 1px);
  background-size: calc(100% / 4) var(--fila);
  background-origin: content-box;
}
/* Lo que se escribe en la hoja tapa la rejilla que pisa */
.feria__cabeza > *, .feria__titulo, .llamada__nota, .llamada__legal { background: var(--noche); }
.feria__cabeza { align-items: stretch; }
.feria__cabeza > * { display: flex; align-items: center; padding: 0.15rem 0.4rem; }
.feria__cabeza > a { padding-left: 0; }
.feria__titulo { width: fit-content; padding-right: 0.4rem; }

.feria__cabeza { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.feria__cabeza img { width: 112px; height: auto; }
.feria__etiqueta { font-size: 0.72rem; font-weight: 650; letter-spacing: 0.07em; text-transform: uppercase; color: var(--tinta-3); }

.feria__titulo {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(1.6rem, min(7.6vw, 4.7vh), 2.9rem);
  line-height: 1.04;
  letter-spacing: -0.03em;
  text-wrap: balance;
}

/* La caja de las cajas: la celda activa de la hoja */
.calculo {
  display: grid;
  gap: 0.5rem;
  padding: clamp(0.7rem, 1.8vh, 1rem) 0.9rem;
  background: var(--noche-panel);
  border: 1px solid var(--noche-linea-fuerte);
}
.calculo__etiqueta { font-weight: 650; font-size: 0.92rem; }
.calculo__fila { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.9rem; }
.celda-activa { position: relative; display: inline-block; outline: 2px solid var(--verde); outline-offset: -1px; }
.celda-activa::after { content: ''; position: absolute; right: -5px; bottom: -5px; width: 8px; height: 8px; background: var(--verde); border: 1.5px solid var(--noche-panel); pointer-events: none; }
.calculo__cajas {
  width: 9.5ch;
  padding: 0.3rem 0.65rem;
  border: 0;
  border-radius: 0;
  background: var(--noche);
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(1.45rem, 3.6vh, 1.85rem);
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  caret-color: var(--verde);
}
.calculo__cajas:focus { outline: none; }
.celda-activa:focus-within { outline-width: 3px; outline-offset: -2px; }
.calculo__mes { font-size: 0.85rem; color: var(--tinta-2); font-variant-numeric: tabular-nums; }
.calculo__escala { display: flex; justify-content: space-between; margin-top: -0.2rem; font-size: 0.72rem; color: var(--tinta-3); font-variant-numeric: tabular-nums; }

/* El deslizador: la barra se llena de verde y el tirador es el de la celda */
.deslizador {
  --p: 20%;
  width: 100%;
  height: 28px;
  margin: 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}
.deslizador::-webkit-slider-runnable-track { height: 6px; background: linear-gradient(90deg, var(--verde) var(--p), var(--noche-linea-fuerte) var(--p)); }
.deslizador::-moz-range-track { height: 6px; background: var(--noche-linea-fuerte); }
.deslizador::-moz-range-progress { height: 6px; background: var(--verde); }
.deslizador::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; margin-top: -8px; background: var(--verde); border: 3px solid var(--noche-panel); box-shadow: 0 0 0 1px var(--verde); }
.deslizador::-moz-range-thumb { width: 16px; height: 16px; background: var(--verde); border: 3px solid var(--noche-panel); border-radius: 0; box-shadow: 0 0 0 1px var(--verde); }
.deslizador:focus-visible { outline-offset: 4px; }

/* Lo que pierdes y lo que ganas: formato condicional */
.resultado { display: grid; gap: 0.5rem; align-content: start; }
.cifra {
  display: grid;
  gap: 0.1rem;
  padding: clamp(0.55rem, 1.6vh, 0.9rem) 0.9rem;
  border: 1px solid var(--noche-linea-fuerte);
  transition: background-color 400ms var(--ease);
}
.cifra--pierdes { background: #252330; }
.cifra--ganas { background: #0f2d2e; }
.cifra__que { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--tinta-2); }
.cifra__valor {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(2.1rem, min(11.5vw, 6.6vh), 3.7rem);
  line-height: 1.02;
  letter-spacing: -0.025em;
}
.cifra--pierdes .cifra__valor { color: var(--pierdes); }
.cifra--ganas .cifra__valor { color: var(--verde); }
.cifra__detalle { font-size: 0.82rem; color: var(--tinta-2); }
.cifra__detalle b { color: var(--tinta); font-weight: 650; }
.resultado__estimacion {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  border: 1px solid var(--noche-linea-fuerte);
  background: var(--noche-panel);
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--tinta-2);
  overflow-wrap: anywhere;
}
.resultado__estimacion::before {
  content: 'fx';
  display: grid;
  place-items: center;
  padding: 0 0.55rem;
  border-right: 1px solid var(--noche-linea-fuerte);
  font-style: italic;
  font-weight: 650;
  color: var(--tinta-3);
}
.resultado__estimacion span { padding: 0.35rem 0.6rem; }
/* Un destello cuando cambia la cifra */
html.mov .cifra.cambia { animation: destello 600ms var(--ease); }
/* El destello se pinta encima del fondo opaco, sin volverlo translúcido */
@keyframes destello { 25% { box-shadow: inset 0 0 0 999px rgba(255, 255, 255, 0.07); } }

/* El botón: una celda verde con su tirador */
.boton {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  width: 100%;
  min-height: 3.2rem;
  padding: 0 1.2rem;
  border: 1px solid transparent;
  border-radius: 2px;
  font: 700 1.05rem/1 var(--texto);
  cursor: pointer;
  text-decoration: none;
  transition: background-color 200ms var(--ease), border-color 200ms var(--ease);
}
.boton svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.boton--verde { background: var(--verde-boton); color: #fff; }
.boton--verde:hover { background: var(--verde-boton-hover); }
.boton--verde::after { content: ''; position: absolute; right: -5px; bottom: -5px; width: 8px; height: 8px; background: var(--verde); border: 1.5px solid var(--noche); }
.boton--celda { background: transparent; color: var(--tinta); border-color: var(--noche-linea-fuerte); }
.boton--celda:hover { border-color: var(--verde); }
.boton[disabled] { opacity: 0.7; cursor: progress; }
.llamada { display: grid; gap: 0.45rem; margin-top: auto; }
.llamada__nota { justify-self: center; padding-inline: 0.4rem; text-align: center; font-size: 0.8rem; color: var(--tinta-2); }
.llamada__legal { justify-self: center; display: flex; gap: 0.9rem; padding-inline: 0.4rem; font-size: 0.72rem; color: var(--tinta-3); }
.llamada__legal a { color: inherit; }

/* Móviles bajos (con las barras del navegador): todo sigue cabiendo en una pantalla */
@media (max-height: 820px) {
  .feria { gap: 0.5rem; padding-top: max(0.5rem, env(safe-area-inset-top)); padding-bottom: max(0.6rem, env(safe-area-inset-bottom)); }
  .feria__titulo { font-size: clamp(1.45rem, min(7.4vw, 4.25vh), 2.9rem); }
  .calculo { gap: 0.4rem; padding-block: 0.55rem; }
  .calculo__cajas { font-size: clamp(1.35rem, 3.4vh, 1.85rem); padding-block: 0.2rem; }
  .deslizador { height: 22px; }
  .resultado { gap: 0.4rem; }
  .cifra { padding-block: 0.42rem; }
  .cifra__valor { font-size: clamp(1.85rem, min(11vw, 5.9vh), 3.7rem); }
  .resultado__estimacion { font-size: 0.78rem; line-height: 1.38; }
  .resultado__estimacion span { padding-block: 0.25rem; }
  .llamada { gap: 0.3rem; }
  .boton { min-height: 3rem; }
}

/* En pantalla ancha: la cifra a la derecha de la caja */
@media (min-width: 900px) and (min-height: 620px) {
  .feria { background-size: calc(100% / 8) var(--fila); }
  .feria {
    max-width: 62rem;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto auto 1fr auto;
    column-gap: 2.5rem;
    align-content: center;
    padding-block: 2.5rem;
  }
  .feria { grid-template-rows: auto auto auto auto; row-gap: 1.25rem; min-height: 100svh; align-content: center; }
  .feria__cabeza { grid-column: 1 / -1; margin-bottom: 0.75rem; }
  .feria__titulo { grid-column: 1; grid-row: 2; align-self: end; }
  .calculo { grid-column: 1; grid-row: 3; align-self: start; }
  .llamada { grid-column: 1; grid-row: 4; margin-top: 0; align-self: start; }
  .resultado { grid-column: 2; grid-row: 2 / span 3; align-self: center; }
}

/* ---------- La reserva: tres pasos a pantalla completa ---------- */

.reserva {
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--noche);
  color: var(--tinta);
  overflow-y: auto;
}
.reserva::backdrop { background: var(--noche); }
html.mov .reserva[open] { animation: sube 320ms var(--ease); }
@keyframes sube { from { transform: translateY(24px); opacity: 0; } }
.reserva__dentro {
  max-width: 32rem;
  min-height: 100%;
  margin: 0 auto;
  padding: max(0.9rem, env(safe-area-inset-top)) 1rem max(1rem, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.reserva__cabeza { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.reserva__volver { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.45rem 0; border: 0; background: none; font-weight: 600; cursor: pointer; }
.reserva__volver svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.reserva__pasos { display: flex; gap: 0.35rem; }
.reserva__pasos span { width: 1.6rem; height: 5px; background: var(--noche-linea-fuerte); transition: background-color 300ms var(--ease); }
.reserva__pasos span.hecho { background: var(--verde); }

.paso { display: flex; flex-direction: column; gap: 1rem; flex: 1; }
html.mov .paso { animation: entra 300ms var(--ease); }
@keyframes entra { from { opacity: 0; transform: translateX(14px); } }
.paso h2 { font-family: var(--display); font-weight: 800; font-size: 1.65rem; line-height: 1.1; letter-spacing: -0.02em; text-wrap: balance; }
.paso h2:focus { outline: none; }
.paso__sub { margin-top: -0.5rem; color: var(--tinta-2); font-size: 0.95rem; }
.paso__sub a { color: var(--tinta); font-weight: 650; }
.paso .boton { margin-top: auto; }

.grupo { display: grid; gap: 0.5rem; }
.grupo__titulo { font-weight: 700; font-size: 0.9rem; }
.fichas { display: grid; grid-template-columns: repeat(auto-fill, minmax(4.4rem, 1fr)); gap: 0.45rem; }
#dias .ficha { padding-block: 0.5rem; }
.fichas--dos { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ficha {
  padding: 0.65rem 0.5rem;
  background: var(--noche-panel);
  border: 1px solid var(--noche-linea-fuerte);
  border-radius: 0;
  font-weight: 650;
  font-size: 0.92rem;
  line-height: 1.25;
  text-align: center;
  cursor: pointer;
  transition: border-color 150ms var(--ease), background-color 150ms var(--ease);
}
.ficha small { display: block; margin-top: 0.15rem; font-size: 0.78rem; font-weight: 500; color: var(--tinta-2); }
.ficha:hover { border-color: var(--tinta-3); }
.ficha[aria-pressed='true'] { position: relative; background: var(--ganas-relleno); outline: 2px solid var(--verde); outline-offset: -1px; border-color: transparent; }
.ficha[aria-pressed='true']::after { content: ''; position: absolute; right: -5px; bottom: -5px; width: 8px; height: 8px; background: var(--verde); border: 1.5px solid var(--noche); }

.calendario { display: inline-flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0.25rem 0.4rem; padding: 0.35rem 0; font-size: 0.88rem; color: var(--tinta-2); text-decoration: none; }
.calendario span { color: var(--tinta); font-weight: 650; text-decoration: underline; text-underline-offset: 0.2em; }
.calendario svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.calendario:hover span { color: var(--verde); }

.campo { display: grid; gap: 0.35rem; }
.campo label { font-weight: 650; font-size: 0.9rem; }
.campo label i { font-style: normal; font-weight: 500; color: var(--tinta-3); }
.campo input {
  width: 100%;
  min-height: 3rem;
  padding: 0.6rem 0.75rem;
  background: var(--noche-panel);
  border: 1px solid var(--noche-linea-fuerte);
  border-radius: 0;
  font-size: 16px;
}
.campo input:focus { outline: 2px solid var(--verde); outline-offset: -1px; border-color: transparent; }
.campo input[aria-invalid='true'] { border-color: var(--error); }
.campo--trampa { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.error { color: var(--error); font-size: 0.88rem; font-weight: 600; }
.error:empty { display: none; }
.legal { font-size: 0.74rem; line-height: 1.5; color: var(--tinta-3); }
.legal a { color: var(--tinta-2); }

.paso--hecho { gap: 0.9rem; }
.agenda { display: grid; gap: 0.55rem; padding: 0.85rem 0.9rem 0.95rem; background: var(--ganas-relleno); outline: 2px solid var(--verde); outline-offset: -1px; position: relative; }
.agenda::after { content: ''; position: absolute; right: -5px; bottom: -5px; width: 8px; height: 8px; background: var(--verde); border: 1.5px solid var(--noche); }
.agenda__titulo { font-weight: 700; }
.agenda__botones { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.5rem; }
.agenda__botones .boton { min-height: 2.9rem; padding: 0 0.8rem; font-size: 0.95rem; background: var(--noche); justify-content: flex-start; }
.agenda__nota { font-size: 0.85rem; color: var(--tinta-2); }

.hecho__marca { display: grid; place-items: center; width: 3.2rem; height: 3.2rem; background: var(--ganas-relleno); outline: 2px solid var(--verde); outline-offset: -1px; }
.hecho__marca svg { width: 26px; height: 26px; fill: none; stroke: var(--verde); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
html.mov .hecho__marca svg path { stroke-dasharray: 24; stroke-dashoffset: 24; animation: traza 500ms var(--ease) 150ms forwards; }
@keyframes traza { to { stroke-dashoffset: 0; } }
.resumen { display: grid; border: 1px solid var(--noche-linea-fuerte); background: var(--noche-panel); }
.resumen div { display: flex; justify-content: space-between; gap: 1rem; padding: 0.55rem 0.8rem; border-bottom: 1px solid var(--noche-linea); font-size: 0.93rem; }
.resumen div:last-child { border-bottom: 0; }
.resumen dt { color: var(--tinta-2); }
.resumen dd { font-weight: 650; text-align: right; font-variant-numeric: tabular-nums; }

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