/* ==========================================================
   PECADO · Landing
   Tema único oscuro. Esquinas rectas en todo; la única forma
   redonda es el botón de play.
   Capas: canvas 0 · viñeta 1 · contenido 2 · grano 3 · modal (top layer)
   ========================================================== */

@font-face {
  font-family: 'Cormorant Garamond';
  src: url('assets/fonts/cormorant-garamond-latin-500-normal.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('assets/fonts/jetbrains-mono-latin-400-normal.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('assets/fonts/jetbrains-mono-latin-500-normal.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #0A0A0A;
  --ink: #EDE6DA;
  --ink-dim: rgba(237, 230, 218, 0.66);
  --ink-faint: rgba(237, 230, 218, 0.38);
  --line: rgba(237, 230, 218, 0.16);
  --red: #C1121F;
  --red-deep: #8B0000;
  --red-soft: rgba(193, 18, 31, 0.5);

  --serif: 'Cormorant Garamond', 'Cormorant', 'Times New Roman', Georgia, serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);

  --gap: clamp(10px, 1.9dvh, 22px);
  --pad-x: clamp(18px, 5vw, 40px);
}

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; }

html {
  background: var(--bg);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  min-height: 100dvh;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img, svg, video { display: block; max-width: 100%; }

[hidden] { display: none !important; }

::selection { background: var(--red); color: var(--ink); }

button, input { font: inherit; color: inherit; }

:focus-visible {
  outline: 1px solid var(--red);
  outline-offset: 3px;
}

/* ---------- Capas de ambiente ---------- */

.bg-cracks {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* Viñeta: oscurece los bordes para que el contenido respire en el centro */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 42%, transparent 35%, rgba(10, 10, 10, 0.82) 100%);
}

/* Grano de película, fijo y sin eventos (no repinta al hacer scroll) */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .9 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- Escenario (móvil primero) ---------- */

.stage {
  position: relative;
  z-index: 2;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: center;
  gap: 22px;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding:
    calc(40px + env(safe-area-inset-top, 0px))
    calc(var(--pad-x) + env(safe-area-inset-right, 0px))
    calc(48px + env(safe-area-inset-bottom, 0px))
    calc(var(--pad-x) + env(safe-area-inset-left, 0px));
}

/* ---------- Marca ---------- */

.brand {
  display: grid;
  justify-items: center;
  text-align: center;
}

.brand__logo {
  width: 124px;
  height: auto;
  aspect-ratio: 1;
  margin-bottom: 8px;
}

.brand__name {
  margin: 0;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 40px;
  line-height: 1;
  letter-spacing: 0.42em;
  margin-right: -0.42em; /* compensa el tracking para centrar ópticamente */
  display: flex;
}

.brand__name .ch { display: inline-block; }

.brand__tagline {
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--ink-dim);
  letter-spacing: 0.02em;
}

/* ---------- Vídeo ---------- */

.video-card {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  padding: 0;
  border: 1px solid var(--line);
  background: #0d0b0b;
  overflow: hidden;
  cursor: pointer;
  transition: transform 160ms var(--ease-out), border-color 200ms ease;
}

.video-card:active { transform: scale(0.98); }

.video-card__poster {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 50%;
  transition: transform 600ms var(--ease-out), opacity 300ms ease;
  opacity: 0.9;
}

.video-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(10, 10, 10, 0) 30%, rgba(10, 10, 10, 0.85) 100%);
}

.video-card__play {
  position: absolute;
  z-index: 1;
  left: 50%;
  top: 50%;
  width: 52px;
  height: 52px;
  margin: -26px 0 0 -26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--red);
  color: var(--ink);
  box-shadow: 0 0 0 0 var(--red-soft);
  animation: play-halo 2.6s var(--ease-out) infinite;
}

.video-card__play svg { width: 18px; height: 18px; margin-left: 3px; fill: currentColor; }

.video-card__label {
  position: absolute;
  z-index: 1;
  left: 14px;
  bottom: 12px;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

@keyframes play-halo {
  0%   { box-shadow: 0 0 0 0 rgba(193, 18, 31, 0.5); }
  70%  { box-shadow: 0 0 0 16px rgba(193, 18, 31, 0); }
  100% { box-shadow: 0 0 0 0 rgba(193, 18, 31, 0); }
}

@media (hover: hover) and (pointer: fine) {
  .video-card:hover { border-color: rgba(193, 18, 31, 0.6); }
  .video-card:hover .video-card__poster { transform: scale(1.04); opacity: 1; }
}

/* ---------- Comunidad ---------- */

.community {
  display: grid;
  gap: 8px;
  justify-items: center;
  text-align: center;
}

.community__text {
  margin: 0;
  font-size: 12px;
  color: var(--ink-dim);
  max-width: 34ch;
}


/* ---------- Botones ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 46px;
  padding: 0 20px;
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 160ms var(--ease-out), background-color 200ms ease, border-color 200ms ease, color 200ms ease;
}

.btn:active { transform: scale(0.97); }

.btn__icon { width: 17px; height: 17px; fill: currentColor; flex: none; }

.btn--ghost strong { font-size: 14px; font-weight: 500; text-transform: none; letter-spacing: 0.04em; }

.btn--ghost {
  width: 100%;
  border-color: var(--line);
  color: var(--ink);
  background: rgba(10, 10, 10, 0.4);
}

.btn--primary {
  background: var(--red);
  color: var(--ink);
}

@media (hover: hover) and (pointer: fine) {
  .btn--ghost:hover { border-color: var(--ink-faint); background: rgba(237, 230, 218, 0.04); }
  .btn--primary:hover { background: #d0192a; }
}

/* ---------- Juego ---------- */

.game {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 22px;
  padding-top: 6px;
}

.cipher { display: grid; justify-items: center; }

.cipher__glyphs {
  display: flex;
  gap: clamp(8px, 2.4vw, 16px);
  justify-content: center;
}

.glyph {
  width: 34px;
  aspect-ratio: 32 / 48;
  color: var(--ink);
  filter: drop-shadow(0 0 5px rgba(193, 18, 31, 0.65));
}

.glyph svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: square;
  stroke-linejoin: miter;
  overflow: visible;
}

.glyph__inner {
  display: block;
  width: 100%;
  height: 100%;
  animation:
    glyph-float 5.2s ease-in-out infinite,
    glyph-breathe 3.6s ease-in-out infinite;
  animation-delay: calc(var(--i) * -0.73s), calc(var(--i) * -0.41s);
}

.glyph.is-glitching .glyph__inner {
  animation: glyph-jitter 90ms steps(2) infinite;
  color: var(--red);
}

.cipher.is-solved .glyph { color: var(--ink); filter: drop-shadow(0 0 8px rgba(193, 18, 31, 0.9)); }
.cipher.is-solved .glyph__inner { animation: none; }

@keyframes glyph-float {
  0%, 100% { transform: translateY(-2px); }
  50%      { transform: translateY(3px); }
}

@keyframes glyph-breathe {
  0%, 100% { opacity: 0.72; }
  50%      { opacity: 1; }
}

@keyframes glyph-jitter {
  0%   { transform: translate(1px, -1px) skewX(4deg); }
  50%  { transform: translate(-2px, 1px) skewX(-6deg); }
  100% { transform: translate(1px, 0) skewX(2deg); }
}

/* Formulario */

.unlock { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }

.unlock__label {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.unlock__row { display: flex; gap: 10px; }

.unlock__input {
  flex: 1;
  min-width: 0;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: rgba(10, 10, 10, 0.55);
  font-size: 16px; /* 16px evita el zoom automático de iOS */
  letter-spacing: 0.32em;
  text-transform: uppercase;
  caret-color: var(--red);
  transition: border-color 200ms ease;
  -webkit-appearance: none;
  appearance: none;
}

.unlock__input:focus { outline: none; border-color: var(--red); }
.unlock__input:focus-visible { outline: none; }
.unlock__input:disabled { opacity: 0.6; }

.unlock__btn { min-width: 96px; }
.unlock__btn:disabled { cursor: progress; opacity: 0.75; }
.unlock__btn.is-busy span { animation: busy 900ms ease-in-out infinite; }

@keyframes busy { 50% { opacity: 0.35; } }

.unlock__row.is-wrong { animation: shake 360ms var(--ease-out); }
.unlock__row.is-wrong .unlock__input { border-color: var(--red); }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(2px); }
}

.unlock__msg {
  position: absolute;
  top: 0;
  right: 0;
  margin: 0;
  line-height: 16.5px;
  text-align: right;
  font-size: 12px;
  color: var(--ink-dim);
  opacity: 0;
  transform: translateY(-3px);
  transition: opacity 200ms ease, transform 200ms var(--ease-out);
}

.unlock__msg.is-visible { opacity: 1; transform: none; }
.unlock__msg.is-error { color: #ff5a64; }

.unlock.is-done .unlock__row { display: none; }
.unlock.is-done .unlock__msg { color: var(--ink); }

/* Tarjeta del evento */

.event {
  position: relative;
  padding: 18px 18px;
  border: 1px solid rgba(193, 18, 31, 0.45);
  background: rgba(12, 8, 8, 0.72);
  transition: border-color 400ms ease, background-color 400ms ease;
}

.event__head { display: flex; align-items: center; gap: 12px; }

.event__title {
  margin: 0;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 26px;
  line-height: 1.1;
  letter-spacing: 0.02em;
}

.event__lock {
  position: relative;
  width: 24px;
  height: 24px;
  color: var(--red);
  flex: none;
}

.event__lock svg { position: absolute; inset: 0; width: 100%; height: 100%; fill: currentColor; }

.event__lock-closed { animation: lock-beat 2.4s ease-in-out infinite; }

.event__lock-open { opacity: 0; transform: scale(0.9); transition: opacity 300ms ease, transform 400ms var(--ease-out); }

@keyframes lock-beat {
  0%, 100% { opacity: 1; transform: scale(1); }
  12%      { opacity: 1; transform: scale(1.1); }
  24%      { opacity: 0.8; transform: scale(1); }
}

/* Fragmentos del candado al romperse (se crean desde main.js) */
.shard {
  position: absolute;
  inset: 0;
  fill: currentColor;
  transition: transform 620ms var(--ease-out), opacity 620ms ease;
}

.event__meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 14px 0 0;
}

.event__meta dt {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.event__meta dd {
  margin: 2px 0 0;
  font-size: 18px;
  letter-spacing: 0.2em;
}

/* Glitch discreto en los ??? */
.glitch { position: relative; display: inline-block; }
.glitch::before,
.glitch::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  opacity: 0;
}
.glitch::before { color: var(--red); animation: glitch-a 5.5s steps(1) infinite; }
.glitch::after  { color: var(--ink); animation: glitch-b 5.5s steps(1) infinite; }

@keyframes glitch-a {
  0%, 91%, 100% { opacity: 0; transform: none; }
  92% { opacity: 0.9; transform: translate(-2px, 1px); clip-path: inset(0 0 55% 0); }
  94% { opacity: 0.9; transform: translate(2px, -1px); clip-path: inset(45% 0 0 0); }
  96% { opacity: 0; }
}
@keyframes glitch-b {
  0%, 92%, 100% { opacity: 0; transform: none; }
  93% { opacity: 0.35; transform: translate(2px, 0); clip-path: inset(30% 0 30% 0); }
  95% { opacity: 0; }
}

.event__open { margin-top: 14px; display: grid; gap: 12px; }
.event__open[hidden] { display: none; }

.event__welcome {
  margin: 0;
  font-family: var(--serif);
  font-size: 20px;
  color: var(--ink);
}

.event__open .btn { width: 100%; }

/* Estado desbloqueado */
.event.is-unlocked { border-color: var(--red); background: rgba(40, 6, 8, 0.72); }
.event.is-unlocked .event__lock-closed { opacity: 0; animation: none; }
.event.is-unlocked .event__lock-open { opacity: 1; transform: none; }
.event.is-unlocked .event__open { animation: rise 500ms var(--ease-out) both; }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- Modal del vídeo ---------- */

.video-modal {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  max-width: none;
  max-height: none;
  overflow: visible;
  opacity: 0;
  transform: scale(0.96);
  transition: opacity 260ms var(--ease-out), transform 260ms var(--ease-out);
}

.video-modal.is-open { opacity: 1; transform: none; }
.video-modal.is-closing { transition-duration: 160ms; }

.video-modal::backdrop {
  background: rgba(6, 5, 5, 0.9);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.video-modal__inner {
  position: relative;
  width: min(92vw, 1100px, calc(86dvh * 16 / 9));
  aspect-ratio: 16 / 9;
  background: #000;
  border: 1px solid var(--line);
}

.video-modal__video { width: 100%; height: 100%; object-fit: cover; background: #0d0b0b; }

.video-modal__empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 24px;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-align: center;
  background: rgba(10, 10, 10, 0.62);
}

.video-modal__close {
  position: absolute;
  top: -48px;
  right: 0;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  background: rgba(10, 10, 10, 0.6);
  cursor: pointer;
  transition: transform 160ms var(--ease-out), border-color 200ms ease;
}

.video-modal__close svg { width: 18px; height: 18px; fill: currentColor; }
.video-modal__close:active { transform: scale(0.95); }

@media (hover: hover) and (pointer: fine) {
  .video-modal__close:hover { border-color: var(--ink-faint); }
}

@media (max-height: 520px) {
  .video-modal__close { top: 10px; right: 10px; z-index: 2; }
}

/* ---------- Entrada (solo con JS) ---------- */

.js .reveal,
.js .brand__name .ch {
  opacity: 0;
  transform: translateY(10px);
  filter: blur(6px);
}

.js .brand__logo.reveal { transform: scale(0.94); filter: blur(10px); }

.js.is-ready .reveal,
.js.is-ready .brand__name .ch {
  opacity: 1;
  transform: none;
  filter: none;
  transition:
    opacity 800ms var(--ease-out),
    transform 900ms var(--ease-out),
    filter 800ms var(--ease-out);
  transition-delay: calc(var(--d, 0) * 1ms);
}

/* ---------- Pantallas grandes: misma columna, más aire ---------- */

@media (min-width: 720px) {
  .stage { max-width: 620px; gap: 30px; padding-top: 56px; padding-bottom: 64px; }
  .brand__logo { width: 168px; }
  .brand__name { font-size: 58px; }
  .brand__tagline { font-size: 13px; }
  .community__text { font-size: 13px; }
  .btn--ghost { width: auto; min-width: 280px; }
  .video-card__play { width: 68px; height: 68px; margin: -34px 0 0 -34px; }
  .video-card__play svg { width: 24px; height: 24px; }
  .video-card__label { left: 20px; bottom: 18px; }
  .glyph { width: 44px; }
  .cipher__glyphs { gap: 20px; }
  .game { gap: 26px; }
}

/* ---------- Menos movimiento ---------- */

@media (prefers-reduced-motion: reduce) {
  .js .reveal,
  .js .brand__name .ch,
  .js .brand__logo.reveal { transform: none; filter: none; }
  .js.is-ready .reveal,
  .js.is-ready .brand__name .ch { transition: opacity 300ms ease; transition-delay: 0ms; }

  .glyph__inner,
  .event__lock-closed,
  .video-card__play,
  .glitch::before,
  .glitch::after { animation: none; }

  .unlock__row.is-wrong { animation: none; }
  .video-modal { transform: none; }
  .shard { transition: opacity 200ms ease; }
}
