/* STRINGZ ── amber phosphor laboratory terminal */

@font-face {
  font-family: "Departure Mono";
  src: url("fonts/DepartureMono-Regular.woff2") format("woff2");
  font-display: swap;
}

:root {
  --bg: #0b0906;
  --bg-panel: #0e0b07;
  --phos: #ffb454;
  --phos-hi: #ffd9a0;
  --phos-dim: #8a6228;
  --phos-faint: #4a3517;
  --glow: 0 0 6px rgba(255, 180, 84, 0.45);
  --mono: "Departure Mono", ui-monospace, "Cascadia Mono", "JetBrains Mono", Menlo, monospace;
}

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

html, body {
  background: var(--bg);
  overscroll-behavior: none;
}

body {
  font-family: var(--mono);
  color: var(--phos);
  font-size: 14px;
  line-height: 1.45;
  min-height: 100dvh;
  text-shadow: var(--glow);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: none;
}

/* ── CRT dressing ─────────────────────────────── */

#scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(0, 0, 0, 0) 0px,
      rgba(0, 0, 0, 0) 2px,
      rgba(0, 0, 0, 0.22) 3px
    ),
    radial-gradient(ellipse at 50% 40%, rgba(0, 0, 0, 0) 55%, rgba(0, 0, 0, 0.5) 100%);
}

#crt {
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px 14px calc(20px + env(safe-area-inset-bottom));
  transition: opacity 0.35s, filter 0.35s;
}

#crt.off {
  opacity: 0;
  filter: brightness(3) blur(2px);
  pointer-events: none;
}

@media (prefers-reduced-motion: no-preference) {
  #crt.powering {
    animation: crt-on 0.55s steps(6) both;
  }
  @keyframes crt-on {
    0%   { opacity: 0; filter: brightness(4) blur(3px); }
    40%  { opacity: 1; filter: brightness(1.8) blur(1px); }
    70%  { opacity: 0.85; filter: brightness(1.1); }
    100% { opacity: 1; filter: none; }
  }
}

/* ── header ───────────────────────────────────── */

header { padding-bottom: 10px; }

#logo {
  color: var(--phos-hi);
  font-size: clamp(13px, 3.4vw, 18px);
  line-height: 1.1;
  text-shadow: 0 0 10px rgba(255, 180, 84, 0.6);
  user-select: none;
}

#tagline {
  color: var(--phos-dim);
  font-size: 12px;
  margin-top: 6px;
  letter-spacing: 0.04em;
}

#status {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--phos-dim);
}
#status .ok { color: var(--phos); }

/* ── layout ───────────────────────────────────── */

main {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 14px;
  align-items: start;
}

@media (max-width: 820px) {
  main { grid-template-columns: 1fr; }
  #stage { order: -1; }
}

#controls, #stage {
  display: grid;
  gap: 14px;
  min-width: 0;
}

/* ── panels: ASCII box look with responsive borders ── */

.panel {
  position: relative;
  border: 1px solid var(--phos-faint);
  background: var(--bg-panel);
  padding: 16px 10px 10px;
}

.panel::before {
  content: "╢ " attr(data-title) " ╟";
  position: absolute;
  top: -0.72em;
  left: 10px;
  background: var(--bg);
  padding: 0 4px;
  color: var(--phos);
  font-size: 13px;
  letter-spacing: 0.02em;
}

.panel::after {
  content: "+";
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 1ch;
  line-height: 1;
  color: var(--phos-dim);
  background: var(--bg);
}

/* ── sliders ──────────────────────────────────── */

.sliders { display: grid; gap: 2px; }

.slider {
  display: grid;
  grid-template-columns: 9ch 1fr 7ch;
  gap: 1ch;
  align-items: center;
  padding: 5px 2px;
  cursor: ew-resize;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.slider .lbl { color: var(--phos-dim); font-size: 12px; white-space: nowrap; overflow: hidden; }
.slider .bar { white-space: nowrap; overflow: hidden; letter-spacing: 0; }
.slider .val { color: var(--phos-dim); font-size: 12px; text-align: right; white-space: nowrap; }

.slider:hover .lbl, .slider.active .lbl { color: var(--phos); }
.slider.active .bar { color: var(--phos-hi); }
.slider.active .val { color: var(--phos); }

/* ── toggles ──────────────────────────────────── */

.toggle-row {
  display: flex;
  align-items: center;
  gap: 1ch;
  padding: 2px 2px 8px;
  flex-wrap: wrap;
}

.toggle-label { color: var(--phos-dim); font-size: 12px; margin-right: 0.5ch; }

button {
  font: inherit;
  background: none;
  border: none;
  color: var(--phos-dim);
  cursor: pointer;
  text-shadow: inherit;
  padding: 6px 2px;
}

.toggle.on { color: var(--phos-hi); }
.toggle:not(.on):hover { color: var(--phos); }

#note-readout {
  margin-left: auto;
  color: var(--phos-hi);
  font-size: 13px;
  min-width: 12ch;
  text-align: right;
}

/* ── scope ────────────────────────────────────── */

#scope {
  font-size: 13px;
  line-height: 1.05;
  color: var(--phos);
  min-height: 8.6em;
  overflow: hidden;
  user-select: none;
}

#meter {
  display: flex;
  gap: 1ch;
  margin-top: 6px;
  font-size: 12px;
  color: var(--phos-dim);
}
#meter-bar { color: var(--phos); white-space: pre; }
#meter-db { min-width: 8ch; }

/* ── fingerboard ──────────────────────────────── */

#fingerboard {
  display: grid;
  gap: 2px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.fb-row {
  display: grid;
  grid-template-columns: 4ch repeat(13, 1fr);
  height: clamp(44px, 9dvh, 64px);
  align-items: stretch;
}

.fb-open {
  display: flex;
  align-items: center;
  color: var(--phos-dim);
  font-size: 12px;
}

.fb-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--phos-faint);
  font-size: 13px;
  overflow: hidden;
}

/* the string itself: a horizontal line through every cell */
.fb-cell::before {
  content: "";
  position: absolute;
  left: 0; right: 0;
  top: 50%;
  height: 1px;
  background: var(--phos-dim);
  box-shadow: 0 0 4px rgba(255, 180, 84, 0.35);
}

/* position tape-marks (like student instrument tapes) */
.fb-cell.marked::after {
  content: "";
  position: absolute;
  left: 0;
  top: 20%; bottom: 20%;
  width: 1px;
  background: var(--phos-faint);
}

.fb-cell .dot {
  position: relative;
  z-index: 1;
  opacity: 0;
  color: var(--phos-hi);
  text-shadow: 0 0 10px rgba(255, 217, 160, 0.9);
}

.fb-cell.held .dot { opacity: 1; }
.fb-cell.held::before {
  background: var(--phos);
  height: 2px;
  animation: string-buzz 90ms linear infinite;
}

@keyframes string-buzz {
  0%   { transform: translateY(-1px); }
  50%  { transform: translateY(1px); }
  100% { transform: translateY(-1px); }
}

@media (prefers-reduced-motion: reduce) {
  .fb-cell.held::before { animation: none; }
}

#fb-hint {
  margin-top: 8px;
  color: var(--phos-faint);
  font-size: 11px;
}

@media (max-width: 820px) {
  #fb-hint { display: none; }
  .fb-row { grid-template-columns: 3.2ch repeat(13, 1fr); }
}

/* ── footer ───────────────────────────────────── */

footer {
  display: flex;
  justify-content: space-between;
  gap: 2ch;
  flex-wrap: wrap;
  margin-top: 16px;
  color: var(--phos-faint);
  font-size: 11px;
}

footer a { color: var(--phos-dim); text-decoration: none; }
footer a:hover { color: var(--phos); }

/* ── power overlay ────────────────────────────── */

#overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: var(--bg);
}

#overlay.hidden { display: none; }

#overlay-logo {
  color: var(--phos-dim);
  font-size: clamp(14px, 4.4vw, 22px);
  line-height: 1.1;
  animation: idle-pulse 2.6s ease-in-out infinite;
}

#overlay-sub { color: var(--phos-faint); font-size: 13px; }

@keyframes idle-pulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

#power {
  margin-top: 12px;
  padding: 14px 22px;
  font-size: 16px;
  color: var(--phos);
  border: 1px solid var(--phos-faint);
  background: var(--bg-panel);
}

#power:hover, #power:focus-visible {
  color: var(--phos-hi);
  border-color: var(--phos-dim);
  text-shadow: 0 0 12px rgba(255, 217, 160, 0.8);
}

#overlay-err {
  max-width: 40ch;
  color: #ff7a54;
  font-size: 12px;
  text-align: center;
}
