/* Article Page Specific Styles */

.container {
    grid-template-columns: 2fr 7fr 1fr;
    align-items: start;
    padding-bottom: 0;
}

/* 页面特定样式 */
.article-sidebar-left, .article-sidebar-right {
    position: sticky;
    top: 7rem;
    height: calc(100vh - 9rem);
    overflow-y: auto;
    padding-bottom: 3rem;
}

.article-sidebar-left {
    padding-right: 1rem;
}

.article-sidebar-right {
    padding-left: 0;
}

.article-content {
    padding: 0 2rem 4rem 2rem;
    border-left: 1px solid rgba(23, 34, 63, 0.3);
}

/* 左侧文章列表样式 */
.article-list {
    list-style: none;
}

.article-list li {
    margin-bottom: 1rem;
}

.article-list a {
    text-decoration: none;
    color: #17223F;
    font-size: 1rem;
    transition: color 0.3s;
    display: block;
    padding: 0.5rem;
    border-radius: 4px;
}

.article-list a:hover, .article-list a.active {
    color: #447593;
    background-color: rgba(68, 117, 147, 0.1);
}

.section-title {
    font-size: 1.2rem;
    color: #447593;
    margin-bottom: 1.5rem;
    font-weight: 900;
    border-bottom: 2px solid #447593;
    padding-bottom: 0.5rem;
}

/* 侧边栏头部布局 */
.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    padding-bottom: 0;
    border-bottom: none;
    position: relative;
    height: 1.5rem;
}

.article-sidebar-right .section-title {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
    line-height: 1.5rem;
}

/* 进度条/返回顶部按钮样式 */
.progress-container {
    cursor: pointer;
    font-size: 0.9rem;
    color: #447593;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    opacity: 0;
    pointer-events: none;
    background-color: rgba(68, 117, 147, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    min-width: 32px;
    box-sizing: border-box;
}

.progress-container.show-rocket {
    padding: 2px 10px;
}

.progress-container.visible {
    opacity: 1;
    pointer-events: auto;
}

.progress-container:hover {
    color: #17223F;
    background-color: rgba(68, 117, 147, 0.2);
}

#rocket-icon {
    font-size: 1rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
}

#rocket-icon svg {
    width: 1em;
    height: 1em;
    fill: currentColor;
}

/* Article Hero/Cover Styles */
.article-hero {
    position: relative;
    width: 100%;
    height: 400px;
    border-radius: 0;
    overflow: hidden;
    margin-bottom: 2rem;
}

.article-content .article-hero {
    margin-left: -2rem;
    margin-right: -2rem;
    width: calc(100% + 4rem);
}

.article-hero .article-cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
    margin-bottom: 0;
    border-radius: 0;
    display: block;
}

.article-hero .hero-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: linear-gradient(to top, rgba(242, 236, 224, 1) 0%, rgba(242, 236, 224, 0.9) 30%, rgba(242, 236, 224, 0.6) 60%, rgba(242, 236, 224, 0) 100%);
    padding: 6rem 2rem 2rem;
    color: #17223F;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    box-sizing: border-box;
}

.article-hero .article-title {
    color: #17223F;
    margin-bottom: 0.8rem;
    text-shadow: none;
    font-size: 2.8rem;
    line-height: 1.2;
}

.article-hero .article-meta {
    color: #666;
    border-bottom: 1px solid rgba(23, 34, 63, 0.15);
    padding-bottom: 1rem;
    margin-bottom: 0;
    font-size: 1rem;
    text-shadow: none;
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 100%;
}

.article-hero .article-meta span {
    display: inline-flex;
    align-items: center;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .article-hero {
        height: 300px;
        border-radius: 0;
    }
    
    .article-content .article-hero {
        margin-left: -2rem;
        margin-right: -2rem;
        width: calc(100% + 4rem);
    }
    
    .article-hero .article-title {
        font-size: 1.8rem;
    }
    
    .article-hero .hero-overlay {
        padding: 3rem 2rem 1.5rem;
    }
}

/* No Cover Header Styles */
.article-header-no-cover .article-title {
    color: #333;
    margin-bottom: 0.5rem;
    font-size: 2.2rem;
    font-weight: 900;
}

.article-header-no-cover .article-meta {
    color: #666;
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid rgba(23, 34, 63, 0.15);
    padding-bottom: 1rem;
    width: 100%;
}

/* Standard Article Body Content Styles (override if needed) */
.article-body p {
    line-height: 1.8;
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
    text-align: justify;
}

/* 标题滚动偏移（防止被 Header 遮挡） */
.article-body h1,
.article-body h2,
.article-body h3,
.article-body h4,
.article-body h5,
.article-body h6 {
    scroll-margin-top: 6rem;
}

.article-body h1 {
    font-size: 2.2rem;
    color: #17223F;
    margin-top: 3rem;
    margin-bottom: 1.5rem;
    font-weight: 900;
}

.article-body h2 {
    font-size: 1.8rem;
    color: #17223F;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    font-weight: 900;
}

.article-body h3 {
    font-size: 1.4rem;
    color: #17223F;
    margin-top: 2rem;
    margin-bottom: 0.8rem;
    font-weight: 900;
}

.article-body h4 {
    font-size: 1.2rem;
    color: #17223F;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    font-weight: 900;
}

.article-body h5 {
    font-size: 1.1rem;
    color: #17223F;
    margin-top: 1.2rem;
    margin-bottom: 0.5rem;
    font-weight: 900;
}

.article-body h6 {
    font-size: 1rem;
    color: #17223F;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    font-weight: 900;
}

/* 目录样式 */
.toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.toc-list li {
    margin-bottom: 0.2rem;
    position: relative;
    line-height: 1.3;
}

.toc-list ul {
    list-style: none;
    padding-left: 0.8rem;
    margin-top: 0.2rem;
    display: none;
}

.toc-list li.open > ul {
    display: block;
}

.toc-list a {
    text-decoration: none;
    color: #666;
    font-size: 0.85rem;
    display: block;
    padding: 0.1rem 0.5rem;
    border-left: 2px solid transparent;
    transition: all 0.3s;
    position: relative;
}

.toc-list a:hover, .toc-list a.active {
    color: #447593;
    border-left-color: #447593;
}

/* 指示箭头 (如果有子菜单) */
.toc-arrow {
    position: absolute;
    right: 0;
    top: 0;
    width: 1rem;
    height: 1.2rem;
    cursor: pointer;
    color: #999;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s;
}

.toc-arrow:hover {
    color: #447593;
}

.toc-list li.open > .toc-arrow {
    transform: rotate(90deg);
}

/* 可折叠二级分类样式 */
.category-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.category-item {
    margin-bottom: 0.5rem;
}

.category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.5rem 0.5rem 0;
    cursor: pointer;
    font-weight: 900;
    color: #17223F;
    user-select: none;
    transition: color 0.3s;
}

.category-header:hover {
    color: #447593;
}

.category-icon {
    font-size: 0.8rem;
    transition: transform 0.3s ease;
    color: #447593;
    transform: rotate(0deg);
}

.category-item.open .category-icon {
    transform: rotate(90deg);
}

.category-sub-list {
    list-style: none;
    padding-left: 0.5rem;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out, opacity 0.3s ease-out;
    opacity: 0;
}

.category-item.open .category-sub-list {
    max-height: 500px;
    opacity: 1;
    transition: max-height 0.5s ease-in, opacity 0.3s ease-in;
}

.category-sub-list li {
    margin-bottom: 0.3rem;
}

.category-sub-list a {
    text-decoration: none;
    color: #555;
    font-size: 0.95rem;
    display: block;
    padding: 0.4rem 0.5rem;
    border-radius: 4px;
    transition: all 0.3s;
    border-left: 2px solid transparent;
}

.category-sub-list a:hover, .category-sub-list a.active {
    color: #447593;
    background-color: rgba(68, 117, 147, 0.1);
    border-left-color: #447593;
}

/* 手机端/平板适配 */
.header-left {
    display: flex;
    align-items: center;
}

@media (max-width: 1200px) {
    .container {
        grid-template-columns: 7.5fr 2.5fr;
        padding: 0 1.5rem;
        gap: 1.5rem;
    }

    .article-sidebar-left {
        position: absolute;
        width: 0;
        height: 0;
        overflow: visible;
        padding: 0;
        margin: 0;
        border: none;
    }

    .mobile-sidebar-toggle {
        display: flex;
        align-items: center;
        cursor: pointer;
        font-weight: bold;
        color: #17223F;
        padding: 0.5rem;
        border-radius: 4px;
        background: none;
        border: none;
        margin-left: 1rem;
    }
    
    .mobile-sidebar-toggle:hover {
        background-color: rgba(23, 34, 63, 0.05);
    }
    
    .mobile-sidebar-toggle .toggle-icon {
        font-size: 1.4rem;
        margin-right: 0.3rem;
    }
    
    .mobile-sidebar-toggle .toggle-text {
        font-size: 1rem;
    }

    .sidebar-inner {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(242, 236, 224, 0.98);
        z-index: 2000;
        padding: 4rem 2rem 2rem 2rem;
        overflow-y: auto;
        box-shadow: 0 0 10px rgba(0,0,0,0.1);
    }

    .sidebar-inner.active {
        display: block;
        animation: slideIn 0.3s ease-out;
    }
    
    @keyframes slideIn {
        from { transform: translateY(100%); opacity: 0; }
        to { transform: translateY(0); opacity: 1; }
    }

    .mobile-sidebar-close {
        display: block;
        position: absolute;
        top: 1.5rem;
        right: 2rem;
        font-size: 2rem;
        color: #999;
        cursor: pointer;
        line-height: 1;
        transition: color 0.3s;
    }

    .mobile-sidebar-close:hover {
        color: #17223F;
    }

    .article-sidebar-right {
        display: block;
        position: sticky;
        top: 7rem;
        height: fit-content;
        max-height: calc(100vh - 9rem);
        overflow-y: auto;
        padding-left: 1rem;
        border-left: 1px solid rgba(23, 34, 63, 0.1);
    }

    .article-content {
        padding: 0 1rem 0 0;
        border: none;
    }

    .article-content .article-hero {
        margin-left: -2rem;
        margin-right: -2rem;
        width: calc(100% + 4rem);
    }

    .progress-container-mobile {
        display: flex;
    }
}

@media (max-width: 900px) {
    .container {
        grid-template-columns: 1fr;
    }

    .article-sidebar-right {
        display: none;
    }

    .article-content {
        padding: 0;
    }

    .article-content .article-hero {
        margin-left: -2.5rem;
        margin-right: -2.5rem;
        width: calc(100% + 5rem);
    }
}

@media (max-width: 600px) {
    .container {
        padding: 0 0.3rem;
    }

    .article-content .article-hero {
        margin-left: -2rem;
        margin-right: -2rem;
        width: calc(100% + 4rem);
    }
}

@media (min-width: 1201px) {
    .mobile-sidebar-toggle {
        display: none;
    }
    
    .mobile-sidebar-close {
        display: none;
    }
    
    .sidebar-inner {
        display: block;
    }
}

/* --- Markdown 内容适配样式 --- */

/* 1. 引用块 (Blockquotes) */
.article-body blockquote {
    margin: 1.5rem 0;
    padding: 1rem 1.5rem;
    border-left: 4px solid #447593;
    background-color: rgba(68, 117, 147, 0.05);
    color: #555;
    font-style: italic;
    border-radius: 0 4px 4px 0;
}

.article-body blockquote p {
    margin-bottom: 0;
}

/* 2. 代码块 (Code Blocks) */
.article-body code {
    font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
    background-color: rgba(23, 34, 63, 0.06);
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-size: 0.9em;
    color: #c7254e;
}

.article-body pre {
    background-color: #f5f5f5;
    padding: 1rem;
    border-radius: 6px;
    margin: 1.5rem 0;
    border: 1px solid rgba(23, 34, 63, 0.1);
    position: relative;
    display: flex;
    align-items: flex-start;
    line-height: 1.5;
}

/* 复制按钮 */
.copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background-color: rgba(255, 255, 255, 0.8);
    border: 1px solid #d1d5da;
    border-radius: 4px;
    padding: 0.2rem 0.5rem;
    font-size: 0.8rem;
    color: #586069;
    cursor: pointer;
    transition: all 0.2s;
    opacity: 0;
    z-index: 10;
}

.article-body pre:hover .copy-btn {
    opacity: 1;
}

.copy-btn:hover {
    background-color: #fff;
    color: #447593;
    border-color: #447593;
}

.copy-btn.copied {
    background-color: #28a745;
    color: white;
    border-color: #28a745;
}

.article-body pre code {
    background-color: transparent;
    padding: 0;
    color: #333;
    flex-grow: 1;
    overflow-x: auto;
    white-space: pre;
    display: block;
    font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
    font-size: 0.9em;
    line-height: 1.5;
}

/* 代码块显示行数 */
.line-numbers {
    flex-shrink: 0;
    text-align: right;
    padding-right: 1rem;
    margin-right: 1rem;
    border-right: 1px solid #e0e0e0;
    color: #999;
    user-select: none;
    font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
    font-size: 0.9em;
    line-height: 1.5;
}

.line-numbers span {
    display: block;
    counter-increment: line-number;
    height: 1.5em;
}

/* 3. 图片 (Images) */
.article-body img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    display: block;
    margin: 1.5rem auto;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* 4. 列表 (Lists) */
.article-body ul, .article-body ol {
    padding-left: 2rem;
    margin-bottom: 1.5rem;
}

.article-body li {
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

/* 5. 链接 (Links) */
.article-body a {
    color: #447593;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.3s;
}

.article-body a:hover {
    border-bottom-color: #447593;
}

/* 6. 水平线 (Horizontal Rule) */
.article-body hr {
    border: 0;
    height: 1px;
    background-image: linear-gradient(to right, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0));
    margin: 2rem 0;
}

/* 7. 表格 (Tables) */
.article-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: 0.95rem;
}

.article-body th, .article-body td {
    padding: 0.8rem;
    border: 1px solid #e0e0e0;
    text-align: left;
}

.article-body th {
    font-weight: bold;
    color: #17223F;
    border-bottom: 2px solid #e0e0e0;
    background-color: transparent;
}

.article-body tr:nth-child(even) {
    background-color: transparent;
}

.article-body tr:hover {
    background-color: transparent;
}

.progress-container-mobile {
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: bold;
    color: #447593;
    margin-left: 1rem;
    padding: 4px 8px;
    border-radius: 4px;
    background-color: rgba(68, 117, 147, 0.1);
    transition: all 0.3s ease;
    opacity: 0;
    pointer-events: none;
}

.progress-container-mobile.visible {
    opacity: 1;
    pointer-events: auto;
}

.progress-container-mobile:hover {
    background-color: rgba(68, 117, 147, 0.2);
}

.progress-container-mobile #rocket-icon-mobile {
    display: flex;
    align-items: center;
}

.progress-container-mobile #rocket-icon-mobile svg {
    width: 1.2rem;
    height: 1.2rem;
    fill: currentColor;
}

@media (max-width: 800px) {
    .progress-container-mobile {
        display: flex;
    }
}

/* --- Callout / Highlight Blocks --- */
.callout {
    padding: 1rem 1.5rem;
    margin: 1.5rem 0;
    border-left: 4px solid #ddd;
    background-color: #f9f9f9;
    border-radius: 0 4px 4px 0;
    color: #555;
    position: relative;
    font-size: 1rem;
    line-height: 1.6;
}

.callout p:last-child {
    margin-bottom: 0;
}

/* Tips: Gray */
.callout.tips {
    border-left-color: #9e9e9e;
    background-color: rgba(158, 158, 158, 0.1);
    color: #616161;
}

/* Danger: Red */
.callout.danger {
    border-left-color: #f44336;
    background-color: rgba(244, 67, 54, 0.1);
    color: #d32f2f;
}

/* Color3: Orange */
.callout.color3 {
    border-left-color: #ff9800;
    background-color: rgba(255, 152, 0, 0.1);
    color: #ef6c00;
}

/* Warning: Yellow (Adjusted to Golden/Amber) */
.callout.warning {
    border-left-color: #fbc02d;
    background-color: rgba(251, 192, 45, 0.1);
    color: #f57f17;
}

/* Success: Grass Green */
.callout.success {
    border-left-color: #8bc34a;
    background-color: rgba(139, 195, 74, 0.1);
    color: #689f38;
}

/* Color2: Green */
.callout.color2 {
    border-left-color: #4caf50;
    background-color: rgba(76, 175, 80, 0.1);
    color: #388e3c;
}

/* Color1: Cyan */
.callout.color1 {
    border-left-color: #00bcd4;
    background-color: rgba(0, 188, 212, 0.1);
    color: #0097a7;
}

/* Info: Blue */
.callout.info {
    border-left-color: #2196f3;
    background-color: rgba(33, 150, 243, 0.1);
    color: #1976d2;
}

/* Color5: Purple */
.callout.color5 {
    border-left-color: #9c27b0;
    background-color: rgba(156, 39, 176, 0.1);
    color: #7b1fa2;
}

/* Color4: Pink */
.callout.color4 {
    border-left-color: #e91e63;
    background-color: rgba(233, 30, 99, 0.1);
    color: #c2185b;
}

/* --- Details / Collapsible Blocks --- */
.article-body details {
    margin: 1.5rem 0;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    background-color: transparent;
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: none;
    line-height: 1.6;
    color: #555;
}

.article-body details summary {
    padding: 0.8rem 1rem;
    cursor: pointer;
    background-color: transparent;
    font-weight: bold;
    color: #17223F;
    position: relative;
    list-style: none;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    transition: color 0.2s;
    border-bottom: 1px solid transparent;
    line-height: 1.5;
}

/* ... existing summary styles ... */
.article-body details summary::-webkit-details-marker {
    display: none;
}

.article-body details summary:hover {
    background-color: transparent;
    color: #447593;
}

/* Custom Arrow (Moved to ::before) */
.article-body details summary::before {
    content: '';
    width: 0; 
    height: 0; 
    border-left: 6px solid #447593;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    margin-right: 0.8rem;
    transition: transform 0.2s ease;
    transform-origin: center;
}

/* Open state: Rotate 90deg to point down */
.article-body details[open] summary::before {
    transform: rotate(90deg);
}

/* Remove old ::after arrow */
.article-body details summary::after {
    display: none;
}

.article-body details[open] summary {
    border-bottom: 1px solid #e0e0e0;
}

/* 
   Content Styles 
   Support both wrapper div (.details-content) and direct children (raw HTML fallback)
*/

/* 1. Wrapper Div Approach (Generated by build_wiki.py) */
.article-body details .details-content {
    padding: 1.5rem 2rem;
    color: #555;
    background-color: transparent;
    line-height: 1.6;
    font-size: 0.95rem;
}

/* 2. Direct Children Fallback (For raw HTML <details>) */
.article-body details > *:not(summary):not(.details-content) {
    padding-left: 2rem;
    padding-right: 2rem;
    font-size: 0.95rem;
}

/* Add vertical padding to the first element after summary */
.article-body details[open] > summary + *:not(.details-content) {
    padding-top: 1.5rem;
    margin-top: 0;
}

/* Add vertical padding to the last element */
.article-body details[open] > *:last-child:not(.details-content) {
    padding-bottom: 1.5rem;
    margin-bottom: 0;
}

/* Typography for details content (Global) */
.article-body details p, 
.article-body details .details-content p {
    margin-bottom: 0.8rem;
    text-align: justify;
    line-height: 1.6;
}

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

.article-body details .details-content ul,
.article-body details .details-content ol {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
}

.article-body details .details-content li {
    margin-bottom: 0.3rem;
}

/* Optional: Add a subtle separator or background for nested code blocks */
.article-body details pre,
.article-body details .details-content pre {
    background-color: rgba(23, 34, 63, 0.03);
    border: 1px solid rgba(23, 34, 63, 0.05);
}
