:root {
  --bg: #ffffff;
  --surface: #eef3ec;
  --ink: #12331a;
  --muted: #55645a;
  --accent: #ff8f00;
  --accent-hover: #ffa733;
  --accent-ink: #0a0e1a;
  --field-1: #0e3316;
  --field-1-ink: #e8f5e9;
  --field-app: #0a0e1a;
  --card-app: #1c2333;
  --card-app-ink: #e8f5e9;
  --card-app-soft: #b4bcc8;
  --risk-bajo: #66bb6a;
  --risk-medio: #ffb74d;
  --risk-alto: #ff7b72;
  --risk-critico: #ff5252;

  --step-small: clamp(0.8125rem, 0.79rem + 0.1vw, 0.875rem);
  --step-body: clamp(1.125rem, 1.05rem + 0.3vw, 1.3125rem);
  --step-lead: clamp(1.25rem, 1.1rem + 0.7vw, 1.625rem);
  --step-title: clamp(1.75rem, 1.4rem + 1vw, 2.5rem);
  --step-head: clamp(2.5rem, 1.3rem + 3.6vw, 5rem);
  --step-brand: clamp(4rem, 10.8vw, 15rem);
  --step-note: 1.0625rem;

  --edge: 20px;
  --pad: clamp(32px, 4.5vw, 72px);
  --radius: 12px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Libre Franklin", system-ui, sans-serif;
  font-size: var(--step-body);
  line-height: 1.5;
}
img { display: block; max-width: 100%; height: auto; }
h1, h2, h3, .marca, .cifra-numero, .pie-marca {
  font-family: "Besley", Georgia, serif;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.08;
  margin: 0;
}
p { margin: 0; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

.saltar:not(:focus) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.saltar:focus {
  position: fixed; left: var(--edge); top: var(--edge); z-index: 20;
  padding: 12px 16px; background: var(--accent); color: var(--accent-ink);
  border-radius: var(--radius);
}

.boton {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 56px; padding: 14px 28px;
  background: var(--accent); color: var(--accent-ink);
  border-radius: var(--radius);
  font-weight: 600; text-decoration: none;
  transition: transform 220ms var(--ease-out), background-color 180ms linear;
}
.boton:hover { background: var(--accent-hover); transform: translateY(-2px); }
.boton:active { transform: scale(0.97); }

.enlace {
  font-weight: 600;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
  transition: text-underline-offset 200ms var(--ease-out);
}
.enlace:hover { text-underline-offset: 7px; }

/* Mitad fija y columna de lectura */
.partido { display: grid; grid-template-columns: 47% 53%; background: var(--field-1); }
.escenario { position: sticky; top: 0; height: 100vh; height: 100svh; padding: var(--edge); }
.marco {
  position: relative; height: 100%; overflow: hidden;
  border-radius: var(--radius); background: var(--field-app);
}
.pantalla {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; object-position: top;
  opacity: 0; transform: scale(1.035);
  transition: opacity 700ms var(--ease-out), transform 1400ms var(--ease-out);
}
.pantalla.activa { opacity: 1; transform: scale(1); }

.columna { min-width: 0; }
.portada {
  position: relative; height: 100vh; height: 100svh; min-height: 620px;
  color: var(--field-1-ink); padding: 20px var(--pad) 0;
}
.menu { display: flex; justify-content: flex-end; align-items: center; gap: clamp(14px, 2vw, 28px); font-size: var(--step-note); }
.menu a {
  display: inline-flex; align-items: center; min-height: 44px;
  text-decoration: none; transition: transform 200ms var(--ease-out);
}
.menu a:hover { transform: translateY(-2px); }
.menu-accion {
  padding: 0 18px; background: var(--accent); color: var(--accent-ink);
  border-radius: var(--radius); font-weight: 600;
}
.portada-texto { position: absolute; left: var(--pad); right: var(--pad); top: 24%; }
.entrada { font-size: var(--step-lead); line-height: 1.32; max-width: 34ch; margin-bottom: 32px; }
.ficha { margin-top: 18px; font-size: var(--step-small); }
.marca {
  position: absolute; right: var(--pad); bottom: 18px;
  font-size: var(--step-brand); line-height: 1; white-space: nowrap;
  color: var(--field-1-ink); z-index: 3; transform-origin: right bottom;
}

.lectura { background: var(--bg); padding: 0 var(--pad) clamp(96px, 12vh, 160px); }
.bloque { max-width: 46ch; padding-top: clamp(96px, 16vh, 180px); }
.bloque > * + * { margin-top: 24px; }
.bloque h2 { font-size: var(--step-title); }

.cifra { background: var(--surface); padding: 28px; border-radius: var(--radius); }
.cifra-numero { font-size: var(--step-head); margin-bottom: 12px; }

table { width: 100%; border-collapse: collapse; font-size: var(--step-note); }
caption { text-align: left; color: var(--muted); font-size: var(--step-small); padding-bottom: 12px; }
th, td { text-align: left; padding: 11px 10px 11px 0; vertical-align: top; border-bottom: 2px solid var(--surface); }
thead th { font-weight: 600; color: var(--muted); }
tbody th { font-weight: 600; white-space: nowrap; padding-right: 18px; }
td:last-child { padding-right: 0; }
thead + tbody td:last-child { white-space: nowrap; }

.cita { margin: 24px 0 0; padding: 26px 28px; background: var(--field-1); color: var(--field-1-ink); border-radius: var(--radius); }
.cita p { font-size: var(--step-lead); line-height: 1.3; }
.cita footer { margin-top: 12px; font-size: var(--step-small); }

.lista { margin: 24px 0 0; padding: 0 0 0 1.1em; }
.lista li + li { margin-top: 12px; }
.lista li::marker { color: var(--accent); }

.solo-movil { display: none; }

/* Dato vivo: se elige la entrada y cambia la salida */
.vivo { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: minmax(58svh, auto) auto; }
.vivo-entrada { background: var(--field-app); color: var(--field-1-ink); padding: 18vh var(--pad) 48px; }
.vivo-entrada label { display: block; font-size: var(--step-lead); font-weight: 600; margin-bottom: 18px; }
.vivo-entrada select {
  display: block; width: 100%; max-width: 34ch; min-height: 60px; padding: 12px 16px;
  font: inherit; font-size: var(--step-lead); color: var(--field-1-ink);
  background: var(--card-app); border: 2px solid #4a5568; border-radius: var(--radius);
  cursor: pointer; transition: border-color 180ms linear;
}
.vivo-entrada select:hover { border-color: var(--accent); }
.vivo-entrada option { color: #0a0e1a; background: #ffffff; }
.vivo-entrada p { margin-top: 20px; max-width: 42ch; font-size: var(--step-note); }
.vivo-salida { background: var(--surface); padding: 18vh var(--pad) 48px; }

.tarjeta {
  max-width: 520px; padding: 32px; border-radius: var(--radius);
  background: var(--card-app); color: var(--card-app-ink);
}
.tarjeta h3 { font-size: var(--step-title); }
.tarjeta-nivel { display: flex; align-items: baseline; gap: 14px; margin-top: 14px; }
.nivel { font-family: "Besley", Georgia, serif; font-weight: 800; font-size: var(--step-title); line-height: 1; }
.puntaje { font-family: "Besley", Georgia, serif; font-size: var(--step-lead); font-weight: 800; font-variant-numeric: tabular-nums; }
.nivel-bajo { color: var(--risk-bajo); }
.nivel-medio { color: var(--risk-medio); }
.nivel-alto { color: var(--risk-alto); }
.nivel-critico { color: var(--risk-critico); }
.barra { height: 10px; margin-top: 18px; border-radius: 5px; background: #3a4557; overflow: hidden; }
.barra span {
  display: block; height: 100%; border-radius: 5px; transform-origin: left;
  transform: scaleX(var(--valor)); transition: transform 500ms var(--ease-out), background-color 300ms linear;
}
.nivel-fondo-bajo { background: var(--risk-bajo); }
.nivel-fondo-medio { background: var(--risk-medio); }
.nivel-fondo-alto { background: var(--risk-alto); }
.nivel-fondo-critico { background: var(--risk-critico); }
.tarjeta dl { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin: 24px 0 0; }
.tarjeta dt { font-size: var(--step-small); color: var(--card-app-soft); }
.tarjeta dd { margin: 2px 0 0; font-weight: 600; font-size: var(--step-note); }
.dl-ancha { grid-column: 1 / -1; }

.vivo-titulo { grid-column: 1 / -1; grid-row: 2; display: grid; grid-template-columns: 1fr 1fr; grid-template-columns: subgrid; font-size: var(--step-head); }
.vivo-titulo span { padding: 16px var(--pad) 32px; }
.vivo-titulo span:first-child { background: var(--field-app); color: var(--field-1-ink); }
.vivo-titulo span:last-child { background: var(--surface); color: var(--ink); }

/* Instalación: pasos que cambian la captura fijada */
.pasos {
  display: grid; grid-template-columns: 5fr 6fr; gap: clamp(32px, 6vw, 96px);
  padding: clamp(96px, 14vh, 160px) var(--pad);
}
.pasos h2 { font-size: var(--step-title); margin-bottom: 40px; }
.paso { min-height: 62vh; color: var(--muted); transition: color 300ms linear; }
.paso.activo { color: var(--ink); }
.paso:last-child { min-height: 40vh; }
.paso-frase { font-size: var(--step-lead); font-weight: 600; line-height: 1.25; margin-bottom: 14px; }
.paso .boton { margin-top: 22px; }
.pasos-escenario {
  --margen-paso: clamp(14px, 2vw, 28px);
  position: sticky; top: 14vh; align-self: start; aspect-ratio: 9 / 8;
  border-radius: var(--radius); background: var(--surface); overflow: hidden;
}
.paso-imagen {
  position: absolute; left: var(--margen-paso); top: var(--margen-paso);
  width: calc(100% - 2 * var(--margen-paso)); height: calc(100% - 2 * var(--margen-paso));
  object-fit: cover; border-radius: var(--radius);
  opacity: 0; transform: scale(1.03);
  transition: opacity 500ms var(--ease-out), transform 900ms var(--ease-out);
}
.paso-imagen.activa { opacity: 1; transform: scale(1); }

/* Pie */
.pie { display: grid; grid-template-columns: 1fr 1fr; min-height: 100vh; min-height: 100svh; background: var(--surface); }
.pie-imagen { background: var(--field-1); overflow: hidden; display: grid; place-items: center; }
.pie-imagen img { width: min(92%, 760px); }
.pie-menu { display: flex; flex-direction: column; padding: 56px var(--pad) 28px; }
.pie-marca { font-size: var(--step-lead); margin-bottom: 36px; }
.pie-menu ul { list-style: none; margin: 0; padding: 0; }
.pie-menu li + li { margin-top: 10px; }
.pie-menu nav a {
  display: inline-block; font-family: "Besley", Georgia, serif; font-weight: 800;
  font-size: var(--step-title); line-height: 1.2; text-decoration: none;
  transition: transform 240ms var(--ease-out), color 180ms linear;
}
.pie-menu nav a:hover { transform: translateX(12px); }
.pie-menu nav:hover a:not(:hover) { color: var(--muted); }
.pie-datos { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; margin-top: 56px; font-size: var(--step-note); }
.pie-datos h2 { font-family: "Libre Franklin", system-ui, sans-serif; font-weight: 600; font-size: var(--step-note); letter-spacing: 0; line-height: 1.5; margin-bottom: 4px; }
.pie-datos details { margin-top: 8px; }
.pie-datos summary { cursor: pointer; font-weight: 600; min-height: 28px; }
.pie-datos code { display: block; margin-top: 6px; font-family: inherit; font-size: var(--step-small); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.pie-legal { margin-top: auto; padding-top: 40px; font-size: var(--step-small); color: var(--muted); }

@media (max-width: 1100px) {
  .ocultar-compacto { display: none !important; }
}

/* Móvil y tableta: composición propia */
@media (max-width: 860px) {
  .partido { display: block; }
  .escenario { position: relative; height: 62vh; height: 62svh; padding: 68px 12px 0; }
  .portada { height: auto; min-height: 0; padding: 0 16px 36px; position: static; }
  .menu {
    position: absolute; top: 12px; left: 16px; right: 16px; z-index: 4;
    justify-content: space-between; gap: 12px; color: var(--field-1-ink);
  }
  .ocultar-movil { display: none !important; }
  .marca {
    position: relative; right: auto; bottom: auto; display: block; order: -1;
    font-size: 16.5vw; margin-top: -3vw;
    transform-origin: left top;
  }
  .portada { display: flex; flex-direction: column; }
  .portada-texto { position: static; margin-top: 4vw; }
  .entrada { margin-bottom: 18px; max-width: none; }
  .boton { width: 100%; }
  .menu-accion { width: auto; }
  .lectura { padding: 0 16px 80px; }
  .bloque { max-width: none; padding-top: 72px; }
  .solo-movil { display: block; width: 100%; border-radius: var(--radius); }
  .bloque .solo-movil { margin-top: 28px; }

  .vivo { grid-template-columns: 1fr; grid-template-rows: auto auto auto; }
  .vivo-entrada { grid-row: 1; padding: 64px 16px 28px; }
  .vivo-entrada select { max-width: none; }
  .vivo-titulo { grid-column: 1; grid-row: 2; grid-template-columns: 1fr; }
  .vivo-titulo span { padding: 12px 16px; }
  .vivo-salida { grid-row: 3; padding: 16px 16px 64px; }
  .tarjeta { padding: 24px; max-width: none; }

  .pasos { grid-template-columns: 1fr; padding: 72px 16px; gap: 0; }
  .pasos-escenario { display: none; }
  .paso { min-height: 0; color: var(--ink); }
  .paso + .paso { margin-top: 48px; }
  .paso:last-child { min-height: 0; }
  .paso .solo-movil { margin-top: 20px; padding: 14px; background: var(--surface); }

  .pie { grid-template-columns: 1fr; min-height: 0; }
  .pie-imagen { height: 50svh; }
  .pie-imagen img { width: auto; height: 100%; }
  .pie-menu { padding: 40px 16px 24px; }
  .pie-menu nav a { font-size: 8vw; }
  .pie-datos { grid-template-columns: 1fr; gap: 24px; margin-top: 40px; }
}

/* Movimiento: la llegada solo aplica con JavaScript activo */
@media (prefers-reduced-motion: no-preference) {
  html.js [data-carga] { animation: llegar 900ms var(--ease-out) both; animation-delay: var(--d, 0ms); }
  html.js [data-sube] { opacity: 0; transform: translateY(22px); }
  html.js [data-sube].visto {
    opacity: 1; transform: none;
    transition: opacity 700ms var(--ease-out), transform 700ms var(--ease-out);
    transition-delay: var(--retardo, 0ms);
  }
  html.js .vivo-entrada > *, html.js .tarjeta > * { transition: opacity 500ms var(--ease-out), transform 500ms var(--ease-out); }
  html.js .vivo:not(.visto) .vivo-entrada > *, html.js .vivo:not(.visto) .tarjeta > * { opacity: 0; transform: translateY(18px); }
  html.js .pie-menu li { transition: opacity 500ms var(--ease-out), transform 500ms var(--ease-out); }
  html.js .pie:not(.visto) .pie-menu li { opacity: 0; transform: translateX(-16px); }
  html.js .pie-menu li:nth-child(2) { transition-delay: 60ms; }
  html.js .pie-menu li:nth-child(3) { transition-delay: 120ms; }
  html.js .pie-menu li:nth-child(4) { transition-delay: 180ms; }
  html.js .pie-menu li:nth-child(5) { transition-delay: 240ms; }
  @keyframes llegar { from { opacity: 0; translate: 0 18px; } to { opacity: 1; translate: 0 0; } }

  @supports (animation-timeline: scroll()) {
    @media (min-width: 861px) {
      .marca { animation: marca-pesa linear both; animation-timeline: scroll(root); animation-range: 0 100vh; }
      @keyframes marca-pesa { from { transform: scale(1); } to { transform: scale(0.93); } }
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: 1ms !important; animation: none !important; }
  .pantalla, .paso-imagen { transform: none; }
}
