/* ============================================================
   RN·3 — Design C
   A Dieter Rams / Braun-inspired minimalist radio. Matte surfaces,
   a signature perforated speaker disc, one accent colour, lots of
   air. "Less, but better." Reuses app.js unchanged.
   Themes: ivory (light, default), walnut (sand), graphite (dark).
   ============================================================ */

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

:root {
  /* IVORY — light, the default Braun off-white */
  --room: #d7d3ca;
  --body-1: #f0ede7;
  --body-2: #e4e0d8;
  --ink: #1b1a18;
  --ink-2: #6c6860;
  --ink-3: #a8a399;
  --hair: rgba(0, 0, 0, 0.1);
  --dot: #cbc6bb;
  --dot-shade: rgba(0, 0, 0, 0.06);
  --key-bg: #e9e5dd;
  --key-line: rgba(0, 0, 0, 0.14);
  --accent: #e1481f;
  --accent-ink: #fff;
  --shadow: rgba(70, 60, 45, 0.28);
}

[data-theme="walnut"] {
  --room: #b9ab92;
  --body-1: #ddd0b9;
  --body-2: #d0c2a8;
  --ink: #2a2318;
  --ink-2: #6e6149;
  --ink-3: #a2916f;
  --hair: rgba(40, 30, 10, 0.12);
  --dot: #c0b094;
  --dot-shade: rgba(60, 45, 20, 0.08);
  --key-bg: #d6c8ae;
  --key-line: rgba(40, 30, 10, 0.16);
  --accent: #c8502a;
  --accent-ink: #fff;
  --shadow: rgba(60, 45, 25, 0.32);
}

[data-theme="graphite"] {
  --room: #0d0e0f;
  --body-1: #1f2123;
  --body-2: #17181a;
  --ink: #ecebe8;
  --ink-2: #9a9892;
  --ink-3: #5e605f;
  --hair: rgba(255, 255, 255, 0.1);
  --dot: #2c2e31;
  --dot-shade: rgba(0, 0, 0, 0.5);
  --key-bg: #25272a;
  --key-line: rgba(255, 255, 255, 0.12);
  --accent: #ff5436;
  --accent-ink: #fff;
  --shadow: rgba(0, 0, 0, 0.6);
}

html, body { height: 100%; }

body {
  font-family: 'Hanken Grotesk', sans-serif;
  background: var(--room);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  overflow: hidden;
  transition: background 0.5s ease;
}

.scene {
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}

/* ── The set: a clean matte slab ───────────────────────────── */
.set {
  width: 100%;
  max-width: 400px;
  border-radius: 28px;
  padding: 26px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  background: linear-gradient(165deg, var(--body-1), var(--body-2));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    0 1px 2px rgba(0, 0, 0, 0.1),
    0 30px 60px -20px var(--shadow);
  transition: background 0.5s ease;
}

/* ── Top identity ──────────────────────────────────────────── */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.ident { display: flex; align-items: center; gap: 9px; }
.dot-mark {
  width: 11px; height: 11px;
  border-radius: 50%;
  background: var(--accent);
}
.ident-txt {
  font-size: 15px; font-weight: 500; letter-spacing: 0.3px;
  color: var(--ink);
}
.ident-txt b { font-weight: 800; }

.top-right { display: flex; align-items: center; gap: 13px; }
.live-badge {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.3px;
  color: var(--accent);
  opacity: 0; transition: opacity 0.3s;
}
.live-badge.visible { opacity: 1; }
.live-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

.themes { display: flex; gap: 6px; }
.swatch {
  width: 14px; height: 14px; border-radius: 50%;
  border: 1px solid var(--hair); padding: 0; cursor: pointer;
  transition: transform 0.15s;
}
.swatch:active { transform: scale(0.88); }
.swatch[data-theme="ivory"] { background: #f0ede7; }
.swatch[data-theme="walnut"] { background: #d0c2a8; }
.swatch[data-theme="graphite"] { background: #1f2123; }
.swatch.active { box-shadow: 0 0 0 2px var(--accent); border-color: transparent; }

.btn-about {
  background: none; border: none; padding: 0;
  color: var(--ink-3); cursor: pointer; display: flex;
  transition: color 0.2s;
}
.btn-about:hover { color: var(--ink); }

/* ── Band selector: quiet text tabs ────────────────────────── */
.bands {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  margin: -2px -4px;
  padding: 2px 4px;
}
.bands::-webkit-scrollbar { display: none; }
.band-pill {
  flex: 0 0 auto;
  background: none; border: none;
  padding: 5px 9px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px; font-weight: 600; letter-spacing: 0.2px;
  color: var(--ink-3);
  cursor: pointer; white-space: nowrap;
  transition: color 0.2s, background 0.2s;
}
.band-pill.active { color: var(--accent-ink); background: var(--accent); }

/* ── Now playing + LANG/CH faders ──────────────────────────── */
.now-row { display: flex; gap: 14px; align-items: stretch; }
.now-row .now { flex: 1; min-width: 0; }
.faders { flex: 0 0 auto; display: flex; gap: 10px; align-items: stretch; }
.fader-unit { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.fader {
  position: relative; width: 22px; flex: 1; min-height: 74px;
  border-radius: 11px; cursor: grab; touch-action: none;
  background: var(--key-bg);
  box-shadow: inset 0 0 0 1px var(--key-line);
}
.fader:active { cursor: grabbing; }
.fader-track {
  position: absolute; left: 50%; top: 9px; bottom: 9px; width: 3px; margin-left: -1.5px;
  border-radius: 3px; background: var(--key-line);
}
.fader-thumb {
  position: absolute; left: 50%; top: 0; width: 20px; height: 13px; margin-left: -10px;
  transform: translateY(-50%); border-radius: 7px; pointer-events: none;
  background: var(--ink);
  box-shadow: 0 1px 3px var(--shadow);
}
.fader-thumb::after {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: 9px; height: 2px; margin: -1px 0 0 -4.5px;
  border-radius: 2px; background: var(--accent);
}
.fader-dashes { position: absolute; inset: 0; pointer-events: none; }
.fader-dash {
  position: absolute; left: 50%; width: 10px; height: 1.5px; margin-left: -5px;
  transform: translateY(-50%); border-radius: 1px;
  background: var(--ink-3);
}
.fader-label { font-family: 'DM Mono', monospace; font-size: 10px; letter-spacing: 1px; color: var(--ink-3); }

.now { padding: 4px 0 2px; }
.now-status {
  font-family: 'DM Mono', monospace;
  font-size: 11px; letter-spacing: 1.5px;
  color: var(--ink-3);
  text-transform: lowercase;
  transition: color 0.3s;
}
.now-status.live { color: var(--accent); }
.now-status.ad { color: var(--accent); }
.now-title {
  font-size: 30px; font-weight: 700; line-height: 1.04;
  letter-spacing: -0.5px;
  margin: 5px 0 4px;
  color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.now-meta {
  font-family: 'DM Mono', monospace;
  font-size: 12px; letter-spacing: 0.2px;
  color: var(--ink-2);
}
.device.off-air .now-title { color: var(--ink-3); }

/* ── Signature perforated speaker disc ─────────────────────── */
.speaker {
  display: flex;
  justify-content: center;
  padding: 4px 0;
}
.speaker-grille {
  width: 168px; height: 168px;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, var(--dot) 1.5px, transparent 1.9px) 0 0 / 12px 12px;
  box-shadow:
    inset 0 0 0 1px var(--hair),
    inset 0 2px 5px var(--dot-shade);
  -webkit-mask: radial-gradient(circle at center, #000 67%, transparent 70%);
          mask: radial-gradient(circle at center, #000 67%, transparent 70%);
  position: relative;
  transition: transform 0.4s ease;
}
.speaker-grille::after {
  content: '';
  position: absolute; inset: 0;
  border-radius: 50%;
  box-shadow: inset 0 0 0 6px var(--body-1);
  -webkit-mask: radial-gradient(circle at center, transparent 64%, #000 65%, #000 67%, transparent 68%);
          mask: radial-gradient(circle at center, transparent 64%, #000 65%, #000 67%, transparent 68%);
}
/* A single animation: a wave of light passes over the EXISTING speaker
   pixels while playing. Same dot grid, tinted with the palette ink. The
   wave band is intersected with a circular mask so it stays inside the disc. */
.speaker-eq {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at center, var(--ink) 1.5px, transparent 2px) 0 0 / 12px 12px;
  opacity: 0;
  pointer-events: none;
  -webkit-mask:
    radial-gradient(circle at center, #000 64%, transparent 67%),
    linear-gradient(180deg, transparent 0%, #000 42%, #000 56%, transparent 94%);
  -webkit-mask-size: 100% 100%, 100% 50%;
  -webkit-mask-position: center, 50% -55%;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-composite: source-in;
  mask:
    radial-gradient(circle at center, #000 64%, transparent 67%),
    linear-gradient(180deg, transparent 0%, #000 42%, #000 56%, transparent 94%);
  mask-size: 100% 100%, 100% 50%;
  mask-position: center, 50% -55%;
  mask-repeat: no-repeat;
  mask-composite: intersect;
}
.device.playing .speaker-eq {
  opacity: 0.5;
  animation: wave 2.6s linear infinite;
}
@keyframes wave {
  0%   { -webkit-mask-position: center, 50% -58%; mask-position: center, 50% -58%; }
  100% { -webkit-mask-position: center, 50% 158%; mask-position: center, 50% 158%; }
}

/* ── Presets: quiet chips ──────────────────────────────────── */
.presets {
  display: flex; flex-wrap: wrap; gap: 7px;
  max-height: 92px; overflow-y: auto;
  scrollbar-width: none;
}
.presets::-webkit-scrollbar { display: none; }
.preset-btn {
  padding: 7px 13px;
  border-radius: 100px;
  border: 1px solid var(--key-line);
  background: transparent;
  color: var(--ink-2);
  font-family: inherit;
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  transition: all 0.18s;
}
.preset-btn:active { transform: scale(0.96); }
.preset-btn.active {
  background: var(--ink);
  color: var(--body-1);
  border-color: var(--ink);
}

/* ── Console: a dial + three keys ──────────────────────────── */
.console {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-top: 4px;
}
.dial-unit, .key-unit { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.console-label {
  font-family: 'DM Mono', monospace;
  font-size: 10px; letter-spacing: 1px; color: var(--ink-3);
}

.dial {
  position: relative;
  width: 58px; height: 58px;
  border-radius: 50%;
  cursor: pointer;
  background: radial-gradient(circle at 50% 38%, var(--body-1), var(--key-bg));
  box-shadow:
    0 0 0 1px var(--key-line),
    inset 0 1px 1px rgba(255, 255, 255, 0.5),
    0 4px 10px var(--shadow);
  transform: rotate(-135deg);
}
.dial:active { filter: brightness(0.98); }
.dial-mark {
  position: absolute;
  top: 7px; left: 50%;
  width: 3px; height: 15px;
  margin-left: -1.5px;
  border-radius: 2px;
  background: var(--accent);
}

.keys { display: flex; gap: 11px; }
.key {
  width: 50px; height: 50px;
  border-radius: 50%;
  border: 1px solid var(--key-line);
  background: var(--key-bg);
  color: var(--ink);
  cursor: pointer;
  display: grid; place-items: center;
  font-family: 'DM Mono', monospace;
  font-size: 13px; font-weight: 500;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.4), 0 2px 5px var(--shadow);
  transition: transform 0.1s, background 0.2s, color 0.2s;
}
.key:active { transform: scale(0.94); }
.key-power.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.key.active { color: var(--accent); border-color: var(--accent); }
.key-mute .ico-muted { display: none; }
.key-mute.muted { color: var(--accent); border-color: var(--accent); }
.key-mute.muted .ico-unmuted { display: none; }
.key-mute.muted .ico-muted { display: block; }

/* ── Autoplay gate ─────────────────────────────────────────── */
.autoplay-gate {
  position: fixed; inset: 0;
  background: color-mix(in srgb, var(--room) 80%, transparent);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; cursor: pointer;
  opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
.autoplay-gate.visible { opacity: 1; pointer-events: auto; }
.gate-content { text-align: center; color: var(--ink); }
.gate-play {
  display: block;
  width: 0; height: 0; margin: 0 auto 16px;
  border-left: 26px solid var(--accent);
  border-top: 16px solid transparent;
  border-bottom: 16px solid transparent;
}
.gate-content p { font-family: 'DM Mono', monospace; font-size: 14px; letter-spacing: 1px; }

/* ── About modal ───────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 90; animation: fade-in 0.2s ease;
}
.modal[hidden] { display: none; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal-sheet {
  position: relative;
  width: 100%; max-width: 400px;
  padding: 28px 26px calc(28px + env(safe-area-inset-bottom));
  border-radius: 24px 24px 0 0;
  background: var(--body-1);
  color: var(--ink);
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.3);
  animation: slide-up 0.25s ease;
}
@keyframes slide-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-close {
  position: absolute; top: 18px; right: 18px;
  background: none; border: none; color: var(--ink-3);
  font-size: 17px; cursor: pointer;
}
.modal-sheet h2 { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; margin-bottom: 14px; }
.modal-sheet p { font-size: 14.5px; line-height: 1.6; color: var(--ink-2); margin-bottom: 12px; }
.modal-switch a { color: var(--accent); text-decoration: none; font-weight: 600; }

/* ── Off-screen player ─────────────────────────────────────── */
#ytContainer {
  position: fixed; left: -9999px; top: -9999px;
  width: 200px; height: 200px; overflow: hidden; pointer-events: none;
}

@media (max-height: 740px) {
  .now-title { font-size: 26px; }
  .speaker-grille { width: 138px; height: 138px; }
  .set { gap: 16px; }
}
