/* Layout: cable-guide channel. TV + "now playing" panel up top, scrolling listings grid below. */
:root {
  --navy: #07124a;        /* page ground, the guide channel's deep blue */
  --grid: #13299c;        /* listing cells */
  --grid-hi: #2342d6;     /* hovered / tuned row */
  --line: #050b33;        /* gaps between cells */
  --gold: #ffd23a;        /* titles, the guide's yellow type */
  --ivory: #f3efe2;       /* body text */
  --red: #d8322b;         /* channel number tiles */
  --osd: #5dff6a;         /* on-screen display green */
  --wood: #4a2f1c;        /* TV cabinet */
  --wood-hi: #6b4428;
  --font-guide: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --font-osd: "VT323", "Courier New", monospace;
  --font-logo: "Bungee", "Impact", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { background: var(--navy); color: var(--ivory); }
body { font-family: var(--font-guide); font-size: 17px; line-height: 1.35; }

.app {
  max-width: 1200px;
  margin: 0 auto;
  padding-inline: 16px;
  padding-block: 12px 24px;
  display: grid;
  gap: 14px;
}

/* ---------- Masthead ---------- */
.masthead { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.logo { display: flex; align-items: baseline; gap: 2px; flex-wrap: wrap; }
.logo-retro, .logo-cable { font-family: var(--font-logo); font-size: clamp(26px, 5vw, 40px); line-height: 1; letter-spacing: .02em; }
.logo-retro { color: var(--gold); text-shadow: 3px 3px 0 var(--red); }
.logo-cable { color: var(--ivory); text-shadow: 3px 3px 0 var(--grid); }
.logo-tag { margin-left: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .14em; font-size: 14px; color: var(--gold); }
.clock { font-family: var(--font-osd); font-size: 34px; color: var(--gold); display: flex; gap: 10px; align-items: baseline; font-variant-numeric: tabular-nums; }
#clockAmPm { font-size: 22px; }

/* ---------- Top: TV + now panel ---------- */
.top { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }

.tv-cabinet {
  background: linear-gradient(160deg, var(--wood-hi), var(--wood) 55%, #2d1b0f);
  border-radius: 22px;
  padding: 18px 18px 10px;
  box-shadow: 0 10px 0 #1d1109, 0 18px 40px rgba(0,0,0,.55), inset 0 2px 0 rgba(255,255,255,.12);
}
.screen {
  position: relative;
  aspect-ratio: 16 / 9;
  max-width: 100%;
  background: #000;
  border-radius: 6px;
  overflow: hidden;
  border: 8px solid #141414;
  box-shadow: 0 0 0 2px #3a3a3a;
}
.screen > iframe, .screen > canvas, .bars, .testcard, .poweron {
  position: absolute; inset: 0; width: 100%; height: 100%; border: 0;
}
#snow { image-rendering: pixelated; display: block; }
#yt { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; visibility: hidden; z-index: 1; }
.screen[data-mode="yt"] #yt { visibility: visible; }
.screen.flash #yt { visibility: hidden; }
.screen.on-video #snow { opacity: 0; }
.screen.flash #snow { opacity: 1; z-index: 3; }

/* Find a show */
.finder { position: relative; display: grid; gap: 6px; }
.finder-label { text-transform: uppercase; letter-spacing: .14em; font-size: 14px; font-weight: 700; color: var(--gold); }
.finder-box { position: relative; display: flex; align-items: center; }
#find {
  width: 100%; font: inherit; font-size: 20px; color: var(--ivory);
  background: var(--grid); border: 3px solid var(--line); box-shadow: inset 0 0 0 2px var(--grid-hi);
  padding: 10px 14px; border-radius: 4px;
}
.finder-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
#find::placeholder { color: rgba(243,239,226,.6); }
#find:focus { outline: 3px solid var(--gold); outline-offset: 1px; }
.finder-count { font-size: 14px; opacity: .75; font-variant-numeric: tabular-nums; }
.finder-results {
  list-style: none; margin: 0; padding: 3px; display: grid; gap: 3px;
  background: var(--line); max-height: 360px; overflow-y: auto;
  position: absolute; left: 0; right: 0; top: 100%; z-index: 20;
  box-shadow: 0 12px 30px rgba(0,0,0,.6);
}
.finder-results button {
  width: 100%; text-align: left; font: inherit; color: var(--ivory); cursor: pointer;
  background: var(--grid); border: 0; padding: 8px 12px; display: grid; gap: 2px;
}
.finder-results button:hover, .finder-results button:focus-visible { background: var(--grid-hi); outline: none; }
.finder-results b { color: var(--gold); font-size: 18px; }
.finder-results small { font-size: 14px; opacity: .85; }
.finder-results .empty { padding: 10px 12px; background: var(--grid); }

/* OSD channel number, top right like a 90s set */
.osd {
  position: absolute; top: 6%; right: 7%; z-index: 6;
  font-family: var(--font-osd); color: var(--osd);
  font-size: clamp(28px, 6vw, 56px); line-height: .9; text-align: right;
  text-shadow: 0 0 6px rgba(93,255,106,.7), 2px 2px 0 #000;
  opacity: 0; transition: opacity .2s;
  pointer-events: none;
}
.osd.show { opacity: 1; }
.osd small { display: block; font-size: .5em; }

/* Power-on overlay */
.poweron {
  z-index: 7; display: grid; place-content: center; justify-items: center; gap: 10px;
  background: rgba(0,0,0,.45); text-align: center; padding: 16px;
}
.poweron small { color: var(--ivory); opacity: .85; font-size: 15px; }
.power-btn {
  font-family: var(--font-osd); font-size: 30px; color: var(--osd);
  background: #000; border: 2px solid var(--osd); border-radius: 8px;
  padding: 8px 20px; cursor: pointer; display: flex; gap: 10px; align-items: center;
  text-shadow: 0 0 6px rgba(93,255,106,.7);
}
.power-btn:hover, .power-btn:focus-visible { background: #0b2a10; outline: none; }

/* SMPTE-style color bars for empty channels */
.bars { z-index: 2; display: grid; grid-template-rows: 67% 8% 25%; }
.bars > div { display: grid; }
.bars-top, .bars-mid { grid-template-columns: repeat(7, 1fr); }
.bars-bot { grid-template-columns: 5fr 5fr 5fr 6fr; }
.bars-top i:nth-child(1){background:#c0c0c0}.bars-top i:nth-child(2){background:#c0c000}
.bars-top i:nth-child(3){background:#00c0c0}.bars-top i:nth-child(4){background:#00c000}
.bars-top i:nth-child(5){background:#c000c0}.bars-top i:nth-child(6){background:#c00000}
.bars-top i:nth-child(7){background:#0000c0}
.bars-mid i:nth-child(1){background:#0000c0}.bars-mid i:nth-child(2){background:#131313}
.bars-mid i:nth-child(3){background:#c000c0}.bars-mid i:nth-child(4){background:#131313}
.bars-mid i:nth-child(5){background:#00c0c0}.bars-mid i:nth-child(6){background:#131313}
.bars-mid i:nth-child(7){background:#c0c0c0}
.bars-bot i:nth-child(1){background:#00214c}.bars-bot i:nth-child(2){background:#fff}
.bars-bot i:nth-child(3){background:#32006a}.bars-bot i:nth-child(4){background:#131313}
.bars-label {
  position: absolute; left: 50%; top: 34%; transform: translate(-50%, -50%);
  background: #000; color: #fff; padding: 10px 22px; text-align: center;
  font-family: var(--font-osd); display: grid; gap: 2px; border: 2px solid #fff;
}
.bars-label strong { font-size: 34px; letter-spacing: .1em; }
.bars-label span { font-size: 24px; color: var(--gold); }
.bars-label small { font-size: 16px; opacity: .8; }

/* Preview-mode stand-in when a player can't load */
.testcard {
  z-index: 2; display: grid; place-content: center; justify-items: center; gap: 6px;
  text-align: center; padding: 8%;
  background: radial-gradient(circle at 50% 40%, #1b3bc4, #07124a 75%);
}
.testcard-eyebrow { text-transform: uppercase; letter-spacing: .16em; font-size: 13px; color: var(--gold); }
.testcard strong { font-size: clamp(20px, 3.4vw, 32px); line-height: 1.1; text-wrap: balance; }
.testcard a { color: var(--gold); font-weight: 700; margin-top: 6px; }
.testcard small { font-size: 13px; opacity: .7; max-width: 34ch; margin-top: 6px; }

.tv-chin { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding-top: 10px; flex-wrap: wrap; }
.brand { font-family: var(--font-logo); font-size: 13px; letter-spacing: .3em; color: #d9b98a; text-shadow: 0 1px 0 #000; }
.knobs { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.vol { display: flex; align-items: center; gap: 6px; font-size: 13px; letter-spacing: .1em; color: #d9b98a; }
.vol input { width: 110px; accent-color: var(--gold); }
.ch-btn {
  font-family: var(--font-guide); font-weight: 700; font-size: 16px; letter-spacing: .06em;
  background: linear-gradient(#333, #111); color: var(--ivory);
  border: 1px solid #000; border-radius: 6px; padding: 7px 14px; cursor: pointer;
  box-shadow: 0 3px 0 #000, inset 0 1px 0 rgba(255,255,255,.2);
}
.ch-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #000; }
.ch-btn:focus-visible, .row:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* Now panel */
.now { display: grid; gap: 14px; min-width: 0; }
.now-card {
  background: linear-gradient(var(--grid), #0d1f7a);
  border: 3px solid var(--line); box-shadow: inset 0 0 0 2px var(--grid-hi);
  padding: 14px 16px;
}
.now-chan { display: flex; gap: 12px; align-items: center; }
.now-num {
  background: var(--red); color: #fff; font-weight: 800; font-size: 40px;
  min-width: 64px; text-align: center; padding: 2px 8px; line-height: 1.1;
  box-shadow: inset 0 -4px 0 rgba(0,0,0,.25); font-variant-numeric: tabular-nums;
}
.now-call { display: block; font-weight: 800; font-size: 26px; color: var(--gold); letter-spacing: .06em; line-height: 1; }
.now-name { display: block; font-size: 17px; text-transform: uppercase; letter-spacing: .08em; }
.now-blurb { margin: 10px 0; font-size: 17px; }
.now-meta { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: 16px; }
.now-meta dt { text-transform: uppercase; letter-spacing: .12em; font-size: 13px; color: var(--gold); padding-top: 2px; }
.now-meta dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* Viewer support card, styled like a station PSA slide */
.support {
  display: grid; gap: 8px; padding: 14px 16px;
  background: repeating-linear-gradient(135deg, #0d1f7a 0 14px, #10248a 14px 28px);
  border: 3px solid var(--line); box-shadow: inset 0 0 0 2px var(--gold);
}
.support-eyebrow { text-transform: uppercase; letter-spacing: .14em; font-size: 12px; color: var(--gold); }
.support strong { font-family: var(--font-logo); font-weight: 400; font-size: 22px; line-height: 1.1; color: var(--ivory); text-wrap: balance; }
.support p { margin: 0; font-size: 16px; }
.support-btn {
  justify-self: start; background: var(--gold); color: var(--navy); text-decoration: none;
  font-weight: 800; font-size: 18px; padding: 8px 16px; border-radius: 6px;
  box-shadow: 0 3px 0 #a8850f;
}
.support-btn:hover, .support-btn:focus-visible { background: #ffe07a; outline: none; }
.support-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #a8850f; }

/* ---------- Guide grid ---------- */
.guide { min-width: 0; }
.guide-head, .row { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 3px; }
.guide-head { background: var(--line); padding: 3px; }
.gh-chan, .gh-slots span {
  background: var(--gold); color: var(--navy); font-weight: 800; text-transform: uppercase;
  letter-spacing: .06em; padding: 4px 8px; font-variant-numeric: tabular-nums;
}
.gh-slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; }

.guide-window {
  height: 360px; overflow: hidden; position: relative;
  background: var(--line); padding: 0 3px 3px;
}
.guide-rows { display: grid; gap: 3px; will-change: transform; }
.guide-window.scrolling .guide-rows { animation: roll var(--roll-time, 40s) linear infinite; }
.guide-window:hover .guide-rows, .guide-window:focus-within .guide-rows, .guide-window.paused .guide-rows { animation-play-state: paused; }
@keyframes roll { from { transform: translateY(0); } to { transform: translateY(var(--roll-dist, -50%)); } }

.row {
  width: 100%; border: 0; padding: 0; background: none; color: inherit; font: inherit;
  text-align: left; cursor: pointer;
}
.row-chan {
  background: var(--red); color: #fff; padding: 6px 8px; display: grid; align-content: center;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.25);
}
.row-chan b { font-size: 26px; line-height: 1; font-variant-numeric: tabular-nums; }
.row-chan span { font-size: 14px; font-weight: 700; letter-spacing: .08em; }
.row-progs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; min-width: 0; }
.cell {
  background: var(--grid); padding: 6px 10px; min-width: 0;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.15);
}
.cell b { display: block; color: var(--gold); font-weight: 700; font-size: 18px; line-height: 1.15;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell small { font-size: 14px; opacity: .85; }
.cell.span3 { grid-column: span 3; }
.row:hover .cell, .row:focus-visible .cell { background: var(--grid-hi); }
.row.tuned .row-chan { background: var(--gold); color: var(--navy); }
.row.tuned .cell { background: var(--grid-hi); }
.guide-hint { margin: 8px 0 0; font-size: 14px; opacity: .7; }

.foot { border-top: 2px solid var(--grid); padding-top: 12px; font-size: 15px; opacity: .85; }
.foot p { margin: 0 0 6px; max-width: 70ch; }
.foot a { color: var(--gold); }

/* ---------- Narrow screens ---------- */
@media (max-width: 860px) {
  .top { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .tv-cabinet { padding: 10px 10px 8px; border-radius: 14px; }
  .screen { border-width: 5px; }
  #find { font-size: 17px; }
  .guide-head, .row { grid-template-columns: 74px minmax(0, 1fr); }
  .gh-slots, .row-progs { grid-template-columns: 1fr; }
  .gh-slots span:nth-child(n+2), .cell:nth-child(n+2) { display: none; }
  .cell.span3 { grid-column: auto; display: block; }
  .row-chan b { font-size: 22px; }
  .clock { font-size: 26px; }
}
@media (prefers-reduced-motion: reduce) {
  .guide-window { overflow-y: auto; }
  .guide-window.scrolling .guide-rows { animation: none; }
}
