/*
 * iScream — Sistema de Alerta Temprana de Radiolibre
 *
 * Same ground as radiolibre.altred.xyz (assets/styles.css there): black page,
 * white ZKM Serendipity, outlined pills that invert on hover. The art is the
 * 1-bit GIFs from altred.xyz's archive, inverted to white-on-black and scaled
 * by whole pixels so they stay crisp.
 */

@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;
  --muted: #8a8a8a;
  --surface: #111;
  --border: rgba(255, 255, 255, 0.6);
  --hairline: rgba(255, 255, 255, 0.25);
  --glow: rgba(255, 255, 255, 0.3);
  --warn: #ff9b9b;
  --alert: #c0392b;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

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

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

body {
  font-family: 'ZKM Serendipity', Arial, Helvetica, sans-serif;
  background-color: var(--bg);
  color: var(--fg);
  margin: 0;
  padding: 16px;
  line-height: 1.5;
  color-scheme: dark;
}

a {
  color: var(--fg);
  text-decoration: underline;
  text-decoration-color: var(--border);
  text-underline-offset: 3px;
}

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

:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 3px;
}

code {
  font-family: var(--mono);
  font-size: 0.9em;
}

/* Components below 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;
}

.hint {
  color: var(--muted);
  font-size: 0.85em;
}

/* ------------------------------------------------------------------ 1-bit art */

/* The GIFs are black ink on white paper; inverting puts them on our ground. */
.bit {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  filter: invert(1);
  display: block;
}

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

.wrap {
  max-width: 720px;
  margin: 0 auto;
}

.masthead {
  display: flex;
  align-items: center;
  gap: 18px;
  margin: 8px 0 20px;
}

.masthead__art {
  width: 160px; /* 2x the source */
  height: auto;
  flex: none;
}

h1 {
  margin: 0;
  font-size: 2.85em;
  line-height: 1;
  letter-spacing: 2px;
}

.masthead__sub {
  margin: 6px 0 0;
  font-size: 0.8em;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--fg-dim);
}

.lede {
  font-size: 1.1em;
  margin: 0 0 28px;
}

.panel {
  margin: 0 0 36px;
}

/* Heading with the hairline running out to the edge, as on radiolibre. */
.panel__title {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 0 16px;
  font-size: 0.8em;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--fg-dim);
}

.panel__title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, var(--border), transparent);
}

.panel--quiet p,
.panel--quiet li {
  color: var(--fg-dim);
}

/* ------------------------------------------------------------------- on air */

.onair {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 20px;
}

.onair__button {
  width: 148px;
  height: 148px;
  border-radius: 50%;
  border: 2px solid var(--fg);
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 1px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: background-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
  -webkit-tap-highlight-color: transparent;
}

.onair__button:hover {
  box-shadow: 0 0 15px var(--glow);
}

.onair__button:disabled {
  cursor: progress;
  opacity: 0.7;
}

.onair__icon {
  width: 120px; /* 2x the source */
  height: auto;
}

/* Live: the button inverts to solid white and the splat goes black on it. */
.onair[data-state='live'] .onair__button {
  background: var(--fg);
  color: var(--bg);
  box-shadow: 0 0 0 6px var(--bg), 0 0 0 8px var(--fg), 0 0 30px var(--glow);
  animation: pulse 1.6s steps(2, jump-none) infinite;
}

.onair[data-state='live'] .onair__icon {
  filter: none;
}

@keyframes pulse {
  50% {
    box-shadow: 0 0 0 6px var(--bg), 0 0 0 8px var(--fg), 0 0 6px var(--glow);
  }
}

.onair__readout {
  min-width: 0;
}

.onair__status {
  margin: 0;
  font-size: 0.95em;
  text-transform: uppercase;
  letter-spacing: 1px;
}

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

.onair__timer {
  margin: 4px 0 10px;
  font-family: var(--mono);
  font-size: 2em;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.onair[data-state='live'] .onair__timer {
  color: var(--fg);
}

/* Input level: a bar of whole "pixels", stepped like the art. */
.meter {
  height: 12px;
  border: 1px solid var(--border);
  padding: 2px;
}

.meter__bar {
  height: 100%;
  width: 0;
  background: repeating-linear-gradient(to right, var(--fg) 0 6px, transparent 6px 8px);
}

/* ----------------------------------------------------------------- metadata */

.meta {
  margin: 22px 0 0;
  border: 1px solid var(--hairline);
  border-radius: 18px;
  padding: 12px 16px;
}

.meta summary {
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 0.9em;
}

.meta__form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.meta__form label {
  display: grid;
  gap: 4px;
  font-size: 0.8em;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--fg-dim);
}

input {
  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: 10px;
  padding: 10px 12px;
  width: 100%;
  min-width: 0;
  text-transform: none;
  letter-spacing: normal;
}

input::placeholder {
  color: var(--muted);
}

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

/* ------------------------------------------------------------------- chips */

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

.chip:hover,
.chip--solid {
  background: var(--fg);
  color: var(--bg);
}

.chip--solid:hover {
  background: var(--fg-dim);
}

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

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

.chat__status {
  margin: 0 0 8px;
  font-size: 0.8em;
  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: 10px 12px;
  height: 45vh;
  min-height: 220px;
  max-height: 480px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--border);
  border-radius: 14px;
  font-family: var(--mono);
  font-size: 0.85em;
  line-height: 1.45;
  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;
}

/* ----------------------------------------------------------------- privacy */

.privacy {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.privacy__art {
  width: 82px; /* 2x */
  height: auto;
  flex: none;
}

.privacy p {
  margin-top: 0;
}

.tips {
  padding-left: 1.2em;
}

.tips li {
  margin-bottom: 6px;
}

/* -------------------------------------------------------------- nav, footer */

nav ul {
  list-style: none;
  padding: 0;
  margin: 8px auto 0;
  max-width: 720px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

nav a {
  display: block;
  padding: 12px 20px;
  border: 1px solid var(--fg);
  border-radius: 25px;
  text-transform: uppercase;
  text-decoration: none;
  font-size: 0.9em;
  font-weight: bold;
  transition: background-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
}

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

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

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

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

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

  .masthead__art {
    width: 80px;
  }

  .masthead__sub {
    letter-spacing: 2px;
  }

  /* Button on top, big enough to hit with a thumb in a crowd. */
  .onair {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  .onair__button {
    width: 180px;
    height: 180px;
  }

  .onair__readout {
    width: 100%;
  }

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

  nav li {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .onair[data-state='live'] .onair__button {
    animation: none;
  }
}
