/* Omarchy Radio — design implementation.
   Theme colours are computed in app.js and written to these custom properties,
   mirroring the mix()/lum() derivations from the source design. */

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

:root {
  --bg: #0a0b0a;
  --fg: #e7e6e0;
  --ac: #5ef2a0;
  --bd: #23261f;
  --bdF: #14170f;
  --c2: #797b74;
  --c3: #4a4c46;
  --rowOn: #101711;
  --rowHov: #101110;
  --trk: #1e201d;
  --lcd: #050505;
  --acFg: #000000;
  --acHi: #8bf5b8;
  --g1: #365f45;
  --g2: #26402f;
  --scan: repeating-linear-gradient(180deg, rgba(0,0,0,.42) 0 2px, transparent 2px 4px);

  --wt-small: 500;

  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: "Space Grotesk", Helvetica, Arial, sans-serif;
  --lcdfont: "VT323", ui-monospace, monospace;
}

html, body { margin: 0; padding: 0; background: var(--bg); }

body {
  font-family: var(--mono);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, p, ul, ol, li, figure { margin: 0; padding: 0; }
ul, ol { list-style: none; }

a { color: var(--ac); text-decoration: none; }
a:hover { color: var(--fg); }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  text-align: left;
  cursor: pointer;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--lcd); }
::-webkit-scrollbar-thumb { background: var(--bd); }
* { scrollbar-width: thin; scrollbar-color: var(--bd) var(--lcd); }

:focus-visible { outline: 2px solid var(--ac); outline-offset: 1px; }

/* Touch: no grey flash on tap, and the drag controls must claim the gesture
   or the page pans out from under a finger mid-drag. */
button, [role="slider"] { -webkit-tap-highlight-color: transparent; }
.seek, .knob { touch-action: none; -webkit-user-select: none; user-select: none; }

@keyframes marq { 0% { transform: translateX(0); } 100% { transform: translateX(-50%); } }
@keyframes blink { 0%, 55% { opacity: 1; } 56%, 100% { opacity: .12; } }

/* ── stage ───────────────────────────────────────────── */

.stage {
  height: 100vh;
  height: 100dvh;
  background: var(--bg);
  color: var(--fg);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

.fit {
  position: relative;
  z-index: 1;
  flex: none;
  width: calc(1180px * var(--fit, 1));
  height: calc(880px * var(--fit, 1));
}

.app {
  position: relative;
  z-index: 1;
  flex: none;
  width: 1180px;
  height: 880px;
  overflow: hidden;
  background: var(--bg);
  border: 1px solid var(--bd);
  display: flex;
  flex-direction: column;
  transform: scale(var(--fit, 1));
  transform-origin: top left;
}

/* ── header ──────────────────────────────────────────── */

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  padding: 16px 20px;
  border-bottom: 1px solid var(--bd);
  flex: none;
}

.bar-l { display: flex; align-items: center; gap: 12px; }

/* Omarchy mark, traced from the omarchy.org favicon. It is a monochrome
   glyph, so it takes the theme accent like the square it replaced. */
.logo {
  width: 17px;
  height: 17px;
  flex: none;
  display: block;
  color: var(--ac);
}

.wordmark {
  font-size: 11px;
  font-weight: 400;
  letter-spacing: .34em;
  text-transform: uppercase;
  color: var(--fg);
}

.home {
  font-size: 10px;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: var(--c2);
  border-bottom: 1px solid var(--bd);
}
.home:hover { color: var(--ac); border-color: var(--ac); }

.bar-r { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }

.live-now {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: var(--ac);
}

.pulse {
  width: 7px;
  height: 7px;
  flex: none;
  background: var(--ac);
  animation: blink 1.4s steps(1) infinite;
}

.net-sum {
  font-size: 10px;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: var(--c2);
  white-space: nowrap;
}

/* theme picker */

.picker { position: relative; }

.picker-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 11px;
  font-size: 10px;
  letter-spacing: .2em;
  text-transform: uppercase;
  border: 1px solid var(--bd);
  color: var(--fg);
  min-width: 168px;
  justify-content: space-between;
}
.picker-btn:hover { border-color: var(--ac); }

.picker-name { display: flex; align-items: center; gap: 9px; }
.sw-ac { width: 8px; height: 8px; flex: none; background: var(--ac); }
.caret { color: var(--c2); }

.menu {
  position: absolute;
  /* The picker lives in the footer, so the list has to open upwards or it
     opens into the bottom edge and is clipped. */
  bottom: 100%;
  right: 0;
  margin-bottom: 3px;
  z-index: 20;
  width: 240px;
  max-height: 340px;
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--bd);
}
.menu[hidden] { display: none; }

.menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  font-size: 10px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--fg);
  border-bottom: 1px solid var(--bdF);
}
.menu button:hover { background: var(--rowHov); }
.menu li.is-on button { background: var(--rowOn); color: var(--ac); }

.sw { display: flex; flex: none; gap: 2px; }
.sw span { width: 9px; height: 14px; }
.menu-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── upper row ───────────────────────────────────────── */

.row-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  flex: none;
  min-height: 0;
}

/* Shared by the playlist and the listener panels. */

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px 10px;
  flex: none;
}

.panel-title {
  font-size: 10px;
  font-weight: 400;
  letter-spacing: .28em;
  text-transform: uppercase;
  color: var(--c2);
}

.panel-meta {
  font-size: 10px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--g1);
}

.deck { border-bottom: 1px solid var(--bd); min-width: 0; }

/* ── LCD ─────────────────────────────────────────────── */

.lcd {
  position: relative;
  background: var(--lcd);
  border-bottom: 1px solid var(--bd);
  padding: 22px 24px 0;
  overflow: hidden;
}

.scan { position: absolute; inset: 0; pointer-events: none; background: var(--scan); }

.lcd-top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-size: 10px;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: var(--g1);
}

.marq-clip {
  overflow: hidden;
  min-width: 0;
  white-space: nowrap;
  margin: 10px 0 2px;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 3%, #000 97%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 3%, #000 97%, transparent);
}

.marq {
  display: inline-flex;
  animation: marq 20s linear infinite;
  will-change: transform;
}

.marq-txt {
  font-family: var(--lcdfont);
  font-size: 62px;
  line-height: 1;
  color: var(--ac);
  padding-right: 80px;
}

.lcd-bot {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.artist {
  font-size: 11px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--g1);
}

.clock {
  display: flex;
  align-items: baseline;
  gap: 9px;
  flex: none;
  white-space: nowrap;
  font-family: var(--lcdfont);
  color: var(--ac);
}
.cur { font-size: 30px; line-height: 1; }
.dur { font-size: 17px; color: var(--g2); }

.vis {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 84px;
  margin-top: 16px;
}
.vis span {
  flex: 1;
  height: 5%;
  background: var(--ac);
  min-height: 2px;
}

/* ── transport ───────────────────────────────────────── */

.transport {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 14px 24px;
}

.tbtns { display: flex; }

.tb {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 36px;
  color: var(--fg);
  font-size: 11px;
  border: 1px solid var(--bd);
  margin-left: -1px;
}
.tb:first-child { margin-left: 0; }
.tb:hover { border-color: var(--ac); color: var(--ac); z-index: 1; }

.tb-play {
  width: 74px;
  font-size: 13px;
  color: var(--acFg);
  background: var(--ac);
  border-color: var(--ac);
}
.tb-play:hover { background: var(--acHi); border-color: var(--acHi); color: var(--acFg); }

.seek {
  flex: 1;
  min-width: 160px;
  height: 36px;
  display: flex;
  align-items: center;
  cursor: pointer;
  border: 1px solid var(--bd);
  padding: 0 8px;
}

.seek-track { position: relative; width: 100%; height: 4px; background: var(--trk); }
.seek-fill { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--ac); }
.seek-head {
  position: absolute;
  top: -6px;
  left: 0;
  width: 3px;
  height: 16px;
  margin-left: -1px;
  background: var(--fg);
}

.knobs { display: flex; gap: 16px; }
.knob-wrap { display: flex; align-items: center; gap: 9px; }
.knob-wrap[hidden] { display: none; }

.knob-lbl {
  font-size: 9px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--c2);
}

.knob {
  position: relative;
  width: 34px;
  height: 34px;
  cursor: ns-resize;
  border: 1px solid var(--bd);
  touch-action: none;
}
.knob:hover { border-color: var(--ac); }

.knob-rot { position: absolute; inset: 0; }

.knob-tick {
  position: absolute;
  left: 50%;
  top: 3px;
  width: 2px;
  height: 12px;
  margin-left: -1px;
  background: var(--ac);
}

.knob-val {
  font-family: var(--lcdfont);
  font-size: 18px;
  line-height: 1;
  color: var(--ac);
  width: 26px;
}

/* ── stat tiles ──────────────────────────────────────── */

.tiles {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--bd);
}

.tile { padding: 14px 20px; border-left: 1px solid var(--bdF); }
.tile:first-child { border-left: 0; }

.tile-v {
  font-family: var(--lcdfont);
  font-size: 34px;
  line-height: 1;
  color: var(--ac);
}

.tile-l {
  font-size: 9px;
  font-weight: 400;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--c2);
  margin-top: 7px;
}

/* ── lower row ───────────────────────────────────────── */

.row-bot {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  flex: 1;
  min-height: 0;
}

.playlist {
  border-right: 1px solid var(--bd);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.playlist .panel-head { padding: 16px 20px 10px; }

/* The one control that says this is a radio. It used to be a 10px text
   link sitting where a caption goes, so it read as a label rather than
   something you press. Outlined means the live stream is there to tune
   into; filled with the dot blinking means it is what you are hearing. */
.back {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 7px 13px;
  font-size: 10px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--ac);
  white-space: nowrap;
  border: 1px solid var(--ac);
}
.back .pulse { animation: none; }
.back:hover { background: var(--ac); color: var(--acFg); }
.back:hover .pulse { background: var(--acFg); }

.back.is-live { background: var(--ac); color: var(--acFg); }
.back.is-live .pulse { background: var(--acFg); }
.back.is-onair .pulse { animation: blink 1.4s steps(1) infinite; }

.tr-head, .track {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 84px;
  gap: 12px;
}

/* Room for the per-row link button, so the columns still line up. */
.tr-head {
  padding: 8px 64px 8px 20px;
  border-top: 1px solid var(--bd);
  border-bottom: 1px solid var(--bd);
  font-size: 9px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--c2);
}
.ta-r { text-align: right; }

.tracks {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.tracks li { display: flex; align-items: stretch; }

.tr-link {
  flex: 0 0 44px;
  min-width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--c3);
  border-bottom: 1px solid var(--bdF);
}
.tr-link:hover { color: var(--ac); background: var(--rowHov); }

.track {
  align-items: center;
  flex: 1;
  min-width: 0;
  padding: 12px 20px;
  border-bottom: 1px solid var(--bdF);
}
.track:hover { background: var(--rowHov); }
.track.is-on { background: var(--rowOn); }

.tr-n { font-family: var(--lcdfont); font-size: 19px; line-height: 1; color: var(--c2); }
.track.is-on .tr-n { color: var(--ac); }

.tr-t { min-width: 0; }

/* Title line, so an advisory badge can sit beside the title without
   pushing it onto its own row. The title keeps the ellipsis. */
.tr-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.tr-line .tr-title { min-width: 0; }

.tr-ex {
  flex: none;
  font-size: 8px;
  letter-spacing: .16em;
  text-transform: uppercase;
  line-height: 1.5;
  padding: 0 4px;
  color: var(--c2);
  border: 1px solid var(--bd);
  border-radius: 2px;
}
.track.is-on .tr-ex { color: var(--ac); border-color: var(--ac); }

.tr-title {
  display: block;
  font-family: var(--sans);
  font-size: 14px;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.track.is-on .tr-title { color: var(--ac); }

.tr-artist {
  display: block;
  font-size: 10px;
  letter-spacing: .1em;
  color: var(--c2);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tr-s {
  text-align: right;
  font-size: 9px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--ac);
}

.panel-note {
  padding: 12px 20px;
  border-bottom: 1px solid var(--bd);
  font-size: 9px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--c3);
}

.geo { display: flex; flex-direction: column; min-height: 0; }

.geo-title { padding: 16px 20px 10px; flex: none; }

.geo-list {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  border-top: 1px solid var(--bd);
}

.geo-row { padding: 11px 20px; border-bottom: 1px solid var(--bdF); }

.geo-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.geo-name {
  font-size: 11px;
  letter-spacing: .06em;
  color: var(--fg);
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.geo-val { font-family: var(--lcdfont); font-size: 17px; line-height: 1; color: var(--ac); }

.geo-bar { height: 3px; margin-top: 8px; background: var(--trk); }
.geo-bar span { display: block; height: 3px; background: var(--ac); }

/* ── footer ──────────────────────────────────────────── */

.foot {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: none;
  padding: 14px 20px;
  border-top: 1px solid var(--bd);
  font-size: 9px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--c2);
}

.status { display: flex; align-items: center; gap: 8px; color: var(--ac); }
.status .pulse { width: 6px; height: 6px; animation-duration: 1.1s; }
.foot .picker { margin-left: auto; }

/* Shown only once the browser says it can actually be installed, so it is
   never a button that does nothing. */
.install {
  display: inline-flex;
  align-items: center;
  padding: 6px 11px;
  font-size: 9px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--ac);
  border: 1px solid var(--ac);
  white-space: nowrap;
}
.install[hidden] { display: none; }
.install:hover { background: var(--ac); color: var(--acFg); }

/* ── noscript ────────────────────────────────────────── */

.noscript {
  position: fixed;
  inset: 0;
  z-index: 50;
  overflow-y: auto;
  padding: 48px 24px;
  background: var(--bg);
  color: var(--fg);
  font-size: 13px;
  line-height: 1.7;
}
.noscript h2 { font-size: 15px; letter-spacing: .1em; text-transform: uppercase; color: var(--ac); margin-bottom: 16px; }
.noscript ul { margin: 16px 0; }
.noscript li { margin-bottom: 8px; }
.noscript code { color: var(--ac); word-break: break-all; }
.noscript p { max-width: 62ch; }

/* The small uppercase labels run 8-11px with wide tracking in dimmed colours;
   a heavier weight keeps them legible. JetBrains Mono ships 400/500/700 here,
   so 500 is a real weight rather than a synthesised one. */
.wordmark, .home, .live-now, .net-sum, .picker-btn, .menu button,
.panel-title, .panel-meta, .lcd-top, .artist,
.tile-l, .tr-head, .tr-s, .tr-artist, .tr-ex, .knob-lbl, .back,
.panel-note, .geo-name, .foot, .status {
  font-weight: var(--wt-small);
}

/* ── responsive ──────────────────────────────────────────
   The design is a fixed 1180x880 canvas scaled to fit. Below that
   width the scale factor would render 9px labels at ~3px, so the
   layout reflows to a single fluid column instead. */

@media (max-width: 900px) {
  .stage { height: auto; min-height: 100dvh; display: block; overflow: visible; }
  .bg { position: fixed; }
  .fit { width: 100%; height: auto; }

  .app {
    width: 100%;
    height: auto;
    min-height: 100dvh;
    transform: none;
    border-left: 0;
    border-right: 0;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
  }

  .row-top, .row-bot { grid-template-columns: minmax(0, 1fr); }
  .row-bot { flex: none; }

  /* The wrappers exist for the desktop grid. Dropping their boxes makes
     every section a direct child of .app, which is what lets the playlist
     move above the stats: they sit in different wrappers otherwise. */
  .row-top, .deck, .row-bot { display: contents; }
  .bar       { order: 0; }
  .lcd       { order: 1; }
  .transport { order: 2; }
  .playlist  { order: 3; }
  .tiles     { order: 4; }
  .geo       { order: 5; }
  .foot      { order: 6; }
  .playlist, .geo { border-right: 0; border-top: 1px solid var(--bd); }

  .playlist { border-right: 0; }
  .tracks, .geo-list { max-height: 340px; }

  .bar { gap: 14px; }
  .bar-r { gap: 14px; width: 100%; }
  .picker { margin-left: auto; }
  .menu { right: auto; left: 0; width: min(240px, 100%); }

  .lcd { padding: 18px 16px 0; }
  .lcd-top { font-size: 9px; letter-spacing: .18em; }
  .lcd-bot { align-items: baseline; gap: 12px; }
  .artist { font-size: 9px; letter-spacing: .14em; }
  .cur { font-size: 24px; }
  .dur { font-size: 14px; }
  .marq-txt { font-size: 44px; }
  .vis { height: 60px; }
  .transport { padding: 14px 16px; }
  .seek { order: 3; width: 100%; flex-basis: 100%; }
  .knobs { margin-left: 0; width: 100%; justify-content: space-between; }

  /* Touch targets. Everything below was 27px to 36px tall, under the 44px
     a fingertip needs, and the knobs were the worst of it at 34 square
     while also being the only controls you have to drag. */
  /* One control bar across the width rather than four buttons huddled at
     the left with the rest of the row empty. */
  .tbtns { width: 100%; }
  .tb { height: 40px; width: auto; flex: 1; }
  .tb-play { flex: 1.6; }

  .seek { height: 44px; }
  .seek.is-live { display: none; }

  /* A dial is the wrong shape for a thumb, and at this size both read as
     empty boxes. They become bars. knobDrag already answers to sideways
     movement, so only the look changes. */
  .knobs { width: 100%; }
  .knob-wrap { flex: 1; gap: 12px; }
  .knob-rot { display: none; }
  .knob-lbl { width: 24px; }
  .knob-val { width: 36px; text-align: right; }
  /* A thin track, but the element keeps its full height so the target
     stays a target: the bar is painted inside it rather than being it. */
  .knob {
    flex: 1;
    width: auto;
    height: 44px;
    border: 0;
    cursor: ew-resize;
    background:
      linear-gradient(90deg,
        var(--ac) calc(var(--v, 0) * 100%), var(--trk) calc(var(--v, 0) * 100%))
      center / 100% 8px no-repeat;
  }

  .foot { flex-wrap: wrap; }
  .foot .picker-btn { min-width: 0; }

  /* 24 themes in a scrolling list, each one a tap target. */
  .menu button { min-height: 44px; }
  .menu { max-height: 60vh; }
  .picker-btn { min-height: 44px; }
  .back { min-height: 44px; display: inline-flex; align-items: center; }
  .install { min-height: 44px; }

  /* The marquee sat 2px off the line beneath it. */
  .marq-clip { margin: 8px 0 12px; }
  .vis { height: 72px; }

  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile:nth-child(3) { border-left: 0; }
  .tile:nth-child(n+3) { border-top: 1px solid var(--bdF); }
}

@media (max-width: 480px) {
  /* Flattening .bar-r lets the picker share the wordmark's row instead of
     claiming one of its own on a screen with no rows to spare. */
  .bar-r { display: contents; }
  .live-now { order: 1; margin-left: auto; }

  .marq-txt { font-size: 34px; }
  .wordmark { letter-spacing: .2em; }
  .home { display: none; }
  .net-sum { display: none; }
  .picker-btn { min-width: 140px; }
}

@media (prefers-reduced-motion: reduce) {
  .marq { animation: none; }
  .pulse { animation: none; }
  * { transition: none !important; }
}
