/* =========================================================================
   Belgische Live TV — Tile concept, rebuilt
   Poster-style channel tiles grouped by broadcaster, horizontally
   scrollable category rail, equal-height cards, single accent colour.
   ========================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@600;700;800&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --n0:  #ffffff;
  --n25: #fbfbfd;
  --n50: #f5f6f9;
  --n100:#eef0f4;
  --n150:#e3e6ec;
  --n200:#d6dae2;
  --n300:#b3b9c6;
  --n500:#787f91;
  --n700:#454c5f;
  --n800:#2b3040;
  --n900:#14161f;

  --bg: var(--n50);
  --surface: var(--n0);
  --surface-sunken: var(--n25);
  --border: var(--n150);
  --border-strong: var(--n200);

  --text: var(--n900);
  --text-dim: var(--n700);
  --text-faint: var(--n500);

  --accent: #4f46e5;
  --accent-600: #4338ca;
  --accent-50: #eef0ff;
  --accent-100: #e0e2ff;
  --accent-ring: rgba(79, 70, 229, 0.22);

  --live: #dc2626;
  --live-bg: #fdecec;
  --gold: #d97706;
  --gold-bg: #fef3e2;

  --cat-vrt: #1c8ce0;
  --cat-dpg: #d6335f;
  --cat-play: #8a4fe0;
  --cat-rtbf: #0f9d64;
  --cat-rtl: #e0508f;
  --cat-regionaal: #b8791a;
  --cat-overig: #626a7d;

  --font-display: 'Manrope', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 18px;
  --r-pill: 999px;

  --shadow-xs: 0 1px 2px rgba(20, 22, 31, 0.05);
  --shadow-sm: 0 3px 10px rgba(20, 22, 31, 0.06);
  --shadow-md: 0 12px 28px rgba(20, 22, 31, 0.10);
  --shadow-lg: 0 24px 56px rgba(20, 22, 31, 0.18);
  --shadow-focus: 0 0 0 3px var(--accent-ring);

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { max-width: 100%; overflow-x: hidden; }
html { scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- Accessibility helpers ---------- */
.skip-link {
  position: absolute; left: -999px; top: auto;
  width: 1px; height: 1px; overflow: hidden; z-index: 999;
}
.skip-link:focus {
  position: fixed; left: 12px; top: 12px;
  width: auto; height: auto; padding: 10px 16px;
  background: var(--accent); color: #fff; border-radius: var(--r-sm);
  font-weight: 700; font-size: 0.82rem; text-decoration: none; box-shadow: var(--shadow-lg);
}
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
a:focus-visible, button:focus-visible, input:focus-visible, .tile:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-xs);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(1000px 420px at 8% -12%, var(--accent-50) 0%, transparent 55%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { font-family: var(--font-display); margin: 0; }
a { color: inherit; }
::selection { background: var(--accent-100); color: var(--accent-600); }
::-webkit-scrollbar { width: 8px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--n300); }
button { font-family: inherit; }

/* ---------- Header ---------- */
header.site {
  position: sticky; top: 0; z-index: 40;
  padding: 14px 24px;
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(12px) saturate(1.4);
  -webkit-backdrop-filter: blur(12px) saturate(1.4);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1360px; margin: 0 auto;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
}
header.site h1 { font-size: 1.05rem; font-weight: 800; letter-spacing: -0.015em; flex-shrink: 0; }
header.site h1 a { text-decoration: none; color: var(--text); display: inline-flex; align-items: center; gap: 10px; }
header.site h1 .brand-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(150deg, var(--accent) 0%, #7a71f0 100%);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.32);
  font-size: 1.05rem;
}
header.site h1 span.hl { color: var(--accent); }
.header-meta { font-size: 0.74rem; color: var(--text-faint); white-space: nowrap; flex-shrink: 0; }

.search-wrap { flex: 0 1 300px; margin-left: auto; }
.search-box { position: relative; width: 100%; }
.search-box svg {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; color: var(--text-faint); pointer-events: none;
}
.search-box input {
  width: 100%;
  padding: 9px 12px 9px 34px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
  background: var(--surface-sunken);
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.search-box input::placeholder { color: var(--text-faint); }
.search-box input:focus { border-color: var(--accent); background: #fff; box-shadow: var(--shadow-focus); }

/* ---------- Category rail: horizontally scrollable, no wrap ---------- */
.filter-rail-wrap {
  position: relative;
  max-width: 1360px; margin: 0 auto;
  padding: 12px 24px 0;
}
.filter-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding-bottom: 2px;
}
.filter-bar::-webkit-scrollbar { display: none; }
.filter-pill {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  padding: 7px 14px;
  border-radius: var(--r-pill);
  font-size: 0.79rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.15s var(--ease);
  display: inline-flex; align-items: center; gap: 7px;
  box-shadow: var(--shadow-xs);
}
.filter-pill .dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.filter-pill .count { font-size: 0.7rem; font-weight: 700; color: var(--text-faint); }
.filter-pill:hover { border-color: var(--border-strong); background: var(--surface-sunken); }
.filter-pill.active { background: var(--text); color: #fff; border-color: var(--text); box-shadow: 0 4px 12px rgba(20,22,31,0.22); }
.filter-pill.active .count { color: rgba(255,255,255,0.75); }

/* ---------- Layout ---------- */
main { max-width: 1360px; margin: 0 auto; padding: 20px 24px 48px; }

.stat-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 12px;
  margin-bottom: 26px;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 14px 16px; box-shadow: var(--shadow-xs);
}
.stat-card .stat-value { font-family: var(--font-display); font-size: 1.5rem; font-weight: 800; letter-spacing: -0.02em; }
.stat-card .stat-label { font-size: 0.74rem; color: var(--text-faint); font-weight: 600; margin-top: 2px; }
.stat-card.accent .stat-value { color: var(--accent); }
.stat-card.live .stat-value { color: var(--live); }
.stat-card.gold .stat-value { color: var(--gold); }

/* ---------- Category sections ---------- */
.cat-section { margin-bottom: 34px; }
.cat-title {
  display: flex; align-items: center; gap: 9px;
  font-weight: 800; font-size: 1.02rem;
  margin: 0 0 14px;
  color: var(--text);
}
.cat-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.cat-count { color: var(--text-faint); font-weight: 600; font-size: 0.78rem; }

/* ---------- Tile grid ---------- */
.tile-grid {
  list-style: none;
  margin: 0; padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(216px, 1fr));
  gap: 14px;
  align-items: stretch;
}

.tile {
  --cat-color: var(--n300);
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition: transform 0.16s var(--ease), box-shadow 0.16s var(--ease), border-color 0.16s var(--ease);
  min-width: 0;
}
.tile:hover, .tile:focus-visible {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
  outline: none;
}

.tile-band {
  height: 4px;
  width: 100%;
  background: var(--cat-color);
  flex-shrink: 0;
}

.tile-top {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 14px 10px;
}
.tile-logo {
  width: 46px; height: 46px; border-radius: var(--r-sm);
  background: var(--surface-sunken); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; flex-shrink: 0; font-size: 1.15rem;
}
.tile-logo img { max-width: 70%; max-height: 70%; object-fit: contain; }

.tile-heading { min-width: 0; flex: 1; padding-top: 1px; }
.tile-name {
  font-weight: 700; font-size: 0.94rem; letter-spacing: -0.005em;
  display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tile-lang {
  display: inline-block; margin-top: 4px;
  font-size: 0.6rem; font-weight: 800; text-transform: uppercase;
  color: var(--text-faint); background: var(--surface-sunken);
  border: 1px solid var(--border); padding: 1px 6px; border-radius: 4px;
}

.fav-btn {
  border: none; background: transparent; cursor: pointer;
  font-size: 1.15rem; color: var(--n300);
  padding: 3px; line-height: 1; flex-shrink: 0; border-radius: var(--r-xs);
  transition: color 0.15s var(--ease), transform 0.15s var(--ease), background 0.15s var(--ease);
}
.fav-btn:hover { color: var(--gold); background: var(--gold-bg); transform: scale(1.1); }
.fav-btn.active { color: var(--gold); }

.tile-now-wrap {
  margin-top: auto;
  padding: 10px 14px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 62px;
  justify-content: center;
}
.now-line, .next-line {
  display: flex; align-items: baseline; gap: 6px;
  min-width: 0;
}
.tag {
  flex-shrink: 0;
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 0.6rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.03em;
  padding: 1px 6px; border-radius: 4px;
}
.tag.tag-live { color: var(--live); background: var(--live-bg); }
.tag.tag-next { color: var(--text-faint); background: var(--surface-sunken); }
.now-line .prog-title { font-size: 0.82rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.next-line { font-size: 0.75rem; color: var(--text-faint); }
.next-line .prog-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-empty { color: var(--text-faint); font-style: italic; font-size: 0.8rem; }

.live-dot {
  display: inline-block; width: 5px; height: 5px; border-radius: 50%;
  background: var(--live); animation: pulse 1.6s ease-in-out infinite; flex-shrink: 0;
}
@keyframes pulse { 0%,100%{opacity:1;} 50%{opacity:0.35;} }

.no-results { display: none; text-align: center; padding: 60px 20px; color: var(--text-faint); }
.no-results .emoji { font-size: 2rem; display: block; margin-bottom: 10px; }
.no-results p { font-size: 0.88rem; margin: 4px 0 0; }

footer.site-footer {
  text-align: center; color: var(--text-faint); font-size: 0.74rem;
  padding: 20px 16px 28px; border-top: 1px solid var(--border);
  max-width: 1360px; margin: 0 auto;
}
footer.site-footer a { color: var(--text-dim); text-decoration: underline; text-underline-offset: 2px; }
footer.site-footer a:hover { color: var(--accent); }

/* ---------- Detail modal ---------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(20, 22, 31, 0.42);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: none; align-items: flex-start; justify-content: center;
  padding: 6vh 16px; z-index: 100; overflow-y: auto;
}
.modal-overlay.open { display: flex; animation: fadeIn 0.15s var(--ease); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-box {
  background: var(--surface); border-radius: var(--r-lg);
  width: min(520px, 100%); box-shadow: var(--shadow-lg);
  overflow: hidden; animation: slideUp 0.18s var(--ease);
}
@keyframes slideUp { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-band { height: 5px; width: 100%; background: var(--accent); }

.modal-header {
  display: flex; align-items: center; gap: 14px;
  padding: 20px 20px 18px; border-bottom: 1px solid var(--border); position: relative;
}
.modal-close {
  position: absolute; top: 14px; right: 14px;
  width: 28px; height: 28px; border-radius: 50%;
  border: none; background: var(--surface-sunken); color: var(--text-dim);
  font-size: 0.85rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s var(--ease);
}
.modal-close:hover { background: var(--border); color: var(--text); }
.modal-header .tile-logo { width: 54px; height: 54px; border-radius: var(--r-md); font-size: 1.4rem; }
.modal-header h2 { font-size: 1.1rem; font-weight: 800; letter-spacing: -0.01em; display: flex; align-items: center; gap: 8px; }
.modal-header .meta { color: var(--text-faint); font-size: 0.76rem; margin-top: 3px; }

.modal-body { padding: 20px 20px 22px; }

.watch-btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-600) 100%);
  color: #fff; font-weight: 700; text-decoration: none;
  padding: 10px 18px; border-radius: var(--r-pill); font-size: 0.85rem;
  box-shadow: 0 8px 20px rgba(79, 70, 229, 0.30);
  transition: filter 0.15s var(--ease), transform 0.15s var(--ease);
  margin-bottom: 22px;
}
.watch-btn:hover { filter: brightness(1.05); transform: translateY(-1px); }

.section-label {
  font-size: 0.68rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-faint); margin: 22px 0 10px;
  display: flex; align-items: center; gap: 6px;
}
.section-label:first-of-type { margin-top: 0; }

.now-row { display: flex; gap: 12px; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--border); }
.now-row:last-child { border-bottom: none; }
.now-time {
  color: var(--accent); font-weight: 700; font-size: 0.76rem;
  white-space: nowrap; min-width: 40px; font-variant-numeric: tabular-nums;
}
.now-row .now-title { font-weight: 700; display: block; font-size: 0.84rem; }
.now-sub { color: var(--text-dim); font-size: 0.76rem; margin-top: 2px; }
.now-desc { color: var(--text-faint); font-size: 0.76rem; margin-top: 3px; line-height: 1.5; }

.badge {
  display: inline-block; background: var(--surface-sunken); padding: 2px 8px;
  border-radius: var(--r-pill); font-size: 0.62rem; font-weight: 700;
  color: var(--text-dim); border: 1px solid var(--border);
}

.empty-note { color: var(--text-faint); font-size: 0.82rem; padding: 6px 0; }
.info-note {
  font-size: 0.74rem; color: var(--text-faint);
  border-top: 1px solid var(--border);
  padding-top: 14px; margin-top: 18px; line-height: 1.55;
}
.loading-spinner {
  width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.7s linear infinite; margin: 26px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 404 ---------- */
.error-page { text-align: center; padding: 80px 20px; }
.error-page .code { font-size: 3rem; font-weight: 800; color: var(--accent); margin: 0; font-family: var(--font-display); }

/* ---------- Install banner (PWA) ---------- */
.install-banner {
  position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 200;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: 12px 14px; display: flex; align-items: center; gap: 12px;
  max-width: 460px; margin: 0 auto;
  animation: slideUpBanner 0.25s var(--ease);
}
.install-banner[hidden] { display: none; }
@keyframes slideUpBanner { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.install-banner-icon {
  width: 36px; height: 36px; border-radius: var(--r-sm);
  background: var(--accent-50); display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; flex-shrink: 0;
}
.install-banner-text { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
.install-banner-text strong { font-size: 0.82rem; }
.install-banner-text span { font-size: 0.7rem; color: var(--text-faint); }
.install-banner-btn {
  background: var(--accent); color: #fff; border: none; font-weight: 700;
  font-size: 0.76rem; padding: 8px 14px; border-radius: var(--r-pill);
  cursor: pointer; white-space: nowrap; flex-shrink: 0;
}
.install-banner-btn:hover { filter: brightness(1.08); }
.install-banner-close { border: none; background: transparent; color: var(--text-faint); cursor: pointer; font-size: 0.9rem; padding: 4px; flex-shrink: 0; }

/* ---------- Mobile bottom nav ---------- */
.bottom-nav { display: none; }

/* =========================================================================
   Responsive
   ========================================================================= */
@media (max-width: 1100px) {
  .stat-strip { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 720px) {
  header.site { padding: 10px 16px; }
  .header-inner { gap: 10px; }
  .search-wrap { flex-basis: 100%; margin-left: 0; order: 3; }
  .filter-rail-wrap { padding: 10px 16px 0; }
  main { padding: 16px 14px 84px; }
  .stat-strip { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; }
  .stat-card { padding: 10px 12px; }
  .stat-card .stat-value { font-size: 1.2rem; }
  .tile-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
  .tile-top { padding: 12px 12px 8px; gap: 10px; }
  .tile-logo { width: 38px; height: 38px; }
  .tile-name { font-size: 0.86rem; }
  .tile-now-wrap { padding: 8px 12px 12px; min-height: 54px; }

  body { padding-bottom: calc(58px + env(safe-area-inset-bottom)); }
  .bottom-nav {
    display: flex;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 150;
    background: rgba(255,255,255,0.96);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    justify-content: space-around;
  }
  .bottom-nav button {
    background: none; border: none; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    color: var(--text-faint); font-size: 0.6rem; font-weight: 700;
    padding: 4px 8px; flex: 1;
  }
  .bottom-nav button .icon { font-size: 1.1rem; line-height: 1; }
  .bottom-nav button.active { color: var(--accent); }
  .install-banner { bottom: calc(66px + env(safe-area-inset-bottom)); }
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal-box { width: 100%; border-radius: 18px 18px 0 0; max-height: 92vh; overflow-y: auto; }
}

@media (max-width: 460px) {
  .tile-grid { grid-template-columns: 1fr 1fr; }
}
