/* =====================================================================
 * 剧场（舞台剧 / 音乐剧 / 脱口秀 / 戏曲）—— 整场观看浮层 + 卡片角标
 * =====================================================================
 * ★ 为什么单独一个文件：这套 UI 与播放页（`.stage`）**没有任何共用语义** ——
 *   那里是"我们自己的 <video> + 音质/原声/伴唱/弹幕"，这里是"B 站官方外链播放器"。
 *   混进 player.css 会让"哪些规则属于我们自己的播放器"彻底说不清。
 *
 * ★ 老引擎口径（Android 9 自带 Chromium 66，全站铁律）：
 *   · 不用 `inset`（展开四向长写）；
 *   · 不用 `min() / max() / clamp()`（前置定值兜底）；
 *   · 不用 `color-mix()`（用 rgba 或 var 直接给）；
 *   · flex 的 `gap` **语法合法但无效** ⇒ 间距一律 `.parent > * + * { margin-left }`；
 *   · 16:9 用 `padding-top: 56.25%` 占位，不用 `aspect-ratio`。
 * ===================================================================== */

/* ------------------------------- 卡片 ------------------------------- */
/* 时长在剧场里是"能不能完整看完"的关键信息，所以直接印在封面上、且不省略 */
.th-card .card-media-wide { position: relative; }
.th-badge {
  position: absolute;
  left: 8px;
  top: 8px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #1a1206;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.36);
}
.th-long { color: var(--dim); font-weight: 600; }

/**
 * 央视条目单独一个配色（青色）：
 * ★ 不是为了好看，是为了**一眼分清这条能不能站内播**。
 *   B 站条目点开是 iframe 内嵌播放器，央视条目点开是站内 <video> + hls；
 *   两者时长、标题格式都很像（都是「豫剧《XX》」），只靠副标题的小字分辨太费劲。
 */
.th-badge.is-cntv {
  color: #04241f;
  background: linear-gradient(135deg, #5eead4, #14b8a6);
  box-shadow: 0 4px 14px rgba(20, 184, 166, 0.34);
}
/**
 * 外部源（爱奇艺 / 优酷）角标：橙色，和央视的青色、B 站的默认色区分开。
 * ★ 用橙色不是审美选择 —— 它在这套深色 UI 里本身就带"要跳出去"的暗示，
 *   和卡片副标题「需跳转观看」形成双重提示。
 */
.th-badge.is-ext {
  color: #2a1400;
  background: linear-gradient(135deg, #fdba74, #f97316);
  box-shadow: 0 4px 14px rgba(249, 115, 22, 0.32);
}
/**
 * 戏曲窝角标：这里显示的是**剧种名**（京剧/越剧/秦腔…），不是"完整版"。
 * ⇒ 用琥珀金，和 B 站的默认色、央视的青色、外部源的橙色都区分开；
 *   目的是让"多剧种"在一屏里一眼可数（用户提的需求就是"其它剧种也采集"）。
 * ★ 字号比其它角标小半档：剧种名最多四个字（河北梆子），要和"完整版"同宽不撑破封面。
 */
.th-badge.is-xw {
  color: #2a1a00;
  background: linear-gradient(135deg, #fde68a, #f59e0b);
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.32);
  letter-spacing: 0.02em;
}

/* ------------------------------- 浮层 ------------------------------- */
.theater {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 130; /* 高于 #modal(120) 与 #stage(110)：剧场是从 MV 页直接打开的 */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.theater-mask {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: rgba(0, 0, 0, 0.72);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.theater-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1000px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  border-radius: var(--r-lg);
  border: 1px solid var(--hair);
  background: var(--glass-2);
  box-shadow: var(--shadow-3);
  overflow: hidden;
}

/* 头部 */
.theater-head {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.theater-title {
  flex: 1;
  min-width: 0;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: 10px;
}

/* 播放区：16:9 占位 + 绝对定位的 iframe（老引擎也认的一种写法） */
.theater-stage {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  background: #000;
  flex: none;
}
.theater-stage iframe {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}
.theater-loading {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.66);
  pointer-events: none;
}

/* 底部：来源说明 + 外链 */
.theater-foot {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  flex: none;
  border-top: 1px solid var(--line);
}
.theater-meta {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  color: var(--mute);
  line-height: 1.5;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: 10px;
}
.theater-foot .btn { flex: none; }

/* ---------------------- 央视源：<video> 与 hls.js ---------------------- */
/**
 * ★ 央视走 hls.js + 自己的 <video>（见 `assets/js/theater.js` 顶部说明），
 *   占位盒与 iframe 完全一致 —— 两种源切换时高度不跳。
 */
.theater-video {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  display: block;
}

/* 全屏按钮（两种源共用）：压在播放区右下 */
.theater-fs {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 2;
  width: 34px;
  height: 34px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.52);
  color: #fff;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.theater-fs:active { background: rgba(0, 0, 0, 0.78); }

/**
 * ★★ 载入失败时要能**点到里面的「去央视网看」**：
 *   `.theater-loading` 默认 `pointer-events:none`（不想挡住播放器），
 *   但错误态里面放了一个 <a>，不放开点不动 —— 那就成了"转圈转一辈子且退不出去"。
 */
.theater-loading--err {
  pointer-events: auto;
  padding: 0 16px;
  text-align: center;
  line-height: 1.9;
  color: rgba(255, 255, 255, 0.82);
}

/**
 * 外部源（爱奇艺 / 优酷）：不能站内播，只做引导。
 * ★ 2026-10-21 加。这两家的详情页都带 X-Frame-Options / CSP，硬嵌是白板，
 *   且跨域检测不到失败，所以干脆不放 iframe，直接给封面 + 说明 + 大按钮。
 * ★ 老 WebView 约束：不用 `inset`（拆成四条）、不用 `aspect-ratio`
 *   （封面靠 `background-size:cover` 自适应，不依赖比例）、不用 `clamp()`。
 */
.theater-ext {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  align-items: stretch;
  background: #0b0d10;
  overflow: hidden;
}
.theater-ext-poster {
  flex: 0 0 38%;
  background-color: #141821;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
}
/* 封面右侧的渐隐，让文字区过渡自然（不用 mask，老 WebView 支持不稳） */
.theater-ext-poster::after {
  content: '';
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, rgba(11, 13, 16, 0) 55%, rgba(11, 13, 16, 0.92) 100%);
}
.theater-ext-body {
  flex: 1 1 auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  /* ★ flex 的 gap 在老 Chromium 66 上"合法但无效"，间距一律用 margin */
  min-width: 0;
}
.theater-ext-title {
  margin: 0 0 6px;
  font-size: 13.5px;
  font-weight: 600;
  color: #fff;
  line-height: 1.45;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.theater-ext-tip {
  margin: 0 0 10px;
  font-size: 11.5px;
  line-height: 1.7;
  color: rgba(255, 255, 255, 0.6);
}
.theater-ext-tip b {
  color: rgba(255, 255, 255, 0.85);
  font-weight: 600;
}
.theater-ext-btn {
  align-self: flex-start;
  padding: 8px 18px;
  border: 0;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #2f7dff, #1a5fd0);
  cursor: pointer;
  /* ★ 手指点上去不要出现系统灰块（Android WebView 默认有） */
  -webkit-tap-highlight-color: transparent;
}
.theater-ext-btn:active {
  transform: scale(0.97);
}
/* 窄屏（手机）改上下排：**封面做成整块背景**，文字压在上面靠底。
 * ★★ 这里踩过坑：一开始写成「封面 flex:0 0 52% + 文字 flex:0 0 auto」的上下两段，
 *   结果 stage 只有 207px 高（16:9），封面吃掉 107px，剩下 100px 装不下
 *   标题 2 行 + 说明 3 行 + 按钮，**按钮被裁成半个**（实测截图 ext-panel.png）。
 *   ⇒ 手机上封面脱离文档流当背景，文字区独占整块高度，永远不会溢出。
 */
@media (max-width: 560px) {
  .theater-ext {
    flex-direction: column;
  }
  .theater-ext-poster {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    flex: none;
  }
  .theater-ext-poster::after {
    background: linear-gradient(180deg, rgba(11, 13, 16, 0.42) 0%, rgba(11, 13, 16, 0.93) 72%);
  }
  .theater-ext-body {
    position: relative;
    z-index: 1;
    flex: 1 1 auto;
    justify-content: flex-end;
    padding: 10px 14px 12px;
  }
  .theater-ext-title {
    font-size: 12.5px;
    margin: 0 0 4px;
    -webkit-line-clamp: 1;
  }
  .theater-ext-tip {
    font-size: 11px;
    line-height: 1.6;
    margin: 0 0 8px;
    /* 说明最多 2 行，多的省略 —— 207px 的高度经不起 4 行 */
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
  .theater-ext-btn {
    padding: 7px 16px;
    font-size: 12.5px;
  }
}

/**
 * ★★ 全屏：三条选择器一个都不能少。
 *   `:fullscreen`（标准）/ `:-webkit-full-screen`（老 Chromium 66）/ `.is-fs`（投影类）。
 *   老 WebView 只认 `webkitRequestFullscreen`；而无头浏览器**直接拒绝** requestFullscreen，
 *   探针就靠 `.is-fs` 判断"点下去到底有没有切成全屏"，缺这条等于探针永远测不到。
 * ★ 用 `position:fixed` 铺满而不是 `height:100vh`：requestFullscreen 被拒时
 *   至少还能铺满视口（视觉上就是全屏），不会出现"撑破浮层、标题栏被顶到屏幕外"。
 */
.theater-stage:fullscreen,
.theater-stage:-webkit-full-screen,
.theater-stage.is-fs {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  padding-top: 0;
  z-index: 200;
  background: #000;
}
.theater-stage:fullscreen video,
.theater-stage:-webkit-full-screen video,
.theater-stage.is-fs video,
.theater-stage:fullscreen iframe,
.theater-stage:-webkit-full-screen iframe,
.theater-stage.is-fs iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* ------------------------------- 手机端 ------------------------------- */
@media (max-width: 767px) {
  .theater { padding: 10px; align-items: flex-start; padding-top: 56px; }
  .theater-card { max-height: 88vh; border-radius: 16px; }
  .theater-head { padding: 10px 12px; }
  .theater-title { font-size: 12.5px; }
  .theater-foot { padding: 8px 12px; }
  .theater-meta { font-size: 11px; }
  /* 竖屏下 16:9 只有 219px 高，横过来看更舒服 —— 提示写清楚，别让用户自己猜 */
  .theater-foot .btn { height: 30px; padding: 0 10px; font-size: 11.5px; }
}
