/* =================================================================
   INFINITE GENERATIVE AV — style.css
   Glassmorphism · cyberpunk · mobile-first · fullscreen immersive
   ================================================================= */

:root {
  /* Core ink — pure machine black, no hue bias */
  --void:        #000000;
  --void-2:      #060606;
  --ink:         #ffffff;
  --ink-dim:     #9a9a9a;
  --ink-faint:   #565656;

  /* Monochrome signal — everything is white light at different
     intensities. The UI never uses chromatic accents; only the
     *worlds* carry color. Glow is the only ornament.               */
  --signal:      #ffffff;   /* primary white light */
  --signal-2:    #cfcfcf;   /* soft white          */
  --signal-3:    #ffffff;   /* bright white        */

  /* Glow tokens — neutral white halos at varying strength */
  --glow-soft:   0 0 12px rgba(255,255,255,0.25);
  --glow:        0 0 18px rgba(255,255,255,0.45);
  --glow-hard:   0 0 26px rgba(255,255,255,0.7);

  /* Glass system — neutral, near-colorless */
  --glass-bg:     rgba(255, 255, 255, 0.04);
  --glass-bg-2:   rgba(255, 255, 255, 0.07);
  --glass-stroke: rgba(255, 255, 255, 0.14);
  --glass-hi:     rgba(255, 255, 255, 0.10);
  --blur:         18px;

  --r:   16px;
  --r-s: 11px;

  /* Pixel type system — Silkscreen for display/labels, VT323 for data */
  --mono: "VT323", ui-monospace, Menlo, Consolas, monospace;
  --sans: "Silkscreen", "VT323", system-ui, monospace;
  --pixel-display: "Silkscreen", monospace;
  --pixel-body: "VT323", monospace;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--void);
  color: var(--ink);
  font-family: var(--sans);
  image-rendering: pixelated;            /* crisp pixel-font edges */
  -webkit-font-smoothing: none;
  font-smooth: never;
  text-rendering: geometricPrecision;
  overscroll-behavior: none;
  touch-action: none;            /* we own the swipe gestures */
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ---- Canvases: stacked full-bleed ------------------------------- */
#gl, #scene {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: block;
}
#gl    { z-index: 0; }
#scene { z-index: 1; mix-blend-mode: normal; }

/* ---- CRT scanlines + flicker overlay (above everything) --------- */
#grain {
  position: fixed;
  inset: -50%;
  z-index: 6;
  pointer-events: none;
  opacity: 0.5;
  background-image:
    /* hard scanlines */
    repeating-linear-gradient(0deg,
      rgba(0,0,0,0.55) 0 1px, transparent 1px 3px),
    /* faint vertical aperture grille */
    repeating-linear-gradient(90deg,
      rgba(255,255,255,0.03) 0 1px, transparent 1px 2px);
  mix-blend-mode: multiply;
  animation: grain 0.4s steps(3) infinite, flicker 6s steps(40) infinite;
}
/* CRT vignette + rolling scan bar */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 7;
  pointer-events: none;
  background:
    radial-gradient(130% 130% at 50% 50%, transparent 55%, rgba(0,0,0,0.6) 100%),
    linear-gradient(0deg, transparent, rgba(255,255,255,0.04) 50%, transparent);
  background-size: 100% 100%, 100% 8px;
  mix-blend-mode: screen;
  animation: scanRoll 7s linear infinite;
}
@keyframes grain {
  0%   { transform: translate(0,0); }
  100% { transform: translate(1px, 2px); }
}
@keyframes flicker {
  0%, 96%, 100% { opacity: 0.5; }
  97%  { opacity: 0.38; }
  98%  { opacity: 0.62; }
  99%  { opacity: 0.44; }
}
@keyframes scanRoll {
  0%   { background-position: 0 0,    0 0; }
  100% { background-position: 0 0,    0 100vh; }
}

/* ================================================================= */
/*  GLASS PRIMITIVE                                                   */
/* ================================================================= */
.glass {
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(100%);
  backdrop-filter: blur(var(--blur)) saturate(100%);
  border: 1px solid var(--glass-stroke);
  border-radius: var(--r);
  box-shadow:
    0 8px 40px rgba(0,0,0,0.6),
    0 0 18px rgba(255,255,255,0.05),
    inset 0 1px 0 var(--glass-hi);
}

/* ================================================================= */
/*  START GATE                                                       */
/* ================================================================= */
.gate {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(120% 120% at 50% 0%, rgba(255,255,255,0.06), transparent 55%),
    radial-gradient(120% 120% at 50% 100%, rgba(255,255,255,0.05), transparent 55%),
    var(--void);
  transition: opacity 0.8s ease;
}
.gate.hide { opacity: 0; pointer-events: none; }

.gate-inner {
  max-width: 440px;
  width: 100%;
  padding: 40px 32px;
  text-align: center;
}
.gate-mark {
  font-size: 64px;
  line-height: 1;
  color: var(--ink);
  text-shadow: 0 0 24px rgba(255,255,255,0.6), 0 0 60px rgba(255,255,255,0.25);
  margin-bottom: 14px;
}
.gate-title {
  font-family: var(--pixel-display);
  font-size: clamp(20px, 5.5vw, 30px);
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.3;
  margin-bottom: 16px;
  text-shadow:
    -1px 0 rgba(180,180,180,0.7),
     1px 0 rgba(120,120,120,0.7),
     0 0 14px rgba(255,255,255,0.4);
  animation: rgbShift 4s steps(8) infinite;
}
@keyframes rgbShift {
  0%, 92%, 100% { text-shadow: -1px 0 rgba(180,180,180,0.7), 1px 0 rgba(120,120,120,0.7), 0 0 14px rgba(255,255,255,0.4); }
  93% { text-shadow: -3px 0 rgba(220,220,220,0.9), 3px 0 rgba(90,90,90,0.9), 0 0 18px rgba(255,255,255,0.6); transform: translateX(1px); }
  96% { text-shadow:  2px 0 rgba(200,200,200,0.8), -2px 0 rgba(110,110,110,0.8), 0 0 14px rgba(255,255,255,0.5); transform: translateX(-1px); }
}
.gate-sub {
  font-family: var(--pixel-body);
  color: var(--ink-dim);
  font-size: 19px;
  line-height: 1.4;
  margin-bottom: 28px;
}
.enter-btn {
  font-family: var(--pixel-display);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.02em;
  color: var(--void);
  background: var(--ink);
  border: none;
  border-radius: 999px;
  padding: 15px 34px;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.2), 0 0 30px rgba(255,255,255,0.35);
}
.enter-btn:hover  { transform: translateY(-2px) scale(1.02); box-shadow: 0 0 0 1px rgba(255,255,255,0.3), 0 0 44px rgba(255,255,255,0.55); }
.enter-btn:active { transform: translateY(0)    scale(0.99); }
.enter-btn:focus-visible { outline: 2px solid var(--signal); outline-offset: 4px; }
.gate-fine { font-family: var(--pixel-body); margin-top: 18px; color: var(--ink-faint); font-size: 16px; letter-spacing: 0.04em; }

/* ================================================================= */
/*  HUD                                                              */
/* ================================================================= */
.hud {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;       /* children opt back in */
}
.hud[hidden] { display: none; }
.hud > * { pointer-events: auto; }

/* ---- Top-left readout ------------------------------------------- */
.readout {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0) + 16px);
  left: 16px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: min(64vw, 360px);
}
.readout-index {
  font-family: var(--mono);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
  display: flex;
  align-items: baseline;
  gap: 3px;
}
#worldIndex {
  color: var(--ink);
  text-shadow: -1px 0 rgba(170,170,170,0.6), 1px 0 rgba(110,110,110,0.6), 0 0 10px rgba(255,255,255,0.4);
}
.readout-slash { color: var(--ink-faint); }
.readout-inf   { color: var(--ink-dim); font-size: 24px; }
.readout-meta { min-width: 0; }
.readout-name {
  font-family: var(--pixel-display);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: uppercase;
}
.readout-tags {
  font-family: var(--mono);
  font-size: 15px;
  color: var(--ink-faint);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- Top-right status ------------------------------------------- */
.status {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0) + 16px);
  right: 16px;
  padding: 9px 14px;
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--mono);
  font-size: 16px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ink);
  box-shadow: var(--glow);
  transition: background 0.3s, box-shadow 0.3s, opacity 0.3s;
}
.status-dot.gen { background: var(--ink-dim); box-shadow: 0 0 14px rgba(255,255,255,0.8); animation: pulse 0.7s ease infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }
.status-label { color: var(--ink-dim); }
.status-fps   { color: var(--ink-faint); margin-left: 2px; }

/* ---- Vertical slider rail --------------------------------------- */
.slider-rail {
  position: absolute;
  top: 50%;
  right: 16px;
  transform: translateY(-50%);
  width: 46px;
  height: min(46vh, 360px);
  border-radius: 999px;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}
.slider-rail:active { cursor: grabbing; }
.slider-rail:focus-visible { outline: 2px solid var(--signal); outline-offset: 3px; }
.slider-fill {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 0%;
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.22));
  transition: height 0.12s linear;
}
.slider-knob {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 30px; height: 30px;
  transform: translate(-50%, 50%);
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 0 0 20px rgba(255,255,255,0.7), inset 0 1px 0 rgba(255,255,255,0.6);
  transition: bottom 0.12s linear;
}
.slider-ticks {
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(180deg,
    transparent 0 22px, var(--glass-stroke) 22px 23px);
  opacity: 0.4;
  pointer-events: none;
}

/* ---- Bottom transport ------------------------------------------- */
.transport {
  position: absolute;
  left: 0; right: 0;
  bottom: calc(env(safe-area-inset-bottom, 0) + 18px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 0 16px;
}
.t-btn {
  width: 46px; height: 46px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 18px;
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.15s, color 0.2s, background 0.2s;
}
.t-btn:hover  { transform: translateY(-2px); color: var(--signal); text-shadow: var(--glow); }
.t-btn:active { transform: translateY(0) scale(0.95); }
.t-btn:focus-visible { outline: 2px solid var(--signal); outline-offset: 3px; }
.t-btn.muted .t-ico { color: var(--ink-faint); text-decoration: line-through; }

.hint {
  font-family: var(--mono);
  font-size: 17px;
  letter-spacing: 0.02em;
  color: var(--ink-dim);
  padding: 8px 18px;
  border-radius: 999px;
  white-space: nowrap;
  transition: opacity 0.6s ease;
}
.hint.fade { opacity: 0; }

/* ---- Transition veil -------------------------------------------- */
.veil {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  background:
    radial-gradient(120% 80% at 50% 50%, transparent 30%, rgba(0,0,0,0.92) 100%);
  transition: opacity 0.45s ease;
}
.veil.show { opacity: 1; }

/* ================================================================= */
/*  RESPONSIVE                                                       */
/* ================================================================= */
@media (max-width: 540px) {
  .readout { max-width: 58vw; padding: 10px 13px; gap: 10px; }
  .readout-index { font-size: 24px; }
  .readout-tags { font-size: 13px; }
  .slider-rail { width: 40px; height: min(42vh, 300px); right: 12px; }
  .slider-knob { width: 26px; height: 26px; }
  .hint { font-size: 14px; padding: 7px 13px; }
  .status { font-size: 14px; }
  .t-btn { width: 42px; height: 42px; }
}

@media (min-width: 1024px) {
  .slider-rail { right: 28px; }
  .readout { left: 24px; }
  .status  { right: 28px; }
}

/* ---- Accessibility: reduced motion ------------------------------ */
@media (prefers-reduced-motion: reduce) {
  #grain { animation: none; }
  .status-dot.gen { animation: none; }
  * { transition-duration: 0.001ms !important; }
}
