/* ============================================================
   cbdc.study -- Classified Dossier Design System
   Colors: #0d1b2a #1b4965 #f0ead2 #fefae0 #5c4033 #a4161a #2b2b2b #dda15e
   Fonts: Libre Bodoni, DM Serif Display, Source Serif 4, IBM Plex Mono, Cormorant Garamond
   ============================================================ */

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

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

body {
    background-color: #f0ead2;
    color: #2b2b2b;
    font-family: 'Source Serif 4', 'Georgia', serif;
    font-size: clamp(0.95rem, 1.5vw, 1.0625rem);
    line-height: 1.72;
    overflow-x: hidden;
}

/* ---- Filing Tab ---- */
#filing-tab {
    position: fixed;
    left: 0;
    top: 0;
    width: 48px;
    height: 100vh;
    background-color: #0d1b2a;
    background-image: repeating-linear-gradient(
        to bottom,
        transparent,
        transparent 6px,
        rgba(27, 73, 101, 0.3) 6px,
        rgba(27, 73, 101, 0.3) 8px
    );
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 24px;
    gap: 20px;
    transform: translateX(-60px);
    transition: transform 0.6s cubic-bezier(0.23, 1, 0.32, 1);
}

#filing-tab.visible {
    transform: translateX(0);
}

.tab-section {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    color: rgba(240, 234, 210, 0.5);
    letter-spacing: 0.03em;
    cursor: pointer;
    transition: color 0.3s ease;
    position: relative;
}

.tab-section.active {
    color: #a4161a;
}

.tab-section.active::before {
    content: '';
    position: absolute;
    left: -12px;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 1px;
    background: #a4161a;
}

.tab-indicator {
    display: none;
}

/* ---- Dossier Index Button ---- */
#dossier-index-btn {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 200;
    background: #0d1b2a;
    color: #f0ead2;
    border: none;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.08em;
    padding: 10px 18px 10px 14px;
    cursor: pointer;
    clip-path: polygon(0 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%);
    transition: background 0.3s ease, color 0.3s ease;
}

#dossier-index-btn:hover {
    background: #a4161a;
    color: #fefae0;
}

/* ---- Dossier Modal ---- */
#dossier-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(13, 27, 42, 0.92);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.4s ease;
}

#dossier-modal.modal-hidden {
    opacity: 0;
    pointer-events: none;
}

#dossier-modal-inner {
    background: #fefae0;
    padding: 48px 56px;
    max-width: 480px;
    width: 90%;
    position: relative;
}

#modal-close {
    position: absolute;
    top: 16px;
    right: 20px;
    background: none;
    border: none;
    font-size: 28px;
    color: #0d1b2a;
    cursor: pointer;
    line-height: 1;
    transition: color 0.3s ease;
}

#modal-close:hover {
    color: #a4161a;
}

.modal-title {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 14px;
    letter-spacing: 0.12em;
    color: #0d1b2a;
    margin-bottom: 32px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(13, 27, 42, 0.15);
}

#modal-nav {
    list-style: none;
}

#modal-nav li {
    margin-bottom: 16px;
}

#modal-nav a {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 14px;
    color: #1b4965;
    text-decoration: none;
    letter-spacing: 0.04em;
    transition: color 0.3s ease;
    display: block;
    padding: 4px 0;
}

#modal-nav a:hover {
    color: #a4161a;
}

/* ---- Cover Section ---- */
.section-cover {
    min-height: 100vh;
    background: #fefae0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    padding-left: 48px;
}

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

.guilloche-watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 500px;
    height: 500px;
    opacity: 0;
    z-index: 1;
    pointer-events: none;
}

.guilloche-watermark.visible {
    opacity: 0.12;
}

.guilloche-svg {
    width: 100%;
    height: 100%;
    animation: guillocheRotate 720s linear infinite;
}

@keyframes guillocheRotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

#site-title {
    font-family: 'Libre Bodoni', serif;
    font-weight: 700;
    font-size: clamp(2.5rem, 5vw, 4.5rem);
    letter-spacing: 0.25em;
    color: #0d1b2a;
    text-shadow: 0 1px 0 rgba(13, 27, 42, 0.08);
    position: relative;
    z-index: 2;
    overflow: hidden;
}

#site-title .letter {
    display: inline-block;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

#site-title .letter.visible {
    opacity: 1;
    transform: translateY(0);
}

#site-subtitle {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.65rem, 1vw, 0.8rem);
    letter-spacing: 0.16em;
    color: #1b4965;
    margin-top: 24px;
    opacity: 0;
    transition: opacity 0.8s ease;
    text-transform: uppercase;
}

#site-subtitle.visible {
    opacity: 1;
}

/* ---- Dossier Sections ---- */
.dossier-section {
    position: relative;
    padding-left: 48px;
    background: #f0ead2;
}

.section-grid {
    display: grid;
    grid-template-columns: 38% 8% 54%;
    min-height: 80vh;
    padding: 80px 40px 80px 20px;
    position: relative;
}

/* Ledger Lines Background */
.content-column {
    background-image: repeating-linear-gradient(
        transparent,
        transparent 27px,
        rgba(13, 27, 42, 0.04) 27px,
        rgba(13, 27, 42, 0.04) 28px
    );
    padding: 20px 0;
}

/* ---- Section Dividers ---- */
.section-divider {
    height: 24px;
    border-top: 1px solid rgba(13, 27, 42, 0.12);
    border-bottom: 1px solid rgba(13, 27, 42, 0.12);
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.6s ease;
}

.section-divider.visible {
    opacity: 1;
}

.divider-guilloche {
    width: 100%;
    height: 100%;
    opacity: 0.06;
}

/* ---- Annotation Margin ---- */
.annotation-margin {
    padding-right: 24px;
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.section-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.1em;
    color: #1b4965;
    text-transform: uppercase;
}

.section-num {
    color: #a4161a;
    font-weight: 400;
    margin-right: 4px;
}

/* ---- Timeline Nodes ---- */
.timeline-node {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    position: relative;
    padding-left: 16px;
}

.node-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    border: 1px solid #a4161a;
    background: transparent;
    flex-shrink: 0;
    margin-top: 4px;
    transition: background 0.4s ease-out;
}

.node-dot.filled {
    background: #a4161a;
}

.node-date {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
    color: #a4161a;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.node-text {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
    color: #1b4965;
    letter-spacing: 0.03em;
    line-height: 1.5;
}

/* Timeline dashed connector */
.timeline-node::before {
    content: '';
    position: absolute;
    left: 18px;
    top: -28px;
    width: 1px;
    height: 28px;
    border-left: 1px dashed rgba(161, 22, 26, 0.3);
}

.timeline-node:first-of-type::before {
    display: none;
}

/* ---- Margin Quotes ---- */
.margin-quote {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-style: italic;
    font-size: clamp(1.1rem, 2vw, 1.5rem);
    color: #5c4033;
    line-height: 1.5;
    padding-left: 16px;
    border-left: 3px solid #5c4033;
    border-left-width: 0;
    transition: border-left-width 0.4s ease-out;
}

.margin-quote.animate-border {
    border-left-width: 3px;
}

.guillemet {
    font-size: 1.4em;
    margin-right: 4px;
    color: #5c4033;
}

/* ---- Mini Charts ---- */
.margin-chart {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mini-chart {
    width: 100%;
    max-width: 140px;
    height: auto;
}

.chart-caption {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    color: #1b4965;
    letter-spacing: 0.02em;
    line-height: 1.4;
}

.chart-line, .chart-area {
    stroke-dasharray: 300;
    stroke-dashoffset: 300;
    transition: stroke-dashoffset 0.8s ease-out;
}

.chart-line.drawn, .chart-area.drawn {
    stroke-dashoffset: 0;
}

/* ---- Gutter Rule ---- */
.gutter-rule {
    display: flex;
    justify-content: center;
}

.gutter-rule::after {
    content: '';
    width: 1px;
    height: 100%;
    background: rgba(27, 73, 101, 0.2);
}

/* ---- Content Column ---- */
.section-heading {
    font-family: 'DM Serif Display', serif;
    font-weight: 400;
    font-size: clamp(1.75rem, 3vw, 2.75rem);
    color: #0d1b2a;
    letter-spacing: 0.04em;
    margin-bottom: 32px;
}

.heading-num {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.6em;
    color: #a4161a;
    margin-right: 8px;
    vertical-align: baseline;
}

.content-column p {
    margin-bottom: 20px;
    text-indent: 2em;
}

.content-column p.body-first {
    text-indent: 0;
}

.content-column p.body-first::first-line {
    font-weight: 600;
}

.content-column p strong {
    font-weight: 600;
    color: #0d1b2a;
}

/* ---- Annotation Reveal Animation ---- */
.annotation-reveal {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}

.annotation-reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ---- Redaction Bars ---- */
.redaction-bar {
    position: relative;
    margin: 24px 0;
    padding: 12px 16px;
    cursor: pointer;
    text-indent: 0;
}

.redacted-text {
    font-family: 'IBM Plex Mono', monospace;
    font-style: italic;
    font-size: 13px;
    color: #2b2b2b;
    line-height: 1.6;
    letter-spacing: 0.02em;
}

.redaction-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #a4161a;
    opacity: 0.85;
    transition: clip-path 0.6s ease-out;
    clip-path: inset(0 0 0 0);
}

.redaction-bar:hover .redaction-overlay {
    clip-path: inset(0 0 0 100%);
}

/* ---- Dark Section (Conclusion) ---- */
.section-dark {
    background-color: #0d1b2a;
    color: #f0ead2;
    position: relative;
    overflow: hidden;
}

.section-dark .content-column {
    background-image: repeating-linear-gradient(
        transparent,
        transparent 27px,
        rgba(240, 234, 210, 0.04) 27px,
        rgba(240, 234, 210, 0.04) 28px
    );
}

.section-heading-dark {
    color: #f0ead2;
}

.heading-num-dark {
    color: #dda15e;
}

.section-num-dark {
    color: #dda15e;
}

.section-dark .section-label {
    color: #dda15e;
}

.section-dark .node-date {
    color: #dda15e;
}

.section-dark .node-text {
    color: rgba(240, 234, 210, 0.7);
}

.node-dot-dark {
    border-color: #dda15e;
}

.node-dot-dark.filled {
    background: #dda15e;
}

.section-dark .timeline-node::before {
    border-left-color: rgba(221, 161, 94, 0.3);
}

.margin-quote-dark {
    color: #dda15e;
    border-left-color: #dda15e;
}

.margin-quote-dark .guillemet {
    color: #dda15e;
}

.gutter-rule-dark::after {
    background: rgba(221, 161, 94, 0.2);
}

.section-dark .content-column p {
    color: #f0ead2;
}

.section-divider-dark {
    border-top-color: rgba(221, 161, 94, 0.12);
    border-bottom-color: rgba(221, 161, 94, 0.12);
}

.redaction-bar-dark .redacted-text {
    color: #f0ead2;
}

.redaction-overlay-dark {
    background: #dda15e;
}

.guilloche-conclusion {
    opacity: 0.08;
    width: 700px;
    height: 700px;
}

/* ---- Dossier Stamp ---- */
.dossier-stamp {
    margin-top: 60px;
    font-family: 'Libre Bodoni', serif;
    font-weight: 700;
    font-size: 24px;
    letter-spacing: 0.2em;
    color: #dda15e;
    text-align: center;
    padding: 24px;
    border: 2px solid rgba(221, 161, 94, 0.3);
    display: inline-block;
}

.stamp-sub {
    display: block;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    font-weight: 400;
    letter-spacing: 0.12em;
    margin-top: 8px;
    color: rgba(221, 161, 94, 0.6);
}

/* ---- Mobile Styles ---- */
@media (max-width: 768px) {
    #filing-tab {
        width: 100%;
        height: 36px;
        flex-direction: row;
        padding: 0 12px;
        gap: 12px;
        align-items: center;
        top: 0;
        left: 0;
    }

    #filing-tab.visible {
        transform: translateX(0) translateY(0);
    }

    .tab-section.active::before {
        left: auto;
        bottom: -4px;
        top: auto;
        transform: none;
        width: 100%;
        height: 1px;
    }

    .section-cover {
        padding-left: 0;
        padding-top: 48px;
    }

    .dossier-section {
        padding-left: 0;
    }

    .section-grid {
        grid-template-columns: 1fr;
        padding: 40px 20px;
        gap: 32px;
    }

    .gutter-rule {
        display: none;
    }

    .annotation-margin {
        padding-right: 0;
        padding-bottom: 24px;
        border-bottom: 1px solid rgba(13, 27, 42, 0.1);
    }

    #dossier-index-btn {
        top: 44px;
        right: 8px;
        font-size: 10px;
        padding: 6px 12px 6px 10px;
    }

    .guilloche-watermark {
        width: 300px;
        height: 300px;
    }

    .guilloche-conclusion {
        width: 400px;
        height: 400px;
    }
}

/* ---- Reduced Motion ---- */
@media (prefers-reduced-motion: reduce) {
    .guilloche-svg {
        animation: none;
    }

    .annotation-reveal {
        transform: none;
    }

    .redaction-overlay {
        transition: opacity 0.3s ease;
    }

    .redaction-bar:hover .redaction-overlay {
        clip-path: inset(0);
        opacity: 0;
    }
}
