/*
 * Ambi — styles.css
 * Glassmorphic player floating over a full-screen animated canvas.
 * Adapts to the OS light/dark preference via the .light class on <body>.
 */

:root {
  --text: rgba(255, 255, 255, 0.94);
  --text-dim: rgba(255, 255, 255, 0.62);
  --text-faint: rgba(255, 255, 255, 0.4);

  --glass-bg: rgba(18, 18, 28, 0.42);
  --glass-bg-2: rgba(255, 255, 255, 0.05);
  --glass-border: rgba(255, 255, 255, 0.14);
  --glass-hi: rgba(255, 255, 255, 0.5);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.55), 0 2px 8px rgba(0, 0, 0, 0.3);

  --chip-bg: rgba(255, 255, 255, 0.06);
  --chip-border: rgba(255, 255, 255, 0.1);
  --chip-active: rgba(255, 255, 255, 0.16);

  --ctrl-bg: rgba(255, 255, 255, 0.1);
  --ctrl-border: rgba(255, 255, 255, 0.16);

  --play-grad: linear-gradient(135deg, #ffffff, #d7d2ff);
  --play-ink: #1a1830;

  --track: rgba(255, 255, 255, 0.16);
  --fill: rgba(255, 255, 255, 0.9);

  --led-on: #7dffb0;

  --blur: blur(28px) saturate(135%);
  --radius: 28px;
}

body.light {
  --text: rgba(18, 20, 28, 0.92);
  --text-dim: rgba(18, 20, 28, 0.6);
  --text-faint: rgba(18, 20, 28, 0.42);

  --glass-bg: rgba(255, 255, 255, 0.55);
  --glass-bg-2: rgba(255, 255, 255, 0.4);
  --glass-border: rgba(255, 255, 255, 0.7);
  --glass-hi: rgba(255, 255, 255, 0.9);
  --shadow: 0 24px 70px rgba(40, 50, 80, 0.22), 0 2px 8px rgba(40, 50, 80, 0.12);

  --chip-bg: rgba(255, 255, 255, 0.5);
  --chip-border: rgba(255, 255, 255, 0.7);
  --chip-active: rgba(255, 255, 255, 0.92);

  --ctrl-bg: rgba(255, 255, 255, 0.6);
  --ctrl-border: rgba(255, 255, 255, 0.8);

  --play-grad: linear-gradient(135deg, #3a3658, #5a5aa0);
  --play-ink: #ffffff;

  --track: rgba(40, 45, 70, 0.18);
  --fill: rgba(60, 60, 120, 0.85);

  --led-on: #1bb874;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  min-height: 100dvh;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: #0c0c14;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* app, not a document: no text selection or long-press callout */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

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

/* ---------- layout ---------- */

.app {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(20px, 4vh, 42px);
  padding: max(20px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
}

/* ---------- player card ---------- */

.player {
  width: min(440px, 100%);
  border-radius: var(--radius);
  padding: 26px 24px 22px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  animation: rise 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.glass {
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow), inset 0 1px 0 var(--glass-hi);
  position: relative;
}
/* subtle top sheen */
.glass::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0) 38%);
  pointer-events: none;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(18px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

/* ---------- now playing ---------- */

.now { display: flex; flex-direction: column; gap: 5px; }
.now-top { display: flex; align-items: center; gap: 9px; }

.dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--text-faint);
  transition: background 0.4s, box-shadow 0.4s;
}
.dot.live {
  background: var(--led-on);
  box-shadow: 0 0 0 0 rgba(125, 255, 176, 0.5);
  animation: ping 2.4s ease-out infinite;
}
@keyframes ping {
  0% { box-shadow: 0 0 0 0 rgba(125, 255, 176, 0.45); }
  70%, 100% { box-shadow: 0 0 0 8px rgba(125, 255, 176, 0); }
}

.station-name { font-size: 13px; font-weight: 600; letter-spacing: 1.4px; text-transform: uppercase; color: var(--text-dim); }
.track-title { font-size: 27px; font-weight: 600; letter-spacing: 0.2px; line-height: 1.15; }
.now-sub { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.tagline { font-size: 13.5px; color: var(--text-dim); }
.time { font-size: 13px; color: var(--text-faint); font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* ---------- stations ---------- */

.stations {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  justify-content: center;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px 9px 11px;
  border-radius: 100px;
  background: var(--chip-bg);
  border: 1px solid var(--chip-border);
  color: var(--text-dim);
  font-size: 13.5px;
  font-weight: 550;
  cursor: pointer;
  transition: background 0.25s, color 0.25s, transform 0.15s, border-color 0.25s, box-shadow 0.25s;
  -webkit-tap-highlight-color: transparent;
}
.chip:hover { transform: translateY(-1px); color: var(--text); }
.chip:active { transform: translateY(0); }
.chip.active {
  background: var(--chip-active);
  color: var(--text);
  border-color: var(--glass-hi);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25), inset 0 1px 0 var(--glass-hi);
}
.chip-dot {
  width: 13px; height: 13px; border-radius: 50%;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.25);
  flex: none;
}

/* ---------- controls ---------- */

.controls {
  display: flex;
  align-items: center;
  gap: 16px;
}

.ctrl {
  display: grid;
  place-items: center;
  border-radius: 50%;
  cursor: pointer;
  border: 1px solid var(--ctrl-border);
  background: var(--ctrl-bg);
  color: var(--text);
  transition: transform 0.14s ease, background 0.25s, box-shadow 0.25s;
  -webkit-tap-highlight-color: transparent;
}
.ctrl svg { width: 46%; height: 46%; fill: currentColor; }
.ctrl:hover { transform: translateY(-2px); }
.ctrl:active { transform: translateY(0) scale(0.96); }

.ctrl-sm { width: 50px; height: 50px; }

.ctrl-play {
  width: 70px; height: 70px;
  background: var(--play-grad);
  color: var(--play-ink);
  border: none;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
.ctrl-play svg { width: 50%; height: 50%; }
.ctrl-play:hover { box-shadow: 0 16px 38px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.7); }

/* volume */
.volume {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.vol-icon { color: var(--text-dim); flex: none; transition: opacity 0.2s; }
.vol-icon svg { width: 22px; height: 22px; fill: currentColor; display: block; }
.vol-icon.muted .wave1, .vol-icon.muted .wave2 { display: none; }

.vol-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
  cursor: pointer;
}
.vol-slider::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right, var(--fill) calc(var(--p) * 1%), var(--track) calc(var(--p) * 1%));
}
.vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  margin-top: -5px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  border: none;
}
.vol-slider::-moz-range-track { height: 6px; border-radius: 3px; background: var(--track); }
.vol-slider::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--fill); }
.vol-slider::-moz-range-thumb {
  width: 16px; height: 16px; border: none; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}
.vol-slider:focus-visible { outline: none; }
.vol-slider:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.25); }

/* ---------- status row ---------- */

.status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 11.5px;
  color: var(--text-faint);
  letter-spacing: 0.2px;
}
.wake { display: inline-flex; align-items: center; gap: 7px; }
.wake-led {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-faint);
  transition: background 0.3s, box-shadow 0.3s;
}
.wake.active .wake-led { background: var(--led-on); box-shadow: 0 0 8px var(--led-on); }
.wake.active .wake-label { color: var(--text-dim); }
.hint { opacity: 0.85; transition: opacity 0.4s; }
.hint.hidden { opacity: 0; }

/* ---------- focus visibility for keyboard users ---------- */
.chip:focus-visible, .ctrl:focus-visible {
  outline: 2px solid var(--glass-hi);
  outline-offset: 3px;
}

/* ---------- help button + about modal ---------- */

.help-btn {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 5;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 50%;
  font-size: 19px; font-weight: 650; line-height: 1;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  -webkit-backdrop-filter: blur(12px) saturate(130%);
  backdrop-filter: blur(12px) saturate(130%);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: transform 0.15s ease, background 0.25s, color 0.25s, border-color 0.25s;
  -webkit-tap-highlight-color: transparent;
}
.help-btn:hover { transform: translateY(-2px); color: var(--text); background: rgba(255, 255, 255, 0.16); }
.help-btn:active { transform: translateY(0); }
body.light .help-btn {
  background: rgba(255, 255, 255, 0.55);
  border-color: rgba(255, 255, 255, 0.7);
  box-shadow: 0 6px 20px rgba(40, 50, 80, 0.16);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 22px;
}
.modal[hidden] { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 8, 16, 0.55);
  -webkit-backdrop-filter: blur(7px);
  backdrop-filter: blur(7px);
  animation: modal-fade 0.3s ease both;
}
body.light .modal-backdrop { background: rgba(150, 165, 195, 0.4); }

.modal-card {
  position: relative;
  width: min(420px, 100%);
  padding: 34px 28px 26px;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  animation: modal-rise 0.42s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.modal-close {
  position: absolute;
  top: 13px; right: 13px;
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--text-dim);
  background: var(--chip-bg);
  border: 1px solid var(--chip-border);
  cursor: pointer;
  transition: transform 0.14s ease, color 0.2s, background 0.2s;
}
.modal-close svg { width: 16px; height: 16px; fill: none; stroke: currentColor; }
.modal-close:hover { color: var(--text); transform: scale(1.06); }

.modal-mark { width: 66px; height: 66px; filter: drop-shadow(0 8px 20px rgba(0, 0, 0, 0.35)); }
.modal-mark svg { width: 100%; height: 100%; display: block; }

.modal-title { font-size: 30px; font-weight: 650; letter-spacing: 0.4px; margin: 6px 0 0; }
.modal-sub { font-size: 13.5px; color: var(--text-dim); margin: 0; }
.modal-text { font-size: 14.5px; line-height: 1.55; color: var(--text-dim); margin: 8px 0 0; }
.modal-fine { font-size: 11.5px; color: var(--text-faint); letter-spacing: 0.2px; margin: 12px 0 0; }

@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-rise {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

/* ---------- responsive ---------- */

@media (max-width: 430px) {
  .player { padding: 22px 18px 18px; gap: 18px; border-radius: 24px; }
  .track-title { font-size: 24px; }
  .ctrl-play { width: 64px; height: 64px; }
  .ctrl-sm { width: 46px; height: 46px; }
  .controls { gap: 13px; }
}

@media (max-height: 560px) {
  .app { justify-content: flex-start; gap: 16px; padding-top: 16px; }
}

/* respect reduced-motion: calm the chrome (the ambient canvas stays, gently) */
@media (prefers-reduced-motion: reduce) {
  .player { animation: none; }
  .dot.live { animation: none; }
  .modal-card, .modal-backdrop { animation: none; }
}
