/* ============================================
   gabs.report — Archival Intelligence Dossier
   ============================================ */

:root {
    --midnight-ink: #111820;
    --dark-slate: #1C2331;
    --archival-gold: #C8A96E;
    --pale-silver: #D4D8DE;
    --muted-steel: #8A9AAE;
    --muted-sage: #6B8F71;
    --copper-wash: #B87333;
    --steel-gray: #5C6B7A;
    --redaction-red: #8B3A3A;
    --deep-black: #0A0E14;
    --dark-rule: #2A3444;
    --section-timing: cubic-bezier(0.4, 0, 0.2, 1);
    --reveal-duration: 600ms;
}

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

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

body {
    background: var(--midnight-ink);
    color: var(--pale-silver);
    font-family: 'Source Serif 4', 'Georgia', serif;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ============================================
   Fixed Header Bar
   ============================================ */
#header-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 48px;
    background: rgba(17, 24, 32, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    border-bottom: 1px solid rgba(200, 169, 110, 0.3);
}

.header-domain {
    font-family: 'Inconsolata', monospace;
    font-size: 14px;
    color: var(--pale-silver);
    letter-spacing: 0.05em;
}

.header-classification {
    font-family: 'Inconsolata', monospace;
    font-size: 12px;
    color: var(--muted-steel);
    letter-spacing: 0.08em;
}

.classification-toggle {
    color: var(--muted-sage);
    cursor: pointer;
    transition: color 0.3s ease;
}

.classification-toggle:hover {
    color: var(--copper-wash);
}

/* ============================================
   Dossier Frame
   ============================================ */
#dossier-frame {
    position: relative;
    margin-top: 48px;
    border: 12px solid var(--dark-slate);
    min-height: calc(100vh - 48px);
    opacity: 0;
    transition: opacity 1.5s var(--section-timing);
}

#dossier-frame.frame-visible {
    opacity: 1;
}

#dossier-inner {
    position: relative;
    border: 1px dashed var(--steel-gray);
    margin: 8px;
    min-height: calc(100vh - 48px - 40px);
}

/* ============================================
   Opening Screen
   ============================================ */
.opening-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 48px - 42px);
    position: relative;
    overflow: hidden;
}

.opening-line {
    width: 100%;
    height: 2px;
    position: absolute;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
}

.opening-line line {
    stroke-dasharray: 1200;
    stroke-dashoffset: 1200;
}

.opening-line.animate line {
    animation: drawLine 1.2s var(--section-timing) forwards;
}

@keyframes drawLine {
    from {
        stroke-dashoffset: 1200;
        x1: 600;
        x2: 600;
    }
    to {
        stroke-dashoffset: 0;
        x1: 0;
        x2: 1200;
    }
}

.opening-title {
    font-family: 'Stint Ultra Expanded', serif;
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 400;
    color: var(--archival-gold);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    opacity: 0;
    position: relative;
    z-index: 1;
    transition: opacity 0.8s ease;
}

.opening-title.visible {
    opacity: 1;
}

.opening-subtitle {
    font-family: 'Inconsolata', monospace;
    font-size: 12px;
    color: var(--muted-sage);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    margin-top: 16px;
    opacity: 0;
    position: relative;
    z-index: 1;
    transition: opacity 0.8s ease;
}

.opening-subtitle.visible {
    opacity: 1;
}

/* ============================================
   Section Page Breaks
   ============================================ */
.section-page-break {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 30px 0;
    position: relative;
}

.page-break-line {
    width: 100%;
    background: var(--steel-gray);
}

.page-break-line.thin {
    height: 0.5px;
}

.page-break-line.thick {
    height: 2px;
}

.page-break-number {
    font-family: 'Inconsolata', monospace;
    font-size: 11px;
    color: var(--steel-gray);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 4px 12px;
}

/* ============================================
   Dossier Sections
   ============================================ */
.dossier-section {
    min-height: 90vh;
    padding: 0 24px 60px;
    position: relative;
}

/* Ruled line background */
.ruled-lines-bg {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 0;
    background-image:
        repeating-linear-gradient(
            to bottom,
            transparent,
            transparent 23px,
            var(--dark-rule) 23px,
            var(--dark-rule) 23.5px
        );
    background-size: 100% 24px;
    opacity: 0.4;
}

/* Every 5th line emphasis handled by overlaying a second pattern */
.ruled-lines-bg::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        repeating-linear-gradient(
            to bottom,
            transparent,
            transparent 119px,
            var(--dark-rule) 119px,
            var(--dark-rule) 120px
        );
    background-size: 100% 120px;
    opacity: 0.6;
}

/* ============================================
   Section Spread (Two-Column Layout)
   ============================================ */
.section-spread {
    display: flex;
    gap: 0;
    position: relative;
    min-height: 70vh;
}

.spread-left {
    width: 38%;
    padding: 20px 24px 20px 20px;
    border-left: 6px solid var(--archival-gold);
    position: relative;
    flex-shrink: 0;
}

/* Left border animation */
.spread-left .left-border-accent {
    display: none; /* The border-left on .spread-left itself handles this */
}

/* Animated left border */
.spread-left {
    border-left-color: transparent;
}

.dossier-section.revealed .spread-left {
    animation: drawBorder 0.8s ease-in-out forwards;
}

@keyframes drawBorder {
    from {
        border-left-color: var(--archival-gold);
        clip-path: inset(0 0 100% 0);
    }
    to {
        border-left-color: var(--archival-gold);
        clip-path: inset(0 0 0% 0);
    }
}

.column-rule {
    width: 4%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-around;
    position: relative;
    flex-shrink: 0;
}

.column-rule::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 1px;
    background: var(--dark-rule);
    transform: translateX(-50%);
}

.diamond-ornament {
    width: 8px;
    height: 8px;
    background: var(--archival-gold);
    opacity: 0.4;
    transform: rotate(45deg);
    position: relative;
    z-index: 1;
    flex-shrink: 0;
}

.spread-right {
    width: 58%;
    padding: 20px 20px 20px 24px;
    position: relative;
}

/* ============================================
   Classification Stamps
   ============================================ */
.classification-stamp {
    display: block;
    font-family: 'Inconsolata', monospace;
    font-size: 12px;
    font-weight: 400;
    color: var(--muted-sage);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    opacity: 0;
    margin-bottom: 8px;
    overflow: hidden;
    white-space: nowrap;
}

.dossier-section.revealed .classification-stamp {
    opacity: 0.6;
}

.classification-stamp.typewriter {
    border-right: 2px solid var(--muted-sage);
    animation: blinkCursor 0.6s step-end infinite;
    width: 0;
    opacity: 0.6;
}

.classification-stamp.typewriter-done {
    border-right: none;
    width: auto;
    opacity: 0.6;
}

@keyframes blinkCursor {
    50% { border-right-color: transparent; }
}

/* ============================================
   Section Headers
   ============================================ */
.section-header {
    font-family: 'Stint Ultra Expanded', serif;
    font-size: clamp(24px, 4vw, 48px);
    font-weight: 400;
    color: var(--archival-gold);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 20px;
    opacity: 0;
    transform: translateX(-30px);
    transition: opacity var(--reveal-duration) ease-out, transform var(--reveal-duration) ease-out;
}

.dossier-section.revealed .section-header {
    opacity: 1;
    transform: translateX(0);
}

/* ============================================
   Body Text
   ============================================ */
.body-text {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 17px;
    line-height: 1.72;
    color: var(--pale-silver);
    margin-bottom: 20px;
    position: relative;
    z-index: 1;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 500ms ease, transform 500ms ease;
}

.dossier-section.revealed .body-text {
    opacity: 1;
    transform: translateY(0);
}

.body-text.end-stamp {
    font-family: 'Inconsolata', monospace;
    font-size: 14px;
    color: var(--muted-steel);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--steel-gray);
}

/* ============================================
   Marginal Notes
   ============================================ */
.marginal-note {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--muted-steel);
    margin-bottom: 16px;
    font-variant: small-caps;
    position: relative;
    z-index: 1;
}

/* ============================================
   Redaction Bars
   ============================================ */
.redaction-bar {
    height: 18px;
    background: var(--deep-black);
    border: 1px solid var(--dark-rule);
    box-shadow: 0 0 4px rgba(200, 169, 110, 0.1);
    margin: 12px 0;
    position: relative;
    cursor: pointer;
    transition: background-color 0.3s ease-in-out;
    overflow: hidden;
    z-index: 1;
}

.redacted-text {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 14px;
    color: var(--pale-silver);
    opacity: 0;
    position: absolute;
    top: 50%;
    left: 8px;
    transform: translateY(-50%);
    white-space: nowrap;
    transition: opacity 0.3s ease-in-out;
    pointer-events: none;
}

.redaction-bar:hover {
    background: rgba(10, 14, 20, 0.3);
}

.redaction-bar:hover .redacted-text {
    opacity: 0.5;
}

/* ============================================
   Copper Wire Diagrams
   ============================================ */
.copper-wire-diagram {
    margin: 20px 0;
    position: relative;
    z-index: 1;
}

.wire-svg {
    width: 120px;
    height: auto;
    overflow: visible;
}

.wire-node {
    fill: none;
    stroke: var(--copper-wash);
    stroke-width: 1px;
    opacity: 0.25;
    transform-origin: center;
    transform: scale(0);
    transition: transform 0.2s ease;
}

.wire-line {
    stroke: var(--copper-wash);
    stroke-width: 1px;
    opacity: 0.25;
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    fill: none;
    transition: stroke-dashoffset 0.4s ease;
}

.copper-wire-diagram.animated .wire-node {
    transform: scale(1);
}

.copper-wire-diagram.animated .wire-line {
    stroke-dashoffset: 0;
}

/* ============================================
   Page Counter
   ============================================ */
#page-counter {
    position: fixed;
    bottom: 16px;
    right: 16px;
    font-family: 'Inconsolata', monospace;
    font-size: 11px;
    color: var(--steel-gray);
    letter-spacing: 0.05em;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 4px;
}

#currentPage {
    color: var(--archival-gold);
    display: inline-block;
    min-width: 1.2em;
    text-align: right;
    position: relative;
}

#currentPage.transitioning {
    animation: counterSwap 0.3s ease;
}

@keyframes counterSwap {
    0% { opacity: 1; transform: translateY(0); }
    40% { opacity: 0; transform: translateY(-8px); }
    60% { opacity: 0; transform: translateY(8px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* ============================================
   Margin Lines (Gold margin line on left)
   ============================================ */
.spread-right::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 1px;
    background: var(--archival-gold);
    opacity: 0.15;
}

/* ============================================
   Staggered reveal for body text paragraphs
   ============================================ */
.dossier-section.revealed .spread-right .body-text:nth-child(2) {
    transition-delay: 0ms;
}
.dossier-section.revealed .spread-right .body-text:nth-child(3) {
    transition-delay: 150ms;
}
.dossier-section.revealed .spread-right .body-text:nth-child(4) {
    transition-delay: 300ms;
}
.dossier-section.revealed .spread-right .body-text:nth-child(5) {
    transition-delay: 450ms;
}
.dossier-section.revealed .spread-right .body-text:nth-child(6) {
    transition-delay: 600ms;
}
.dossier-section.revealed .spread-right .body-text:nth-child(7) {
    transition-delay: 750ms;
}

/* Also count .redaction-bar between paragraphs for correct nth-child */
.dossier-section.revealed .spread-right .redaction-bar ~ .body-text {
    /* handled by nth-child above */
}

/* ============================================
   Mobile Adaptation
   ============================================ */
@media (max-width: 768px) {
    .section-spread {
        flex-direction: column;
    }

    .spread-left {
        width: 100%;
        border-left: 4px solid var(--archival-gold);
        padding: 16px;
    }

    .column-rule {
        display: none;
    }

    .spread-right {
        width: 100%;
        padding: 16px;
    }

    .dossier-section {
        min-height: auto;
        padding: 0 12px 40px;
    }

    #dossier-frame {
        border-width: 8px;
    }

    #dossier-inner {
        margin: 4px;
    }

    .section-header {
        font-size: clamp(18px, 5vw, 32px);
    }

    .classification-stamp {
        font-size: 10px;
    }

    .body-text {
        font-size: 15px;
    }

    .marginal-note {
        font-size: 13px;
    }

    .opening-screen {
        min-height: calc(100vh - 48px - 26px);
    }

    #header-bar {
        padding: 0 12px;
    }
}

/* ============================================
   Selection styling
   ============================================ */
::selection {
    background: var(--archival-gold);
    color: var(--midnight-ink);
}

/* ============================================
   Scrollbar styling
   ============================================ */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--midnight-ink);
}

::-webkit-scrollbar-thumb {
    background: var(--dark-rule);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--steel-gray);
}
