/* ============================================================================
 * 主题补充样式表（自动生成，勿手改）
 *
 * ① 预览补丁升格：静态快照只留渲染后 DOM，React 的 scrolled / 筛选态不会被带过来，
 *    这里用纯 CSS + 少量 JS 补回（页头滚动底色、筛选按钮激活态、时间轴圆点、白底阅读面工具类）。
 * ② 内联 style 兜底：sanitize 会剥掉 style 属性，index.html 的 9 处内联样式按原文转成类。
 * ③ 页头当页高亮 + 移动端菜单。
 * ========================================================================== */

/* ============================================================================
 * 126 主题补充样式（由预览补丁升格而来）
 *
 * 为什么需要：静态快照只保留渲染后的 DOM，React 的运行时状态（useState 驱动的
 * scrolled / activeLevel / activeCat）不会被带过来。原设计里这三处的表现依赖
 * 运行时 class 切换，所以直开快照会「样式缺失」。这里用纯 CSS + 少量 JS 补回。
 *
 * 作用范围：126 门户专属主题包（assets/css/theme-extra.css），门户与离线预览共用。
 * ========================================================================== */

/* 兜底：hidden 属性在静态页里必须可靠生效（筛选隐藏卡片用） */
[hidden] { display: none !important; }

/* ---------- ① 页头滚动底色 ----------------------------------------------
 * 对应 Header.tsx:117-121 的 scrolled 分支：
 *   backdrop-blur-xl bg-[#050e1f]/80 border-b border-[#00b4ff]/10
 *   shadow-[0_4px_30px_rgba(0,0,0,0.4)] py-2   （未滚动时是 bg-transparent py-4）
 * header 自带 transition-all duration-300，所以这里改 padding 会平滑过渡。
 * ------------------------------------------------------------------------ */
header.is-scrolled {
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  background: rgba(5, 14, 31, 0.8);
  border-bottom: 1px solid rgba(0, 180, 255, 0.1);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.4);
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}

/* ---------- ② 列表页筛选按钮激活态 --------------------------------------
 * 对应 PolicyBrowser.tsx:75-79 与 NewsFeed.tsx:106-110 的条件 class：
 *   激活 = bg-[#0066ff] text-white shadow-[0_0_14px_rgba(0,102,255,0.5)]
 *   常态 = bg-[#081629] text-[#cfe6fa] border border-[#00e5ff]/15
 * 用自定义类 + !important 覆盖原有的常态 class，避免运行时拼接 Tailwind 类名。
 * ------------------------------------------------------------------------ */
button.filter-btn { cursor: pointer; }
button.filter-btn.is-active {
  background: #0066ff !important;
  color: #ffffff !important;
  border-color: transparent !important;
  box-shadow: 0 0 14px rgba(0, 102, 255, 0.5);
}
button.filter-btn:not(.is-active) {
  background: #081629 !important;
  color: #cfe6fa !important;
  border: 1px solid rgba(0, 229, 255, 0.15) !important;
}
button.filter-btn:not(.is-active):hover {
  border-color: rgba(0, 229, 255, 0.4) !important;
  color: #ffffff !important;
}

/* ---------- ③ 发展历程时间轴：圆点与竖线对不齐 ---------------------------
 * 原设计 AboutFallback.tsx 写的是 -left-[29px]。几何关系：
 *   容器 .relative.border-l-2（竖线 2px）→ 子项 .relative.pl-10（圆点 absolute 相对它定位）
 *   子项 padding box 左边缘 = 容器 border box 左边缘 + 2px，故竖线中心在子项坐标 -1px 处；
 *   圆点 h-4 w-4（16px），要正中压线则 left = -(16/2 + 1) = -9px。
 *   -29px 会把圆点整颗推到竖线左侧 → 视觉「点线分离」。
 * theme.css 里两种取值都没生成（dev 编译遗漏），所以这里直接把位移补上，
 * 并同时修正 HTML 里的类名（见 _build_preview.cjs 的 fixTimelineDot）。
 * ------------------------------------------------------------------------ */
.-left-\[9px\] { left: -9px !important; }
.-left-\[29px\] { left: -9px !important; }

/* ---------- ④ 白底阅读面用到的、theme.css 未生成的工具类 -----------------
 * 取值 = Tailwind 默认调色板，保证快照与设计稿一致。
 * （后续做 CMS 上传包时，应把这几条补进 lib/cms-template-classes.ts 安全清单，
 *   让门户自己的 Tailwind 生成，不要依赖这个预览专用补丁层。）
 * ------------------------------------------------------------------------ */
.text-sky-500 { color: #0ea5e9; }
.border-sky-200 { border-color: #bae6fd; }
.border-sky-300 { border-color: #7dd3fc; }
.border-sky-400 { border-color: #38bdf8; }

/* 2026-09-17 二次审计补漏：下列 4 条在渲染后的 DOM 里被用到，但门户 Tailwind 没生成规则
 *（原文见 ServicesFallback.tsx:142 的条件模板串，扫描阶段未命中），
 * 直接按 Tailwind 默认调色板/间距补齐，保证版式与设计一致。 */
.bg-slate-200 { background-color: #e2e8f0; }
.hover\:border-sky-400:hover { border-color: #38bdf8; }
.hover\:text-sky-600:hover { color: #0284c7; }
/* lg: 断点 = 64rem（Tailwind 默认 lg） */
@media (min-width: 64rem) {
  .lg\:\[\&\>\*\:first-child\]\:order-2 > *:first-child { order: 2; }
}

/* ---------- ② 原内联 style → 类（sanitize 剥离 style 属性，见构建器步骤 2） ---------- */
.st-1 { background-image:linear-gradient(rgba(0,170,255,0.05) 1px, transparent 1px), linear-gradient(90deg, rgba(0,170,255,0.05) 1px, transparent 1px);background-size:60px 60px; }
.st-2 { animation:float-figure 6s ease-in-out infinite; }
.st-3 { animation:pulse-ring 3s ease-out infinite; }
.st-4 { animation:pulse-ring 3s ease-out infinite 1s; }
.st-5 { animation:pulse-ring 3s ease-out infinite 2s; }
.st-6 { animation:spin-slow 20s linear infinite; }
.st-7 { animation:spin-slow 30s linear infinite reverse; }
.st-8 { animation:spin-slow 40s linear infinite; }
.st-9 { background-image:linear-gradient(rgba(0,170,255,0.08) 1px, transparent 1px), linear-gradient(90deg, rgba(0,170,255,0.08) 1px, transparent 1px);background-size:40px 40px; }

/* ---------- ③ 页头当页高亮（原设计由 React 按 pathname 拼 class） ---------- */
header nav a.is-current { color: #00e5ff !important; }
header nav li > span.nav-underline {
  position: absolute; left: 0.75rem; right: 0.75rem; bottom: -0.125rem; height: 2px;
  border-radius: 9999px; background: linear-gradient(to right, #0066ff, #00e5ff);
  box-shadow: 0 0 10px rgba(0, 170, 255, 0.8);
}

/* ---------- ⑤ 越白名单标签降级的补偿（2026-09-17） ----------
 * 门户 sanitize 白名单没有 button，构建器已把 <button> 降级为 <div class="… js-menu-btn|js-tab-btn">。
 * Tailwind preflight 给 button 的默认样式（cursor:pointer、背景透明、字体继承）随之丢失，
 * 这里按需补回；user-select 与 tap-highlight 让 div 版按钮的手感与原生 button 一致。     */
.js-menu-btn, .js-tab-btn { cursor: pointer; -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent; font: inherit; }
.js-menu-btn:focus-visible, .js-tab-btn:focus-visible {
  outline: 2px solid #00e5ff; outline-offset: 2px; }

/* ---------- ④ 移动端菜单（原设计为 React 条件渲染，静态快照无面板 DOM，由 theme.js 生成） ---------- */
.mobile-panel {
  position: absolute; left: 0; right: 0; top: 100%;
  background: rgba(5, 14, 31, 0.98);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  border-top: 1px solid rgba(0, 180, 255, 0.15);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  padding: 0.75rem 1rem 1.25rem;
  max-height: calc(100vh - 4.5rem); overflow-y: auto;
}
.mobile-panel[hidden] { display: none; }
.mobile-panel a {
  display: block; padding: 0.625rem 0.75rem; border-radius: 0.5rem;
  font-size: 0.875rem; font-weight: 500; color: rgba(232, 244, 255, 0.85);
}
.mobile-panel a:hover { background: rgba(255, 255, 255, 0.05); color: #ffffff; }
@media (min-width: 1024px) { .mobile-panel { display: none; } }

/* ============================================================================
 * 政策支持分组 tab（2026-10-07 新增）
 *
 * 为什么需要这段：theme.js 的 initPolicyTabs 切 tab 时加/移除 .is-active，
 * 但**原设计里选中态是靠元素自带 class 表达的**（静态快照版是
 *   bg-[#0066ff] text-white shadow-[0_0_14px_rgba(0,102,255,0.5)]，即蓝底白字）。
 * CMS 模板把 <button> 降级成 <div class="js-policy-tab"> 后，那些「当前选中」的 class
 * 只能落在「全部」那一个上；其余 tab 要靠 JS 切换 ⇒ 必须有 .is-active 的样式规则。
 *
 * 查证（2026-10-07）：theme.css 与 theme-extra.css 原本**都没有** .is-active 定义
 * （theme-extra.css 里只有 .filter-btn { cursor: pointer }），
 * 所以 JS 加了类也没有任何视觉变化 —— 这就是「点 tab 看不到选中态」的根因。
 *
 * 颜色与原设计对齐：主色 #0066ff、光晕 rgba(0,102,255,.5)。
 * ============================================================================ */
.js-policy-tab {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.js-policy-tab.is-active {
  background: #0066ff;
  color: #ffffff;
  border-color: #0066ff;
  box-shadow: 0 0 14px rgba(0, 102, 255, 0.5);
}

/* 分组面板显隐：initPolicyTabs 切 hidden 类。
   这条 !important 是兜底 —— 主题包 CSS 未加载时也不至于 4 个 iframe 全糊在页面上。 */
.js-policy-panel.hidden {
  display: none !important;
}

/* iframe 内容区：去默认边框/白底，与外层深蓝底色一致 */
.js-policy-frame {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
}

/* ============================================================================
 * 政策分组 tab · 加载中状态与图标动画（2026-10-07 追加）
 *
 * 背景：iframe 懒加载期间若无任何提示，用户会以为「点了没反应」。
 *      theme.js 的 ensureLoaded 负责亮出 .js-policy-loading，
 *      iframe 的 load/error 与 8s 超时收掉它。
 * ============================================================================ */
.js-policy-loading.hidden {
  display: none !important;
}

/* 加载 spinner：纯 CSS 自绘（border + rotate）。
   🔴 不用图标：主题 icons.css 只有 58 个图标，实测**无** loader/refresh 类，
   写 <span class="ic ic-loader-2"> 会因 mask 找不到图标而渲染成空框。*/
.cms-spinner {
  display: block;
  width: 34px;
  height: 34px;
  margin: 0 auto 16px;
  border: 3px solid rgba(0, 229, 255, 0.18);
  border-top-color: #00e5ff;
  border-radius: 50%;
  animation: cms-policy-spin 900ms linear infinite;
}

@keyframes cms-policy-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .cms-spinner { animation-duration: 2400ms; }
}

/* 加载态时隐藏 iframe 本体，避免出现一块空白区域再突然出内容 */
.js-policy-panel.is-loading > .js-policy-frame {
  visibility: hidden;
}

.opc-carousel { position: relative; }
.opc-carousel__track {
  display: flex; transform: translateX(0);
  transition: transform .5s ease; will-change: transform;
}
.opc-carousel__slide { flex: 0 0 100%; min-width: 100%; }
.opc-carousel__slide img {
  width: 100%; aspect-ratio: 4 / 3; object-fit: contain; display: block;
}
/* 原单图底部的渐变遮罩，移到轮播层之上（不挡按钮，pointer-events:none） */
.opc-carousel__overlay {
  position: absolute; inset: 0; pointer-events: none; z-index: 2;
  background: linear-gradient(to top, rgba(5, 14, 31, 0.6), transparent 55%, transparent);
}
.opc-carousel__btn {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 3;
  width: 2.25rem; height: 2.25rem; display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; line-height: 1; color: #e8f4ff; cursor: pointer;
  background: rgba(5, 14, 31, 0.45); border: 1px solid rgba(0, 180, 255, 0.25); border-radius: 9999px;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  transition: background .2s, transform .15s;
}
.opc-carousel__btn:hover { background: rgba(0, 140, 255, 0.55); }
.opc-carousel__btn:active { transform: translateY(-50%) scale(0.92); }
.opc-carousel__btn--prev { left: 0.75rem; }
.opc-carousel__btn--next { right: 0.75rem; }
.opc-carousel__dots {
  position: absolute; bottom: 0.75rem; left: 50%; transform: translateX(-50%);
  z-index: 3; display: flex; gap: 0.4rem;
}
.opc-carousel__dot {
  width: 0.5rem; height: 0.5rem; border-radius: 9999px; cursor: pointer;
  background: rgba(232, 244, 255, 0.4); transition: background .2s, width .2s;
}
.opc-carousel__dot.is-active { background: #00e5ff; width: 1.1rem; }
