/* =========================
   LIGHT THEME
========================== */

:root {
  color-scheme: light;

  --bg: #f4f4f4;
  --text: #000000;
  --muted-text: #444444;

  --header1: #0066cc;
  --header2: #003399;

  --marquee-bg: #ffff99;
  --marquee-fg: #000000;

  --toolbar-bg: #ededed;
  --panel-bg: #ffffff;
  --panel-inner: #f6f6f6;
  --panel-hover: #e6f0ff;

  --control-bg: #e6e6e6;
  --control-fg: #000000;
  --input-bg: #ffffff;
  --input-fg: #000000;

  --titlebar1: #000080;
  --titlebar2: #1084d0;

  --footer-bg: #f9f9f9;
  --border: #c0c0c0;
  --border-strong: #000080;
  --shadow: #000000;

  --accent: #0066cc;
  --accent-light: #bde0ff;
  --accent-dark: #002d65;

  --eyebrow: #000080;
  --error: #cc0000;
  --live: #ff0000;

  font-family:
    "Comic Sans MS",
    "Trebuchet MS",
    Arial,
    sans-serif;
}

/* =========================
   DARK THEME
========================== */

body.theme-dark {
  color-scheme: dark;

  --bg: #0f0f14;
  --text: #e6e6e6;
  --muted-text: #b5b5c6;

  --header1: #1a1a3d;
  --header2: #0d0d20;

  --marquee-bg: #1c1c33;
  --marquee-fg: #66ccff;

  --toolbar-bg: #1a1a1f;
  --panel-bg: #1e1e24;
  --panel-inner: #15151b;
  --panel-hover: #2a2a44;

  --control-bg: #292932;
  --control-fg: #e6e6e6;
  --input-bg: #101017;
  --input-fg: #ffffff;

  --titlebar1: #16164d;
  --titlebar2: #174f80;

  --footer-bg: #141419;
  --border: #555568;
  --border-strong: #3399ff;
  --shadow: #000000;

  --accent: #3399ff;
  --accent-light: #72bbff;
  --accent-dark: #00509f;

  --eyebrow: #66ccff;
  --error: #ff8297;
  --live: #ff4f64;
}

/* =========================
   GLOBAL
========================== */

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  padding: 24px;

  color: var(--text);
  background-color: var(--bg);

  overflow-x: hidden;
  transition:
    color 160ms ease,
    background-color 160ms ease;
}

body.login-required {
  overflow: hidden;
}

/* Retro grid background */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;

  background-image:
    linear-gradient(
      to right,
      rgb(127 127 127 / 8%) 1px,
      transparent 1px
    ),
    linear-gradient(
      to bottom,
      rgb(127 127 127 / 8%) 1px,
      transparent 1px
    );

  background-size: 32px 32px;
}

button,
input,
select {
  font: inherit;
}

button,
a,
select {
  -webkit-tap-highlight-color: transparent;
}

/* =========================
   PLAYER SHELL
========================== */

.player-shell {
  position: relative;
  z-index: 5;

  width: min(980px, 100%);
  margin: 0 auto;

  color: var(--text);
  background: var(--panel-bg);
  border: 3px ridge var(--border);
  box-shadow: 5px 5px 0 var(--shadow);

  transition:
    filter 180ms ease,
    opacity 180ms ease,
    color 160ms ease,
    background 160ms ease;
}

.player-shell[inert] {
  opacity: 0.32;
  filter: blur(5px);
  pointer-events: none;
  user-select: none;
}

/* =========================
   HEADER
========================== */

.site-header {
  position: relative;
  z-index: 10;

  padding: 12px 10px 10px;

  color: #ffffff;
  text-align: center;
  background: linear-gradient(var(--header1), var(--header2));
  border-bottom: 3px solid var(--border-strong);
}

.site-header h1 {
  margin: 0;
  font-size: clamp(1.8rem, 5vw, 2.7rem);
  line-height: 1.2;
  text-shadow: 2px 2px 0 #000000;
}

.site-header .tagline {
  margin: 5px 0 0;
  font-size: 14px;
}

/* =========================
   MARQUEE
========================== */

.retro-marquee {
  position: relative;
  z-index: 10;

  width: 100%;
  padding: 4px 0;

  overflow: hidden;

  color: var(--marquee-fg);
  background: var(--marquee-bg);
  border-top: 2px solid var(--text);
  border-bottom: 2px solid var(--text);

  font-weight: bold;
  white-space: nowrap;
}

.marquee-content {
  display: inline-block;
  min-width: 100%;
  padding-left: 100%;

  animation: marquee-scroll 22s linear infinite;
}

@keyframes marquee-scroll {
  from {
    transform: translateX(0);
  }

  to {
    transform: translateX(-100%);
  }
}

/* =========================
   TOOLBAR
========================== */

.toolbar {
  position: relative;
  z-index: 10;

  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;

  margin: 12px;
  padding: 8px 10px;

  color: var(--text);
  background: var(--toolbar-bg);
  border: 3px ridge var(--border);
}

.theme-control {
  display: flex;
  align-items: center;
  gap: 7px;

  color: var(--text);
  font-size: 14px;
  font-weight: bold;
}

.theme-control select {
  min-height: 36px;
  padding: 4px 8px;

  color: var(--control-fg);
  background: var(--control-bg);
  border: 3px outset var(--border);

  cursor: pointer;
}

.theme-control select:active {
  border-style: inset;
}

.status {
  color: var(--muted-text);
  font-family: "Courier New", monospace;
  font-size: 13px;
  font-weight: bold;
  text-align: right;
}

.retro-button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  min-height: 42px;
  padding: 7px 14px;

  color: var(--control-fg);
  background: var(--control-bg);
  border: 3px outset var(--border);
  border-radius: 0;

  font-weight: bold;
  text-decoration: none;
  cursor: pointer;
}

.retro-button:visited {
  color: var(--control-fg);
}

.retro-button:hover,
button:hover:not(:disabled) {
  background: var(--panel-hover);
}

.retro-button:active,
button:active:not(:disabled) {
  border-style: inset;
}

/* =========================
   RADIO CONTENT
========================== */

.radio-content {
  padding: 0 12px 12px;
}

.now-playing,
.controls-panel {
  margin-top: 14px;

  background: var(--panel-bg);
  border: 3px ridge var(--border);
  box-shadow: 3px 3px 0 var(--shadow);
}

.panel-titlebar,
.login-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;

  min-height: 32px;
  padding: 5px 9px;

  color: #ffffff;
  background: linear-gradient(
    90deg,
    var(--titlebar1),
    var(--titlebar2)
  );
  border-bottom: 2px solid #000000;

  font-family: "Trebuchet MS", Arial, sans-serif;
  font-size: 14px;
  font-weight: bold;
}

.now-playing-content {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 22px;

  min-height: 190px;
  padding: clamp(22px, 5vw, 42px);

  background:
    linear-gradient(
      135deg,
      rgb(51 153 255 / 9%),
      transparent 55%
    ),
    var(--panel-inner);
}

.radio-icon {
  display: grid;
  place-items: center;

  width: clamp(90px, 18vw, 145px);
  aspect-ratio: 1;

  background: var(--control-bg);
  border: 4px outset var(--border);
  font-size: clamp(3.7rem, 10vw, 6.5rem);
}

.track-information {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 8px;

  color: var(--eyebrow);
  font-family: "Courier New", monospace;
  font-size: 0.78rem;
  font-weight: bold;
  letter-spacing: 0.12em;
}

h1,
h2,
p {
  overflow-wrap: anywhere;
}

h2 {
  min-height: 1.1em;
  margin: 8px 0;

  color: var(--text);
  font-size: clamp(1.6rem, 5vw, 3rem);
  line-height: 1.1;
}

.track-path {
  min-height: 1.4em;
  margin: 12px 0 0;

  color: var(--muted-text);
  font-family: "Courier New", monospace;
  font-size: 14px;
}

.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;

  font-family: "Courier New", monospace;
  font-size: 12px;
}

.live-dot {
  width: 9px;
  height: 9px;

  background: var(--live);
  border: 1px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 0 7px var(--live);

  animation: live-pulse 1.2s ease-in-out infinite;
}

@keyframes live-pulse {
  50% {
    opacity: 0.35;
  }
}

/* =========================
   CONTROLS
========================== */

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;

  padding: 22px;
  background: var(--panel-inner);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid #ff00ff;
  outline-offset: 3px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

button.primary {
  min-width: 150px;

  color: #ffffff;
  background: linear-gradient(
    var(--accent-light),
    var(--accent-dark)
  );
  border-color:
    var(--accent-light)
    var(--accent-dark)
    var(--accent-dark)
    var(--accent-light);

  text-shadow: 1px 1px 0 #000000;
}

button.primary:hover:not(:disabled) {
  filter: brightness(1.12);
}

button.primary:active:not(:disabled) {
  border-style: inset;
}

.volume {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 12px;

  min-width: 240px;

  color: var(--text);
  font-size: 14px;
  font-weight: bold;
}

input[type="range"] {
  width: 100%;
  min-width: 120px;
  accent-color: var(--accent);
  cursor: pointer;
}

input[type="range"]:disabled {
  cursor: not-allowed;
}

/* =========================
   FOOTER
========================== */

footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;

  margin: 12px;
  padding: 9px 12px;

  color: var(--muted-text);
  background: var(--footer-bg);
  border: 3px groove var(--border);

  font-family: "Courier New", monospace;
  font-size: 12px;
  text-align: center;
}

footer p {
  margin: 0;
}

.blink {
  color: var(--live);
  font-weight: bold;
  animation: blink 1s step-start infinite;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

/* =========================
   LOGIN OVERLAY
========================== */

.login-overlay {
  position: fixed;
  z-index: 1000;
  inset: 0;

  display: grid;
  place-items: center;

  padding: 24px;

  background: rgb(0 0 64 / 72%);
  backdrop-filter: blur(5px);

  transition:
    opacity 180ms ease,
    visibility 180ms ease;
}

body.theme-dark .login-overlay {
  background: rgb(4 4 12 / 82%);
}

.login-overlay.is-hidden {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.login-panel {
  width: min(450px, 100%);
  padding: 0;

  color: var(--text);
  background: var(--toolbar-bg);
  border: 4px outset var(--border);
  border-radius: 0;
  box-shadow: 8px 8px 0 rgb(0 0 0 / 75%);
}

.login-content {
  padding: clamp(22px, 6vw, 36px);
  text-align: center;
}

.login-icon {
  margin: 0 0 8px;
  font-size: 64px;
  line-height: 1;
}

.login-panel h2 {
  min-height: auto;
  margin: 4px 0 0;

  color: var(--text);
  font-size: clamp(2rem, 8vw, 3.1rem);
  line-height: 1;
}

.login-description {
  margin: 14px 0 24px;
  color: var(--muted-text);
  line-height: 1.5;
}

.login-field {
  display: grid;
  gap: 7px;

  margin-top: 16px;

  color: var(--text);
  font-size: 0.88rem;
  font-weight: bold;
  text-align: left;
}

.login-field input {
  width: 100%;
  min-height: 46px;
  padding: 9px 11px;

  color: var(--input-fg);
  background: var(--input-bg);
  border: 3px inset var(--border);
  border-radius: 0;
  outline: none;
}

.login-field input:hover {
  border-color: var(--accent);
}

.login-field input:focus {
  border-color: var(--accent);
}

.login-error {
  min-height: 1.4em;
  margin: 13px 0 2px;

  color: var(--error);
  font-family: "Courier New", monospace;
  font-size: 0.83rem;
  font-weight: bold;
  text-align: left;
}

.login-submit {
  width: 100%;
  margin-top: 10px;
}

.login-footer {
  margin: 20px 0 0;

  color: var(--muted-text);
  font-family: "Courier New", monospace;
  font-size: 11px;
}

.login-shake {
  animation: login-shake 260ms ease-in-out;
}

@keyframes login-shake {
  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-8px);
  }

  75% {
    transform: translateX(8px);
  }
}

/* =========================
   SPARKLES
========================== */

.sparkle {
  position: fixed;
  top: -20px;
  z-index: 2;

  opacity: 0.9;
  pointer-events: none;

  font-size: 20px;
  animation: fall 10s linear infinite;
}

@keyframes fall {
  0% {
    transform: translateY(-10vh) rotate(0deg);
    opacity: 0;
  }

  10% {
    opacity: 1;
  }

  100% {
    transform: translateY(110vh) rotate(360deg);
    opacity: 0;
  }
}

/* =========================
   RESPONSIVE DESIGN
========================== */

@media (max-width: 760px) {
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .theme-control {
    justify-content: center;
  }

  .theme-control select {
    flex: 1;
  }

  .status {
    text-align: center;
  }

  .home-button {
    width: 100%;
  }
}

@media (max-width: 680px) {
  body {
    padding: 0;
  }

  .player-shell {
    min-height: 100vh;
    border: 0;
    box-shadow: none;
  }

  .now-playing-content {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .radio-icon {
    margin: 0 auto;
  }

  .controls {
    align-items: stretch;
    flex-direction: column;
  }

  button.primary {
    width: 100%;
  }

  .volume {
    width: 100%;
    min-width: 0;
  }

  footer {
    align-items: center;
    flex-direction: column;
  }

  .login-overlay {
    padding: 12px;
  }
}

@media (max-width: 420px) {
  .site-header h1 {
    font-size: 1.55rem;
  }

  .now-playing-content {
    padding: 24px 16px;
  }

  .volume {
    align-items: stretch;
    flex-direction: column;
  }

  .login-content {
    padding: 22px 18px;
  }
}

/* =========================
   REDUCED MOTION
========================== */

@media (prefers-reduced-motion: reduce) {
  body,
  .player-shell,
  .login-overlay {
    transition: none;
  }

  .sparkle,
  .marquee-content,
  .live-dot,
  .blink,
  .login-shake {
    animation: none;
  }

  .marquee-content {
    padding-left: 12px;
    transform: none;
  }
}
