:root {
  --navy-deep: #050914;
  --navy: #0b1330;
  --navy-2: #101c44;
  --ink: #0e2a6e;
  --paper: #fbfbfd;
  --gold: #e7c07a;
  --gold-2: #c99a4a;
  --white: #f5f7ff;
}

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

html, body {
  width: 100%;
  height: 100%;
  background: var(--navy-deep);
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

body {
  overflow: hidden;
  font-family: 'Space Grotesk', 'JetBrains Mono', monospace;
  color: var(--white);
}

#stage {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--navy-deep);
}

/* ---------- video ---------- */

#hero-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  background: var(--navy-deep);
}

#hero-video.is-hidden {
  pointer-events: none;
}

/* ---------- fx canvas (three.js particles) ---------- */

#fx {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
}

#vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background:
    radial-gradient(ellipse at center, rgba(5,9,20,0) 0%, rgba(5,9,20,0.55) 62%, rgba(5,9,20,0.94) 100%),
    linear-gradient(180deg, rgba(5,9,20,0.35) 0%, rgba(5,9,20,0.1) 20%, rgba(5,9,20,0.1) 78%, rgba(5,9,20,0.55) 100%);
}

/* ---------- reveal layer ---------- */

#reveal {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(18px, 3.2vh, 34px);
  padding: clamp(16px, 4vh, 48px) clamp(16px, 4vw, 48px);
  pointer-events: none;
}

.letter-frame {
  position: relative;
  height: min(78dvh, 900px);
  aspect-ratio: 1253 / 1771;
  max-width: 92vw;
  opacity: 0;
  will-change: transform, opacity;
  filter: drop-shadow(0 30px 60px rgba(0,0,0,0.55)) drop-shadow(0 6px 18px rgba(0,0,0,0.35));
}

.letter-frame::before {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 3px;
  background: linear-gradient(160deg, rgba(231,192,122,0.55), rgba(231,192,122,0) 30%);
  z-index: 0;
}

#letter-img {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 2px;
  background: var(--paper);
  user-select: none;
  -webkit-user-drag: none;
}

/* ---------- CTA ---------- */

#cta {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 16px 30px;
  border-radius: 999px;
  text-decoration: none;
  color: var(--navy-deep);
  background: linear-gradient(135deg, #f3dba6, var(--gold) 45%, var(--gold-2));
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  font-size: clamp(13px, 1.9vw, 16px);
  letter-spacing: 0.02em;
  box-shadow: 0 10px 30px rgba(201, 154, 74, 0.35), 0 2px 8px rgba(0,0,0,0.25);
  opacity: 0;
  will-change: transform, opacity;
  cursor: pointer;
  transition: transform 0.35s cubic-bezier(.2,.8,.2,1), box-shadow 0.35s ease, filter 0.35s ease;
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
}

#cta:hover, #cta:focus-visible {
  transform: translateY(-3px);
  box-shadow: 0 16px 40px rgba(201, 154, 74, 0.5), 0 4px 12px rgba(0,0,0,0.3);
  filter: brightness(1.06);
}

#cta:active { transform: translateY(-1px) scale(0.98); }

.cta-arrow {
  display: inline-block;
  transition: transform 0.3s ease;
}
#cta:hover .cta-arrow { transform: translateX(4px); }

#reveal.is-active {
  pointer-events: auto;
}

/* ---------- sound toggle (only interactive chrome) ---------- */

#sound-toggle {
  position: absolute;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 11px;
  padding: 16px 26px 16px 18px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, #5eeba0, #16a34a);
  color: #062514;
  cursor: pointer;
  opacity: 0;
  transform: scale(0.9);
  box-shadow: 0 10px 28px rgba(22, 163, 74, 0.5), 0 3px 10px rgba(0,0,0,0.3);
  transition: opacity 0.5s ease, transform 0.3s ease, padding 0.3s ease, background 0.3s ease, box-shadow 0.3s ease;
  -webkit-tap-highlight-color: transparent;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: clamp(13px, 1.8vw, 15px);
  letter-spacing: 0.01em;
}

#sound-toggle.is-visible { opacity: 1; transform: scale(1); }
#sound-toggle:hover { transform: scale(1.05); box-shadow: 0 14px 34px rgba(22,163,74,0.65), 0 4px 12px rgba(0,0,0,0.3); }
#sound-toggle:active { transform: scale(0.97); }

#sound-toggle .sound-ring {
  position: absolute;
  inset: -7px;
  border-radius: inherit;
  border: 2px solid rgba(94, 235, 160, 0.6);
  animation: sound-pulse 1.8s ease-out infinite;
  pointer-events: none;
}

@keyframes sound-pulse {
  0%   { transform: scale(1);    opacity: 0.85; }
  100% { transform: scale(1.4);  opacity: 0; }
}

.sound-label { white-space: nowrap; }

/* once sound is confirmed on: collapse to a quiet icon-only circle */
#sound-toggle.is-unmuted-state {
  padding: 13px;
  gap: 0;
  background: rgba(5,9,20,0.4);
  border: 1px solid rgba(255,255,255,0.25);
  color: rgba(255,255,255,0.85);
  box-shadow: none;
}
#sound-toggle.is-unmuted-state:hover { background: rgba(5,9,20,0.6); }
#sound-toggle.is-unmuted-state .sound-ring,
#sound-toggle.is-unmuted-state .sound-label { display: none; }

#sound-toggle.is-hidden-phase { opacity: 0 !important; pointer-events: none; }

@media (prefers-reduced-motion: reduce) {
  #sound-toggle .sound-ring { animation: none; }
}

/* ---------- mobile: force a landscape-filled frame (video phase only) ---------- */

@media (orientation: portrait) and (max-width: 926px), (orientation: portrait) and (max-height: 926px) {
  #stage.force-landscape {
    position: fixed;
    top: 50%;
    left: 50%;
    width: 100vh;
    height: 100vw;
    width: 100dvh;
    height: 100dvw;
    transform: translate(-50%, -50%) rotate(90deg);
    transform-origin: center center;
  }
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .letter-frame, #cta, #hero-video { transition-duration: 0.01ms !important; }
}

@media (max-width: 520px) {
  #cta { padding: 14px 24px; }
}
