/* economic.wiki - Sepia Glassmorphism Horizontal Scroll */

/* ==================== RESET & BASE ==================== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    overflow: hidden;
    height: 100%;
}

body {
    background: #F5EBD8;
    color: #3B2A1A;
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.72;
    letter-spacing: 0.005em;
    overflow: hidden;
    height: 100%;
    width: 100%;
}

::selection {
    background: #E8D5A8;
    color: #3B2A1A;
}

/* ==================== PROGRESS BAR ==================== */
.progress-bar-track {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: #E8D5A8;
    z-index: 100;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: #8B6914;
    transition: width 0.3s ease-out;
}

.chapter-indicators {
    position: absolute;
    top: -3px;
    left: 0;
    right: 0;
    height: 9px;
    display: flex;
    justify-content: space-evenly;
    align-items: center;
    pointer-events: none;
}

.chapter-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #E8D5A8;
    border: 1.5px solid #9E7C52;
    transition: background 0.3s, transform 0.3s;
    pointer-events: auto;
    cursor: pointer;
}

.chapter-dot.active {
    background: #8B6914;
    border-color: #8B6914;
    transform: scale(1.3);
}

/* ==================== TOC TOGGLE ==================== */
.toc-toggle {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 110;
    background: rgba(245, 235, 218, 0.7);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(180, 155, 110, 0.3);
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    transition: background 0.3s, transform 0.3s;
}

.toc-toggle:hover {
    background: rgba(245, 235, 218, 0.9);
    transform: scale(1.05);
}

/* ==================== TOC OVERLAY ==================== */
.toc-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(42, 27, 14, 0.4);
    backdrop-filter: blur(8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s;
}

.toc-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.toc-panel {
    background: rgba(245, 235, 218, 0.85);
    backdrop-filter: blur(20px) saturate(140%);
    border: 1px solid rgba(180, 155, 110, 0.3);
    border-radius: 16px;
    padding: 48px;
    max-width: 420px;
    width: 90%;
    transform: scale(0.9);
    transition: transform 0.4s;
}

.toc-overlay.open .toc-panel {
    transform: scale(1);
}

.toc-title {
    font-family: 'Fraunces', Georgia, serif;
    font-weight: 700;
    font-size: clamp(1.5rem, 3vw, 2rem);
    color: #3B2A1A;
    margin-bottom: 24px;
    letter-spacing: -0.02em;
}

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

.toc-list li {
    margin-bottom: 16px;
}

.toc-link {
    font-family: 'Caveat', cursive;
    font-size: clamp(1.1rem, 1.5vw, 1.4rem);
    color: #5C3D21;
    text-decoration: none;
    cursor: pointer;
    transition: color 0.2s;
    display: block;
    padding: 4px 0;
}

.toc-link:hover {
    color: #8B6914;
}

/* ==================== PARTICLE CANVAS ==================== */
#particleCanvas {
    position: fixed;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    width: 100%;
    height: 100%;
}

/* ==================== CHAPTERS CONTAINER ==================== */
.chapters-container {
    display: flex;
    flex-direction: row;
    overflow-x: scroll;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    height: 100vh;
    width: 100vw;
    z-index: 1;
    position: relative;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.chapters-container::-webkit-scrollbar {
    display: none;
}

/* ==================== CHAPTER ==================== */
.chapter {
    min-width: 100vw;
    height: 100vh;
    scroll-snap-align: start;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* ==================== CHAPTER BACKGROUND ==================== */
.chapter-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    overflow: hidden;
}

.bg-illustration {
    position: absolute;
    width: 80%;
    height: 80%;
    top: 10%;
    left: 10%;
    opacity: 0;
    transition: opacity 0.8s;
}

.chapter.visible .bg-illustration {
    opacity: 0.5;
}

#chapter-1.visible .bg-illustration {
    opacity: 0.7;
}

/* ==================== WATERMARKS ==================== */
.watermark {
    position: absolute;
    font-size: clamp(6rem, 12vw, 14rem);
    color: #3B2A1A;
    opacity: 0.06;
    font-family: Georgia, serif;
    pointer-events: none;
    user-select: none;
}

/* ==================== CHAPTER DIVIDER ==================== */
.chapter-divider {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 20px;
    z-index: 3;
}

.chapter-divider svg {
    height: 100%;
}

/* ==================== GLASS PANEL ==================== */
.glass-panel {
    position: relative;
    z-index: 5;
    background: rgba(245, 235, 218, 0.55);
    backdrop-filter: blur(16px) saturate(140%);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
    border: 1px solid rgba(180, 155, 110, 0.3);
    border-radius: 12px;
    padding: clamp(24px, 4vw, 48px);
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s, transform 0.6s;
}

.chapter.visible .glass-panel {
    opacity: 1;
    transform: translateY(0);
}

/* ==================== WELCOME PANEL ==================== */
.welcome-panel {
    position: absolute;
    bottom: 15%;
    left: 8%;
    max-width: 55%;
    padding: clamp(32px, 5vw, 60px);
}

.welcome-title {
    font-family: 'Fraunces', Georgia, serif;
    font-weight: 700;
    font-size: clamp(3rem, 7vw, 5.5rem);
    letter-spacing: -0.02em;
    color: #3B2A1A;
    line-height: 1.1;
    margin-bottom: 12px;
}

.welcome-subtitle {
    font-family: 'Caveat', cursive;
    font-size: clamp(1.1rem, 2vw, 1.6rem);
    color: #9E7C52;
    font-weight: 400;
    margin-bottom: 16px;
    opacity: 0;
    transition: opacity 0.6s 0.6s;
}

.chapter.visible .welcome-subtitle {
    opacity: 1;
}

.quill-flourish {
    width: clamp(150px, 30vw, 300px);
    height: auto;
    display: block;
    margin-top: 8px;
}

.flourish-path {
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    transition: stroke-dashoffset 1.2s 0.8s;
}

.chapter.visible .flourish-path {
    stroke-dashoffset: 0;
}

/* ==================== CONCEPT PANELS ==================== */
.concept-panel {
    position: absolute;
    max-width: 48%;
    padding: clamp(28px, 4vw, 48px);
}

.concept-panel.upper-right {
    top: 12%;
    right: 10%;
}

.concept-panel.center-left {
    top: 50%;
    left: 8%;
    transform: translateY(-50%) translateY(20px);
}

.chapter.visible .concept-panel.center-left {
    transform: translateY(-50%) translateY(0);
}

.concept-panel.lower-left {
    bottom: 12%;
    left: 8%;
}

.chapter-number {
    font-family: 'Fraunces', Georgia, serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.5vw, 1.3rem);
    color: #8B6914;
    display: block;
    margin-bottom: 8px;
    letter-spacing: 0.05em;
}

.chapter-title {
    font-family: 'Fraunces', Georgia, serif;
    font-weight: 700;
    font-size: clamp(2.5rem, 6vw, 5rem);
    letter-spacing: -0.02em;
    color: #3B2A1A;
    line-height: 1.1;
    margin-bottom: 20px;
}

.concept-panel .chapter-title {
    font-size: clamp(1.8rem, 4vw, 3.2rem);
}

.chapter-body p {
    margin-bottom: 16px;
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 400;
    color: #3B2A1A;
}

.chapter-body p:last-child {
    margin-bottom: 0;
}

/* ==================== MARGIN NOTES ==================== */
.margin-note {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid rgba(180, 155, 110, 0.3);
}

.annotation {
    font-family: 'Caveat', cursive;
    font-size: clamp(0.85rem, 1vw, 1.05rem);
    color: #9E7C52;
    font-weight: 400;
    line-height: 1.5;
}

/* ==================== DATA CALLOUT ==================== */
.data-callout {
    margin-top: 16px;
    padding: 12px 16px;
    background: rgba(42, 27, 14, 0.06);
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.data-label {
    font-family: 'Caveat', cursive;
    font-size: 0.85rem;
    color: #9E7C52;
    font-weight: 700;
}

.data-value {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.8rem, 0.9vw, 1rem);
    font-weight: 500;
    color: #5C3D21;
    letter-spacing: 0.02em;
}

/* ==================== FOOTER ==================== */
.site-footer {
    display: none;
}

/* ==================== RESPONSIVE: VERTICAL MODE ==================== */
@media (max-width: 768px) {
    html {
        overflow: auto;
    }

    body {
        overflow: auto;
        height: auto;
    }

    .chapters-container {
        flex-direction: column;
        overflow-x: hidden;
        overflow-y: auto;
        scroll-snap-type: y mandatory;
        height: auto;
        width: 100%;
    }

    .chapter {
        min-width: 100%;
        min-height: 100vh;
        height: auto;
        scroll-snap-align: start;
        flex-direction: column;
        padding: 16px;
    }

    .glass-panel {
        position: relative;
        max-width: 100%;
        width: 100%;
        top: auto;
        bottom: auto;
        left: auto;
        right: auto;
        margin: auto;
    }

    .welcome-panel {
        position: relative;
        bottom: auto;
        left: auto;
        max-width: 100%;
    }

    .concept-panel.upper-right,
    .concept-panel.center-left,
    .concept-panel.lower-left {
        position: relative;
        top: auto;
        bottom: auto;
        left: auto;
        right: auto;
        max-width: 100%;
        transform: none;
    }

    .chapter.visible .concept-panel.center-left {
        transform: none;
    }

    .chapter-divider {
        display: none;
    }

    .bg-illustration {
        width: 100%;
        height: 60%;
        top: 5%;
        left: 0;
        opacity: 0.3;
    }

    .margin-note {
        padding: 12px;
        background: rgba(245, 235, 218, 0.4);
        border-radius: 8px;
        border-top: none;
    }

    .progress-bar-track {
        display: none;
    }

    .toc-toggle {
        top: 12px;
        right: 12px;
    }

    .site-footer {
        display: block;
        background: #2A1B0E;
        padding: 40px 24px;
        text-align: center;
    }

    .footer-content {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .footer-title {
        font-family: 'Fraunces', Georgia, serif;
        font-weight: 700;
        font-size: 1.2rem;
        color: #F5EBD8;
    }

    .footer-note {
        font-family: 'Caveat', cursive;
        font-size: 0.95rem;
        color: #9E7C52;
    }
}

/* ==================== LARGE SCREEN MARGIN NOTES ==================== */
@media (min-width: 1400px) {
    .concept-panel {
        display: grid;
        grid-template-columns: 1fr 25%;
        grid-template-rows: auto auto 1fr auto;
        gap: 0 24px;
    }

    .chapter-number {
        grid-column: 1;
    }

    .chapter-title {
        grid-column: 1;
    }

    .chapter-body {
        grid-column: 1;
    }

    .margin-note {
        grid-column: 2;
        grid-row: 1 / -1;
        border-top: none;
        border-left: 1px solid rgba(180, 155, 110, 0.3);
        padding-top: 0;
        padding-left: 20px;
        margin-top: 0;
        display: flex;
        align-items: center;
    }

    .data-callout {
        grid-column: 1;
    }
}
