/* 中国历史 · 朝代页共享样式
   每个朝代通过 body 上的 theme-* 类切换配色、纹理与细节 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    --serif: "Songti SC", "STSong", "SimSun", "Noto Serif CJK SC", serif;
    --radius: 12px;
    --panel: rgba(255, 255, 255, 0.04);
    --border: rgba(255, 255, 255, 0.09);
    min-height: 100vh;
    background-color: var(--bg);
    background-image: radial-gradient(1100px 560px at 50% -8%, var(--bg2), var(--bg) 62%);
    background-attachment: fixed;
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Microsoft YaHei", sans-serif;
    line-height: 1.8;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* 朝代纹理层 */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
}

.page {
    position: relative;
    z-index: 1;
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 clamp(20px, 5vw, 48px) 80px;
}

/* 顶部导航 */
.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px clamp(16px, 4vw, 28px);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 15px;
    font-size: 13.5px;
    color: var(--muted);
    text-decoration: none;
    border: 1px solid var(--border);
    border-radius: 999px;
    transition: color 0.3s ease, border-color 0.3s ease, background 0.3s ease;
}

.back:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--panel);
}

.crumb {
    font-size: 11.5px;
    letter-spacing: 0.2em;
    color: var(--muted);
    white-space: nowrap;
}

/* 封面 */
.hero {
    position: relative;
    padding: clamp(56px, 8vw, 104px) 0 clamp(36px, 5vw, 52px);
    border-bottom: 1px solid var(--border);
    overflow: hidden;
    animation: rise 0.9s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.watermark {
    position: absolute;
    top: -0.04em;
    right: -0.04em;
    font-family: var(--serif);
    font-size: clamp(200px, 32vw, 360px);
    line-height: 1;
    color: var(--ink);
    opacity: 0.045;
    pointer-events: none;
    user-select: none;
}

.kicker {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    font-size: 11.5px;
    letter-spacing: 0.26em;
    color: var(--accent);
}

.kicker::before {
    content: "";
    width: 30px;
    height: 1px;
    background: linear-gradient(90deg, var(--accent), transparent);
}

.hero h1 {
    position: relative;
    margin: 14px 0 2px;
    font-family: var(--serif);
    font-size: clamp(60px, 11vw, 118px);
    font-weight: 600;
    letter-spacing: 0.08em;
    line-height: 1.06;
}

.sub {
    position: relative;
    font-family: var(--serif);
    font-size: clamp(15px, 2vw, 19px);
    letter-spacing: 0.24em;
    color: var(--accent);
}

.lead {
    position: relative;
    max-width: 720px;
    margin-top: 24px;
    font-size: 15px;
    line-height: 2;
    color: var(--muted);
}

.facts {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 26px;
    list-style: none;
}

.facts li {
    padding: 7px 14px;
    font-size: 12.5px;
    color: var(--muted);
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.facts b {
    margin-right: 8px;
    font-weight: 600;
    color: var(--ink);
}

/* 章节 */
.section {
    padding-top: clamp(42px, 6vw, 64px);
    animation: rise 0.9s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.sec-head {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.sec-head h2 {
    flex-shrink: 0;
    font-family: var(--serif);
    font-size: clamp(19px, 2.3vw, 23px);
    font-weight: 600;
    letter-spacing: 0.18em;
}

.sec-head::after {
    content: "";
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, var(--border), transparent);
}

/* 大事记 */
.timeline {
    list-style: none;
    border-top: 1px solid var(--border);
}

.timeline li {
    display: grid;
    grid-template-columns: 104px minmax(0, 1fr);
    gap: 22px;
    padding: 17px 4px;
    border-bottom: 1px solid var(--border);
    transition: background 0.3s ease;
}

.timeline li:hover {
    background: linear-gradient(90deg, var(--panel), transparent);
}

.era {
    font-family: var(--serif);
    font-size: 14px;
    letter-spacing: 0.03em;
    color: var(--accent);
}

.timeline h3 {
    font-family: var(--serif);
    font-size: 16.5px;
    font-weight: 600;
    letter-spacing: 0.06em;
}

.timeline p {
    margin-top: 3px;
    font-size: 13.5px;
    line-height: 1.85;
    color: var(--muted);
}

/* 成就卡片 */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 16px;
}

.card {
    position: relative;
    padding: 22px 20px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.4s ease, box-shadow 0.4s ease;
}

.card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    opacity: 0;
    transition: opacity 0.4s ease;
}

.card:hover {
    transform: translateY(-5px);
    border-color: var(--accent);
    box-shadow: 0 16px 34px rgba(0, 0, 0, 0.28);
}

.card:hover::before {
    opacity: 0.9;
}

.card h3 {
    font-family: var(--serif);
    font-size: 16.5px;
    font-weight: 600;
    letter-spacing: 0.06em;
}

.card p {
    margin-top: 8px;
    font-size: 13.5px;
    line-height: 1.85;
    color: var(--muted);
}

/* 人物标签 */
.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    list-style: none;
}

.tags li {
    padding: 6px 15px;
    font-size: 13px;
    color: var(--muted);
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 999px;
    transition: color 0.3s ease, border-color 0.3s ease;
}

.tags li:hover {
    color: var(--accent);
    border-color: var(--accent);
}

/* 页尾 */
.end {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-top: 70px;
    padding-top: 22px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    letter-spacing: 0.16em;
    color: var(--muted);
}

.end a {
    color: var(--accent);
    text-decoration: none;
}

.end a:hover {
    text-decoration: underline;
}

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 640px) {
    .crumb {
        display: none;
    }

    .timeline li {
        grid-template-columns: 74px minmax(0, 1fr);
        gap: 12px;
    }

    .end {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
    }
}

/* ============ 朝代主题 ============ */

/* 夏 · 陶土与水 */
body.theme-xia {
    --bg: #1b1611;
    --bg2: #2b2218;
    --ink: #f2e7d5;
    --muted: #b8a88f;
    --accent: #b0793f;
    --panel: rgba(176, 121, 63, 0.07);
    --border: rgba(176, 121, 63, 0.24);
}
body.theme-xia::before {
    background-image: repeating-radial-gradient(circle at 50% 115%, rgba(176, 121, 63, 0.10) 0 1px, transparent 1px 28px);
}

/* 商 · 甲骨与青铜 */
body.theme-shang {
    --bg: #111814;
    --bg2: #1d2a22;
    --ink: #ece4d3;
    --muted: #a3b0a2;
    --accent: #b08d57;
    --panel: rgba(176, 141, 87, 0.06);
    --border: rgba(176, 141, 87, 0.22);
}
body.theme-shang::before {
    background-image:
        repeating-linear-gradient(0deg, rgba(176, 141, 87, 0.06) 0 1px, transparent 1px 84px),
        repeating-linear-gradient(90deg, rgba(176, 141, 87, 0.06) 0 1px, transparent 1px 84px);
}

/* 周 · 礼乐与铭文 */
body.theme-zhou {
    --bg: #1e1414;
    --bg2: #2d1d19;
    --ink: #f1e5d2;
    --muted: #bda893;
    --accent: #b3543f;
    --panel: rgba(179, 84, 63, 0.07);
    --border: rgba(179, 84, 63, 0.24);
}
body.theme-zhou::before {
    background-image:
        repeating-linear-gradient(90deg, rgba(179, 84, 63, 0.07) 0 1px, transparent 1px 88px),
        repeating-linear-gradient(90deg, rgba(201, 160, 90, 0.05) 0 1px, transparent 1px 24px);
}

/* 秦 · 玄黑与朱红 */
body.theme-qin {
    --bg: #0c0c0e;
    --bg2: #17171b;
    --ink: #f0efe9;
    --muted: #9b9b96;
    --accent: #b5372f;
    --panel: rgba(181, 55, 47, 0.06);
    --border: rgba(181, 55, 47, 0.24);
    --radius: 2px;
}
body.theme-qin::before {
    background-image:
        repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.045) 0 1px, transparent 1px 64px),
        repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.045) 0 1px, transparent 1px 128px);
}
body.theme-qin .hero h1 {
    font-weight: 700;
    letter-spacing: 0.22em;
}

/* 汉 · 绛红与织锦 */
body.theme-han {
    --bg: #1a0f11;
    --bg2: #2b1618;
    --ink: #f4e8d8;
    --muted: #c0a99b;
    --accent: #b03a34;
    --panel: rgba(176, 58, 52, 0.07);
    --border: rgba(207, 162, 92, 0.22);
}
body.theme-han::before {
    background-image:
        radial-gradient(circle at 12% 18%, rgba(176, 58, 52, 0.12), transparent 28%),
        radial-gradient(circle at 84% 66%, rgba(207, 162, 92, 0.09), transparent 30%),
        repeating-linear-gradient(0deg, rgba(207, 162, 92, 0.04) 0 1px, transparent 1px 40px);
}

/* 魏晋南北朝 · 青瓷与竹林 */
body.theme-weijin {
    --bg: #131a19;
    --bg2: #1f2c29;
    --ink: #eef1e8;
    --muted: #a7b5ac;
    --accent: #7fa78f;
    --panel: rgba(127, 167, 143, 0.07);
    --border: rgba(127, 167, 143, 0.24);
}
body.theme-weijin::before {
    background-image:
        repeating-linear-gradient(88deg, rgba(127, 167, 143, 0.08) 0 2px, transparent 2px 36px),
        repeating-linear-gradient(92deg, rgba(127, 167, 143, 0.05) 0 1px, transparent 1px 62px);
}
body.theme-weijin .hero h1 {
    letter-spacing: 0.12em;
}

/* 隋 · 运河与石白 */
body.theme-sui {
    --bg: #0e1921;
    --bg2: #162a36;
    --ink: #e9f1f2;
    --muted: #9fb2ba;
    --accent: #5c99b0;
    --panel: rgba(92, 153, 176, 0.07);
    --border: rgba(92, 153, 176, 0.24);
}
body.theme-sui::before {
    background-image:
        repeating-linear-gradient(118deg, rgba(92, 153, 176, 0.08) 0 1px, transparent 1px 24px),
        repeating-linear-gradient(62deg, rgba(92, 153, 176, 0.05) 0 1px, transparent 1px 34px);
}

/* 唐 · 三彩与牡丹 */
body.theme-tang {
    --bg: #1d130d;
    --bg2: #332114;
    --ink: #f8ecd6;
    --muted: #c9b394;
    --accent: #d9a441;
    --panel: rgba(217, 164, 65, 0.08);
    --border: rgba(217, 164, 65, 0.26);
}
body.theme-tang::before {
    background-image:
        radial-gradient(circle at 80% 4%, rgba(217, 164, 65, 0.18), transparent 42%),
        radial-gradient(circle at 4% 82%, rgba(184, 68, 58, 0.14), transparent 40%),
        radial-gradient(circle at 60% 60%, rgba(93, 138, 134, 0.08), transparent 46%);
}
body.theme-tang .hero h1 {
    background: linear-gradient(180deg, #fdf3dc 18%, #d9a441 120%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* 宋 · 天青与留白 */
body.theme-song {
    --bg: #eef1ec;
    --bg2: #e6ebe5;
    --ink: #243029;
    --muted: #5f6f67;
    --accent: #3f7f79;
    --panel: rgba(255, 255, 255, 0.62);
    --border: rgba(36, 48, 41, 0.14);
    --radius: 10px;
}
body.theme-song::before {
    background-image:
        repeating-linear-gradient(0deg, rgba(36, 48, 41, 0.03) 0 1px, transparent 1px 34px),
        radial-gradient(circle at 88% 8%, rgba(63, 127, 121, 0.10), transparent 36%);
}
body.theme-song .watermark {
    opacity: 0.06;
}
body.theme-song .hero h1 {
    font-weight: 300;
    letter-spacing: 0.14em;
}
body.theme-song .card:hover {
    box-shadow: 0 14px 30px rgba(36, 48, 41, 0.12);
}

/* 元 · 青花与草原 */
body.theme-yuan {
    --bg: #0e1927;
    --bg2: #172a42;
    --ink: #e9eef5;
    --muted: #a3b2c6;
    --accent: #6f95c6;
    --panel: rgba(111, 149, 198, 0.07);
    --border: rgba(111, 149, 198, 0.24);
}
body.theme-yuan::before {
    background-image:
        radial-gradient(circle at 12% 16%, rgba(111, 149, 198, 0.14) 0 2px, transparent 3px),
        radial-gradient(circle at 68% 42%, rgba(217, 211, 196, 0.10) 0 1.5px, transparent 3px),
        radial-gradient(circle at 34% 78%, rgba(111, 149, 198, 0.10) 0 2px, transparent 3px);
    background-size: 120px 120px, 160px 160px, 200px 200px;
}

/* 清 · 宫廷与琉璃 */
body.theme-qing {
    --bg: #221012;
    --bg2: #35181b;
    --ink: #f7ead6;
    --muted: #c5a99c;
    --accent: #c8a24a;
    --panel: rgba(200, 162, 74, 0.07);
    --border: rgba(200, 162, 74, 0.24);
}
body.theme-qing::before {
    background-image:
        repeating-linear-gradient(45deg, rgba(200, 162, 74, 0.07) 0 1px, transparent 1px 20px),
        repeating-linear-gradient(-45deg, rgba(158, 47, 44, 0.07) 0 1px, transparent 1px 20px);
}
body.theme-qing .hero h1 {
    background: linear-gradient(180deg, #fdf1d6 20%, #c8a24a 120%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
