/* ماهواره آنلاین — TV version (10-foot UI).
   Designed for a remote control, not a mouse or touch screen:
   large text everywhere (nothing below 24px), large tiles, and a
   high-contrast focus ring — the focused element is always obvious
   from across the room. Same fonts as the phone app (SiteBody for
   body, SiteHeadings for headings), served by the Worker. */
@font-face {
  font-family: 'SiteBody';
  src: url('https://shabakehaye.mahvareh.workers.dev/fonts/body-vf.woff2') format('woff2-variations');
  font-weight: 100 1000;
  font-display: swap;
}
@font-face {
  font-family: 'SiteHeadings';
  src: url('https://shabakehaye.mahvareh.workers.dev/fonts/headings-vf.woff2') format('woff2-variations');
  font-weight: 100 1000;
  font-display: swap;
}
:root {
  --bg: #0d0d0f;
  --surface: #1c1c22;
  --surface2: #26262e;
  --text: #ffffff;
  --muted: #b8b8c4;
  --accent: #ff0000;
  --accent2: #cc0000;
  --border: #3a3a44;
  --focus: #ffffff;
  --focus-glow: rgba(255, 255, 255, 0.35);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'SiteBody', Vazirmatn, system-ui, -apple-system, sans-serif;
  font-size: 24px;
  line-height: 1.5;
  overflow-x: hidden;
}
.app { max-width: 1920px; margin: 0 auto; padding: 36px 56px 48px; }
.topbar { display: flex; align-items: center; padding-bottom: 28px; }
.brand { display: flex; flex-direction: column; margin-inline-end: 32px; }
.brand-title { font-family: 'SiteHeadings', 'SiteBody', Vazirmatn, sans-serif; font-size: 44px; font-weight: 800; line-height: 1.2; }
.brand-sub { font-size: 24px; color: var(--muted); }
.lang-select {
  margin-inline-start: auto;
  padding: 12px 20px;
  border-radius: 999px;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 24px;
  cursor: pointer;
  outline: none;
}
.lang-select.focused { border-color: var(--focus); box-shadow: 0 0 0 4px var(--focus-glow); }

/* Feed chips: one horizontal row, scrolls with focus.
   Spacing is via margins, NOT the `gap` property — old TV browsers
   ignore `gap` in flexbox, which is why the buttons touched each
   other no matter how large the gap was set. */
.chips { display: flex; overflow-x: auto; padding: 8px 4px 20px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  margin-inline-end: 28px;
  padding: 16px 32px;
  border-radius: 999px;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 26px;
  cursor: pointer;
  outline: none;
  white-space: nowrap;
}
.chip.active { background: linear-gradient(135deg, var(--accent), var(--accent2)); border-color: transparent; font-weight: 700; }
.chip:last-child { margin-inline-end: 0; }
.chip.focused { border-color: var(--focus); box-shadow: 0 0 0 4px var(--focus-glow); transform: scale(1.05); }

/* Search: a full-width field under the chips. On a TV the remote
   opens the on-screen keyboard when the field is focused. */
.search-row { display: flex; margin: 8px 4px 20px; }
.search-input {
  flex: 1;
  min-width: 0;
  padding: 18px 28px;
  border-radius: 999px;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 26px;
  outline: none;
}
.search-input::placeholder { color: var(--muted); }
.search-input.focused { border-color: var(--focus); box-shadow: 0 0 0 4px var(--focus-glow); }
.search-clear {
  flex: 0 0 auto;
  margin-inline-start: 20px;
  padding: 18px 28px;
  border-radius: 999px;
  border: 2px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-family: inherit;
  font-size: 26px;
  cursor: pointer;
  outline: none;
}
.search-clear.focused { border-color: var(--focus); box-shadow: 0 0 0 4px var(--focus-glow); }

.count { font-size: 24px; color: var(--muted); margin: 12px 4px 20px; }
/* Grid spacing is via margins on the tiles, NOT `gap` — old TV
   browsers ignore grid `gap` too, which left the tiles touching.
   Each tile carries half the spacing (18px) on every side, and the
   grid's negative margin keeps the outer edges aligned. */
.grid {
  list-style: none;
  margin: -18px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
}
.grid > li { margin: 18px; }
.tile {
  display: block;
  width: 100%;
  min-height: 168px;
  text-align: start;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 20px;
  padding: 28px 36px;
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  outline: none;
}
/* The flex row lives here (a plain <div>), not on the <button>:
   old TV browsers do not lay out flexbox correctly inside a
   <button>, so the logo and the text collapsed together. The logo
   margin is a physical margin, not a logical one, so it works even
   where logical properties are unsupported. */
.tile-inner { display: flex; align-items: center; }
.tile-logo { width: 112px; height: 112px; border-radius: 14px; object-fit: contain; background: #fff; flex: 0 0 auto; }
.tile-play {
  width: 112px; height: 112px; border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  flex: 0 0 auto; display: flex; align-items: center; justify-content: center;
}
[dir="rtl"] .tile-logo, [dir="rtl"] .tile-play { margin-left: 32px; }
[dir="ltr"] .tile-logo, [dir="ltr"] .tile-play { margin-right: 32px; }
.tile-play svg { width: 48px; height: 48px; fill: #fff; margin-inline-start: 4px; }
.tile-body { flex: 1; min-width: 0; }
.tile-name {
  font-family: 'SiteHeadings', 'SiteBody', Vazirmatn, sans-serif;
  font-weight: 700; font-size: 30px; line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tile-group { font-size: 24px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile.playing { border-color: var(--accent); }
/* The focus ring: bright white outline + glow + slight scale, so the
   focused tile is unmissable from the couch. */
.tile.focused {
  border-color: var(--focus);
  box-shadow: 0 0 0 4px var(--focus-glow), 0 0 28px rgba(255, 255, 255, 0.25);
  transform: scale(1.03);
  background: var(--surface2);
}
.empty { text-align: center; color: var(--muted); padding: 80px 0; font-size: 28px; }
.status { margin: 28px 4px 0; font-size: 24px; color: var(--muted); min-height: 36px; }
.status.error { color: #ff9a9a; }
.hint {
  margin: 32px 4px 0;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 24px;
  color: var(--muted);
}

/* Player: a fixed fullscreen overlay. The video fills the screen;
   the bar at the bottom holds the channel name, status, and the
   three remote-navigable buttons (alternate source / favorite /
   back). The overlay itself is the fullscreen — no dependency on the
   browser's fullscreen API, which many TV browsers lack.
   Position is set with explicit top/right/bottom/left (NOT the
   `inset` shorthand) because older TV browsers do not support it. */
.player-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 1000;
  background: #000;
  display: flex; flex-direction: column;
}
.video-wrap { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.video-wrap video { width: 100%; height: 100%; object-fit: contain; background: #000; display: block; }
/* Exit button: a large floating ✕ in the top corner of the video.
   TVs crop the edges (overscan), so the bottom player bar can sit
   below the visible area — this button is the always-visible way
   out. It sits 32px in from the edges (overscan-safe) and is part
   of the D-pad player zone. */
.player-exit {
  position: absolute; top: 32px; left: 32px; z-index: 10;
  width: 72px; height: 72px; border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.6);
  background: rgba(13, 13, 15, 0.75);
  color: #fff;
  font-family: inherit;
  font-size: 36px; line-height: 1;
  cursor: pointer;
  outline: none;
  display: flex; align-items: center; justify-content: center;
}
.player-exit.focused { border-color: var(--focus); box-shadow: 0 0 0 4px var(--focus-glow); transform: scale(1.08); }
.player-bar {
  display: flex; align-items: center;
  /* Overscan-safe: keep the bar clear of the TV's cropped edges. */
  padding: 20px 40px 32px;
  background: rgba(13, 13, 15, 0.95);
  border-top: 1px solid var(--border);
}
.player-bar > * { margin-inline-end: 20px; }
.player-bar > *:last-child { margin-inline-end: 0; }
.np-name { font-family: 'SiteHeadings', 'SiteBody', Vazirmatn, sans-serif; font-weight: 800; font-size: 32px; }
.np-group { font-size: 24px; color: var(--muted); background: var(--surface2); border: 1px solid var(--border); border-radius: 999px; padding: 4px 16px; }
.player-status { font-size: 24px; color: var(--muted); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-status.error { color: #ff9a9a; }
.player-btn {
  flex: 0 0 auto;
  padding: 14px 28px;
  border-radius: 999px;
  border: 2px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-family: inherit;
  font-size: 26px;
  cursor: pointer;
  outline: none;
  white-space: nowrap;
}
.player-btn.focused { border-color: var(--focus); box-shadow: 0 0 0 4px var(--focus-glow); transform: scale(1.05); }
.player-btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); border-color: transparent; font-weight: 700; }
.player-btn.fav { color: var(--accent); }
