/* ── Variables ── */
:root {
  --bg:          #0c0c18;
  --surface:     #161625;
  --surface-2:   #1e1e32;
  --surface-3:   #27273d;
  --border:      rgba(255,255,255,0.07);
  --accent:      #7c6fff;
  --accent-dim:  rgba(124,111,255,0.13);
  --accent-glow: rgba(124,111,255,0.22);
  --text-1:      #eeeeff;
  --text-2:      rgba(238,238,255,0.52);
  --text-3:      rgba(238,238,255,0.28);
  --danger:      #f87171;
  --radius:      14px;
  --radius-sm:   10px;
  --radius-xs:   6px;
  --player-h:    72px;
  --header-h:    60px;
  --mob-nav-h:   56px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text-1);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input { font: inherit; }
[hidden] { display: none !important; }
.hide    { display: none !important; }

/* ── App Header ── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: rgba(12,12,24,0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
  flex-shrink: 0;
}
.brand-icon { font-size: 22px; line-height: 1; }
.brand-text strong { font-size: 15px; font-weight: 700; display: block; letter-spacing: -0.2px; }
.brand-sub { font-size: 11px; color: var(--text-2); display: block; }

.tab-nav {
  display: flex;
  gap: 4px;
  flex: 1;
  justify-content: center;
}

/* tab-btn is the class for desktop nav items */
.tab-btn {
  padding: 7px 20px;
  border-radius: 100px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
  transition: background 0.15s, color 0.15s;
}
.tab-btn:hover { color: var(--text-1); background: var(--surface-2); }
.tab-btn.is-active { background: var(--accent-dim); color: var(--accent); }

/* ── Main ── */
.app-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 24px 120px;
}
body.has-radio-player .app-main { padding-bottom: calc(var(--player-h) + 100px); }

/* ── Section hero ── */
.section-hero { margin-bottom: 20px; }
.section-hero h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.4px; }
.section-hero p { font-size: 14px; color: var(--text-2); margin-top: 4px; }

/* ── Genre filter pills (generated by player.js as .btn.ghost) ── */
.genre-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.btn.ghost {
  padding: 6px 14px;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  border: 1px solid var(--border);
  background: var(--surface);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn.ghost:hover {
  color: var(--text-1);
  background: var(--surface-2);
  border-color: rgba(124,111,255,0.35);
}
.btn.ghost.active {
  background: var(--accent-dim);
  border-color: rgba(124,111,255,0.4);
  color: var(--accent);
}

/* ── Station grid (player.js renders into .grid.cols-3) ── */
.grid.cols-3 {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

/* ── Station card (player.js generates .radio-station.panel) ── */
.radio-station.panel {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  user-select: none;
}
.radio-station.panel:hover {
  background: var(--surface-2);
  border-color: rgba(124,111,255,0.28);
}
.radio-station.panel:active { transform: scale(0.98); }
.radio-station.panel:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.radio-station.panel.is-active {
  background: var(--surface-2);
  border-color: rgba(124,111,255,0.45);
}

.radio-station__icon {
  font-size: 26px;
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-3);
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.radio-station.panel.is-active .radio-station__icon {
  background: var(--accent-dim);
}

.radio-station__info { flex: 1; min-width: 0; }
.radio-station__name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

/* .chip is used for genre tags */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 100px;
  background: var(--surface-3);
  color: var(--text-2);
  margin-top: 4px;
  line-height: 1.6;
}

.chip.tv-live-chip {
  background: rgba(239,68,68,0.14);
  color: var(--danger);
}
.chip.tv-live-chip .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--danger);
  flex-shrink: 0;
  animation: pulse-dot 1.5s ease-in-out infinite;
}

.radio-station__action {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.radio-station__play-icon {
  font-size: 13px;
  color: var(--text-3);
  transition: color 0.15s;
}
.radio-station.panel:hover .radio-station__play-icon,
.radio-station.panel.is-active .radio-station__play-icon { color: var(--accent); }

/* ── Wave animation (player bar + station card) ── */
.radio-wave {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 20px;
}
.radio-wave span {
  display: block;
  width: 3px;
  border-radius: 2px;
  background: var(--accent);
  animation: wave-bar 0.85s ease-in-out infinite;
}
.radio-wave span:nth-child(1) { animation-delay: 0.00s; }
.radio-wave span:nth-child(2) { animation-delay: 0.12s; }
.radio-wave span:nth-child(3) { animation-delay: 0.24s; }
.radio-wave span:nth-child(4) { animation-delay: 0.36s; }
.radio-wave span:nth-child(5) { animation-delay: 0.48s; }

@keyframes wave-bar {
  0%, 100% { height: 4px; }
  50%       { height: 18px; }
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1;   transform: scale(1);   }
  50%       { opacity: 0.4; transform: scale(0.65); }
}

/* ── TV layout ── */
.tv-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 14px;
  align-items: start;
}

/* Video player pane */
.tv-player-pane {
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  aspect-ratio: 16 / 9;
}
#tvVideo {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: #000;
}

/* Overlay with gradient + channel info */
.tv-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(to bottom, transparent 55%, rgba(0,0,0,0.72) 100%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 14px 16px;
}
.tv-controls-overlay {
  position: absolute;
  top: 10px;
  right: 10px;
  pointer-events: all;
}
.tv-btn {
  background: rgba(0,0,0,0.52);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: var(--radius-xs);
  padding: 5px 10px;
  font-size: 16px;
  line-height: 1;
  transition: background 0.15s;
}
.tv-btn:hover { background: rgba(0,0,0,0.8); }

.tv-channel-name-overlay {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 6px rgba(0,0,0,0.85);
}
.tv-channel-meta-overlay {
  font-size: 12px;
  color: rgba(255,255,255,0.62);
  margin-top: 3px;
}

/* TV channel list */
.tv-channel-grid {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

/* player.js generates .tv-channel articles */
.tv-channel {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.13s;
}
.tv-channel:last-child { border-bottom: none; }
.tv-channel:hover { background: var(--surface-2); }
.tv-channel:focus-visible { outline: 2px solid var(--accent) inset; }
.tv-channel.is-active { background: var(--accent-dim); }

.tv-channel__icon {
  font-size: 22px;
  flex-shrink: 0;
  width: 34px;
  text-align: center;
  line-height: 1;
}
.tv-channel__info { flex: 1; min-width: 0; }
.tv-channel__name { font-size: 13px; font-weight: 600; }
.tv-channel__meta {
  font-size: 11px;
  color: var(--text-2);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.tv-channel__lang {
  background: var(--surface-3);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* TV error */
.tv-error {
  margin-top: 12px;
  padding: 12px 16px;
  background: rgba(239,68,68,0.09);
  border: 1px solid rgba(239,68,68,0.22);
  color: #fca5a5;
  border-radius: var(--radius-sm);
  font-size: 14px;
  line-height: 1.5;
}

/* ── Radio Player Bar ── */
.radio-player {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--player-h);
  background: rgba(13,13,24,0.94);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-top: 1px solid rgba(255,255,255,0.09);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  z-index: 200;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
}
.radio-player.is-active { transform: translateY(0); }

.radio-player__track {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}
.radio-player__icon { font-size: 26px; flex-shrink: 0; line-height: 1; }
.radio-player__name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.radio-player__genre { font-size: 12px; color: var(--text-2); margin-top: 1px; }

.radio-player__controls {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

/* Play button — player.js uses class "btn primary radio-player__play" */
.btn.primary.radio-player__play {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  transition: background 0.15s, transform 0.1s;
  flex-shrink: 0;
}
.btn.primary.radio-player__play:hover:not(:disabled) {
  background: #9d8fff;
  transform: scale(1.06);
}
.btn.primary.radio-player__play:active:not(:disabled) { transform: scale(0.96); }
.btn.primary.radio-player__play:disabled {
  background: var(--surface-3);
  color: var(--text-3);
  cursor: not-allowed;
}

.radio-player__right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.radio-player__error {
  font-size: 12px;
  color: var(--danger);
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.radio-player__vol {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  cursor: default;
}
#radioVolume {
  width: 80px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ── Mobile bottom nav ── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--mob-nav-h);
  background: rgba(13,13,24,0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  z-index: 300;
}

.bottom-nav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 0;
  color: var(--text-3);
  font-size: 10px;
  font-weight: 500;
  transition: color 0.15s;
}
.bottom-nav__item.is-active { color: var(--accent); }
.bottom-nav__icon { font-size: 20px; line-height: 1; }
.bottom-nav__label { font-size: 10px; letter-spacing: 0.01em; }

/* ── Responsive breakpoints ── */

/* Tablet: stack TV layout */
@media (max-width: 860px) {
  .tv-layout {
    grid-template-columns: 1fr;
  }
  .tv-channel-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }
  .tv-channel {
    border-bottom: none;
    border-right: 1px solid var(--border);
  }
  .tv-channel:nth-child(even) { border-right: none; }
  .tv-channel:nth-last-child(-n+2) { border-bottom: none; }
}

/* Mobile */
@media (max-width: 600px) {
  :root { --header-h: 54px; }
  .app-header { padding: 0 14px; }
  .app-main { padding: 18px 14px 100px; }
  body.has-radio-player .app-main { padding-bottom: calc(var(--player-h) + var(--mob-nav-h) + 16px); }

  .brand-sub { display: none; }
  .tab-nav { display: none; }

  .bottom-nav { display: flex; }
  .radio-player { bottom: var(--mob-nav-h); }

  .grid.cols-3 { grid-template-columns: repeat(2, 1fr); }
  .section-hero h1 { font-size: 21px; }

  .tv-channel-grid { grid-template-columns: 1fr; }
  .tv-channel { border-right: none; border-bottom: 1px solid var(--border); }

  #radioVolume { display: none; }
  .radio-player { padding: 0 14px; }
}

@media (max-width: 380px) {
  .grid.cols-3 { grid-template-columns: 1fr; }
}
