/* ==========================================
   AI纪元 · 文章统一视觉层
   仅负责文章共用外壳、排版节奏与交互状态；
   各篇专属图表、卡片和主题色仍由对应 CSS 维护。
   ========================================== */

body.article-page {
    --article-shell-max: 1320px;
    --article-reading-max: 920px;
    --article-hero-radius: 0 0 32px 32px;
    --article-section-gap: clamp(2.5rem, 5vw, 4.5rem);
    --article-hero-start: #0b1b1d;
    --article-hero-mid: #153739;
    --article-hero-end: #1a4241;
    --article-hero-glow-a: rgba(227, 167, 47, 0.18);
    --article-hero-glow-b: rgba(44, 157, 147, 0.2);
    --article-hero-accent: #79c9c0;
    background-color: var(--bg-base);
    color: var(--text-primary);
    text-rendering: optimizeLegibility;
}

/* 各篇只调整深色底的色相，结构与排版保持一致。 */
body.article-page[data-hero-tone="aurora"] {
    --article-hero-start: #0d1825;
    --article-hero-mid: #18344a;
    --article-hero-end: #245052;
    --article-hero-glow-a: rgba(117, 181, 220, 0.2);
    --article-hero-glow-b: rgba(81, 201, 177, 0.18);
    --article-hero-accent: #8bd6c9;
}

body.article-page[data-hero-tone="amber"] {
    --article-hero-start: #21150d;
    --article-hero-mid: #47301a;
    --article-hero-end: #5a3c1e;
    --article-hero-glow-a: rgba(242, 195, 91, 0.22);
    --article-hero-glow-b: rgba(202, 111, 61, 0.18);
    --article-hero-accent: #f2c35b;
}

body.article-page[data-hero-tone="blue"] {
    --article-hero-start: #0b1828;
    --article-hero-mid: #163a59;
    --article-hero-end: #20536c;
    --article-hero-glow-a: rgba(101, 174, 230, 0.22);
    --article-hero-glow-b: rgba(66, 196, 206, 0.18);
    --article-hero-accent: #8dcdf7;
}

body.article-page[data-hero-tone="violet"] {
    --article-hero-start: #171123;
    --article-hero-mid: #352653;
    --article-hero-end: #493764;
    --article-hero-glow-a: rgba(181, 143, 235, 0.22);
    --article-hero-glow-b: rgba(105, 159, 232, 0.16);
    --article-hero-accent: #c8aff2;
}

body.article-page[data-hero-tone="indigo"] {
    --article-hero-start: #10152b;
    --article-hero-mid: #242e59;
    --article-hero-end: #344370;
    --article-hero-glow-a: rgba(133, 151, 238, 0.22);
    --article-hero-glow-b: rgba(99, 192, 219, 0.16);
    --article-hero-accent: #aab9ff;
}

body.article-page[data-hero-tone="coral"] {
    --article-hero-start: #241113;
    --article-hero-mid: #4e282a;
    --article-hero-end: #63372f;
    --article-hero-glow-a: rgba(231, 137, 104, 0.22);
    --article-hero-glow-b: rgba(223, 184, 91, 0.16);
    --article-hero-accent: #f3b08e;
}

body.article-page[data-hero-tone="teal"] {
    --article-hero-start: #0b1c20;
    --article-hero-mid: #164047;
    --article-hero-end: #20575a;
    --article-hero-glow-a: rgba(72, 191, 184, 0.22);
    --article-hero-glow-b: rgba(91, 151, 221, 0.16);
    --article-hero-accent: #82d6ce;
}

body.article-page[data-hero-tone="magenta"] {
    --article-hero-start: #241022;
    --article-hero-mid: #512047;
    --article-hero-end: #6a3159;
    --article-hero-glow-a: rgba(229, 125, 194, 0.22);
    --article-hero-glow-b: rgba(153, 130, 235, 0.16);
    --article-hero-accent: #efabd5;
}

body.article-page[data-hero-tone="bronze"] {
    --article-hero-start: #24170f;
    --article-hero-mid: #503020;
    --article-hero-end: #674431;
    --article-hero-glow-a: rgba(219, 133, 85, 0.22);
    --article-hero-glow-b: rgba(230, 186, 111, 0.16);
    --article-hero-accent: #efb28f;
}

body.article-page[data-hero-tone="crimson"] {
    --article-hero-start: #250d13;
    --article-hero-mid: #531725;
    --article-hero-end: #6d2030;
    --article-hero-glow-a: rgba(234, 83, 105, 0.22);
    --article-hero-glow-b: rgba(151, 101, 211, 0.16);
    --article-hero-accent: #ff9aaa;
}

body.article-page[data-hero-tone="cobalt"] {
    --article-hero-start: #0f172d;
    --article-hero-mid: #1a345f;
    --article-hero-end: #274875;
    --article-hero-glow-a: rgba(105, 134, 235, 0.22);
    --article-hero-glow-b: rgba(74, 190, 215, 0.17);
    --article-hero-accent: #9dbdf7;
}

body.article-page[data-hero-tone="cyan"] {
    --article-hero-start: #0b1e22;
    --article-hero-mid: #154149;
    --article-hero-end: #1e575d;
    --article-hero-glow-a: rgba(76, 199, 205, 0.22);
    --article-hero-glow-b: rgba(94, 155, 224, 0.16);
    --article-hero-accent: #84d7d8;
}

body.article-page[data-hero-tone="navy"] {
    --article-hero-start: #0d1824;
    --article-hero-mid: #173746;
    --article-hero-end: #294b49;
    --article-hero-glow-a: rgba(229, 171, 72, 0.22);
    --article-hero-glow-b: rgba(59, 167, 155, 0.18);
    --article-hero-accent: #efc66c;
}

body.article-page[data-hero-tone="heritage"] {
    --article-hero-start: #161d19;
    --article-hero-mid: #304437;
    --article-hero-end: #4c5639;
    --article-hero-glow-a: rgba(232, 203, 132, 0.2);
    --article-hero-glow-b: rgba(116, 169, 137, 0.18);
    --article-hero-accent: #efd28b;
}

body.article-page .navbar {
    min-height: 58px;
    padding-block: 0.55rem;
    border-bottom-color: rgba(223, 216, 208, 0.85);
}

body.article-page .main-content {
    width: min(calc(100% - 2rem), var(--article-shell-max));
    padding: clamp(1.5rem, 3vw, 2.75rem) 0 clamp(3rem, 6vw, 5.5rem);
}

/* 首屏统一采用 part15 的深色杂志式 Hero：大标题、网格纹理与底部圆角。 */
body.article-page .article-header,
body.article-page .hero-section,
body.article-page .detail-hero {
    position: relative;
    overflow: hidden;
    isolation: isolate;
    margin: 0 auto var(--article-section-gap);
    padding: clamp(4.5rem, 8vw, 7.5rem) clamp(1.5rem, 5vw, 4rem);
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: var(--article-hero-radius);
    color: #f8f4e9;
    background:
        radial-gradient(circle at 78% 18%, var(--article-hero-glow-a), transparent 25%),
        radial-gradient(circle at 15% 84%, var(--article-hero-glow-b), transparent 29%),
        linear-gradient(135deg, var(--article-hero-start) 0%, var(--article-hero-mid) 56%, var(--article-hero-end) 100%);
    box-shadow: 0 24px 60px rgba(13, 31, 33, 0.18);
    text-align: center;
}

body.article-page .article-header::before,
body.article-page .hero-section::before,
body.article-page .detail-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    width: auto;
    height: auto;
    opacity: 0.16;
    border-radius: inherit;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.12) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.12) 1px, transparent 1px);
    background-size: 38px 38px;
    transform: none;
    mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.8), transparent 86%);
    -webkit-mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.8), transparent 86%);
}

body.article-page .hero-section::after {
    display: none;
}

body.article-page .article-title,
body.article-page .hero-title,
body.article-page .detail-hero-title {
    max-width: 980px;
    margin: 0.85rem auto 1rem;
    color: #fffdf7;
    font-family: 'Noto Serif SC', serif;
    font-size: clamp(2.5rem, 6vw, 5rem);
    font-weight: 700;
    line-height: 1.12;
    letter-spacing: -0.04em;
    text-wrap: balance;
    text-shadow: 0 8px 28px rgba(0, 0, 0, 0.16);
}

body.article-page .article-subtitle,
body.article-page .article-desc,
body.article-page .hero-desc,
body.article-page .detail-hero-subtitle {
    max-width: 820px;
    margin-inline: auto;
    color: rgba(248, 244, 233, 0.76);
    font-size: clamp(1rem, 2vw, 1.22rem);
    line-height: 1.8;
    text-wrap: pretty;
}

body.article-page :is(.article-header, .hero-section, .detail-hero)
:is(.article-number, .article-kicker, .hero-kicker, .hero-badge, .detail-hero-badge) {
    display: inline-flex;
    align-items: center;
    min-height: auto;
    margin: 0 0 1rem;
    padding: 0;
    border: 0;
    border-radius: 0;
    color: var(--article-hero-accent);
    background: transparent;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.16em;
}

body.article-page .article-meta {
    margin-top: 1.25rem;
    gap: 0.65rem 1rem;
    color: rgba(248, 244, 233, 0.7);
}

body.article-page .article-meta span {
    min-height: 30px;
    padding: 0.28rem 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 999px;
    color: rgba(248, 244, 233, 0.76);
    background: rgba(4, 17, 18, 0.28);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

body.article-page .detail-hero-year {
    margin-bottom: 0.35rem;
    color: var(--article-hero-accent);
    background: none;
    -webkit-text-fill-color: currentColor;
    text-shadow: 0 8px 28px rgba(0, 0, 0, 0.2);
}

body.article-page .detail-hero .hero-meta-row {
    gap: 0.65rem 1rem;
    color: rgba(248, 244, 233, 0.7);
}

body.article-page .detail-hero .meta-pair {
    align-items: center;
    padding: 0.42rem 0.78rem;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 999px;
    background: rgba(4, 17, 18, 0.28);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

body.article-page .detail-hero .meta-key,
body.article-page .detail-hero .meta-val {
    color: rgba(248, 244, 233, 0.76);
}

body.article-page .amc-hero .article-title span:last-child,
body.article-page .crypto-hero .article-title span {
    color: var(--article-hero-accent);
}

body.article-page .amc-hero .hero-thesis,
body.article-page .crypto-hero .hero-equation {
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(4, 17, 18, 0.32);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* 正文节奏 */
body.article-page .chapter-section,
body.article-page .detail-section {
    scroll-margin-top: 112px;
}

body.article-page .chapter-section {
    margin-bottom: var(--article-section-gap);
}

body.article-page .chapter-section > h2,
body.article-page .detail-section-title {
    line-height: 1.35;
    letter-spacing: -0.015em;
    text-wrap: balance;
}

body.article-page .chapter-section p,
body.article-page .chapter-section li,
body.article-page .detail-section p,
body.article-page .detail-section li {
    text-wrap: pretty;
}

body.article-page :where(.chapter-section, .detail-section) a:not(.nav-button):not(.toc-link) {
    text-underline-offset: 0.2em;
    text-decoration-thickness: 1px;
}

body.article-page :where(pre, .code-block, .terminal-window, .terminal-block) {
    max-width: 100%;
    border-radius: 14px;
}

body.article-page :where(img, svg, canvas, video) {
    max-width: 100%;
}

/* 统一结尾：收束语、上下篇、页脚 */
body.article-page .chapter-section:has(> .transition-block) {
    margin: clamp(2.5rem, 6vw, 5rem) 0 0;
}

body.article-page .transition-block {
    margin: 0;
    padding: clamp(1.5rem, 4vw, 2.5rem);
    border: 1px solid var(--border-subtle);
    border-radius: 18px;
    background:
        linear-gradient(135deg, hsl(var(--primary-hue) 72% 96% / 0.86), hsl(var(--accent-hue) 90% 96% / 0.82));
    box-shadow: var(--shadow-sm);
}

body.article-page .transition-block p {
    max-width: 780px;
    margin: 0 auto;
    font-size: clamp(0.98rem, 1.5vw, 1.08rem);
    line-height: 1.9;
}

body.article-page .article-nav {
    align-items: stretch;
    margin-top: clamp(2rem, 5vw, 4rem);
    padding: clamp(1.5rem, 4vw, 2.5rem) 0 0;
}

body.article-page .nav-button {
    min-height: 52px;
    max-width: min(48%, 460px);
    padding: 0.8rem 1.2rem;
    border-radius: 14px;
    line-height: 1.45;
}

body.article-page .footer {
    padding: 1.4rem 1rem;
    background: rgba(250, 248, 245, 0.9);
}

/* 目录按钮与导航的交互状态统一 */
body.article-page :where(a, button):focus-visible {
    outline: 3px solid hsl(var(--primary-hue) 75% 58% / 0.34);
    outline-offset: 3px;
}

body.article-page .toc-toggle-btn {
    top: 76px;
    border-radius: 12px;
}

body.article-page .toc-sidebar {
    border-radius: 0 18px 18px 0;
}

@media (max-width: 768px) {
    body.article-page {
        --article-hero-radius: 20px;
        --article-section-gap: 2.75rem;
    }

    body.article-page .navbar {
        min-height: 52px;
        padding: 0.45rem 0.65rem;
    }

    body.article-page .main-content {
        width: min(calc(100% - 1rem), var(--article-shell-max));
        padding-top: 1rem;
    }

    body.article-page .article-header,
    body.article-page .hero-section,
    body.article-page .detail-hero {
        margin-bottom: 2.5rem;
        padding: 2.5rem 1rem 2rem;
    }

    body.article-page .article-title,
    body.article-page .hero-title,
    body.article-page .detail-hero-title {
        font-size: clamp(1.75rem, 9vw, 2.4rem);
        line-height: 1.25;
    }

    body.article-page .article-subtitle,
    body.article-page .article-desc,
    body.article-page .hero-desc,
    body.article-page .detail-hero-subtitle {
        font-size: 0.94rem;
        line-height: 1.75;
    }

    body.article-page .article-meta {
        align-items: center;
    }

    body.article-page .article-meta span {
        width: fit-content;
        max-width: 100%;
    }

    body.article-page .comparison-table {
        display: block;
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        overscroll-behavior-inline: contain;
        -webkit-overflow-scrolling: touch;
    }

    body.article-page .ref-item .ref-title,
    body.article-page .ref-item .ref-detail {
        min-width: 0;
        overflow-wrap: anywhere;
    }

    body.article-page .ref-item .ref-title {
        flex: 1 1 100%;
    }

    body.article-page .level-ladder {
        justify-content: flex-start;
    }

    body.article-page .toc-toggle-btn {
        top: 64px;
        left: 8px;
    }

    body.article-page .article-nav {
        gap: 0.75rem;
    }

    body.article-page .nav-button {
        max-width: none;
        min-height: 48px;
    }
}

@media (prefers-reduced-motion: reduce) {
    body.article-page *,
    body.article-page *::before,
    body.article-page *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

@media print {
    body.article-page .article-header,
    body.article-page .hero-section,
    body.article-page .detail-hero,
    body.article-page .transition-block {
        box-shadow: none;
    }
}

body.article-page .footer-links {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    margin-top: 0.55rem;
}

body.article-page .footer-links a {
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-decoration: none;
}

body.article-page .footer-links a:hover {
    color: var(--primary);
}
