/* ========================================
   layer2.wiki - Scholarly Education Layout
   ======================================== */

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', sans-serif;
    font-size: 17px;
    line-height: 1.85;
    color: #334155;
    background-color: #FEFDFB;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ========================================
   Top Navigation Bar (56px)
   ======================================== */
.top-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    height: 56px;
    background: #FFFFFF;
    border-bottom: 1px solid #E5E1D8;
}

.nav-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 32px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-logo {
    font-family: 'Merriweather', serif;
    font-weight: 700;
    font-size: 20px;
    color: #1E293B;
    text-decoration: none;
    letter-spacing: -0.01em;
}

.nav-logo:hover {
    color: #2563EB;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 24px;
}

.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 12px;
    pointer-events: none;
}

.search-input {
    width: 280px;
    height: 36px;
    padding: 0 12px 0 36px;
    border: 1px solid #E5E1D8;
    border-radius: 6px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    color: #334155;
    background: #FEFDFB;
    outline: none;
    transition: width 400ms cubic-bezier(0.34, 1.56, 0.64, 1),
                border-color 200ms ease;
}

.search-input:focus {
    width: 400px;
    border-color: #2563EB;
}

.search-input::placeholder {
    color: #64748B;
}

.nav-contribute {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 500;
    color: #64748B;
    text-decoration: none;
    transition: color 150ms ease;
}

.nav-contribute:hover {
    color: #2563EB;
}

/* ========================================
   Breadcrumb Trail (32px)
   ======================================== */
.breadcrumb-bar {
    height: 32px;
    background: #FEFDFB;
    border-bottom: 1px solid #E5E1D8;
}

.breadcrumb-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 32px;
    height: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
}

.breadcrumb-item {
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-variant: small-caps;
    letter-spacing: 0.05em;
    color: #9B8E7E;
}

.breadcrumb-item a {
    color: #9B8E7E;
    text-decoration: none;
    transition: color 150ms ease;
}

.breadcrumb-item a:hover {
    color: #2563EB;
}

.breadcrumb-item.active {
    color: #64748B;
}

.breadcrumb-sep {
    font-size: 12px;
    color: #9B8E7E;
}

/* ========================================
   Page Layout
   ======================================== */
.page-layout {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 32px;
    display: flex;
    position: relative;
}

/* ========================================
   Main Content Column (max-width: 680px)
   ======================================== */
.content-column {
    max-width: 680px;
    width: 100%;
    margin: 0 auto;
    padding: 48px 0 80px;
}

/* ========================================
   Article Header
   ======================================== */
.article-header {
    margin-bottom: 40px;
}

.article-title {
    font-family: 'Merriweather', serif;
    font-weight: 700;
    font-size: 36px;
    line-height: 1.3;
    color: #1E293B;
    letter-spacing: -0.01em;
    margin-bottom: 12px;
}

.article-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.meta-item {
    font-family: 'Crimson Pro', serif;
    font-style: italic;
    font-size: 14px;
    line-height: 1.6;
    color: #64748B;
}

.meta-sep {
    color: #E5E1D8;
    font-size: 14px;
}

/* ========================================
   Article Sections
   ======================================== */
.article-section {
    margin-bottom: 8px;
    position: relative;
}

.article-section h2 {
    font-family: 'Merriweather', serif;
    font-weight: 700;
    font-size: 26px;
    line-height: 1.35;
    color: #1E293B;
    letter-spacing: -0.01em;
    border-left: 4px solid #2563EB;
    padding-left: 16px;
    margin-bottom: 24px;
}

.article-section h3 {
    font-family: 'Merriweather', serif;
    font-weight: 700;
    font-size: 20px;
    line-height: 1.4;
    color: #1E293B;
    font-variant: small-caps;
    margin-top: 32px;
    margin-bottom: 16px;
}

.article-section p {
    margin-bottom: 1em;
}

.article-section a {
    color: #334155;
    text-decoration: underline;
    text-decoration-color: #93C5FD;
    text-underline-offset: 3px;
    transition: color 150ms ease,
                text-decoration-color 150ms ease;
}

.article-section a:hover {
    color: #2563EB;
    text-decoration-color: #2563EB;
}

/* ========================================
   Section Dividers
   ======================================== */
.section-divider {
    border: none;
    width: 40%;
    height: 1px;
    background: #E5E1D8;
    margin: 48px auto;
}

/* ========================================
   Margin Annotations
   ======================================== */
.margin-annotation {
    display: none;
}

@media (min-width: 1200px) {
    .margin-annotation {
        display: block;
        position: absolute;
        right: -260px;
        width: 220px;
        background: #F8F6F1;
        padding: 14px 16px;
        border-top: 2px solid #F59E0B;
        font-family: 'Crimson Pro', serif;
        font-style: italic;
        font-size: 14px;
        line-height: 1.6;
        color: #64748B;
    }

    .margin-annotation strong {
        font-style: normal;
        font-weight: 600;
        font-family: 'Inter', sans-serif;
        font-size: 12px;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: #1E293B;
        display: block;
        margin-bottom: 4px;
    }
}

/* ========================================
   Inline Diagrams
   ======================================== */
.inline-diagram {
    margin: 32px 0;
    padding: 24px;
    background: #F8F6F1;
    border-radius: 4px;
}

.protocol-diagram {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    display: block;
}

.diagram-label {
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    fill: #1E293B;
}

.diagram-label-sub {
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    fill: #64748B;
}

.inline-diagram figcaption {
    font-family: 'Crimson Pro', serif;
    font-style: italic;
    font-size: 14px;
    line-height: 1.6;
    color: #64748B;
    text-align: center;
    margin-top: 16px;
}

/* ========================================
   Citation Cards
   ======================================== */
.citation-card {
    margin: 28px 0;
    padding: 20px 24px;
    background: #FEF9EE;
    border-left: 3px solid #F59E0B;
}

.citation-text {
    font-family: 'Crimson Pro', serif;
    font-style: italic;
    font-size: 16px;
    line-height: 1.7;
    color: #334155;
    margin-bottom: 8px;
}

.citation-source {
    font-family: 'Crimson Pro', serif;
    font-style: italic;
    font-size: 14px;
    line-height: 1.6;
    color: #64748B;
    display: block;
}

.citation-source em {
    font-style: normal;
    text-decoration: underline;
    text-decoration-color: #E5E1D8;
}

/* ========================================
   Comparison Table
   ======================================== */
.comparison-table {
    width: 100%;
    border-collapse: collapse;
    margin: 28px 0;
    font-size: 15px;
}

.comparison-table thead th {
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #1E293B;
    text-align: left;
    padding: 12px 16px;
    border-bottom: 2px solid #1E293B;
    background: #F8F6F1;
}

.comparison-table tbody td {
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    color: #334155;
    padding: 12px 16px;
    border-bottom: 1px solid #E5E1D8;
    vertical-align: top;
}

.comparison-table tbody tr:last-child td {
    border-bottom: none;
}

.comparison-table tbody td:first-child {
    font-weight: 500;
    color: #1E293B;
}

/* ========================================
   Footnote References (superscript)
   ======================================== */
.footnote-ref {
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 600;
    color: #2563EB;
    cursor: pointer;
    text-decoration: none;
    position: relative;
    top: -0.3em;
    padding: 0 2px;
    transition: color 150ms ease;
}

.footnote-ref:hover {
    color: #1E293B;
}

/* ========================================
   Footnote Tooltip
   ======================================== */
.footnote-tooltip {
    position: fixed;
    max-width: 300px;
    background: #FFFFFF;
    padding: 14px 18px;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    font-family: 'Crimson Pro', serif;
    font-style: italic;
    font-size: 14px;
    line-height: 1.6;
    color: #334155;
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms ease;
    z-index: 200;
}

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

/* ========================================
   Footnotes Section
   ======================================== */
.footnotes-section {
    margin-bottom: 8px;
}

.footnotes-section h2 {
    font-family: 'Merriweather', serif;
    font-weight: 700;
    font-size: 26px;
    line-height: 1.35;
    color: #1E293B;
    letter-spacing: -0.01em;
    border-left: 4px solid #2563EB;
    padding-left: 16px;
    margin-bottom: 24px;
}

.footnotes-list {
    list-style: none;
    border-top: 1px solid #E5E1D8;
    padding-top: 24px;
}

.footnote-item {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    font-family: 'Crimson Pro', serif;
    font-size: 14px;
    line-height: 1.6;
    color: #64748B;
}

.footnote-number {
    font-weight: 600;
    color: #2563EB;
    flex-shrink: 0;
    min-width: 24px;
}

.footnote-text em {
    font-style: normal;
    text-decoration: underline;
    text-decoration-color: #E5E1D8;
}

/* ========================================
   Related Articles Footer
   ======================================== */
.related-articles {
    margin-top: 48px;
    padding-top: 48px;
    border-top: 1px solid #E5E1D8;
}

.related-articles h2 {
    font-family: 'Merriweather', serif;
    font-weight: 700;
    font-size: 22px;
    color: #1E293B;
    letter-spacing: -0.01em;
    margin-bottom: 24px;
}

.related-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.related-card {
    border: 1px solid #E5E1D8;
    padding: 20px;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    transition: border-color 150ms ease;
}

.related-card:hover {
    border-color: #2563EB;
}

.related-title {
    font-family: 'Merriweather', serif;
    font-weight: 700;
    font-size: 16px;
    color: #1E293B;
    margin-bottom: 8px;
    line-height: 1.4;
}

.related-excerpt {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: #64748B;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex-grow: 1;
}

.related-arrow {
    font-size: 18px;
    color: #2563EB;
    margin-top: 12px;
    display: block;
}

/* ========================================
   Table of Contents Sidebar
   ======================================== */
.toc-sidebar {
    display: none;
}

@media (min-width: 1200px) {
    .toc-sidebar {
        display: block;
        position: fixed;
        right: calc((100vw - 1200px) / 2 + 32px);
        top: 80px;
        width: 200px;
    }

    .page-layout {
        position: relative;
    }
}

.toc-progress-track {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #E5E1D8;
}

.toc-progress-fill {
    position: absolute;
    left: 0;
    top: 0;
    width: 2px;
    height: 0;
    background: #2563EB;
    transform-origin: top;
    transition: height 200ms ease;
}

.toc-nav {
    padding-left: 16px;
}

.toc-heading {
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #64748B;
    margin-bottom: 12px;
}

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

.toc-item {
    margin-bottom: 8px;
}

.toc-link {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    color: #64748B;
    text-decoration: none;
    transition: color 200ms ease, font-weight 200ms ease;
    display: block;
    line-height: 1.5;
}

.toc-link:hover {
    color: #1E293B;
}

.toc-link.active {
    color: #2563EB;
    font-weight: 600;
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 768px) {
    .nav-inner {
        padding: 0 16px;
    }

    .breadcrumb-inner {
        padding: 0 16px;
    }

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

    .search-input {
        width: 200px;
    }

    .search-input:focus {
        width: 240px;
    }

    .article-title {
        font-size: 28px;
    }

    .article-section h2 {
        font-size: 22px;
    }

    .related-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .comparison-table {
        font-size: 13px;
    }

    .comparison-table thead th,
    .comparison-table tbody td {
        padding: 8px 10px;
    }
}

@media (max-width: 480px) {
    .nav-contribute {
        display: none;
    }

    .search-input {
        width: 160px;
    }

    .search-input:focus {
        width: 200px;
    }
}