/* --- A classic, stately color palette for a historical theme --- */
:root {
    --primary-color: #3c4f65;    /* A deep, muted blue-gray */
    --secondary-color: #7a6c5d;  /* A warm, earthy brown */
    --accent-color: #a95c32;    /* A rich terracotta */
    --text-color: #333;
    --bg-color: #f5f3f0;      /* A very light, warm off-white like old paper */
    --content-bg: #ffffff;
    --border-color: #e4e1d9;    /* A soft, warm gray for borders */
    --font-family: 'Georgia', 'Times New Roman', serif;
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-family);
    line-height: 1.7;
    margin: 0;
    padding: 0;
}

.article-hero {
    height: 70vh;
    max-height: 600px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: white;
    overflow: hidden;
}

.article-hero::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(rgba(60, 79, 101, 0.7), rgba(122, 108, 93, 0.7));
    z-index: 1;
}

.article-hero-bg { position:absolute; top:0; left:0; width:100%; height:100%; object-fit:cover; z-index:0; }
.article-hero-content { position:relative; z-index:2; padding:0 2rem; max-width:800px; }
.article-hero h1 { font-size: clamp(2.5rem,5vw,4rem); margin-bottom:1rem; font-weight:700; }
.article-hero .subtitle { font-size:clamp(1rem,2vw,1.25rem); font-family:var(--font-sans); font-weight:300; opacity:0.9; }

.article-container { display:grid; grid-template-columns:1fr 250px; gap:3rem; max-width:1200px; margin:3rem auto; padding:0 2rem; }
.article-content { background-color:var(--content-bg); padding:2rem 3rem; border-radius:8px; box-shadow:0 4px 15px rgba(0,0,0,0.05); }

/* --- Responsive Images --- */
.article-content img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 1.5rem 0;
    border-radius: 12px;
}

.article-content h2 { font-size:2.2rem; color:var(--primary-color); margin-top:2.5rem; margin-bottom:1rem; scroll-margin-top:100px; }
.article-content h3 { font-size:1.5rem; color:var(--secondary-color); margin-top:2rem; margin-bottom:1rem; }
.article-content p { font-size:1.1rem; margin-bottom:1.5rem; }

.article-meta { font-family:var(--font-sans); font-size:0.9rem; color:#777; margin-bottom:2rem; display:flex; gap:1.5rem; }

.author-bio { margin-top:3rem; padding-top:2rem; border-top:1px solid var(--border-color); display:flex; align-items:center; gap:1.5rem; }
.author-bio img { width:80px; height:80px; border-radius:50%; margin:0; object-fit: cover; }
.author-bio div h4 { margin:0 0 0.25rem 0; font-size:1.2rem; }
.author-bio div p { margin:0; font-size:0.95rem; color:#666; }

/* --- Table of Contents (Desktop) --- */
.table-of-contents {
    position: sticky;
    top: 100px;
    height: calc(100vh - 120px);
    overflow-y: auto;
    padding-right: 20px;
    background-color: white;
}

.table-of-contents h3 {
    font-size: 1.0rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
    border-bottom: 3px solid var(--accent-color);
    padding-bottom: 0.1rem;
    position: sticky;
    top: 0;
    background-color: white;
    border-radius: 2px;
    z-index: 10px;
}

.table-of-contents ul { 
    list-style: none; 
    padding: 0; 
    margin: 0;
    background-color: white;
}

.table-of-contents li { 
    margin-bottom: 0.5rem;
    background-color: white;
}

.table-of-contents a {
    background-color: white;
    text-decoration: none;
    color: var(--text-color);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    display: block;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.table-of-contents a:hover, .table-of-contents a.active {
    background-color: var(--accent-color);
    color: white;
}

/* --- Mobile Table of Contents --- */
.mobile-toc-container {
    display: none; /* Hidden on desktop */
    margin-bottom: 2rem;
}

.mobile-toc-toggle {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
    font-family: var(--font-sans);
    font-weight: 600;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.2s;
}

.mobile-toc-toggle:hover { background-color: var(--secondary-color); }
.mobile-toc-toggle .arrow { transition: transform 0.3s ease; }
.mobile-toc-toggle.is-open .arrow { transform: rotate(180deg); }

.mobile-toc-links {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease;
    background-color: var(--content-bg);
    border-radius: 8px;
    margin-top: 0.5rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}
.mobile-toc-links.is-open { max-height: 500px; overflow-y: auto; }
.mobile-toc-links ul { list-style: none; padding: 1rem; margin: 0; }
.mobile-toc-links a {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--text-color);
    text-decoration: none;
    font-family: var(--font-sans);
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.2s;
}
.mobile-toc-links a:last-child { border-bottom: none; }
.mobile-toc-links a:hover, .mobile-toc-links a.active {
    background-color: var(--bg-color);
    color: var(--primary-color);
}

/* --- Back to Top Button --- */
#back-to-top {
    position: fixed;
    bottom: 25px;
    right: 25px;
    width: 50px;
    height: 50px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: none; /* Hidden by default */
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: background-color 0.3s ease, transform 0.3s ease;
}
#back-to-top:hover { background-color: var(--secondary-color); transform: translateY(-3px); }


/* --- Mobile Responsiveness --- */
@media (max-width:992px) {
    .article-container {
        grid-template-columns: 1fr;
        padding: 0 1rem;
    }
    .article-content { padding:1.5rem; }
    
    /* Hide desktop TOC, show mobile TOC */
    .table-of-contents { display:none; }
    .mobile-toc-container { display:block; }

    /* Stack meta and author bio */
    .article-meta { flex-direction: column; gap: 0.5rem; }
    .author-bio { flex-direction: column; text-align: center; }
}