/* cbdc.study — Surrealist CBDC Research Environment */
/* ================================================== */

:root {
    --void: #0d0820;
    --indigo: #1a1040;
    --teal: #2dd4a8;
    --coral: #d4532d;
    --ivory: #e8e2d6;
    --mist: #6b6480;
    --glitch: #8b2dd4;
}

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

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

body {
    background-color: var(--void);
    color: var(--ivory);
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 400;
    font-size: clamp(1.1rem, 1.6vw, 1.35rem);
    line-height: 1.72;
    letter-spacing: 0.005em;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ======================== */
/* SCANLINE OVERLAY         */
/* ======================== */

.scanline-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        transparent 0px,
        transparent 1.5px,
        rgba(13, 8, 32, 0.08) 1.5px,
        rgba(13, 8, 32, 0.08) 3px
    );
    pointer-events: none;
    z-index: 1000;
}

/* ======================== */
/* DEPTH 1: THE SURFACE     */
/* ======================== */

.depth-surface {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background-color: var(--void);
    overflow: hidden;
}

.surface-content {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.display-title {
    font-family: 'Playfair Display', serif;
    font-weight: 900;
    font-size: clamp(8rem, 18vw, 16rem);
    letter-spacing: -0.04em;
    line-height: 0.9;
    color: var(--ivory);
    opacity: 0;
    animation: fadeInTitle 2.4s ease-out 1.8s forwards;
    transform-origin: center center;
    transition: transform 0.1s linear, opacity 0.1s linear;
}

@keyframes fadeInTitle {
    from { opacity: 0; }
    to { opacity: 1; }
}

.circuit-traces-surface {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90vw;
    height: 80vh;
    z-index: 1;
    overflow: visible;
}

.circuit-trace {
    fill: none;
    stroke: var(--teal);
    stroke-width: 0.4;
    opacity: 0;
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    animation: drawCircuit 4s cubic-bezier(0.16, 1, 0.3, 1) 2s forwards;
}

@keyframes drawCircuit {
    to {
        stroke-dashoffset: 0;
        opacity: 0.25;
    }
}

.circuit-node {
    fill: none;
    stroke: var(--teal);
    stroke-width: 0.5;
    opacity: 0;
    animation: fadeNode 1.5s ease-out 5s forwards;
}

@keyframes fadeNode {
    to { opacity: 0.35; }
}

.subtitle {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 0.7rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--mist);
    margin-top: 2rem;
    opacity: 0;
    animation: typeIn 2s steps(40) 3s forwards;
    overflow: hidden;
    white-space: nowrap;
    border-right: 1px solid var(--mist);
    animation: typeIn 2s steps(40) 3s forwards, blinkCursor 0.7s step-end 3s 5;
}

@keyframes typeIn {
    from {
        opacity: 1;
        width: 0;
    }
    to {
        opacity: 1;
        width: 100%;
    }
}

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

.domain-watermark {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 0.6rem;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--mist);
    opacity: 0.15;
}

/* ======================== */
/* BREATH MOMENTS           */
/* ======================== */

.breath-moment {
    height: 30vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--indigo);
}

.breath-node {
    width: 20px;
    height: 20px;
}

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

@keyframes pulseBreath {
    0%, 100% { opacity: 0.2; }
    50% { opacity: 0.6; }
}

/* ======================== */
/* DEPTH 2: SHALLOW WATER   */
/* ======================== */

.depth-shallow {
    min-height: 150vh;
    background-color: var(--indigo);
    position: relative;
    padding: clamp(6rem, 12vh, 10rem) 0;
}

.shallow-grid {
    display: grid;
    grid-template-columns: 1fr minmax(0, 38ch) 1fr;
    gap: 2rem;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    margin-bottom: clamp(6rem, 12vh, 10rem);
}

.reading-column {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.section-label {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 0.75rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--mist);
    display: block;
    margin-bottom: 1rem;
}

.section-label-center {
    text-align: center;
    width: 100%;
}

.section-display {
    font-family: 'Playfair Display', serif;
    font-weight: 900;
    font-size: clamp(5rem, 15vw, 14rem);
    letter-spacing: -0.04em;
    line-height: 0.9;
    color: var(--ivory);
    margin-bottom: 2rem;
}

.section-display-center {
    text-align: center;
}

.section-display-sm {
    font-family: 'Playfair Display', serif;
    font-weight: 900;
    font-size: clamp(3rem, 8vw, 6rem);
    letter-spacing: -0.04em;
    line-height: 0.9;
    color: var(--ivory);
    margin-bottom: 1.5rem;
}

.body-text {
    max-width: 38ch;
    color: var(--ivory);
    opacity: 0.9;
}

.margin-circuit {
    display: flex;
    align-items: stretch;
    justify-content: center;
    overflow: hidden;
}

.margin-svg {
    width: 60px;
    height: 100%;
    min-height: 400px;
}

.margin-trace {
    stroke-width: 0.5;
    opacity: 0;
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
}

.margin-trace.animated {
    animation: drawMarginTrace 3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes drawMarginTrace {
    to {
        stroke-dashoffset: 0;
        opacity: 0.15;
    }
}

/* ======================== */
/* CHAPTER NUMERALS         */
/* ======================== */

.chapter-numeral {
    position: absolute;
    top: 10%;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Playfair Display', serif;
    font-weight: 900;
    font-size: clamp(8rem, 22vw, 20rem);
    color: transparent;
    -webkit-text-stroke: 1.5px var(--teal);
    opacity: 0;
    z-index: 0;
    pointer-events: none;
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: opacity 0.5s ease;
}

.chapter-numeral.visible {
    opacity: 0.12;
}

/* ======================== */
/* DEPTH 3: THE PASSAGE     */
/* ======================== */

.depth-passage {
    min-height: 150vh;
    background-color: var(--indigo);
    position: relative;
    padding: clamp(6rem, 12vh, 10rem) 2rem;
}

.passage-block {
    display: flex;
    align-items: center;
    gap: clamp(3rem, 6vw, 6rem);
    max-width: 1100px;
    margin: 0 auto;
    margin-bottom: clamp(6rem, 12vh, 10rem);
}

.passage-left {
    margin-left: clamp(2rem, 5vw, 8rem);
}

.passage-right {
    margin-right: clamp(2rem, 5vw, 8rem);
    flex-direction: row-reverse;
    margin-left: auto;
}

.passage-text {
    flex: 1;
    min-width: 0;
}

/* ======================== */
/* GLITCH ILLUSTRATIONS     */
/* ======================== */

.glitch-illustration {
    position: relative;
    width: clamp(200px, 25vw, 350px);
    height: clamp(200px, 25vw, 350px);
    flex-shrink: 0;
}

.glitch-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    mix-blend-mode: screen;
}

.glitch-teal {
    background: radial-gradient(circle, rgba(45, 212, 168, 0.15) 0%, transparent 70%);
    transform: translate(2px, -1px);
}

.glitch-coral {
    background: radial-gradient(circle, rgba(212, 83, 45, 0.12) 0%, transparent 70%);
    transform: translate(-2px, 1px);
}

.glitch-violet {
    background: radial-gradient(circle, rgba(139, 45, 212, 0.1) 0%, transparent 70%);
    transform: translate(0, 2px);
}

.surreal-object {
    position: relative;
    width: 100%;
    height: 100%;
    z-index: 2;
}

.glitch-illustration:hover .glitch-teal {
    transform: translate(5px, -3px);
    transition: transform 0.6s cubic-bezier(0.23, 1, 0.32, 1);
}

.glitch-illustration:hover .glitch-coral {
    transform: translate(-5px, 3px);
    transition: transform 0.6s cubic-bezier(0.23, 1, 0.32, 1);
}

.glitch-illustration:hover .glitch-violet {
    transform: translate(0, 5px);
    transition: transform 0.6s cubic-bezier(0.23, 1, 0.32, 1);
}

/* ======================== */
/* DEPTH 4: DEEP STUDY      */
/* ======================== */

.depth-study {
    min-height: 150vh;
    background-color: var(--indigo);
    position: relative;
    padding: clamp(6rem, 12vh, 10rem) 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.concept-mosaic {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-auto-flow: dense;
    gap: 1.5rem;
    max-width: 1100px;
    width: 100%;
    margin-top: 3rem;
}

.concept-card {
    position: relative;
    background-color: rgba(26, 16, 64, 0.6);
    border: 1px solid rgba(45, 212, 168, 0.15);
    padding: clamp(1.5rem, 3vw, 2.5rem);
    overflow: hidden;
    transition: transform 0.6s cubic-bezier(0.23, 1, 0.32, 1),
                box-shadow 0.6s ease,
                border-color 0.6s ease;
}

.concept-card:hover {
    transform: scale(1.04);
    border-color: rgba(45, 212, 168, 0.5);
    box-shadow: 0 0 40px rgba(45, 212, 168, 0.08);
}

.concept-card:hover .card-circuit-border {
    opacity: 0.8;
}

.concept-card:hover .card-scanline {
    animation: scanSweep 0.8s ease-out;
}

.concept-span-2 {
    grid-column: span 2;
}

.concept-span-3 {
    grid-column: span 3;
}

.card-circuit-border {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: 1px solid var(--teal);
    opacity: 0.3;
    pointer-events: none;
    transition: opacity 0.6s ease;
}

.card-scanline {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--teal), transparent);
    opacity: 0;
    pointer-events: none;
}

@keyframes scanSweep {
    0% {
        top: 0;
        opacity: 0.8;
    }
    100% {
        top: 100%;
        opacity: 0;
    }
}

.card-label {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 0.65rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--teal);
    display: block;
    margin-bottom: 0.75rem;
}

.card-title {
    font-family: 'Playfair Display', serif;
    font-weight: 900;
    font-size: clamp(1.4rem, 2.5vw, 2rem);
    letter-spacing: -0.02em;
    line-height: 1.1;
    color: var(--ivory);
    margin-bottom: 1rem;
}

.card-text {
    font-size: clamp(0.9rem, 1.2vw, 1.05rem);
    line-height: 1.65;
    color: var(--ivory);
    opacity: 0.8;
}

.concept-connectors {
    display: none;
}

/* ======================== */
/* DEPTH 5: THE FLOOR       */
/* ======================== */

.depth-floor {
    min-height: 100vh;
    background-color: var(--indigo);
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: clamp(6rem, 12vh, 10rem) 2rem;
}

.floor-column {
    max-width: 38ch;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.floor-final-text {
    color: var(--teal);
    font-style: italic;
    margin-top: 2rem;
}

.floor-convergence {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: clamp(6rem, 12vh, 10rem);
    gap: 4rem;
}

.convergence-word {
    font-family: 'Playfair Display', serif;
    font-weight: 900;
    font-size: clamp(2rem, 4vw, 3rem);
    color: var(--ivory);
    opacity: 0.4;
    letter-spacing: 0.2em;
    transition: opacity 1s ease, font-size 1s ease;
}

.convergence-dot {
    width: 2px;
    height: 2px;
    background-color: var(--teal);
    border-radius: 50%;
    opacity: 0.5;
}

.floor-void {
    height: 50vh;
    background: linear-gradient(to bottom, var(--indigo), var(--void));
}

/* ======================== */
/* GLITCH MICRO-MOMENT      */
/* ======================== */

.glitch-active {
    animation: glitchMicro 80ms step-end;
}

@keyframes glitchMicro {
    0% {
        transform: translateX(3px);
        color: var(--glitch);
    }
    50% {
        transform: translateX(-2px);
        color: var(--glitch);
    }
    100% {
        transform: translateX(0);
        color: inherit;
    }
}

/* ======================== */
/* SECTION VISIBILITY       */
/* ======================== */

.depth-shallow .reading-column,
.passage-text,
.concept-card,
.floor-column {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 1.2s ease-out, transform 1.2s ease-out;
}

.depth-shallow .reading-column.in-view,
.passage-text.in-view,
.concept-card.in-view,
.floor-column.in-view {
    opacity: 1;
    transform: translateY(0);
}

/* ======================== */
/* DATA FLOW ANIMATION      */
/* ======================== */

@keyframes dataFlow {
    0% {
        stroke-dashoffset: 20;
    }
    100% {
        stroke-dashoffset: 0;
    }
}

.circuit-trace.flowing {
    stroke-dasharray: 4 16;
    animation: dataFlow 8s linear infinite;
    opacity: 0.25;
}

/* ======================== */
/* RESPONSIVE               */
/* ======================== */

@media (max-width: 768px) {
    .shallow-grid {
        grid-template-columns: 1fr;
        padding: 0 1.5rem;
    }

    .margin-circuit {
        display: none;
    }

    .passage-block {
        flex-direction: column;
        padding: 0 1rem;
    }

    .passage-right {
        flex-direction: column;
    }

    .glitch-illustration {
        width: 200px;
        height: 200px;
    }

    .concept-mosaic {
        grid-template-columns: 1fr;
    }

    .concept-span-2,
    .concept-span-3 {
        grid-column: span 1;
    }

    .chapter-numeral {
        font-size: clamp(6rem, 30vw, 12rem);
    }

    .section-display {
        font-size: clamp(3rem, 12vw, 8rem);
    }
}

@media (max-width: 480px) {
    .display-title {
        font-size: clamp(4rem, 20vw, 8rem);
    }

    .section-display {
        font-size: clamp(2.5rem, 14vw, 5rem);
    }

    .section-display-sm {
        font-size: clamp(2rem, 10vw, 3.5rem);
    }
}
