/* ============================================
   cbdc.study — Styles
   Dark-academia research dossier aesthetic
   ============================================ */

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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    background: #0b0e13;
    color: #b8ad98;
    font-family: 'Newsreader', Georgia, serif;
    font-weight: 300;
    font-size: clamp(15px, 1.6vw, 19px);
    line-height: 1.85;
    letter-spacing: 0.01em;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ---- Opening Spread / Hero ---- */
.hero-spread {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #0b0e13;
    overflow: hidden;
}

.hero-content {
    text-align: center;
    position: relative;
    z-index: 2;
}

.hero-title {
    font-family: 'Cormorant Garamond', 'Times New Roman', serif;
    font-weight: 700;
    font-size: clamp(40px, 8vw, 96px);
    letter-spacing: 0.12em;
    color: #d4c5a0;
    text-transform: uppercase;
    line-height: 1.1;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 800ms ease, transform 800ms ease;
}

.hero-title.visible {
    opacity: 1;
    transform: translateY(0);
}

.hero-rule {
    position: relative;
    width: 0%;
    height: 1px;
    background: #c9a84c;
    margin: 30px auto;
    transition: width 1800ms ease-in-out;
}

.hero-rule.visible {
    width: 60%;
}

.hero-rule .rule-diamond {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(45deg);
    width: 8px;
    height: 8px;
    border: 1px solid #c9a84c;
    background: #0b0e13;
    opacity: 0;
    transition: opacity 400ms ease 1600ms;
}

.hero-rule.visible .rule-diamond {
    opacity: 1;
}

.hero-subtitle {
    font-family: 'Newsreader', Georgia, serif;
    font-weight: 300;
    font-style: italic;
    font-size: 18px;
    color: #8a7d6a;
    max-width: 600px;
    margin: 0 auto;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 600ms ease, transform 600ms ease;
}

.hero-subtitle.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Scroll Chevron */
.scroll-chevron {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 400ms ease;
    cursor: pointer;
}

.scroll-chevron.visible {
    animation: chevronPulse 2000ms ease-in-out infinite;
}

@keyframes chevronPulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.7; }
}

/* ---- Timeline Spine ---- */
.timeline-spine {
    position: fixed;
    right: 30px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    opacity: 0;
    transition: opacity 600ms ease;
}

.timeline-spine.visible {
    opacity: 1;
}

.timeline-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    background: rgba(201, 168, 76, 0.15);
}

.timeline-node {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid #c9a84c;
    background: #0b0e13;
    cursor: pointer;
    position: relative;
    z-index: 2;
    margin: 20px 0;
    transition: background 600ms ease, box-shadow 600ms ease;
    padding: 0;
    outline: none;
}

.timeline-node.filled {
    background: radial-gradient(circle at center, #c9a84c, #8a6d2f);
    box-shadow: 0 0 8px rgba(201, 168, 76, 0.3);
}

.timeline-node:hover {
    box-shadow: 0 0 12px rgba(201, 168, 76, 0.4);
}

/* ---- Chapter Spread Layout ---- */
.spread {
    position: relative;
    width: 100%;
    min-height: 100vh;
}

.chapter {
    display: grid;
    grid-template-columns: 55% 45%;
    min-height: 100vh;
    position: relative;
}

/* Vertical hairline divider */
.chapter-hairline {
    position: absolute;
    left: 55%;
    top: 0;
    bottom: 0;
    width: 1px;
    background: rgba(201, 168, 76, 0.15);
    z-index: 1;
    transition: background 600ms ease;
}

.chapter.in-view .chapter-hairline {
    background: rgba(201, 168, 76, 0.15);
}

/* Watermark chapter numerals */
.chapter-watermark {
    position: absolute;
    left: 3vw;
    top: 50%;
    transform: translateY(-50%);
    font-family: 'Cormorant Garamond', serif;
    font-weight: 700;
    font-size: clamp(80px, 12vw, 160px);
    color: rgba(201, 168, 76, 0.06);
    line-height: 1;
    pointer-events: none;
    z-index: 0;
    user-select: none;
}

/* Text Column */
.chapter-text-col {
    position: relative;
    padding: 10vh 6vw 10vh 8vw;
    z-index: 2;
}

.chapter-title {
    font-family: 'Cormorant Garamond', 'Times New Roman', serif;
    font-weight: 600;
    font-size: clamp(28px, 5vw, 64px);
    letter-spacing: 0.08em;
    color: #d4c5a0;
    text-transform: uppercase;
    line-height: 1.1;
    margin-bottom: 40px;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 500ms ease, transform 500ms ease;
}

.chapter.in-view .chapter-title {
    opacity: 1;
    transform: translateY(0);
}

.chapter-body {
    margin-bottom: 24px;
    color: #b8ad98;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 500ms ease, transform 500ms ease;
}

.chapter.in-view .chapter-body {
    opacity: 1;
    transform: translateY(0);
}

/* Staggered paragraph animation */
.chapter.in-view .chapter-body:nth-child(2) { transition-delay: 0ms; }
.chapter.in-view .chapter-body:nth-child(3) { transition-delay: 150ms; }
.chapter.in-view .chapter-body:nth-child(4) { transition-delay: 300ms; }
.chapter.in-view .chapter-body:nth-child(5) { transition-delay: 450ms; }
.chapter.in-view .chapter-body:nth-child(6) { transition-delay: 600ms; }

/* Visual Column */
.chapter-visual-col {
    position: relative;
    padding: 6vh 6vw 6vh 4vw;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Ledger Grid Underlay */
.ledger-grid {
    position: absolute;
    inset: 0;
    background:
        repeating-linear-gradient(
            to right,
            #1a2030 0px,
            #1a2030 1px,
            transparent 1px,
            transparent 40px
        ),
        repeating-linear-gradient(
            to bottom,
            #1a2030 0px,
            #1a2030 1px,
            transparent 1px,
            transparent 24px
        );
    opacity: 0.5;
    pointer-events: none;
}

/* SVG Diagrams */
.chapter-diagram {
    width: 100%;
    max-width: 400px;
    height: auto;
    position: relative;
    z-index: 2;
}

/* Path draw animation */
.draw-path {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 2500ms ease-in-out;
}

.chapter.in-view .draw-path,
.concluding-spread.in-view .draw-path {
    stroke-dashoffset: 0;
}

/* Diagram nodes */
.diagram-node {
    transition: transform 400ms ease, filter 400ms ease;
    transform-origin: center;
}

.diagram-node:hover {
    transform: scale(1.15);
    filter: drop-shadow(0 0 6px rgba(201, 168, 76, 0.2));
}

/* ---- Marginalia Annotations ---- */
.marginalia {
    position: absolute;
    z-index: 10;
    cursor: default;
    transition: color 300ms ease, transform 300ms ease;
}

.marginalia[data-rotation="-2"] { transform: rotate(-2deg); }
.marginalia[data-rotation="-3"] { transform: rotate(-3deg); }
.marginalia[data-rotation="-4"] { transform: rotate(-4deg); }
.marginalia[data-rotation="-5"] { transform: rotate(-5deg); }

.marginalia-text {
    font-family: 'DM Mono', monospace;
    font-weight: 300;
    font-size: 10px;
    color: #7a8fa6;
    letter-spacing: 0.04em;
    white-space: nowrap;
    display: block;
    transition: color 300ms ease, transform 300ms ease;
}

.marginalia .leader-line {
    display: block;
    margin-top: 2px;
}

.marginalia:hover .marginalia-text {
    color: #c9a84c;
}

.marginalia:hover {
    transform: scale(1.05) rotate(-2deg);
}

/* Marginalia reveal animation */
.marginalia {
    opacity: 0;
    transition: opacity 400ms ease, color 300ms ease, transform 300ms ease;
}

.chapter.in-view .marginalia {
    opacity: 1;
    transition-delay: 800ms;
}

/* ---- Brass Rule Separators ---- */
.brass-rule-separator {
    position: relative;
    width: 0%;
    max-width: 80%;
    height: 1px;
    background: #c9a84c;
    margin: 0 auto;
    transition: width 1200ms ease-in-out;
}

.brass-rule-separator.visible {
    width: 80%;
}

.brass-rule-separator .rule-diamond {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(45deg);
    width: 8px;
    height: 8px;
    border: 1px solid #c9a84c;
    background: #0b0e13;
}

/* ---- Concluding Spread ---- */
.concluding-spread {
    background: #111621;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10vh 5vw;
    min-height: 100vh;
}

.concluding-text {
    max-width: 680px;
    margin: 0 auto 60px;
}

.concluding-title {
    font-family: 'Cormorant Garamond', 'Times New Roman', serif;
    font-weight: 600;
    font-size: clamp(28px, 5vw, 64px);
    letter-spacing: 0.08em;
    color: #d4c5a0;
    text-transform: uppercase;
    line-height: 1.1;
    margin-bottom: 40px;
    text-align: center;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 500ms ease, transform 500ms ease;
}

.concluding-spread.in-view .concluding-title {
    opacity: 1;
    transform: translateY(0);
}

.concluding-body {
    margin-bottom: 24px;
    color: #b8ad98;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 500ms ease, transform 500ms ease;
}

.concluding-spread.in-view .concluding-body {
    opacity: 1;
    transform: translateY(0);
}

.concluding-spread.in-view .concluding-body:nth-child(2) { transition-delay: 0ms; }
.concluding-spread.in-view .concluding-body:nth-child(3) { transition-delay: 150ms; }
.concluding-spread.in-view .concluding-body:nth-child(4) { transition-delay: 300ms; }
.concluding-spread.in-view .concluding-body:nth-child(5) { transition-delay: 450ms; }

.concluding-diagram {
    width: 100%;
    max-width: 680px;
    margin: 0 auto;
}

#diagram-conclusion {
    width: 100%;
    height: auto;
}

/* ---- Data / Annotation Typography ---- */
.data-text {
    font-family: 'DM Mono', monospace;
    font-weight: 300;
    font-size: clamp(11px, 1.2vw, 14px);
    letter-spacing: 0.04em;
    color: #7a8fa6;
}

/* ---- Diagram Stroke Color ---- */
.chapter-diagram line,
.chapter-diagram path,
.chapter-diagram rect {
    stroke: #3d5a73;
}

/* ---- Selection ---- */
::selection {
    background: rgba(201, 168, 76, 0.25);
    color: #d4c5a0;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: #0b0e13;
}

::-webkit-scrollbar-thumb {
    background: rgba(201, 168, 76, 0.2);
    border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(201, 168, 76, 0.4);
}

/* ---- Responsive ---- */
@media (max-width: 900px) {
    .chapter {
        grid-template-columns: 1fr;
        min-height: auto;
    }

    .chapter-hairline {
        display: none;
    }

    .chapter-watermark {
        font-size: clamp(60px, 20vw, 120px);
        left: 5vw;
    }

    .chapter-text-col {
        padding: 6vh 6vw;
    }

    .chapter-visual-col {
        padding: 4vh 6vw;
    }

    .marginalia {
        position: relative;
        top: auto !important;
        left: auto !important;
        display: block;
        margin: 16px 0;
        transform: none !important;
    }

    .marginalia .leader-line {
        display: none;
    }

    .timeline-spine {
        right: 10px;
    }

    .timeline-node {
        width: 8px;
        height: 8px;
        margin: 12px 0;
    }
}

@media (max-width: 600px) {
    .hero-subtitle {
        font-size: 15px;
        padding: 0 20px;
    }

    .timeline-spine {
        display: none;
    }

    .concluding-text {
        padding: 0 4vw;
    }
}
