/* diplomatic.wiki — Education Scholarly Layout
   Palette: #1F1710 #F8F4ED #7A2832 #B8963E #2A2016 #8A7E72 #3E5C8A #EDE6D8
*/

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: #F8F4ED;
    color: #2A2016;
    font-family: 'EB Garamond', serif;
    font-weight: 400;
    font-size: 1.05rem;
    line-height: 1.8;
}

/* ── Portico (Hero) ── */
#portico {
    background-color: #1F1710;
    min-height: 50vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 24px;
}

.portico-inner {
    text-align: center;
    max-width: 800px;
}

.portico-title {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 700;
    font-size: clamp(2.5rem, 5vw, 4.5rem);
    color: #F8F4ED;
    letter-spacing: 0.04em;
    margin-bottom: 16px;
    opacity: 0;
    animation: fadeReveal 600ms ease forwards;
}

.portico-subtitle {
    font-family: 'Alegreya Sans', sans-serif;
    font-weight: 400;
    font-size: 1.1rem;
    color: #B8963E;
    letter-spacing: 0.06em;
    margin-bottom: 24px;
    opacity: 0;
    animation: fadeReveal 600ms ease 200ms forwards;
}

.breadcrumb {
    font-family: 'Alegreya Sans', sans-serif;
    font-size: 0.85rem;
    color: #8A7E72;
    opacity: 0;
    animation: fadeReveal 600ms ease 400ms forwards;
}

.crumb-sep {
    margin: 0 8px;
    color: #B8963E;
    opacity: 0.4;
}

.crumb.active {
    color: #F8F4ED;
}

@keyframes fadeReveal {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Wiki Layout ── */
.wiki-layout {
    display: grid;
    grid-template-columns: 280px 15px 1fr;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    min-height: 100vh;
}

/* ── Sidebar ── */
#sidebar {
    position: relative;
}

.sidebar-inner {
    position: sticky;
    top: 24px;
    padding: 32px 0 32px 0;
}

.sidebar-heading {
    font-family: 'Alegreya Sans', sans-serif;
    font-weight: 700;
    font-size: 0.75rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #8A7E72;
    margin-bottom: 16px;
    padding-left: 16px;
}

.toc-list {
    list-style: none;
    position: relative;
}

.toc-marker {
    position: absolute;
    left: 0;
    top: 0;
    width: 3px;
    height: 28px;
    background: #7A2832;
    border-radius: 2px;
    transition: transform 200ms ease;
    z-index: 2;
}

.toc-item {
    position: relative;
}

.toc-item a {
    display: block;
    font-family: 'Alegreya Sans', sans-serif;
    font-weight: 400;
    font-size: 0.9rem;
    line-height: 1.5;
    color: #2A2016;
    text-decoration: none;
    padding: 4px 16px;
    transition: color 0.2s ease, font-weight 0.2s ease;
}

.toc-item.toc-h3 a {
    padding-left: 32px;
    font-size: 0.85rem;
    color: #8A7E72;
}

.toc-item.active a {
    color: #7A2832;
    font-weight: 500;
}

.toc-item a:hover {
    color: #7A2832;
}

/* TOC stagger animation */
.toc-item {
    opacity: 0;
}

.toc-item.toc-visible {
    animation: fadeReveal 300ms ease forwards;
}

/* ── Book Spine Shadow ── */
.spine-shadow {
    background: linear-gradient(to right, rgba(31, 23, 16, 0.08), transparent);
    width: 15px;
}

/* ── Main Content ── */
#content {
    max-width: 720px;
    padding: 40px 0 80px 24px;
}

/* ── Section Headings ── */
.wiki-section {
    margin-bottom: 48px;
}

.wiki-section h2 {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: clamp(1.8rem, 3vw, 2.8rem);
    color: #2A2016;
    line-height: 1.2;
    margin-bottom: 4px;
}

.wiki-section h3 {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: clamp(1.3rem, 2vw, 1.8rem);
    color: #2A2016;
    line-height: 1.25;
    margin-bottom: 16px;
}

.wiki-section h4 {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: clamp(1.1rem, 1.5vw, 1.4rem);
    color: #2A2016;
    line-height: 1.3;
    margin-bottom: 12px;
}

/* ── Decorative Heading Rules ── */
.heading-rule {
    position: relative;
    height: 8px;
    margin-bottom: 24px;
    max-width: 200px;
}

.heading-rule::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 0.5px;
    background: #B8963E;
    opacity: 0.4;
}

.heading-rule::after {
    content: '';
    position: absolute;
    top: 4px;
    left: 0;
    right: 0;
    height: 1px;
    background: #B8963E;
    opacity: 0.4;
}

/* ── Content with Marginalia ── */
.content-with-margin {
    display: grid;
    grid-template-columns: 1fr 180px;
    gap: 32px;
    align-items: start;
}

.main-text p {
    margin-bottom: 20px;
}

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

/* ── Marginalia ── */
.marginalia {
    padding-top: 4px;
}

.margin-note {
    font-family: 'EB Garamond', serif;
    font-style: italic;
    font-weight: 400;
    font-size: 0.85rem;
    line-height: 1.6;
    color: #8A7E72;
    border-left: 1px solid #B8963E;
    padding-left: 12px;
    opacity: 0.85;
}

/* ── Footnote References ── */
.footnote-ref {
    font-family: 'EB Garamond', serif;
    font-size: 0.75em;
    color: #7A2832;
    cursor: help;
    text-decoration: none;
    position: relative;
    vertical-align: super;
    line-height: 0;
}

.footnote-ref:hover {
    color: #3E5C8A;
}

/* ── Footnote Tooltip ── */
.footnote-tooltip {
    position: fixed;
    background: #EDE6D8;
    color: #2A2016;
    font-family: 'EB Garamond', serif;
    font-size: 0.9rem;
    line-height: 1.6;
    padding: 12px 16px;
    border: 1px solid rgba(184, 150, 62, 0.3);
    border-radius: 3px;
    max-width: 320px;
    box-shadow: 0 4px 12px rgba(31, 23, 16, 0.12);
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms ease;
    z-index: 1000;
}

.footnote-tooltip.visible {
    opacity: 1;
    pointer-events: auto;
}

/* ── Blockquote / Treaty Excerpts ── */
.treaty-quote {
    border-left: 3px solid #B8963E;
    padding-left: 1.5rem;
    background: #EDE6D8;
    padding: 20px 24px;
    margin: 24px 0;
    border-radius: 2px;
}

.treaty-quote p {
    font-family: 'EB Garamond', serif;
    font-style: italic;
    font-size: 1.05rem;
    line-height: 1.75;
    color: #2A2016;
    margin-bottom: 8px;
}

.treaty-cite {
    font-family: 'Alegreya Sans', sans-serif;
    font-variant: small-caps;
    font-size: 0.85rem;
    color: #8A7E72;
    display: block;
    margin-top: 8px;
}

.treaty-cite em {
    font-variant: normal;
    font-style: italic;
}

/* ── Definition List ── */
.definition-list {
    margin: 0;
}

.definition-list dt {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: 1.15rem;
    color: #7A2832;
    margin-top: 20px;
    margin-bottom: 4px;
}

.definition-list dt:first-child {
    margin-top: 0;
}

.definition-list dd {
    font-family: 'EB Garamond', serif;
    font-size: 1.02rem;
    line-height: 1.75;
    color: #2A2016;
    padding-left: 20px;
    margin-bottom: 12px;
    border-left: 1px solid rgba(184, 150, 62, 0.3);
}

/* ── Cross-Reference Cards ── */
.cross-refs {
    display: flex;
    gap: 16px;
    margin-top: 32px;
    flex-wrap: wrap;
}

.ref-card {
    width: 240px;
    background: #EDE6D8;
    border: 1px solid rgba(184, 150, 62, 0.2);
    border-radius: 3px;
    padding: 16px;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}

.ref-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(31, 23, 16, 0.1);
}

.ref-corner {
    position: absolute;
    top: 0;
    right: 0;
    width: 24px;
    height: 24px;
    background: linear-gradient(225deg, #F8F4ED 50%, #EDE6D8 50%);
}

.ref-label {
    font-family: 'Alegreya Sans', sans-serif;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #8A7E72;
    margin-bottom: 6px;
}

.ref-title {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: 1.05rem;
    color: #3E5C8A;
    margin-bottom: 4px;
}

.ref-desc {
    font-family: 'EB Garamond', serif;
    font-size: 0.9rem;
    line-height: 1.5;
    color: #8A7E72;
}

/* ── Reading List ── */
.reading-list {
    list-style: none;
    padding: 0;
}

.reading-list li {
    font-family: 'EB Garamond', serif;
    font-size: 1rem;
    line-height: 1.7;
    color: #2A2016;
    margin-bottom: 12px;
    padding-left: 20px;
    position: relative;
}

.reading-list li::before {
    content: '\2014';
    position: absolute;
    left: 0;
    color: #B8963E;
}

.reading-author {
    font-weight: 500;
}

.reading-list em {
    font-style: italic;
}

/* ── Article Footer ── */
.article-footer {
    font-family: 'Alegreya Sans', sans-serif;
    font-size: 0.85rem;
    letter-spacing: 0.04em;
    color: #8A7E72;
    text-align: center;
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid rgba(184, 150, 62, 0.3);
}

/* ── Mobile Sidebar Toggle ── */
.sidebar-toggle {
    display: none;
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 48px;
    height: 48px;
    background: #1F1710;
    border: 1px solid #B8963E;
    border-radius: 50%;
    cursor: pointer;
    z-index: 1001;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    box-shadow: 0 4px 12px rgba(31, 23, 16, 0.3);
}

.toggle-bar {
    display: block;
    width: 18px;
    height: 2px;
    background: #F8F4ED;
    border-radius: 1px;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.sidebar-toggle.active .toggle-bar:nth-child(1) {
    transform: rotate(45deg) translate(4px, 4px);
}

.sidebar-toggle.active .toggle-bar:nth-child(2) {
    opacity: 0;
}

.sidebar-toggle.active .toggle-bar:nth-child(3) {
    transform: rotate(-45deg) translate(4px, -4px);
}

/* ── Responsive ── */
@media (max-width: 1024px) {
    .wiki-layout {
        grid-template-columns: 240px 10px 1fr;
    }

    .content-with-margin {
        grid-template-columns: 1fr;
    }

    .marginalia {
        padding-top: 0;
        margin-top: 16px;
    }

    .margin-note {
        border-left: 2px solid #B8963E;
        padding: 8px 12px;
        background: rgba(237, 230, 216, 0.5);
    }
}

@media (max-width: 768px) {
    .wiki-layout {
        grid-template-columns: 1fr;
    }

    .spine-shadow {
        display: none;
    }

    #sidebar {
        position: fixed;
        top: 0;
        left: -300px;
        width: 280px;
        height: 100vh;
        background: #F8F4ED;
        z-index: 1000;
        border-right: 1px solid rgba(184, 150, 62, 0.3);
        box-shadow: 4px 0 20px rgba(31, 23, 16, 0.15);
        transition: left 0.3s ease;
        overflow-y: auto;
    }

    #sidebar.sidebar-open {
        left: 0;
    }

    .sidebar-inner {
        position: static;
        padding: 24px 16px;
    }

    .sidebar-toggle {
        display: flex;
    }

    #content {
        padding: 24px 0 80px 0;
        max-width: 100%;
    }

    .content-with-margin {
        grid-template-columns: 1fr;
    }

    .marginalia {
        padding-top: 0;
        margin-top: 12px;
    }

    /* Mobile margin notes as inline asides */
    .margin-note {
        border-left: 2px solid #B8963E;
        padding: 10px 14px;
        background: rgba(237, 230, 216, 0.5);
        border-radius: 2px;
        font-size: 0.9rem;
    }

    .cross-refs {
        flex-direction: column;
    }

    .ref-card {
        width: 100%;
    }
}

@media (max-width: 480px) {
    #portico {
        min-height: 40vh;
        padding: 40px 16px;
    }

    .wiki-layout {
        padding: 0 16px;
    }
}
