/* ==========================================================================
   数学之家 · 空间皮肤（练习 / 题库共用）
   --------------------------------------------------------------------------
   与站点 custom.css 同一套设计令牌：深空极光、玻璃拟物、大圆角、顶部高光。
   本文件在原 base.html 的基础样式之后加载，只覆盖视觉层，不改任何类名与结构，
   因此所有页面（含未单独调整的模板）会自动统一风格。
   ========================================================================== */

/* ---------- 1. 令牌：字体、圆角、缓动 ---------- */
:root {
    --mh-font:
        "HarmonyOS Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI",
        "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
        "Noto Sans CJK SC", "Source Han Sans SC", sans-serif;
    --mh-r-sm: 12px;
    --mh-r-md: 18px;
    --mh-r-lg: 26px;
    --mh-r-pill: 999px;
    --mh-ease: cubic-bezier(.2, .8, .2, 1);
    --mh-expo: cubic-bezier(.16, 1, .3, 1);
}

/* ---------- 2. 深空（暗色） ---------- */
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #07080f;
        --bg-2: #0a0c16;
        --card: rgba(255, 255, 255, .055);
        --surface-2: rgba(255, 255, 255, .085);
        --ink: #eaecf5;
        --sub: rgba(234, 236, 245, .66);
        --line: rgba(255, 255, 255, .09);
        --stroke-2: rgba(255, 255, 255, .17);
        --brand: #5b84ff;
        --brand-soft: rgba(91, 132, 255, .16);
        --panel: rgba(0, 0, 0, .18);
        --input: rgba(255, 255, 255, .06);
        --input-line: rgba(255, 255, 255, .12);
        --hdr: rgba(7, 8, 15, .62);
        --btn-gray: rgba(255, 255, 255, .08);
        --ring: rgba(91, 132, 255, .30);
        --rim: inset 0 1px 0 rgba(255, 255, 255, .10);
        --shadow-card: 0 26px 60px -34px rgba(0, 0, 0, .95);
        --glow-a: rgba(46, 75, 255, .30);
        --glow-b: rgba(139, 59, 255, .22);
        --glow-c: rgba(16, 184, 166, .16);
        --grid-line: rgba(255, 255, 255, .045);
        color-scheme: dark;
    }
}

/* ---------- 3. 晨雾（亮色） ---------- */
@media (prefers-color-scheme: light) {
    :root {
        --bg: #edf0f6;
        --bg-2: #f7f8fc;
        --card: rgba(255, 255, 255, .72);
        --surface-2: rgba(255, 255, 255, .90);
        --ink: #141827;
        --sub: rgba(20, 24, 39, .64);
        --line: rgba(22, 28, 48, .10);
        --stroke-2: rgba(22, 28, 48, .18);
        --brand: #3a63e8;
        --brand-soft: rgba(58, 99, 232, .10);
        --panel: rgba(255, 255, 255, .52);
        --input: rgba(255, 255, 255, .88);
        --input-line: rgba(22, 28, 48, .16);
        --hdr: rgba(255, 255, 255, .68);
        --btn-gray: rgba(20, 24, 39, .06);
        --ring: rgba(58, 99, 232, .22);
        --rim: inset 0 1px 0 rgba(255, 255, 255, .95);
        --shadow-card: 0 22px 50px -32px rgba(24, 32, 64, .38);
        --glow-a: rgba(143, 176, 255, .55);
        --glow-b: rgba(199, 168, 255, .45);
        --glow-c: rgba(143, 227, 214, .40);
        --grid-line: rgba(22, 28, 48, .05);
        color-scheme: light;
    }
}

/* ---------- 4. 底色：极光 + 网格 ---------- */
body {
    font: 15px/1.75 var(--mh-font);
    color: var(--ink);
    background-color: var(--bg);
    background-image:
        radial-gradient(1100px 640px at 10% -12%, var(--glow-a), transparent 68%),
        radial-gradient(900px 520px at 94% 2%, var(--glow-b), transparent 70%),
        radial-gradient(900px 640px at 50% 112%, var(--glow-c), transparent 68%),
        linear-gradient(var(--grid-line) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
    background-size: auto, auto, auto, 56px 56px, 56px 56px;
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

/* ---------- 5. 顶栏：玻璃条 ---------- */
body > header,
header {
    height: 60px;
    padding: 0 clamp(14px, 3vw, 28px);
    gap: 14px;
    background: var(--hdr);
    -webkit-backdrop-filter: blur(18px) saturate(160%);
    backdrop-filter: blur(18px) saturate(160%);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 12px 34px -28px rgba(0, 0, 0, .95);
}

header .logo {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: .2px;
    color: var(--ink);
}

header .who {
    color: var(--sub);
    font-size: 13px;
    padding: 2px 10px;
    border: 1px solid var(--line);
    border-radius: var(--mh-r-pill);
    background: var(--card);
}

header a {
    color: var(--sub);
    font-size: 14px;
    text-decoration: none;
    transition: color .16s var(--mh-ease);
}

header a:hover {
    color: var(--ink);
}

header .home {
    border: 1px solid var(--stroke-2);
    border-radius: var(--mh-r-pill);
    padding: 4px 13px;
    color: var(--ink);
    background: var(--card);
    transition: border-color .16s var(--mh-ease), background .16s var(--mh-ease), transform .16s var(--mh-ease);
}

header .home:hover {
    border-color: var(--brand);
    color: var(--ink);
    background: var(--surface-2);
    transform: translateY(-1px);
}

/* ---------- 6. 主区与卡片：玻璃拟物 ---------- */
main {
    margin: 26px auto 48px;
    padding: 0 clamp(14px, 3vw, 20px);
}

.card,
.qitem,
details,
.ansbox {
    position: relative;
    background: linear-gradient(180deg, var(--surface-2), var(--card));
    border: 1px solid var(--line);
    border-radius: var(--mh-r-md);
    box-shadow: var(--rim), var(--shadow-card);
    -webkit-backdrop-filter: blur(18px) saturate(150%);
    backdrop-filter: blur(18px) saturate(150%);
}

/* 列表项数量多（题库一页几十条），去掉毛玻璃，避免滚动掉帧 */
.qitem {
    background: var(--card);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    box-shadow: var(--rim), 0 18px 40px -34px rgba(0, 0, 0, .9);
}

.card {
    padding: 18px 22px;
    margin-bottom: 18px;
}

.qitem {
    padding: 16px 20px;
    margin: 12px 0;
}

details,
.ansbox {
    border: 1px dashed var(--stroke-2);
    background: var(--panel);
}

/* ---------- 7. 按钮 ---------- */
button,
.btn {
    border-radius: var(--mh-r-sm);
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: .2px;
    background: var(--brand);
    color: #fff;
    border: 0;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), 0 12px 26px -16px var(--brand);
    transition: transform .16s var(--mh-ease), filter .16s var(--mh-ease), box-shadow .16s var(--mh-ease);
}

button:hover,
.btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.06);
}

button:active,
.btn:active {
    transform: translateY(0);
    filter: brightness(.97);
}

.btn.gray,
.btn.ghost {
    box-shadow: none;
    font-weight: 400;
}

.btn.ghost:hover,
.btn.gray:hover {
    filter: none;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .10);
}

/* ---------- 8. 表单控件 ---------- */
input,
select,
textarea {
    border-radius: var(--mh-r-sm);
    border: 1px solid var(--input-line);
    background: var(--input);
    color: var(--ink);
    padding: 8px 12px;
    transition: border-color .16s var(--mh-ease), box-shadow .16s var(--mh-ease), background .16s var(--mh-ease);
}

input::placeholder,
textarea::placeholder {
    color: var(--sub);
    opacity: .8;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--ring);
}

/* ---------- 9. 标签、知识点、难度 ---------- */
.pill {
    border-radius: var(--mh-r-pill);
    padding: 1px 10px;
    line-height: 20px;
}

.kp,
.kp-link {
    border-radius: 6px;
}

.kp-link {
    transition: border-color .16s var(--mh-ease), background .16s var(--mh-ease);
}

.chiprow {
    gap: 7px;
    margin: 9px 0;
}

.chip {
    border-radius: var(--mh-r-pill);
    padding: 4px 13px;
    background: var(--card);
    border: 1px solid var(--line);
    transition: color .14s var(--mh-ease), border-color .14s var(--mh-ease),
        background .14s var(--mh-ease), transform .14s var(--mh-ease);
}

.chip:hover {
    border-color: var(--brand);
    color: var(--brand);
    transform: translateY(-1px);
}

.chip.active {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 10px 24px -14px var(--brand);
}

/* ---------- 10. 刷题区 ---------- */
.prac .stem {
    font-size: 16.5px;
    margin-top: 14px;
}

.pracbar {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.ansbox {
    margin-top: 16px;
    padding: 14px 18px;
}

.ans-lab {
    display: inline-block;
    padding: 1px 9px;
    border-radius: var(--mh-r-pill);
    background: var(--brand-soft);
    color: var(--brand);
    font-size: 12px;
    margin-bottom: 6px;
}

.kbd {
    border-radius: 6px;
    background: var(--card);
    border: 1px solid var(--line);
    border-bottom-width: 2px;
}

/* ---------- 11. 姓名入口（居中药丸卡） ---------- */
.gate {
    max-width: 460px;
    margin: clamp(36px, 9vh, 96px) auto;
    padding: 38px 34px 34px;
    text-align: center;
    background: linear-gradient(180deg, var(--surface-2), var(--card));
    border: 1px solid var(--line);
    border-radius: var(--mh-r-lg);
    box-shadow: var(--rim), var(--shadow-card);
    -webkit-backdrop-filter: blur(20px) saturate(150%);
    backdrop-filter: blur(20px) saturate(150%);
}

.gate h1 {
    font-size: 21px;
    font-weight: 600;
    letter-spacing: .3px;
    margin: 0 0 10px;
}

.gate .tip {
    color: var(--sub);
    margin: 0 0 24px;
}

.gate .inrow {
    gap: 10px;
}

.gate input {
    padding: 11px 14px;
    border-radius: var(--mh-r-sm);
}

.gate button {
    padding: 11px 22px;
    border-radius: var(--mh-r-sm);
}

/* ---------- 12. 表格与代码块 ---------- */
th,
td {
    border-bottom: 1px solid var(--line);
}

pre.md-out {
    background: var(--panel);
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: var(--mh-r-sm);
}

code {
    border-radius: 5px;
    padding: 1px 5px;
    background: var(--btn-gray);
}

/* ---------- 13. 入场动画 ---------- */
@keyframes mh-rise {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

main>* {
    animation: mh-rise .52s var(--mh-expo) both;
}

main>*:nth-child(2) {
    animation-delay: .06s;
}

main>*:nth-child(3) {
    animation-delay: .12s;
}

main>*:nth-child(n+4) {
    animation-delay: .16s;
}

@media (prefers-reduced-motion: reduce) {

    main>*,
    button,
    .btn,
    .chip {
        animation: none !important;
        transition: none !important;
    }
}

/* ---------- 14. 滚动条（暗色） ---------- */
@media (prefers-color-scheme: dark) {
    ::-webkit-scrollbar {
        width: 10px;
        height: 10px;
    }

    ::-webkit-scrollbar-track {
        background: transparent;
    }

    ::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, .14);
        border: 2px solid transparent;
        border-radius: 8px;
        background-clip: content-box;
    }

    ::-webkit-scrollbar-thumb:hover {
        background: rgba(255, 255, 255, .26);
        background-clip: content-box;
    }
}

/* ---------- 15. 小屏 ---------- */
@media (max-width: 640px) {
    body>header,
    header {
        height: 54px;
        gap: 10px;
    }

    header .logo {
        font-size: 15px;
    }

    main {
        margin-top: 18px;
    }

    .card {
        padding: 15px 16px;
        border-radius: var(--mh-r-sm);
    }

    .gate {
        padding: 28px 20px;
        border-radius: var(--mh-r-md);
    }
}

/* ---------- 16. 顶栏徽标（题库组卷篮计数） ---------- */
header .cart-badge {
    display: inline-block;
    margin-left: 3px;
    padding: 0 7px;
    border-radius: var(--mh-r-pill);
    background: var(--brand);
    color: #fff;
    font-size: 12px;
    line-height: 18px;
    vertical-align: 1px;
}
