/*
 * RadioLibre — radiolibre.altred.xyz
 *
 * Extracted from the inline <style> block the page used to carry. The visual
 * design is unchanged: black ground, white type, inverted logo, pill nav.
 *
 * Rules for the old "Bloque 79" section were dropped — that markup no longer
 * exists on the page, so they styled nothing.
 */

@font-face {
  font-family: 'ZKM Serendipity';
  src: url('https://zkm.de/themes/custom/zkm/typeface/WiP_ZKMSerendipity/ZKMSerendipity-Medium.woff') format('woff');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #000;
  --fg: #fff;
  --fg-dim: #ccc;
  --surface: #222;
  --border: rgba(255, 255, 255, 0.6);
  --glow: rgba(255, 255, 255, 0.3);
  --warn: #ff9b9b;
  --muted: #8a8a8a;
  --hairline: rgba(255, 255, 255, 0.25);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  /* The centre column: live streams and chat share it, under the tagline. */
  --column: 640px;
  --alert: #c0392b;
}

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

body {
  font-family: 'ZKM Serendipity', Arial, Helvetica, sans-serif;
  background-color: var(--bg);
  color: var(--fg);
  margin: 0;
  padding: 15px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  justify-content: space-between;
  /* Native form and media controls follow this rather than rendering light. */
  color-scheme: dark;
}

.main-content-wrapper {
  /* Takes the free height, so the nav and the credits sit together at the bottom. */
  flex: 1 0 auto;
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  padding: 0 15px;
  text-align: left;
}

/* ---------------------------------------------------------------- typography */

h1 {
  font-size: 2.85em;
  text-align: center;
  margin-bottom: 20px;
  text-transform: uppercase;
  letter-spacing: 2px;
  /* Sits above the logo, which is pulled up underneath it. */
  position: relative;
  z-index: 1;
}

p {
  line-height: 1.5;
  margin-bottom: 12px;
  text-align: center;
  max-width: 640px;
  margin-left: auto;
  margin-right: auto;
}

/* Was an <h3> nested inside a <p>, which is invalid; it was only ever there
   for its size and weight. */
.tagline {
  font-size: 1.17em;
  font-weight: bold;
  /* Wider than other paragraphs so the Spanish lead fits on one line. */
  max-width: 760px;
}

.tagline span {
  display: block;
}

/* Three lines at any width: the first two shrink with the viewport instead
   of wrapping (about 80 and 70 characters across the column). */
.tagline__lead,
.tagline__en {
  white-space: nowrap;
}

.tagline__lead {
  font-size: clamp(7px, 2.05vw, 0.82em);
  margin-bottom: 4px;
}

.tagline__en {
  font-size: clamp(8px, 2.3vw, 0.92em);
}

.tagline__tag {
  margin-top: 2px;
}

a {
  color: var(--fg);
  text-decoration: none;
  transition: color 0.3s ease, background-color 0.3s ease;
}

a:hover {
  color: var(--fg-dim);
}

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

.content {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.main-image {
  /* Pulls the title down over the logo. */
  margin-bottom: -25px;
  text-align: center;
  width: 100%;
  position: relative;
  z-index: 0;
}

.main-image img {
  max-width: 350px;
  height: auto;
  border-radius: 10px;
  border: 2px solid var(--fg);
  box-shadow: 0 0 15px var(--glow);
  filter: invert(100%);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  display: inline-block;
  margin: 0 auto;
}

.main-image img:hover {
  transform: scale(1.25);
  box-shadow: 0 0 25px rgba(255, 255, 255, 0.5);
}

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

/*
 * One card per live mount. Idle cards are outlined like the nav pills; the
 * card that is playing inverts to white, the same move the nav makes on hover,
 * so the one you are listening to is unmistakable from across the room.
 */

.stations {
  width: 100%;
  max-width: var(--column);
  margin: 30px auto;
}

.stations__title {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 0 14px;
  font-size: 0.8em;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--fg-dim);
}

/* Hairline that runs out from the heading to the edge. */
.stations__title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, var(--border), transparent);
}

.stations__message {
  margin: 0 auto;
  max-width: none;
  padding: 22px 16px;
  border: 1px dashed var(--border);
  border-radius: 18px;
  font-size: 0.9em;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--fg-dim);
}

.stations__message[data-state='error'] {
  color: var(--warn);
  border-color: currentColor;
}

.stations__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.station {
  --ink: var(--fg);
  --paper: var(--bg);
  --muted: var(--fg-dim);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 14px 20px 14px 14px;
  color: var(--ink);
  background-color: var(--paper);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: background-color 0.35s ease, color 0.35s ease, box-shadow 0.35s ease, border-color 0.35s ease;
}

.station:hover {
  border-color: var(--fg);
  box-shadow: 0 0 15px var(--glow);
}

.station[data-state='playing'],
.station[data-state='connecting'],
.station[data-state='reconnecting'] {
  --ink: var(--bg);
  --paper: var(--fg);
  --muted: #555;
  border-color: var(--fg);
  box-shadow: 0 0 28px rgba(255, 255, 255, 0.35);
}

/* --- play / pause */

.station__toggle {
  position: relative;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: var(--paper);
  background-color: var(--ink);
  cursor: pointer;
  transition: transform 0.2s ease, background-color 0.35s ease, color 0.35s ease;
}

.station__toggle:hover {
  transform: scale(1.08);
}

.station__toggle:active {
  transform: scale(0.95);
}

.station__icon {
  grid-area: 1 / 1;
  display: grid;
}

.station__icon svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.station__icon--pause,
.station[data-state='playing'] .station__icon--play,
.station[data-state='connecting'] .station__icon--play,
.station[data-state='reconnecting'] .station__icon--play {
  display: none;
}

.station[data-state='playing'] .station__icon--pause,
.station[data-state='connecting'] .station__icon--pause,
.station[data-state='reconnecting'] .station__icon--pause {
  display: grid;
}

/* A ring that spins while the stream is connecting, and breathes once live. */
.station__ring {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid transparent;
  pointer-events: none;
}

.station[data-state='connecting'] .station__ring,
.station[data-state='reconnecting'] .station__ring {
  border-color: var(--ink) transparent transparent transparent;
  animation: spin 0.9s linear infinite;
}

.station[data-state='playing'] .station__ring {
  border-color: var(--ink);
  animation: breathe 2.4s ease-out infinite;
}

/* --- name, now playing, status */

.station__info {
  min-width: 0;
}

.station__head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.station__name {
  margin: 0;
  font-size: 1.15em;
  letter-spacing: 1px;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.station__now,
.station__status {
  margin: 3px 0 0;
  max-width: none;
  text-align: left;
  font-size: 0.85em;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.station__now::before {
  content: '♪ ';
}

.station__status {
  font-size: 0.72em;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
}

.station[data-state='reconnecting'] .station__status,
.station[data-state='error'] .station__status {
  color: var(--alert);
}

.station[data-state='error'] {
  border-color: var(--warn);
}

.station__retry {
  margin-top: 8px;
  font-family: inherit;
  font-size: 0.72em;
  font-weight: bold;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--ink);
  background: transparent;
  border: 1px solid currentColor;
  border-radius: 25px;
  padding: 6px 14px;
  cursor: pointer;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.station__retry:hover {
  background-color: var(--ink);
  color: var(--paper);
}

/* Four bars that dance only while audio is actually arriving. */
.station__bars {
  display: none;
  align-items: flex-end;
  gap: 2px;
  height: 14px;
  flex: none;
}

.station__bars i {
  width: 3px;
  height: 100%;
  background-color: currentColor;
  transform-origin: bottom;
  animation: bounce 0.9s ease-in-out infinite;
}

.station__bars i:nth-child(2) { animation-delay: -0.45s; animation-duration: 0.7s; }
.station__bars i:nth-child(3) { animation-delay: -0.2s; animation-duration: 1.1s; }
.station__bars i:nth-child(4) { animation-delay: -0.6s; animation-duration: 0.8s; }

.station[data-state='playing'] .station__bars {
  display: inline-flex;
}

/* --- listeners, format, volume */

.station__side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.station__facts {
  display: flex;
  gap: 10px;
  margin: 0;
  font-size: 0.7em;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

/* Listener count as a small person glyph, drawn in CSS so it takes the ink. */
.station__listeners::before {
  content: '';
  display: inline-block;
  width: 0.8em;
  height: 0.9em;
  margin-right: 4px;
  vertical-align: -0.05em;
  background-color: currentColor;
  -webkit-mask: radial-gradient(circle at 50% 28%, #000 0 25%, transparent 26%),
    radial-gradient(ellipse at 50% 100%, #000 0 48%, transparent 49%);
  mask: radial-gradient(circle at 50% 28%, #000 0 25%, transparent 26%),
    radial-gradient(ellipse at 50% 100%, #000 0 48%, transparent 49%);
}

.station__volume {
  display: flex;
  align-items: center;
  gap: 8px;
}

.station__mute {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
}

.station__mute svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.station__mute .cross,
.station__mute[data-muted='true'] .wave {
  display: none;
}

.station__mute[data-muted='true'] .cross {
  display: inline;
}

/* The range input, redrawn: a hairline track that fills up to the thumb. */
.station__slider {
  -webkit-appearance: none;
  appearance: none;
  width: 110px;
  height: 20px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}

.station__slider::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 3px;
  background: linear-gradient(to right, var(--ink) var(--level, 80%), color-mix(in srgb, var(--ink) 25%, transparent) var(--level, 80%));
}

.station__slider::-moz-range-track {
  height: 3px;
  border-radius: 3px;
  background: color-mix(in srgb, var(--ink) 25%, transparent);
}

.station__slider::-moz-range-progress {
  height: 3px;
  border-radius: 3px;
  background: var(--ink);
}

.station__slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -5.5px;
  border-radius: 50%;
  background: var(--ink);
  border: 2px solid var(--paper);
  box-shadow: 0 0 0 1px var(--ink);
  transition: transform 0.15s ease;
}

.station__slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--ink);
  border: 2px solid var(--paper);
  box-shadow: 0 0 0 1px var(--ink);
}

.station__slider:hover::-webkit-slider-thumb,
.station__slider:focus-visible::-webkit-slider-thumb {
  transform: scale(1.25);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes breathe {
  0% { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(1.35); opacity: 0; }
}

@keyframes bounce {
  0%, 100% { transform: scaleY(0.25); }
  50% { transform: scaleY(1); }
}

@media (prefers-reduced-motion: reduce) {
  .station__bars i,
  .station__ring {
    animation: none !important;
  }
  .main-image img,
  a,
  .station,
  .station__toggle {
    transition: none;
  }
}

/* Visible keyboard focus, which the original stylesheet never provided. */
.station__toggle:focus-visible,
.station__mute:focus-visible,
.station__retry:focus-visible,
.station__slider:focus-visible,
nav a:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 3px;
}

.station[data-state='playing'] :focus-visible,
.station[data-state='connecting'] :focus-visible,
.station[data-state='reconnecting'] :focus-visible {
  outline-color: var(--bg);
}

/* --------------------------------------------------------------------- chat */

/* Components set display:flex/grid, which would otherwise beat [hidden]. */
[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.chat-panel {
  width: 100%;
  max-width: var(--column);
  margin: 0 auto 30px;
}

.chat__join,
.chat__say {
  display: flex;
  gap: 8px;
}

.chat__join input,
.chat__say input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 16px; /* below 16px iOS zooms the page on focus */
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 25px;
  padding: 10px 16px;
}

.chat__join input::placeholder,
.chat__say input::placeholder {
  color: var(--muted);
}

.chip {
  font: inherit;
  font-size: 0.85em;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--bg);
  background: var(--fg);
  border: 1px solid var(--fg);
  border-radius: 25px;
  padding: 10px 20px;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
}

.chip:hover {
  background: var(--bg);
  color: var(--fg);
  box-shadow: 0 0 15px var(--glow);
}

.chat__status {
  margin: 0 0 8px;
  max-width: none;
  text-align: left;
  font-size: 0.75em;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
}

.chat__status[data-state='error'] {
  color: var(--warn);
}

.chat__log {
  list-style: none;
  margin: 0 0 10px;
  padding: 12px 14px;
  height: 40vh;
  min-height: 200px;
  max-height: 420px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--border);
  border-radius: 18px;
  font-family: var(--mono);
  font-size: 0.85em;
  line-height: 1.45;
  text-align: left;
  overflow-wrap: anywhere;
}

.chat__log li {
  margin: 0 0 2px;
}

.chat__time {
  color: var(--muted);
  margin-right: 6px;
}

.chat__nick {
  font-weight: bold;
}

.chat__nick::after {
  content: ' ';
}

.chat__log .is-self .chat__nick {
  text-decoration: underline;
}

.chat__log .is-event {
  color: var(--muted);
  font-style: italic;
}

.chat__log .is-action {
  font-style: italic;
}

/* The last lines from before you arrived (from reporta's bitácora): dimmed. */
.chat__log .is-history {
  opacity: 0.5;
}

.chat__note {
  margin: 12px auto 0;
  max-width: none;
  font-size: 0.8em;
  color: var(--muted);
}

.chat__note a {
  color: var(--fg-dim);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--hairline);
  text-underline-offset: 3px;
}

/* ---------------------------------------------------------------- navigation */

nav {
  margin-top: 20px;
  width: 100%;
}

nav ul {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 15px;
}

nav a {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11.4px 19px; /* 95% of the original pill */
  border: 1px solid var(--fg);
  border-radius: 25px;
  text-transform: uppercase;
  font-size: 0.855em;
  font-weight: bold;
}

nav a:hover {
  background-color: var(--fg);
  color: var(--bg);
  box-shadow: 0 0 15px var(--glow);
}

nav a svg {
  width: 19px;
  height: 19px;
  fill: currentColor;
}

/* ------------------------------------------------------------------ credits */

.credits {
  margin: 18px auto 0;
  font-size: 0.75em;
  color: var(--muted);
  text-align: center;
}

.credits p {
  margin: 0 auto;
}

.credits a {
  color: var(--fg-dim);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--hairline);
  text-underline-offset: 3px;
}

.credits a:hover {
  text-decoration-color: var(--fg-dim);
}

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

@media (max-width: 768px) {
  h1 {
    font-size: 2em;
  }

  nav ul {
    flex-direction: column;
    align-items: center;
  }

  nav li {
    width: 80%;
  }

  nav a {
    width: 100%;
    text-align: center;
  }
}

@media (max-width: 480px) {
  h1 {
    font-size: 1.8em;
  }

  .main-image img {
    max-width: 260px;
  }

  /* Phones: the volume row drops under the name, full width. */
  .station {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 10px 14px;
    padding: 14px;
    border-radius: 28px;
  }

  .station__side {
    grid-column: 1 / -1;
    flex-direction: row-reverse;
    justify-content: space-between;
    align-items: center;
  }

  .station__slider {
    width: 140px;
  }
}
