/* ---- Tokens: "set-top box at night" ---- */
:root {
  --bg: #0e1220;
  --panel: #171d31;
  --panel-2: #1e2540;
  --line: #262f4e;
  --text: #edeff7;
  --muted: #8b93af;
  --live: #ff3b4e;
  --now: #ff3b4e;

  --cat-uk: #c4384d;
  --cat-us: #3b6fe0;
  --cat-sport: #2fa36b;
  --cat-news: #e0a93b;
  --cat-fun: #b54fd8;

  --rail-w: 216px;
  --px-per-min: 4;      /* 30 min slot = 120px */
  --row-h: 72px;

  --font-display: "Barlow Condensed", "Arial Narrow", sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  display: flex;
  flex-direction: column;
}

/* ---- Top bar ---- */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #131830, var(--bg));
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { color: var(--live); font-size: 18px; letter-spacing: -3px; }
.brand h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 26px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.brand h1 em { font-style: normal; color: var(--muted); font-weight: 500; }

.daynav { display: flex; gap: 6px; flex: 1; overflow-x: auto; }
.daynav button {
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 6px 14px;
  cursor: pointer;
  white-space: nowrap;
}
.daynav button:hover { color: var(--text); border-color: var(--line); }
.daynav button.active { color: var(--text); background: var(--panel-2); border-color: var(--line); }

.topbar-right { display: flex; align-items: center; gap: 14px; }
.clock {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  letter-spacing: 0.06em;
}

.btn {
  display: inline-block;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 6px;
  padding: 7px 14px;
  text-decoration: none;
  font: 500 13px var(--font-body);
  cursor: pointer;
}
.btn:hover { background: #253057; }
.btn.ghost { background: transparent; }

/* ---- Guide grid ---- */
main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.guide-scroller { flex: 1; overflow: auto; position: relative; }
.guide { position: relative; width: max-content; min-width: 100%; }

.time-ruler {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  height: 34px;
  margin-left: var(--rail-w);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.time-ruler .tick {
  flex: 0 0 calc(var(--px-per-min) * 30px);
  font-family: var(--font-display);
  font-size: 15px;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 8px 0 0 8px;
  border-left: 1px solid var(--line);
}

/* Category band header — collapsible */
.cat-band {
  position: sticky;
  left: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 34px;
  padding: 0 14px;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text);
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  border-top: 1px solid var(--line);
  width: 100vw;
  max-width: 100%;
  cursor: pointer;
  user-select: none;
}
.cat-band:hover { background: var(--panel-2); }
.cat-band .swatch { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }
.cat-band .cat-count { color: var(--muted); font-size: 12px; font-weight: 500; letter-spacing: 0.06em; text-transform: none; }
.cat-band .collapse-arrow { margin-left: auto; font-size: 11px; color: var(--muted); }
.cat-band.collapsed { opacity: 0.7; }
.cat-band.collapsed .collapse-arrow { color: var(--text); }

/* Channel rows */
.channel-row { display: flex; height: var(--row-h); border-bottom: 1px solid var(--line); }
.channel-cell {
  position: sticky;
  left: 0;
  z-index: 3;
  flex: 0 0 var(--rail-w);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  background: var(--panel);
  border-right: 2px solid var(--line);
  border-left: 4px solid var(--cat-color, var(--line));
}
.channel-cell img {
  width: 40px; height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--panel-2);
}
.channel-cell .no-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--panel-2);
  display: grid; place-items: center;
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--muted);
}
.channel-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
/* Avatar and name link to the channel — no visual noise, subtle hover */
.channel-link {
  color: inherit;
  text-decoration: none;
  min-width: 0;
  display: block;
}
.channel-link:hover .channel-name { color: #fff; text-decoration: underline; text-underline-offset: 3px; }
.channel-link:hover img, .channel-link:hover .no-avatar { outline: 2px solid var(--line); }
.channel-name {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: 0.03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Discreet subscribe link — muted until hovered, then YouTube red */
.sub-link {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  letter-spacing: 0.04em;
  width: fit-content;
}
.sub-link:hover { color: var(--live); }
/* Modal footer subscribe button — same subtlety, red on hover */
.btn.sub-btn { color: var(--muted); }
.btn.sub-btn:hover { color: #fff; background: var(--live); border-color: var(--live); }
.channel-live-dot {
  display: inline-block;
  margin-left: 6px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 8px var(--live);
  animation: pulse 1.6s infinite;
}
@keyframes pulse { 50% { opacity: 0.4; } }

.track { position: relative; height: 100%; }

.prog {
  position: absolute;
  top: 6px;
  bottom: 6px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 10px;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.prog:hover, .prog:focus-visible { background: #2a3560; border-color: #3b4a85; outline: none; }
.prog:focus-visible { box-shadow: 0 0 0 2px var(--cat-us); }

/* Title: always bright white */
.prog .p-title {
  font-weight: 600;
  font-size: 13px;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Meta: clearly readable muted colour */
.prog .p-meta {
  font-size: 11px;
  color: #a0a8c4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Video filler: subtle blue-grey, category left accent */
.prog.video {
  background: linear-gradient(180deg, #1c2236, #171d2e);
  border-left: 3px solid var(--cat-color, var(--line));
}
.prog.video .p-title { color: #d8ddf0; }

/* Scheduled (non-live) show: stronger blue tint, thicker left border */
.prog.show {
  background: linear-gradient(180deg, #232c52, #1b2242);
  border: 1px solid #3a4878;
  border-left: 4px solid var(--cat-color, #3a4878);
}
.prog.show .p-title { font-size: 14px; color: #ffffff; }

/* Live-stream show: strong red border on ALL sides + glow */
.prog.show.live-show {
  background: linear-gradient(180deg, #2e1820, #1f1018);
  border: 2px solid rgba(255, 59, 78, 0.85) !important;
  border-left: 5px solid var(--live) !important;
  box-shadow: 0 0 16px rgba(255, 59, 78, 0.5), inset 0 0 20px rgba(255, 59, 78, 0.1);
}
.prog.show.live-show:hover {
  background: linear-gradient(180deg, #3d1e28, #2a1220);
  border-color: rgba(255, 59, 78, 1) !important;
  box-shadow: 0 0 24px rgba(255, 59, 78, 0.7), inset 0 0 20px rgba(255, 59, 78, 0.15);
}
.prog.show.live-show .p-title { color: #ffcdd2; font-size: 14px; }

/* Currently on air */
.prog.on-now {
  border-color: var(--cat-color, #3b4a85) !important;
  box-shadow: 0 0 10px rgba(255,255,255,0.08);
}

/* Empty placeholder */
.prog.empty {
  opacity: 0.35;
  cursor: default;
  border-style: dashed;
}
.prog.empty .p-title { color: #8b93af; font-style: italic; }

.badge-live {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #fff;
  background: var(--live);
  border-radius: 3px;
  padding: 1px 6px;
  margin-right: 6px;
  vertical-align: middle;
}

/* Scheduled non-live tag */
.badge-scheduled {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.10em;
  color: #c8d4ff;
  background: rgba(60, 80, 180, 0.55);
  border: 1px solid rgba(100, 130, 255, 0.4);
  border-radius: 3px;
  padding: 1px 6px;
  margin-right: 6px;
  vertical-align: middle;
}

/* NOW playhead */
.nowline {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--now);
  z-index: 10;
  pointer-events: none;
  box-shadow: 0 0 14px rgba(255, 59, 78, 0.9);
  display: none; /* JS controls visibility via style.display */
}
.nowline span {
  position: sticky;
  top: 36px;
  display: inline-block;
  transform: translateX(-50%);
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  background: var(--now);
  color: #fff;
  border-radius: 3px;
  padding: 1px 6px;
}

.empty-state { text-align: center; color: var(--muted); padding: 60px 20px; font-size: 15px; }
.empty-state a { color: var(--text); }

/* ---- Modal player ---- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 18, 0.82);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 20px;
}
.modal[hidden] { display: none; }
.modal-card {
  width: min(920px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 14px 18px;
}
.modal-eyebrow {
  margin: 0 0 2px;
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.modal-head h2 { margin: 0; font-size: 17px; font-weight: 600; }
.player { aspect-ratio: 16 / 9; background: #000; }
.player iframe { width: 100%; height: 100%; border: 0; display: block; }
.modal-foot { padding: 12px 18px; display: flex; justify-content: flex-end; }

/* ---- Reduced motion / small screens ---- */
@media (prefers-reduced-motion: reduce) {
  .channel-live-dot { animation: none; }
  .prog { transition: none; }
}
@media (max-width: 720px) {
  :root { --rail-w: 140px; --px-per-min: 3; }
  .brand h1 { font-size: 20px; }
  .clock { display: none; }
  .channel-name { font-size: 15px; }
}
