/* ==========================================================================
   JMP Radio – tokens: kleuren, radii, schaduwen, typografie en glas
   ========================================================================== */

/* Kleuren zijn geregistreerde custom properties, zodat ze kunnen overvloeien:
   bij een zenderwissel (1,2 s) en tussen licht en donker (1,4 s). */
@property --accent      { syntax: '<color>'; inherits: true; initial-value: #e2001a; }
@property --accent-ui   { syntax: '<color>'; inherits: true; initial-value: #e2001a; }
@property --accent-text { syntax: '<color>'; inherits: true; initial-value: #e2001a; }
@property --accent-2    { syntax: '<color>'; inherits: true; initial-value: #a30013; }
@property --art         { syntax: '<color>'; inherits: true; initial-value: #e2001a; }
@property --bg          { syntax: '<color>'; inherits: true; initial-value: #ffffff; }
@property --text        { syntax: '<color>'; inherits: true; initial-value: #111114; }
@property --text-2      { syntax: '<color>'; inherits: true; initial-value: rgba(60, 60, 67, .76); }
@property --text-3      { syntax: '<color>'; inherits: true; initial-value: rgba(60, 60, 67, .46); }
@property --glass-bg    { syntax: '<color>'; inherits: true; initial-value: rgba(255, 255, 255, .55); }

:root {
  color-scheme: light dark;

  /* De accentkleur volgt de huidige zender; main.js zet deze vijf waarden. */
  --accent: #e2001a;          /* de huisstijlkleur zelf: gloed, tint, schaduw */
  --accent-ui: #e2001a;       /* vlakken, ringen, iconen (contrast ≥ 3) */
  --accent-text: #e2001a;     /* kleine tekst (contrast ≥ 4,5) */
  --on-accent: #ffffff;       /* tekst en iconen op een accentvlak */
  --accent-2: #a30013;        /* tweede kleur (titelsticker, screensaver) */
  --on-accent-2: #ffffff;
  --art: #e2001a;             /* dominante kleur van de artwork */

  /* Licht thema */
  --bg: #ffffff;
  --text: #111114;
  --text-2: rgba(60, 60, 67, .76);
  --text-3: rgba(60, 60, 67, .46);
  --glass-bg: rgba(255, 255, 255, .55);
  --glass-solid: rgba(248, 248, 250, .94);     /* fallback zonder backdrop-filter */
  --glass-edge-top: rgba(255, 255, 255, .55);
  --glass-edge-bottom: rgba(255, 255, 255, .08);
  --hairline: rgba(0, 0, 0, .06);
  --fill-quiet: rgba(120, 120, 128, .12);
  --inset: rgba(120, 120, 128, .08);
  --plate: #ffffff;                            /* het plaatje achter een zenderlogo */
  --raised: #ffffff;
  --shadow-glass: 0 8px 32px rgba(0, 0, 0, .22);
  --shadow-soft: 0 4px 18px rgba(0, 0, 0, .09);
  --orange: #ff9500;
  --red: #ff3b30;

  --radius-card: 22px;
  --radius-row: 22px;
  --radius-panel: 36px;

  --font: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --spring: cubic-bezier(.2, .8, .2, 1);
  --t-press: 250ms;
  --t-move: 450ms;
  --t-slow: 550ms;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);

  transition:
    --accent 1.2s ease-in-out, --accent-ui 1.2s ease-in-out, --accent-text 1.2s ease-in-out,
    --accent-2 1.2s ease-in-out, --art 1.2s ease-in-out,
    --bg 1.4s ease-in-out, --text 1.4s ease-in-out, --text-2 1.4s ease-in-out,
    --text-3 1.4s ease-in-out, --glass-bg 1.4s ease-in-out;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --text: #f5f5f7;
    --text-2: rgba(235, 235, 245, .72);
    --text-3: rgba(235, 235, 245, .42);
    --glass-bg: rgba(30, 30, 30, .5);
    --glass-solid: rgba(30, 30, 32, .94);
    --glass-edge-top: rgba(255, 255, 255, .28);
    --glass-edge-bottom: rgba(255, 255, 255, .04);
    --hairline: rgba(255, 255, 255, .08);
    --fill-quiet: rgba(120, 120, 128, .22);
    --inset: rgba(120, 120, 128, .14);
    --plate: #f7f7f9;
    --raised: #3a3a3e;
    --shadow-soft: 0 4px 18px rgba(0, 0, 0, .4);
  }
}

/* ------------------------------------------------------------------ basis */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.35;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

h1, h2, h3, p, figure { margin: 0; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

button, input, select {
  font: inherit;
  color: inherit;
}

button {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

button:disabled { cursor: default; opacity: .45; }

/* Zichtbare focusring in de accentkleur, alleen bij toetsenbordgebruik. */
:focus { outline: none; }
:focus-visible {
  outline: 3px solid var(--accent-ui);
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.icon {
  width: 1.375rem;
  height: 1.375rem;
  flex: none;
  display: block;
}

.boot-error {
  position: fixed;
  inset: auto 1rem 1rem;
  z-index: 100;
  padding: 1rem 1.25rem;
  border-radius: 1rem;
  background: var(--red);
  color: #fff;
  font-weight: 600;
  text-align: center;
}

/* ------------------------------------------------------------------- glas */

/* Eén herbruikbare glaslaag: vervaagde achtergrond, een tint in de accentkleur
   en een rand die van boven (licht) naar onder (bijna weg) verloopt.
   De zenderrijen in de lijst gebruiken dezelfde regels (zie components.css). */
.glass {
  --tint: var(--accent);
  --tint-amount: 16%;
  position: relative;
  border-radius: var(--radius-card);
  background-color: var(--glass-bg);
  background-image: linear-gradient(color-mix(in srgb, var(--tint) var(--tint-amount), transparent) 0 0);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
  box-shadow: var(--shadow-glass), 0 0 0 .5px var(--hairline);
}

/* De rand van 1 px: een verloop, uitgesneden met een mask zodat alleen de rand overblijft. */
.glass::before {
  content: "";
  position: absolute;
  inset: 0;
  padding: 1px;
  border-radius: inherit;
  background: linear-gradient(180deg, var(--glass-edge-top), var(--glass-edge-bottom));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  pointer-events: none;
}

/* Miniplayer en processing-card: getint met de dominante kleur van de artwork. */
.glass--art {
  --tint: var(--art);
  --tint-amount: 28%;
}

/* Zonder backdrop-filter: een effen, iets transparante achtergrond. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass { background-color: var(--glass-solid); }
}

/* ----------------------------------------------------- kleine bouwstenen */

/* Ronde glazen knop (tandwiel, uitvoer, zijbalk). Veert in bij indrukken. */
.icon-button {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  flex: none;
  border-radius: 50%;
  color: var(--accent-ui);
  transition: transform var(--t-press) var(--spring);
}
.icon-button.glass { box-shadow: var(--shadow-soft), 0 0 0 .5px var(--hairline); }
.icon-button:active { transform: scale(.92); }

.spinner {
  display: block;
  width: 1.375rem;
  height: 1.375rem;
  border: 2.5px solid color-mix(in srgb, currentColor 25%, transparent);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

/* Live-puntje met een ring die in 1,4 s uitdijt en vervaagt. Grijs als er niets live is. */
.live-dot {
  position: relative;
  flex: none;
  width: .5rem;
  height: .5rem;
  border-radius: 50%;
  background: var(--text-3);
}
[data-status="live"] .live-dot,
.is-live .live-dot,
.is-active .live-dot { background: var(--accent-ui); }
[data-status="live"] .live-dot::after,
.is-live .live-dot::after,
.is-active .live-dot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1.5px solid var(--accent-ui);
  animation: pulse 1.4s ease-out infinite;
}

/* De golfvorm: de staafjes lichten om de beurt op zolang iets speelt. */
.wave .wave__bar { opacity: .4; }
.is-waving .wave .wave__bar,
.wave.is-waving .wave__bar { animation: wave 1.2s ease-in-out infinite; }
.wave .wave__bar:nth-child(2) { animation-delay: .14s; }
.wave .wave__bar:nth-child(3) { animation-delay: .28s; }
.wave .wave__bar:nth-child(4) { animation-delay: .42s; }
.wave .wave__bar:nth-child(5) { animation-delay: .56s; }

/* Schuifregelaar: de gevulde kant in de accentkleur (--fill komt uit JavaScript). */
.range {
  --fill: 50%;
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 1.75rem;
  margin: 0;
  background: transparent;
  cursor: pointer;
  touch-action: pan-y;
}
.range::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent-ui) var(--fill), var(--fill-quiet) var(--fill));
}
.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 1.5rem;
  height: 1.5rem;
  margin-top: calc(3px - .75rem);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .28), 0 0 0 .5px rgba(0, 0, 0, .1);
  transition: transform var(--t-press) var(--spring);
}
.range:active::-webkit-slider-thumb { transform: scale(1.12); }
.range::-moz-range-track {
  height: 6px;
  border-radius: 3px;
  background: var(--fill-quiet);
}
.range::-moz-range-progress {
  height: 6px;
  border-radius: 3px;
  background: var(--accent-ui);
}
.range::-moz-range-thumb {
  width: 1.5rem;
  height: 1.5rem;
  border: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .28), 0 0 0 .5px rgba(0, 0, 0, .1);
}
.range:disabled { opacity: .4; cursor: default; }
.range:focus-visible { outline-offset: 6px; border-radius: 8px; }

/* Schakelaar in iOS-stijl. */
.switch {
  position: relative;
  display: block;
  flex: none;
  width: 3.1875rem;
  height: 1.9375rem;
  cursor: pointer;
}
.switch__input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.switch__track {
  position: absolute;
  inset: 0;
  border-radius: 1rem;
  background: var(--fill-quiet);
  box-shadow: inset 0 0 0 1px var(--hairline);
  transition: background-color var(--t-press) ease;
  pointer-events: none;
}
.switch__track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: calc(1.9375rem - 4px);
  height: calc(1.9375rem - 4px);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .28);
  transition: transform var(--t-move) var(--spring);
}
.switch__input:checked + .switch__track { background: var(--accent-ui); }
.switch__input:checked + .switch__track::after { transform: translateX(1.25rem); }
.switch__input:focus-visible + .switch__track { outline: 3px solid var(--accent-ui); outline-offset: 3px; }

/* Knoppen in Instellingen. */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  min-height: 2.75rem;
  padding: .625rem 1.125rem;
  border-radius: .875rem;
  background: var(--fill-quiet);
  font-weight: 600;
  font-size: .9375rem;
  transition: transform var(--t-press) var(--spring), background-color var(--t-press) ease;
}
.button:not(:disabled):active { transform: scale(.97); }
.button .icon { width: 1.125rem; height: 1.125rem; }
.button--primary { background: var(--accent-ui); color: var(--on-accent); }
.button--quiet { background: var(--inset); }
.button--danger { background: color-mix(in srgb, var(--red) 14%, transparent); color: var(--red); }
.button--wide { width: 100%; }
.button--link {
  align-self: flex-start;
  min-height: 2.25rem;
  padding: .25rem .5rem;
  margin-left: -.5rem;
  background: none;
  color: var(--accent-text);
}

/* ------------------------------------------------------------- animaties */

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse {
  from { transform: scale(1); opacity: .9; }
  to { transform: scale(2.4); opacity: 0; }
}
@keyframes wave {
  0%, 100% { opacity: .4; }
  40% { opacity: 1; }
}
@keyframes pop {
  0% { transform: scale(.86); }
  60% { transform: scale(1.06); }
  100% { transform: scale(1); }
}
@keyframes rise {
  from { transform: translateY(1.75rem); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@keyframes art-in {
  from { transform: scale(.94); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@keyframes flash {
  0% { opacity: 0; }
  15% { opacity: 1; }
  100% { opacity: 0; }
}
@keyframes drift {
  from { transform: scale(1.5) translate(-4%, -3%) rotate(-6deg); }
  to { transform: scale(1.7) translate(5%, 4%) rotate(8deg); }
}
@keyframes float-a {
  from { transform: translate(-12%, -10%) scale(1); }
  to { transform: translate(18%, 14%) scale(1.25); }
}
@keyframes float-b {
  from { transform: translate(10%, 12%) scale(1.2); }
  to { transform: translate(-16%, -12%) scale(.95); }
}

/* Weinig beweging gevraagd: geen pan en geen bewegende achtergrond, alleen fades. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
  :root { --t-press: 1ms; --t-move: 1ms; --t-slow: 1ms; }
}
