/* ========================================
   Mojimoji World - 文章內容排版
   ======================================== */

/* 主內容區域 */
.site-main {
    flex: 1;
    background: var(--paper);
    padding-bottom: var(--space-4);
}

/* 文章容器 */
.content-article {
    background: var(--paper);
    max-width: var(--content-width);
    padding: 0;
    border-radius: 0;
    box-shadow: none;
}

/* 文章標題區 */
.article-header {
    margin-bottom: var(--space-4);
}

.article-header h1 {
    font-family: var(--font-serif);
    font-size: var(--text-2xl);
    font-weight: 700;
    line-height: var(--leading-tight);
    color: var(--ink);
    margin-top: var(--space-4);
    margin-bottom: var(--space-4);
    /* 中文標題優化 */
    text-wrap: balance;
}

.article-meta {
    font-size: var(--text-sm);
    color: var(--ink-muted);
}

/* 文章內容基礎 - 中文優化排版 */
.article-content {
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    color: var(--ink);
    /* 左對齊，更自然的閱讀體驗 */
    text-align: left;
}

/* 段落 - 使用 em 單位讓間距隨字體縮放 */
.article-content p {
    margin-bottom: 1.5em;
}

/* 標題層級 */
.article-content h1 {
    font-family: var(--font-serif);
    font-size: var(--text-3xl);
    font-weight: 700;
    margin-top: 2em;
    margin-bottom: 0.75em;
    line-height: var(--leading-tight);
}

.article-content h2 {
    font-family: var(--font-serif);
    font-size: var(--text-2xl);
    font-weight: 700;
    margin-top: 1.75em;
    margin-bottom: 0.75em;
    line-height: var(--leading-snug);
}

.article-content h3 {
    font-family: var(--font-sans);
    font-size: var(--text-xl);
    font-weight: 600;
    margin-top: var(--space-5);
    margin-bottom: var(--space-3);
    line-height: var(--leading-snug);
    color: var(--ink);
}

.article-content h4 {
    font-family: var(--font-sans);
    font-size: var(--text-lg);
    font-weight: 600;
    margin-top: var(--space-4);
    margin-bottom: var(--space-2);
    color: var(--ink-light);
}

.article-content > h1:first-child,
.article-content > h2:first-child {
    margin-top: 0;
}

/* 標題錨點連結 - 預設隱藏 */
.article-content .heading-anchor {
    color: var(--ink-faint);
    text-decoration: none;
    margin-left: var(--space-2);
    font-size: 0.75em;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s, visibility 0.15s;
}

.article-content h1:hover .heading-anchor,
.article-content h2:hover .heading-anchor,
.article-content h3:hover .heading-anchor,
.article-content h4:hover .heading-anchor,
.article-content h5:hover .heading-anchor,
.article-content h6:hover .heading-anchor {
    opacity: 1;
    visibility: visible;
}

/* 連結 */
.article-content a:not(.heading-anchor) {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: color 0.15s;
}

.article-content a:not(.heading-anchor):hover {
    color: var(--accent-hover);
}

/* 列表 */
.article-content ul,
.article-content ol {
    margin-bottom: var(--space-4);
    padding-left: var(--space-4);
}

.article-content li {
    margin-bottom: var(--space-2);
    padding-left: var(--space-1);
}

.article-content li::marker {
    color: var(--ink-muted);
}

/* 引言 */
.article-content blockquote {
    margin: var(--space-5) 0;
    padding: 0;
    padding-left: var(--space-4);
    border-left: 3px solid var(--rule-dark);
    font-family: var(--font-serif);
    font-size: var(--text-lg);
    font-style: italic;
    color: var(--text-em-color);
    line-height: var(--leading-relaxed);
}

.article-content blockquote p:last-child {
    margin-bottom: 0;
}

/* 程式碼 */
.article-content code {
    font-family: 'Fira Code', 'SF Mono', Consolas, monospace;
    font-size: 0.9em;
    background: var(--paper-muted);
    padding: 0.15em 0.4em;
    border-radius: var(--radius-sm);
    color: var(--ink);
}

.article-content pre {
    margin: var(--space-4) 0;
    padding: var(--space-4);
    background: var(--code-block-bg);
    border-radius: var(--radius-md);
    overflow-x: auto;
}

.article-content pre code {
    background: transparent;
    padding: 0;
    color: var(--code-block-ink);
}

/* 表格 */
.article-content table {
    width: 100%;
    margin: var(--space-4) 0;
    border-collapse: collapse;
    font-size: var(--text-base);
}

.article-content th {
    text-align: left;
    font-weight: 600;
    padding: var(--space-2) var(--space-3);
    border-bottom: 2px solid var(--rule-dark);
    color: var(--ink);
}

/* 首欄多為短標籤，避免在窄螢幕被擠成直排 */
.article-content th:first-child,
.article-content td:first-child {
    min-width: 5.5em;
}

.article-content td {
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid var(--rule);
    color: var(--ink-light);
}

.article-content tr:last-child td {
    border-bottom: none;
}

/* 圖片 */
.article-content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    margin: var(--space-3) 0;
}

.article-content figure {
    margin: var(--space-5) 0;
}

.article-content figure img {
    display: block;
}

.article-content figcaption {
    font-size: var(--text-sm);
    color: var(--ink-muted);
    text-align: center;
    margin-top: var(--space-2);
}

/* 分隔線 */
.article-content hr {
    border: none;
    text-align: center;
    margin: var(--space-6) 0;
}

.article-content hr::before {
    content: '• • •';
    color: var(--ink-muted);
    letter-spacing: 1em;
}

/* 目錄 */
.table-of-contents {
    font-size: var(--text-sm);
    background: var(--paper-warm);
    padding: var(--space-4);
    margin: var(--space-4) 0;
    border-radius: var(--radius-md);
}

.table-of-contents::before {
    content: '目錄';
    display: block;
    font-weight: 600;
    margin-bottom: var(--space-2);
    color: var(--ink);
}

.table-of-contents ul {
    margin-bottom: 0;
    padding-left: var(--space-3);
}

.table-of-contents li {
    margin-bottom: var(--space-1);
}

.table-of-contents a {
    color: var(--ink-light);
    text-decoration: none;
}

.table-of-contents a:hover {
    color: var(--ink);
}

@media (max-width: 767.98px) {
    .article-header {
        margin-bottom: var(--space-3);
    }

    .article-header h1 {
        margin-top: var(--space-3);
        margin-bottom: var(--space-2);
    }

    .article-content h2 {
        font-size: 1.25rem;
    }
}
