/* ============================================
   economic.day — Maximalist Economic Manuscript
   ============================================ */

:root {
    --bg-primary: #f4ece0;
    --bg-secondary: #e8dcc8;
    --text-primary: #2c1810;
    --accent-gold: #c4a267;
    --accent-indigo: #2d3a5c;
    --accent-verdigris: #5b7c6a;
    --shadow-warm: #8c5e3c;
    --highlight-amber: #e8a94a;
    --cursor-x: 50vw;
    --cursor-y: 50vh;
}

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

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

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 400;
    line-height: 1.75;
    overflow-x: hidden;
    position: relative;
}

/* ---- Grain Overlay ---- */
.grain-overlay {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.035;
    mix-blend-mode: multiply;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 256px 256px;
}

/* ---- Cursor Lamp Orb ---- */
.cursor-lamp {
    position: fixed;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(232, 169, 74, 0.15) 0%, transparent 70%);
    left: var(--cursor-x);
    top: var(--cursor-y);
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 9998;
    transition: left 0.2s ease-out, top 0.2s ease-out;
    opacity: 0;
}

.cursor-lamp.visible {
    opacity: 1;
}

/* ---- Ledger Background Lines ---- */
.ledger-bg {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background-image: repeating-linear-gradient(
        to bottom,
        transparent,
        transparent calc(2rem - 1px),
        rgba(196, 162, 103, 0.08) calc(2rem - 1px),
        rgba(196, 162, 103, 0.08) 2rem
    );
}

/* ---- Manuscript Grid Rules (decorative vertical lines) ---- */
.manuscript-grid-rules {
    position: fixed;
    inset: 0;
    display: grid;
    grid-template-columns: repeat(11, 1fr);
    max-width: 1440px;
    margin: 0 auto;
    left: 0;
    right: 0;
    pointer-events: none;
    z-index: 0;
    padding: 0 clamp(1rem, 3vw, 4rem);
}

.grid-rule {
    border-right: 1px solid rgba(196, 162, 103, 0.12);
    height: 100%;
}

/* ---- Chapter Navigation ---- */
.chapter-nav {
    position: fixed;
    left: 1.5vw;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    z-index: 100;
}

.chapter-nav-link {
    font-family: 'DM Sans', sans-serif;
    font-weight: 500;
    font-size: clamp(0.7rem, 0.85vw, 0.9rem);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--text-primary);
    opacity: 0.3;
    text-decoration: none;
    transition: color 0.6s ease, opacity 0.6s ease;
    writing-mode: horizontal-tb;
}

.chapter-nav-link.active {
    color: var(--highlight-amber);
    opacity: 1;
}

/* ---- Content Grid ---- */
.content-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-template-rows: auto;
    gap: 0;
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 clamp(1rem, 3vw, 4rem);
    position: relative;
}

/* ---- Chapters ---- */
.chapter {
    position: relative;
    padding: clamp(4rem, 10vh, 8rem) 0;
    min-height: 100vh;
    overflow: visible;
}

/* ---- Ghost Numerals ---- */
.ghost-numeral {
    position: absolute;
    font-family: 'Playfair Display', Georgia, serif;
    font-style: italic;
    font-weight: 700;
    font-size: clamp(6rem, 15vw, 14rem);
    color: var(--accent-gold);
    opacity: 0.06;
    z-index: 0;
    pointer-events: none;
    top: 10%;
    left: 5%;
    transform: rotate(-3deg);
    line-height: 1;
}

.ghost-numeral.drift {
    animation: ghostDrift 20s ease-in-out infinite;
}

@keyframes ghostDrift {
    0%, 100% { transform: rotate(-3deg) translateY(0); }
    50% { transform: rotate(-3deg) translateY(-5px); }
}

/* ---- Hero Title ---- */
.hero-title {
    grid-column: 1 / 13;
    padding-top: clamp(2rem, 8vh, 6rem);
    padding-bottom: 2rem;
}

.hero-line-1 {
    display: block;
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 700;
    font-style: italic;
    font-size: clamp(3.5rem, 10vw, 9rem);
    letter-spacing: -0.02em;
    color: var(--accent-indigo);
    line-height: 1.05;
}

.hero-line-2 {
    display: block;
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 700;
    font-style: italic;
    font-size: clamp(3.5rem, 10vw, 9rem);
    letter-spacing: -0.02em;
    color: var(--accent-indigo);
    line-height: 1.05;
    margin-left: 33.33%;
}

.hero-intro {
    grid-column: 2 / 9;
    padding: 2rem 0;
    font-size: clamp(1rem, 1.3vw, 1.25rem);
}

.hero-intro p {
    max-width: 65ch;
}

/* ---- Chapter Titles ---- */
.chapter-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 700;
    font-style: italic;
    font-size: clamp(2rem, 5vw, 4.5rem);
    letter-spacing: -0.02em;
    color: var(--accent-indigo);
    margin-bottom: 1.5rem;
    line-height: 1.15;
}

/* ---- Content Blocks ---- */
.content-block {
    position: relative;
    z-index: 2;
    padding: clamp(1.5rem, 3vw, 2.5rem);
    background-color: var(--bg-primary);
}

.content-block p {
    font-size: clamp(1rem, 1.3vw, 1.25rem);
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 400;
    letter-spacing: 0.01em;
    line-height: 1.75;
    margin-bottom: 1.25rem;
}

.content-block p:last-child {
    margin-bottom: 0;
}

/* Overlapping block backgrounds */
.block-overlap-1,
.block-overlap-3 {
    background-color: var(--bg-primary);
}

.block-overlap-2 {
    background-color: var(--bg-secondary);
    z-index: 3;
}

.block-weather-1 { background-color: var(--bg-primary); z-index: 2; }
.block-weather-2 { background-color: var(--bg-secondary); z-index: 3; }
.block-weather-3 { background-color: var(--bg-primary); z-index: 4; }
.block-weather-4 { background-color: var(--bg-secondary); z-index: 5; }

/* ---- Ornamental Borders ---- */
.ornamental-border {
    position: relative;
    padding: clamp(1rem, 2vw, 2rem);
}

.ornamental-border::before,
.ornamental-border::after {
    content: '';
    position: absolute;
    width: 24px;
    height: 24px;
    border-color: rgba(196, 162, 103, 0.4);
    border-style: solid;
}

.ornamental-border::before {
    top: 0;
    left: 0;
    border-width: 2px 0 0 2px;
}

.ornamental-border::after {
    bottom: 0;
    right: 0;
    border-width: 0 2px 2px 0;
}

/* ---- Flowing SVG Curves ---- */
.flowing-curve {
    position: absolute;
    width: 100%;
    height: 200px;
    z-index: 1;
    pointer-events: none;
    overflow: visible;
}

.flowing-curve path {
    stroke: var(--accent-gold);
    stroke-width: 1.5;
    fill: none;
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 4s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.flowing-curve.visible path {
    stroke-dashoffset: 0;
}

.curve-1 { top: 45%; left: 0; }
.curve-2 { bottom: 5%; left: 0; }
.curve-3 { bottom: 10%; left: 0; }
.curve-4a { bottom: 15%; left: 0; }
.curve-4b { bottom: 5%; left: 0; }
.curve-5 { bottom: 25%; left: 0; }

/* ---- Section Dividers ---- */
.section-divider {
    position: relative;
    width: 100%;
    height: 80px;
    overflow: visible;
}

.divider-curve {
    width: 100%;
    height: 80px;
}

.divider-curve path {
    stroke: var(--accent-gold);
    stroke-width: 1.5;
    fill: none;
}

/* ---- Marginal Notes ---- */
.marginal-note {
    position: absolute;
    font-family: 'EB Garamond', Georgia, serif;
    font-weight: 400;
    font-style: italic;
    font-size: clamp(0.65rem, 0.9vw, 0.85rem);
    letter-spacing: 0.02em;
    color: var(--accent-verdigris);
    opacity: 0.6;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    pointer-events: none;
    z-index: 1;
}

/* ---- Annotation Floats (Chapter III) ---- */
.annotation-float {
    position: absolute;
    width: clamp(160px, 18vw, 240px);
    font-family: 'EB Garamond', Georgia, serif;
    font-style: italic;
    font-size: clamp(0.8rem, 1vw, 0.95rem);
    color: var(--accent-verdigris);
    line-height: 1.6;
    z-index: 3;
}

.annotation-left {
    left: clamp(1rem, 3vw, 4rem);
    top: 30%;
}

.annotation-right {
    right: clamp(1rem, 3vw, 4rem);
    top: 55%;
}

.annotation-float p {
    margin: 0;
}

/* ---- Decorative Numerals (Chapter IV) ---- */
.decorative-numerals {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}

.deco-num {
    position: absolute;
    font-family: 'Playfair Display', Georgia, serif;
    font-style: italic;
    font-weight: 700;
    font-size: clamp(3rem, 8vw, 7rem);
    color: var(--accent-gold);
    opacity: 0.07;
    line-height: 1;
}

/* ---- Chapter V Background Transition ---- */
.chapter-5 {
    background: linear-gradient(
        to bottom,
        var(--bg-primary) 0%,
        var(--bg-secondary) 100%
    );
}

/* ---- Colophon ---- */
.colophon {
    text-align: center;
    padding: 4rem 0 2rem;
    position: relative;
    z-index: 2;
}

.colophon-text {
    font-family: 'DM Sans', sans-serif;
    font-weight: 500;
    font-size: clamp(0.7rem, 0.85vw, 0.9rem);
    text-transform: uppercase;
    letter-spacing: 0.25em;
    color: var(--accent-gold);
}

/* ---- Fade In Animation ---- */
.fade-in {
    opacity: 0;
    transition: opacity 0.8s ease;
}

.fade-in.visible {
    opacity: 1;
}

/* ---- Reduced Motion ---- */
@media (prefers-reduced-motion: reduce) {
    .ghost-numeral.drift {
        animation: none;
    }
    .flowing-curve path {
        stroke-dasharray: none;
        stroke-dashoffset: 0;
        transition: none;
    }
    .fade-in {
        opacity: 1;
        transition: none;
    }
    .cursor-lamp {
        display: none;
    }
    .chapter-nav-link {
        transition: none;
    }
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .chapter-nav {
        left: 0.5vw;
        gap: 1rem;
    }

    .chapter-nav-link {
        font-size: 0.6rem;
    }

    .manuscript-grid-rules {
        display: none;
    }

    .content-block {
        grid-column: 1 / 13 !important;
        transform: none !important;
    }

    .hero-line-2 {
        margin-left: 15%;
    }

    .annotation-float {
        position: relative;
        width: 100%;
        left: auto !important;
        right: auto !important;
        top: auto !important;
        padding: 1rem clamp(1rem, 3vw, 4rem);
    }

    .marginal-note {
        display: none;
    }

    .ghost-numeral {
        font-size: clamp(4rem, 20vw, 8rem);
    }
}
