/* ==========================================================================
   LIVE TV PAGE (tv.html) — loads after css/global.css
   Compact live layout: Cloudflare Stream player (left) + schedule widget
   (right), live/off-air status pill, fallback controls.
   Builds on global .container, .card-panel, .view-more-btn.
   ========================================================================== */

.tv-player-section {
  padding: 40px 0;
}

/* --------------------------------------------------------------------------
   0. COMPACT LIVE LAYOUT — player LEFT (60%), schedule RIGHT (40%)
   Max 600px player + 400px schedule, centred, so the player never
   stretches full-width. The schedule card stretches to the player's height.
   -------------------------------------------------------------------------- */
.tv-live-layout {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(260px, 2fr);   /* 60 / 40 */
  grid-template-areas:
    "status   ."
    "player   schedule"
    "controls .";
  column-gap: 24px;
  row-gap: 14px;
  max-width: 1024px;          /* 600px player + 24px gap + 400px schedule */
  margin-inline: auto;
}
.tv-live-layout .tv-status-bar    { grid-area: status; }
.tv-live-layout .tv-player-frame  { grid-area: player; }
.tv-live-layout .tv-control-bar   { grid-area: controls; }
.tv-live-layout .tv-schedule-card { grid-area: schedule; }

/* --------------------------------------------------------------------------
   1. STATUS BAR (states set by js/pages/tv.js)
   -------------------------------------------------------------------------- */
.tv-status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.tv-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--primary-navy);
}
.tv-status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background-color: #94a3b8;
  transition: var(--transition);
}
.tv-status-dot.live {
  background-color: var(--accent-red);
  animation: pulse 1.6s infinite;
}
.tv-status-dot.offline {
  background-color: var(--text-muted);
}
.tv-quality-tag {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.8px;
  color: var(--text-light);
  background: var(--primary-navy);
  padding: 3px 10px;
  border-radius: var(--radius-pill);
}

/* --------------------------------------------------------------------------
   2. PLAYER FRAME — extends .card-panel, edge-to-edge 16:9 video
   -------------------------------------------------------------------------- */
.card-panel.tv-player-frame {
  padding: 0;
  overflow: hidden;
  background: #000000;
  border: none;
  box-shadow: var(--shadow-lg);
  align-self: start;          /* keep 16:9 — the schedule matches its height */
  min-width: 0;
}
.tv-player-ratio {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--dark-navy);
}
.tv-player-ratio:fullscreen {
  aspect-ratio: auto;
  width: 100%;
  height: 100%;
}
.tv-live-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
.tv-live-frame[hidden],
.tv-player-overlay[hidden],
.tv-ctrl-btn[hidden] {
  display: none;
}

/* Start overlay (uses the hero gradient colors) */
.tv-player-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  text-align: center;
  color: var(--text-light);
  background: radial-gradient(circle at center, #063168 0%, var(--dark-navy) 70%);
}
.tv-play-btn {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: none;
  background-color: #dc2626;
  color: var(--text-light);
  font-size: 1.45rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  box-shadow: 0 8px 24px rgba(220, 38, 38, 0.45);
  transition: var(--transition);
}
.tv-play-btn:hover {
  transform: scale(1.08);
  background-color: #b91c1c;
}
.tv-overlay-title {
  font-size: 1.15rem;
  font-weight: 800;
  margin-bottom: 4px;
}
.tv-overlay-text {
  font-size: 0.86rem;
  color: #cbd5e1;
  max-width: 380px;
}

/* --------------------------------------------------------------------------
   3. FALLBACK CONTROLS — built on .view-more-btn
   -------------------------------------------------------------------------- */
.tv-control-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.view-more-btn.tv-ctrl-btn {
  font-family: inherit;
  cursor: pointer;
}

/* --------------------------------------------------------------------------
   4. SCHEDULE WIDGET (right side) — extends .card-panel
   Badges/visibility set by js/pages/tv.js from each item's data-start/end.
   -------------------------------------------------------------------------- */
.card-panel.tv-schedule-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 16px 18px;
}

.tv-schedule-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.tv-schedule-title {
  font-size: 1rem;
  font-weight: 800;
  color: var(--primary-navy);
}
.tv-schedule-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent-blue);
  white-space: nowrap;
}
.tv-schedule-link i { font-size: 0.7rem; }
.tv-schedule-link:hover { color: var(--primary-navy); }

.tv-schedule-list {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* One schedule slot. Slots share the card height evenly. */
.tv-sched-item {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  min-width: 0;
  padding: 10px 12px;
  background: var(--bg-light);
  border: 1px solid var(--border-light);
  border-left: 4px solid #cbd5e1;
  border-radius: var(--radius-md);
}
.tv-sched-item[hidden],
.tv-sched-day[hidden] {
  display: none;
}
.tv-sched-item.is-live {
  background: #fef2f2;
  border-color: #fecaca;
  border-left-color: var(--accent-red);
}
.tv-sched-item.is-next {
  border-left-color: var(--accent-gold);
}

.tv-sched-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}
.tv-sched-time {
  min-width: 0;
  font-size: 0.76rem;
  font-weight: 700;
  color: #475569;
  font-variant-numeric: tabular-nums;   /* times line up vertically */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tv-sched-title {
  font-size: 0.92rem;
  font-weight: 800;
  line-height: 1.3;
  color: var(--primary-navy);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}

/* Status badges */
.tv-sched-badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.6px;
  line-height: 1.4;
  text-transform: uppercase;
  white-space: nowrap;
}
.tv-badge-live     { background: #dc2626; color: #ffffff; }   /* AA contrast */
.tv-badge-next     { background: #fef3c7; color: #92400e; }
.tv-badge-upcoming { background: #e2e8f0; color: #334155; }

/* Animated "on air" dot */
.tv-badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ffffff;
  animation: tvLiveBlink 1.2s ease-in-out infinite;
}
@keyframes tvLiveBlink {
  0%, 100% { opacity: 1;   transform: scale(1); }
  50%      { opacity: 0.3; transform: scale(0.7); }
}

/* --------------------------------------------------------------------------
   5. FOCUS, RESPONSIVE & REDUCED MOTION
   -------------------------------------------------------------------------- */
.tv-play-btn:focus-visible,
.tv-ctrl-btn:focus-visible,
.tv-live-frame:focus-visible,
.tv-schedule-link:focus-visible {
  outline: 3px solid var(--accent-gold);
  outline-offset: 3px;
}

/* Landscape tablets (side-by-side, narrower): tighter schedule so all
   3 slots fit beside the smaller player without making it taller. */
@media (max-width: 991px) {
  .tv-player-section { padding: 32px 0; }
  .card-panel.tv-schedule-card { padding: 12px 14px; }
  .tv-schedule-head { margin-bottom: 6px; }
  .tv-schedule-title { font-size: 0.92rem; }
  .tv-schedule-list { gap: 5px; }
  .tv-sched-item { padding: 5px 10px; gap: 1px; }
  .tv-sched-title {
    font-size: 0.86rem;
    -webkit-line-clamp: 1;
    line-clamp: 1;
  }
  .tv-play-btn { width: 58px; height: 58px; font-size: 1.25rem; margin-bottom: 10px; }
  .tv-overlay-title { font-size: 1.02rem; }
  .tv-overlay-text { font-size: 0.8rem; }
}

/* Mobile & portrait tablets: stack — player on top, schedule below */
@media (max-width: 768px) {
  .tv-live-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "status"
      "player"
      "controls"
      "schedule";
    max-width: 640px;         /* caps player height at 360px on portrait tablets */
  }
  .card-panel.tv-schedule-card { padding: 16px; }
  .tv-schedule-list { gap: 8px; }
  .tv-sched-item {
    flex: 0 0 auto;           /* natural height when stacked */
    padding: 10px 12px;
    gap: 4px;
  }
  .tv-sched-title {
    font-size: 0.92rem;
    -webkit-line-clamp: 2;
    line-clamp: 2;
  }
}

@media (max-width: 600px) {
  .tv-player-section { padding: 24px 0; }
  /* Reload + Fullscreen share a row; radio link full width below.
     If Fullscreen is hidden (iPhone), Reload grows to fill the row. */
  .tv-control-bar .tv-ctrl-btn {
    flex: 1 1 calc(50% - 5px);
    justify-content: center;
    padding: 8px 12px;
    font-size: 0.86rem;
  }
  .tv-control-bar a.tv-ctrl-btn { flex-basis: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .tv-status-dot.live,
  .tv-badge-dot { animation: none; }
  .tv-play-btn:hover { transform: none; }
}
