/* ===== NOX/01 - Topographic Field ===== */
:root {
  --bg: #050608;
  --bg-2: #0a0c10;
  --fg: #e9eef5;
  --dim: #6b7787;
  --line: rgba(180, 200, 220, 0.08);
  --line-2: rgba(180, 200, 220, 0.18);
  --accent: oklch(0.85 0.18 200);
  --accent-soft: color-mix(in oklab, var(--accent) 22%, transparent);
  --accent-dim: color-mix(in oklab, var(--accent) 55%, #6b7787);
  --panel: rgba(8, 10, 14, 0.72);
  --panel-stroke: rgba(180, 200, 220, 0.12);
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.02em;
  overflow: hidden;
  cursor: none;
  -webkit-font-smoothing: antialiased;
  /* Prevent the browser from intercepting touch gestures (pinch-zoom,
     pan-scroll) so the pointer-based input handlers in main.js see every
     tap and drag without delay. */
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

/* Touch shortcut helpers: swap CLICK ↔ TAP and hide keyboard-only hints. */
.hint-touch { display: none; }

#stage {
  position: fixed; inset: 0;
  width: 100vw; height: 100vh;
  display: block;
  z-index: 0;
}

/* Overlays */
#grain {
  pointer-events: none;
  position: fixed; inset: 0;
  z-index: 1;
  background-image: url("grain.svg");
  mix-blend-mode: overlay;
  opacity: 0.35;
}
body.no-grain #grain { display: none; }

#vignette {
  pointer-events: none;
  position: fixed; inset: 0;
  z-index: 2;
  background:
    radial-gradient(ellipse at center, transparent 50%, rgba(0,0,0,0.55) 100%),
    linear-gradient(transparent 0, transparent calc(100% - 1px), rgba(255,255,255,0.04) 100%);
}

body.scanlines::after {
  content: "";
  pointer-events: none;
  position: fixed; inset: 0;
  z-index: 3;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255,255,255,0.02) 0,
    rgba(255,255,255,0.02) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: overlay;
}

/* Crosshair */
#crosshair {
  position: fixed;
  left: 50vw; top: 50vh;
  z-index: 20;
  pointer-events: none;
  transform: translate(-50%, -50%);
  color: var(--accent);
  mix-blend-mode: screen;
  filter: drop-shadow(0 0 4px var(--accent-soft));
}
.ch-svg {
  display: block;
  overflow: visible;
}

/* Panels */
.panel {
  position: fixed;
  z-index: 10;
  background: var(--panel);
  border: 1px solid var(--panel-stroke);
  backdrop-filter: blur(10px) saturate(140%);
  color: var(--fg);
}
.panel-head {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--panel-stroke);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.panel-head .spacer { flex: 1; }
.panel-body { padding: 10px; }
.dim { color: var(--dim); }
.mono-sm { font-size: 10px; }

.dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--dim);
  box-shadow: 0 0 0 0 var(--dim);
}
.dot.live {
  background: var(--accent);
  animation: pulse 1.6s ease-out infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 var(--accent-soft); }
  100% { box-shadow: 0 0 0 10px transparent; }
}

/* Brand */
#brand {
  position: fixed;
  top: 18px; left: 18px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 13px;
  background: var(--panel);
  border: 1px solid var(--panel-stroke);
  backdrop-filter: blur(10px) saturate(140%);
  color: var(--fg);
  pointer-events: none;
}
#brand .logo { display: flex; gap: 10px; align-items: center; color: var(--accent); }
#brand .logo-text { color: var(--fg); }
#brand .logo-name { font-weight: 700; letter-spacing: 0.22em; font-size: 12px; }
#brand .logo-sub { font-size: 9px; margin-top: 3px; letter-spacing: 0.22em; }

/* Telemetry top-right */
#telemetry {
  top: 16px; right: 16px;
  width: 240px;
}
.tele-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 8px;
  border-bottom: 1px solid var(--panel-stroke);
}
.tele-cell {
  padding: 5px 6px;
  border: 1px solid var(--panel-stroke);
  background: rgba(255,255,255,0.015);
}
.tele-label {
  font-size: 8px;
  color: var(--dim);
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.tele-val {
  font-size: 16px;
  font-weight: 600;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  margin-top: 2px;
}
.tele-val-sm { font-size: 9px; color: var(--fg); font-weight: 400; }
.spark { display: block; margin-top: 3px; width: 100%; height: 18px; }
.tele-bar {
  margin-top: 6px;
  height: 4px;
  background: rgba(255,255,255,0.05);
  position: relative;
}
.tele-bar > div {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 0%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
}
.tele-strip {
  padding: 6px 8px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px 10px;
  font-size: 9px;
}
.tele-strip > div { font-variant-numeric: tabular-nums; }

/* Mini footer — bottom-right, copyright + privacy link */
#footer-mini {
  position: fixed;
  right: 16px; bottom: 20px;
  z-index: 10;
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px 12px;
  background: var(--panel);
  border: 1px solid var(--panel-stroke);
  backdrop-filter: blur(10px);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--dim);
}
#footer-mini .sep { color: var(--dim); opacity: 0.5; }
#footer-mini a {
  color: var(--fg);
  text-decoration: underline;
  text-decoration-color: var(--fg);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  pointer-events: auto;
  cursor: none;
  transition: color 160ms ease, text-decoration-color 160ms ease;
}
#footer-mini a:hover { color: var(--accent); text-decoration-color: var(--accent); }
#footer-mini a:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; }

/* Hint strip */
#hint {
  position: fixed;
  left: 50%; bottom: 20px;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 8px 14px;
  background: var(--panel);
  border: 1px solid var(--panel-stroke);
  backdrop-filter: blur(10px);
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--fg);
}
#hint .sep { color: var(--dim); }

/* Anchor dots — small markers that ride the terrain, with a soft expanding ring */
.anchor {
  position: fixed;
  width: 5px; height: 5px;
  margin: -2.5px 0 0 -2.5px;
  z-index: 9;
  pointer-events: none;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.85;
  box-shadow: 0 0 6px var(--accent-soft);
  mix-blend-mode: screen;
}
.anchor::before,
.anchor::after {
  content: '';
  position: absolute;
  left: 50%; top: 50%;
  width: 5px; height: 5px;
  margin: -2.5px 0 0 -2.5px;
  border: 1px solid var(--accent);
  border-radius: 50%;
  opacity: 0;
  animation: anchor-ring 1.8s ease-out infinite;
}
.anchor::after { animation-delay: 0.9s; }
@keyframes anchor-ring {
  0%   { transform: scale(1);   opacity: 0.55; }
  100% { transform: scale(7);   opacity: 0; }
}

/* (removed) Controls bottom-left */
#controls {
  display: none;
}
#controls .panel-body {
  overflow-y: auto;
  padding: 0;
}
#controls.collapsed .panel-body { display: none; }
#controls .panel-body::-webkit-scrollbar { width: 6px; }
#controls .panel-body::-webkit-scrollbar-thumb { background: var(--panel-stroke); }

.ctl-section { padding: 10px; border-bottom: 1px solid var(--panel-stroke); }
.ctl-section:last-child { border-bottom: none; }
.ctl-section-h {
  font-size: 9px;
  color: var(--dim);
  letter-spacing: 0.22em;
  margin-bottom: 8px;
}
.ctl-row {
  display: grid;
  grid-template-columns: 90px 1fr 52px;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  font-size: 10px;
}
.ctl-row label {
  color: var(--fg);
  letter-spacing: 0.04em;
}
.ctl-row input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  height: 14px;
  cursor: pointer;
}
.ctl-row input[type="range"]::-webkit-slider-runnable-track {
  height: 2px;
  background: linear-gradient(to right, var(--accent) var(--p,0%), rgba(255,255,255,0.08) var(--p,0%));
}
.ctl-row input[type="range"]::-moz-range-track {
  height: 2px;
  background: rgba(255,255,255,0.08);
}
.ctl-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 8px; height: 12px;
  background: var(--accent);
  margin-top: -5px;
  box-shadow: 0 0 6px var(--accent);
  border-radius: 1px;
}
.ctl-row input[type="range"]::-moz-range-thumb {
  width: 8px; height: 12px;
  background: var(--accent);
  border: none;
  box-shadow: 0 0 6px var(--accent);
  border-radius: 1px;
}
.ctl-row .ctl-val {
  text-align: right;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  font-size: 10px;
}
.ctl-toggle-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 8px;
}
.toggle {
  font: inherit;
  font-size: 9px;
  letter-spacing: 0.18em;
  color: var(--dim);
  background: transparent;
  border: 1px solid var(--panel-stroke);
  padding: 6px 8px;
  cursor: pointer;
  transition: 0.12s;
}
.toggle.on {
  color: var(--bg);
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 10px var(--accent-soft);
}
.toggle:hover { color: var(--fg); border-color: var(--line-2); }
.toggle.on:hover { color: var(--bg); }

.iconbtn {
  font: inherit;
  font-size: 9px;
  color: var(--dim);
  letter-spacing: 0.12em;
  background: transparent;
  border: 1px solid var(--panel-stroke);
  padding: 3px 6px;
  cursor: pointer;
}
.iconbtn:hover { color: var(--accent); border-color: var(--accent); }

/* Presets bottom-right */
#presets {
  right: 16px; bottom: 16px;
  width: 320px;
}
.preset-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 10px;
}
.preset {
  text-align: left;
  font: inherit;
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--fg);
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--panel-stroke);
  padding: 7px 8px;
  cursor: pointer;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.preset:hover { border-color: var(--accent-dim); }
.preset.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent-soft); }
.preset .p-name { font-weight: 600; }
.preset .p-desc { color: var(--dim); font-size: 9px; }
.preset .p-swatch {
  position: absolute;
  right: 6px; top: 6px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
}

.action-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; margin-bottom: 6px; }
.action-row:last-child { grid-template-columns: 1fr 1fr; margin-bottom: 0; }
.action {
  font: inherit;
  font-size: 10px;
  color: var(--fg);
  background: transparent;
  border: 1px solid var(--panel-stroke);
  padding: 7px 6px;
  cursor: pointer;
  letter-spacing: 0.08em;
}
.action:hover { border-color: var(--accent); color: var(--accent); }
.action.accent { color: var(--accent); border-color: var(--accent-dim); }
.action.accent:hover { background: var(--accent-soft); }
.action.recording { color: #ff5b6e; border-color: #ff5b6e; animation: rec-blink 1s steps(2, end) infinite; }
@keyframes rec-blink { 50% { opacity: 0.4; } }

/* Accent rail */
#accent-rail {
  position: fixed;
  left: 16px; top: 50%;
  transform: translateY(-50%);
  width: 44px;
  z-index: 10;
}
#accent-rail .panel-head {
  flex-direction: column;
  gap: 4px;
  padding: 8px 4px;
  writing-mode: vertical-rl;
  text-orientation: mixed;
}
#accent-rail .panel-head .spacer { display: none; }
.accent-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 0;
  align-items: center;
}
.swatch {
  width: 22px; height: 22px;
  border: 1px solid var(--panel-stroke);
  cursor: pointer;
  position: relative;
  transition: 0.15s;
}
.swatch:hover { transform: scale(1.1); }
.swatch.active { border-color: #fff; box-shadow: 0 0 0 1px #fff inset, 0 0 8px var(--accent); }

/* Toasts */
#toasts {
  position: fixed;
  left: 50%; bottom: 24px;
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}
.toast {
  background: var(--panel);
  border: 1px solid var(--accent);
  color: var(--fg);
  padding: 8px 14px;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  backdrop-filter: blur(6px);
  animation: toast-in 0.25s ease-out;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.toast.fade { opacity: 0; transform: translateY(-8px); transition: 0.4s; }

/* Konami */
#konami-overlay {
  position: fixed; inset: 0;
  z-index: 40;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s;
  background: radial-gradient(ellipse at center, transparent 0%, transparent 50%, rgba(255, 0, 80, 0.08) 100%);
}
#konami-overlay.on { opacity: 1; }
#konami-overlay .kn-text {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.32em;
  color: var(--accent);
  text-shadow: 0 0 24px var(--accent);
  animation: kn-flick 1.4s steps(8, end) infinite;
}
@keyframes kn-flick {
  0%, 100% { opacity: 1; }
  92% { opacity: 0.4; }
}

/* Responsive bail */
@media (max-width: 880px) {
  #telemetry, #presets { width: 280px; }
  #controls { width: 280px; }
  #brand .brand-meta { display: none; }
}

/* Phone-class viewports — slim down the brand badge so it doesn't dominate. */
@media (max-width: 600px) {
  #brand {
    top: 10px; left: 10px;
    padding: 6px 10px;
    gap: 8px;
  }
  #brand .logo { gap: 8px; }
  #brand .logo svg { width: 18px; height: 18px; }
  #brand .logo-name { font-size: 10px; letter-spacing: 0.18em; }
  #brand .logo-sub { font-size: 8px; margin-top: 2px; letter-spacing: 0.18em; }

  /* Telemetry has no use on mobile (no keyboard shortcuts to time, no FPS
     spelunking) and competes for scarce edge space with the brand. Hide it. */
  #telemetry { display: none; }

  #hint {
    bottom: 60px;
    padding: 7px 12px;
    gap: 10px;
    font-size: 9px;
    letter-spacing: 0.14em;
    max-width: calc(100vw - 24px);
    flex-wrap: wrap;
    justify-content: center;
    text-align: center;
  }

  #footer-mini {
    right: 50%; bottom: 14px;
    transform: translateX(50%);
    padding: 6px 10px;
    font-size: 9px;
    letter-spacing: 0.14em;
  }
}

/* Mobile gesture panel — hidden by default, revealed on touch devices below.
   Sits at the bottom-center above the mini footer and mirrors the
   telemetry panel's chrome so it reads as part of the same console. */
#mobile-instructions {
  display: none;
  position: fixed;
  left: 50%;
  bottom: 60px;
  transform: translateX(-50%);
  z-index: 10;
  width: min(260px, calc(100vw - 24px));
}
#mobile-instructions .mi-list {
  list-style: none;
  margin: 0;
  padding: 4px 0;
}
#mobile-instructions .mi-list li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border-top: 1px solid var(--panel-stroke);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
#mobile-instructions .mi-list li:first-child { border-top: 0; }
#mobile-instructions .mi-key {
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}
#mobile-instructions .mi-val {
  color: var(--fg);
  font-weight: 600;
}

/* Touch / coarse-pointer devices — there's no hovering cursor to track,
   so hide the crosshair, restore the system cursor, swap the desktop
   hint strip for the structured mobile gesture panel, and let main.js
   handle the tap-count gestures. */
@media (hover: none) and (pointer: coarse) {
  html, body { cursor: auto; }
  a#brand { cursor: pointer; }
  #footer-mini a { cursor: pointer; }
  #crosshair { display: none; }
  #telemetry { display: none; }
  #hint { display: none; }
  #mobile-instructions { display: block; }
}
