/* ============================================================
   QAMNQN RADIO — stark monochrome broadside
   ink on newsprint · brutalist-mixed type · sparse · subtle motion
   ============================================================ */

:root {
  --ink: #14110d;
  --paper: #f4f0e6;
  --paper-2: #ece7d8;
  --rule: #14110d;
  --hair: rgba(20, 17, 13, 0.18);
  --muted: rgba(20, 17, 13, 0.55);

  --grotesque: "Archivo Black", "Arial Black", sans-serif;
  --mono: "Space Mono", ui-monospace, monospace;
  --serif: "Newsreader", Georgia, serif;

  --gut: clamp(1.25rem, 3vw, 3rem);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--mono);
  -webkit-font-smoothing: antialiased;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  height: 100dvh;          /* lock the app to the viewport */
  overflow: hidden;        /* sections scroll internally, not the page */
}

::selection { background: var(--ink); color: var(--paper); }

/* ---- newsprint grain + crop marks --------------------------------------- */
.grain {
  position: fixed; inset: 0; z-index: 9; pointer-events: none;
  opacity: 0.5; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='0.35'/></svg>");
}
.crop {
  position: fixed; width: 14px; height: 14px; z-index: 10; pointer-events: none;
}
.crop--tl { top: 14px; left: 14px; border-top: 1.5px solid var(--ink); border-left: 1.5px solid var(--ink); }
.crop--tr { top: 14px; right: 14px; border-top: 1.5px solid var(--ink); border-right: 1.5px solid var(--ink); }
.crop--bl { bottom: 14px; left: 14px; border-bottom: 1.5px solid var(--ink); border-left: 1.5px solid var(--ink); }
.crop--br { bottom: 14px; right: 14px; border-bottom: 1.5px solid var(--ink); border-right: 1.5px solid var(--ink); }

/* ---- masthead ----------------------------------------------------------- */
.masthead {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 1rem; padding: clamp(0.85rem, 1.6vw, 1.25rem) var(--gut) 0.7rem;
  border-bottom: 2px solid var(--rule);
}
.masthead__brand { display: flex; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.wordmark {
  font-family: var(--grotesque);
  font-size: clamp(1.1rem, 2.2vw, 1.7rem);
  letter-spacing: 0.02em;
}
/* easter egg: hover "qamnqn" and it rotates 180° — revealing "ubuweb" */
.flipword { display: inline-block; cursor: pointer; }
.flipword__inner {
  display: inline-block;
  transform-origin: 50% 50%;
  transition: transform 0.7s cubic-bezier(0.76, 0, 0.24, 1);
}
.flipword:hover .flipword__inner { transform: rotate(180deg); }
@media (prefers-reduced-motion: reduce) {
  .flipword__inner { transition: none; }
}
.colophon { font-size: 0.7rem; color: var(--muted); letter-spacing: 0.04em; }

.onair {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.72rem; letter-spacing: 0.22em; font-weight: 700;
  white-space: nowrap;
}
.onair__dot {
  width: 9px; height: 9px; border: 1.5px solid var(--ink); border-radius: 50%;
  background: transparent;
}
.onair.is-live .onair__dot { background: var(--ink); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.2; } }

/* ---- tuner -------------------------------------------------------------- */
.tuner { padding: 0.9rem var(--gut); border-bottom: 1px solid var(--hair); }
.tuner__row { display: flex; flex-wrap: wrap; gap: 0; }
#stations { border: 1px solid var(--rule); }

.station {
  appearance: none; cursor: pointer; background: var(--paper); color: var(--ink);
  border: 0; border-right: 1px solid var(--rule);
  font-family: var(--mono); text-align: left;
  padding: 0.55rem 0.85rem; min-width: 0; flex: 1 1 0;
  display: flex; flex-direction: column; gap: 2px;
  transition: background 0.18s ease, color 0.18s ease;
}
.station:last-child { border-right: 0; }
.station__name { font-size: 0.82rem; font-weight: 700; letter-spacing: 0.01em; white-space: nowrap; }
.station__desc {
  font-size: 0.62rem; color: var(--muted); line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.station:hover { background: var(--paper-2); }
.station.is-active { background: var(--ink); color: var(--paper); } /* inversion = active */
.station.is-active .station__desc { color: rgba(244, 240, 230, 0.7); }

.tuner__row--decades { align-items: center; gap: 0.6rem; margin-top: 0.7rem; }
.dial-label { font-size: 0.66rem; letter-spacing: 0.2em; color: var(--muted); }
#decades { display: flex; gap: 0; border: 1px solid var(--rule); }
.decade {
  appearance: none; cursor: pointer; background: var(--paper); color: var(--ink);
  border: 0; border-right: 1px solid var(--rule);
  font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.08em;
  padding: 0.32rem 0.7rem; transition: background 0.15s ease, color 0.15s ease;
}
.decade:last-child { border-right: 0; }
.decade:hover { background: var(--paper-2); }
.decade.is-active { background: var(--ink); color: var(--paper); }

/* ---- stage: now-playing + queue ----------------------------------------- */
.stage {
  display: grid;
  grid-template-columns: 1fr clamp(220px, 24vw, 320px);
  gap: var(--gut);
  /* tighter top, no bottom so scrolling text runs up flush beneath the player */
  padding: clamp(0.9rem, 2vw, 1.6rem) var(--gut) 0;
  align-items: stretch;
  min-height: 0;          /* allow children to shrink + scroll */
  overflow: hidden;
}

/* each column scrolls within the locked viewport */
.nowplaying, .queue {
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--hair) transparent;
  scrollbar-gutter: stable;   /* reserve scrollbar space so text never sits under it */
  padding-bottom: clamp(1.75rem, 3vw, 3rem);  /* breathing room above the player at scroll end */
}
.nowplaying::-webkit-scrollbar, .queue::-webkit-scrollbar { width: 8px; }
.nowplaying::-webkit-scrollbar-thumb, .queue::-webkit-scrollbar-thumb { background: var(--hair); }
.nowplaying::-webkit-scrollbar-track, .queue::-webkit-scrollbar-track { background: transparent; }

/* now playing */
.nowplaying { min-width: 0; padding-right: 0.5rem; }
.np__empty { padding-top: 2rem; max-width: 40ch; }
.np__prompt { font-family: var(--grotesque); font-size: clamp(1.4rem, 3vw, 2.4rem); line-height: 1.02; margin: 0 0 0.6rem; }
.np__sub { color: var(--muted); font-size: 0.8rem; margin: 0; }
.np__credit {
  margin: 1.6rem 0 0; max-width: 46ch;
  font-size: 0.72rem; line-height: 1.5; color: var(--muted);
}
.colophon a, .np__credit a {
  color: inherit; text-decoration: none;
  border-bottom: 1px solid currentColor;
}
.colophon a:hover, .np__credit a:hover { color: var(--ink); }

.np__station {
  margin: 0 0 0.8rem; font-size: 0.72rem; letter-spacing: 0.26em; font-weight: 700;
  text-transform: uppercase;
}
.np__station::before { content: "▮ "; }

.np__artist {
  font-family: var(--grotesque);
  font-size: clamp(2.6rem, 9vw, 7.5rem);
  line-height: 0.86; letter-spacing: -0.02em;
  margin: 0 0 0.8rem; text-transform: uppercase;
  word-break: break-word; hyphens: auto;
}

.np__piece {
  font-size: 0.95rem; letter-spacing: 0.01em; margin: 0 0 1.4rem;
  padding-left: 0.9rem; border-left: 3px solid var(--ink);
}

.np__meta { display: flex; flex-wrap: wrap; gap: 0.5rem 1.2rem; margin: 0 0 1.5rem; }
.np__eras { font-size: 0.68rem; letter-spacing: 0.16em; font-weight: 700; }
.np__eras:not(:empty)::after { content: ""; }
.np__tags { font-size: 0.72rem; color: var(--muted); }

.np__bio {
  font-family: var(--serif); font-size: 1.18rem; line-height: 1.5;
  max-width: 56ch; margin: 0 0 1.6rem; font-weight: 400;
  white-space: pre-line;   /* keep tracklists / stanzas on their own lines */
}

.np__archive {
  display: inline-block; font-size: 0.72rem; letter-spacing: 0.14em; font-weight: 700;
  color: var(--ink); text-decoration: none; border-bottom: 2px solid var(--ink);
  padding-bottom: 2px; transition: opacity 0.15s ease;
}
.np__archive:hover { opacity: 0.55; }

/* related-artist steering */
.np__related { margin: 2rem 0; }
.np__related-label {
  display: block; font-size: 0.62rem; letter-spacing: 0.22em;
  color: var(--muted); margin-bottom: 0.8rem;
}
.np__chips { display: flex; flex-wrap: wrap; gap: 0.55rem; }
.chip {
  appearance: none; cursor: pointer; font-family: var(--mono);
  font-size: 0.72rem; letter-spacing: 0.01em;
  background: var(--paper); color: var(--ink);
  border: 1px solid var(--ink); padding: 0.45rem 0.75rem;
  transition: background 0.15s ease, color 0.15s ease;
}
.chip::before { content: "→ "; opacity: 0.5; }
.chip:hover { background: var(--ink); color: var(--paper); }
.chip:hover::before { opacity: 1; }

/* splice reveal on track change */
.np__card.is-fresh .np__station { animation: rise 0.32s ease both; }
.np__card.is-fresh .np__artist { animation: rise 0.42s ease 0.04s both; }
.np__card.is-fresh .np__piece,
.np__card.is-fresh .np__meta,
.np__card.is-fresh .np__bio,
.np__card.is-fresh .np__related { animation: rise 0.4s ease 0.1s both; }
@keyframes rise {
  from { opacity: 0; transform: translateY(0.6rem); clip-path: inset(0 0 100% 0); }
  to   { opacity: 1; transform: none; clip-path: inset(0 0 0 0); }
}

/* queue */
.queue { border-left: 1px solid var(--hair); padding-left: var(--gut); padding-right: 0.5rem; min-width: 0; }
.queue__head {
  font-size: 0.68rem; letter-spacing: 0.22em; font-weight: 700; margin: 0 0 0.7rem;
  padding-bottom: 0.4rem; border-bottom: 2px solid var(--ink);
}
.queue__head--hist { margin-top: 1.8rem; color: var(--muted); border-bottom-color: var(--hair); }
.queue__list { list-style: none; margin: 0; padding: 0; }
.queue__empty {
  font-size: 0.72rem; line-height: 1.55; color: var(--muted);
  padding: 0.55rem 0 0.2rem; max-width: 30ch;
}
.queue__empty::before { content: "— "; }
.queue__item {
  cursor: pointer; padding: 0.5rem 0; border-bottom: 1px solid var(--hair);
  display: flex; flex-direction: column; gap: 1px;
  transition: padding-left 0.15s ease, background 0.15s ease;
}
.queue__item:hover { padding-left: 0.5rem; background: var(--paper-2); }
.qi__artist { font-size: 0.78rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qi__piece { font-size: 0.64rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.queue__item--hist { opacity: 0.6; }
.queue__item--hist:hover { opacity: 1; }

/* ---- transport ---------------------------------------------------------- */
.transport {
  position: sticky; bottom: 0; z-index: 8;
  display: grid; grid-template-columns: auto 1fr auto; align-items: center;
  gap: clamp(0.8rem, 2vw, 2rem);
  padding: 0.7rem var(--gut);
  background: var(--ink); color: var(--paper);
}
.transport__controls { display: flex; gap: 0.4rem; }
.tbtn {
  appearance: none; cursor: pointer;
  background: transparent; color: var(--paper);
  border: 1.5px solid var(--paper); width: 38px; height: 38px;
  font-size: 0.9rem; font-family: var(--mono);
  display: grid; place-items: center;
  transition: background 0.15s ease, color 0.15s ease;
}
.tbtn:hover { background: var(--paper); color: var(--ink); }
.tbtn--play { width: 46px; }

.transport__scrub { display: flex; align-items: center; gap: 0.8rem; min-width: 0; }
.time { font-size: 0.7rem; letter-spacing: 0.05em; opacity: 0.85; font-variant-numeric: tabular-nums; }

.scrub {
  -webkit-appearance: none; appearance: none; width: 100%; height: 2px;
  background: rgba(244, 240, 230, 0.35); cursor: pointer; outline: none;
}
.scrub::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 12px; height: 12px; background: var(--paper); border-radius: 0;
}
.scrub::-moz-range-thumb { width: 12px; height: 12px; background: var(--paper); border: 0; border-radius: 0; }

.transport__title {
  font-size: 0.72rem; letter-spacing: 0.04em; text-align: right;
  white-space: nowrap; overflow: hidden; max-width: 28vw;
  opacity: 0.85;
}
.transport__title .ticker {
  display: inline-block; max-width: 100%; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; vertical-align: bottom;
}
.transport__title.is-ticking .ticker {
  max-width: none; overflow: visible; text-overflow: clip;
  animation: ticker var(--ticker-dur, 9s) ease-in-out infinite;
}
@keyframes ticker {
  0%, 12%   { transform: translateX(0); }
  48%, 60%  { transform: translateX(var(--ticker-shift, 0px)); }
  96%, 100% { transform: translateX(0); }
}
@media (prefers-reduced-motion: reduce) {
  .transport__title.is-ticking .ticker {
    animation: none; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
  }
}

/* ---- responsive --------------------------------------------------------- */
@media (max-width: 760px) {
  /* unlock the viewport lock on small screens: let the page scroll naturally */
  body { height: auto; min-height: 100dvh; overflow-x: hidden; overflow-y: auto; }
  .stage { grid-template-columns: 1fr; overflow: visible; min-height: 0; }
  .nowplaying, .queue { overflow: visible; min-height: 0; }
  .nowplaying { padding-right: 0; }
  .queue { border-left: 0; padding-left: 0; border-top: 1px solid var(--hair); padding-top: 1.4rem; }
  .station { flex: 1 1 40%; border-bottom: 1px solid var(--rule); }
  .transport { grid-template-columns: auto 1fr; }
  .transport__title { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .np__card.is-fresh * { animation: none !important; }
  .onair.is-live .onair__dot { animation: none; }
}
