/* ════════════════════════════════════════════ */
/* COVER ANIMATION — Travelling Tunnel Canvas  */
/* ════════════════════════════════════════════ */

/* ── PHASE 1: ENTER GATE ── */
#enter-gate {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: #0a0a0b;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  overflow: hidden;
  box-sizing: border-box;
  padding: 0 1rem;
}

/* Subtle noise grain overlay */
#enter-gate::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  background-size: 256px 256px;
  pointer-events: none;
  z-index: 1;
}

/* Faint radial overhead light */
#enter-gate::after {
  content: '';
  position: absolute;
  top: 35%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(600px, 100vw);
  height: min(600px, 100vw);
  background: radial-gradient(ellipse, rgba(140, 140, 155, 0.04) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.gate-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2.5rem;
  max-width: 520px;
  padding: 2rem;
  text-align: center;
  opacity: 0;
  animation: gate-surface 2.4s ease-out 0.3s forwards;
}

@keyframes gate-surface {
  0%   { opacity: 0; transform: translateY(8px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* Thin horizontal rule */
.gate-rule {
  width: 40px;
  height: 1px;
  background: rgba(138, 138, 142, 0.6);
  opacity: 0;
  animation: gate-fade-rule 1.8s ease-out 1.6s forwards;
}
@keyframes gate-fade-rule {
  to { opacity: 0.6; }
}

/* Message paragraph */
.gate-message {
  font-size: 1.05rem;
  line-height: 1.85;
  color: rgba(138, 138, 142, 1);
  letter-spacing: 0.015em;
  font-weight: 400;
}
.gate-message em {
  font-style: italic;
}
.gate-message em.gate-red   { color: #e05a45; }
.gate-message em.gate-green { color: #87c240; }
.gate-message em.gate-cyan  { color: #39dede; }

/* Enter button */
.enter-btn {
  background: none;
  cursor: pointer;
  border: 1px solid rgba(90, 90, 94, 1);
  color: rgba(138, 138, 142, 1);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.85rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 0.75rem 2.6rem;
  transition: all 0.6s ease;
  opacity: 0;
  animation: gate-fade-btn 1.2s ease-out 2.8s forwards;
}
@keyframes gate-fade-btn {
  to { opacity: 1; }
}
.enter-btn:hover {
  color: rgba(194, 194, 198, 1);
  border-color: rgba(194, 194, 198, 1);
  box-shadow: 0 0 30px rgba(180, 180, 190, 0.05);
  letter-spacing: 0.24em;
}
.enter-btn:active {
  transform: scale(0.97);
}

/* Resume mode — yellow primary button */
.enter-btn.resume-mode {
  border-color: rgba(255, 176, 0, 0.6);
  color: rgba(255, 176, 0, 0.85);
}
.enter-btn.resume-mode:hover {
  border-color: rgba(255, 176, 0, 0.9);
  color: rgba(255, 200, 50, 1);
  box-shadow: 0 0 30px rgba(255, 176, 0, 0.08);
}
.resume-chapter-line {
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  margin-top: 0.3rem;
  opacity: 0.6;
}

/* Restart button — secondary, subdued */
.restart-btn {
  margin-top: 1.4rem;
  font-size: 0.72rem !important;
  opacity: 0;
  animation: gate-fade-btn 1s ease-out 3.6s forwards;
}

/* Exit: blur + fade up */
.gate-content.leaving {
  animation: gate-descend 1.4s ease-in forwards;
}
@keyframes gate-descend {
  0%   { opacity: 1; filter: blur(0); }
  100% { opacity: 0; filter: blur(4px); transform: translateY(-12px); }
}

/* ── PHASE 2: Tunnel canvas ── */
#metro-intro {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: #050507;
  overflow: hidden;
  opacity: 0;
  transition: opacity 3s ease;
}
#metro-intro.visible {
  opacity: 1;
}
#metro-intro.dismissed {
  pointer-events: none;
}
#metro-intro canvas {
  width: 100%;
  height: 100%;
}

/* Make cover-screen transparent so canvas shows through */
.cover-screen {
  background: rgba(5, 5, 7, 0.3) !important;
  opacity: 0;
  transition: opacity 3s ease;
  pointer-events: none;
}
.cover-screen.visible {
  opacity: 1;
  pointer-events: auto;
}

/* Cover content layout */
.cover-content {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Title starts hidden, revealed after loader */
.cover-title {
  transition: color 0.05s step-end, text-shadow 0.05s step-end;
  opacity: 0;
}

/* Title glow sync with dramatic light flicker */
.cover-title.glow-flicker {
  color: rgba(235, 230, 220, 0.95);
  text-shadow:
    0 0 20px rgba(255, 200, 100, 0.5),
    0 0 50px rgba(255, 185, 80, 0.3),
    0 0 100px rgba(255, 176, 0, 0.2),
    0 0 150px rgba(255, 176, 0, 0.1);
}

/* ── Loader bar ── */
.loader-wrap {
  width: 286px;
  position: absolute;
  bottom: calc(100% + 60px);
  left: 50%;
  transform: translateX(-50%);
}
.loader-track {
  width: 100%;
  height: 1px;
  background: rgba(212, 208, 203, 0.15);
  position: relative;
  overflow: hidden;
}
.loader-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 0%;
  background: rgba(212, 208, 203, 0.5);
  transition: width 0.3s linear;
}
.loader-text {
  color: rgba(212, 208, 203, 0.3);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-align: center;
  margin-top: 12px;
  font-family: 'IBM Plex Mono', monospace;
}

/* ── BEGIN button — hidden until loader finishes ── */
.cover-begin {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.8s ease, border-color 0.3s ease, color 0.3s ease;
}
.cover-begin.ready {
  opacity: 1;
  pointer-events: auto;
}

/* Story content hidden until BEGIN, then fades in */
body.cover-active {
  background: #050507 !important;
}
body.cover-active > .chapter,
body.cover-active > .depth-gauge,
body.cover-active > .blur-vignette,
body.cover-active > .dark-vignette {
  opacity: 0;
}
body.cover-revealed > .chapter,
body.cover-revealed > .depth-gauge,
body.cover-revealed > .blur-vignette,
body.cover-revealed > .dark-vignette {
  transition: opacity 8s ease;
  opacity: 1;
}

/* ── Mobile adjustments ── */
@media (max-width: 600px) {
  .gate-content {
    max-width: 100%;
    padding: 1.5rem 0.5rem;
    box-sizing: border-box;
  }
  .gate-message {
    font-size: 0.85rem;
    line-height: 1.7;
  }
  .gate-message br {
    display: none;
  }
  .enter-btn {
    font-size: 0.75rem;
    padding: 0.6rem 1.8rem;
  }
}
