/* ============================================================
   抖音火热榜 - 用户外观偏好 (首页 / 内页共用)
   由 static/appearance.js 在 <html> 上写入 data-theme / data-font /
   data-density, 本文件据此切换整套协调的配色与字号。
   ============================================================ */

:root {
    --fs: 1;
    --density: 1;
}

/* ---------- 字号档位 ---------- */
html[data-font="small"]  { --fs: 0.90; }
html[data-font="normal"] { --fs: 1; }
html[data-font="large"]  { --fs: 1.15; }
html[data-font="xlarge"] { --fs: 1.30; }

/* ---------- 列表密度 ---------- */
html[data-density="compact"] { --density: 0.78; }
html[data-density="cozy"]    { --density: 1; }
html[data-density="relaxed"] { --density: 1.25; }

/* ---------- 主题: 经典红(默认) ---------- */
:root,
html[data-theme="classic"] {
    --rebang-accent: #d93b30;
    --rebang-accent-hover: #c5342a;
    --rebang-accent-soft: rgba(217, 59, 48, 0.08);
    --rebang-text: #1a1715;
    --rebang-secondary: #5c5650;
    --rebang-tertiary: #a09890;
    --rebang-border: rgba(0, 0, 0, 0.06);
    --rebang-border-strong: rgba(0, 0, 0, 0.12);
    --rebang-bg: #ffffff;
    --rebang-card: #ffffff;
    --rebang-soft: rgba(0, 0, 0, 0.025);
    --rebang-hover: rgba(0, 0, 0, 0.035);
    --rebang-error: #b33026;
    --rebang-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.03);
    --rebang-shadow-hover: 0 2px 8px rgba(0, 0, 0, 0.06), 0 8px 24px rgba(0, 0, 0, 0.06);
}

/* ---------- 主题: 科技蓝 ---------- */
html[data-theme="blue"] {
    --rebang-accent: #2f6fce;
    --rebang-accent-hover: #255ab0;
    --rebang-accent-soft: rgba(47, 111, 206, 0.09);
    --rebang-text: #171b22;
    --rebang-secondary: #545e6b;
    --rebang-tertiary: #939daa;
    --rebang-border: rgba(23, 40, 70, 0.07);
    --rebang-border-strong: rgba(23, 40, 70, 0.14);
    --rebang-bg: #fbfcfe;
    --rebang-card: #ffffff;
    --rebang-soft: rgba(47, 111, 206, 0.045);
    --rebang-hover: rgba(47, 111, 206, 0.07);
    --rebang-error: #c0392b;
    --rebang-shadow: 0 1px 3px rgba(31, 64, 120, 0.05), 0 4px 12px rgba(31, 64, 120, 0.04);
    --rebang-shadow-hover: 0 2px 8px rgba(31, 64, 120, 0.08), 0 8px 24px rgba(31, 64, 120, 0.07);
}

/* ---------- 主题: 森林绿 ---------- */
html[data-theme="green"] {
    --rebang-accent: #159957;
    --rebang-accent-hover: #0f7a45;
    --rebang-accent-soft: rgba(21, 153, 87, 0.09);
    --rebang-text: #17211b;
    --rebang-secondary: #556158;
    --rebang-tertiary: #96a29a;
    --rebang-border: rgba(20, 70, 45, 0.08);
    --rebang-border-strong: rgba(20, 70, 45, 0.15);
    --rebang-bg: #fbfdfb;
    --rebang-card: #ffffff;
    --rebang-soft: rgba(21, 153, 87, 0.045);
    --rebang-hover: rgba(21, 153, 87, 0.075);
    --rebang-error: #b4452f;
    --rebang-shadow: 0 1px 3px rgba(20, 80, 50, 0.05), 0 4px 12px rgba(20, 80, 50, 0.04);
    --rebang-shadow-hover: 0 2px 8px rgba(20, 80, 50, 0.08), 0 8px 24px rgba(20, 80, 50, 0.07);
}

/* ---------- 主题: 暖橙 ---------- */
html[data-theme="orange"] {
    --rebang-accent: #e8830c;
    --rebang-accent-hover: #cc7008;
    --rebang-accent-soft: rgba(232, 131, 12, 0.10);
    --rebang-text: #211a14;
    --rebang-secondary: #62574b;
    --rebang-tertiary: #a69a8c;
    --rebang-border: rgba(90, 60, 20, 0.08);
    --rebang-border-strong: rgba(90, 60, 20, 0.15);
    --rebang-bg: #fffdfa;
    --rebang-card: #ffffff;
    --rebang-soft: rgba(232, 131, 12, 0.05);
    --rebang-hover: rgba(232, 131, 12, 0.08);
    --rebang-error: #c0392b;
    --rebang-shadow: 0 1px 3px rgba(120, 75, 20, 0.05), 0 4px 12px rgba(120, 75, 20, 0.04);
    --rebang-shadow-hover: 0 2px 8px rgba(120, 75, 20, 0.08), 0 8px 24px rgba(120, 75, 20, 0.07);
}

/* ---------- 主题: 夜间 ---------- */
html[data-theme="dark"] {
    --rebang-accent: #ff6b5e;
    --rebang-accent-hover: #ff8276;
    --rebang-accent-soft: rgba(255, 107, 94, 0.13);
    --rebang-text: #ece9e6;
    --rebang-secondary: #b9b2aa;
    --rebang-tertiary: #8a847d;
    --rebang-border: rgba(255, 255, 255, 0.09);
    --rebang-border-strong: rgba(255, 255, 255, 0.18);
    --rebang-bg: #14161a;
    --rebang-card: #1e2128;
    --rebang-soft: rgba(255, 255, 255, 0.05);
    --rebang-hover: rgba(255, 255, 255, 0.085);
    --rebang-error: #ff8a80;
    --rebang-shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 4px 12px rgba(0, 0, 0, 0.22);
    --rebang-shadow-hover: 0 2px 8px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.3);
}
html[data-theme="dark"] .freq-realtime { background: rgba(217,59,48,0.20); color: #ff8f85; border-color: rgba(217,59,48,0.32); }
html[data-theme="dark"] .freq-hourly  { background: rgba(232,131,12,0.20); color: #ffb45c; border-color: rgba(232,131,12,0.32); }
html[data-theme="dark"] .freq-daily   { background: rgba(47,125,225,0.20); color: #82b4ff; border-color: rgba(47,125,225,0.32); }
html[data-theme="dark"] .freq-slow    { background: rgba(150,160,170,0.18); color: #b8c0c8; border-color: rgba(150,160,170,0.28); }

/* ============================================================
   字号缩放: 只缩放正文与控件文字, 不缩放 Logo/图标, 保证布局稳定
   ============================================================ */
/* 各类文字的原始基准值(px), 与模板内声明保持一致。
   注意: 模板 <style> 在 appearance.css 之后加载, 同名单类选择器优先级相同会覆盖本文件;
       故统一加 html[data-font] 前缀提升特异性, 确保首页/内页字号切换都生效。 */
html[data-font] .filter-btn                 { font-size: calc(13px * var(--fs)); }
html[data-font] .sort-btn                   { font-size: calc(13px * var(--fs)); }
html[data-font] .sort-btn-ghost             { font-size: calc(12px * var(--fs)); }
html[data-font] .platform-title             { font-size: calc(15px * var(--fs)); }
html[data-font] .platform-time              { font-size: calc(11px * var(--fs)); }
html[data-font] .card-more-link             { font-size: calc(12px * var(--fs)); }
html[data-font] .list-number                { font-size: calc(13px * var(--fs)); }
html[data-font] .list-text                  { font-size: calc(13px * var(--fs)); }
html[data-font] .empty-list                 { font-size: calc(13px * var(--fs)); }
html[data-font] .error-text                 { font-size: calc(12px * var(--fs)); }
html[data-font] .footer-brand               { font-size: calc(15px * var(--fs)); }
html[data-font] .footer-links a             { font-size: calc(12px * var(--fs)); }
html[data-font] .footer-copy                { font-size: calc(12px * var(--fs)); }
html[data-font] .footer-update              { font-size: calc(11px * var(--fs)); }
html[data-font] .sort-label                 { font-size: calc(13px * var(--fs)); }
html[data-font] .sort-modal-head h3         { font-size: calc(17px * var(--fs)); }
html[data-font] .sort-modal-close           { font-size: calc(24px * var(--fs)); }
html[data-font] .sort-modal-tip             { font-size: calc(12px * var(--fs)); }
html[data-font] .sort-item-name             { font-size: calc(14px * var(--fs)); }
html[data-font] .sort-item-cat              { font-size: calc(11px * var(--fs)); }
html[data-font] .sort-item-actions button   { font-size: calc(14px * var(--fs)); }
html[data-font] .freq-badge                 { font-size: calc(10px * var(--fs)); }
html[data-font] .back-link                  { font-size: calc(13px * var(--fs)); }
html[data-font] .detail-title               { font-size: calc(24px * var(--fs)); }
html[data-font] .detail-meta                { font-size: calc(12px * var(--fs)); }
html[data-font] .section-title              { font-size: calc(16px * var(--fs)); }
html[data-font] .section-title .count       { font-size: calc(12px * var(--fs)); }
html[data-font] .list-date                  { font-size: calc(11px * var(--fs)); }
html[data-font] .empty-block                { font-size: calc(13px * var(--fs)); }
html[data-font] .stale-banner               { font-size: calc(13px * var(--fs)); }
html[data-font] .footer-detail              { font-size: calc(12px * var(--fs)); }
html[data-font] .footer-detail a            { font-size: calc(12px * var(--fs)); }
/* 内页列表文字基准比首页大 1px */
html[data-font] .detail .list-text,
html[data-font] .history-list .list-text,
html[data-font] .latest-list .list-text { font-size: calc(14px * var(--fs)); }

/* 首页卡片错误文案基准 12px, detail 页 13px */
html[data-font] .error-box .error-text { font-size: calc(12px * var(--fs)); }
html[data-font] .error-text { font-size: calc(13px * var(--fs)); }

/* ---------- 列表密度 ---------- */
.list-container .list-item-link { padding-top: calc(10px * var(--density)); padding-bottom: calc(10px * var(--density)); }
.latest-list .list-item-link,
.history-list .list-item-link { padding-top: calc(11px * var(--density)); padding-bottom: calc(11px * var(--density)); }

/* ============================================================
   回到顶部按钮 (内页与首页共用同一套样式)
   ============================================================ */
.back-to-top {
    position: fixed; bottom: 32px; right: 32px;
    width: 44px; height: 44px; border-radius: 50%;
    background: var(--rebang-accent); color: #fff;
    border: none; cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.22);
    display: flex; align-items: center; justify-content: center;
    opacity: 0; visibility: hidden; transform: translateY(16px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 999;
}
.back-to-top.visible { opacity: 1; visibility: visible; transform: translateY(0); }
.back-to-top:hover { background: var(--rebang-accent-hover); transform: translateY(-2px); }
.back-to-top:active { transform: scale(0.92); }
.back-to-top-arrow {
    display: inline-block; width: 10px; height: 10px;
    border-left: 2px solid #fff; border-top: 2px solid #fff;
    transform: rotate(45deg); margin-top: 3px;
}
@media (max-width: 640px) {
    .back-to-top { bottom: 20px; right: 16px; width: 40px; height: 40px; }
}

/* ============================================================
   外观设置入口与面板 (JS 动态注入)
   ============================================================ */
.rb-appear-btn {
    position: fixed; bottom: 32px; right: 88px;
    width: 40px; height: 40px; border-radius: 50%;
    background: var(--rebang-card); color: var(--rebang-accent);
    border: 1px solid var(--rebang-border-strong);
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.12);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; z-index: 1001; font-size: 18px; line-height: 1;
    transition: transform 0.2s ease, border-color 0.2s ease;
}
.rb-appear-btn:hover { transform: rotate(30deg); border-color: var(--rebang-accent); }
@media (max-width: 640px) {
    .rb-appear-btn { bottom: 20px; right: 66px; width: 36px; height: 36px; font-size: 16px; }
}

.rb-appear-panel {
    position: fixed; bottom: 84px; right: 32px; z-index: 1002;
    width: 268px; max-width: calc(100vw - 32px);
    background: var(--rebang-card); color: var(--rebang-text);
    border: 1px solid var(--rebang-border);
    border-radius: 14px; box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18);
    padding: 16px; opacity: 0; visibility: hidden;
    transform: translateY(10px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}
.rb-appear-panel.open { opacity: 1; visibility: visible; transform: translateY(0); }
@media (max-width: 640px) {
    .rb-appear-panel { bottom: 68px; right: 16px; }
}
.rb-appear-panel h4 {
    margin: 0 0 14px; font-size: 14px; font-weight: 600;
    display: flex; align-items: center; justify-content: space-between;
}
.rb-appear-panel h4 button {
    border: none; background: transparent; cursor: pointer;
    color: var(--rebang-tertiary); font-size: 20px; line-height: 1; padding: 0 2px;
}
.rb-appear-panel h4 button:hover { color: var(--rebang-text); }
.rb-appear-group { margin-bottom: 14px; }
.rb-appear-group:last-child { margin-bottom: 0; }
.rb-appear-label {
    display: block; font-size: 11px; color: var(--rebang-tertiary);
    margin-bottom: 7px; letter-spacing: 0.4px;
}
.rb-appear-row { display: flex; flex-wrap: wrap; gap: 6px; }
.rb-appear-opt {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 12px; padding: 6px 10px; border-radius: 18px;
    border: 1px solid var(--rebang-border);
    background: var(--rebang-soft); color: var(--rebang-secondary);
    cursor: pointer; font-family: inherit; transition: all 0.15s ease;
}
.rb-appear-opt:hover { border-color: var(--rebang-accent); color: var(--rebang-accent); }
.rb-appear-opt.active {
    background: var(--rebang-accent); color: #fff;
    border-color: var(--rebang-accent);
}
.rb-appear-dot {
    width: 9px; height: 9px; border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.12); flex-shrink: 0;
}
.rb-appear-reset {
    width: 100%; margin-top: 4px; padding: 8px;
    border: 1px solid var(--rebang-border); border-radius: 8px;
    background: transparent; color: var(--rebang-tertiary);
    font-size: 11px; cursor: pointer; font-family: inherit;
}
.rb-appear-reset:hover { color: var(--rebang-accent); border-color: var(--rebang-accent); }

/* 弹窗隐藏态兜底: 不依赖 Bootstrap 的 [hidden]{display:none!important},
   否则 CDN 不可用时隐藏的遮罩会拦截整页点击 */
.sort-modal-backdrop[hidden],
.rss-modal-backdrop[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
    .back-to-top, .rb-appear-btn, .rb-appear-panel { transition-duration: 0.01ms !important; }
}
