/* ============================================================
   CRT PACK v11 — "You are looking at a Nostromo monitor"
   Curvature + vignette + refresh band + chromatic aberration
   + signal tear + glitch hovers + static page transition.
   Pure CSS/JS overlay layers. Content untouched.
   Layers: fog 0 / content 10 / header 100 / scanlines 9999
           refresh band 9996 / vignette 9997 / static 10005
   ============================================================ */

/* ---------- 1. TUBE VIGNETTE + CURVED GLASS ---------- */
.crt-vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9997;
  /* darkened corners = curved glass illusion */
  background:
    radial-gradient(ellipse 120% 120% at 50% 50%,
      transparent 60%,
      rgba(0, 0, 0, 0.18) 82%,
      rgba(0, 0, 0, 0.55) 100%);
}

/* rounded tube corners */
.crt-vignette::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 18px;
  box-shadow: 0 0 0 24px #000;
}

/* faint glass reflection sweep, static */
.crt-vignette::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(112deg,
    transparent 0%,
    rgba(180, 255, 180, 0.015) 28%,
    rgba(180, 255, 180, 0.035) 33%,
    transparent 40%);
}

/* ---------- 2. REFRESH BAND (slow sweep down the tube) ---------- */
.crt-band {
  position: fixed;
  left: 0;
  width: 100%;
  height: 22vh;
  top: -25vh;
  pointer-events: none;
  z-index: 9996;
  background: linear-gradient(to bottom,
    transparent 0%,
    rgba(51, 255, 0, 0.022) 35%,
    rgba(51, 255, 0, 0.045) 50%,
    rgba(51, 255, 0, 0.022) 65%,
    transparent 100%);
  animation: crt-band-sweep 11s linear infinite;
}

@keyframes crt-band-sweep {
  0%   { transform: translateY(0); }
  100% { transform: translateY(560vh); }
}

/* ---------- 3. CHROMATIC ABERRATION on big type ---------- */
.hero-title {
  text-shadow:
    -1.5px 0 rgba(255, 40, 70, 0.35),
     1.5px 0 rgba(60, 140, 255, 0.30),
    var(--glow-green-intense),
    0 0 30px rgba(64, 224, 112, 0.3);
}

.section-title {
  text-shadow:
    -1px 0 rgba(255, 40, 70, 0.25),
     1px 0 rgba(60, 140, 255, 0.22),
    var(--glow-green);
}

/* ---------- 4. SIGNAL TEAR (random horizontal glitch, JS-driven) ---------- */
.crt-tear {
  position: fixed;
  left: 0;
  width: 100%;
  height: 3px;
  top: 40%;
  pointer-events: none;
  z-index: 9998;
  background: rgba(51, 255, 0, 0.25);
  box-shadow: 0 0 12px rgba(51, 255, 0, 0.4);
  opacity: 0;
}

body.signal-tear .crt-tear {
  opacity: 1;
}

body.signal-tear .content-wrapper {
  transform: translateX(3px) skewX(0.3deg);
  filter: hue-rotate(8deg);
}

/* ---------- 5. GLITCH HOVER on cards ---------- */
@keyframes card-glitch {
  0%   { transform: translate(0, 0);      clip-path: inset(0 0 0 0); filter: none; }
  25%  { transform: translate(-3px, 1px); clip-path: inset(12% 0 60% 0); filter: drop-shadow(2px 0 0 rgba(255,40,70,.6)) drop-shadow(-2px 0 0 rgba(60,140,255,.5)); }
  50%  { transform: translate(3px, -1px); clip-path: inset(55% 0 8% 0);  filter: drop-shadow(-2px 0 0 rgba(255,40,70,.6)) drop-shadow(2px 0 0 rgba(60,140,255,.5)); }
  75%  { transform: translate(-2px, 0);   clip-path: inset(30% 0 35% 0); filter: none; }
  100% { transform: translate(0, 0);      clip-path: inset(0 0 0 0);     filter: none; }
}

.mission-card:hover .mc-title,
.founded-vessel:hover .fv-title,
.file-card:hover .file-card-header {
  animation: card-glitch 0.26s steps(2) 1;
}

/* ---------- 6. DECRYPT/SCRAMBLE reveal (JS adds .decrypting-fx) ---------- */
.decrypting-fx {
  color: var(--green) !important;
  text-shadow:
    -1.5px 0 rgba(255, 40, 70, 0.5),
     1.5px 0 rgba(60, 140, 255, 0.45),
    var(--glow-green) !important;
}

/* ---------- 7. STATIC PAGE TRANSITION ---------- */
#static-overlay {
  position: fixed;
  inset: 0;
  z-index: 10005;
  pointer-events: none;
  opacity: 0;
  background:
    repeating-linear-gradient(0deg,
      rgba(51, 255, 0, 0.08) 0px, rgba(51, 255, 0, 0.08) 1px,
      rgba(0, 0, 0, 0.9) 1px, rgba(0, 0, 0, 0.9) 2px,
      rgba(20, 120, 20, 0.15) 2px, rgba(20, 120, 20, 0.15) 3px,
      rgba(0, 0, 0, 0.85) 3px, rgba(0, 0, 0, 0.85) 5px),
    #000;
}

#static-overlay.active {
  opacity: 1;
  animation: static-jitter 0.22s steps(4) infinite;
}

@keyframes static-jitter {
  0%   { background-position: 0 0,    0 0; }
  25%  { background-position: 0 -7px, 0 0; }
  50%  { background-position: 0 4px,  0 0; }
  75%  { background-position: 0 -2px, 0 0; }
  100% { background-position: 0 9px,  0 0; }
}

/* ---------- 8. STARFIELD canvas ---------- */
#star-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  opacity: 0.55;
}

/* ---------- Side-by-side videos that stack on mobile ---------- */
.video-duo {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-md);
}

/* ---------- Mobile: keep it light ---------- */
@media (max-width: 768px) {
  .crt-band { display: none; }
  .crt-vignette::before { border-radius: 10px; box-shadow: 0 0 0 14px #000; }
  .video-duo { grid-template-columns: 1fr; }
}

/* ---------- 9. MU/TH/UR TERMINAL (easter egg, ` / ~) ---------- */
#muthur-terminal {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 44vh;
  min-height: 280px;
  background: rgba(0, 8, 0, 0.96);
  border-top: 1px solid var(--green);
  box-shadow: 0 -6px 30px rgba(51, 255, 0, 0.15);
  z-index: 10004;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  transform: translateY(105%);
  transition: transform 0.25s ease-out;
}

#muthur-terminal.open {
  transform: translateY(0);
}

#muthur-terminal .mt-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  border-bottom: 1px solid var(--green-dim);
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--green-mid);
}

#muthur-terminal .mt-close {
  background: none;
  border: none;
  color: var(--green-mid);
  font-family: var(--font);
  font-size: 11px;
  cursor: pointer;
  letter-spacing: 1px;
}

#muthur-terminal .mt-close:hover {
  color: var(--green);
  text-shadow: var(--glow-green);
}

#muthur-terminal .mt-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--green);
}

#muthur-terminal .mt-line { white-space: pre-wrap; }
#muthur-terminal .mt-line.term-echo  { color: var(--green-mid); }
#muthur-terminal .mt-line.term-red   { color: var(--red);   text-shadow: var(--glow-red); }
#muthur-terminal .mt-line.term-amber { color: var(--amber); text-shadow: var(--glow-amber); }

#muthur-terminal .mt-inputline {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--green-dim);
}

#muthur-terminal .mt-prompt {
  font-size: 12px;
  color: var(--green);
  text-shadow: var(--glow-green);
  white-space: nowrap;
}

#muthur-terminal .mt-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--green);
  font-family: var(--font);
  font-size: 12px;
  caret-color: var(--green);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ---------- Reduced motion: kill all the theatre ---------- */
@media (prefers-reduced-motion: reduce) {
  .crt-band,
  .crt-tear,
  #static-overlay { display: none !important; }
  .mission-card:hover .mc-title,
  .founded-vessel:hover .fv-title,
  .file-card:hover .file-card-header { animation: none; }
}

/* ============================================================
   SPECTACLE PACK v12 — bridge hero, motion tracker, arcade,
   cockpit LEDs, ship events, VHS bursts
   ============================================================ */

/* ---------- BRIDGE HERO (nav display) ---------- */
.bridge-hero {
  position: relative;
  min-height: 66vh;
}

.bridge-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  opacity: 0.9;
}

/* "click the ships" affordance */
.bridge-hint {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  z-index: 1;
  font-size: 9px;
  letter-spacing: 2px;
  white-space: nowrap;
  color: rgba(255, 191, 0, 0.55);
  pointer-events: none;
  animation: hint-pulse 3s ease-in-out infinite;
}

.bridge-hint.locked {
  color: var(--amber);
  text-shadow: var(--glow-amber);
  animation: none;
}

@keyframes hint-pulse {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}

@media (max-width: 900px) {
  .bridge-hint { display: none; }
}

/* keep the title legible over the planet */
.bridge-hero .hero-title,
.bridge-hero .hero-subtitle {
  text-shadow: 0 0 4px #000, 0 0 12px #000, var(--glow-green);
}

/* lift the real hero content above the canvas — but leave the
   absolutely-positioned overlays (HUD corners, hint) alone */
.bridge-hero > *:not(.bridge-canvas):not(.bridge-hud):not(.bridge-hint) {
  position: relative;
  z-index: 1;
}

.bridge-hud {
  position: absolute;
  font-size: 9px;
  letter-spacing: 1.5px;
  line-height: 1.8;
  color: var(--green-mid);
  text-shadow: 0 0 4px rgba(51, 255, 0, 0.35);
  pointer-events: none;
  z-index: 1;
}

.bridge-hud-tl { top: 18px; left: 24px; text-align: left; }
.bridge-hud-tr { top: 18px; right: 24px; text-align: right; }
.bridge-hud-bl { bottom: 18px; left: 24px; text-align: left; }
.bridge-hud-br { bottom: 18px; right: 24px; text-align: right; }

@media (max-width: 900px) {
  .bridge-hud { display: none; }
}

/* ---------- MOTION TRACKER ---------- */
#motion-tracker {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 8000;
  background: rgba(2, 6, 2, 0.92);
  border: 1px solid var(--green-dim);
  box-shadow: 0 0 18px rgba(51, 255, 0, 0.12), inset 0 0 24px rgba(0, 0, 0, 0.6);
  font-family: var(--font);
}

#motion-tracker .mtk-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 8px;
  border-bottom: 1px solid var(--green-dim);
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--green-mid);
}

#motion-tracker .mtk-close {
  background: none;
  border: none;
  color: var(--green-mid);
  font-family: var(--font);
  font-size: 9px;
  cursor: pointer;
  padding: 2px;
}

#motion-tracker .mtk-close:hover { color: var(--green); }

#motion-tracker canvas { display: block; }

#motion-tracker .mtk-readout {
  padding: 3px 8px 5px;
  border-top: 1px solid var(--green-dim);
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--green);
  text-align: center;
}

#motion-tracker .mtk-readout.mtk-close-range {
  color: var(--amber);
  text-shadow: var(--glow-amber);
  animation: mtk-blink 0.5s step-end infinite;
}

@keyframes mtk-blink {
  50% { opacity: 0.35; }
}

/* ---------- ARCADE OVERLAY ---------- */
#arcade-overlay {
  position: fixed;
  inset: 0;
  z-index: 10010;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.96);
}

#arcade-overlay.open { display: flex; }

.arc-frame {
  border: 1px solid var(--green-dim);
  background: #020402;
  box-shadow: 0 0 40px rgba(51, 255, 0, 0.15), inset 0 0 60px rgba(0, 0, 0, 0.7);
  padding: 0 0 10px;
  max-width: 96vw;
}

.arc-marquee {
  padding: 8px 14px;
  border-bottom: 1px solid var(--green-dim);
  font-size: 10px;
  letter-spacing: 3px;
  color: var(--amber);
  text-shadow: var(--glow-amber);
  text-align: center;
}

.arc-frame canvas {
  display: block;
  max-width: 96vw;
  max-height: 74vh;
  image-rendering: pixelated;
}

.arc-legend {
  padding: 8px 10px 0;
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--green-mid);
  text-align: center;
}

.arc-touch {
  display: none;
  justify-content: center;
  gap: 14px;
  padding-top: 10px;
}

.arc-touch button {
  font-family: var(--font);
  font-size: 14px;
  color: var(--green);
  background: transparent;
  border: 1px solid var(--green-dim);
  padding: 10px 26px;
  cursor: pointer;
}

@media (pointer: coarse) {
  .arc-touch { display: flex; }
}

/* ---------- COCKPIT LED STRIP ---------- */
.led-strip {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin-bottom: var(--sp-md);
  font-size: 8px;
  letter-spacing: 2px;
  color: var(--green-dim);
}

.led-unit {
  display: flex;
  align-items: center;
  gap: 5px;
}

.led {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px rgba(51, 255, 0, 0.8);
  animation: led-blink 3s step-end infinite;
}

.led-amber {
  background: var(--amber);
  box-shadow: 0 0 6px rgba(255, 191, 0, 0.8);
}

@keyframes led-blink {
  0%, 82%, 100% { opacity: 1; }
  84%, 92% { opacity: 0.15; }
  94% { opacity: 1; }
  96% { opacity: 0.3; }
}

/* ---------- SHIP EVENT TOAST ---------- */
#ship-event {
  position: fixed;
  left: 22px;
  bottom: 22px;
  z-index: 8001;
  max-width: 320px;
  padding: 9px 14px;
  background: rgba(2, 6, 2, 0.94);
  border: 1px solid var(--green-dim);
  border-left: 3px solid var(--green);
  font-family: var(--font);
  font-size: 10px;
  letter-spacing: 1.5px;
  color: var(--green);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.4s ease, transform 0.4s ease;
  pointer-events: none;
}

#ship-event.show {
  opacity: 1;
  transform: translateY(0);
}

#ship-event.amber {
  border-left-color: var(--amber);
  color: var(--amber);
  text-shadow: 0 0 6px rgba(255, 191, 0, 0.4);
}

/* ---------- VHS INTERFERENCE BURST ---------- */
#vhs-burst {
  position: fixed;
  inset: 0;
  z-index: 10004;
  pointer-events: none;
  display: none;
}

#vhs-burst.active {
  display: block;
  background:
    repeating-linear-gradient(0deg,
      rgba(180, 255, 180, 0.09) 0px,
      transparent 2px,
      rgba(0, 0, 0, 0.35) 3px,
      transparent 6px,
      rgba(180, 255, 180, 0.05) 9px,
      transparent 13px);
  animation: vhs-track 0.09s steps(2) infinite;
}

#vhs-burst.active::before {
  content: '';
  position: absolute;
  left: 0;
  width: 100%;
  height: 26%;
  top: 30%;
  background: rgba(200, 255, 200, 0.06);
  border-top: 2px solid rgba(51, 255, 0, 0.25);
  border-bottom: 1px solid rgba(255, 0, 60, 0.18);
  filter: blur(1px);
  animation: vhs-band 0.14s steps(3) infinite;
}

@keyframes vhs-track {
  0% { background-position: 0 0; }
  100% { background-position: 0 9px; }
}

@keyframes vhs-band {
  0% { top: 26%; height: 22%; }
  50% { top: 38%; height: 30%; }
  100% { top: 31%; height: 18%; }
}

body.vhs-shake .content-wrapper {
  animation: vhs-jolt 0.12s steps(2) infinite;
}

@keyframes vhs-jolt {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-3px, 1px) skewX(0.4deg); }
  50% { transform: translate(2px, -2px); }
  75% { transform: translate(-1px, 2px) skewX(-0.3deg); }
  100% { transform: translate(0, 0); }
}
