/*
 * 漫读漫画主题 · 暗黑模式 + 夜读模式
 *
 * 设计准则（参考 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;
    }
}

/* ============================ 锁章付费区重构(修被拉长 + 重叠) ============================ */
/*
 * 原 bug:.reader-lock-panel{position:absolute;inset:0} 钉死在 max-height:160px 的
 * .reader-lock-blur 上,但面板里有套餐卡 + 按钮,内容远超 160px → 溢出、与按钮重叠、
 * 整体被异常拉伸。这里改为正常文档流:blur 仅作顶部装饰条,面板在其下方自然排布。
 */
.reader-lock-wrap {
    position: relative;
    background: var(--bg-surface, #1c1c1f);
    border-radius: var(--radius, 12px);
    overflow: hidden;
    max-width: 560px;
    margin: 20px auto;
    border: 1px solid var(--border, #2d2d33);
}
.reader-lock-blur {
    max-height: 120px;
    overflow: hidden;
    filter: blur(14px) brightness(.45);
    pointer-events: none;
    user-select: none;
}
.reader-lock-blur img {
    width: 100%;
    height: auto;
    display: block;
}
/* 关键:面板不再 absolute,回归正常流,高度由内容决定 */
.reader-lock-panel {
    background: none;
    display: block;
    padding: 20px 20px 28px;
    text-align: center;
    margin-top: -40px;          /* 轻微上提,盖住 blur 底边,过渡自然 */
    position: relative;
    z-index: 1;
}
.reader-lock-panel .lock-badge {
    display: inline-block;
    background: var(--primary);
    color: #1a1a1a;
    font-size: 12px;
    font-weight: 700;
    padding: 3px 12px;
    border-radius: 12px;
    margin-bottom: 12px;
}
.reader-lock-panel h2 {
    color: var(--text, #e4e4e7);
    font-size: 18px;
    font-weight: 800;
    margin-bottom: 6px;
}
.reader-lock-panel > p {
    color: var(--text-sec, #a1a1aa);
    font-size: 13px;
    margin-bottom: 16px;
    line-height: 1.6;
}
.reader-lock-panel .lock-note {
    color: var(--text-muted, #71717a);
    font-size: 12px;
    margin-top: 14px;
}

/* 锁章页套餐:紧凑横排,点击即支付(无两步选择) */
.lock-plan-row {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin: 0 auto 8px;
    max-width: 100%;
}
.lock-plan {
    flex: 1 1 0;
    min-width: 96px;
    max-width: 150px;
    background: var(--bg-elevated, #27272a);
    border: 1.5px solid var(--border, #2d2d33);
    border-radius: 10px;
    padding: 12px 10px;
    text-align: center;
    cursor: pointer;
    transition: all .15s ease;
    position: relative;
    text-decoration: none;
    display: block;
}
.lock-plan:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
}
.lock-plan.featured {
    border-color: var(--primary);
    background: rgba(255, 209, 0, .1);
}
.lock-plan__tag {
    position: absolute;
    top: -9px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary);
    color: #1a1a1a;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
}
.lock-plan__name { color: var(--text-sec, #a1a1aa); font-size: 12px; margin-bottom: 4px; }
.lock-plan__price { color: var(--text, #fff); font-size: 19px; font-weight: 900; }
.lock-plan__price sub { font-size: 11px; font-weight: 400; bottom: 0; }
.lock-plan__save { color: var(--primary); font-size: 10px; margin-top: 3px; line-height: 1.3; }

/* 锁章页主按钮(点击即打开套餐选择/直接支付) */
.btn-unlock-vip {
    display: inline-block;
    background: linear-gradient(135deg, #FFD100, #FFA500);
    color: #1a1a1a;
    font-weight: 800;
    font-size: 15px;
    padding: 12px 32px;
    border-radius: 24px;
    border: none;
    cursor: pointer;
    margin-top: 14px;
    text-decoration: none;
    transition: transform .15s ease;
}
.btn-unlock-vip:hover { transform: scale(1.03); }

/* 手机端:套餐竖排,锁章卡留边距 */
@media (max-width: 720px) {
    .reader-lock-wrap { margin: 16px 12px; }
    .lock-plan-row { gap: 8px; }
    .lock-plan { padding: 10px 8px; min-width: 0; }
    .lock-plan__price { font-size: 17px; }
}

/* ============================ VIP 弹窗 + 手机端支付紧凑化 ============================ */
/*
 * 问题:.vip-modal 内容过高顶满屏幕,上下无安全边距,关闭按钮被挤出视口。
 * 手机端 mct_render_vip_plan_cards('modal'/'page') 的完整大卡占满全屏。
 * 这里给弹窗加安全边距 + 内部滚动,并在手机端把套餐卡压缩成紧凑单列。
 */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .72);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;            /* 上下左右安全边距,保证能点到空白处关闭 */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
/* 沿用 style.css 既有的 opacity/visibility 显隐机制(保留淡入动画),
 * 这里只补充 padding / 滚动 / 安全边距,不改 display。 */

.vip-modal {
    background: var(--bg-surface, #1c1c1f);
    border-radius: 16px;
    width: 100%;
    max-width: 440px;
    max-height: calc(100vh - 48px);   /* 永远不顶满,上下各留 24px */
    overflow-y: auto;
    position: relative;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border, #2d2d33);
}
.vip-modal .modal-close {
    position: sticky;
    top: 0;
    float: right;
    margin: 10px 10px -10px 0;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, .35);
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    z-index: 2;
}
.vip-modal__top { padding: 20px 20px 8px; text-align: center; }
.vip-modal__top .vip-crown { font-size: 34px; }
.vip-modal__top h2 { font-size: 18px; font-weight: 800; color: var(--text, #fff); margin: 6px 0; }
.vip-modal__top p { font-size: 13px; color: var(--text-sec, #a1a1aa); line-height: 1.6; }
.vip-modal__body { padding: 0 16px 20px; }

/* 弹窗里的福利列表紧凑 */
.vip-modal .vip-benefits {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    justify-content: center;
    list-style: none;
    padding: 10px 0;
    margin: 0 0 8px;
}
.vip-modal .vip-benefit { font-size: 12px; color: var(--text-sec, #a1a1aa); }
.vip-modal .vip-benefit::before { content: "✓ "; color: var(--primary); font-weight: 700; }

.vip-modal__cta {
    display: block;
    text-align: center;
    background: linear-gradient(135deg, #FFD100, #FFA500);
    color: #1a1a1a;
    font-weight: 800;
    padding: 12px;
    border-radius: 12px;
    text-decoration: none;
    margin-top: 12px;
}
.vip-modal__note { text-align: center; font-size: 11px; color: var(--text-muted, #71717a); margin-top: 10px; }

/*
 * 手机端把 /vip/ 页 + 弹窗里的完整套餐卡(.mct-vip-product-grid)压成紧凑单列,
 * 不再每张卡占大半屏。保留全部文字,仅缩小留白和字号。
 */
@media (max-width: 720px) {
    .mct-vip-product-grid {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }
    .mct-vip-product {
        padding: 14px !important;
    }
    .mct-vip-product__price { font-size: 26px !important; }
    .mct-vip-product__benefits { margin: 8px 0 !important; }
    .mct-vip-product__benefits li { font-size: 12px !important; }
    /* 双支付按钮并排,省高度 */
    .mct-plan-pay-types {
        display: flex !important;
        gap: 8px !important;
    }
    .mct-plan-pay-types .mct-plan-buy {
        flex: 1 !important;
        text-align: center !important;
        padding: 10px 0 !important;
        font-size: 14px !important;
    }
    /* 弹窗在手机上几乎贴边但仍留可点关闭的边距 */
    .modal-overlay { padding: 16px 10px; }
    .vip-modal { max-height: calc(100vh - 32px); }
}

/* ============================ 支付成功 toast ============================ */
.mct-toast {
    position: fixed;
    left: 50%;
    bottom: 80px;
    transform: translateX(-50%) translateY(20px);
    background: #1c1c1f;
    color: #fff;
    border: 1px solid var(--primary);
    border-radius: 24px;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 8px 32px rgba(0, 0, 0, .4);
    z-index: 100000;
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s ease, transform .3s ease;
    max-width: 90vw;
    text-align: center;
}
.mct-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.mct-toast .mct-toast__icon { color: var(--primary); margin-right: 6px; }
