/* Free Fable 5 — landing. Estática, autónoma, sin peticiones externas.
   Concepto: el bosque empieza en penumbra (el Olvido) y se enciende a medida
   que bajas (litLevel del juego). Identidad del juego: noche #14141c, oro
   #f0c878, verde memoria #cfe8c0, fuente Pixelify Sans. */

@font-face {
  font-family: 'Pixelify Sans';
  src: url('fonts/pixelify-sans-700.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: 'Pixelify Sans';
  src: url('fonts/pixelify-sans-400.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}

:root {
  --night: #14141c;
  --night-2: #1a1a26;
  --gold: #f0c878;
  --gold-deep: #c79a4a;
  --green: #cfe8c0;
  --ink: #ece9e1;
  --ink-dim: #b4b2c2;
  --line: #ffffff1a;
  --display: 'Pixelify Sans', ui-monospace, monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --maxw: 1120px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1); /* ease-out-quint */
  --lit: 0.45; /* 0 = penumbra, 1 = encendido. main.js lo mueve con el scroll;
                  este valor base es el estado a media luz cuando NO hay JS. */

  /* Escala z semántica */
  --z-bg: 0;
  --z-base: 1;
  --z-rail: 30;
  --z-header: 40;
  --z-skip: 100;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--night);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  position: relative;
  overflow-x: hidden;
}

/* Capa fija: la noche que se enciende. El resplandor cálido crece con --lit
   (el bosque vívido vive en el hero; aquí solo la penumbra que va calmándose). */
.world {
  position: fixed; inset: 0; z-index: var(--z-bg); pointer-events: none;
}
/* El bosque, page-wide y muy atenuado, que EMERGE con --lit: hay algo que
   iluminar bajo el hero, no solo noche plana. Velado en oscuro para que el
   texto (casi blanco sobre noche) mantenga contraste AAA aun cuando crece. */
.world::before {
  content: ""; position: absolute; inset: 0;
  background:
    linear-gradient(#0e0e16cc, #0e0e16cc),
    url('assets/banner.webp') center top / cover no-repeat;
  image-rendering: pixelated;
  opacity: calc(0.05 + var(--lit) * 0.22);
  transition: opacity 0.3s linear;
}
.world::after {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(90% 55% at 50% 0%, #f0c87826, transparent 72%),
    radial-gradient(70% 50% at 85% 100%, #cfe8c01c, transparent 72%);
  opacity: calc(0.12 + var(--lit) * 0.88);
  transition: opacity 0.3s linear;
}

img { max-width: 100%; display: block; }
.px { image-rendering: pixelated; }

a { color: var(--gold); text-decoration: none; }
a:hover { color: #ffdf9a; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; border-radius: 4px; }
::selection { background: var(--gold); color: #1b1607; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 clamp(20px, 5vw, 40px); position: relative; z-index: var(--z-base); }

.skip {
  position: absolute; left: -999px; top: 0; z-index: var(--z-skip);
  background: var(--gold); color: var(--night); padding: 10px 16px; border-radius: 8px; font-weight: 600;
}
.skip:focus { left: 14px; top: 14px; }

/* barra de progreso = "cuánto has encendido el bosque" */
.progress {
  position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: var(--z-header);
  background: linear-gradient(90deg, var(--gold-deep), var(--gold), var(--green));
  transform: scaleX(var(--lit)); transform-origin: 0 50%; will-change: transform;
}

/* ---------- header ---------- */
.header {
  position: sticky; top: 0; z-index: var(--z-header);
  display: flex; align-items: center; gap: 18px;
  padding: 14px clamp(20px, 5vw, 40px);
  background: color-mix(in srgb, var(--night) 78%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 11px; font-family: var(--display); font-weight: 700; font-size: 19px; color: var(--ink); white-space: nowrap; }
.brand:hover { color: var(--ink); }
.brand img { width: 30px; height: 30px; }
/* En pantallas estrechas, solo el emblema (deja sitio a "Secciones" + "Jugar"). */
@media (max-width: 480px) { .brand__name { display: none; } }
.nav { display: flex; gap: 26px; margin-left: auto; }
.nav a { color: var(--ink-dim); font-size: 15px; }
.nav a:hover { color: var(--gold); }

/* Menú de secciones en móvil: <details> nativo (funciona sin JS). */
.navmenu { display: none; position: relative; }
.navmenu > summary {
  list-style: none; cursor: pointer; user-select: none;
  font-family: var(--display); font-size: 14px; color: var(--ink-dim);
  display: inline-flex; align-items: center; min-height: 44px; /* touch target */
  padding: 0 16px; border: 1px solid var(--line); border-radius: 10px;
}
.navmenu > summary::-webkit-details-marker { display: none; }
.navmenu > summary::marker { content: ""; }
.navmenu[open] > summary { color: var(--gold); border-color: var(--gold); }
.navmenu__panel {
  position: absolute; right: 0; top: calc(100% + 10px);
  display: flex; flex-direction: column; min-width: 190px; gap: 2px; padding: 8px;
  background: color-mix(in srgb, var(--night) 96%, transparent);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 14px 44px #000a;
}
.navmenu__panel a { color: var(--ink-dim); font-size: 15px; padding: 0 12px; border-radius: 8px; display: flex; align-items: center; min-height: 44px; }
.navmenu__panel a:hover { color: var(--gold); background: #ffffff0a; }

@media (max-width: 760px) {
  .nav { display: none; }
  .navmenu { display: block; margin-left: auto; }
}

/* ---------- botones ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 9px;
  font-family: var(--display); font-weight: 700; font-size: 16px;
  padding: 12px 22px; border-radius: 11px; border: 1px solid transparent;
  transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease), background 0.18s var(--ease), border-color 0.18s var(--ease);
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); transition-duration: 0.05s; }
.btn--primary { background: var(--gold); color: #1b1607; box-shadow: 0 8px 30px #f0c87833; }
.btn--primary:hover { background: #ffdf9a; box-shadow: 0 12px 38px #f0c87844; color: #1b1607; }
.btn--ghost { background: #ffffff0a; color: var(--ink); border-color: var(--line); }
.btn--ghost:hover { border-color: var(--gold); color: var(--gold); }
.btn--lg { font-size: 18px; padding: 15px 30px; }

/* ---------- secciones ---------- */
/* scroll-margin: al saltar por las anclas, el header sticky no tapa el encabezado. */
.section { padding: clamp(72px, 12vh, 130px) 0; scroll-margin-top: 80px; }
.h2 {
  font-family: var(--display); font-weight: 700; line-height: 1.05;
  font-size: clamp(30px, 5vw, 52px); margin: 0 0 22px; letter-spacing: -0.01em;
  text-wrap: balance; max-width: 18ch;
}
.lead { color: var(--ink-dim); font-size: clamp(17px, 2.2vw, 19px); max-width: 60ch; margin: 0 0 18px; text-wrap: pretty; }
.lead b, .lead strong { color: var(--ink); font-weight: 600; }
.lead .em { color: var(--gold); font-weight: 600; }

/* ---------- hero ---------- */
.hero {
  min-height: 94vh; display: flex; align-items: center; padding: 120px 0 96px;
  position: relative; isolation: isolate; margin-top: -64px; /* el banner sube tras el header */
}
/* El bosque vívido: la escena generada a sangre, con scrim para que el texto respire. */
.hero::before {
  content: ""; position: absolute; inset: 0; z-index: -2;
  background: var(--night) url('assets/banner.webp') center / cover no-repeat;
  image-rendering: pixelated;
}
.hero::after {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background:
    linear-gradient(90deg, #0b0b12f2 0%, #0c0c14d9 38%, #0c0c1480 64%, #0c0c1433 100%),
    linear-gradient(0deg, var(--night) 2%, transparent 34%);
}
.hero__grid { width: 100%; max-width: 60ch; }
/* En móvil el texto ocupa todo el ancho: scrim vertical para asegurar contraste. */
@media (max-width: 760px) {
  .hero::after {
    background:
      linear-gradient(0deg, var(--night) 4%, #0c0c14e6 40%, #0c0c14b3 100%),
      linear-gradient(90deg, #0b0b12cc, transparent 80%);
  }
}

.hero__kicker {
  font-family: var(--display); color: var(--green); font-size: 15px; letter-spacing: 0.02em;
  margin: 0 0 18px;
}
.hero__title {
  font-family: var(--display); font-weight: 700; color: var(--ink);
  font-size: clamp(54px, 11vw, 92px); line-height: 0.92; letter-spacing: -0.02em;
  margin: 0 0 22px; text-shadow: 0 2px 30px #000a, 0 0 50px #f0c87822; text-wrap: balance;
}
.hero__title .glow { color: var(--gold); }
.hero__sub { font-size: clamp(19px, 2.6vw, 23px); color: var(--ink); max-width: 34ch; margin: 0 0 16px; }
.hero__story { color: var(--ink-dim); max-width: 50ch; margin: 0 0 30px; }
.actions { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; }
.meta {
  margin-top: 26px; font-family: var(--display); font-size: 13.5px; color: var(--ink-dim);
  display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center;
}
.meta .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--gold); opacity: 0.6; }

/* ---------- bloque alterno (historia / los tres) ---------- */
.split { display: grid; grid-template-columns: 1fr 0.78fr; gap: clamp(28px, 6vw, 72px); align-items: center; }
.split--flip { grid-template-columns: 0.78fr 1fr; }
.split--flip .split__art { order: -1; }
@media (max-width: 820px) { .split, .split--flip { grid-template-columns: 1fr; gap: 28px; } .split--flip .split__art { order: 0; } }
/* El sprite (prop 32px) es un "specimen" pequeño y nítido sobre un halo que lo
   abraza, no una tira perdida en una caja grande. Escala ~2.5x → bloques limpios. */
.split__art { display: grid; place-items: center; padding: 24px; min-height: 200px; }
.split__art::before {
  content: ""; grid-area: 1 / 1; place-self: center;
  width: clamp(150px, 20vw, 188px); aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle, var(--tint, #f0c8781f), transparent 66%);
  filter: blur(3px);
}
.split__sprite { grid-area: 1 / 1; place-self: center; width: clamp(64px, 9vw, 84px); image-rendering: pixelated; filter: drop-shadow(0 8px 14px #000b); }
.split__sprite--float { animation: float 5s var(--ease) infinite; }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }

/* ---------- el bucle (secuencia real → numerada con intención) ---------- */
.loop { margin-top: 44px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; counter-reset: step; }
@media (max-width: 720px) { .loop { grid-template-columns: 1fr 1fr; } }
.loop__step {
  position: relative; padding: 22px 20px 20px; border: 1px solid var(--line); border-radius: 16px;
  background: #ffffff08;
}
.loop__step::before {
  counter-increment: step; content: counter(step);
  font-family: var(--display); font-size: 13px; color: var(--night); font-weight: 700;
  position: absolute; top: -13px; left: 20px;
  width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; background: var(--gold);
}
.loop__step h3 { font-family: var(--display); font-size: 18px; margin: 4px 0 6px; color: var(--ink); }
.loop__step p { margin: 0; font-size: 14.5px; color: var(--ink-dim); }
.loop__step .arrow { position: absolute; right: -11px; top: 50%; transform: translateY(-50%); color: var(--gold-deep); font-size: 20px; }
@media (max-width: 720px) { .loop__step .arrow { display: none; } }

/* ---------- controles ---------- */
.controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 12px; margin-top: 38px; }
.ctrl { padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: #ffffff06; }
.ctrl__keys { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 12px; }
.kbd {
  font-family: var(--display); font-size: 14px; color: var(--gold);
  background: #0d0d15; border: 1px solid var(--line); border-bottom-width: 3px;
  border-radius: 7px; padding: 5px 11px; line-height: 1;
}
.ctrl__what { font-weight: 600; color: var(--ink); margin: 0; }
.ctrl__note { color: var(--ink-dim); font-size: 14px; margin: 3px 0 0; }

/* ---------- cierre ---------- */
.closing { text-align: center; }
.closing .h2 { max-width: 22ch; margin-inline: auto; font-size: clamp(34px, 6.5vw, 60px); }
.closing .lead { margin-inline: auto; }
.closing__row { display: flex; justify-content: center; gap: clamp(18px, 5vw, 40px); margin: 0 0 30px; }
.closing__row img { width: clamp(48px, 9vw, 68px); height: auto; filter: drop-shadow(0 8px 14px #000a); }
.closing .actions { justify-content: center; margin-top: 30px; }

/* ---------- footer ---------- */
.footer { border-top: 1px solid var(--line); padding: 44px 0 56px; color: var(--ink-dim); font-size: 14px; }
.footer__wrap { display: flex; flex-wrap: wrap; gap: 12px 22px; align-items: center; justify-content: space-between; }
.footer__stack { font-family: var(--display); display: flex; gap: 9px; flex-wrap: wrap; opacity: 0.75; }
@media (max-width: 600px) { .footer__wrap { justify-content: center; text-align: center; } }

/* ---------- motion: reveals que REALZAN un contenido ya visible ----------
   El estado oculto solo se aplica bajo <html class="anim">, que el <head>
   añade antes del paint únicamente si hay JS, soporte de IntersectionObserver
   y el usuario no pidió menos movimiento. Sin JS / headless / reduced-motion:
   nunca se oculta nada (la página jamás se publica en blanco). */
@media (prefers-reduced-motion: no-preference) {
  .anim .reveal { opacity: 0; transform: translateY(20px); transition: opacity 0.7s var(--ease), transform 0.7s var(--ease); }
  .anim .reveal.in { opacity: 1; transform: none; }
  .anim .stagger > * { opacity: 0; transform: translateY(16px); transition: opacity 0.6s var(--ease), transform 0.6s var(--ease); }
  .anim .stagger.in > * { opacity: 1; transform: none; }
  .anim .stagger.in > *:nth-child(2) { transition-delay: 0.08s; }
  .anim .stagger.in > *:nth-child(3) { transition-delay: 0.16s; }
  .anim .stagger.in > *:nth-child(4) { transition-delay: 0.24s; }
}

/* Menos movimiento: sin la flotación continua de los sprites (los reveals ya
   van bajo .anim, que el <head> no activa con reduced-motion). */
@media (prefers-reduced-motion: reduce) {
  .split__sprite--float { animation: none; }
}
