/* ==========================================================================
   mores.dev - Light-Academia Scholarly Design
   Colors: #F9F7F3, #E8E3D8, #2C1810, #6B5F4F, #D4AF8F, #8B4545, #5F7F5F, #8B6F47, #3D3D3D
   Fonts: Lora, Libre Franklin, IBM Plex Mono
   ========================================================================== */

/* --- Reset & Base --- */

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Libre Franklin', sans-serif;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    font-weight: 400;
    line-height: 1.7;
    letter-spacing: 0.015em;
    color: #3D3D3D;
    background-color: #F9F7F3;
    overflow-x: hidden;
}

/* Paper grain texture overlay */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.04;
    background-image:
        repeating-conic-gradient(#6B5F4F 0% 25%, transparent 0% 50%) 0 0 / 3px 3px,
        repeating-conic-gradient(#6B5F4F 0% 25%, transparent 0% 50%) 1.5px 1.5px / 3px 3px;
}

/* --- Scroll Progress Indicator --- */

#scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 2px;
    height: 0%;
    background: linear-gradient(to bottom, #D4AF8F, #8B6F47);
    z-index: 1000;
    transition: height 0.1s ease-out;
}

@media (min-width: 769px) {
    #scroll-progress {
        left: calc(30% - 1px);
    }
}

/* --- Opening Section (Title Page) --- */

.section-opening {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
    position: relative;
}

.opening-content {
    max-width: 600px;
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInUp 1.2s ease-out 0.3s forwards;
}

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.opening-ornament-top {
    margin-bottom: 2rem;
}

.site-title {
    font-family: 'Lora', serif;
    font-size: clamp(3rem, 6vw, 5rem);
    font-weight: 700;
    color: #2C1810;
    letter-spacing: 0.02em;
    margin-bottom: 1.5rem;
    line-height: 1.1;
}

.ornament-fleuron {
    display: flex;
    justify-content: center;
    margin-bottom: 2rem;
}

.scroll-invitation {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.85rem;
    color: #6B5F4F;
    letter-spacing: 0.05em;
    opacity: 0;
    animation: fadeIn 1s ease-out 1.5s forwards;
}

@keyframes fadeIn {
    to { opacity: 0.7; }
}

/* --- Main Layout: Left Margin + Content --- */

.main-layout {
    display: flex;
    min-height: 100vh;
    position: relative;
}

/* --- Left Margin / Marginalia --- */

.left-margin {
    width: 30%;
    min-width: 220px;
    max-width: 360px;
    background-color: #E8E3D8;
    padding: 3rem 1.5rem 3rem 1.5rem;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    border-right: 1px solid rgba(212, 175, 143, 0.3);
}

.left-margin::-webkit-scrollbar {
    width: 4px;
}

.left-margin::-webkit-scrollbar-track {
    background: transparent;
}

.left-margin::-webkit-scrollbar-thumb {
    background: rgba(212, 175, 143, 0.4);
    border-radius: 2px;
}

.margin-nav {
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
}

.margin-section {
    cursor: pointer;
    padding: 0.75rem 0;
    border-left: 2px solid transparent;
    padding-left: 1rem;
    transition: border-color 0.4s ease, background-color 0.3s ease;
}

.margin-section:hover {
    border-left-color: #D4AF8F;
    background-color: rgba(212, 175, 143, 0.1);
}

.margin-section.active {
    border-left-color: #8B4545;
}

.margin-ornament {
    display: block;
    margin-bottom: 0.5rem;
}

.margin-label {
    font-family: 'Lora', serif;
    font-size: 0.95rem;
    font-weight: 700;
    color: #2C1810;
    letter-spacing: 0.02em;
    display: block;
    margin-bottom: 0.3rem;
}

.margin-note {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.8rem;
    font-weight: 400;
    color: #6B5F4F;
    line-height: 1.5;
}

/* --- Content Column --- */

.content-column {
    flex: 1;
    max-width: 760px;
    padding: 4rem 3rem 6rem 3rem;
    margin: 0 auto;
}

/* --- Content Sections --- */

.content-section {
    margin-bottom: 5vh;
    padding-bottom: 3vh;
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

.content-section.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Section Dividers (decorative fleuron lines) */
.section-divider {
    display: flex;
    justify-content: center;
    margin-bottom: 2.5rem;
    padding-top: 1rem;
}

/* --- Typography --- */

h2 {
    font-family: 'Lora', serif;
    font-size: clamp(2rem, 4vw, 3.2rem);
    font-weight: 700;
    color: #2C1810;
    letter-spacing: 0.02em;
    margin-bottom: 1.5rem;
    line-height: 1.25;
}

.drop-cap {
    float: left;
    font-family: 'Lora', serif;
    font-size: 3.5em;
    line-height: 0.8;
    padding-right: 0.08em;
    padding-top: 0.07em;
    color: #8B6F47;
    font-weight: 700;
}

p {
    margin-bottom: 1.25rem;
    text-align: left;
}

em {
    font-style: italic;
    color: #2C1810;
}

/* --- Pull Quotes --- */

.pull-quote {
    margin: 2.5rem 0;
    padding: 1.5rem 1.5rem 1.5rem 2rem;
    border-left: 4px solid #8B4545;
    background-color: #E8E3D8;
    position: relative;
}

.pull-quote p {
    font-family: 'Lora', serif;
    font-style: italic;
    font-size: 1.1rem;
    line-height: 1.65;
    letter-spacing: 0.02em;
    color: #2C1810;
    margin-bottom: 0;
}

/* --- Footnote Markers --- */

.footnote-marker {
    color: #D4AF8F;
    font-family: 'Lora', serif;
    font-size: 0.85em;
    cursor: pointer;
    position: relative;
    transition: color 0.3s ease;
    text-decoration: none;
}

.footnote-marker:hover {
    color: #8B4545;
}

/* --- Footnote Tooltip --- */

.footnote-tooltip {
    position: fixed;
    max-width: 320px;
    background-color: #F9F7F3;
    border: 1px solid rgba(212, 175, 143, 0.5);
    border-left: 3px solid #D4AF8F;
    padding: 1rem 1.2rem;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.8rem;
    line-height: 1.55;
    color: #6B5F4F;
    box-shadow: 0 4px 16px rgba(44, 24, 16, 0.1);
    z-index: 500;
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.footnote-tooltip.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

/* --- Links --- */

a {
    color: #8B4545;
    text-decoration: none;
    transition: background-color 0.3s ease;
}

a:hover {
    text-decoration: underline;
    background-color: #E8E3D8;
}

/* --- Closing Ornament --- */

.closing-ornament {
    display: flex;
    justify-content: center;
    margin-top: 4rem;
    padding-top: 2rem;
}

/* --- Responsive: Mobile --- */

@media (max-width: 768px) {
    .main-layout {
        flex-direction: column;
    }

    .left-margin {
        width: 100%;
        max-width: 100%;
        min-width: 100%;
        position: relative;
        height: auto;
        padding: 2rem 1.5rem;
        border-right: none;
        border-bottom: 1px solid rgba(212, 175, 143, 0.3);
    }

    .margin-nav {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 1rem;
    }

    .margin-section {
        flex: 1 1 140px;
        padding: 0.5rem;
        border-left: none;
        border-bottom: 2px solid transparent;
        padding-left: 0;
    }

    .margin-section:hover {
        border-left-color: transparent;
        border-bottom-color: #D4AF8F;
    }

    .margin-section.active {
        border-left-color: transparent;
        border-bottom-color: #8B4545;
    }

    .margin-note {
        display: none;
    }

    .margin-ornament {
        display: none;
    }

    .content-column {
        padding: 2rem 1.5rem 4rem 1.5rem;
    }

    .drop-cap {
        font-size: 2.8em;
    }

    h2 {
        font-size: clamp(1.6rem, 5vw, 2.4rem);
    }

    .footnote-tooltip {
        max-width: 260px;
        left: 1rem;
        right: 1rem;
    }

    #scroll-progress {
        top: auto;
        bottom: 0;
        left: 0;
        width: 0%;
        height: 2px;
        background: linear-gradient(to right, #D4AF8F, #8B6F47);
    }
}

/* --- Selection --- */

::selection {
    background-color: rgba(212, 175, 143, 0.3);
    color: #2C1810;
}

/* --- Smooth transitions for all interactive elements --- */

.margin-section,
.footnote-marker,
.pull-quote,
a {
    transition-timing-function: cubic-bezier(0.25, 0.1, 0.25, 1);
}
