/* ============================================================
   NOSTALGIA RADIO — overnight service
   Night-drive dashboard: VFD green-amber glow, chrome trim,
   sodium-vapor streetlights. Fonts: Michroma (badges) + VT323 (VFD).
   ============================================================ */

:root {
  --accent: #f0b95e;
  --vfd-bg: #050703;
  --dash-1: #16171d;
  --dash-2: #0c0d12;
  --label: #8f93a3;
}

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

html, body { height: 100%; }

body {
  background: #03040c;
  font-family: 'Michroma', sans-serif;
  color: #d8dbe8;
  overflow: hidden;
  user-select: none;
}

#scene { position: fixed; inset: 0; z-index: 0; display: block; }

/* windshield vignette */
#vignette {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background:
    radial-gradient(130% 100% at 50% 38%, transparent 55%, rgba(0,0,5,0.55) 88%, rgba(0,0,5,0.85) 100%),
    linear-gradient(180deg, rgba(2,3,10,0.5), transparent 18%);
}

/* film grain */
#grain {
  position: fixed; inset: -50%; z-index: 2; pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)' opacity='0.9'/%3E%3C/svg%3E");
  animation: grain-shift 0.9s steps(4) infinite;
}
@keyframes grain-shift {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-2%, 1%); }
  50% { transform: translate(1%, -2%); }
  75% { transform: translate(-1%, 2%); }
  100% { transform: translate(2%, -1%); }
}

/* ---------- brand + credits ---------- */
#brand {
  position: fixed; top: 22px; left: 28px; z-index: 3;
  display: flex; flex-direction: column; gap: 4px;
  letter-spacing: 0.32em; font-size: 12px; color: #cdd2e4;
  text-shadow: 0 0 18px rgba(150,170,255,0.35);
}
#brand .brand-sub {
  font-size: 8px; letter-spacing: 0.42em; color: #6d7288;
}

#credits {
  position: fixed; top: 24px; right: 28px; z-index: 3;
  font-size: 8px; letter-spacing: 0.22em; color: #565b70;
  text-transform: uppercase;
}
#credits a { color: #8b91ac; text-decoration: none; border-bottom: 1px dotted #555; }
#credits a:hover { color: var(--accent); }

/* ---------- start overlay ---------- */
#start-overlay {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(80% 80% at 50% 45%, rgba(4,5,14,0.55), rgba(2,3,9,0.92));
  backdrop-filter: blur(2px);
  transition: opacity 0.9s ease, visibility 0.9s;
}
#start-overlay.hidden { opacity: 0; visibility: hidden; }

.start-card { text-align: center; padding: 20px; }
.start-kicker {
  font-size: 10px; letter-spacing: 0.55em; color: var(--accent);
  margin-bottom: 22px; text-shadow: 0 0 14px var(--accent);
}
.start-card h1 {
  font-size: clamp(42px, 8vw, 84px);
  line-height: 1.02; letter-spacing: 0.12em; color: #eceff9;
  text-shadow: 0 0 40px rgba(160,180,255,0.35), 0 0 90px rgba(120,140,255,0.18);
  margin-bottom: 20px;
}
.start-copy {
  font-family: 'VT323', monospace; font-size: 20px; line-height: 1.5;
  color: #9aa0b8; margin-bottom: 34px;
}
#btn-start {
  font-family: 'Michroma', sans-serif; font-size: 13px; letter-spacing: 0.35em;
  color: #0d0b04; background: linear-gradient(180deg, #ffd98f, #e9a83f);
  border: none; border-radius: 3px; padding: 17px 44px 15px 48px;
  cursor: pointer;
  box-shadow: 0 0 34px rgba(240,185,94,0.45), inset 0 1px 0 rgba(255,255,255,0.6);
  transition: transform 0.15s ease, box-shadow 0.3s ease;
}
#btn-start:hover { transform: translateY(-2px); box-shadow: 0 0 55px rgba(240,185,94,0.7), inset 0 1px 0 rgba(255,255,255,0.6); }
#btn-start:active { transform: translateY(0); }
.start-hint {
  margin-top: 30px; font-family: 'VT323', monospace;
  font-size: 15px; color: #5b6076; letter-spacing: 0.08em;
}
.start-credit {
  margin-top: 14px; font-family: 'VT323', monospace;
  font-size: 15px; color: #4a4f63; letter-spacing: 0.08em;
}
.start-credit a { color: #8b91ac; text-decoration: none; border-bottom: 1px dotted #555; }
.start-credit a:hover { color: var(--accent); }

/* ---------- dashboard ---------- */
#dash {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; flex-direction: column; align-items: center;
  padding: 0 14px;
  pointer-events: none;
}
#head-unit {
  pointer-events: auto;
  width: min(1060px, 100%);
  background: linear-gradient(180deg, var(--dash-1), var(--dash-2) 70%);
  border: 1px solid #2c2e38;
  border-bottom: none;
  border-radius: 14px 14px 0 0;
  box-shadow:
    0 -18px 60px rgba(0,0,0,0.75),
    inset 0 1px 0 rgba(255,255,255,0.07),
    inset 0 0 0 1px rgba(0,0,0,0.4);
  padding: 12px 18px 16px;
  position: relative;
}
#head-unit::before {                 /* chrome pinstripe */
  content: ''; position: absolute; top: 6px; left: 14px; right: 14px; height: 1px;
  background: linear-gradient(90deg, transparent, #767b8b 20%, #a9aec0 50%, #767b8b 80%, transparent);
  opacity: 0.5;
}

/* ---------- collapse handle + mini bar ---------- */
#btn-collapse {
  display: block; width: 100%; height: 26px;
  background: none; border: none; cursor: pointer;
  position: relative; margin-top: -4px;
}
#btn-collapse span {
  position: absolute; left: 50%; top: 11px; transform: translateX(-50%);
  width: 46px; height: 4px; border-radius: 2px;
  background: #3a3d4c;
  transition: background 0.2s, width 0.2s;
}
#btn-collapse:hover span { background: var(--accent); width: 60px; }

#mini-bar {
  display: none;
  align-items: center; gap: 10px;
  padding: 0 6px 12px;
}
#mini-station {
  flex: 1; min-width: 0;
  font-family: 'VT323', monospace; font-size: 19px;
  color: var(--accent); text-shadow: 0 0 8px var(--accent);
  letter-spacing: 0.04em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#mini-bar button {
  padding: 9px 16px 8px;
  font-family: 'Michroma', sans-serif; font-size: 10px; letter-spacing: 0.14em;
  color: #c3c7d6;
  background: linear-gradient(180deg, #23252e, #15161d);
  border: 1px solid #333644; border-radius: 4px;
  cursor: pointer;
}
#mini-bar button:hover { color: var(--accent); border-color: var(--accent); }

#head-unit.collapsed #dial,
#head-unit.collapsed #presets,
#head-unit.collapsed #unit-body { display: none; }
#head-unit.collapsed #mini-bar { display: flex; }

/* ---------- tuning dial ---------- */
#dial {
  position: relative;
  height: 44px; margin: 4px 4px 10px;
  background: linear-gradient(180deg, #08090d, #101219);
  border: 1px solid #262833;
  border-radius: 5px;
  overflow: hidden;
}
.dial-band {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  font-size: 9px; letter-spacing: 0.2em; color: var(--label);
}
.dial-scale {
  position: absolute; left: 44px; right: 16px; top: 5px;
  display: flex; justify-content: space-between;
  font-family: 'VT323', monospace; font-size: 15px; color: #7b8098;
}
.dial-ticks {
  position: absolute; left: 44px; right: 16px; top: 24px; bottom: 7px;
  background:
    repeating-linear-gradient(90deg, #3a3e50 0 1px, transparent 1px 10.5px);
  opacity: 0.8;
}
#needle {
  position: absolute; top: 3px; bottom: 3px; left: 44px;
  width: 2px;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent), 0 0 26px var(--accent);
  transition: left 0.7s cubic-bezier(0.3, 1.2, 0.4, 1);
}

/* ---------- preset strip ---------- */
#presets {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 5px;
  margin: 0 4px 10px;
}
.preset {
  position: relative;
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center;
  gap: 1px; padding: 4px 7px 3px;
  background: linear-gradient(180deg, #1d1f27, #12131a);
  border: 1px solid #2c2e3a; border-radius: 4px;
  cursor: pointer; text-align: left;
  transition: border-color 0.2s, box-shadow 0.2s;
  min-width: 0;
}
.preset b {
  font-family: 'VT323', monospace; font-weight: normal;
  font-size: 14px; color: #9aa0b8; line-height: 1;
}
.preset i {
  font-family: 'Michroma', sans-serif; font-style: normal;
  font-size: 6px; letter-spacing: 0.1em; color: #6c7188; line-height: 1.25;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.preset u {
  position: absolute; top: 3px; right: 4px;
  text-decoration: none;
  font-family: 'Michroma', sans-serif; font-size: 5.5px; letter-spacing: 0.08em;
  color: #565b70; border: 1px solid #3a3d4c; border-radius: 2px; padding: 1px 2px;
}
.preset:hover { border-color: #4a4e60; }
.preset.active {
  border-color: var(--accent);
  box-shadow: 0 0 12px color-mix(in srgb, var(--accent) 45%, transparent), inset 0 0 8px rgba(0,0,0,0.5);
}
.preset.active b, .preset.active i, .preset.active u { color: var(--accent); text-shadow: 0 0 8px var(--accent); }
.preset.active u { border-color: var(--accent); }

/* ---------- unit body: knobs | display | buttons ---------- */
#unit-body {
  display: grid;
  grid-template-columns: 108px 1fr 192px;
  gap: 16px;
  align-items: stretch;
}

#knob-col {
  display: flex; flex-direction: column; gap: 10px;
  justify-content: space-between;
  padding: 4px 0;
}
.round-btn {
  width: 46px; height: 46px; border-radius: 50%;
  font-family: 'Michroma', sans-serif; font-size: 8px; letter-spacing: 0.1em;
  color: #b9bdcd;
  background: radial-gradient(circle at 35% 30%, #3a3d49, #16171d 70%);
  border: 1px solid #3c3f4d;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.15), 0 3px 8px rgba(0,0,0,0.6);
  cursor: pointer;
}
.round-btn:hover { color: var(--accent); border-color: var(--accent); }
body.powered .round-btn { color: var(--accent); box-shadow: inset 0 1px 0 rgba(255,255,255,0.15), 0 0 14px rgba(240,185,94,0.25); }

.slider-group { display: flex; flex-direction: column; gap: 5px; }
.slider-group span { font-size: 7px; letter-spacing: 0.28em; color: var(--label); }

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px; border-radius: 2px;
  background: #262833; outline: none; cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 13px; height: 13px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #4a4e5c, #1b1c23 75%);
  border: 1px solid #565b6d;
  box-shadow: 0 2px 5px rgba(0,0,0,0.7);
}
input[type="range"]::-moz-range-thumb {
  width: 13px; height: 13px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #4a4e5c, #1b1c23 75%);
  border: 1px solid #565b6d;
}

/* ---------- VFD display ---------- */
#display {
  position: relative;
  background: var(--vfd-bg);
  border: 1px solid #1d2029;
  border-radius: 6px;
  padding: 9px 14px 6px;
  overflow: hidden;
  box-shadow: inset 0 0 26px rgba(0,0,0,0.9), inset 0 0 60px rgba(0,20,0,0.25);
  font-family: 'VT323', monospace;
  color: var(--accent);
  text-shadow: 0 0 7px var(--accent);
  display: flex; flex-direction: column;
}
#display::after {                     /* scanlines */
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,0.28) 0 1px, transparent 1px 3px);
}
.vfd-row { display: flex; justify-content: space-between; align-items: center; }
.vfd-row.top { font-size: 17px; opacity: 0.9; }
#vfd-badge {
  font-family: 'Michroma', sans-serif; font-size: 7px; letter-spacing: 0.3em;
  padding: 3px 8px 2px; border: 1px solid currentColor; border-radius: 2px; opacity: 0.75;
}
#vfd-station {
  font-size: clamp(26px, 3.2vw, 34px);
  letter-spacing: 0.06em; line-height: 1.05; margin-top: 2px;
}
#vfd-tagline { font-size: 14px; opacity: 0.55; letter-spacing: 0.1em; margin-bottom: 3px; }

.vfd-title-wrap { overflow: hidden; white-space: nowrap; }
#vfd-title { display: inline-flex; font-size: 19px; opacity: 0.92; }
#vfd-title span { padding-right: 60px; }
#vfd-title.scroll { animation: marquee var(--marquee-dur, 12s) linear infinite; }
@keyframes marquee { from { transform: translateX(0); } to { transform: translateX(-50%); } }

.vfd-row.bottom { margin-top: auto; font-size: 15px; opacity: 0.85; padding-top: 3px; }
#vu { image-rendering: pixelated; }

#seek {
  height: 3px !important; margin-top: 6px;
  background: rgba(255,255,255,0.1);
}
#seek::-webkit-slider-thumb { width: 9px; height: 9px; background: var(--accent); border: none; box-shadow: 0 0 8px var(--accent); }
#seek::-moz-range-thumb { width: 9px; height: 9px; background: var(--accent); border: none; box-shadow: 0 0 8px var(--accent); }

/* ---------- transport + aux buttons ---------- */
#button-col { display: flex; flex-direction: column; gap: 6px; justify-content: center; }

#transport { display: flex; gap: 5px; }
#transport button {
  flex: 1; padding: 11px 0 10px;
  font-family: 'Michroma', sans-serif; font-size: 10px; letter-spacing: 0.14em;
  color: #c3c7d6;
  background: linear-gradient(180deg, #23252e, #15161d);
  border: 1px solid #333644; border-radius: 4px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}
#transport button:hover { color: var(--accent); border-color: var(--accent); }
#btn-random { letter-spacing: 0.3em !important; }

#aux { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
#btn-dash { grid-column: 1 / -1; }
#aux button {
  padding: 9px 0 8px;
  font-family: 'Michroma', sans-serif; font-size: 8px; letter-spacing: 0.18em;
  color: #8d92a6;
  background: linear-gradient(180deg, #1c1e26, #121319);
  border: 1px solid #2c2e3a; border-radius: 4px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, box-shadow 0.2s;
  white-space: nowrap; overflow: hidden;
}
#aux button:hover { color: var(--accent); border-color: var(--accent); }
#aux button.on {
  color: var(--accent); border-color: var(--accent);
  box-shadow: 0 0 10px color-mix(in srgb, var(--accent) 40%, transparent), inset 0 0 6px rgba(0,0,0,0.5);
  text-shadow: 0 0 8px var(--accent);
}

/* ---------- episode browser ---------- */
#browser {
  pointer-events: auto;
  width: min(1060px, 100%);
  margin-bottom: 8px;
  background: linear-gradient(180deg, rgba(13,14,19,0.97), rgba(8,9,13,0.97));
  border: 1px solid #2c2e38;
  border-radius: 10px;
  box-shadow: 0 -10px 50px rgba(0,0,0,0.7);
  overflow: hidden;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
#browser.hidden { opacity: 0; transform: translateY(12px); pointer-events: none; height: 0; margin: 0; border: none; }

#browser-head {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid #23252f;
}
#browser-title {
  font-size: 9px; letter-spacing: 0.3em; color: var(--accent);
  text-shadow: 0 0 10px var(--accent);
  white-space: nowrap;
}
#browser-filter {
  flex: 1;
  font-family: 'VT323', monospace; font-size: 17px;
  color: var(--accent); background: #0a0c10;
  border: 1px solid #262833; border-radius: 3px;
  padding: 4px 10px; outline: none;
}
#browser-filter::placeholder { color: #4c5165; }
#browser-filter:focus { border-color: var(--accent); }
#browser-close {
  font-size: 16px; color: #8d92a6; background: none; border: none; cursor: pointer;
  padding: 0 4px;
}
#browser-close:hover { color: var(--accent); }

#browser-list {
  max-height: 34vh; overflow-y: auto;
  padding: 6px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 3px;
}
#browser-list::-webkit-scrollbar { width: 8px; }
#browser-list::-webkit-scrollbar-thumb { background: #2c2e3a; border-radius: 4px; }
.browser-item {
  font-family: 'VT323', monospace; font-size: 16px; text-align: left;
  color: #9aa0b8; background: none;
  border: 1px solid transparent; border-radius: 3px;
  padding: 3px 9px; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.browser-item:hover { color: var(--accent); border-color: #2f323f; background: rgba(255,255,255,0.02); }
.browser-item.playing {
  color: var(--accent); border-color: var(--accent);
  text-shadow: 0 0 8px var(--accent);
}
.browser-empty {
  grid-column: 1 / -1;
  font-family: 'VT323', monospace; font-size: 17px; color: #565b70;
  padding: 18px; text-align: center; letter-spacing: 0.1em;
}

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  #presets { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 860px) {
  #unit-body { grid-template-columns: 1fr; gap: 10px; }
  #knob-col { flex-direction: row; align-items: center; gap: 14px; }
  .slider-group { flex: 1; }
  #display { min-height: 128px; }
  #brand { left: 16px; top: 14px; }
  #credits { display: none; }
  #dash { padding: 0; }
  #head-unit, #browser { border-radius: 0; }
  #browser { margin-bottom: 0; }
}
@media (max-width: 520px) {
  #presets { grid-template-columns: repeat(2, 1fr); }
  #vfd-station { font-size: 22px; }
  #browser-list { grid-template-columns: 1fr; }
}
