/*
 * Pop Bollard — one stylesheet for all three pages.
 *
 * The look: a 1982 home computer that just booted. A solid border colour around a dark
 * "screen", a bitmap display face, inverse-video labels, hard pixel edges everywhere.
 * Rules that keep it coherent:
 *   - every border, gap and offset is a multiple of --u (4px); nothing is rounded,
 *     blurred or smoothly graded
 *   - two type roles only: PBOLL (the 5x7 bitmap face, sizes in multiples of 10px) for
 *     display, labels and buttons; a plain monospace at >= 16px for reading
 *   - the 16 musician colours live only inside the device; the page uses five colours
 */

@font-face {
  font-family: "PBOLL";
  src: url("/static/fonts/pboll.woff") format("woff"), url("/static/fonts/pboll.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: block;
}

:root {
  --u: 4px;

  --border: #7c70da;        /* the "screen border" of the machine */
  --bg: #20175e;            /* the screen */
  --panel: #2c2180;         /* raised areas */
  --line: #5b4fc4;          /* rules and quiet borders */
  --text: #ecebff;          /* body text: 13:1 on --bg */
  --soft: #b9b3f2;          /* secondary text: 7.6:1 on --bg */
  --ink: #0d0a3a;           /* darkest: outlines, text on bright fills */

  --yellow: #ffe45c;        /* primary action */
  --cyan: #7deaf2;          /* links, keywords */
  --pink: #ff6b9a;          /* ON AIR */
  --green: #6fe89a;         /* good news */

  /* the ball */
  --ball-hi: #ffffff;
  --ball: #e4e0ff;
  --ball-lo: #aaa1f3;
  --ball-deep: #7468d8;
  --ball-line: #0d0a3a;
  --ball-shadow: #150f45;
  --bezel: #0a0a12;
  --btn-face: #ffe45c;
  --btn-shade: #c9a914;
  --led-off: #3d3199;
  --turtle: #6fe89a;

  --display: "PBOLL", ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --body: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --s: 2;                   /* device scale: CSS pixels per screen pixel */
  --pad: calc(var(--u) * 4); /* the frame's side padding */
}

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

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

body {
  margin: 0;
  background: var(--border);
  color: var(--text);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.6;
}

h1, h2, p, ol, ul { margin: 0; padding: 0; }
ol, ul { list-style: none; }
canvas { image-rendering: pixelated; image-rendering: crisp-edges; display: block; }
[hidden] { display: none !important; }

a { color: var(--cyan); text-decoration-thickness: 2px; text-underline-offset: 4px; }
a:hover { color: var(--yellow); }

:focus-visible { outline: var(--u) solid var(--yellow); outline-offset: var(--u); }

.skip {
  position: absolute; left: calc(var(--u) * 2); top: -80px; z-index: 20;
  background: var(--yellow); color: var(--ink);
  font-family: var(--display); font-size: 20px; line-height: 1; padding: calc(var(--u) * 3);
}
.skip:focus { top: calc(var(--u) * 2); }

/* ── the machine's screen ─────────────────────────────────────────────────────────────── */

.frame {
  background: var(--bg);
  margin: calc(var(--u) * 2);
  min-height: calc(100vh - var(--u) * 4);
  padding: 0 var(--pad) calc(var(--u) * 8);
  display: flex;
  flex-direction: column;
}

main { flex: 1; width: 100%; max-width: 1320px; margin: 0 auto; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: calc(var(--u) * 3);
  padding: calc(var(--u) * 4) 0 calc(var(--u) * 7);
  width: 100%; max-width: 1320px; margin: 0 auto calc(var(--u) * 8);
  /* the early-80s stripe: three hard bands, no blending */
  background: linear-gradient(to bottom, var(--pink) 0 4px, var(--yellow) 4px 8px, var(--cyan) 8px 12px) left bottom / 100% 12px no-repeat;
}

.wordmark {
  display: inline-flex; align-items: center; gap: calc(var(--u) * 2);
  font-family: var(--display); font-size: 20px; line-height: 1;
  color: var(--text); text-decoration: none; white-space: nowrap;
  padding: var(--u) 0;
}
.wordmark:hover { color: var(--yellow); }
.wordmark svg { width: 24px; height: 24px; flex: none; }

.nav { display: flex; align-items: center; gap: var(--u); }
.wide-only { display: none; }
.navlink {
  font-family: var(--display); font-size: 20px; line-height: 1;
  color: var(--text); text-decoration: none; background: none;
  border: var(--u) solid transparent; padding: calc(var(--u) * 2) var(--u);
  cursor: pointer; min-height: 44px; display: inline-flex; align-items: center; white-space: nowrap;
}
.navlink:hover { color: var(--yellow); border-color: var(--line); }
.navlink.is-here { background: var(--text); color: var(--bg); }

/* ── type ─────────────────────────────────────────────────────────────────────────────── */

.display {
  font-family: var(--display); font-weight: 400;
  font-size: 40px; line-height: 1.1; letter-spacing: 0;
  color: var(--text);
}
.h2 {
  font-family: var(--display); font-weight: 400; font-size: 20px; line-height: 1;
  color: var(--bg); background: var(--soft);
  display: inline-block; padding: var(--u) calc(var(--u) * 2);
}
.lede { font-size: 18px; line-height: 1.6; max-width: 46ch; color: var(--text); }
.fineprint { font-size: 16px; color: var(--soft); }
.label { font-family: var(--display); font-size: 20px; line-height: 1; display: block; }

.tag {
  font-family: var(--display); font-size: 20px; line-height: 1;
  display: inline-block; padding: var(--u) calc(var(--u) * 2);
  background: var(--text); color: var(--bg); white-space: nowrap;
}

/* ── buttons: inverse-video blocks with a hard offset edge ────────────────────────────── */

.btn {
  font-family: var(--display); font-size: 20px; line-height: 1; font-weight: 400;
  display: inline-flex; align-items: center; justify-content: center; gap: calc(var(--u) * 2);
  min-height: 48px; padding: calc(var(--u) * 3) calc(var(--u) * 4);
  color: var(--text); background: var(--panel);
  border: var(--u) solid var(--text);
  box-shadow: var(--u) var(--u) 0 0 var(--ink);
  text-decoration: none; text-transform: uppercase; white-space: nowrap;
  cursor: pointer; user-select: none; -webkit-user-select: none;
  touch-action: manipulation;
}
.btn:hover { background: var(--text); color: var(--bg); }
.btn:active, .btn.is-down { transform: translate(var(--u), var(--u)); box-shadow: none; }
.btn:disabled { cursor: wait; background: var(--panel); color: var(--soft); border-color: var(--line); box-shadow: none; transform: none; }

.btn-primary { background: var(--yellow); color: var(--ink); border-color: var(--ink); }
.btn-primary:hover { background: var(--text); color: var(--ink); }

.btn-ghost { background: transparent; border-color: var(--line); box-shadow: none; }
.btn-ghost:hover { background: var(--panel); color: var(--text); border-color: var(--text); }
.btn-ghost:active { transform: none; }

.btn-big { font-size: 20px; min-height: 64px; padding: calc(var(--u) * 4) calc(var(--u) * 6); border-width: var(--u); }
.btn-small { min-height: 44px; padding: calc(var(--u) * 2) calc(var(--u) * 3); }

.cta-row { display: flex; flex-wrap: wrap; gap: calc(var(--u) * 4); align-items: center; }

/* ── ON AIR lamp ──────────────────────────────────────────────────────────────────────── */

.lamp {
  display: inline-block; width: calc(var(--u) * 3); height: calc(var(--u) * 3);
  background: var(--line); flex: none;
}
.lamp.is-on { background: var(--pink); animation: blink 1s steps(1, end) infinite; }
@keyframes blink { 50% { background: var(--line); } }

.onair-line {
  display: flex; align-items: flex-start; gap: calc(var(--u) * 3);
  font-size: 16px; color: var(--soft);
}
.onair-line .lamp { margin-top: 7px; }

/* ── the virtual device ───────────────────────────────────────────────────────────────── */

/* on phones the ball is wider than the page, so it runs out to the frame's edge */
.device-mount { margin-inline: calc(var(--pad) * -1); min-width: 0; }
.pbdev-clip { width: 100%; overflow: hidden; }

.pbdev { display: flex; flex-direction: column; align-items: center; gap: calc(var(--u) * 2); }

.pbdev-stage {
  position: relative; flex: none;
  width: calc(240px * var(--s)); height: calc(254px * var(--s));
  /* centre the ball even when it is wider than the page (phones): it simply bleeds off */
  left: 50%; transform: translateX(-50%);
  align-self: flex-start;
}
.pbdev-body { position: absolute; inset: 0; width: 100%; height: 100%; }
.pbdev-lcd {
  position: absolute; cursor: pointer;
  left: calc(45px * var(--s)); top: calc(60px * var(--s));
  width: calc(150px * var(--s)); height: calc(100px * var(--s));
  background: var(--bezel);
}
.pbdev-lcd:focus-visible { outline-offset: calc(var(--u) * 1); }

.pbdev-btn {
  position: absolute; width: calc(30px * var(--s)); height: calc(30px * var(--s));
  background: transparent; border: 0; padding: 0; cursor: pointer;
  touch-action: none; -webkit-tap-highlight-color: transparent;
}
.pbdev-btn-1 { left: calc(67px * var(--s)); top: calc(171px * var(--s)); }
.pbdev-btn-2 { left: calc(105px * var(--s)); top: calc(175px * var(--s)); }
.pbdev-btn-3 { left: calc(143px * var(--s)); top: calc(171px * var(--s)); }
.pbdev-btn:focus-visible { outline-offset: 0; }

.pbdev-legend {
  display: grid; gap: calc(var(--u) * 2) calc(var(--u) * 5);
  font-size: 16px; line-height: 1.3; color: var(--soft);
  padding: 0 var(--pad);
}
.pbdev-legend li { display: grid; grid-template-columns: auto auto 1fr; column-gap: calc(var(--u) * 2); align-items: center; }
.pbdev-key {
  font-family: var(--display); font-size: 20px; line-height: 1;
  background: var(--yellow); color: var(--ink);
  padding: var(--u) calc(var(--u) * 1.5);
}
.pbdev-what { color: var(--text); white-space: nowrap; }
.pbdev-hold { white-space: nowrap; font-size: 14px; }

/* ── landing ──────────────────────────────────────────────────────────────────────────── */

.hero { display: grid; gap: calc(var(--u) * 8); align-items: center; }
.hero-copy { display: grid; gap: calc(var(--u) * 6); justify-items: start; }
.hero-device { display: grid; gap: calc(var(--u) * 3); justify-items: center; min-width: 0; }
.hero-device .onair-line { max-width: 52ch; padding: 0 calc(var(--u) * 2); }

.steps { margin-top: calc(var(--u) * 14); border-top: var(--u) solid var(--line); padding-top: calc(var(--u) * 8); }
.listing { display: grid; gap: calc(var(--u) * 4); font-size: 18px; max-width: 64ch; }
.listing li { display: grid; grid-template-columns: 3ch 1fr; column-gap: calc(var(--u) * 3); align-items: baseline; }
.listing .ln { color: var(--soft); }
.listing .kw { font-family: var(--display); font-size: 20px; line-height: 1; background: var(--cyan); color: var(--ink); padding: var(--u) calc(var(--u) * 2); margin-right: calc(var(--u) * 2); }

/* ── device page ──────────────────────────────────────────────────────────────────────── */

.devicepage { display: grid; gap: calc(var(--u) * 6); }
.devhead { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: calc(var(--u) * 4); }
.devhead-id { display: grid; gap: calc(var(--u) * 2); justify-items: start; min-width: 0; }
.devname { font-family: var(--display); font-weight: 400; font-size: 30px; line-height: 1.1; overflow-wrap: anywhere; }
.devhead-actions { display: flex; flex-wrap: wrap; gap: calc(var(--u) * 3); }

.visitor-note {
  display: flex; flex-wrap: wrap; align-items: center; gap: calc(var(--u) * 3);
  border: var(--u) solid var(--line); padding: calc(var(--u) * 3) calc(var(--u) * 4);
}

.statusline {
  font-size: 16px; line-height: 1.5; min-height: calc(1.5em + var(--u) * 6);
  background: var(--ink); color: var(--green);
  border: var(--u) solid var(--line);
  padding: calc(var(--u) * 2) calc(var(--u) * 3);
  overflow-wrap: anywhere;
}
.statusline::after {
  content: ""; display: inline-block; width: 0.6em; height: 1em; margin-left: 0.4em;
  background: var(--green); vertical-align: -0.15em; animation: cursor 1s steps(1, end) infinite;
}
@keyframes cursor { 50% { background: transparent; } }

.mainaction { display: flex; }
.mainaction .btn { width: 100%; }

.songs { display: grid; gap: calc(var(--u) * 4); justify-items: start; }
.songlist { width: 100%; display: grid; border-top: var(--u) solid var(--line); }
.song {
  display: grid; grid-template-columns: auto 1fr; gap: calc(var(--u) * 3) calc(var(--u) * 4);
  align-items: center; padding: calc(var(--u) * 4) 0;
  border-bottom: var(--u) solid var(--line);
}
.song.is-current { background: var(--panel); box-shadow: calc(var(--u) * -4) 0 0 0 var(--panel), calc(var(--u) * 4) 0 0 0 var(--panel); }
.song-main { display: grid; gap: var(--u); min-width: 0; }
.song-title { font-size: 18px; line-height: 1.35; color: var(--text); overflow-wrap: anywhere; }
.song-title .ln, .song-meta .ln { color: var(--soft); margin-right: 1ch; }
.song-meta { font-size: 14px; color: var(--soft); }
.btn-play { width: 48px; min-height: 48px; padding: 0; }
.song.is-current .btn-play { background: var(--yellow); color: var(--ink); border-color: var(--ink); }
.btn-share { grid-column: 1 / -1; justify-self: stretch; }
.btn-share.is-on { background: var(--pink); color: var(--ink); border-color: var(--ink); }
.btn-share.is-on:hover { background: var(--text); }
.tag-onair { grid-column: 1 / -1; justify-self: start; background: var(--pink); color: var(--ink); }
.empty { color: var(--soft); max-width: 46ch; }

.rename { display: grid; gap: calc(var(--u) * 3); border: var(--u) solid var(--yellow); padding: calc(var(--u) * 4); }
.rename-row { display: flex; flex-wrap: wrap; align-items: center; gap: calc(var(--u) * 3); }
.at { font-family: var(--display); font-size: 20px; line-height: 1; }
.input {
  font-family: var(--body); font-size: 18px; line-height: 1.2;
  background: var(--ink); color: var(--text);
  border: var(--u) solid var(--text); border-radius: 0;
  padding: calc(var(--u) * 2) calc(var(--u) * 3); min-height: 48px; min-width: 0; flex: 1 1 14ch;
}

/* ── FM page ──────────────────────────────────────────────────────────────────────────── */

.fmpage { display: grid; gap: calc(var(--u) * 6); }
.fmhead { display: grid; gap: calc(var(--u) * 3); justify-items: start; }
.nowplaying, .upnext { display: grid; gap: calc(var(--u) * 3); justify-items: start; }
.np-title { font-family: var(--display); font-size: 30px; line-height: 1.15; overflow-wrap: anywhere; }
.np-from { font-size: 16px; color: var(--soft); }
.nextlist { width: 100%; display: grid; border-top: var(--u) solid var(--line); counter-reset: nx; }
.next {
  display: grid; grid-template-columns: 3ch 1fr; column-gap: calc(var(--u) * 3);
  padding: calc(var(--u) * 3) 0; border-bottom: var(--u) solid var(--line); counter-increment: nx 10;
}
.next::before { content: counter(nx); color: var(--soft); grid-row: span 2; }
.next-title { font-size: 18px; line-height: 1.35; overflow-wrap: anywhere; }
.next-from { font-size: 14px; color: var(--soft); }
.btn.is-on { background: var(--pink); color: var(--ink); border-color: var(--ink); }
.fm-cta { display: flex; flex-wrap: wrap; align-items: center; gap: calc(var(--u) * 3); border: var(--u) solid var(--line); padding: calc(var(--u) * 3) calc(var(--u) * 4); }

/* ── not found ────────────────────────────────────────────────────────────────────────── */

.notfound { display: grid; gap: calc(var(--u) * 6); justify-items: start; padding: calc(var(--u) * 10) 0; }

/* ── footer & toast ───────────────────────────────────────────────────────────────────── */

.foot {
  width: 100%; max-width: 1320px; margin: calc(var(--u) * 16) auto 0;
  border-top: var(--u) solid var(--line); padding-top: calc(var(--u) * 6);
  display: grid; gap: calc(var(--u) * 4); font-size: 16px; color: var(--soft);
}
.foot p { max-width: 64ch; }
.foot-links { display: flex; flex-wrap: wrap; gap: calc(var(--u) * 6); font-family: var(--display); font-size: 20px; line-height: 1; }
.foot-links a { color: var(--soft); text-decoration: none; padding: calc(var(--u) * 3) 0; }
.foot-links a:hover { color: var(--yellow); }

.notice {
  position: fixed; left: 50%; bottom: calc(var(--u) * 6); z-index: 30;
  transform: translateX(-50%);
  width: max-content; max-width: calc(100vw - var(--u) * 12);
  background: var(--text); color: var(--ink);
  border: var(--u) solid var(--ink); box-shadow: var(--u) var(--u) 0 0 var(--ink);
  padding: calc(var(--u) * 3) calc(var(--u) * 4);
  font-size: 16px; line-height: 1.45;
  display: none;
}
.notice.is-on { display: block; }
.notice-good { background: var(--green); }
.notice-bad { background: var(--pink); }

.is-signing-in [data-action="signin"] { cursor: wait; }

/* ── bigger screens ───────────────────────────────────────────────────────────────────── */

@media (min-width: 560px) {
  :root { --pad: calc(var(--u) * 8); }
  .wide-only { display: inline; }
  .nav { gap: calc(var(--u) * 2); }
  .navlink { padding: calc(var(--u) * 2); }
  .wordmark { gap: calc(var(--u) * 3); }
  .pbdev-legend { grid-template-columns: repeat(3, auto); justify-content: center; }
  .pbdev-legend li { grid-template-columns: auto auto; align-items: start; }
  .pbdev-key { grid-row: span 2; margin-top: 2px; }
  .song { grid-template-columns: auto 1fr auto; }
  .btn-share, .tag-onair { grid-column: auto; justify-self: end; }
  .frame { margin: calc(var(--u) * 4); min-height: calc(100vh - var(--u) * 8); padding-bottom: calc(var(--u) * 10); }
  .display { font-size: 60px; }
  .mainaction .btn { width: auto; }
}

@media (min-width: 800px) and (min-height: 700px) {
  :root { --s: 3; }
}

@media (min-width: 1240px) {
  .frame { margin: calc(var(--u) * 6); min-height: calc(100vh - var(--u) * 12); }
  .hero { grid-template-columns: minmax(0, 1fr) auto; gap: calc(var(--u) * 8); }
  /* beside a column of text the ball's ray tips may poke into the gutter */
  .device-mount { margin-inline: 0; }
  .pbdev-clip { overflow: visible; }
  .hero-device, .devicepage > .device-mount, .fmpage > .device-mount { width: calc(224px * var(--s)); }
  .devicepage {
    grid-template-columns: auto minmax(0, 1fr); column-gap: calc(var(--u) * 10);
    grid-template-areas: "dev head" "dev note" "dev status" "dev action" "dev songs" "dev rename" "dev .";
    grid-template-rows: auto auto auto auto auto auto 1fr; align-items: start;
  }
  .devicepage > .device-mount { grid-area: dev; position: sticky; top: calc(var(--u) * 6); }
  .devicepage > .devhead { grid-area: head; }
  .devicepage > .visitor-note { grid-area: note; }
  .devicepage > .statusline { grid-area: status; }
  .devicepage > .mainaction { grid-area: action; }
  .devicepage > .songs { grid-area: songs; }
  .devicepage > .rename { grid-area: rename; }
  .fmpage {
    grid-template-columns: auto minmax(0, 1fr); column-gap: calc(var(--u) * 10);
    grid-template-areas: "dev head" "dev lede" "dev action" "dev now" "dev next" "dev cta" "dev .";
    grid-template-rows: auto auto auto auto auto auto 1fr; align-items: start;
  }
  .fmpage > .device-mount { grid-area: dev; position: sticky; top: calc(var(--u) * 6); }
  .fmpage > .fmhead { grid-area: head; }
  .fmpage > .lede { grid-area: lede; }
  .fmpage > .mainaction { grid-area: action; }
  .fmpage > .nowplaying { grid-area: now; }
  .fmpage > .upnext { grid-area: next; }
  .fmpage > .fm-cta { grid-area: cta; }
}

@media (prefers-reduced-motion: reduce) {
  .lamp.is-on, .statusline::after { animation: none; }
  .btn:active, .btn.is-down { transform: none; }
}
