/* ═══════════════════════════════════════════════════════════════
   GEATER://OS — design system + shell
   palette: void black · #ff2361 signal pink · caution yellow ·
   silver · phosphor green (NVG). Marathon-adjacent, glass panels.
   ═══════════════════════════════════════════════════════════════ */

:root {
  --bg: #05060a;
  --bg-2: #0a0c12;
  --ink: #e8eaf0;
  --dim: #8a8fa0;
  /* text-legible muted grey (~4.9:1 on --bg, WCAG AA); also used for faint
     decorative strokes where the extra visibility is harmless. */
  --faint: #767c8d;
  --pink: #ff2361;
  --yellow: #ffd60a;
  --green: #59ff7d;
  --silver: #c9cdd6;
  --glass: rgba(255, 255, 255, 0.035);
  --glass-brt: rgba(255, 255, 255, 0.07);
  --line: rgba(255, 255, 255, 0.09);
  --line-brt: rgba(255, 255, 255, 0.2);
  --font-d: "Chakra Petch", system-ui, sans-serif;
  --font-m: "IBM Plex Mono", ui-monospace, monospace;
  --rail-w: 92px;
  --top-h: 44px;
  color-scheme: dark;
}

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

/* the `hidden` attribute must always win, even over ID-specificity display rules
   (e.g. #terminal { display:flex }). without this the terminal can't be closed. */
[hidden] { display: none !important; }

/* visible keyboard focus for every interactive control over the dark glass
   theme (WCAG 2.4.7). pointer users don't see it (:focus-visible only). */
:where(a, button, input, select, [tabindex]):focus-visible {
  outline: 2px solid var(--yellow);
  outline-offset: 2px;
  border-radius: 1px;
}

html { scrollbar-color: var(--faint) transparent; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-m);
  font-size: 15px;
  line-height: 1.55;
  overflow: hidden;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--pink); color: #05060a; }

h1, h2, h3, .rail-btn, button { font-family: var(--font-d); }

button { background: none; border: 0; color: inherit; cursor: pointer; font-size: inherit; }
a { color: var(--yellow); text-decoration: none; }

@media (pointer: fine) {
  body.cursor-on, body.cursor-on * { cursor: none !important; }
}

/* ── background layers ─────────────────────────────────────── */
#bg-fx { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; }

#grid-overlay {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse at 50% 40%, black 30%, transparent 78%);
}

/* faint scanlines over everything */
body::after {
  content: ""; position: fixed; inset: 0; z-index: 90; pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,0.16) 0 1px, transparent 1px 3px);
  opacity: 0.5;
}

/* ── custom cursor ──────────────────────────────────────────── */
#cursor { position: fixed; inset: 0; z-index: 200; pointer-events: none; display: none; }
body.cursor-on #cursor { display: block; }
#cursor .c-dot {
  position: absolute; width: 5px; height: 5px; border-radius: 50%;
  background: var(--pink); transform: translate(-50%, -50%);
}
#cursor .c-ring {
  position: absolute; width: 30px; height: 30px; transform: translate(-50%, -50%) rotate(0deg);
  border-radius: 50%;
  border: 1px solid rgba(255, 35, 97, 0.55);
  transition: width .18s ease, height .18s ease, border-color .18s ease, border-radius .18s ease;
}
#cursor.is-hot .c-ring {
  width: 40px; height: 40px; border-radius: 6px;
  border-color: var(--yellow);
}
#cursor .c-ring::before, #cursor .c-ring::after {
  content: ""; position: absolute; background: currentColor; color: rgba(255,35,97,.7);
  left: 50%; top: 50%;
}
#cursor.is-hot .c-ring::before { width: 9px; height: 1px; transform: translate(-50%, -50%); color: var(--yellow); }
#cursor.is-hot .c-ring::after { width: 1px; height: 9px; transform: translate(-50%, -50%); color: var(--yellow); }

/* ── NVG mode ───────────────────────────────────────────────── */
#nvg-overlay { position: fixed; inset: 0; z-index: 95; pointer-events: none; opacity: 0; transition: opacity .35s; }
body[data-nvg="on"] #nvg-overlay { opacity: 1; }
#nvg-overlay .nvg-noise {
  position: absolute; inset: -100px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
  mix-blend-mode: overlay; animation: nvg-jitter .28s steps(3) infinite;
}
#nvg-overlay .nvg-vignette {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 50%, transparent 46%, rgba(0, 8, 0, 0.92) 100%);
}
@keyframes nvg-jitter { 0% {transform: translate(0,0);} 50% {transform: translate(-30px,20px);} 100% {transform: translate(24px,-16px);} }
body[data-nvg="on"] { filter: sepia(1) hue-rotate(65deg) saturate(2.4) brightness(1.05) contrast(1.1); }
body[data-nvg="on"] #tb-nvg { color: var(--green); border-color: var(--green); text-shadow: 0 0 8px var(--green); }

/* ── boot ───────────────────────────────────────────────────── */
#boot {
  position: fixed; inset: 0; z-index: 150; background: #030408;
  display: grid; place-items: center; transition: opacity .6s, visibility .6s;
}
/* pointer-events:none the instant is-done lands so the fading overlay stops
   swallowing clicks (and can't be double-clicked) during the 0.6s fade. */
#boot.is-done { opacity: 0; visibility: hidden; pointer-events: none; }
.boot-inner { width: min(680px, 92vw); position: relative; }
#boot-log {
  font: 400 12.5px/1.7 var(--font-m); color: var(--dim);
  min-height: 240px; white-space: pre-wrap;
}
#boot-log .ok { color: var(--green); }
#boot-log .warn { color: var(--yellow); }
#boot-log .pink { color: var(--pink); }
#boot-bar { height: 3px; background: rgba(255,255,255,.08); margin-top: 14px; overflow: hidden; }
#boot-bar i { display: block; height: 100%; width: 0%; background: var(--pink); transition: width .2s; box-shadow: 0 0 12px var(--pink); }
#boot-title { text-align: center; margin-top: 34px; }
#boot-title.hidden, #boot-enter.hidden, .boot-hint.hidden { display: none; }
.boot-glyph { width: 54px; margin: 0 auto 10px; color: var(--pink); animation: glyph-pulse 2.2s ease-in-out infinite; }
@keyframes glyph-pulse { 50% { filter: drop-shadow(0 0 14px var(--pink)); } }
#boot-title h1 { font-size: clamp(2rem, 7vw, 3.4rem); letter-spacing: .14em; font-weight: 600; }
.boot-sub { color: var(--dim); letter-spacing: .34em; font-size: .68rem; margin-top: 8px; }
#boot-enter {
  margin-top: 30px; padding: 13px 34px;
  font: 600 .95rem/1 var(--font-d); letter-spacing: .18em;
  color: var(--yellow); border: 1px solid var(--yellow);
  background: rgba(255, 214, 10, 0.06);
  transition: background .2s, color .2s, box-shadow .2s;
  animation: enter-throb 1.6s ease-in-out infinite;
}
#boot-enter:hover, #boot-enter:focus-visible { background: var(--yellow); color: #05060a; box-shadow: 0 0 34px rgba(255,214,10,.45); }
@keyframes enter-throb { 50% { box-shadow: 0 0 22px rgba(255, 214, 10, 0.28); } }
.boot-hint { margin-top: 14px; color: var(--faint); font-size: .68rem; letter-spacing: .12em; }
#boot-skip {
  position: absolute; right: 0; bottom: -54px; color: var(--faint);
  font: 500 .72rem/1 var(--font-d); letter-spacing: .22em; padding: 8px 10px;
}
#boot-skip:hover { color: var(--ink); }

/* ── glitch headline ────────────────────────────────────────── */
.glitch { position: relative; display: inline-block; }
.glitch::before, .glitch::after {
  content: attr(data-text); position: absolute; inset: 0; opacity: 0;
  pointer-events: none;
}
.glitch.is-glitching::before { opacity: .85; color: var(--pink); transform: translate(-3px, 1px); clip-path: inset(12% 0 58% 0); animation: gl-a .32s steps(4) both; }
.glitch.is-glitching::after { opacity: .85; color: #34e6ff; transform: translate(3px, -2px); clip-path: inset(60% 0 8% 0); animation: gl-b .32s steps(4) both; }
@keyframes gl-a { 0% { clip-path: inset(8% 0 66% 0); } 50% { clip-path: inset(46% 0 22% 0); } 100% { clip-path: inset(80% 0 4% 0); } }
@keyframes gl-b { 0% { clip-path: inset(70% 0 8% 0); } 50% { clip-path: inset(20% 0 56% 0); } 100% { clip-path: inset(4% 0 82% 0); } }

/* ── top bar ────────────────────────────────────────────────── */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--top-h); z-index: 80;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px 0 18px;
  background: linear-gradient(rgba(5,6,10,.92), rgba(5,6,10,.75));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
  opacity: 0; transform: translateY(-100%); transition: opacity .5s .1s, transform .5s .1s;
}
body.is-live #topbar { opacity: 1; transform: none; }
.tb-left, .tb-right { display: flex; align-items: center; gap: 14px; }
.tb-brand { font: 600 .85rem/1 var(--font-d); letter-spacing: .16em; }
.tb-brand b { color: var(--pink); }
.tb-ver { color: var(--faint); font-size: .64rem; letter-spacing: .1em; }
#tb-clock { color: var(--dim); font-size: .74rem; letter-spacing: .12em; min-width: 74px; text-align: right; }
#tb-signal { display: inline-flex; gap: 2px; align-items: flex-end; height: 12px; }
#tb-signal i { width: 3px; background: var(--green); animation: sig 2.4s infinite; }
#tb-signal i:nth-child(1) { height: 4px; } #tb-signal i:nth-child(2) { height: 7px; animation-delay: .3s; }
#tb-signal i:nth-child(3) { height: 9px; animation-delay: .6s; } #tb-signal i:nth-child(4) { height: 12px; animation-delay: .9s; }
@keyframes sig { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
.tb-btn {
  display: inline-flex; align-items: center; gap: 6px;
  font: 500 .7rem/1 var(--font-d); letter-spacing: .12em;
  color: var(--dim); border: 1px solid var(--line); padding: 6px 9px;
  transition: color .2s, border-color .2s;
}
.tb-btn:hover { color: var(--ink); border-color: var(--line-brt); }
.tb-btn svg { width: 15px; height: 15px; }
.tb-btn[aria-pressed="false"] .snd-wave { display: none; }
#tb-trophies { color: var(--silver); }
#tb-trophies.all-done { color: var(--yellow); border-color: var(--yellow); }

/* ── nav rail ───────────────────────────────────────────────── */
#rail {
  position: fixed; left: 0; top: var(--top-h); bottom: 0; width: var(--rail-w); z-index: 70;
  display: flex; flex-direction: column; justify-content: center; gap: 4px;
  padding: 12px 0;
  border-right: 1px solid var(--line);
  background: linear-gradient(90deg, rgba(5,6,10,.9), rgba(5,6,10,.6));
  backdrop-filter: blur(8px);
  opacity: 0; transform: translateX(-100%); transition: opacity .5s .2s, transform .5s .2s;
}
body.is-live #rail { opacity: 1; transform: none; }
.rail-btn {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 11px 4px; color: var(--dim);
  transition: color .18s, background .18s;
}
.rail-btn .rb-key {
  position: absolute; top: 6px; right: 9px; font-size: .55rem; color: var(--faint);
}
.rail-btn .rb-glyph { font-size: 1.05rem; line-height: 1; }
.rail-btn .rb-label { font-size: .56rem; letter-spacing: .14em; font-weight: 600; }
.rail-btn:hover { color: var(--ink); background: var(--glass); }
.rail-btn.is-active { color: var(--pink); }
.rail-btn.is-active::before {
  content: ""; position: absolute; left: 0; top: 14%; bottom: 14%; width: 2px;
  background: var(--pink); box-shadow: 0 0 10px var(--pink);
}
.rail-btn.is-visited::after {
  content: ""; position: absolute; top: 8px; left: 10px; width: 4px; height: 4px;
  border-radius: 50%; background: var(--green);
}

/* ── stage & modules ────────────────────────────────────────── */
#stage {
  position: fixed; top: var(--top-h); left: var(--rail-w); right: 0; bottom: 0; z-index: 10;
  opacity: 0; transition: opacity .5s .25s;
}
body.is-live #stage { opacity: 1; }
.module {
  position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden;
  padding: 34px clamp(18px, 4vw, 54px) 70px;
  display: none; outline: none;
}
.module.is-active { display: block; animation: mod-in .45s cubic-bezier(.2,.9,.25,1) both; }
@keyframes mod-in { from { opacity: 0; transform: translateY(14px); } }

.mod-head {
  display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap;
  margin-bottom: 26px; padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.mod-head h2 {
  font-size: clamp(1.5rem, 3.4vw, 2.2rem); font-weight: 600; letter-spacing: .1em;
}
.mod-head h2::before { content: "// "; color: var(--pink); }
.mod-tag { color: var(--dim); font: 400 .68rem/1.4 var(--font-m); letter-spacing: .14em; }

/* ── generic panel (glass) ──────────────────────────────────── */
.panel {
  position: relative;
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(10px);
  padding: 20px;
}
.panel::before, .panel::after {
  content: ""; position: absolute; width: 14px; height: 14px; pointer-events: none;
  border: 1px solid var(--line-brt);
}
.panel::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.panel::after { bottom: -1px; right: -1px; border-left: 0; border-top: 0; }
.panel h3 { font-size: .82rem; letter-spacing: .18em; color: var(--silver); margin-bottom: 14px; font-weight: 600; }

.btn-y {
  display: inline-block; padding: 10px 20px;
  font: 600 .78rem/1 var(--font-d); letter-spacing: .16em;
  color: var(--yellow); border: 1px solid var(--yellow); background: rgba(255,214,10,.05);
  transition: background .18s, color .18s, box-shadow .18s;
}
.btn-y:hover { background: var(--yellow); color: #05060a; box-shadow: 0 0 22px rgba(255,214,10,.35); }
.btn-ghost {
  display: inline-block; padding: 10px 20px;
  font: 600 .78rem/1 var(--font-d); letter-spacing: .16em;
  color: var(--dim); border: 1px solid var(--line);
  transition: color .18s, border-color .18s;
}
.btn-ghost:hover { color: var(--ink); border-color: var(--line-brt); }

/* ── breach transition ──────────────────────────────────────── */
#breach { position: fixed; inset: 0; z-index: 120; pointer-events: none; }
#breach .breach-a, #breach .breach-b {
  position: absolute; inset: 0; transform: scaleX(0);
}
#breach .breach-a {
  background: repeating-linear-gradient(-45deg, #0a0b10 0 26px, #11131c 26px 30px);
  border-bottom: 2px solid var(--pink);
}
#breach .breach-b { background: var(--pink); }
#breach.is-firing .breach-a { animation: breach-wipe .52s cubic-bezier(.7,0,.2,1) both; }
#breach.is-firing .breach-b { animation: breach-wipe .52s cubic-bezier(.7,0,.2,1) .06s both; opacity: .28; }
@keyframes breach-wipe {
  0% { transform: scaleX(0); transform-origin: left; }
  49% { transform: scaleX(1); transform-origin: left; }
  51% { transform: scaleX(1); transform-origin: right; }
  100% { transform: scaleX(0); transform-origin: right; }
}

/* ── toasts ─────────────────────────────────────────────────── */
#toasts { position: fixed; right: 18px; top: calc(var(--top-h) + 14px); z-index: 130; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
/* the trophy panel shares the top-right corner; move toasts aside while it's open */
body.ach-open #toasts { right: auto; left: 18px; align-items: flex-start; }
.toast {
  display: flex; align-items: center; gap: 12px;
  min-width: 280px; max-width: 360px; padding: 12px 16px;
  background: rgba(10, 12, 18, 0.92); border: 1px solid var(--line-brt);
  border-left: 3px solid var(--pink);
  backdrop-filter: blur(12px);
  animation: toast-in .45s cubic-bezier(.2,1.2,.3,1) both, toast-out .4s ease-in 4.4s both;
  box-shadow: 0 8px 30px rgba(0,0,0,.5);
}
.toast.plat { border-left-color: var(--yellow); box-shadow: 0 0 40px rgba(255,214,10,.25); }
.toast .t-icon { font-size: 1.3rem; }
.toast .t-body b { display: block; font: 600 .8rem/1.3 var(--font-d); letter-spacing: .1em; }
.toast .t-body span { color: var(--dim); font-size: .7rem; }
@keyframes toast-in { from { opacity: 0; transform: translateX(40px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-8px); } }

/* ── achievements panel ─────────────────────────────────────── */
#ach-panel {
  position: fixed; right: 18px; top: calc(var(--top-h) + 12px); z-index: 125;
  width: min(360px, calc(100vw - 36px)); max-height: 70vh; overflow-y: auto;
  background: rgba(8, 9, 14, 0.96);
}
#ach-panel h3 { display: flex; justify-content: space-between; align-items: center; }
#ach-close { color: var(--dim); font-size: .9rem; padding: 2px 6px; }
#ach-close:hover { color: var(--pink); }
#ach-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
#ach-list li { display: flex; gap: 10px; align-items: baseline; font-size: .74rem; color: var(--faint); }
#ach-list li.got { color: var(--ink); }
#ach-list li .a-mark { color: var(--faint); }
#ach-list li.got .a-mark { color: var(--green); }
#ach-list li b { font: 600 .74rem/1.4 var(--font-d); letter-spacing: .08em; }
#ach-list li span { color: var(--dim); }
#ach-list li.locked-secret { font-style: italic; }

/* ── terminal ───────────────────────────────────────────────── */
#terminal {
  position: fixed; z-index: 140; left: 50%; bottom: 24px; transform: translateX(-50%);
  width: min(680px, calc(100vw - 28px)); height: 320px;
  display: flex; flex-direction: column;
  background: rgba(4, 5, 8, 0.96); border: 1px solid var(--line-brt);
  box-shadow: 0 20px 60px rgba(0,0,0,.65), 0 0 0 1px rgba(255,35,97,.12);
  backdrop-filter: blur(14px);
  animation: term-in .25s ease-out both;
}
@keyframes term-in { from { opacity: 0; transform: translateX(-50%) translateY(20px); } }
.term-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; border-bottom: 1px solid var(--line);
  font: 600 .68rem/1 var(--font-d); letter-spacing: .16em; color: var(--dim);
}
#term-close { color: var(--dim); } #term-close:hover { color: var(--pink); }
#term-out { flex: 1; overflow-y: auto; padding: 10px 12px; font-size: .76rem; color: var(--silver); white-space: pre-wrap; }
#term-out .t-cmd { color: var(--yellow); }
#term-out .t-pink { color: var(--pink); }
#term-out .t-green { color: var(--green); }
.term-line { display: flex; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--line); }
.term-ps1 { color: var(--green); font-size: .76rem; }
#term-in { flex: 1; background: none; border: 0; outline: 0; color: var(--ink); font: 400 .76rem/1.4 var(--font-m); caret-color: var(--pink); }

/* ── scrollbars ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--faint); }
::-webkit-scrollbar-thumb:hover { background: var(--dim); }
::-webkit-scrollbar-track { background: transparent; }

/* ── reduced motion ─────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; transition-duration: .001s !important; }
  #nvg-overlay .nvg-noise { animation: none; }
}
