/* Factory Radio: a late-70s hi-fi tuner in a dark club. Each station colours the room (--accent). */

@property --accent {
  syntax: '<color>';
  inherits: true;
  initial-value: #ffb23d;
}

:root {
  --accent: #ffb23d;
  --signal: 1;

  --night: #0b0a1a;
  --night-2: #120f2a;
  --panel: #1a1823;
  --panel-2: #121019;
  --panel-edge: rgba(255, 255, 255, 0.07);
  --text: #f6efe4;
  --muted: #a8a2b8;
  --faint: #6d6880;
  --amber: #ffb23d;
  --amber-soft: #d98c1f;
  --needle: #ff3b4f;
  --ink: #07060d;

  --font-display: 'Unbounded', 'Arial Black', sans-serif;
  --font-tech: 'Chakra Petch', 'Consolas', monospace;
  --font-body: 'Figtree', 'Segoe UI', sans-serif;

  --radius-l: 28px;
  --radius-m: 18px;
  --radius-s: 12px;
  --gutter: clamp(16px, 4vw, 56px);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --btn: 54px;
  --knob: 104px;
  --scale-inset: 3%; /* ticks, labels, markers and needle share this inner box */

  transition: --accent 900ms var(--ease-out);
  color-scheme: dark;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--night);
  color: var(--text);
  font: 400 16px/1.5 var(--font-body);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
a { color: inherit; }

/* ---------- Atmosphere ---------- */

.ambient {
  position: fixed;
  inset: -20vmax;
  z-index: -2;
  background:
    radial-gradient(40vmax 30vmax at 22% 18%, color-mix(in oklab, var(--accent) 26%, transparent), transparent 70%),
    radial-gradient(46vmax 36vmax at 85% 75%, color-mix(in oklab, var(--accent) 14%, #3b1c6e 30%), transparent 70%),
    linear-gradient(160deg, var(--night) 0%, var(--night-2) 55%, #170d2b 100%);
  animation: drift 26s ease-in-out infinite alternate;
}

.is-standby .ambient { filter: saturate(0.35) brightness(0.7); }

@keyframes drift {
  to { transform: translate3d(-3vmax, 2vmax, 0) scale(1.04); }
}

.grain {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.07;
  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='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- Masthead ---------- */

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 26px var(--gutter) 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand__mark {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 4px solid var(--accent);
  position: relative;
  box-shadow: 0 0 18px color-mix(in oklab, var(--accent) 60%, transparent);
}

.brand__mark::after {
  content: '';
  position: absolute;
  left: 50%;
  top: -4px;
  width: 4px;
  height: 14px;
  margin-left: -2px;
  border-radius: 2px;
  background: var(--needle);
}

.brand__name {
  font: 800 15px/1 var(--font-display);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.brand__name em {
  font-style: normal;
  color: var(--accent);
}

.masthead__meta {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: 600 12px/1 var(--font-tech);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--needle);
  box-shadow: 0 0 10px var(--needle);
  animation: pulse 1.8s ease-in-out infinite;
}

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

/* ---------- Page ---------- */

.page {
  max-width: 1440px;
  margin: 0 auto;
  padding: 28px var(--gutter) 40px;
  display: grid;
  gap: clamp(28px, 4vw, 48px);
}

/* ---------- Tuner panel ---------- */

.tuner {
  position: relative;
  padding: clamp(22px, 3.2vw, 44px) clamp(20px, 3.6vw, 56px) clamp(18px, 2.4vw, 30px);
  border-radius: var(--radius-l);
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.012) 0 1px, transparent 1px 3px),
    linear-gradient(180deg, #23202d 0%, var(--panel) 38%, var(--panel-2) 100%);
  border: 1px solid var(--panel-edge);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -1px 0 rgba(0, 0, 0, 0.6),
    0 40px 80px -30px rgba(0, 0, 0, 0.85),
    0 0 0 1px rgba(0, 0, 0, 0.4);
  animation: rise 900ms var(--ease-out) both;
}

/* Entrance in pure CSS: the content never depends on JavaScript to become visible */
@keyframes rise {
  from { opacity: 0; transform: translateY(18px); }
}

/* Four screws in the corners of the faceplate */
.tuner__screws i {
  position: absolute;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #5a5666, #1b1922 70%);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.6);
}

.tuner__screws i::after {
  content: '';
  position: absolute;
  inset: 4px 1px;
  background: rgba(0, 0, 0, 0.55);
  transform: rotate(35deg);
}

.tuner__screws i:nth-child(1) { top: 14px; left: 14px; }
.tuner__screws i:nth-child(2) { top: 14px; right: 14px; }
.tuner__screws i:nth-child(3) { bottom: 14px; left: 14px; }
.tuner__screws i:nth-child(4) { bottom: 14px; right: 14px; }

.tuner__top {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: clamp(16px, 2.6vw, 40px);
  margin-bottom: clamp(20px, 2.6vw, 34px);
}

/* Frequency readout: glowing amber digits */
.readout {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.readout__freq {
  font: 700 clamp(56px, 7.4vw, 104px)/0.9 var(--font-tech);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: var(--amber);
  text-shadow:
    0 0 18px rgba(255, 178, 61, 0.55),
    0 0 52px rgba(255, 140, 30, 0.35);
  min-width: 4.2ch;
  text-align: right;
  transition: color 400ms, text-shadow 400ms, opacity 400ms;
}

.readout__unit {
  font: 700 clamp(14px, 1.4vw, 20px)/1 var(--font-tech);
  letter-spacing: 0.1em;
  color: var(--faint);
}

.is-standby .readout__freq {
  color: #4a3a22;
  text-shadow: none;
}

.readout__now {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.readout__station {
  font: 800 clamp(18px, 1.9vw, 28px)/1.1 var(--font-display);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 300ms;
}

.is-searching.is-on .readout__station {
  color: var(--muted);
  animation: flicker 0.9s steps(2) infinite;
}

@keyframes flicker {
  50% { opacity: 0.55; }
}

.readout__track {
  font: 500 15px/1.3 var(--font-body);
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Signal meter */
.meter {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  height: 36px;
}

.meter i {
  width: 7px;
  border-radius: 3px;
  background: #2e2a38;
  transition: background 160ms, box-shadow 160ms;
}

.meter i:nth-child(1) { height: 22%; }
.meter i:nth-child(2) { height: 40%; }
.meter i:nth-child(3) { height: 58%; }
.meter i:nth-child(4) { height: 78%; }
.meter i:nth-child(5) { height: 100%; }

.meter i.is-lit {
  background: var(--amber);
  box-shadow: 0 0 10px rgba(255, 178, 61, 0.65);
}

/* Controls: round buttons around the big knob */
.controls {
  display: flex;
  align-items: center;
  gap: clamp(10px, 1.2vw, 18px);
}

.btn {
  flex: none;
  width: var(--btn);
  height: var(--btn);
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: linear-gradient(180deg, #2a2640, #17142a);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.09), 0 6px 16px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  transition: transform 160ms var(--ease-out), border-color 200ms, box-shadow 200ms, color 200ms;
}

.btn svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn:hover { border-color: color-mix(in oklab, var(--accent) 60%, transparent); }
.btn:active { transform: scale(0.94); }

.btn:focus-visible,
.knob:focus-visible,
.scale:focus-visible,
.marker:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.btn--power { color: var(--muted); }

.is-on:not(.is-blocked) .btn--power {
  color: var(--ink);
  background: radial-gradient(circle at 40% 35%, #ffd27a, var(--accent) 70%);
  border-color: transparent;
  box-shadow: 0 0 24px color-mix(in oklab, var(--accent) 70%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.is-standby .btn--power,
.is-blocked .btn--power { animation: invite 2.4s ease-in-out infinite; }

/* Big tap button over the scale while the browser still blocks sound */
.tap-to-listen {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 5;
  display: none;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 0 26px 0 20px;
  border: 0;
  border-radius: 999px;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 30% 30%, color-mix(in oklab, var(--accent) 70%, white), var(--accent) 70%);
  color: var(--ink);
  font: 700 15px/1 var(--font-tech);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 0 0 0 color-mix(in oklab, var(--accent) 50%, transparent), 0 14px 30px rgba(0, 0, 0, 0.55);
  animation: tap-pulse 1.8s ease-out infinite;
}

.tap-to-listen svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.is-blocked .tap-to-listen { display: inline-flex; }

@keyframes tap-pulse {
  70% { box-shadow: 0 0 0 16px transparent, 0 14px 30px rgba(0, 0, 0, 0.55); }
  100% { box-shadow: 0 0 0 0 transparent, 0 14px 30px rgba(0, 0, 0, 0.55); }
}

/* On, but the browser still blocks sound: the hint in the readout pulses in the station colour */
.is-blocked .readout__track {
  color: var(--accent);
  animation: flicker 1.6s ease-in-out infinite;
}

@keyframes invite {
  50% { box-shadow: 0 0 0 7px color-mix(in oklab, var(--accent) 22%, transparent), 0 6px 16px rgba(0, 0, 0, 0.45); }
}

.icon-muted { display: none; }
.is-muted .icon-muted { display: block; }
.is-muted .icon-sound { display: none; }
.is-muted #muteBtn { color: var(--needle); }

/* The knob: knurled metal with a glowing index dot */
.knob {
  position: relative;
  flex: none;
  width: var(--knob);
  height: var(--knob);
  border-radius: 50%;
  cursor: grab;
  touch-action: none;
  background: radial-gradient(circle, #121019 58%, #05040a 60%, #2c2938 66%, #0e0c15 72%);
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.knob.is-turning { cursor: grabbing; }

.knob__grip {
  position: absolute;
  inset: 9%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, #2b2834 0 46%, transparent 47%),
    repeating-conic-gradient(from 0deg, #4a4656 0deg 3deg, #18161f 3deg 6deg);
  box-shadow: inset 0 2px 3px rgba(255, 255, 255, 0.18), inset 0 -4px 8px rgba(0, 0, 0, 0.7);
  will-change: transform;
}

.knob__grip::after {
  /* light reflection that stays on top while the grip turns */
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 24%, rgba(255, 255, 255, 0.22), transparent 45%);
}

.knob__dot {
  position: absolute;
  top: 12%;
  left: 50%;
  width: 7px;
  height: 18px;
  margin-left: -3.5px;
  border-radius: 4px;
  background: var(--needle);
  box-shadow: 0 0 10px var(--needle);
}

.is-standby .knob__dot { background: #5b2a32; box-shadow: none; }

/* ---------- The scale ---------- */

.scale {
  position: relative;
  height: clamp(150px, 13vw, 176px);
  border-radius: var(--radius-m);
  background: linear-gradient(180deg, #05040a 0%, #0d0b13 60%, #17110a 100%);
  box-shadow:
    inset 0 2px 12px rgba(0, 0, 0, 0.9),
    inset 0 0 0 1px rgba(255, 255, 255, 0.05),
    0 1px 0 rgba(255, 255, 255, 0.05);
  overflow: hidden;
  cursor: ew-resize;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}

/* Inner box: ticks and labels keep a margin, so the edge labels stay inside the glass */
.scale__ticks,
.scale__labels,
.scale__stations,
.scale__needle-track {
  position: absolute;
  left: var(--scale-inset);
  right: var(--scale-inset);
}

.scale__viz {
  position: absolute;
  inset: auto 0 0 0;
  width: 100%;
  height: 70%;
  filter: blur(6px);
  opacity: 0.9;
  mix-blend-mode: screen;
}

.scale__labels {
  top: 14px;
  height: 18px;
}

.scale__label {
  position: absolute;
  transform: translateX(-50%);
  font: 700 13px/1 var(--font-tech);
  letter-spacing: 0.04em;
  color: var(--amber);
  text-shadow: 0 0 8px rgba(255, 178, 61, 0.55);
  transition: color 600ms, text-shadow 600ms;
}

.scale__ticks {
  top: 32px;
  height: 64px;
  width: calc(100% - 2 * var(--scale-inset)); /* an SVG needs an explicit width */
  overflow: visible;
}

.tick {
  stroke: var(--amber-soft);
  stroke-width: 1.2;
  vector-effect: non-scaling-stroke;
  opacity: 0.65;
  transition: stroke 600ms, opacity 600ms;
}

.tick--mid { opacity: 0.85; }

.tick--major {
  stroke: var(--amber);
  stroke-width: 2;
  opacity: 1;
  filter: drop-shadow(0 0 3px rgba(255, 178, 61, 0.7));
}

/* Standby: the lamps behind the scale are off */
.is-standby .scale__label { color: #5a4526; text-shadow: none; }
.is-standby .tick { stroke: #4d3a20; filter: none; }

/* Power on: the lamps warm up from left to right */
.is-on .scale__label,
.is-on .tick { animation: lamp-on 1.1s var(--ease-out) both; }

@keyframes lamp-on {
  0% { opacity: 0.15; }
  30% { opacity: 0.9; }
  45% { opacity: 0.4; }
  100% { opacity: 1; }
}

/* Station markers on the bottom rail */
.scale__stations {
  bottom: 0;
  height: 56px;
}

.marker {
  position: absolute;
  bottom: 0;
  transform: translateX(-50%);
  min-width: 44px;
  height: 56px;
  padding: 0 6px;
  display: grid;
  justify-items: center;
  align-content: end;
  gap: 4px;
  border: 0;
  background: none;
  cursor: pointer;
}

.marker__line {
  width: 30px;
  height: 4px;
  border-radius: 2px;
  background: var(--marker-color);
  opacity: 0.55;
  box-shadow: 0 0 10px var(--marker-color);
  transition: opacity 300ms, width 300ms var(--ease-out);
}

.marker__name {
  font: 700 10px/1 var(--font-tech);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: color-mix(in oklab, var(--marker-color) 75%, white);
  opacity: 0.6;
  padding-bottom: 10px;
  white-space: nowrap;
  transition: opacity 300ms;
}

.marker:hover .marker__line,
.marker.is-active .marker__line { opacity: 1; width: 42px; }

.marker:hover .marker__name,
.marker.is-active .marker__name { opacity: 1; }

.is-standby .marker { filter: grayscale(0.85) brightness(0.55); }

/* The needle: a red filament with a glow that grows with the signal */
.scale__needle {
  position: absolute;
  top: 8px;
  bottom: 8px;
  width: 4px;
  margin-left: -2px;
  border-radius: 2px;
  background: linear-gradient(180deg, #ff7a86, var(--needle) 30%, var(--needle) 85%, #a3121f);
  box-shadow:
    0 0 calc(8px + var(--signal) * 18px) rgba(255, 59, 79, calc(0.45 + var(--signal) * 0.45)),
    0 0 2px rgba(255, 255, 255, 0.6);
  pointer-events: none;
}

/* Same inner box as ticks and labels, so the needle lines up with the numbers */
.scale__needle-track {
  top: 0;
  bottom: 0;
  pointer-events: none;
}

.is-standby .scale__needle {
  background: #6e2630;
  box-shadow: none;
}

.scale__glass {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent 30%),
    linear-gradient(100deg, transparent 40%, rgba(255, 255, 255, 0.035) 50%, transparent 60%);
}

.tuner__hint {
  margin: 14px 0 0;
  text-align: center;
  font: 600 11px/1.4 var(--font-tech);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--faint);
}

/* ---------- Station panel ---------- */

.station {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: clamp(28px, 4vw, 64px);
  align-items: start;
  animation: rise 900ms 180ms var(--ease-out) both;
}

.station.is-switching .cover,
.station.is-switching .info > * {
  animation: swap 700ms var(--ease-out) both;
}

.station.is-switching .info > :nth-child(2) { animation-delay: 60ms; }
.station.is-switching .info > :nth-child(3) { animation-delay: 110ms; }
.station.is-switching .info > :nth-child(n + 4) { animation-delay: 160ms; }

@keyframes swap {
  from { opacity: 0; transform: translateY(12px); filter: blur(6px); }
}

.is-searching .station { filter: saturate(0.4); opacity: 0.75; transition: filter 400ms, opacity 400ms; }

/* Cover: the album art, square like a record sleeve, with the song title over it. The whole sleeve is shown
   (object-fit: contain); a blurred copy behind it fills the edges of sleeves that are not exactly square. */
.cover {
  position: relative;
  margin: 0;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-l);
  overflow: hidden;
  background: #151223;
  box-shadow:
    0 50px 90px -40px color-mix(in oklab, var(--accent) 55%, transparent),
    0 30px 60px -30px rgba(0, 0, 0, 0.9);
  isolation: isolate;
}

.cover__backdrop {
  position: absolute;
  inset: -10%;
  width: 120%;
  height: 120%;
  object-fit: cover;
  filter: blur(28px) saturate(1.25) brightness(0.55);
}

.cover__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform 6s var(--ease-out), opacity 400ms var(--ease-out);
}

.cover:hover .cover__img { transform: scale(1.03); }

.cover::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(8, 6, 18, 0.35) 0%, transparent 30%, transparent 45%, rgba(8, 6, 18, 0.92) 100%),
    linear-gradient(90deg, color-mix(in oklab, var(--accent) 22%, transparent), transparent 60%);
  z-index: 1;
}

/* Fallback when there is no album art: a glowing record in the station colour */
.cover__fallback {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  background:
    radial-gradient(circle at 70% 60%, color-mix(in oklab, var(--accent) 40%, transparent) 0 6%, transparent 6.5%),
    repeating-radial-gradient(circle at 70% 60%, #17141f 0 3px, #0f0d16 3px 6px),
    #0f0d16;
}

.cover__fallback span {
  font: 900 clamp(120px, 18vw, 260px)/1 var(--font-display);
  color: color-mix(in oklab, var(--accent) 80%, transparent);
  opacity: 0.18;
  transform: translate(-28%, 6%);
}

.cover.is-missing .cover__img,
.cover.is-missing .cover__backdrop { display: none; }
.cover.is-missing .cover__fallback { display: grid; }

.cover__caption {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  gap: 4px;
  padding: clamp(20px, 3vw, 36px);
}

.cover__live { grid-row: 1; }
.cover__title { grid-row: 3; }
.cover__tagline { grid-row: 4; }

.cover__live {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-self: start;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(7, 6, 13, 0.6);
  backdrop-filter: blur(8px);
  font: 700 11px/1 var(--font-tech);
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

/* Another station on air (MFM on Thursday evening): the badge in MFM's own blue and pink. */
.is-guest-broadcast .cover__live {
  --guest-blue: #1fb4f0;
  --guest-pink: #f45ce0;
  background: linear-gradient(100deg, color-mix(in oklab, var(--guest-blue) 85%, transparent),
                                      color-mix(in oklab, var(--guest-pink) 85%, transparent));
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.is-guest-broadcast .cover__live .dot { background: #fff; }

.cover__title {
  font: 800 clamp(24px, 2.8vw, 42px)/1.08 var(--font-display);
  letter-spacing: -0.02em;
  text-shadow: 0 4px 30px rgba(0, 0, 0, 0.6);
  overflow-wrap: anywhere;
}

.cover__tagline {
  font: 500 clamp(16px, 1.6vw, 22px)/1.25 var(--font-body);
  color: color-mix(in oklab, var(--accent) 45%, #f6efe4);
}

/* Info column */
.info {
  min-width: 0;
  container-type: inline-size; /* the station name scales to this column (cqi) */
}

.info__eyebrow {
  margin: 0 0 6px;
  font: 700 15px/1 var(--font-tech);
  letter-spacing: 0.22em;
  color: var(--accent);
}

.info__name {
  /* Letters of the longest word (set by view.js). A name of one long word (StarGuardz) shrinks until that word fits
     the column, instead of breaking in the middle. 0.8em per letter: measured width 0.74em plus the skew. */
  --name-chars: 6;
  margin: 0;
  font: 900 italic clamp(44px, 6.2vw, 92px)/0.95 var(--font-display);
  font-size: min(clamp(44px, 6.2vw, 92px), 100cqi / (var(--name-chars) * 0.8));
  letter-spacing: -0.035em;
  font-synthesis: style;
  transform: skewX(-6deg);
  transform-origin: left bottom;
  background: linear-gradient(180deg, #fff6e6 30%, color-mix(in oklab, var(--accent) 45%, #fff6e6));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  overflow-wrap: anywhere;
}

.info__desc {
  margin: 14px 0 26px;
  max-width: 46ch;
  font-size: 18px;
  color: var(--muted);
}

.label {
  margin: 0 0 12px;
  font: 700 12px/1 var(--font-tech);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Now playing card */
.now {
  padding: 18px 20px 16px;
  margin-bottom: 28px;
  border-radius: var(--radius-m);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.02));
  border: 1px solid rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(12px);
}

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

.now__art {
  flex: none;
  width: 64px;
  height: 64px;
  border-radius: var(--radius-s);
  object-fit: cover;
  background: linear-gradient(135deg, color-mix(in oklab, var(--accent) 50%, #1a1626), #1a1626);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
}

.now__text {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.now__title {
  font-size: 19px;
  font-weight: 700;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.now__artist { color: var(--muted); }

.progress {
  height: 4px;
  margin-top: 16px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.progress span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, color-mix(in oklab, var(--accent) 60%, transparent), var(--accent));
  box-shadow: 0 0 12px var(--accent);
  transform-origin: left;
  transform: scaleX(0);
  transition: transform 1s linear;
}

.now__times {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font: 600 12px/1 var(--font-tech);
  font-variant-numeric: tabular-nums;
  color: var(--faint);
}

/* Temporary test button "Volgend nummer", only with ?test in the URL (js/skip-test.js) */
.skip-test {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed rgba(255, 255, 255, 0.1);
}

.skip-test__btn {
  min-height: 36px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid color-mix(in oklab, var(--accent) 45%, transparent);
  background: linear-gradient(180deg, #2a2640, #17142a);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.09), 0 6px 16px rgba(0, 0, 0, 0.45);
  color: var(--accent);
  font: 700 12px/1 var(--font-tech);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 160ms var(--ease-out), border-color 200ms, opacity 200ms;
}

.skip-test__btn:hover { border-color: var(--accent); }
.skip-test__btn:active { transform: scale(0.96); }
.skip-test__btn:disabled { opacity: 0.5; cursor: progress; }

.skip-test__btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.skip-test__status {
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
}

.skip-test__login {
  color: var(--accent);
  text-underline-offset: 3px;
  overflow-wrap: anywhere;
}

/* History list */
.history {
  list-style: none;
  margin: 0 0 26px;
  padding: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.history__item {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 12px 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  animation: swap 600ms calc(var(--i) * 60ms) var(--ease-out) both;
}

.history__art {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: center / cover no-repeat, radial-gradient(circle, #0b0a12 0 14%, #24202f 15% 100%);
  background-color: #24202f;
  border: 1px solid color-mix(in oklab, var(--accent) 40%, transparent);
}

.history__text {
  display: grid;
  min-width: 0;
}

.history__text strong,
.history__text span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history__text strong { font-weight: 600; }
.history__text span { color: var(--muted); font-size: 14px; }

.history__when {
  font: 600 12px/1 var(--font-tech);
  color: var(--faint);
  white-space: nowrap;
}

.streams {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 0;
}

.streams .label { margin: 0 6px 0 0; }

.streams a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  font: 700 12px/1 var(--font-tech);
  letter-spacing: 0.1em;
  text-decoration: none;
  transition: border-color 200ms, background 200ms;
}

.streams a:hover {
  border-color: var(--accent);
  background: color-mix(in oklab, var(--accent) 14%, transparent);
}

.footer {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 var(--gutter) 32px;
  font: 600 11px/1.4 var(--font-tech);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--faint);
}

.footer p { margin: 0; }

/* ---------- Small desktop: the controls get their own row, so the station name has room ---------- */

@media (max-width: 1240px) {
  .tuner__top {
    grid-template-columns: auto minmax(0, 1fr) auto;
    row-gap: 22px;
  }

  .controls {
    grid-column: 1 / -1;
    justify-content: center;
  }
}

/* ---------- Tablet ---------- */

@media (max-width: 980px) {
  :root { --knob: 92px; --btn: 48px; }

  .station { grid-template-columns: minmax(0, 1fr); }

  /* One column: the square sleeve would get very tall, so it stays at most 520 px wide, aligned with the text. */
  .cover { width: min(100%, 520px); justify-self: start; }

  .info__desc { max-width: none; }

  .skip-test { margin-top: 12px; padding-top: 12px; }
}

/* ---------- Mobile portrait ---------- */

@media (max-width: 640px) {
  :root { --knob: 84px; --btn: 44px; --radius-l: 22px; }

  .masthead { padding-top: 18px; }
  .page { padding-top: 18px; }

  .tuner__top {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 14px 12px;
  }

  .readout__freq { font-size: clamp(48px, 15vw, 64px); }

  .readout__now {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .meter { height: 28px; }

  .scale { height: 140px; }
  .scale__label--minor { display: none; }
  .scale__label { font-size: 12px; }
  .marker__name { font-size: 9px; letter-spacing: 0.12em; }

  .info__desc { font-size: 16px; margin-bottom: 20px; }
  .now { padding: 14px 16px; }
  .now__art { width: 56px; height: 56px; }
  .now__title { font-size: 17px; }

  .skip-test__btn { min-height: 40px; }
  .skip-test__status { font-size: 12px; }
}

/* ---------- Narrow phones ---------- */

@media (max-width: 420px) {
  :root { --knob: 72px; --btn: 40px; --gutter: 16px; }

  .masthead__meta { font-size: 10px; letter-spacing: 0.12em; }
  .brand__name { font-size: 13px; white-space: nowrap; }
  .masthead__meta { white-space: nowrap; }
  .masthead__meta-text { display: none; }

  /* Stations sit close together on a narrow scale: only the tuned one shows its name */
  :root { --scale-inset: 6%; }
  .marker__name { opacity: 0; }
  .marker.is-active .marker__name { opacity: 1; }

  .tuner { padding: 20px 14px 14px; }
  .tuner__screws { display: none; }

  .controls { gap: 8px; }
  .btn svg { width: 19px; height: 19px; }

  .readout__freq { font-size: 15vw; }

  .scale { height: 128px; }
  .marker { min-width: 36px; padding: 0 2px; }
  .marker__line { width: 22px; }
  .marker__name { letter-spacing: 0.06em; }

  .cover { width: 100%; }
  .cover__caption { padding: 18px; }

  .history__item { grid-template-columns: 40px minmax(0, 1fr); }
  .history__art { width: 40px; height: 40px; }
  .history__when { grid-column: 2; font-size: 11px; }

  .skip-test__btn { width: 100%; }
}

/* Diagnostics, only with ?debug in the URL */
.debug-panel {
  position: fixed;
  inset: auto 8px 8px 8px;
  z-index: 50;
  max-height: 55vh;
  overflow: auto;
  margin: 0;
  padding: 10px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.88);
  color: #9ef5a8;
  font: 11px/1.35 ui-monospace, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-all;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}
