/* ============================================================
   AI 教育 · 章节阅读页样式
   依赖 ai-education.css 的全部变量与基础样式
   ============================================================ */

/* page background slightly softer for long-form reading */
body.ae-reading {
    background: var(--ae-bg);
}

/* === breadcrumb nav === */
.ae-crumbs {
    background: rgba(251, 246, 238, 0.92);
    border-bottom: 1px solid var(--ae-line);
    padding: 14px 0;
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(14px) saturate(140%);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
}
[data-theme="dark"] .ae-crumbs {
    background: rgba(16, 10, 4, 0.88);
    border-bottom-color: rgba(232, 166, 91, 0.18);
}
[data-theme="dark"] .ae-crumbs a { color: var(--ae-ink-mute); }
[data-theme="dark"] .ae-crumbs a:hover { color: var(--ae-amber-deep); }
[data-theme="dark"] .ae-crumbs .sep { color: rgba(232, 166, 91, 0.28); }
[data-theme="dark"] .ae-crumbs .book { color: var(--ae-ink); }
[data-theme="dark"] .ae-crumbs .part { color: var(--ae-ink-mid); }
.ae-crumbs-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 32px;
    display: flex;
    align-items: center;
    gap: 18px;
    font-family: var(--ae-font-mono);
    font-size: 11px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ae-ink-mute);
}
.ae-crumbs a { color: var(--ae-ink-mute); transition: color .2s; }
.ae-crumbs a:hover { color: var(--ae-amber-deep); }
.ae-crumbs .sep { color: var(--ae-line-strong); }
.ae-crumbs .book {
    font-family: var(--ae-font-cn-serif);
    font-size: 13px;
    letter-spacing: 0.02em;
    text-transform: none;
    color: var(--ae-ink);
    font-weight: 600;
}
.ae-crumbs .part {
    font-family: var(--ae-font-cn);
    font-size: 12px;
    letter-spacing: 0;
    text-transform: none;
    color: var(--ae-ink-mid);
}
.ae-crumbs .nav-spacer { flex: 1; }
.ae-crumbs .nav-end {
    display: flex;
    gap: 16px;
    align-items: center;
    font-size: 11px;
}

/* === chapter hero === */
.ae-ch-hero {
    padding: 80px 0 56px;
    border-bottom: 1px solid var(--ae-line);
    background: linear-gradient(180deg, var(--ae-bg-soft) 0%, var(--ae-bg) 100%);
    position: relative;
    overflow: hidden;
}
.ae-ch-hero::after {
    content: '';
    position: absolute;
    right: -120px; top: 50%;
    transform: translateY(-50%);
    width: 320px; height: 320px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--ae-amber-soft) 0%, transparent 70%);
    opacity: 0.5;
    pointer-events: none;
}
.ae-ch-hero-inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 32px;
    position: relative;
    z-index: 1;
}
.ae-ch-hero-inner > * {
    max-width: 720px;
}
.ae-ch-hero .ch-meta {
    font-family: var(--ae-font-mono);
    font-size: 12px;
    letter-spacing: 0.2em;
    color: var(--ae-amber-deep);
    margin-bottom: 22px;
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}
.ae-ch-hero .ch-meta .part-tag {
    padding: 5px 12px;
    border-radius: 999px;
    background: rgba(232, 166, 91, 0.15);
    border: 1px solid rgba(232, 166, 91, 0.32);
    color: var(--ae-amber-deep);
    font-family: var(--ae-font-cn);
    font-size: 12px;
    letter-spacing: 0;
}
.ae-ch-hero .ch-meta .reading-time {
    color: var(--ae-ink-mute);
    font-family: var(--ae-font-cn);
    font-size: 13px;
    letter-spacing: 0;
}
.ae-ch-hero h1 {
    font-family: var(--ae-font-cn-serif);
    font-weight: 700;
    font-size: clamp(36px, 5vw, 56px);
    line-height: 1.18;
    color: var(--ae-ink);
    letter-spacing: -0.002em;
    margin-bottom: 18px;
}
.ae-ch-hero .ch-lead {
    font-family: var(--ae-font-cn-serif);
    font-size: 19px;
    line-height: 1.9;
    color: var(--ae-ink-mid);
    max-width: 700px;
}

/* === main reading layout === */
.ae-ch-main {
    display: grid;
    grid-template-columns: 1fr 240px;
    gap: 64px;
    max-width: 1180px;
    margin: 0 auto;
    padding: 64px 32px 80px;
    position: relative;
}
.ae-ch-content {
    max-width: 720px;
    min-width: 0;
}
.ae-ch-section {
    margin-bottom: 72px;
    scroll-margin-top: 80px;
}
.ae-ch-section:last-child { margin-bottom: 0; }
.ae-ch-section h2 {
    font-family: var(--ae-font-cn-serif);
    font-weight: 700;
    font-size: 30px;
    line-height: 1.4;
    color: var(--ae-ink);
    margin: 0 0 32px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--ae-amber);
    display: inline-block;
    max-width: 100%;
    letter-spacing: 0.01em;
}
.ae-ch-section h3 {
    font-family: var(--ae-font-cn-serif);
    font-weight: 600;
    font-size: 22px;
    color: var(--ae-ink);
    margin: 42px 0 18px;
    padding-left: 14px;
    border-left: 3px solid var(--ae-amber);
    line-height: 1.45;
}
.ae-ch-section h3:first-child {
    margin-top: 0;
}
/* Tighter spacing for content right after a paragraph that ends a thought */
.ae-ch-section p + h3 {
    margin-top: 38px;
}
.ae-ch-section p {
    font-family: var(--ae-font-cn-serif);
    font-weight: 400;
    font-size: 19px;
    line-height: 2.05;          /* 中文长文呼吸感：≥2.0 是甜区 */
    color: var(--ae-ink);
    margin: 0 0 30px;           /* 段距 = 字号 × 1.58，纸书出版常用 */
    letter-spacing: 0.01em;     /* 字间略松一点，更舒展 */
    /* Chinese typography */
    font-feature-settings: "halt" 1, "palt" 1;
    text-spacing: ideograph-alpha ideograph-numeric;
    hanging-punctuation: allow-end first;
    text-wrap: pretty;
}
/* First paragraph after H2 — let it breathe a bit more visually  */
.ae-ch-section h2 + p::first-letter {
    margin-right: 1px;
}
.ae-ch-section p strong {
    color: var(--ae-ink);
    font-weight: 600;
}

/* === golden-sentence highlighting (restrained) === */
/* Paragraph-level: a whole-paragraph key claim.
   Keep visual weight low — only the left rule + slight bump, no fill. */
.ae-ch-section p.hl-quote {
    font-family: var(--ae-font-cn-serif);
    font-weight: 600;
    font-size: 20.5px;
    line-height: 2.0;
    color: var(--ae-ink);
    border-left: 2.5px solid var(--ae-amber);
    padding: 8px 0 8px 24px;
    margin: 32px 0;
    background: none;
    letter-spacing: 0.01em;
}
[data-theme="dark"] .ae-ch-section p.hl-quote {
    color: var(--ae-cream);
}

/* Sentence-level: golden sentence within a normal paragraph.
   Subtle thin underline — not a yellow highlight bar. */
.ae-ch-section p strong.hl {
    font-family: var(--ae-font-cn-serif);
    font-weight: 600;
    color: var(--ae-ink);
    background: none;
    border-bottom: 1.5px solid rgba(232, 166, 91, 0.55);
    padding-bottom: 1px;
}
[data-theme="dark"] .ae-ch-section p strong.hl {
    color: var(--ae-cream);
    border-bottom-color: rgba(232, 166, 91, 0.7);
}

/* .bracket class kept for occasional manual use — but no longer auto-applied.
   Render subtly when present. */
.ae-ch-section .bracket {
    font-style: normal;
    color: inherit;
    font-weight: 500;
}
.ae-ch-section .footref {
    display: inline-block;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: rgba(232, 166, 91, 0.18);
    color: var(--ae-amber-deep);
    font-family: var(--ae-font-mono);
    font-size: 10px;
    text-align: center;
    line-height: 18px;
    margin: 0 2px;
    cursor: help;
    transition: background .2s;
    vertical-align: super;
    position: relative;
}
.ae-ch-section .footref:hover {
    background: var(--ae-amber-deep);
    color: var(--ae-cream);
}
.ae-ch-section .footref::after {
    content: attr(data-note);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    background: var(--ae-bg-deep);
    color: var(--ae-cream);
    font-family: var(--ae-font-cn);
    font-size: 12px;
    line-height: 1.55;
    letter-spacing: 0;
    text-align: left;
    padding: 10px 14px;
    border-radius: 8px;
    width: max(220px, min(280px, 70vw));
    box-shadow: 0 12px 32px -10px rgba(0,0,0,0.4);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s;
    z-index: 10;
    white-space: normal;
}
.ae-ch-section .footref:hover::after,
.ae-ch-section .footref:focus::after { opacity: 1; }
.ae-ch-section .footref:focus { outline: 2px solid var(--ae-amber-deep); outline-offset: 2px; }

/* === sticky chapter TOC sidebar === */
.ae-ch-toc {
    position: sticky;
    top: 80px;
    align-self: start;
    padding: 22px 0;
    border-left: 1px solid var(--ae-line);
    padding-left: 20px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
}
.ae-ch-toc .toc-label {
    font-family: var(--ae-font-mono);
    font-size: 10px;
    letter-spacing: 0.22em;
    color: var(--ae-ink-mute);
    text-transform: uppercase;
    margin-bottom: 14px;
    display: block;
}
.ae-ch-toc ol {
    list-style: none;
    margin: 0; padding: 0;
    counter-reset: section;
}
.ae-ch-toc li {
    counter-increment: section;
    margin-bottom: 10px;
}
.ae-ch-toc a {
    display: block;
    font-family: var(--ae-font-cn);
    font-size: 13px;
    line-height: 1.5;
    color: var(--ae-ink-mid);
    padding: 5px 0 5px 22px;
    position: relative;
    transition: color .2s;
}
.ae-ch-toc a::before {
    content: counter(section, decimal-leading-zero);
    position: absolute;
    left: 0; top: 5px;
    font-family: var(--ae-font-mono);
    font-size: 10px;
    color: var(--ae-ink-mute);
    letter-spacing: 0.1em;
}
.ae-ch-toc a:hover {
    color: var(--ae-amber-deep);
}
.ae-ch-toc a.is-active {
    color: var(--ae-amber-deep);
    font-weight: 600;
    background: rgba(232, 166, 91, 0.08);
    border-radius: 6px;
}
.ae-ch-toc a.is-active::before { color: var(--ae-amber-deep); font-weight: 600; }
[data-theme="dark"] .ae-ch-toc a.is-active {
    background: rgba(232, 166, 91, 0.12);
}

/* === chapter end cards (summary, thinking, next) === */
.ae-ch-end {
    max-width: 880px;
    margin: 0 auto;
    padding: 48px 32px 80px;
}
.ae-end-card {
    background: var(--ae-bg-soft);
    border: 1px solid var(--ae-line);
    border-radius: 22px;
    padding: 36px 36px 32px;
    margin-bottom: 24px;
}
.ae-end-card .label {
    font-family: var(--ae-font-mono);
    font-size: 11px;
    letter-spacing: 0.22em;
    color: var(--ae-amber-deep);
    margin-bottom: 8px;
    display: inline-flex; align-items: center; gap: 12px;
}
.ae-end-card .label::before {
    content: ''; width: 24px; height: 1px; background: var(--ae-amber-deep);
}
.ae-end-card h3 {
    font-family: var(--ae-font-cn-serif);
    font-weight: 600;
    font-size: 24px;
    color: var(--ae-ink);
    margin-bottom: 22px;
}
.ae-end-card ul, .ae-end-card ol {
    list-style: none;
    padding: 0; margin: 0;
}
.ae-end-card li {
    padding: 16px 0;
    border-bottom: 1px dashed var(--ae-line-strong);
    font-family: var(--ae-font-cn-serif);
    font-size: 17px;
    line-height: 1.85;
    color: var(--ae-ink);
    display: flex;
    gap: 16px;
    align-items: baseline;
}
.ae-end-card li:last-child { border-bottom: none; }
.ae-end-card li::before {
    content: '';
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--ae-amber);
    flex-shrink: 0;
    transform: translateY(8px);
}
.ae-end-card.thinking li::before {
    content: counter(q, decimal-leading-zero);
    width: 28px; height: auto;
    background: none;
    color: var(--ae-amber-deep);
    font-family: var(--ae-font-mono);
    font-size: 12px;
    font-weight: 500;
    transform: none;
    letter-spacing: 0.06em;
}
.ae-end-card.thinking ol { counter-reset: q; }
.ae-end-card.thinking li { counter-increment: q; }

.ae-end-card .key {
    font-family: var(--ae-font-mono);
    font-size: 10px;
    letter-spacing: 0.18em;
    color: var(--ae-amber-deep);
    padding: 3px 8px;
    background: rgba(232, 166, 91, 0.12);
    border-radius: 4px;
    flex-shrink: 0;
    margin-right: 8px;
    text-transform: uppercase;
}

/* === "读完了？转发给一位家长" CTA === */
.ae-ch-pass {
    margin-top: 36px;
    padding: 30px 32px;
    background: linear-gradient(135deg, rgba(232, 166, 91, 0.10), rgba(160, 85, 42, 0.06));
    border: 1px solid rgba(232, 166, 91, 0.34);
    border-radius: 20px;
    text-align: center;
}
.ae-ch-pass .lead {
    font-family: var(--ae-font-cn-serif);
    font-weight: 600;
    font-size: 22px;
    color: var(--ae-ink);
    line-height: 1.5;
    margin-bottom: 8px;
    letter-spacing: 0.005em;
}
.ae-ch-pass .lead em {
    font-style: normal;
    color: var(--ae-amber-deep);
}
.ae-ch-pass .desc {
    font-family: var(--ae-font-cn-serif);
    font-size: 15px;
    color: var(--ae-ink-mid);
    margin-bottom: 22px;
    line-height: 1.75;
}
.ae-ch-pass .pass-actions {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
}
.ae-ch-pass .pass-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 22px;
    border-radius: 999px;
    font-family: var(--ae-font-cn);
    font-size: 14px;
    cursor: pointer;
    border: 1.5px solid var(--ae-amber);
    background: transparent;
    color: var(--ae-ink);
    transition: all .25s;
}
.ae-ch-pass .pass-btn:hover {
    background: var(--ae-amber-deep);
    color: var(--ae-bg);
    border-color: var(--ae-amber-deep);
}
.ae-ch-pass .pass-btn.primary {
    background: var(--ae-amber-deep);
    color: var(--ae-bg);
    border-color: var(--ae-amber-deep);
}
.ae-ch-pass .pass-btn.primary:hover {
    background: var(--ae-ink);
    border-color: var(--ae-ink);
}
[data-theme="dark"] .ae-ch-pass {
    background: linear-gradient(135deg, rgba(232, 166, 91, 0.14), rgba(160, 85, 42, 0.08));
}
[data-theme="dark"] .ae-ch-pass .pass-btn.primary {
    background: var(--ae-amber-deep);
    color: var(--ae-bg-deep);
}

/* === prev / next chapter footer === */
.ae-ch-pn {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    margin-top: 32px;
}
.ae-ch-pn .pn {
    background: var(--ae-glass-strong);
    border: 1px solid var(--ae-line);
    border-radius: 18px;
    padding: 24px 26px;
    transition: all .25s;
    display: block;
}
.ae-ch-pn .pn:hover {
    border-color: var(--ae-amber);
    transform: translateY(-3px);
    box-shadow: var(--ae-shadow-card);
}
.ae-ch-pn .pn .dir {
    font-family: var(--ae-font-mono);
    font-size: 11px;
    letter-spacing: 0.18em;
    color: var(--ae-ink-mute);
    margin-bottom: 8px;
}
.ae-ch-pn .pn .num {
    font-family: var(--ae-font-mono);
    font-size: 11px;
    color: var(--ae-amber-deep);
    margin-bottom: 6px;
    letter-spacing: 0.16em;
}
.ae-ch-pn .pn .nm {
    font-family: var(--ae-font-cn-serif);
    font-weight: 600;
    font-size: 18px;
    color: var(--ae-ink);
    line-height: 1.4;
}
.ae-ch-pn .pn.next { text-align: right; }
.ae-ch-pn .pn.disabled { opacity: 0.35; pointer-events: none; }

/* === continue to AI section === */
.ae-ch-ask {
    margin-top: 32px;
    padding: 28px 32px;
    background: linear-gradient(135deg, rgba(232, 166, 91, 0.12), rgba(160, 85, 42, 0.08));
    border: 1px solid rgba(232, 166, 91, 0.4);
    border-radius: 18px;
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}
.ae-ch-ask .meta {
    flex: 1; min-width: 220px;
}
.ae-ch-ask .meta .l {
    font-family: var(--ae-font-mono);
    font-size: 11px;
    letter-spacing: 0.18em;
    color: var(--ae-amber-deep);
    margin-bottom: 6px;
}
.ae-ch-ask .meta .t {
    font-family: var(--ae-font-cn-serif);
    font-weight: 600;
    font-size: 17px;
    color: var(--ae-ink);
}
.ae-ch-ask .meta .d {
    font-size: 13px;
    color: var(--ae-ink-mid);
    margin-top: 4px;
    line-height: 1.5;
}
.ae-ch-ask .actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
    min-width: 280px;
}
.ae-ch-ask .actions .ae-ai-jumps { justify-content: flex-end; }
@media (max-width: 720px) {
    .ae-ch-ask .actions {
        align-items: flex-start;
        min-width: 0;
        width: 100%;
    }
    .ae-ch-ask .actions .ae-ai-jumps { justify-content: flex-start; }
}

/* === responsive === */
@media (max-width: 1024px) {
    .ae-ch-main {
        grid-template-columns: 1fr;
        gap: 40px;
        padding: 48px 24px 60px;
    }
    .ae-ch-toc {
        position: static;
        padding-left: 0;
        border-left: none;
        border-top: 1px solid var(--ae-line);
        padding-top: 22px;
        order: -1;
        max-height: none;
    }
    .ae-ch-toc ol {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }
}
@media (max-width: 640px) {
    .ae-crumbs-inner { padding: 0 16px; gap: 8px; font-size: 10px; flex-wrap: wrap; }
    .ae-crumbs .nav-end { gap: 8px; flex-wrap: wrap; }
    .ae-crumbs .part { display: none; }   /* drop part name on tiny screens */
    .ae-ch-hero { padding: 48px 0 36px; }
    .ae-ch-hero-inner { padding: 0 20px; }
    .ae-ch-hero h1 { font-size: 36px; line-height: 1.2; }
    .ae-ch-section p { font-size: 17.5px; line-height: 1.92; }
    .ae-ch-section h2 { font-size: 26px; }
    .ae-ch-section h3 { font-size: 20px; margin-top: 32px; }
    .ae-ch-section p.hl-quote { font-size: 18.5px; padding-left: 18px; margin: 22px 0; }
    .ae-ch-end { padding: 32px 20px 60px; }
    .ae-end-card { padding: 26px 22px 22px; }
    .ae-end-card li { font-size: 16px; padding: 14px 0; }
    .ae-ch-pn { grid-template-columns: 1fr; }
    .ae-ch-pn .pn.next { text-align: left; }
    .ae-ch-toc ol { grid-template-columns: 1fr; }
    .ae-ch-pass { padding: 24px 22px; }
    .ae-ch-pass .lead { font-size: 19px; }
    .ae-ch-pass .desc { font-size: 14px; }
    .ae-ch-ask { padding: 22px 20px; }
}
