/* CrackDaddys Cable - TV guide
   Remote-first: every interactive state is reachable with arrow keys + OK.
   Sized for a 10-foot viewing distance, not a mouse. */

:root {
  /* The band must never be shorter than its own content, or the flex column inside
     squeezes the text rows and clips the glyphs mid-line. 36vh alone is only 259px at
     720p while the panel needs ~300px, so pin a floor and let it grow on bigger screens. */
  --band: max(322px, 36vh);   /* height of the now-playing / picture band */
  --rowh: 62px;            /* one channel row */
  --rulerh: 38px;          /* time ruler header */
  --chanw: 194px;          /* channel column width */
  --colw: 6;               /* 30-minute columns visible */

  --ink:      #eaf2ff;
  --ink-dim:  #9db4d4;
  --navy-0:   #050d1a;
  --navy-1:   #0b1c36;
  --navy-2:   #16305c;
  --navy-3:   #1e4179;
  --accent:   #ff9d19;
  --accent-2: #ffd24a;
  --now:      #ff3b30;

  --bevel-hi: rgba(255,255,255,.22);
  --bevel-lo: rgba(0,0,0,.55);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--navy-0);
  color: var(--ink);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  cursor: none;                 /* it is a TV. the remote is the cursor. */
}

.hidden { display: none !important; }

/* Pointer-driven clients - a tablet on the couch, a laptop - need a visible cursor and
   tappable affordances. A pure TV emits no pointer events at all, so the cursorless
   presentation above still applies to it either way. */
@media (hover: hover), (any-pointer: coarse) {
  html, body { cursor: auto; }
  .chcell, .prog { cursor: pointer; }
}
/* Kill the double-tap-to-zoom delay on touch, and stop the browser claiming the
   horizontal swipe we use for paging programmes. */
.chcell, .prog, #rows { -webkit-tap-highlight-color: transparent; }
#rows { touch-action: none; }
body.is-loading #guide,
body.is-loading #topband { display: none; }

/* -------------------------------------------------------------- top band */

#topband {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--band);
  display: flex;
  background: linear-gradient(135deg, #123059 0%, #071831 55%, #050d1a 100%);
  border-bottom: 1px solid var(--bevel-hi);
  z-index: 2;
}

#nowpanel {
  flex: 1 1 auto; min-width: 0;
  padding: 16px 30px 14px;
  display: flex; flex-direction: column;
  border-right: 1px solid rgba(0,0,0,.7);
}

/* No row in this column may shrink. Flex would otherwise compress the tallest text row
   (the title) to recover space, and with overflow:hidden that silently slices the glyphs
   through the middle instead of overflowing where it can be seen and fixed. */
#nowpanel > * { flex: 0 0 auto; }

.np-brand {
  display: flex; align-items: center; gap: 9px;
  font: 700 15px/1 "Arial Narrow", Arial, sans-serif;
  letter-spacing: .16em; text-transform: uppercase;
  color: var(--ink-dim);
}
.np-brand em { font-style: normal; color: var(--accent); margin-left: 5px; }
.brand-sq {
  background: var(--accent); color: #21160a;
  font-size: 12px; font-weight: 800; letter-spacing: .02em;
  padding: 4px 6px; border-radius: 2px;
}

.np-ch { margin-top: 10px; display: flex; align-items: baseline; gap: 16px; min-width: 0; }
.np-num {
  font: 800 76px/0.9 "Arial Narrow", Arial, sans-serif;
  color: var(--accent); letter-spacing: -.02em;
  text-shadow: 0 2px 0 rgba(0,0,0,.5);
}
.np-net {
  font: 700 34px/1 "Arial Narrow", Arial, sans-serif;
  letter-spacing: .1em; text-transform: uppercase; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.np-rule {
  margin: 12px 0 10px; height: 3px; width: 116px;
  background: linear-gradient(90deg, var(--accent), rgba(255,157,25,0));
}
.np-label {
  font: 700 11.5px/1 "Arial Narrow", Arial, sans-serif;
  letter-spacing: .28em; color: var(--ink-dim);
}
.np-title {
  margin-top: 7px;
  font: 700 32px/1.12 "Arial Narrow", Arial, sans-serif;
  letter-spacing: .01em; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.np-sub {
  margin-top: 5px;
  font: 500 18px/1.15 "Arial Narrow", Arial, sans-serif;
  letter-spacing: .05em; color: var(--ink-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.np-foot {
  margin-top: auto; display: flex; align-items: baseline; gap: 14px;
  padding-top: 12px; min-width: 0;
}
.np-nextlabel {
  font: 700 11.5px/1 "Arial Narrow", Arial, sans-serif;
  letter-spacing: .24em; color: var(--accent);
  flex: 0 0 auto;
}
.np-next {
  font: 600 19px/1.15 "Arial Narrow", Arial, sans-serif;
  letter-spacing: .04em; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.np-foot2 {
  margin-top: 9px; display: flex; align-items: baseline; gap: 18px;
  padding-top: 9px; border-top: 1px solid rgba(255,255,255,.09);
  font: 700 16px/1 "Arial Narrow", Arial, sans-serif;
  letter-spacing: .06em;
}
.np-range { color: var(--accent-2); }
.np-clock { color: var(--ink-dim); }

/* the picture lives in a true 16:9 box so a 16:9 stream is never cropped */
#videobox {
  position: relative;
  flex: 0 0 auto;
  height: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.07);
}
#player { width: 100%; height: 100%; object-fit: cover; display: block; background: #000; }

/* full-screen viewing */
body.solo #topband { height: 100vh; }
body.solo #nowpanel { display: none; }
body.solo #videobox { width: 100%; height: 100vh; aspect-ratio: auto; }
body.solo #guide { display: none; }

/* ------------------------------------------------------------ tune banner */

#banner {
  position: absolute;
  left: 26px; bottom: 26px;
  display: flex; align-items: stretch;
  background: linear-gradient(180deg, rgba(22,48,92,.96), rgba(5,13,26,.96));
  border: 1px solid var(--bevel-hi);
  border-radius: 3px;
  box-shadow: 0 10px 30px rgba(0,0,0,.6), inset 0 1px 0 var(--bevel-hi);
  overflow: hidden;
  transition: opacity .4s ease;
  z-index: 6;
}
body:not(.solo) #banner { display: none; }   /* the now-panel already says this */
#banner.fade { opacity: 0; }

.bn-num {
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  color: #21160a;
  font: 800 54px/1 "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  padding: 9px 18px 11px;
  min-width: 96px; text-align: center;
  text-shadow: 0 1px 0 rgba(255,255,255,.4);
}
.bn-body { padding: 11px 22px 11px 18px; display: flex; flex-direction: column; justify-content: center; }
.bn-net {
  font: 700 20px/1.1 "Arial Narrow", Arial, sans-serif;
  letter-spacing: .14em; text-transform: uppercase;
}
.bn-now { margin-top: 5px; font-size: 14px; color: var(--ink-dim); }
.bn-time {
  padding: 0 18px; display: flex; align-items: center;
  border-left: 1px solid rgba(255,255,255,.14);
  font: 700 19px/1 "Arial Narrow", Arial, sans-serif;
  color: var(--accent-2); letter-spacing: .06em;
}

/* browsers start muted; this is the only cue that sound is waiting on a button press */
.soundhint {
  position: absolute; right: 14px; bottom: 12px;
  padding: 6px 12px;
  font: 700 12px/1 "Arial Narrow", Arial, sans-serif;
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--accent-2);
  background: rgba(5,13,26,.82);
  border: 1px solid var(--bevel-hi);
  border-radius: 2px;
  pointer-events: none;
}

/* ------------------------------------------------------------------- boot */

#boot {
  position: fixed; inset: 0; z-index: 20;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 22px;
  background: radial-gradient(ellipse at 50% 40%, #123059 0%, #050d1a 70%);
}
body:not(.is-loading) #boot { display: none; }
.boot-mark {
  font: 800 68px/1 "Arial Narrow", Arial, sans-serif; letter-spacing: .1em;
  color: var(--accent);
  border: 3px solid var(--accent);
  padding: 16px 26px; border-radius: 4px;
  box-shadow: inset 0 0 30px rgba(255,157,25,.25);
}
.boot-msg { font: 600 15px/1 "Arial Narrow", Arial, sans-serif; letter-spacing: .3em; color: var(--ink-dim); }

/* ------------------------------------------------------------------ guide */

#guide {
  position: fixed; left: 0; right: 0; bottom: 0;
  height: calc(100vh - var(--band));
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, rgba(11,28,54,.99) 0%, rgba(5,13,26,1) 100%);
  z-index: 4;
}

#ghead {
  flex: 0 0 46px;
  display: flex; align-items: center;
  padding: 0 20px;
  background: linear-gradient(180deg, var(--navy-3), var(--navy-1));
  border-bottom: 1px solid rgba(0,0,0,.6);
  box-shadow: inset 0 1px 0 var(--bevel-hi);
}
/* The tabs replace a static "PROGRAM GUIDE" label: they are the way into Browse By Show,
   and they have to LOOK pressable or nobody discovers it with a D-pad. Reached with UP
   from the first channel row - the usual guide gesture, so it needs no explanation. */
.gh-tabs { display: flex; gap: 9px; align-items: center; padding: 4px; border-radius: 3px; }
.gh-tabs .tab {
  font: 700 14px/1 "Arial Narrow", Arial, sans-serif;
  letter-spacing: .18em; text-transform: uppercase;
  color: var(--ink-dim);
  padding: 8px 15px 7px; border-radius: 2px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.035);
}
.gh-tabs .tab.on { color: #21160a; background: var(--accent); border-color: var(--accent); }
/* when the D-pad is up here, say so unambiguously - a TV has no hover state to lean on */
.gh-tabs.live { box-shadow: inset 0 0 0 2px rgba(255,157,25,.55); }
.gh-tabs.live .tab.cur { outline: 2px solid #fff; outline-offset: 1px; }
.ghead-hints {
  margin-left: auto; margin-right: 24px;
  display: flex; gap: 22px;
  font: 600 13px/1 "Arial Narrow", Arial, sans-serif;
  letter-spacing: .12em; color: var(--ink-dim); text-transform: uppercase;
}
.ghead-hints b { color: var(--accent-2); font-weight: 700; }
.ghead-clock {
  font: 700 21px/1 "Arial Narrow", Arial, sans-serif;
  letter-spacing: .06em; color: var(--ink);
  padding-left: 20px; border-left: 1px solid rgba(255,255,255,.14);
}

/* -------------------------------------------------------- browse by show */

#showview { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; padding: 10px 16px 14px; }

#showhead {
  flex: 0 0 auto; display: flex; align-items: baseline; gap: 18px;
  padding: 0 10px 9px;
  font: 600 12.5px/1 "Arial Narrow", Arial, sans-serif;
  letter-spacing: .14em; text-transform: uppercase; color: var(--ink-dim);
}
#showhead .sh-count { color: var(--accent-2); font-weight: 700; }

/* Two columns, not cards. A cable "browse by title" wall reads as a list of names at a
   glance; a grid of boxes makes the viewer read each one. Density wins on a TV. */
#showlist {
  flex: 1 1 auto; min-height: 0;
  display: grid; grid-template-columns: 1fr 1fr; gap: 3px 24px;
  align-content: start;
  overflow: hidden;
}

.showrow {
  display: flex; align-items: baseline; gap: 12px;
  height: 50px; padding: 0 12px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05);
}
.showrow .nm {
  flex: 1 1 auto; min-width: 0;
  font: 700 22px/1 "Arial Narrow", Arial, sans-serif;
  letter-spacing: .02em; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.showrow .net {
  flex: 0 0 auto;
  font: 700 12.5px/1 "Arial Narrow", Arial, sans-serif;
  letter-spacing: .12em; text-transform: uppercase; color: var(--ink-dim);
}
.showrow .when {
  flex: 0 0 auto; min-width: 104px; text-align: right;
  font: 700 13.5px/1 "Arial Narrow", Arial, sans-serif;
  letter-spacing: .08em; color: var(--accent-2);
}
.showrow.live .when { color: #6cf07a; }              /* on right now */
.showrow.on { background: linear-gradient(90deg, rgba(255,157,25,.26), rgba(255,157,25,.04)); }
.showrow.on .nm { color: #fff; }
.showrow.sel { box-shadow: inset 0 0 0 2px var(--accent); }

/* ------------------------------------------------------------------- grid */

#grid { flex: 1 1 auto; display: flex; min-height: 0; }

#colchan {
  flex: 0 0 var(--chanw);
  border-right: 2px solid rgba(0,0,0,.7);
  display: flex; flex-direction: column;
  background: linear-gradient(90deg, var(--navy-1), var(--navy-2));
}
.chantag {
  flex: 0 0 var(--rulerh);
  display: flex; align-items: center; justify-content: center;
  font: 700 12px/1 "Arial Narrow", Arial, sans-serif; letter-spacing: .2em;
  color: var(--ink-dim);
  background: linear-gradient(180deg, var(--navy-3), var(--navy-2));
  border-bottom: 1px solid rgba(0,0,0,.6);
  box-shadow: inset 0 1px 0 var(--bevel-hi);
}
#chanlist { overflow: hidden; }

.chcell {
  height: var(--rowh);
  display: flex; align-items: center; gap: 12px;
  padding: 0 12px 0 14px;
  border-bottom: 1px solid rgba(0,0,0,.55);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
}
.chcell .num {
  font: 800 29px/1 "Arial Narrow", Arial, sans-serif;
  color: var(--ink-dim); min-width: 46px; text-align: right;
  letter-spacing: -.01em;
}
.chcell .nm {
  font: 700 13.5px/1.15 "Arial Narrow", Arial, sans-serif;
  letter-spacing: .09em; text-transform: uppercase; color: var(--ink);
}
.chcell.on { background: linear-gradient(90deg, rgba(255,157,25,.24), rgba(255,157,25,.04)); }
.chcell.on .num { color: var(--accent-2); }
.chcell.on .nm { color: #fff; }

#colgrid { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

#ruler {
  flex: 0 0 var(--rulerh);
  display: grid; grid-template-columns: repeat(var(--colw), 1fr);
  background: linear-gradient(180deg, var(--navy-3), var(--navy-2));
  border-bottom: 1px solid rgba(0,0,0,.6);
  box-shadow: inset 0 1px 0 var(--bevel-hi);
}
#ruler div {
  display: flex; align-items: center;
  padding-left: 10px;
  font: 700 13.5px/1 "Arial Narrow", Arial, sans-serif;
  letter-spacing: .1em; color: var(--ink-dim);
  border-right: 1px solid rgba(0,0,0,.4);
  box-shadow: inset -1px 0 0 rgba(255,255,255,.05);
}
#ruler div.now-col { color: var(--accent-2); }

#rows { position: relative; flex: 1 1 auto; overflow: hidden; }

.row {
  position: relative;
  height: var(--rowh);
  border-bottom: 1px solid rgba(0,0,0,.55);
  background: rgba(255,255,255,.02);
}
.row.alt   { background: rgba(255,255,255,.045); }
.row.on    { background: rgba(255,157,25,.07); }
/* continues the grid past the last real channel so the panel reads as a guide
   with room to grow, rather than a void under one row */
.row.ghost { background: rgba(255,255,255,.012); }

.prog {
  position: absolute; top: 4px; bottom: 4px;
  display: flex; flex-direction: column; justify-content: center;
  padding: 0 11px;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(46,88,150,.85), rgba(21,52,101,.85));
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 2px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.12);
}
.prog .pt {
  font: 700 16px/1.2 "Arial Narrow", Arial, sans-serif;
  letter-spacing: .02em; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.prog .ps {
  margin-top: 4px;
  font: 500 12px/1.15 "Arial Narrow", Arial, sans-serif;
  letter-spacing: .05em; color: #b9cdea;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.prog.sel {
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  border-color: #ffe9b8;
  box-shadow: 0 0 0 2px rgba(255,210,74,.55), 0 6px 18px rgba(0,0,0,.55);
  z-index: 3;
}
.prog.sel .pt { color: #1d1305; font-weight: 800; }
.prog.sel .ps { color: #4a3413; }

.nowline {
  position: absolute; top: 0; bottom: 0; width: 2px;
  background: var(--now);
  box-shadow: 0 0 7px rgba(255,59,48,.85);
  z-index: 5; pointer-events: none;
}

/* ------------------------------------------------------------------ info */

#ginfo {
  flex: 0 0 84px;
  display: flex; align-items: center; gap: 20px;
  padding: 0 22px;
  background: linear-gradient(180deg, var(--navy-2), var(--navy-1));
  border-top: 1px solid rgba(0,0,0,.6);
  box-shadow: inset 0 1px 0 var(--bevel-hi);
}
.gi-time {
  font: 700 20px/1 "Arial Narrow", Arial, sans-serif;
  letter-spacing: .04em; color: var(--accent-2);
  padding-right: 20px; border-right: 1px solid rgba(255,255,255,.14);
  min-width: 178px;
}
.gi-body { min-width: 0; flex: 1 1 auto; }
.gi-title {
  font: 700 22px/1.15 "Arial Narrow", Arial, sans-serif;
  letter-spacing: .03em; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.gi-sub {
  margin-top: 6px;
  font: 500 15px/1.15 "Arial Narrow", Arial, sans-serif;
  letter-spacing: .05em; color: var(--ink-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.gi-hint {
  font: 700 13px/1 "Arial Narrow", Arial, sans-serif;
  letter-spacing: .16em; color: var(--ink-dim);
  padding-left: 22px; border-left: 1px solid rgba(255,255,255,.14);
  white-space: nowrap;
}
.gi-hint b { color: var(--accent-2); }

/* ------------------------------------------------------------- invite gate */

#gate {
  position: fixed; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 35%, #14335f 0%, #050d1a 72%);
}
#gate, #gate input, #gate button { cursor: auto; }
.gate-box {
  width: min(720px, 88vw);
  padding: 42px 46px 36px;
  text-align: center;
  background: linear-gradient(180deg, rgba(22,48,92,.92), rgba(5,13,26,.96));
  border: 1px solid var(--bevel-hi);
  border-radius: 4px;
  box-shadow: 0 24px 60px rgba(0,0,0,.7), inset 0 1px 0 var(--bevel-hi);
}
.gate-mark {
  display: inline-block;
  font: 800 40px/1 "Arial Narrow", Arial, sans-serif; letter-spacing: .08em;
  color: var(--accent);
  border: 3px solid var(--accent);
  padding: 10px 16px; border-radius: 3px;
  box-shadow: inset 0 0 24px rgba(255,157,25,.22);
}
.gate-title {
  margin-top: 22px;
  font: 700 30px/1 "Arial Narrow", Arial, sans-serif;
  letter-spacing: .22em; text-transform: uppercase; color: #fff;
}
.gate-msg {
  margin-top: 14px;
  font: 500 17px/1.4 "Arial Narrow", Arial, sans-serif;
  letter-spacing: .04em; color: var(--ink-dim);
}
.gate-row { margin-top: 26px; display: flex; gap: 12px; justify-content: center; }
.gate-input {
  flex: 0 1 320px; min-width: 0;
  padding: 14px 16px;
  font: 700 22px/1 "Arial Narrow", Arial, sans-serif; letter-spacing: .3em;
  text-align: center;
  color: #fff;
  background: rgba(0,0,0,.45);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 3px;
  outline: none;
}
.gate-input::placeholder {
  color: #5c739a; letter-spacing: .14em; text-transform: uppercase; font-size: 15px;
}
.gate-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(255,157,25,.35); }
.gate-go {
  padding: 14px 26px;
  font: 800 18px/1 "Arial Narrow", Arial, sans-serif; letter-spacing: .16em;
  color: #21160a;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  border: 1px solid #ffe9b8; border-radius: 3px;
}
.gate-hint {
  margin-top: 22px;
  font: 500 14px/1.4 "Arial Narrow", Arial, sans-serif;
  letter-spacing: .06em; color: #7c92b5;
}
body.is-loading #gate { display: flex; }
