/*
 * 漫读漫画主题 · 暗黑模式 + 夜读模式
 *
 * 设计准则（参考 Material Design / WCAG AA / Webtoons-dark-mode 项目）：
 *  - 不用纯黑 #000，用 #121212，避免与浅色文字的光晕（halation）和眼疲劳。
 *  - 不用纯白 #fff 文字，用 #e4e4e7，柔和不刺眼。
 *  - 漫画图片绝对不反色、不加 hue-rotate（会破坏画面颜色）。
 *    只对 chrome（导航/卡片/表单/弹窗）应用暗主题。
 *  - 主体通过 CSS 变量翻转完成；少量硬编码 #fff 背景的组件单独覆盖。
 *  - 对比度 WCAG AA：正文 4.5:1，大字 3:1。本配色实际 17:1（主文字）/ 9:1（次文字）。
 *
 * 切换机制：<html data-theme="dark"> 由 dark-mode.js 在 <head> 早期注入设置。
 *
 * 夜读模式：[data-night-dim="on"] 给 .reader-img 加 brightness(0.85)，独立开关，
 * 亮黑模式都可用，专为长时间夜读减刺眼。
 */

/* ============================ 变量翻转 ============================ */

html[data-theme="dark"] {
    --primary:       #FFD100;
    --primary-hover: #FFE640;
    --primary-light: rgba(255, 209, 0, 0.12);
    --primary-dark:  #C9A000;
    --nav-bg:        #0e0e10;
    --white:         #1c1c1f;       /* 原来表示"白色卡片背景"的变量，暗模式翻成 surface */
    --bg:            #121212;
    --text:          #e4e4e7;
    --text-sec:      #a1a1aa;
    --text-muted:    #71717a;
    --border:        #2d2d33;
    --red:           #f87171;
    --orange:        #fb923c;
    --green:         #4ade80;
    --shadow-sm:     0 1px 4px rgba(0, 0, 0, 0.35);
    --shadow:        0 2px 12px rgba(0, 0, 0, 0.45);
    --shadow-lg:     0 8px 32px rgba(0, 0, 0, 0.55);

    color-scheme: dark;
}

/* color-scheme 让浏览器把滚动条、表单原生控件等渲染成暗色 */

/* ============================ 全局软覆盖 ============================ */
/* 大部分主题样式靠 var(--bg) / var(--text) / var(--white) 已经自动适配。
 * 下面只处理硬编码颜色的关键元素。
 */

html[data-theme="dark"] body { background: var(--bg); color: var(--text); }

/* 硬编码 #fff 背景的组件 → 翻成 surface */
html[data-theme="dark"] .mct-admin-card,
html[data-theme="dark"] .mct-history-item,
html[data-theme="dark"] .mct-vip-status,
html[data-theme="dark"] .mct-user-card,
html[data-theme="dark"] .mct-user-order-item,
html[data-theme="dark"] .vip-modal,
html[data-theme="dark"] .modal,
html[data-theme="dark"] .auth-form,
html[data-theme="dark"] .filter-drawer,
html[data-theme="dark"] .mct-reader-chapter-sheet__panel,
html[data-theme="dark"] .mct-auth-modal,
html[data-theme="dark"] .hero-slide__content,
html[data-theme="dark"] .sidebar-block,
html[data-theme="dark"] .chapter-end-card,
html[data-theme="dark"] .vip-plan-card {
    background: #1c1c1f !important;
    color: var(--text);
    border-color: var(--border);
}

/* 强调态/选中态卡片：#fffdf0 之类浅黄底 → 暗黄半透明 */
html[data-theme="dark"] .mct-vip-status.active,
html[data-theme="dark"] .vip-plan-card.featured,
html[data-theme="dark"] .vip-plan-card.active,
html[data-theme="dark"] .mct-admin-test-panel {
    background: rgba(255, 209, 0, 0.06) !important;
    border-color: rgba(255, 209, 0, 0.32) !important;
}

/* 浅灰底块 #f6f6f6 / #f5f5f5 → 比 surface 再浅一档作分层 */
html[data-theme="dark"] .filter-panel,
html[data-theme="dark"] .chapter-grid .chapter-item,
html[data-theme="dark"] .detail-tag {
    background: #27272a;
    color: var(--text);
    border-color: var(--border);
}

/* 状态徽章浅色文字保持（红/黄/绿在暗底上对比足够）*/

/* ============================ 表单控件 ============================ */

html[data-theme="dark"] input[type="text"],
html[data-theme="dark"] input[type="email"],
html[data-theme="dark"] input[type="password"],
html[data-theme="dark"] input[type="search"],
html[data-theme="dark"] input[type="number"],
html[data-theme="dark"] input[type="url"],
html[data-theme="dark"] input[type="tel"],
html[data-theme="dark"] textarea,
html[data-theme="dark"] select {
    background: #27272a;
    color: var(--text);
    border: 1px solid var(--border);
}

html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
    color: var(--text-muted);
}

html[data-theme="dark"] input:focus,
html[data-theme="dark"] textarea:focus,
html[data-theme="dark"] select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(255, 209, 0, 0.18);
    outline: none;
}

/* ============================ 链接（按钮里的黄底深字保持） ============================ */
/*
 * 不在这里设全局 a 颜色——主题大量 .X a 选择器(.header-actions a / .genre-nav a /
 * .mct-mobile-bottom-nav a / .mct-footer-menu a 等)与 html[data-theme="dark"] a 特异性
 * 平局(0,1,1),全局规则因 dark.css 后加载会赢得平局并把它们全部覆盖,直接破坏导航/底部
 * 栏的颜色。链接颜色统一交给各组件自己负责(下面按需补单点覆盖)。
 */
html[data-theme="dark"] .btn-primary,
html[data-theme="dark"] .btn-yellow {
    color: #1a1a1a;   /* 黄底深字保持 */
}

/* 手机底部导航(theme-extra.css 行 819 用了 rgba(255,255,255,.96) 白底 + a color #5f6671)
 * 暗模式下必须翻成暗底 + 浅文字,否则白底白字 → 整条 nav 几乎不可见(只剩 active 项)。
 */
html[data-theme="dark"] .mct-mobile-bottom-nav {
    background: rgba(20, 20, 22, 0.92);
    border-top-color: var(--border);
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.5);
}
html[data-theme="dark"] .mct-mobile-bottom-nav a {
    color: var(--text-sec);     /* #a1a1aa,9:1 对比暗底 */
}
html[data-theme="dark"] .mct-mobile-bottom-nav a.active,
html[data-theme="dark"] .mct-mobile-bottom-nav a.active .mct-bottom-icon {
    color: var(--primary);      /* 品牌黄,active 高亮 */
}

/* Footer 文字硬编码 #1f2937(深色),暗模式必须翻成浅色 */
html[data-theme="dark"] .mct-footer-menu a,
html[data-theme="dark"] .mct-footer-contact a {
    color: var(--text-sec);
}
html[data-theme="dark"] .mct-footer-menu a:hover,
html[data-theme="dark"] .mct-footer-contact a:hover {
    color: var(--primary);
}
html[data-theme="dark"] .mct-footer-email a {
    color: var(--primary);      /* 邮箱保留醒目色 */
}

/* ============================ 蒙层 ============================ */

html[data-theme="dark"] .modal-overlay,
html[data-theme="dark"] .mct-auth-modal-overlay,
html[data-theme="dark"] .filter-drawer-overlay,
html[data-theme="dark"] .mct-reader-chapter-sheet__mask {
    background: rgba(0, 0, 0, 0.7);
}

/* ============================ 阅读页 ============================ */

html[data-theme="dark"] .reader-header,
html[data-theme="dark"] .reader-toolbar,
html[data-theme="dark"] .reader-bottom-nav {
    background: #0e0e10;
    border-color: var(--border);
    color: var(--text);
}

html[data-theme="dark"] .reader-content {
    background: var(--bg);
    color: var(--text);
}

html[data-theme="dark"] .reader-img-wrap {
    background: transparent;
}

/* ★★★ 漫画图片永远不动颜色 ★★★ */
html[data-theme="dark"] .reader-img,
html[data-theme="dark"] .manga-card__cover img,
html[data-theme="dark"] .detail-cover img {
    filter: none !important;
    /* 用户开启"夜读"时由下面 [data-night-dim] 规则单独控制亮度 */
}

/* GEO 文本块在阅读页底部：颜色靠 inline var(--text/text-sec)，这里只调背景 */
html[data-theme="dark"] .mct-reader-context {
    background: var(--bg);
}

/* ============================ 夜读模式（独立开关，亮黑均可用） ============================ */

html[data-night-dim="on"] .reader-img {
    filter: brightness(0.85);
    transition: filter 0.2s ease;
}

/* 夜读按钮激活态 */
html[data-night-dim="on"] .mct-night-dim-toggle {
    color: var(--primary);
}
html[data-night-dim="on"] .mct-night-dim-toggle .toolbar-icon {
    text-shadow: 0 0 6px rgba(255, 209, 0, 0.5);
}

/* ============================ 顶部 ☾/☀ 切换按钮 ============================ */

.mct-theme-toggle {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text);
    transition: var(--transition);
    margin-left: 8px;
    font-size: 16px;
    line-height: 1;
}
.mct-theme-toggle:hover {
    border-color: var(--primary);
    color: var(--primary);
}
.mct-theme-toggle .mct-theme-toggle-light,
.mct-theme-toggle .mct-theme-toggle-dark {
    display: none;
}
html[data-theme="dark"] .mct-theme-toggle .mct-theme-toggle-light { display: inline; }
html:not([data-theme="dark"]) .mct-theme-toggle .mct-theme-toggle-dark { display: inline; }

/* 强制模式（admin 在 layout.dark_mode=dark/light 时设置）：隐藏切换按钮 */
html[data-theme-locked="1"] .mct-theme-toggle {
    display: none !important;
}

/* ============================ 选区 / 滚动条美化 ============================ */

html[data-theme="dark"] ::-webkit-scrollbar { width: 10px; height: 10px; }
html[data-theme="dark"] ::-webkit-scrollbar-track { background: #1c1c1f; }
html[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: #3a3a40;
    border-radius: 5px;
}
html[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: #52525b; }

/* ============================ 选区 ============================ */
html[data-theme="dark"] ::selection {
    background: rgba(255, 209, 0, 0.32);
    color: var(--text);
}

/* ============================ 分页(标准窗口化布局) ============================ */
/* 这一组样式不止暗模式用——它给 mct_pagination 输出的 <span> 元素(当前页/省略号/禁用箭头)
 * 补样式,与已有 .pagination a 视觉对齐。theme-extra.css 行 623 只覆盖了 <a>,新版分页含
 * 大量 span,需要此段配合,否则 1355/15=91 页时翻页排版会再次失控。
 */
.pagination {
    flex-wrap: wrap;
    row-gap: 6px;
}
.pagination span.active,
.pagination span.pagination__nav,
.pagination span.pagination__ellipsis {
    min-width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    font-size: 14px;
    border: 1px solid var(--border);
    color: var(--text);
    background: var(--white);
    user-select: none;
}
.pagination span.active {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--nav-bg);
    font-weight: 700;
}
.pagination span.pagination__ellipsis {
    border-color: transparent;
    background: transparent;
    color: var(--text-muted);
    cursor: default;
}
.pagination .pagination__nav {
    font-size: 18px;
    line-height: 1;
    font-weight: 700;
}
.pagination span.disabled,
.pagination .pagination__nav.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* 手机端紧凑 + 单行可滚 */
@media (max-width: 720px) {
    .pagination {
        gap: 4px;
        padding: 16px 8px;
    }
    .pagination a,
    .pagination span.active,
    .pagination span.pagination__nav,
    .pagination span.pagination__ellipsis {
        min-width: 30px;
        height: 30px;
        font-size: 13px;
    }
}

/* ============================ 底部导航防御性保险 ============================ */
/* 之前用户报"分类页底部只显示一个图标",静态 CSS 检查没发现明确隐藏规则。
 * 大概率是 91 个翻页按钮把布局推乱后的次生症状,但加层保险:在手机视口强制
 * 4 列网格 + 高 z-index,无论上方分页/抽屉/插件 CSS 怎样,都让 4 个图标稳定显示。
 */
@media (max-width: 720px) {
    .mct-mobile-bottom-nav {
        display: grid !important;
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
        z-index: 2100 !important;
    }
    .mct-mobile-bottom-nav a {
        min-width: 0;
        overflow: hidden;
    }
}
