/* ========================================================================
   TV GUIDE — Early-2000s DirecTV look.
   Sharp corners. Grey page + blue list block. Nothing else.
   ======================================================================== */

:root {
  /* Guide interior palette (the blue list block) */
  --c-bg-0:        #04102f;
  --c-bg-1:        #06174a;
  --c-bg-2:        #0a2f7a;

  /* Row bands — raised contrast for visible separation */
  --c-row-a:       #0a1f4e;
  --c-row-b:       #0f2a68;
  --c-row-border:  #000000;
  --c-row-hi:      rgba(255, 255, 255, 0.06);

  /* Page bg (outside the list) — grey, darker at top */
  --c-page-top:    #3a3d45;
  --c-page-mid:    #6d727b;
  --c-page-bot:    #a9adb5;

  --c-border:      rgba(160, 195, 255, 0.22);
  --c-border-strong: rgba(255, 255, 255, 0.18);

  /* Text */
  --c-text:        #ffffff;
  --c-text-dim:    #d6e0f2;
  --c-text-mute:   #8ea7d0;

  --c-cyan:        #5ab9ff;
  --c-yellow:      #ffc419;
  --c-yellow-soft: #ffd83d;
  --c-red:         #ff2e24;
  --c-hd:          #ffffff;

  /* Type */
  --f-display: 'Barlow Condensed', system-ui, sans-serif;
  --f-body:    'Barlow', system-ui, sans-serif;

  /* Geometry */
  --row-h:     46px;
  --ch-col-w:  240px;
  --slot-w:    260px;
}

/* ---------- Reset / base ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--f-body);
  color: var(--c-text);
  background:
    linear-gradient(180deg, var(--c-page-top) 0%, var(--c-page-mid) 55%, var(--c-page-bot) 100%);
  background-attachment: fixed;
  min-height: 100vh;
  overflow: hidden;                /* page never scrolls; only the grid scrolls */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Subtle grain on the grey */
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  opacity: 0.04;
  z-index: 1;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  mix-blend-mode: overlay;
}

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

/* ---------- App shell ---------- */
.app {
  position: relative;
  z-index: 2;
  max-width: 100%;
  margin: 0 auto;
  padding: 14px 0 8px;            /* bottom gutter so last row + scrollbar show */
  display: flex;
  flex-direction: column;
  gap: 0;
  height: 100vh; height: 100dvh;     /* dvh = true viewport, fixes chopped bottom */
}

/* ---------- Info bar — 3 columns aligned with the grid below ---------- */
.info-bar {
  display: grid;
  grid-template-columns: var(--ch-col-w) 1fr auto;    /* SAME columns as grid below */
  gap: 0;
  align-items: center;                                 /* vertically center all content */
  padding: 6px 18px 10px;
  background: transparent;
  border: none;
  box-shadow: none;
  flex-shrink: 0;                    /* never compress — always fully visible */
}

.info-left {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 12px;
}
.brand-mark { width: 228px; height: 180px; }
.day-time {
  font-family: var(--f-display);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: 0.5px;
  color: var(--c-text);
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.info-mid {
  min-width: 0;                      /* allows child text-ellipsis to work */
  padding-right: 16px;
}
.now-top-row {
  display: flex;
  align-items: baseline;
  gap: 16px;
}
.now-title {
  font-family: var(--f-display);
  font-weight: 700;
  font-size: 30px;
  letter-spacing: 0.3px;
  line-height: 1.1;
  color: var(--c-text);
  text-shadow: 0 1px 3px rgba(0,0,0,0.55);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rating {
  padding: 2px 10px;
  border: 1px solid var(--c-text);
  font-family: var(--f-display);
  font-weight: 600;
  letter-spacing: 0.6px;
  color: var(--c-text);
  font-size: 13px;
  flex-shrink: 0;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}
.now-slot {
  margin-top: 4px;
  font-family: var(--f-display);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: 0.4px;
  color: var(--c-text);
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}
.now-desc {
  margin-top: 7px;
  font-size: 14.5px;
  color: var(--c-text);
  max-width: 760px;
  line-height: 1.4;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.info-right { display: flex; align-items: flex-start; }
.pip {
  position: relative;
  width: 340px;
  height: 192px;
  overflow: hidden;
  background: #000;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(0, 0, 0, 0.35);
  cursor: pointer;
}
.pip video { width: 100%; height: 100%; object-fit: cover; display: block; }
.pip-badge {
  position: absolute; top: 10px; left: 10px;
  background: var(--c-red);
  color: #fff;
  font-family: var(--f-display);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 1.2px;
  padding: 3px 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.6);
  pointer-events: none;
}
.pip-fs {
  position: absolute; top: 8px; right: 8px;
  width: 34px; height: 34px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  z-index: 2;
  transition: background 120ms ease;
}
.pip-fs:hover { background: rgba(0,0,0,0.85); }

/* ---------- Scrollable grid container — THE blue block ---------- */
.grid-wrap {
  position: relative;
  flex: 1;                         /* fill remaining space — no bottom margin */
  min-height: 0;
  overflow: auto;
  background: var(--c-bg-0);
  border: 1px solid #000;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
  scroll-behavior: smooth;
}
.grid-wrap::-webkit-scrollbar { width: 12px; height: 12px; }
.grid-wrap::-webkit-scrollbar-track { background: #020820; }
.grid-wrap::-webkit-scrollbar-thumb { background: var(--c-cyan); }
.grid-wrap::-webkit-scrollbar-thumb:hover { background: #7cc6ff; }

/* ---------- Time header: SOLID opaque background, high z-index (fixes overlap) ---------- */
.time-header {
  display: flex;
  position: sticky;
  top: 0;
  z-index: 20;
  background: #04102f;
  border-bottom: 2px solid #000;
  box-shadow: 0 2px 0 rgba(0,0,0,0.6);
  font-family: var(--f-display);
  font-weight: 600;
}
.time-header .date {
  width: var(--ch-col-w);
  flex-shrink: 0;
  padding: 12px 16px;
  font-size: 14px;
  color: var(--c-text);
  letter-spacing: 0.6px;
  border-right: 2px solid #000;
  background: #04102f;
  /* Pin to top-left corner on both-axis scroll */
  position: sticky;
  left: 0;
  z-index: 21;
}
.time-header .slots {
  display: flex;
  background: #04102f;
}
.time-header .slot {
  width: var(--slot-w);
  flex: 0 0 var(--slot-w);
  padding: 12px 14px;
  font-size: 14px;
  color: var(--c-text);
  border-right: 1px solid var(--c-border);
  background: #04102f;
  letter-spacing: 0.3px;
}

/* ---------- Grid rows ---------- */
.grid {
  display: flex;
  flex-direction: column;
  position: relative;        /* positioning context for .now-line */
}

.row {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--c-row-border);
  min-height: var(--row-h);
  min-width: 100%;
}
.row:nth-child(odd)  { background: var(--c-row-a); }
.row:nth-child(even) { background: var(--c-row-b); }
.row:hover           { background: var(--c-row-hi); }

.ch-cell {
  width: var(--ch-col-w);
  flex-shrink: 0;
  display: flex; align-items: center; gap: 0;
  padding: 0 14px;
  border-right: 2px solid #000;
  font-family: var(--f-display);
  background: linear-gradient(90deg, #05123b 0%, #071a50 100%);
  cursor: pointer;
  /* Pin to left edge on horizontal scroll so channel identity stays visible */
  position: sticky;
  left: 0;
  z-index: 3;
  transition: background 120ms ease;
}
.ch-cell:hover { background: linear-gradient(90deg, #07195a 0%, #0a256f 100%); }
.ch-num {
  font-weight: 700;
  font-size: 15px;
  color: var(--c-text);
  letter-spacing: 0.3px;
  min-width: 18px;
  text-align: center;
}
.ch-logo {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, rgba(255,255,255,0.14), rgba(255,255,255,0.04));
  border: 1px solid rgba(255,255,255,0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  font-family: var(--f-display);
  font-size: 11px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.78);
  letter-spacing: 0.5px;
}
.ch-logo img { width: 100%; height: 100%; object-fit: contain; display: block; }
.ch-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--c-text);
  letter-spacing: 0.6px;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.slots-row { display: flex; position: relative; flex: 1; }

.program {
  position: relative;
  padding: 0 14px;
  display: flex; align-items: center; gap: 6px;
  border-right: 1px solid var(--c-border);
  font-family: var(--f-display);
  font-weight: 500;
  font-size: 15px;
  color: var(--c-text);
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
  justify-content: flex-start;
}
.program::before {
  content: "<";
  margin-right: 2px;
  color: var(--c-text-mute);
  font-weight: 400;
  opacity: 0;
}
.program.cont::before { opacity: 1; }
.program .title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  max-width: calc(100% - 44px);
}
.program .hd-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 5px;
  border: 1px solid var(--c-hd);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--c-hd);
  opacity: 0.9;
  flex-shrink: 0;
}
.program:hover { background: rgba(90, 185, 255, 0.1); }
.program.selected {
  background: rgba(255, 196, 25, 0.14);
  color: var(--c-yellow);
  box-shadow: inset 0 0 0 2px var(--c-yellow);
}
.program.selected::before,
.program.selected .title { color: var(--c-yellow); }
.program.selected .hd-badge { color: var(--c-yellow); border-color: var(--c-yellow); opacity: 1; }

/* ---------- Now-line: fine red line, top to bottom ---------- */
.now-line {
  position: absolute;
  top: 0; bottom: 0;
  width: 2px;
  background: var(--c-red);
  pointer-events: none;
  z-index: 2;
  left: 0;
}

/* ---------- Entrance animation ---------- */
@keyframes fadeUp { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.grid-wrap { animation: fadeUp 400ms ease-out both; }

/* ---------- Responsive fallback ---------- */
@media (max-width: 820px) {
  :root { --ch-col-w: 140px; --slot-w: 200px; --row-h: 42px; }
  .info-bar { grid-template-columns: 1fr; }
  .info-right { justify-content: space-between; }
  .pip { width: 220px; height: 124px; }
  .now-title { font-size: 22px; }
  .ch-logo { width: 28px; height: 28px; }
}

/* ---------- Fullscreen video styles ---------- */
#video:fullscreen,
#video:-webkit-full-screen {
  width: 100vw; height: 100vh; object-fit: contain; background: #000;
}

/* ---------- Anti-adblock notice (minimal, non-intrusive) ---------- */
.adblock-notice {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 440px;
  padding: 10px 14px;
  background: #04102f;
  color: #ffffff;
  font-family: var(--f-display);
  font-size: 14px;
  letter-spacing: 0.3px;
  border: 1px solid #ffc419;
  box-shadow: 0 6px 20px rgba(0,0,0,0.6);
  cursor: pointer;
  z-index: 200;
  animation: fadeUp 260ms ease-out both;
}
.adblock-notice::after {
  content: "  ×";
  color: var(--c-text-mute);
  font-weight: 700;
}



/* now-line show-start label */
.now-line::before {
  content: attr(data-show-start);
  position: absolute;
  top: -22px;
  left: -28px;
  background: var(--c-red);
  color: #fff;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: 0.3px;
  pointer-events: none;
}
.now-line[data-show-start=""]::before { display: none; }

/* === GRID FIX v2 (forced bright blue continuous rows) === */
.slots-row { min-width: 3120px !important; }
.row:nth-child(odd) .slots-row { background: #1c4890 !important; }
.row:nth-child(even) .slots-row { background: #163872 !important; }
.program:not([data-row]) { background: transparent !important; border: none !important; }
.program:not([data-row]) .title { opacity: 0.25 !important; }


/* ===== Category Navigation Bar ===== */
.cat-bar{display:flex;align-items:center;gap:0;background:var(--c-bg-1);border-bottom:2px solid var(--c-yellow);height:var(--row-h);padding:0 18px;flex-shrink:0;position:relative;z-index:50;overflow:visible;}
.cat-btn{font-family:var(--f-display);font-weight:600;font-size:14px;letter-spacing:.5px;color:var(--c-yellow);padding:0 14px;height:100%;display:flex;align-items:center;cursor:pointer;border:none;background:transparent;transition:background 150ms;white-space:nowrap;}
.cat-btn:hover,.cat-btn.active{background:rgba(255,196,25,.15);}
.cat-dropdown{position:absolute;top:100%;left:0;right:0;background:var(--c-bg-0);border:1px solid var(--c-yellow);border-top:none;max-height:420px;overflow-y:auto;z-index:100;display:none;padding:12px;}
.cat-dropdown.open{display:block;}
.cat-grid{display:grid;grid-template-columns:repeat(7,1fr);gap:8px;}
.cat-ch{display:flex;flex-direction:column;align-items:center;gap:4px;padding:8px 4px;cursor:pointer;border-radius:4px;transition:background 150ms;}
.cat-ch:hover{background:rgba(255,196,25,.1);}
.cat-ch-logo{width:48px;height:36px;object-fit:contain;background:rgba(255,255,255,.05);border-radius:2px;}
.cat-ch-name{font-family:var(--f-display);font-size:11px;color:var(--c-text-dim);text-align:center;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:100%;}
.zone-regions{display:grid;grid-template-columns:repeat(7,1fr);gap:8px;margin-bottom:12px;}
.zone-region-btn{font-family:var(--f-display);font-weight:600;font-size:13px;color:var(--c-yellow);padding:10px 8px;text-align:center;cursor:pointer;background:var(--c-bg-1);border:1px solid var(--c-border);transition:background 150ms;border-radius:2px;}
.zone-region-btn:hover,.zone-region-btn.active{background:rgba(255,196,25,.15);}
@media(max-width:768px){.cat-btn{font-size:11px;padding:0 8px;}.cat-grid,.zone-regions{grid-template-columns:repeat(4,1fr);}}
@media(max-width:480px){.cat-grid,.zone-regions{grid-template-columns:repeat(3,1fr);}}

/* Search in category bar */
.cat-search-wrap{position:relative;margin-left:auto;display:flex;align-items:center;height:100%;}
.cat-search{font-family:var(--f-display);font-size:14px;color:var(--c-text);background:var(--c-bg-0);border:1px solid var(--c-yellow);padding:4px 12px;width:220px;height:30px;outline:none;border-radius:2px;}
.cat-search::placeholder{color:var(--c-text-mute);}
.cat-search:focus{border-color:var(--c-yellow-soft);background:var(--c-bg-1);}
.cat-search-results{position:absolute;top:100%;right:0;width:320px;max-height:360px;overflow-y:auto;background:var(--c-bg-0);border:1px solid var(--c-yellow);display:none;z-index:110;}
.cat-search-results.open{display:block;}
.cat-search-item{padding:8px 12px;color:var(--c-text-dim);font-family:var(--f-display);font-size:13px;cursor:pointer;border-bottom:1px solid var(--c-border);}
.cat-search-item:hover{background:rgba(255,196,25,.1);color:var(--c-yellow);}
.cat-search-nf{padding:12px;color:var(--c-red);font-family:var(--f-display);font-size:13px;text-align:center;}

/* === ELIMINATE old controls === */
.info-bar ~ .cat-bar{margin-top:0;}
.info-bar{margin-bottom:0;padding-bottom:6px;}
#gridWrap{margin-top:0;padding-top:0;}
.brand-mark{width:228px;height:auto;pointer-events:none;}
