:root {
  --bg: #0b0e1a;
  --bg-raised: #12162b;
  --hairline: rgba(238, 241, 251, 0.12);
  --text-primary: #eef1fb;
  --text-secondary: #9aa3c4;
  --amber: #e8a33d;
  --amber-dim: #7a5a29;
  --signal: #6fcf97;
  --font-display: "Fraunces", serif;
  --font-mono: "Space Mono", monospace;
  /* ambient light, retuned per hour and weather below */
  --haze: rgba(232, 163, 61, 0.16);
  --haze-2: rgba(232, 163, 61, 0.06);
  /* where the needle rests, (91.3 - 88) / 20 */
  --tune: 16.5%;
}

/* ---- mood tint ----
   body[data-daypart] sets the base color and the top glow,
   body[data-mood] sets the second glow from the weather. */
body[data-daypart="dawn"] {
  --bg: #120f22;
  --bg-raised: #1b1730;
  --haze: rgba(236, 138, 118, 0.2);
}
body[data-daypart="day"] {
  --bg: #0f1628;
  --bg-raised: #172038;
  --haze: rgba(240, 180, 90, 0.2);
}
body[data-daypart="dusk"] {
  --bg: #140e20;
  --bg-raised: #1d162d;
  --haze: rgba(214, 112, 96, 0.2);
}
body[data-mood="cloud"] { --haze-2: rgba(150, 160, 190, 0.1); }
body[data-mood="rain"]  { --haze-2: rgba(80, 140, 230, 0.2); --haze: rgba(120, 150, 210, 0.14); }
body[data-mood="storm"] { --haze-2: rgba(130, 100, 230, 0.22); --haze: rgba(110, 130, 200, 0.14); }
body[data-mood="fog"]   { --haze-2: rgba(190, 196, 214, 0.14); --haze: rgba(190, 196, 214, 0.1); }
body[data-mood="snow"]  { --haze-2: rgba(190, 225, 255, 0.18); --haze: rgba(200, 225, 255, 0.12); }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-mono);
  transition: background-color 1.2s ease;
}

/* soft glow behind the masthead and a second one low on the page */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 90% 45% at 50% 0%, var(--haze), transparent 70%),
    radial-gradient(ellipse 80% 50% at 90% 100%, var(--haze-2), transparent 70%);
}

/* film grain */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.09;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

body {
  display: flex;
  justify-content: center;
  padding: 20px 16px 120px;
}

.muted { color: var(--text-secondary); }

.console {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 480px;
}

/* faceplate panels: a lit top edge, a shadowed bottom edge, a drop shadow */
.dial,
.reading {
  border: 1px solid var(--hairline);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    inset 0 -1px 0 rgba(0, 0, 0, 0.45),
    0 1px 0 rgba(0, 0, 0, 0.6),
    0 14px 34px rgba(0, 0, 0, 0.38);
}

/* tuning dial */
.dial {
  display: flex;
  align-items: center;
  gap: 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0) 50%),
    var(--bg-raised);
  border-radius: 10px;
  padding: 10px;
}

/* backlit amber glass */
.dial-glass {
  flex: 1;
  padding: 6px 14px 4px;
  border-radius: 6px;
  border: 1px solid rgba(232, 163, 61, 0.28);
  background: linear-gradient(180deg, rgba(232, 163, 61, 0.16), rgba(232, 163, 61, 0.05));
  box-shadow:
    inset 0 0 20px rgba(232, 163, 61, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.dial-track {
  position: relative;
  height: 30px;
  border-bottom: 1px solid rgba(232, 163, 61, 0.4);
}

.tick {
  position: absolute;
  bottom: 0;
  left: calc(var(--i) * 5%);
  width: 1px;
  height: 6px;
  background: rgba(232, 163, 61, 0.35);
}

.tick.major { height: 11px; background: rgba(232, 163, 61, 0.75); }

.mhz {
  position: absolute;
  top: 0;
  left: calc(var(--i) * 5%);
  transform: translateX(-50%);
  font-size: 9px;
  line-height: 1;
  color: rgba(232, 163, 61, 0.8);
}

.needle {
  position: absolute;
  top: 11px;
  bottom: -3px;
  left: var(--tune);
  width: 2px;
  margin-left: -1px;
  background: #ff5a3c;
  box-shadow: 0 0 6px #ff5a3c, 0 0 14px rgba(255, 90, 60, 0.5);
  animation: sweep 2.4s cubic-bezier(.2, .9, .3, 1) forwards;
}

/* script.js takes over the needle while tuning; the transition makes each
   hop (and the final settle back on the station) glide instead of jump */
.needle.tuning {
  animation: none;
  transition: left 0.7s cubic-bezier(.45, .05, .35, 1);
}

@keyframes sweep {
  0% { left: 0%; }
  55% { left: 100%; }
  100% { left: var(--tune); }
}

.freq {
  flex-shrink: 0;
  font-size: 20px;
  line-height: 1;
  color: var(--amber);
  text-shadow: 0 0 10px rgba(232, 163, 61, 0.55);
  padding-right: 4px;
}

.freq-unit {
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--amber-dim);
  text-shadow: none;
}

/* masthead */
.masthead {
  padding: 22px 4px 6px;
  text-align: center;
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

h1 {
  margin: 0;
  text-shadow: 0 0 28px var(--haze);
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 42px;
  letter-spacing: -0.01em;
}

.onair {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
}

.pilot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--amber-dim);
  box-shadow: 0 0 0 rgba(111, 207, 151, 0);
  transition: background 0.4s ease, box-shadow 0.4s ease;
}

.pilot.live {
  background: var(--signal);
  box-shadow: 0 0 10px var(--signal);
  animation: pulse 1.6s ease-in-out infinite;
}

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

/* reading */
.reading {
  /* lit top edge plus four corner screws */
  background:
    radial-gradient(circle at 11px 11px, rgba(255, 255, 255, 0.22) 0 2px, rgba(0, 0, 0, 0.5) 2.5px, transparent 3.5px),
    radial-gradient(circle at calc(100% - 11px) 11px, rgba(255, 255, 255, 0.22) 0 2px, rgba(0, 0, 0, 0.5) 2.5px, transparent 3.5px),
    radial-gradient(circle at 11px calc(100% - 11px), rgba(255, 255, 255, 0.22) 0 2px, rgba(0, 0, 0, 0.5) 2.5px, transparent 3.5px),
    radial-gradient(circle at calc(100% - 11px) calc(100% - 11px), rgba(255, 255, 255, 0.22) 0 2px, rgba(0, 0, 0, 0.5) 2.5px, transparent 3.5px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0) 30%),
    var(--bg-raised);
  border-radius: 10px;
  padding: 22px 20px 20px;
  margin-top: 16px;
}

.temp-row {
  display: flex;
  align-items: baseline;
  gap: 16px;
}

.temp {
  text-shadow: 0 0 30px var(--haze);
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 64px;
  line-height: 1;
}

.temp-meta p { margin: 0; }
#condition { font-size: 15px; margin-bottom: 4px; }
#place { font-size: 12px; }

.strip {
  margin-top: 20px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
  padding: 16px 0;
}

.strip-label {
  margin: 0 0 4px;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.strip-wide { grid-column: 1 / -1; }

.strip-value {
  margin: 0;
  font-size: 14px;
}

.script {
  margin: 20px 0 0;
  font-size: 14px;
  line-height: 1.85;
  color: var(--text-primary);
  white-space: pre-wrap;
}

/* docked player */
.dock {
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.35);
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  background: rgba(11, 14, 26, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--hairline);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
}

.dock[hidden] { display: none; }

.dock-inner {
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
}

.knob {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid var(--amber-dim);
  background: radial-gradient(circle at 35% 30%, #2a2210, var(--bg-raised) 70%);
  color: var(--amber);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.2s ease;
}

.knob:hover { border-color: var(--amber); }
.knob:active { transform: scale(0.95); }
.knob[disabled] { opacity: 0.5; cursor: default; }

.transport-meta { flex: 1; min-width: 0; }

#transportLabel {
  margin: 4px 0 0;
  font-size: 11px;
  color: var(--text-secondary);
}

.bars {
  margin-left: 4px;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 14px;
}

/* the voice drives each bar's height live (see the meter in script.js) */
.bars span {
  width: 3px;
  height: 15%;
  background: var(--amber-dim);
  border-radius: 1px;
  transition: height 70ms linear;
}

.bars.live span { background: var(--amber); box-shadow: 0 0 4px rgba(232, 163, 61, 0.6); }
.bars.live span:nth-child(n + 8) { background: #ff5a3c; box-shadow: 0 0 4px rgba(255, 90, 60, 0.6); }

/* if the browser won't hand over the audio, fall back to the old bounce */
.bars.live.canned span { animation: bounce 0.9s ease-in-out infinite; }
.bars.live.canned span:nth-child(2n) { animation-delay: 0.15s; }
.bars.live.canned span:nth-child(3n) { animation-delay: 0.3s; }

@keyframes bounce {
  0%, 100% { height: 20%; }
  50% { height: 100%; }
}

.ghost-btn {
  flex-shrink: 0;
  background: transparent;
  border: 1px solid var(--hairline);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
}

.ghost-btn:hover { border-color: var(--text-secondary); }

/* loading state */
#loading { text-align: center; font-size: 13px; }
#loading .ghost-btn { margin-top: 12px; }

.foot {
  margin-top: 22px;
  text-align: center;
  font-size: 11px;
  color: var(--text-secondary);
  opacity: 0.7;
}

@media (max-width: 380px) {
  .temp { font-size: 52px; }
  h1 { font-size: 34px; }
}

@media (prefers-reduced-motion: reduce) {
  .needle { animation: none; }
  .pilot.live { animation: none; }
  .bars.live.canned span { animation: none; height: 60%; }
}
