/* ============================================================
   电视直播页
   ============================================================ */

.tv-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 26px;
  align-items: start;
}

.player-column {
  min-width: 0;
  animation: rise-in 720ms 80ms var(--ease) both;
}

/* ---------- 播放器 ---------- */

.player-shell {
  position: relative;
  isolation: isolate;
  width: 100%;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  color: #fff;
  background: var(--video-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.player-shell video {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

/* 接近 16:9 的直播源铺满画面，避免边缘出现细黑边 */
.player-shell video.is-fill {
  object-fit: cover;
}

.player-poster {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  overflow: hidden;
  text-align: center;
  background:
    radial-gradient(70% 120% at 50% 10%, rgba(255, 92, 87, 0.13), transparent 55%),
    radial-gradient(55% 85% at 75% 85%, rgba(69, 105, 255, 0.12), transparent 60%),
    #07090d;
  opacity: 1;
  visibility: visible;
  transition: opacity 420ms ease, visibility 420ms ease;
}

.player-poster::before {
  position: absolute;
  width: min(58%, 460px);
  aspect-ratio: 1;
  content: "";
  border: 1px solid rgba(255, 255, 255, 0.055);
  border-radius: 50%;
  box-shadow:
    0 0 0 38px rgba(255, 255, 255, 0.017),
    0 0 0 78px rgba(255, 255, 255, 0.012);
}

.player-poster img {
  position: relative;
  z-index: 1;
  width: clamp(58px, 8.4vw, 90px);
  height: auto;
  margin-bottom: 10px;
  border-radius: 22%;
  filter: drop-shadow(0 16px 34px rgba(0, 0, 0, 0.52));
}

.player-poster strong {
  position: relative;
  z-index: 1;
  font-size: clamp(16px, 2vw, 22px);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.player-poster span {
  position: relative;
  z-index: 1;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.42);
}

.poster-glow {
  position: absolute;
  top: 18%;
  left: 50%;
  width: 42%;
  height: 38%;
  background: var(--accent);
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.16;
  transform: translateX(-50%);
}

.player-shell.has-frame .player-poster {
  opacity: 0;
  visibility: hidden;
}

/* 中央播放按钮 */

.big-play {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 10px;
  color: #fff;
  background: transparent;
  transform: translate(-50%, -50%);
  transition: opacity 220ms ease, transform 220ms ease, visibility 220ms ease;
}

.big-play__circle {
  display: grid;
  width: clamp(56px, 7vw, 74px);
  height: clamp(56px, 7vw, 74px);
  padding-left: 4px;
  place-items: center;
  background: linear-gradient(145deg, var(--accent), #e11d48);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 50%;
  box-shadow: 0 16px 40px rgba(225, 29, 72, 0.36), 0 0 0 10px rgba(255, 255, 255, 0.055);
  transition: transform 220ms var(--ease), box-shadow 220ms ease;
}

.big-play:hover .big-play__circle {
  box-shadow: 0 18px 48px rgba(225, 29, 72, 0.46), 0 0 0 13px rgba(255, 255, 255, 0.07);
  transform: scale(1.06);
}

.big-play__circle .icon {
  width: 26px;
  height: 26px;
}

.big-play__label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.68);
}

.big-play[hidden] {
  display: none !important;
}

/* 加载与错误 */

.loading-overlay,
.error-overlay {
  position: absolute;
  inset: 0;
  z-index: 7;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  background: rgba(5, 6, 9, 0.78);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}

.spinner {
  display: block;
  width: 36px;
  height: 36px;
  border: 2.5px solid rgba(255, 255, 255, 0.14);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

.loading-overlay p {
  margin: 16px 0 0;
  font-size: 13px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.88);
}

.loading-channel {
  margin-top: 5px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.4);
}

.error-overlay {
  z-index: 8;
  background:
    radial-gradient(60% 70% at 50% 20%, rgba(255, 92, 87, 0.1), transparent 70%),
    rgba(5, 6, 9, 0.94);
}

.error-overlay__icon {
  display: grid;
  width: 52px;
  height: 52px;
  margin-bottom: 12px;
  place-items: center;
  color: #ff8f87;
  background: rgba(255, 92, 87, 0.11);
  border: 1px solid rgba(255, 92, 87, 0.22);
  border-radius: 16px;
}

.error-overlay__icon .icon {
  width: 25px;
  height: 25px;
}

.error-overlay h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 720;
  letter-spacing: -0.02em;
}

.error-overlay p {
  max-width: 380px;
  margin: 7px 0 18px;
  font-size: 12px;
  line-height: 1.7;
  color: rgba(255, 255, 255, 0.55);
}

.error-overlay__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 9px;
}

.error-overlay .btn {
  min-height: 42px;
  font-size: 12px;
}

.error-overlay .btn-ghost {
  color: rgba(255, 255, 255, 0.72);
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
}

/* 双击反馈 */

.tap-feedback {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 9;
  display: grid;
  width: 76px;
  height: 76px;
  place-items: center;
  color: #fff;
  background: rgba(0, 0, 0, 0.48);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.78);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.tap-feedback.is-visible {
  animation: tap-pop 680ms var(--ease);
}

.tap-feedback .icon {
  width: 28px;
  height: 28px;
}

@keyframes tap-pop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.72); }
  22% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  70% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.08); }
}

/* ---------- 控制栏 ---------- */

.player-controls {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 5;
  padding: 56px 18px 15px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.86) 0%, rgba(0, 0, 0, 0.45) 46%, transparent 100%);
  pointer-events: none;
  transition: opacity 200ms ease, visibility 200ms ease;
}

/* 只让实际控件接管触摸，避免透明渐变区挡住中央播放按钮 */
.player-controls .timeline,
.player-controls .control-row {
  pointer-events: auto;
}

.player-shell.controls-idle .player-controls {
  opacity: 0;
  visibility: hidden;
}

@media (hover: hover) {
  .player-shell.controls-idle {
    cursor: none;
  }
}

.timeline {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 3px;
}

.seek-bar,
.volume-bar {
  --seek: 100%;
  height: 22px;
  padding: 0;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  cursor: pointer;
}

.seek-bar {
  flex: 1;
  min-width: 0;
}

.seek-bar::-webkit-slider-runnable-track {
  height: 4px;
  background: linear-gradient(
    90deg,
    var(--accent) 0%,
    var(--accent) var(--seek),
    rgba(255, 255, 255, 0.22) var(--seek),
    rgba(255, 255, 255, 0.22) 100%
  );
  border-radius: 999px;
}

.seek-bar::-moz-range-track {
  height: 4px;
  background: rgba(255, 255, 255, 0.22);
  border-radius: 999px;
}

.seek-bar::-moz-range-progress {
  height: 4px;
  background: var(--accent);
  border-radius: 999px;
}

.seek-bar::-webkit-slider-thumb {
  width: 13px;
  height: 13px;
  margin-top: -4.5px;
  appearance: none;
  -webkit-appearance: none;
  background: #fff;
  border: 2px solid var(--accent);
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  transition: transform 140ms ease;
}

.seek-bar::-moz-range-thumb {
  width: 10px;
  height: 10px;
  background: #fff;
  border: 2px solid var(--accent);
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.seek-bar:hover::-webkit-slider-thumb,
.seek-bar:focus-visible::-webkit-slider-thumb {
  transform: scale(1.2);
}

.seek-bar:disabled {
  cursor: default;
  opacity: 0.7;
}

.volume-bar {
  width: 72px;
}

.volume-bar::-webkit-slider-runnable-track {
  height: 3px;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.82) 0%,
    rgba(255, 255, 255, 0.82) var(--seek),
    rgba(255, 255, 255, 0.22) var(--seek),
    rgba(255, 255, 255, 0.22) 100%
  );
  border-radius: 999px;
}

.volume-bar::-moz-range-track {
  height: 3px;
  background: rgba(255, 255, 255, 0.22);
  border-radius: 999px;
}

.volume-bar::-moz-range-progress {
  height: 3px;
  background: rgba(255, 255, 255, 0.82);
  border-radius: 999px;
}

.volume-bar::-webkit-slider-thumb {
  width: 10px;
  height: 10px;
  margin-top: -3.5px;
  appearance: none;
  -webkit-appearance: none;
  background: #fff;
  border: 0;
  border-radius: 50%;
}

.volume-bar::-moz-range-thumb {
  width: 9px;
  height: 9px;
  background: #fff;
  border: 0;
  border-radius: 50%;
}

.live-edge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 7px;
  transition: color 160ms ease, background 160ms ease, border-color 160ms ease;
}

.live-edge .live-dot {
  width: 5px;
  height: 5px;
  background: currentColor;
}

.live-edge .live-dot::after {
  display: none;
}

.live-edge.is-at-live {
  color: #ff7c73;
  background: rgba(255, 92, 87, 0.12);
  border-color: rgba(255, 92, 87, 0.2);
}

.live-edge:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
}

.control-row {
  display: flex;
  align-items: center;
  gap: 2px;
}

.control-btn {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  padding: 0;
  place-items: center;
  color: rgba(255, 255, 255, 0.82);
  background: transparent;
  border-radius: 11px;
  transition: color 160ms ease, background 160ms ease, transform 160ms ease;
}

.control-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.control-btn:active {
  transform: scale(0.94);
}

.control-btn .icon {
  width: 20px;
  height: 20px;
}

.volume-control {
  display: flex;
  align-items: center;
  gap: 2px;
}

.control-live {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 0 8px;
  margin-left: 6px;
  font-size: 10px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.48);
  white-space: nowrap;
}

.control-live .live-dot {
  width: 5px;
  height: 5px;
  background: rgba(255, 255, 255, 0.4);
}

.control-live .live-dot::after {
  display: none;
}

.player-shell.is-playing .control-live {
  color: rgba(255, 255, 255, 0.72);
}

.player-shell.is-playing .control-live .live-dot {
  background: #ff5c57;
  box-shadow: 0 0 10px rgba(255, 92, 87, 0.7);
}

.control-spacer {
  flex: 1;
}

/* 全屏状态 */

.player-shell:fullscreen,
.player-shell:-webkit-full-screen {
  position: fixed;
  inset: 0;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: auto;
  border: 0;
  border-radius: 0;
  overflow: hidden;
  background: #000;
}

.player-shell:fullscreen video,
.player-shell:-webkit-full-screen video {
  width: 100%;
  height: 100%;
}

.player-shell:fullscreen .player-controls,
.player-shell:-webkit-full-screen .player-controls {
  padding-right: 28px;
  padding-bottom: max(18px, env(safe-area-inset-bottom));
  padding-left: 28px;
}

.player-shell:fullscreen .player-poster,
.player-shell:-webkit-full-screen .player-poster {
  border-radius: 0;
}

/* ---------- 当前频道信息 ---------- */

.now-playing {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 2px 0;
}

.now-logo {
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  padding: 3px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.now-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 10px;
}

.now-copy {
  min-width: 0;
}

.now-title-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.now-title-row h2 {
  margin: 0;
  overflow: hidden;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.025em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.now-title-row .live-badge {
  flex: 0 0 auto;
}

.now-meta {
  margin: 3px 0 0;
  overflow: hidden;
  font-size: 12px;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 88px;
  min-height: 44px;
  padding: 0 15px;
  margin-left: auto;
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 620;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: color 160ms ease, background 160ms ease, border-color 160ms ease;
}

.fav-btn:hover {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--border-strong);
}

.fav-btn .icon {
  width: 17px;
  height: 17px;
}

.fav-btn.is-favorite {
  color: #ffc247;
  background: rgba(255, 194, 71, 0.09);
  border-color: rgba(255, 194, 71, 0.2);
}

.fav-btn.is-favorite .icon {
  fill: currentColor;
}

/* ---------- 桌面侧边频道栏 ---------- */

@media (min-width: 1081px) {
  .tv-layout {
    grid-template-columns: minmax(0, 1fr) 356px;
  }

  .tv-layout .channel-panel {
    position: sticky;
    top: calc(var(--header-h) + 22px);
    height: clamp(480px, calc(100dvh - var(--header-h) - 156px), 680px);
  }
}

/* ---------- 响应式 ---------- */

@media (max-width: 1080px) {
  .tv-layout {
    display: block;
  }

  .player-column {
    max-width: 100%;
  }
}

@media (max-width: 720px) {
  .player-shell {
    border-radius: 18px;
    box-shadow: 0 18px 46px rgba(0, 0, 0, 0.32);
  }

  .player-poster img {
    width: 66px;
    margin-bottom: 7px;
  }

  .player-poster strong {
    font-size: 16px;
  }

  .player-poster span {
    font-size: 10px;
  }

  .big-play__label {
    display: none;
  }

  .player-controls {
    padding: 44px 10px 8px;
  }

  .timeline {
    gap: 8px;
    margin-bottom: 1px;
  }

  .live-edge {
    height: 32px;
    padding: 0 8px;
  }

  .control-btn {
    width: 44px;
    height: 44px;
  }

  .volume-bar {
    display: none;
  }

  .control-live {
    margin-left: 3px;
    padding: 0 4px;
  }

  .error-overlay {
    padding: 16px;
  }

  .error-overlay__icon {
    width: 42px;
    height: 42px;
    margin-bottom: 8px;
    border-radius: 13px;
  }

  .error-overlay h2 {
    font-size: 17px;
  }

  .error-overlay p {
    margin: 5px 0 12px;
    font-size: 11px;
  }

  .error-overlay .btn {
    min-height: 40px;
    padding: 0 13px;
    font-size: 11px;
  }

  .now-playing {
    gap: 11px;
    padding-top: 13px;
  }

  .now-logo {
    width: 46px;
    height: 46px;
    border-radius: 13px;
  }

  .now-title-row h2 {
    font-size: 16px;
  }

  .now-meta {
    font-size: 11px;
  }

  .now-title-row .live-badge {
    height: 22px;
    padding: 0 7px;
    font-size: 9px;
  }

  .fav-btn {
    min-width: 44px;
    width: 44px;
    padding: 0;
    border-radius: 11px;
  }

  .fav-btn span {
    display: none;
  }

  .fav-btn .icon {
    width: 18px;
    height: 18px;
  }
}

@media (max-width: 420px) {
  .control-live {
    display: none;
  }

  .big-play__circle {
    width: 54px;
    height: 54px;
  }

  .big-play__circle .icon {
    width: 22px;
    height: 22px;
  }

  .timeline {
    gap: 6px;
  }

  .live-edge {
    padding: 0 7px;
    font-size: 8px;
  }

  .now-meta {
    max-width: 160px;
  }
}

@media (max-width: 900px) and (orientation: landscape) and (max-height: 540px) {
  .page {
    padding-top: 12px;
  }

  .page-head {
    display: none;
  }

  .player-shell {
    width: auto;
    max-width: 100%;
    height: calc(100dvh - var(--header-h) - 26px);
    max-height: 100%;
    margin: 0 auto;
    aspect-ratio: 16 / 9;
    border-radius: 18px;
  }

  .now-playing {
    display: none;
  }
}
