/* ============================================================
   monopole.wiki — Styles
   An encyclopedic reference with antique-book aesthetic
   ============================================================ */

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 20px;
}

body {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: clamp(15px, 1vw, 17px);
    font-weight: 400;
    line-height: 1.8;
    color: #3A3028;
    background: #F5F0E5;
}

/* --- Paper Texture Overlay --- */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
    opacity: 0.3;
}

/* --- Sidebar --- */
#sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 280px;
    height: 100vh;
    overflow-y: auto;
    background: #EDE5D8;
    border-right: 1px solid #D0C0A8;
    padding: 32px 20px;
    z-index: 100;
    display: flex;
    flex-direction: column;
}

#sidebar-header {
    margin-bottom: 32px;
    padding-bottom: 20px;
    border-bottom: 1px solid #D0C0A8;
}

#logotype {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 700;
    font-size: clamp(22px, 2.5vw, 30px);
    color: #2A2018;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.logotype-dot {
    color: #8A6840;
}

#sidebar-subtitle {
    font-family: 'Inconsolata', 'Courier New', monospace;
    font-size: 11px;
    color: #8A8070;
    margin-top: 6px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

/* --- Table of Contents --- */
#toc {
    flex: 1;
}

#toc-list {
    list-style: none;
    padding: 0;
}

#toc-list li {
    margin-bottom: 2px;
}

.toc-link {
    display: block;
    padding: 8px 12px;
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 13px;
    font-weight: 400;
    color: #8A8070;
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: all 0.2s ease;
    line-height: 1.4;
}

.toc-link:hover {
    color: #3A3028;
    background: rgba(138, 104, 64, 0.06);
}

.toc-link.active {
    border-left: 3px solid #8A6840;
    font-weight: 700;
    color: #2A2018;
    background: rgba(138, 104, 64, 0.08);
}

/* --- Sidebar Footer --- */
#sidebar-footer {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid #D0C0A8;
}

.sidebar-note {
    font-family: 'Inconsolata', 'Courier New', monospace;
    font-size: 10px;
    color: #8A8070;
    letter-spacing: 0.03em;
    line-height: 1.6;
}

/* --- Main Content --- */
#content {
    margin-left: 280px;
    max-width: 800px;
    padding: 40px 48px 80px;
}

/* --- Article Sections --- */
.article-section {
    margin-bottom: 60px;
    scroll-margin-top: 20px;
}

/* --- Vintage Illustrations --- */
.section-illustration {
    margin-bottom: 24px;
}

.vintage-illustration {
    width: 100%;
    max-width: 500px;
    height: auto;
    display: block;
    margin: 0 auto;
}

/* --- Book Page Panels --- */
.book-page {
    background: #F8F4EC;
    box-shadow: 2px 0 4px rgba(42, 32, 24, 0.08), 4px 0 8px rgba(42, 32, 24, 0.04);
    border-left: 1px solid #E0D8C8;
    padding: 32px 36px;
    position: relative;
}

/* Subtle page-edge effect */
.book-page::before {
    content: '';
    position: absolute;
    right: -3px;
    top: 4px;
    bottom: 4px;
    width: 2px;
    background: rgba(208, 192, 168, 0.4);
}

.book-page::after {
    content: '';
    position: absolute;
    right: -6px;
    top: 8px;
    bottom: 8px;
    width: 1px;
    background: rgba(208, 192, 168, 0.25);
}

/* --- Section Headings --- */
.section-heading {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 700;
    font-size: clamp(24px, 3vw, 40px);
    color: #2A2018;
    margin-bottom: 20px;
    letter-spacing: -0.01em;
    line-height: 1.2;
}

/* --- Lead Paragraphs --- */
.lead-paragraph {
    font-size: clamp(17px, 1.2vw, 20px);
    line-height: 1.7;
    color: #3A3028;
    margin-bottom: 16px;
    font-style: italic;
}

/* --- Body Paragraphs --- */
.book-page p {
    margin-bottom: 14px;
    color: #3A3028;
}

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

/* --- Page Rule Lines --- */
.page-rule {
    border: none;
    border-bottom: 1px solid #D0C0A8;
    margin: 20px 0;
}

/* --- Reference Code / Inline Formulas --- */
.reference-code {
    font-family: 'Inconsolata', 'Courier New', monospace;
    font-size: 13px;
    font-weight: 400;
    color: #3A3028;
    background: rgba(208, 192, 168, 0.25);
    padding: 2px 5px;
    border-radius: 2px;
}

/* --- Equation Blocks --- */
.equation-block {
    text-align: center;
    margin: 20px 0;
    padding: 16px;
    background: rgba(208, 192, 168, 0.15);
    border-left: 3px solid #8A6840;
}

.equation-block .reference-code {
    font-size: 15px;
    background: none;
    padding: 0;
}

/* ============================================================
   ACCORDION STYLES
   Three levels of nesting depth
   ============================================================ */

.accordion {
    margin-bottom: 4px;
}

.accordion-header {
    cursor: pointer;
    padding: 12px 14px;
    border-bottom: 1px solid #D0C0A8;
    font-family: 'Playfair Display', Georgia, serif;
    display: flex;
    align-items: center;
    gap: 10px;
    user-select: none;
    transition: background 0.15s ease;
}

.accordion-header:hover {
    background: rgba(138, 104, 64, 0.06);
}

.accordion-header[data-level="1"] {
    font-size: 16px;
    font-weight: 700;
    color: #2A2018;
}

.accordion-header[data-level="2"] {
    font-size: 14px;
    font-weight: 600;
    color: #3A3028;
    padding-left: 24px;
    border-bottom-color: rgba(208, 192, 168, 0.6);
}

.accordion-header[data-level="3"] {
    font-size: 13px;
    font-weight: 600;
    color: #8A8070;
    padding-left: 36px;
    border-bottom-color: rgba(208, 192, 168, 0.4);
}

.accordion-icon {
    font-size: 10px;
    color: #8A6840;
    transition: transform 0.25s ease;
    flex-shrink: 0;
    display: inline-block;
}

.accordion-header.open .accordion-icon {
    transform: rotate(90deg);
}

.accordion-title {
    flex: 1;
}

.accordion-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease-out;
}

.accordion-body.open {
    /* max-height set dynamically by JS */
}

.accordion-content {
    padding: 16px 14px;
}

.accordion-header[data-level="2"] + .accordion-body .accordion-content {
    padding-left: 24px;
}

.accordion-header[data-level="3"] + .accordion-body .accordion-content {
    padding-left: 36px;
}

/* --- References --- */
.references-list {
    margin-top: 12px;
}

.reference-entry {
    margin-bottom: 12px;
    padding-left: 40px;
    text-indent: -40px;
    font-size: 14px;
    line-height: 1.6;
    color: #3A3028;
}

.reference-entry em {
    font-style: italic;
}

.reference-entry strong {
    font-weight: 700;
}

.reference-entry .reference-code {
    font-size: 12px;
    font-weight: 700;
    color: #8A6840;
    background: none;
    padding: 0;
}

/* --- Footer --- */
#page-footer {
    margin-top: 40px;
    padding-top: 20px;
}

.footer-text {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 14px;
    color: #8A8070;
    margin-bottom: 4px;
}

.footer-note {
    font-family: 'Inconsolata', 'Courier New', monospace;
    font-size: 11px;
    color: #8A8070;
    letter-spacing: 0.02em;
}

/* --- Sidebar Scrollbar --- */
#sidebar::-webkit-scrollbar {
    width: 4px;
}

#sidebar::-webkit-scrollbar-track {
    background: transparent;
}

#sidebar::-webkit-scrollbar-thumb {
    background: #D0C0A8;
    border-radius: 2px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 960px) {
    #sidebar {
        position: relative;
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid #D0C0A8;
        padding: 24px 20px;
    }

    #content {
        margin-left: 0;
        padding: 32px 24px 60px;
    }

    .book-page {
        padding: 24px 20px;
    }
}

@media (max-width: 600px) {
    #content {
        padding: 20px 16px 40px;
    }

    .book-page {
        padding: 20px 16px;
        box-shadow: 1px 0 3px rgba(42, 32, 24, 0.06);
    }

    .book-page::before,
    .book-page::after {
        display: none;
    }

    .section-heading {
        font-size: 22px;
    }

    .lead-paragraph {
        font-size: 16px;
    }

    .accordion-header[data-level="2"] {
        padding-left: 16px;
    }

    .accordion-header[data-level="3"] {
        padding-left: 24px;
    }

    .reference-entry {
        padding-left: 30px;
        text-indent: -30px;
    }
}
