/* ============================================================
   monopole.wiki — Styles
   Dark-mode cathedral of forbidden knowledge
   ============================================================ */

/* --- CSS Custom Properties --- */
:root {
    --obsidian-substrate: #0c0e12;
    --graphite-stratum: #1a1e26;
    --detector-steel: #2d3a4a;
    --signal-gray: #3a4a5c;
    --readout-silver: #8a96a6;
    --archive-bone: #c8cdd4;
    --monopole-teal: #6b8fa3;
    --cherenkov-blue: #4a7a94;
    --emission-white: #e8ecf0;
}

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

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    background-color: var(--obsidian-substrate);
    color: var(--readout-silver);
    font-family: 'Crimson Pro', Georgia, serif;
    font-weight: 300;
    font-size: clamp(1rem, 1.8vw, 1.15rem);
    line-height: 1.72;
    text-rendering: optimizeLegibility;
    font-variant-ligatures: common-ligatures;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Typography --- */
.logotype {
    font-family: 'Cormorant Garamond', 'Times New Roman', serif;
    font-weight: 600;
    font-size: clamp(3.5rem, 9vw, 7rem);
    letter-spacing: 0.04em;
    color: var(--emission-white);
    font-feature-settings: 'liga' 1, 'kern' 1, 'onum' 1;
    white-space: nowrap;
}

.section-heading {
    font-family: 'Cormorant Garamond', 'Times New Roman', serif;
    font-weight: 600;
    font-size: clamp(1.8rem, 4vw, 3.2rem);
    letter-spacing: 0.02em;
    color: var(--archive-bone);
    font-feature-settings: 'liga' 1, 'kern' 1, 'onum' 1;
    margin-bottom: 2rem;
}

.subsection-heading {
    font-family: 'Cormorant Garamond', 'Times New Roman', serif;
    font-weight: 600;
    font-size: clamp(1.2rem, 2.5vw, 1.8rem);
    letter-spacing: 0.02em;
    color: var(--archive-bone);
    font-feature-settings: 'liga' 1, 'kern' 1, 'onum' 1;
    margin-bottom: 1rem;
    margin-top: 2.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.body-text {
    max-width: 680px;
    margin-bottom: 0;
    color: var(--readout-silver);
    font-weight: 300;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.body-text em {
    font-weight: 400;
    font-style: italic;
    color: var(--archive-bone);
}

.technical-text {
    font-family: 'IBM Plex Mono', 'Courier New', monospace;
    font-weight: 400;
    font-size: clamp(0.75rem, 1.2vw, 0.85rem);
    letter-spacing: 0.06em;
    color: var(--monopole-teal);
    font-variant-numeric: tabular-nums;
}

.annotation-label {
    font-family: 'IBM Plex Mono', 'Courier New', monospace;
    font-weight: 400;
    font-size: clamp(0.65rem, 1vw, 0.75rem);
    letter-spacing: 0.08em;
    color: var(--signal-gray);
    text-transform: uppercase;
    display: block;
    margin-bottom: 0.5rem;
}

.annotation-text {
    font-family: 'Crimson Pro', Georgia, serif;
    font-weight: 300;
    font-size: clamp(0.85rem, 1.4vw, 0.95rem);
    line-height: 1.6;
    color: var(--readout-silver);
}

/* --- Chip Number (Typographic Ornament) --- */
.chip-number {
    font-family: 'IBM Plex Mono', 'Courier New', monospace;
    font-weight: 400;
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    color: var(--signal-gray);
    border: 1px solid var(--detector-steel);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    font-variant-numeric: tabular-nums;
}

.section-marker {
    margin-bottom: 1rem;
}

/* --- Progress Indicator --- */
#progress-track {
    position: fixed;
    right: 12px;
    top: 0;
    height: 100vh;
    width: 2px;
    background-color: var(--graphite-stratum);
    z-index: 100;
}

#progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--monopole-teal);
    transform: scaleY(0);
    transform-origin: top;
    will-change: transform;
}

.progress-tick {
    position: absolute;
    left: -6px;
    width: 6px;
    height: 1px;
    background-color: var(--detector-steel);
}

.progress-tick[data-stratum="0"] { top: 0; }
.progress-tick[data-stratum="1"] { top: 16.67%; }
.progress-tick[data-stratum="2"] { top: 41.67%; }
.progress-tick[data-stratum="3"] { top: 66.67%; }
.progress-tick[data-stratum="4"] { top: 100%; }

/* --- Stratum Sections --- */
.stratum {
    position: relative;
    width: 100%;
}

/* --- STRATUM 0: Entry Void --- */
#stratum-0 {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.entry-void {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3rem;
    width: 100%;
    padding: 0 2rem;
}

.logotype-container {
    display: flex;
    align-items: center;
    width: 100%;
    max-width: 1200px;
    gap: 1.5rem;
}

.horizontal-rule {
    flex: 1;
    height: 1px;
    background-color: var(--signal-gray);
    opacity: 0;
    transform: scaleX(0);
    will-change: transform, opacity;
}

.rule-left {
    transform-origin: right center;
}

.rule-right {
    transform-origin: left center;
}

.horizontal-rule.animate {
    animation: rule-draw 800ms ease-out forwards;
}

@keyframes rule-draw {
    0% {
        transform: scaleX(0);
        opacity: 0.2;
    }
    100% {
        transform: scaleX(1);
        opacity: 1;
    }
}

.horizontal-rule.animate.pulsing {
    animation: rule-draw 800ms ease-out forwards, rule-pulse 4s ease-in-out infinite 1s;
}

@keyframes rule-pulse {
    0%, 100% { opacity: 0.2; }
    50% { opacity: 0.6; }
}

.logotype {
    opacity: 0;
    transform: translateY(10px);
    will-change: opacity, transform;
}

.logotype.animate {
    animation: logotype-reveal 600ms ease-out forwards;
}

@keyframes logotype-reveal {
    0% {
        opacity: 0;
        transform: translateY(10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.scroll-invite {
    opacity: 0;
    will-change: opacity;
}

.scroll-invite.animate {
    animation: chevron-breathe 2.5s ease-in-out infinite;
}

@keyframes chevron-breathe {
    0%, 100% { opacity: 0.2; }
    50% { opacity: 0.7; }
}

/* --- STRATUM 1: Manifesto Layer --- */
#stratum-1 {
    min-height: 150vh;
    padding: 8rem 2rem;
    display: flex;
    justify-content: center;
}

.manifesto-column {
    max-width: 680px;
    width: 100%;
}

.manifesto-column .body-text {
    margin-bottom: 0;
}

/* Connector traces between paragraphs */
.connector-trace {
    width: 100%;
    max-width: 680px;
    height: 24px;
    margin: 3rem 0;
    display: block;
}

/* --- STRATUM 2: Knowledge Grid --- */
#stratum-2 {
    min-height: 200vh;
    padding: 8rem 2rem;
    display: flex;
    justify-content: center;
}

.knowledge-grid {
    max-width: 1100px;
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 3rem;
    position: relative;
}

.grid-main {
    max-width: 680px;
}

.grid-separator {
    position: absolute;
    left: calc(100% - 300px - 1.5rem);
    top: 0;
    bottom: 0;
    width: 1px;
    background-color: var(--detector-steel);
    animation: separator-pulse 3s ease-in-out infinite;
}

@keyframes separator-pulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.7; }
}

.grid-sidebar {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    padding-top: 4rem;
}

.sidebar-annotation {
    padding: 1.25rem;
    border-left: 2px solid var(--detector-steel);
}

.sidebar-circuit {
    display: flex;
    justify-content: center;
    padding: 1rem 0;
}

.sidebar-trace-svg {
    width: 160px;
    height: 100px;
}

/* --- STRATUM 3: Deep Archive --- */
#stratum-3 {
    min-height: 150vh;
    padding: 8rem 2rem;
}

.deep-archive {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
}

.archive-panel {
    border: 1px solid var(--detector-steel);
    background: transparent;
    padding: 2rem;
    max-width: 550px;
    opacity: 0;
    will-change: opacity, transform;
}

.panel-left {
    align-self: flex-start;
    transform: translateX(-30px);
}

.panel-right {
    align-self: flex-end;
    transform: translateX(30px);
}

.archive-panel.revealed {
    opacity: 1;
    transform: translateX(0);
    transition: opacity 500ms ease-out, transform 500ms ease-out;
}

.panel-label {
    font-family: 'IBM Plex Mono', 'Courier New', monospace;
    font-weight: 400;
    font-size: clamp(0.65rem, 1vw, 0.75rem);
    letter-spacing: 0.1em;
    color: var(--monopole-teal);
    text-transform: uppercase;
    display: block;
    margin-bottom: 0.75rem;
}

.panel-text {
    font-family: 'Crimson Pro', Georgia, serif;
    font-weight: 300;
    font-size: clamp(0.9rem, 1.5vw, 1.05rem);
    line-height: 1.65;
    color: var(--readout-silver);
}

/* --- STRATUM 4: Terminus --- */
#stratum-4 {
    min-height: 50vh;
    padding: 8rem 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.terminus {
    max-width: 680px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}

.terminus-ornament {
    width: 160px;
    margin-bottom: 1rem;
}

.terminus-circuit {
    width: 100%;
    height: auto;
}

.colophon {
    font-family: 'Crimson Pro', Georgia, serif;
    font-weight: 300;
    font-style: italic;
    font-size: 0.9rem;
    line-height: 1.7;
    color: var(--signal-gray);
}

.colophon-attribution {
    margin-top: 0.5rem;
}

.colophon-attribution .technical-text {
    font-size: 0.75rem;
    color: var(--signal-gray);
}

/* --- Stratum Dividers --- */
.stratum-divider {
    width: 100%;
    height: 40px;
    padding: 0 2rem;
    overflow: visible;
}

.divider-svg {
    width: 100%;
    height: 40px;
    display: block;
}

/* --- SVG Trace Styles --- */
.trace-line {
    stroke: var(--detector-steel);
    stroke-width: 0.5;
    fill: none;
}

.trace-tap {
    stroke-width: 0.5;
}

.trace-node {
    fill: var(--monopole-teal);
    opacity: 0;
    transition: opacity 400ms ease-out;
}

.trace-node.illuminated {
    opacity: 1;
}

/* Node pulse animation — staggered per node */
@keyframes node-pulse {
    0%, 100% {
        filter: drop-shadow(0 0 0 rgba(107, 143, 163, 0));
    }
    50% {
        filter: drop-shadow(0 0 4px rgba(107, 143, 163, 0.4));
    }
}

.trace-node.illuminated {
    animation: node-pulse 3s ease-in-out infinite;
}

.trace-node.illuminated:nth-child(odd) {
    animation-delay: 0s;
}

.trace-node.illuminated:nth-child(even) {
    animation-delay: 1.5s;
}

/* Center node in terminus */
.center-node {
    fill: var(--monopole-teal);
}

/* --- Pulse-Attention System --- */
.pulse-node {
    display: inline-block;
    width: 6px;
    height: 6px;
    min-width: 6px;
    border-radius: 50%;
    background-color: var(--monopole-teal);
    animation: pulse-breathe 2.5s ease-in-out infinite;
    flex-shrink: 0;
    margin-top: 0.55em;
}

@keyframes pulse-breathe {
    0% {
        transform: scale(1);
        opacity: 0.8;
        box-shadow: 0 0 0 0 rgba(107, 143, 163, 0.4);
    }
    50% {
        transform: scale(1.4);
        opacity: 0.4;
        box-shadow: 0 0 6px 2px rgba(107, 143, 163, 0.25);
    }
    100% {
        transform: scale(1);
        opacity: 0.8;
        box-shadow: 0 0 0 0 rgba(107, 143, 163, 0);
    }
}

/* --- Reveal Animations --- */
.reveal-element {
    opacity: 0;
    transform: translateY(20px);
    will-change: opacity, transform;
    transition: opacity 500ms ease-out, transform 500ms ease-out;
}

.reveal-element.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* Trace drawing animation */
.trace-line {
    stroke-dasharray: 0;
    stroke-dashoffset: 0;
}

.trace-line.draw-ready {
    transition: stroke-dashoffset 1200ms ease-in-out;
}

.trace-line.drawn {
    stroke-dashoffset: 0 !important;
}

/* --- Responsive: Mobile --- */
@media (max-width: 960px) {
    .knowledge-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .grid-separator {
        display: none;
    }

    .grid-sidebar {
        padding-top: 2rem;
        border-top: 1px solid var(--detector-steel);
    }

    .sidebar-annotation {
        margin-left: 1rem;
    }

    .archive-panel {
        max-width: 100%;
    }

    .panel-left,
    .panel-right {
        align-self: stretch;
    }

    .panel-left {
        transform: translateX(-20px);
    }

    .panel-right {
        transform: translateX(20px);
    }

    .logotype-container {
        flex-direction: column;
        gap: 1rem;
    }

    .horizontal-rule {
        width: 80%;
        flex: none;
        transform-origin: center;
    }

    .rule-left {
        order: -1;
        transform-origin: center;
    }

    .logotype {
        text-align: center;
    }
}

@media (max-width: 600px) {
    #stratum-1,
    #stratum-2,
    #stratum-3,
    #stratum-4 {
        padding: 5rem 1.25rem;
    }

    .stratum-divider {
        padding: 0 1.25rem;
    }

    .logotype {
        font-size: clamp(2rem, 9vw, 3.5rem);
    }

    .subsection-heading {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .body-text {
        flex-direction: column;
        gap: 0.5rem;
    }

    .pulse-node {
        margin-top: 0;
    }
}

/* --- Selection --- */
::selection {
    background-color: var(--cherenkov-blue);
    color: var(--emission-white);
}

/* --- Scrollbar (Webkit) --- */
::-webkit-scrollbar {
    width: 0;
    background: transparent;
}
