@font-face {
  font-family: "Geist";
  src: url("../Assets/web/Geist.ttf") format("truetype");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --night: #0e0c0b;
  --ink: #1f1915;        /* texto sobre crema */
  --ink-dim: #6e6152;
  --orange: #ff5a0a;
  --amber: #ffa320;
  --amber-hi: #ffc35a;
  --amber-dim: #a86f00;
  --sand: #c9b9a3;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --crt: "VT323", "IBM Plex Mono", monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
html { background: var(--sand); }
/* una sola pantalla: el hero. Si la ventana es más baja que el mínimo del hero, <main> scrollea. */
main {
  height: 100vh; height: 100dvh;
  overflow-x: hidden; overflow-y: auto;
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
main::-webkit-scrollbar { display: none; }
body {
  font-family: "Geist", system-ui, sans-serif;
  color: var(--ink);
  background: transparent;
  -webkit-font-smoothing: antialiased;
}
body.is-intro main { overflow: hidden; }
img { display: block; max-width: 100%; }
.mono { font-family: var(--mono); }

/* ---------- Intro ASCII ---------- */
#intro {
  position: fixed; inset: 0; width: 100vw; height: 100vh;
  z-index: 100; pointer-events: none;
}
.reveal {
  opacity: 0; transform: translateY(10px);
  transition: opacity .6s ease, transform .6s cubic-bezier(.2,.7,.2,1);
  transition-delay: calc(var(--d, 0) * 80ms);
}
body.is-revealed .reveal { opacity: 1; transform: none; }
/* intro blueprint: el bloque de texto entra desde la izquierda cuando la tecla termina de armarse */
html.intro-blueprint .reveal {
  transition: opacity .7s ease, transform .9s cubic-bezier(.16,.84,.24,1);
  transition-delay: calc(var(--d, 0) * 75ms);
}
html.intro-blueprint body:not(.is-built) .reveal { opacity: 0; transform: translateX(-64px); }
html.intro-blueprint body:not(.is-built) .stage__hint { opacity: 0; }

/* ================= HERO ================= */
.hero {
  position: relative;
  height: 100%; min-height: 600px;
  scroll-snap-align: start; scroll-snap-stop: always;
  overflow: hidden;
  background: var(--sand);
}
.hero__stage { position: absolute; inset: 0; z-index: 0; }
.hero::after { /* film grain: textura de ruido generada una vez (js/grain.js), sin modos de mezcla para no frenar el 3D */
  content: ""; position: absolute; inset: -64px; z-index: 3; pointer-events: none;
  background-image: var(--grain, none);
  background-size: var(--grain-size, 192px) var(--grain-size, 192px);
  image-rendering: pixelated;
  will-change: transform;
  animation: grain .5s steps(1) infinite;
}
@keyframes grain {
  0% { transform: translate3d(0, 0, 0); } 20% { transform: translate3d(-37px, 21px, 0); }
  40% { transform: translate3d(29px, -44px, 0); } 60% { transform: translate3d(-52px, -13px, 0); }
  80% { transform: translate3d(17px, 41px, 0); }
}
.stage__vignette {
  position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background:
    radial-gradient(45% 40% at 68% 38%, rgba(255,214,170,.16), transparent 70%),
    radial-gradient(120% 95% at 55% 45%, transparent 52%, rgba(70,48,28,.26) 100%);
}
#key3d { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; touch-action: pan-y; }
#key3d.is-hover { cursor: pointer; }
.stage__blinds { /* sombras de persiana, como en la referencia (espejadas) */
  position: absolute; inset: -20%; pointer-events: none;
  background: repeating-linear-gradient(28deg,
    rgba(70,52,34,0) 0, rgba(70,52,34,0) 34px, rgba(70,52,34,.13) 70px, rgba(70,52,34,.13) 84px, rgba(70,52,34,0) 122px, rgba(70,52,34,0) 150px);
  will-change: transform;
  animation: blinds 18s ease-in-out infinite alternate;
}
@keyframes blinds { to { transform: translate3d(40px, 16px, 0); } }
.stage__fallback { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }

/* capa de interfaz encima del 3D: deja pasar los clicks a la tecla */
.hero__ui {
  position: absolute; inset: 0; z-index: 2; pointer-events: none;
  display: grid; grid-template-rows: auto 1fr auto;
  padding: clamp(22px, 4vh, 44px) clamp(22px, 4vw, 64px);
}
.hero__ui a, .hero__ui button, .hero__ui .modules { pointer-events: auto; }

.hero__logo {
  width: clamp(124px, 19.5vh, 205px); height: auto;
  /* logo blanco tal cual; un glow gris suave lo despega del crema */
  filter: drop-shadow(0 1px 1px rgba(60,45,30,.35)) drop-shadow(0 0 12px rgba(60,45,30,.35)) drop-shadow(0 0 30px rgba(60,45,30,.18));
}

.hero__info { align-self: center; max-width: min(640px, 46vw); display: grid; gap: clamp(12px, 2.2vh, 22px); }
.hero__title {
  font-family: "Geist", system-ui, sans-serif;
  font-weight: 800; letter-spacing: -.04em; line-height: .95;
  font-size: clamp(40px, min(5.4vw, 8.4vh), 92px);
  color: #fff;
  text-shadow: 0 1px 1px rgba(60,45,30,.3), 0 0 14px rgba(60,45,30,.3), 0 0 36px rgba(60,45,30,.18);
}
.hero__title .hl { color: var(--key, var(--orange)); transition: color .45s ease; text-shadow: 0 1px 1px rgba(60,45,30,.25), 0 0 18px rgba(60,45,30,.18);
}
.hero__meta {
  font-family: "Geist Mono", var(--mono); font-size: 12px; font-weight: 500;
  letter-spacing: .14em; text-transform: uppercase; color: rgba(31,25,21,.62);
}
.hero__meta i { font-style: normal; color: var(--key, var(--orange)); margin: 0 .35em; transition: color .4s; }

/* ---------- Módulos: teclas retro deshabilitadas ---------- */
.modules { margin-top: 6px; }
.modules__label {
  font-family: "Geist Mono", var(--mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase;
  color: rgba(31,25,21,.45); margin-bottom: 10px;
}
.blink { animation: caret 1s steps(2) infinite; }
.modules__list { --gap: 22px; list-style: none; display: grid; grid-template-columns: repeat(5, 1fr); gap: var(--gap); }
.modules__list li { position: relative; }
/* conectores wireframe entre episodios: círculo — línea — círculo, en naranja */
.modules__list li:not(:last-child)::after {
  content: ""; position: absolute; z-index: 1; pointer-events: none;
  top: calc(50% - 2px); left: calc(100% - 4px); width: calc(var(--gap) + 8px); height: 8px;
  transform: translateY(-50%);
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='30' height='8' viewBox='0 0 30 8'><g fill='none' stroke='%23ff5a0a' stroke-width='1.2'><circle cx='4' cy='4' r='2.4'/><circle cx='26' cy='4' r='2.4'/><path d='M6.4 4H23.6'/></g></svg>") center / contain no-repeat;
}
.module {
  width: 100%; aspect-ratio: 1 / 1.02; position: relative;
  display: flex; flex-direction: column; justify-content: space-between; text-align: left;
  padding: 10px 10px 9px;
  font-family: "Geist", system-ui, sans-serif; color: rgba(31,25,21,.5);
  background: linear-gradient(180deg, rgba(244,237,224,.78), rgba(226,215,196,.7));
  border: 1px solid rgba(31,25,21,.14);
  border-bottom-width: 4px; border-bottom-color: rgba(31,25,21,.2);
  border-radius: 9px;
  box-shadow: 0 6px 14px -8px rgba(60,45,30,.45), inset 0 1px 0 rgba(255,255,255,.7);
  cursor: not-allowed;
  backdrop-filter: blur(3px);
  transition: transform .15s, color .2s;
}
.module:hover { transform: translateY(1px); color: rgba(31,25,21,.62); }
.module__ep { font-family: "Geist Mono", var(--mono); font-size: 10.5px; font-weight: 500; letter-spacing: .1em; color: rgba(31,25,21,.38); }
.module__name { font-size: 13px; font-weight: 700; line-height: 1.12; letter-spacing: -.01em; text-transform: uppercase; }
.module__name em { font-style: normal; font-weight: 500; font-size: 11px; letter-spacing: .02em; opacity: .75; }
.module__lock { font-family: "Geist Mono", var(--mono); font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase; color: rgba(31,25,21,.32); }

.hero__foot { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; }
.hero__partners { display: flex; align-items: center; gap: 12px; color: rgba(31,25,21,.6); font-weight: 600; }
.hero__partners img { height: 18px; width: auto; filter: brightness(0); opacity: .72; }
.hero__partners img + span + img { height: 14px; }

.stage__hint {
  position: absolute; z-index: 1; left: 69%; bottom: 24%; transform: translateX(-50%);
  font-size: 12px; letter-spacing: .12em; color: rgba(40,30,22,.55);
  pointer-events: none; transition: opacity .6s ease;
  animation: blink-hint 1.6s steps(2) infinite;
}
.stage__hint.is-gone { opacity: 0; }
@keyframes blink-hint { 50% { color: rgba(40,30,22,.3); } }

@keyframes caret { 50% { opacity: 0; } }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

/* ---------- Inscripción: campo crema + tecla naranja (mismo lenguaje que los episodios) ---------- */
.signup { pointer-events: auto; max-width: 560px; min-width: 0; }
.signup .modules__label { margin-bottom: 8px; }
.signup__row { display: flex; gap: 10px; }
.signup__field {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px;
  height: 46px; padding: 0 14px; border-radius: 9px; cursor: text;
  background: linear-gradient(180deg, rgba(250,245,236,.92), rgba(236,227,211,.88));
  border: 1px solid rgba(31,25,21,.16); border-bottom-width: 3px;
  box-shadow: 0 6px 14px -8px rgba(60,45,30,.45), inset 0 1px 0 rgba(255,255,255,.8);
  transition: border-color .2s, box-shadow .2s;
}
.signup__field:focus-within { border-color: rgba(255,90,10,.7); box-shadow: 0 0 0 3px rgba(255,90,10,.18), inset 0 1px 0 rgba(255,255,255,.8); }
.signup__gt { font-family: "Geist Mono", var(--mono); color: var(--orange); font-weight: 600; }
.signup__field input {
  flex: 1; min-width: 0; width: 100%; height: 100%; border: 0; outline: none; background: transparent;
  font-family: "Geist Mono", var(--mono); font-size: 14px; color: var(--ink);
}
.signup__field input::placeholder { color: rgba(31,25,21,.38); }
.signup__btn {
  flex: none; height: 46px; padding: 0 18px; border-radius: 9px; cursor: pointer;
  font-family: "Geist", system-ui, sans-serif; font-weight: 700; font-size: 13px; letter-spacing: .06em; text-transform: uppercase;
  color: #fff; background: linear-gradient(180deg, #ff6a1f, #f04e00);
  border: 0; border-bottom: 4px solid #b83a00;
  box-shadow: 0 8px 16px -8px rgba(160,60,0,.6);
  transition: transform .1s, filter .2s;
}
/* sigue el color de la tecla 3D (--key / --key-ink los pone hero3d.js al presionarla) */
@supports (color: color-mix(in srgb, red, blue)) {
  .signup__btn {
    color: var(--key-ink, #fff);
    background: var(--key, var(--orange)) linear-gradient(180deg, rgba(255,255,255,.1), rgba(0,0,0,.07));
    border-bottom-color: color-mix(in srgb, var(--key, var(--orange)) 70%, #000);
    box-shadow: 0 8px 16px -8px color-mix(in srgb, var(--key, var(--orange)) 65%, transparent);
    transition: transform .1s, filter .2s, color .45s ease, background-color .45s ease, border-color .45s ease, box-shadow .45s ease;
  }
}
.signup__btn:hover { filter: brightness(1.06); }
.signup__btn:active { transform: translateY(2px); border-bottom-width: 2px; }
.signup__btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.signup__btn:disabled { opacity: .6; cursor: wait; }
.signup__hint {
  margin-top: 7px; font-family: "Geist Mono", var(--mono); font-size: 10.5px; line-height: 1.45; letter-spacing: .04em;
  color: rgba(31,25,21,.55);
}
.signup__hint[data-kind="ok"] { color: #2f6b1f; font-weight: 600; }
.signup__hint[data-kind="err"] { color: #b03a08; font-weight: 600; }


/* ---------- Estados de los episodios ---------- */
.module.is-published { cursor: pointer; color: var(--ink); background: linear-gradient(180deg, rgba(250,246,238,.94), rgba(236,227,211,.9)); }
.module.is-published .module__ep { color: var(--orange); }
.module.is-published .module__lock { color: rgba(31,25,21,.55); }
.module.is-published:hover { transform: translateY(1px); border-bottom-width: 3px; }
.module.is-pending { box-shadow: inset 0 -3px 0 #ffa320, 0 6px 14px -8px rgba(60,45,30,.45); }
.module.is-pending .module__lock { color: #a86f00; }
.module.is-changes { box-shadow: inset 0 -3px 0 var(--orange), 0 6px 14px -8px rgba(60,45,30,.45); }
.module.is-changes .module__lock { color: #b03a08; }
.module.is-approved {
  color: #fff; background: linear-gradient(180deg, #5fb84a, #3f9a2e);
  border-color: rgba(30,80,20,.45); border-bottom-color: #2d6e21;
}
.module.is-approved .module__ep, .module.is-approved .module__lock { color: rgba(255,255,255,.85); }
.module.is-approved .module__ep::after { content: " ✓"; }
.module:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }

.signup__me {
  margin-top: 4px; padding: 2px 0; border: 0; background: none; cursor: pointer;
  font-family: "Geist Mono", var(--mono); font-size: 10.5px; letter-spacing: .04em; color: rgba(31,25,21,.55);
  text-decoration: underline; text-underline-offset: 3px;
}
.signup__me:hover { color: var(--orange); }
.signup__field--static { cursor: default; }
.signup__email { flex: 1; min-width: 0; font-family: "Geist Mono", var(--mono); font-size: 14px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.signup__hint .signup__me { margin: 0 0 0 4px; padding: 0; font-size: inherit; }

/* ---------- Panel del episodio ---------- */
html.panel-open main { overflow: hidden; }
.panel__scrim {
  position: fixed; inset: 0; z-index: 40; background: rgba(40,28,18,.38);
  opacity: 0; transition: opacity .25s ease;
}
.panel__scrim.is-open { opacity: 1; }
.panel {
  position: fixed; z-index: 41; top: 0; right: 0; bottom: 0; width: min(520px, 100vw);
  overflow-y: auto; overscroll-behavior: contain;
  padding: 22px 24px calc(24px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 14px;
  color: var(--ink); background: linear-gradient(180deg, #f8f3ea, #efe6d6);
  border-left: 1px solid rgba(31,25,21,.16); border-radius: 14px 0 0 14px;
  box-shadow: -30px 0 60px -20px rgba(40,25,10,.6);
  transform: translateX(104%); transition: transform .26s cubic-bezier(.2,.7,.2,1);
  outline: none;
}
.panel.is-open { transform: none; }
.panel__close {
  align-self: flex-end; border: 0; background: none; cursor: pointer; padding: 4px 2px;
  font-family: "Geist Mono", var(--mono); font-size: 12px; letter-spacing: .08em; color: rgba(31,25,21,.55);
}
.panel__close:hover { color: var(--orange); }
.panel__ep { display: flex; flex-direction: column; gap: 14px; }
.panel__ep[hidden] { display: none; }
.panel__kicker, .panel__label {
  font-family: "Geist Mono", var(--mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: rgba(31,25,21,.5);
}
.panel__title { font-size: 30px; font-weight: 800; letter-spacing: -.03em; line-height: 1; margin-top: -6px; }
.panel__title span { color: var(--orange); }
.panel__video { position: relative; aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden; background: #14100c; }
.panel__video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.panel__summary { padding-left: 18px; font-size: 14px; line-height: 1.5; color: rgba(31,25,21,.85); display: grid; gap: 4px; }
.panel__materials { display: flex; gap: 8px; flex-wrap: wrap; }
.panel__materials a {
  font-family: "Geist Mono", var(--mono); font-size: 11.5px; text-decoration: none; color: var(--ink);
  padding: 6px 10px; border-radius: 7px; border: 1px solid rgba(31,25,21,.2); border-bottom-width: 3px; background: rgba(255,255,255,.55);
}
.panel__materials a:hover { border-color: var(--orange); }
.panel__submit { border-top: 1px dashed rgba(31,25,21,.25); padding-top: 14px; display: grid; gap: 9px; }
.panel__assignment, .panel__authText { font-size: 13.5px; line-height: 1.45; }
.panel__status { font-family: "Geist Mono", var(--mono); font-size: 12px; line-height: 1.4; padding: 7px 10px; border-radius: 6px; border: 1px solid; }
.panel__status.is-pending { color: #8a5a00; background: rgba(255,163,32,.16); border-color: rgba(255,163,32,.45); }
.panel__status.is-changes { color: #a8300a; background: rgba(255,90,10,.12); border-color: rgba(255,90,10,.45); }
.panel__status.is-approved { color: #2f6b1f; background: rgba(80,170,60,.14); border-color: rgba(80,170,60,.45); }
.panel__form[hidden], .panel__auth[hidden], .panel__status[hidden], .panel__assignment[hidden], .panel__who[hidden] { display: none; }
.panel__who { font-family: "Geist Mono", var(--mono); font-size: 11px; line-height: 1.4; color: rgba(31,25,21,.55); overflow-wrap: anywhere; }
.panel__who b { font-weight: 600; color: var(--ink); }
.panel__auth { display: grid; gap: 9px; }
.panel__row { display: flex; gap: 8px; }
.panel__field {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 12px; border-radius: 8px; cursor: text;
  background: #fbf8f2; border: 1px solid rgba(31,25,21,.18); border-bottom-width: 3px;
  font-family: "Geist Mono", var(--mono); color: var(--orange); font-weight: 600;
}
.panel__field:focus-within { border-color: rgba(255,90,10,.7); box-shadow: 0 0 0 3px rgba(255,90,10,.15); }
.panel__field input {
  flex: 1; min-width: 0; width: 100%; height: 100%; border: 0; outline: none; background: transparent;
  font-family: "Geist Mono", var(--mono); font-size: 14px; font-weight: 400; color: var(--ink);
}
.panel__btn {
  flex: none; height: 44px; padding: 0 15px; border-radius: 8px; cursor: pointer; border: 0; border-bottom: 4px solid #b83a00;
  font-family: "Geist", system-ui, sans-serif; font-weight: 700; font-size: 12px; letter-spacing: .06em; text-transform: uppercase;
  color: #fff; background: linear-gradient(180deg, #ff6a1f, #f04e00);
}
.panel__btn:disabled { opacity: .6; cursor: wait; }
.panel__btn:active { transform: translateY(2px); border-bottom-width: 2px; }
.panel__link {
  justify-self: start; border: 0; background: none; cursor: pointer; padding: 0;
  font-family: "Geist Mono", var(--mono); font-size: 11px; color: rgba(31,25,21,.55); text-decoration: underline;
}
.panel__msg { font-family: "Geist Mono", var(--mono); font-size: 12px; line-height: 1.4; min-height: 1.4em; color: rgba(31,25,21,.6); }
.panel__msg[data-kind="ok"] { color: #2f6b1f; font-weight: 600; }
.panel__msg[data-kind="err"] { color: #b03a08; font-weight: 600; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  /* layout en flujo: logo · lugar para la tecla · texto · logos. Si no entra en la pantalla, la hero
     crece y <main> scrollea (nunca se pisan). La tecla se centra en el hueco (ver resize() en hero3d.js). */
  .hero { height: auto; min-height: 100%; }
  .hero__ui {
    position: relative; min-height: 100vh; min-height: 100dvh;
    grid-template-rows: auto minmax(calc(48vw + 24px), 1fr) auto auto;
    padding: 18px 18px calc(16px + env(safe-area-inset-bottom));
  }
  .hero__info { grid-row: 3; max-width: none; gap: 16px; }
  .hero__foot { grid-row: 4; margin-top: 22px; }
  .hero__title { font-size: clamp(34px, min(10.5vw, 6.2svh), 52px); max-width: 11ch; }
  .hero__logo { width: clamp(74px, 21vw, 96px); }
  .hero__meta { font-size: 10px; letter-spacing: .05em; }
  .hero__meta i { margin: 0 .2em; }
  .stage__hint { display: none; }

  /* las 5 clases: mismas medidas, un poco más grandes */
  .modules__label { margin-bottom: 7px; }
  .modules__list { --gap: 11px; }
  .modules__list li:not(:last-child)::after { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='19' height='8' viewBox='0 0 19 8'><g fill='none' stroke='%23ff5a0a' stroke-width='1.2'><circle cx='4' cy='4' r='2.4'/><circle cx='15' cy='4' r='2.4'/><path d='M6.4 4H12.6'/></g></svg>"); }
  .module {
    aspect-ratio: auto; height: clamp(80px, 11.5svh, 104px);
    padding: 8px 7px 7px; border-radius: 8px; overflow: hidden;
    justify-content: space-between;
  }
  .module__ep { font-size: 10px; }
  .module__name { font-size: 12px; line-height: 1.1; }
  .module__name em, .module__name br { display: none; }
  .module__lock { display: none; }

  .hero__partners { gap: 8px; font-size: 12px; }
  .hero__partners img { height: 13px; }
  .hero__partners img + span + img { height: 10px; }

  /* inscripción: ancho completo */
  .signup { max-width: none; }
  .signup .modules__label { margin-bottom: 6px; }
  .signup__row { gap: 8px; }
  .signup__field { height: 44px; padding: 0 11px; }
  .signup__field input { font-size: 16px; } /* 16px: iOS no hace zoom al enfocar */
  .signup__btn { height: 44px; padding: 0 13px; font-size: 12px; }
  .signup__hint { margin-top: 8px; font-size: 10px; line-height: 1.5; }
  .signup__me { font-size: 10px; margin-top: 6px; padding: 4px 0; }

  /* panel: pantalla completa */
  .panel { width: 100vw; border-radius: 0; border-left: 0; padding: max(16px, env(safe-area-inset-top)) 16px calc(20px + env(safe-area-inset-bottom)); }
  .panel__title { font-size: 26px; }
  .panel__field input { font-size: 16px; }
}
@media (max-width: 900px) and (max-height: 720px) {
  .hero__info { gap: 13px; }
  .hero__ui { grid-template-rows: auto minmax(calc(44vw + 16px), 1fr) auto auto; }
  .hero__foot { margin-top: 18px; }
  .hero__title { font-size: clamp(30px, 9vw, 40px); }
  .module { height: 70px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
