/* ============================================================
   scroll-cinematic-pro v2 — estilos base
   Tema por data-theme en <html>: cambia tokens sin tocar estructura.
   Tipografía: cargar en el HTML 2 fuentes editoriales (NUNCA
   Inter/Roboto/Arial/Space Grotesk como default).
   ============================================================ */

:root,
[data-theme="noir"] {
  --bg: #0b0a09;
  --ink: #f5f1e8;
  --ink-dim: rgba(245, 241, 232, 0.64);
  --accent: #c9a227;
  --accent-soft: rgba(201, 162, 39, 0.14);
  --surface: #161310;
  --font-display: "Fraunces", serif;
  --font-body: "Manrope", system-ui, sans-serif;
}

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

html { scroll-behavior: auto; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  overflow-x: hidden;
  line-height: 1.6;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.08; }

a { color: inherit; }

/* ---------- Nav ---------- */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 32px;
  font-size: 13px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  mix-blend-mode: difference;
}
.nav a { text-decoration: none; }
.nav a:hover, .nav a:focus-visible { color: var(--accent); outline-offset: 4px; }
.nav .nav-links { display: flex; gap: 28px; }

/* ---------- Sección scrub (sticky) ---------- */
.cinematic {
  position: relative;
  height: 500vh; /* distancia de scroll = duración de reproducción (420–600vh) */
}
.cinematic .sticky {
  position: sticky;
  top: 0;
  height: 100vh;
  width: 100%;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--bg);
}
.cinematic canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: var(--vignette-opacity, 1); /* temas claros la bajan via token */
  background:
    radial-gradient(120% 90% at 50% 45%, transparent 45%, rgba(0, 0, 0, 0.6) 100%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.4) 0%, transparent 25%, transparent 70%, rgba(0, 0, 0, 0.65) 100%);
}

/* Copy superpuesto con ventanas [data-in, data-out] */
.reveal-line {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: max-content;
  max-width: 90vw;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2.2rem, 7vw, 6rem);
  letter-spacing: 0.01em;
  line-height: 1.05;
  text-align: center;
  opacity: 0;
  will-change: opacity, transform;
  z-index: 10;
}
.reveal-line em { font-style: italic; color: var(--accent); }
/* La PRIMERA línea del hero nace visible: es el candidato LCP de la página
   (con opacity 0 inicial no habría texto pintado en el primer viewport).
   Su ventana debe empezar en negativo (ej. data-in="-0.3") para que el motor
   la mantenga visible arriba del todo. */
.overlay-stack .reveal-line:first-child { opacity: 1; }

/* Indicador de carga + progreso del scrub */
.scrub-loading {
  position: absolute;
  bottom: 70px; left: 50%;
  transform: translateX(-50%);
  z-index: 12;
  font-size: 11px;
  letter-spacing: 0.3em;
  color: var(--ink-dim);
}
.scrub-loading.done { display: none; }
.scrub-progress {
  position: absolute;
  left: 32px; right: 32px; bottom: 44px;
  height: 1px;
  background: rgba(255, 255, 255, 0.14);
  z-index: 12;
}
.scrub-progress-fill { height: 100%; width: 0; background: var(--accent); }

.scroll-hint {
  position: absolute;
  bottom: 16px; left: 50%;
  transform: translateX(-50%);
  z-index: 12;
  font-size: 11px;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: var(--ink-dim);
  animation: bob 1.8s ease-in-out infinite;
  transition: opacity 0.4s;
}
@keyframes bob {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(6px); }
}

/* ---------- Secciones de contenido ---------- */
.section { padding: 120px 32px; max-width: 1200px; margin: 0 auto; }
.section .kicker {
  font-size: 12px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 16px;
}
.section h2 { font-size: clamp(1.9rem, 4.5vw, 3.4rem); margin-bottom: 24px; max-width: 18ch; }
.section p.lead { font-size: 1.15rem; color: var(--ink-dim); max-width: 58ch; }

/* Bento de valor */
.bento {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-top: 56px;
}
.bento .cell {
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  padding: 32px 28px;
}
.bento .cell.wide { grid-column: span 2; }
.bento h3 { font-size: 1.35rem; margin-bottom: 10px; }
.bento p { color: var(--ink-dim); font-size: 0.98rem; }

/* Stats */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  text-align: center;
  margin-top: 48px;
}
.stat-num {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 6vw, 4.2rem);
  color: var(--accent);
}
.stat-label { font-size: 0.9rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-dim); }

/* CTA */
.cta { text-align: center; }
.btn {
  display: inline-block;
  margin-top: 32px;
  padding: 16px 44px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  font-size: 14px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-decoration: none;
  transition: background 0.25s, color 0.25s;
}
.btn:hover, .btn:focus-visible { background: var(--accent); color: var(--bg); outline-offset: 4px; }

/* Footer */
.footer {
  padding: 56px 32px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  display: flex;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  color: var(--ink-dim);
  font-size: 0.9rem;
}

/* Reveals genéricos */
.reveal { opacity: 0; transform: translateY(26px); transition: opacity 0.7s ease, transform 0.7s ease; }
.reveal.in { opacity: 1; transform: none; }

/* ---------- Efectos cinematográficos (opt-in) ---------- */
/* Film grain: <div class="fx-grain" aria-hidden="true"></div> dentro de .sticky.
   Una sola capa de ruido SVG animada por saltos — costo casi nulo. */
.fx-grain {
  position: absolute;
  inset: -40%;
  pointer-events: none;
  z-index: 11;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='0.55'/></svg>");
  opacity: 0.06;
  animation: fx-grain-shift 0.9s steps(4) infinite;
}
@keyframes fx-grain-shift {
  0%   { transform: translate(0, 0); }
  25%  { transform: translate(-3%, 2%); }
  50%  { transform: translate(2%, -3%); }
  75%  { transform: translate(-2%, -2%); }
  100% { transform: translate(3%, 3%); }
}
@media (prefers-reduced-motion: reduce) { .fx-grain { animation: none; } }
.no-js .fx-grain, .save-data .fx-grain { animation: none; }

/* Glass card: añade .glass a una .cell o .h-item (mejor sobre imágenes/canvas;
   backdrop-filter es caro en GPU — usarlo en tarjetas, nunca a viewport completo) */
.glass {
  background: color-mix(in srgb, var(--surface) 52%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  backdrop-filter: blur(14px) saturate(1.2);
  border: 1px solid rgba(255, 255, 255, 0.12);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass { background: var(--surface); } /* fallback sólido */
}

/* Tinte de color por sección: <div class="fx-tint" aria-hidden="true"></div>
   dentro de .sticky; el color sale del tema (o define --tint inline) */
.fx-tint {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  background: var(--tint, var(--accent-soft));
  mix-blend-mode: overlay;
  opacity: 0.4;
}

/* En móvil los efectos se degradan a su versión ligera: backdrop-filter,
   mix-blend-mode y la capa animada de grain cuestan LCP real con CPU lenta
   (medido: +1s de LCP en Lighthouse móvil). El look completo es de desktop. */
@media (max-width: 820px) {
  .fx-grain { animation: none; opacity: 0.05; }
  .fx-tint { mix-blend-mode: normal; opacity: 0.16; }
  .glass {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    background: var(--surface);
  }
}

/* ---------- Accesibilidad / degradación ---------- */
/* Sin JavaScript: todo visible y estático (mismas reglas que reduced-motion) */
.no-js .cinematic { height: 100vh; }
.no-js .reveal-line { position: static; transform: none; opacity: 1 !important; margin: 8px 0; }
.no-js .overlay-stack {
  position: absolute; inset: 0; z-index: 10;
  display: grid; place-content: center; text-align: center; padding: 24px;
}
.no-js .reveal { opacity: 1; transform: none; transition: none; }
.no-js .scroll-hint, .no-js .scrub-progress, .no-js .scrub-loading { display: none; }

@media (prefers-reduced-motion: reduce) {
  .cinematic { height: 100vh; } /* sin distancia de scrub: un solo viewport */
  .reveal-line { position: static; transform: none; opacity: 1 !important; margin: 8px 0; }
  .cinematic .overlay-stack {
    position: absolute; inset: 0; z-index: 10;
    display: grid; place-content: center; text-align: center; padding: 24px;
  }
  .reveal { opacity: 1; transform: none; transition: none; }
  .scroll-hint, .scrub-progress { display: none; }
}
/* saveData / 2g-3g: modo poster, todo visible sin scrub */
.save-data .cinematic { height: 100vh; }
.save-data .reveal-line { position: static; transform: none; opacity: 1 !important; margin: 8px 0; }
.save-data .overlay-stack {
  position: absolute; inset: 0; z-index: 10;
  display: grid; place-content: center; text-align: center; padding: 24px;
}
.save-data .scroll-hint, .save-data .scrub-progress, .save-data .scrub-loading { display: none; }

/* ---------- Móvil ---------- */
@media (max-width: 820px) {
  .nav { padding: 16px 18px; }
  .nav .nav-links { gap: 16px; }
  .section { padding: 80px 20px; }
  .bento { grid-template-columns: 1fr; }
  .bento .cell.wide { grid-column: span 1; }
  .stats { grid-template-columns: 1fr; gap: 32px; }
  .scrub-progress { left: 18px; right: 18px; }
}

/* Hit-area táctil cómoda en links de texto (WCAG 2.5.8) sin mover el layout */
.nav a, .footer a {
  padding: 12px 8px;
  margin: -12px -8px;
  display: inline-block;
}

/* ── motion-premium: galería horizontal pinned ── */
.h-gallery { overflow: hidden; padding: 110px 0; }
.h-track { display: flex; gap: 24px; padding: 0 32px; width: max-content; will-change: transform; }
.h-item { flex: 0 0 min(70vw, 460px); background: var(--surface); border: 1px solid rgba(0,0,0,0.08); border-radius: 14px; padding: 44px 34px; }
.h-item h3 { font-size: 1.5rem; margin-bottom: 12px; }
.h-item p { color: var(--ink-dim); }
.no-js .h-gallery, .reduced-motion .h-gallery { overflow-x: auto; }
@media (prefers-reduced-motion: reduce) { .h-gallery { overflow-x: auto; } }

/* ── badge glass sobre el hero ── */
.fx-badge { position: absolute; left: 32px; bottom: 90px; z-index: 12; padding: 10px 18px; border-radius: 999px; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; }
@media (max-width: 820px) { .fx-badge { left: 18px; bottom: 76px; } }

/* ── tema claro (arena): el copy sobre el canvas del hero debe ser claro y legible ── */
[data-theme="arena"] .cinematic .reveal-line { color: #f8f3ea; text-shadow: 0 2px 34px rgba(0,0,0,0.55); }
[data-theme="arena"] .cinematic .reveal-line em { color: #e8c87a; }
[data-theme="arena"] .scroll-hint, [data-theme="arena"] .scrub-loading { color: rgba(248,243,234,0.85); }
