/* The Impossible Video — Jack Reimon
   Dirección visual: teatro a oscuras. Negro cálido, marfil y un único acento
   de latón; serif de alto contraste (Cormorant Garamond) para los títulos y
   una sans geométrica ligera (Jost) en versalitas para lo funcional. */
:root {
  --ink: #0b0a0d;
  --ink-2: #131116;
  --ivory: #efe6d5;
  --ivory-dim: #b9b0a0;
  --mute: #8a8274;
  --brass: #c9a66b;
  --brass-hi: #e3c690;
  --line: rgba(239, 230, 213, 0.16);
  --serif: "Cormorant Garamond", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "Jost", "Avenir Next", "Helvetica Neue", Arial, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--ink); color: var(--ivory); overflow: hidden; }
body { font-family: var(--sans); font-weight: 300; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%; touch-action: manipulation; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }

#stage { position: fixed; inset: 0; background: var(--ink); overflow: hidden; }

/* ───────── vídeo ───────── */
#videoWrap { position: absolute; inset: 0; background: #000; opacity: 0; transition: opacity 1.4s var(--ease); }
#videoWrap.is-on { opacity: 1; }
#videoWrap video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: transparent; opacity: 0; pointer-events: none; }
#videoWrap video.is-front { opacity: 1; z-index: 2; }
#videoWrap video.is-back { opacity: 1; z-index: 1; }
#vignette { position: absolute; inset: 0; z-index: 3; pointer-events: none; background: radial-gradient(ellipse at 50% 45%, transparent 55%, rgba(0, 0, 0, 0.35) 100%); }

/* ───────── textos sobre el vídeo ───────── */
#overlay { position: absolute; inset: 0; z-index: 5; pointer-events: none; }
.intro-title { position: absolute; left: max(4vw, env(safe-area-inset-left)); bottom: max(7vh, env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 0.9em; font-size: clamp(11px, 1.5vw, 18px); opacity: 0; transform: translateY(8px); transition: opacity 1.2s var(--ease), transform 1.6s var(--ease); text-shadow: 0 1px 14px rgba(0, 0, 0, 0.7); }
.intro-title.is-on { opacity: 1; transform: none; }
.it-name { font-family: var(--sans); font-weight: 400; letter-spacing: 0.32em; text-transform: uppercase; font-size: 0.78em; }
.it-rule { width: 2.6em; height: 1px; background: var(--brass); }
.it-work { font-family: var(--serif); font-style: italic; font-size: 1.35em; letter-spacing: 0.01em; }

.listen { position: absolute; left: 50%; bottom: max(6.5vh, calc(env(safe-area-inset-bottom) + 10px)); transform: translate(-50%, 10px); display: flex; align-items: center; gap: 0.85em; padding: 0.62em 1.25em 0.62em 1.05em; border-radius: 99px; background: rgba(11, 10, 13, 0.46); border: 1px solid var(--line); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); opacity: 0; transition: opacity 0.9s var(--ease), transform 0.9s var(--ease); font-size: clamp(11px, 1.35vw, 16px); }
.listen.is-on { opacity: 1; transform: translate(-50%, 0); }
.listen-text { letter-spacing: 0.26em; text-transform: uppercase; font-size: 0.78em; font-weight: 400; color: var(--ivory); white-space: nowrap; }
.listen-wave { display: inline-flex; align-items: center; gap: 3px; height: 1.3em; }
.listen-wave i { width: 2px; height: 30%; border-radius: 2px; background: var(--brass-hi); animation: wave 1.5s ease-in-out infinite; }
.listen-wave i:nth-child(2) { animation-delay: 0.15s; }
.listen-wave i:nth-child(3) { animation-delay: 0.3s; }
.listen-wave i:nth-child(4) { animation-delay: 0.45s; }
.listen-wave i:nth-child(5) { animation-delay: 0.6s; }
.listen.is-hearing .listen-wave i { animation-duration: 0.45s; background: var(--ivory); }
@keyframes wave { 0%, 100% { height: 22%; opacity: 0.55; } 50% { height: 100%; opacity: 1; } }

/* ───────── pantallas ───────── */
.screen { position: absolute; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center; opacity: 0; visibility: hidden; transition: opacity 0.9s var(--ease), visibility 0s linear 0.9s; padding: max(5vh, env(safe-area-inset-top)) max(6vw, env(safe-area-inset-right)) max(5vh, env(safe-area-inset-bottom)) max(6vw, env(safe-area-inset-left)); }
.screen.is-on { opacity: 1; visibility: visible; transition: opacity 0.9s var(--ease), visibility 0s; }
.veil { position: absolute; inset: 0; background:
    radial-gradient(ellipse 70% 60% at 50% 38%, rgba(201, 166, 107, 0.10), transparent 70%),
    radial-gradient(ellipse at 50% 120%, rgba(120, 70, 60, 0.16), transparent 60%),
    linear-gradient(180deg, #0d0b10 0%, #0b0a0d 60%, #070608 100%); }
.veil::after { content: ""; position: absolute; inset: 0; opacity: 0.07; mix-blend-mode: overlay; 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.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>"); }

.panel { position: relative; z-index: 1; max-width: 46rem; }
.panel-center { text-align: center; display: flex; flex-direction: column; align-items: center; }
.eyebrow { font-size: clamp(10px, 1.1vw, 13px); letter-spacing: 0.42em; text-transform: uppercase; color: var(--brass); font-weight: 400; margin-bottom: 1.6em; }
.title { font-family: var(--serif); font-weight: 400; font-size: clamp(40px, 8.2vw, 104px); line-height: 0.95; letter-spacing: -0.01em; color: var(--ivory); }
.title em { font-style: italic; font-weight: 400; color: var(--brass-hi); }
.title-sm { font-size: clamp(30px, 5.4vw, 64px); line-height: 1.02; }
.lead { font-family: var(--serif); font-size: clamp(17px, 2.1vw, 25px); line-height: 1.4; color: var(--ivory-dim); margin-top: 1.5em; max-width: 30em; }
.fine { font-size: clamp(11px, 1.05vw, 13px); letter-spacing: 0.06em; color: var(--mute); margin-top: 1.7em; max-width: 34em; line-height: 1.6; }

.btn { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 0.8em; margin-top: 2.4em; padding: 1.05em 1.9em; border-radius: 99px; font-size: clamp(11px, 1.15vw, 14px); letter-spacing: 0.24em; text-transform: uppercase; font-weight: 500; transition: transform 0.5s var(--ease), background 0.4s, color 0.4s, border-color 0.4s, box-shadow 0.5s; }
.btn-primary { background: var(--ivory); color: var(--ink); box-shadow: 0 0 0 1px rgba(239, 230, 213, 0.2), 0 18px 50px -18px rgba(227, 198, 144, 0.55); }
.btn-primary::before { content: ""; position: absolute; inset: -7px; border-radius: 99px; border: 1px solid rgba(201, 166, 107, 0.45); animation: halo 2.8s ease-out infinite; }
@keyframes halo { 0% { opacity: 0.9; transform: scale(0.97); } 100% { opacity: 0; transform: scale(1.09); } }
.btn-ghost { border: 1px solid var(--line); color: var(--ivory); }
.btn .ico { width: 1.5em; height: 1.5em; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; }
@media (hover: hover) {
  .btn-primary:hover { background: var(--brass-hi); transform: translateY(-2px); }
  .btn-ghost:hover { border-color: var(--brass); color: var(--brass-hi); }
  .link:hover { color: var(--brass-hi); }
}
.btn:active { transform: scale(0.98); }
.btn:focus-visible, .link:focus-visible { outline: 2px solid var(--brass-hi); outline-offset: 4px; }
.link { display: inline-block; margin-top: 2em; font-size: clamp(11px, 1.05vw, 13px); letter-spacing: 0.22em; text-transform: uppercase; color: var(--ivory-dim); text-decoration: none; border-bottom: 1px solid var(--line); padding-bottom: 0.35em; transition: color 0.3s; }
.row { display: flex; flex-wrap: wrap; gap: 0 1em; }
.panel-center .row { justify-content: center; }
.btn[hidden] { display: none; }
a.btn { text-decoration: none; }

/* ───────── la app no deja salir (Instagram…): instrucciones a mano en primer plano ───────── */
.corner-hint { position: absolute; z-index: 2; top: max(10px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); display: none; flex-direction: column; align-items: center; gap: 2px; color: var(--brass-hi); font-size: 22px; line-height: 1; }
.corner-hint svg { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
#scrUnsupported.is-stuck.has-corner .corner-hint { display: flex; animation: corner 1.3s ease-in-out infinite; }
@keyframes corner { 0%, 100% { transform: translateY(6px); opacity: 0.75; } 50% { transform: translateY(0); opacity: 1; } }
#scrUnsupported.is-stuck .eyebrow, #scrUnsupported.is-stuck .fine { display: none; }
#scrUnsupported.is-stuck .title-sm { font-size: clamp(24px, 4.2vw, 48px); }
#scrUnsupported.is-stuck .lead { margin-top: 0.9em; }
#scrUnsupported.is-stuck .steps { margin-top: 1.1em; animation: rise 0.9s var(--ease) both; }
#scrUnsupported.is-stuck .steps li { font-size: clamp(15px, 1.5vw, 18px); color: var(--ivory); }
#scrUnsupported.is-stuck .steps b { color: var(--brass-hi); font-weight: 500; }
#scrUnsupported.is-stuck .btn { margin-top: 1.6em; }

.suits { position: absolute; left: 0; right: 0; bottom: max(4vh, env(safe-area-inset-bottom)); display: flex; justify-content: center; gap: 2.2em; font-size: clamp(11px, 1.2vw, 15px); color: var(--mute); opacity: 0.6; }
.suits span:nth-child(2), .suits span:nth-child(3) { color: #8a5148; }

/* entrada escalonada de la pantalla de inicio */
#scrStart.is-on .panel > * { animation: rise 1.5s var(--ease) both; }
#scrStart.is-on .panel > *:nth-child(2) { animation-delay: 0.12s; }
#scrStart.is-on .panel > *:nth-child(3) { animation-delay: 0.26s; }
#scrStart.is-on .panel > *:nth-child(4) { animation-delay: 0.4s; }
#scrStart.is-on .panel > *:nth-child(5) { animation-delay: 0.54s; }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }

/* ───────── carga ───────── */
.loader { perspective: 600px; margin-bottom: 2em; }
.loader-card { width: 46px; height: 64px; border-radius: 6px; border: 1px solid var(--brass); display: flex; align-items: center; justify-content: center; color: var(--brass-hi); font-size: 20px; animation: flip 2.2s var(--ease) infinite; background: linear-gradient(160deg, rgba(201, 166, 107, 0.16), transparent 60%); }
@keyframes flip { 0% { transform: rotateY(0); } 45%, 55% { transform: rotateY(180deg); } 100% { transform: rotateY(360deg); } }
.loading-text { font-family: var(--serif); font-style: italic; font-size: clamp(20px, 2.4vw, 30px); color: var(--ivory); }
.dots i { animation: blink 1.4s infinite both; font-style: normal; }
.dots i:nth-child(2) { animation-delay: 0.2s; }
.dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.15; } 40% { opacity: 1; } }
.progress { width: min(240px, 50vw); height: 1px; background: var(--line); margin-top: 1.8em; overflow: hidden; }
#progressBar { height: 100%; width: 0; background: var(--brass-hi); transition: width 0.4s linear; }

/* ───────── denegado ───────── */
.steps { list-style: none; counter-reset: s; margin-top: 1.6em; text-align: left; max-width: 30em; }
.steps:empty { display: none; }
.steps li { counter-increment: s; position: relative; padding: 0.55em 0 0.55em 2.6em; font-size: clamp(13px, 1.25vw, 15px); line-height: 1.55; color: var(--ivory-dim); border-top: 1px solid var(--line); }
.steps li:last-child { border-bottom: 1px solid var(--line); }
.steps li::before { content: counter(s); position: absolute; left: 0.3em; top: 0.5em; font-family: var(--serif); font-style: italic; font-size: 1.3em; color: var(--brass); }
.steps b { color: var(--ivory); font-weight: 400; }

/* ───────── final ───────── */
.screen-end { justify-content: flex-end; align-items: center; transition-duration: 1.6s; }
.end-shade { position: absolute; inset: 0; background: linear-gradient(90deg, rgba(8, 7, 10, 0) 30%, rgba(8, 7, 10, 0.74) 58%, rgba(8, 7, 10, 0.93) 100%); }
.panel-end { text-align: left; width: min(42%, 30rem); margin-right: 2vw; }
.title-end { font-size: clamp(34px, 5.6vw, 76px); }
.panel-end .lead { font-style: italic; }
.panel-end .btn { margin-top: 2em; padding: 0.95em 1.5em; }
.panel-end .btn-primary::before { display: none; }
.screen-end.is-on .panel-end > * { animation: rise 1.6s var(--ease) both; animation-delay: 0.5s; }
.screen-end.is-on .panel-end > *:nth-child(2) { animation-delay: 0.62s; }
.screen-end.is-on .panel-end > *:nth-child(3) { animation-delay: 0.76s; }
.screen-end.is-on .panel-end > *:nth-child(4) { animation-delay: 0.9s; }
.screen-end.is-on .panel-end > *:nth-child(5) { animation-delay: 1.04s; }

/* ───────── teléfono en vertical (no se pide girar: el vídeo se ve entero, con franjas) ───────── */
@media (orientation: portrait) and (pointer: coarse) {
  .panel-end { width: 100%; margin: 0; text-align: center; display: flex; flex-direction: column; align-items: center; }
  .screen-end { align-items: flex-end; }
  /* el vídeo es la franja central (alto = 56,25vw): la sombra solo funde su cuarto inferior con el negro de debajo */
  .end-shade { background: linear-gradient(180deg, rgba(8, 7, 10, 0) calc(50% + 12vw), rgba(8, 7, 10, 0.92) calc(50% + 28.125vw), rgba(8, 7, 10, 0.97) 100%); }
  .row { justify-content: center; }
  /* panel final compacto, para que quepa debajo del vídeo también en teléfonos bajos */
  .panel-end .eyebrow { margin-bottom: 0.9em; }
  .panel-end .lead { margin-top: 0.8em; }
  .panel-end .btn { margin-top: 1.4em; }
  .panel-end .link { margin-top: 1.4em; }
  .screen-end { padding-bottom: max(3vh, env(safe-area-inset-bottom)); }
}
@media (max-height: 430px) {
  .title { font-size: clamp(34px, 12vh, 64px); }
  .title-sm { font-size: clamp(24px, 9vh, 40px); }
  .lead { margin-top: 0.8em; font-size: clamp(15px, 4.6vh, 20px); }
  .btn { margin-top: 1.2em; padding: 0.85em 1.5em; }
  .eyebrow { margin-bottom: 0.9em; }
  .fine { margin-top: 1em; }
  .suits { display: none; }
  .steps li { padding-top: 0.35em; padding-bottom: 0.35em; }
  .steps li::before { top: 0.3em; }
  .panel-end .btn { margin-top: 1em; }
  .link { margin-top: 1.1em; }
}

/* ───────── debug ───────── */
.debug-only { display: none; }
body.is-debug .debug-only { display: inline-block; }
.debug { position: absolute; z-index: 40; top: 8px; left: 8px; width: min(330px, 46vw); max-height: calc(100% - 16px); overflow: auto; background: rgba(10, 10, 12, 0.86); border: 1px solid var(--line); border-radius: 8px; padding: 10px; font: 11px/1.45 ui-monospace, Menlo, monospace; color: #d8d2c4; }
.debug h4 { font: 500 10px/1 var(--sans); letter-spacing: 0.2em; text-transform: uppercase; color: var(--brass); margin: 8px 0 5px; }
.debug .kv b { color: #fff; font-weight: 500; }
.debug .grid { display: grid; grid-template-columns: repeat(13, 1fr); gap: 2px; }
.debug button { background: #1d1b21; border: 1px solid #34303a; border-radius: 3px; padding: 3px 0; font: 10px ui-monospace, Menlo, monospace; color: #e9e2d2; }
.debug button.red { color: #ff8f84; }
.debug .rowb { display: flex; flex-wrap: wrap; gap: 3px; }
.debug .rowb button { padding: 3px 6px; }
.debug pre { white-space: pre-wrap; word-break: break-word; max-height: 110px; overflow: auto; color: #a9a294; }

/* en vertical el vídeo (16:9) es una franja en el centro: el rótulo va justo debajo, no al pie de la pantalla */
@media (orientation: portrait) {
  .intro-title { bottom: auto; top: calc(50% + 28.125vw + 16px); left: max(5vw, env(safe-area-inset-left)); font-size: 13px; }
}

/* en vertical el panel ocupa la franja negra de encima del vídeo */
@media (orientation: portrait) { .debug { width: min(360px, calc(100% - 16px)); max-height: 34%; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01s !important; animation-iteration-count: 1 !important; }
}
