/* ============================================
   cbdc.study - Bauhaus CBDC Research Institute
   Ocean Deep Palette / Masonry Layout
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --abyss-black: #0B1622;
    --deep-marine: #1A3A5C;
    --phosphor-cyan: #00E5CC;
    --signal-red: #E63946;
    --solar-amber: #F4A720;
    --foam-white: #E8F0F8;
    --drift-gray: #7B8FA3;
    --trench-blue: #122A42;
    --bioluminescent-green: #00FF88;
    --deep-abyss: #06101A;
    --final-abyss: #040D16;
}

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

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

body {
    background: var(--abyss-black);
    color: var(--foam-white);
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.875rem, 1.1vw, 1rem);
    line-height: 1.65;
    letter-spacing: 0.01em;
    overflow-x: hidden;
    position: relative;
    background: linear-gradient(
        to bottom,
        var(--abyss-black) 0%,
        var(--abyss-black) 30%,
        var(--deep-abyss) 70%,
        var(--final-abyss) 100%
    );
}

a {
    color: var(--phosphor-cyan);
    text-decoration: none;
}

/* --- Cursor-Follow Bioluminescent Glow --- */
#cursor-glow {
    position: fixed;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: var(--bioluminescent-green);
    opacity: 0.07;
    pointer-events: none;
    z-index: 9999;
    filter: blur(60px);
    transform: translate(-50%, -50%);
    transition: left 0.15s ease-out, top 0.15s ease-out, opacity 0.3s ease;
    will-change: left, top;
    left: -200px;
    top: -200px;
}

#cursor-glow.on-block {
    opacity: 0.12;
}

#cursor-glow.on-icon {
    background: var(--phosphor-cyan);
    opacity: 0.15;
}

/* --- Organic Blob Underlays --- */
#blob-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.organic-blob {
    position: absolute;
    opacity: 0;
    animation-timing-function: ease-in-out;
    animation-iteration-count: infinite;
    animation-direction: alternate;
}

.blob-1 {
    width: 600px;
    height: 600px;
    top: 10%;
    left: -5%;
    fill: var(--phosphor-cyan);
    opacity: 0.08;
    animation: blobDrift1 28s ease-in-out infinite alternate, blobMorph1 22s ease-in-out infinite;
}

.blob-2 {
    width: 400px;
    height: 400px;
    top: 30%;
    right: -10%;
    fill: var(--deep-marine);
    opacity: 0.10;
    animation: blobDrift2 32s ease-in-out infinite alternate, blobMorph2 26s ease-in-out infinite;
}

.blob-3 {
    width: 500px;
    height: 500px;
    top: 55%;
    left: 20%;
    fill: var(--phosphor-cyan);
    opacity: 0.06;
    animation: blobDrift3 25s ease-in-out infinite alternate, blobMorph3 20s ease-in-out infinite;
}

.blob-4 {
    width: 350px;
    height: 350px;
    top: 75%;
    right: 15%;
    fill: var(--deep-marine);
    opacity: 0.09;
    animation: blobDrift4 30s ease-in-out infinite alternate;
}

.blob-5 {
    width: 450px;
    height: 450px;
    top: 15%;
    right: 30%;
    fill: var(--deep-marine);
    opacity: 0.07;
    animation: blobDrift5 27s ease-in-out infinite alternate;
}

.blob-6 {
    width: 300px;
    height: 300px;
    top: 45%;
    left: -8%;
    fill: var(--phosphor-cyan);
    opacity: 0.10;
    animation: blobDrift6 24s ease-in-out infinite alternate;
}

@keyframes blobDrift1 {
    0% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(80px, 40px) scale(1.05); }
    100% { transform: translate(-40px, 80px) scale(0.95); }
}

@keyframes blobDrift2 {
    0% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(-60px, 50px) scale(1.08); }
    100% { transform: translate(40px, -30px) scale(0.97); }
}

@keyframes blobDrift3 {
    0% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(50px, -40px) scale(1.03); }
    100% { transform: translate(-70px, 60px) scale(0.96); }
}

@keyframes blobDrift4 {
    0% { transform: translate(0, 0) rotate(0deg); }
    100% { transform: translate(-50px, 40px) rotate(10deg); }
}

@keyframes blobDrift5 {
    0% { transform: translate(0, 0) rotate(0deg); }
    100% { transform: translate(60px, -50px) rotate(-8deg); }
}

@keyframes blobDrift6 {
    0% { transform: translate(0, 0); }
    100% { transform: translate(40px, 60px); }
}

@keyframes blobMorph1 {
    0% { border-radius: 42% 58% 55% 45% / 48% 52% 48% 52%; }
    33% { border-radius: 55% 45% 42% 58% / 52% 48% 55% 45%; }
    66% { border-radius: 48% 52% 58% 42% / 45% 55% 42% 58%; }
    100% { border-radius: 42% 58% 55% 45% / 48% 52% 48% 52%; }
}

@keyframes blobMorph2 {
    0% { border-radius: 45% 55% 50% 50% / 50% 50% 55% 45%; }
    50% { border-radius: 55% 45% 45% 55% / 45% 55% 50% 50%; }
    100% { border-radius: 45% 55% 50% 50% / 50% 50% 55% 45%; }
}

@keyframes blobMorph3 {
    0% { border-radius: 50% 50% 45% 55% / 55% 45% 50% 50%; }
    50% { border-radius: 45% 55% 55% 45% / 50% 50% 45% 55%; }
    100% { border-radius: 50% 50% 45% 55% / 55% 45% 50% 50%; }
}

/* --- Specimen Bar Navigation --- */
#specimen-bar {
    position: fixed;
    left: 0;
    top: 0;
    width: 48px;
    height: 100vh;
    background: var(--abyss-black);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 32px;
    z-index: 1000;
    border-right: 1px solid rgba(123, 143, 163, 0.15);
    opacity: 0;
    transform: translateX(-48px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

#specimen-bar.visible {
    opacity: 1;
    transform: translateX(0);
}

.specimen-icon {
    display: flex;
    align-items: center;
    position: relative;
    padding: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    overflow: visible;
    white-space: nowrap;
}

.specimen-icon svg {
    flex-shrink: 0;
    transition: transform 0.3s ease-out;
}

.specimen-icon:hover svg {
    transform: rotate(15deg);
}

.specimen-label {
    position: absolute;
    left: 40px;
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--phosphor-cyan);
    background: var(--abyss-black);
    padding: 4px 12px 4px 8px;
    border: 1px solid rgba(0, 229, 204, 0.2);
    opacity: 0;
    transform: translateX(-10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
}

.specimen-icon:hover .specimen-label {
    opacity: 1;
    transform: translateX(0);
}

/* --- Scene 1: THE SURFACE --- */
.scene-surface {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    padding-left: 48px;
}

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

.site-title {
    font-family: 'Share Tech Mono', monospace;
    font-weight: 400;
    font-size: clamp(2.4rem, 8vw, 6rem);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    line-height: 1.1;
    color: var(--foam-white);
    margin-bottom: 2rem;
}

.title-letter {
    display: inline-block;
    opacity: 0;
    transform: translateY(30px);
}

.title-letter.visible {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.4s ease-out, transform 0.4s ease-out;
}

.subtitle {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: clamp(0.9rem, 1.5vw, 1.2rem);
    color: var(--drift-gray);
    letter-spacing: 0.05em;
    opacity: 0;
    transition: opacity 0.8s ease;
}

.subtitle.visible {
    opacity: 1;
}

/* --- Theorem Bands --- */
.theorem-band {
    position: relative;
    width: 100%;
    height: 64px;
    overflow: hidden;
    z-index: 2;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: height 0.3s ease;
    flex-direction: column;
    justify-content: center;
}

.theorem-band:hover {
    height: 96px;
}

.theorem-band.band-cyan {
    background: var(--phosphor-cyan);
}

.theorem-band.band-red {
    background: var(--signal-red);
}

.theorem-band.band-amber {
    background: var(--solar-amber);
}

.theorem-text-wrapper {
    white-space: nowrap;
    overflow: hidden;
    width: 100%;
    height: 64px;
    display: flex;
    align-items: center;
}

.theorem-text {
    font-family: 'Share Tech Mono', monospace;
    font-size: clamp(0.85rem, 1.2vw, 1.1rem);
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--abyss-black);
    white-space: nowrap;
    display: inline-block;
    animation: theoremScroll 25s linear infinite;
    padding-left: 100%;
}

.theorem-band:hover .theorem-text {
    animation-play-state: paused;
}

.theorem-subtext {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 0.8rem;
    color: var(--abyss-black);
    opacity: 0;
    padding: 0 24px;
    transition: opacity 0.3s ease;
    text-align: center;
    max-height: 0;
    overflow: hidden;
}

.theorem-band:hover .theorem-subtext {
    opacity: 0.8;
    max-height: 32px;
}

@keyframes theoremScroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(-200%); }
}

/* --- Masonry Grid --- */
.scene-masonry {
    position: relative;
    z-index: 1;
    padding: 80px 48px 80px 96px;
}

.masonry-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 24px;
    max-width: 1400px;
    margin: 0 auto;
}

/* Block span sizes */
.block-span-4 {
    grid-column: span 4;
}

.block-span-6 {
    grid-column: span 6;
}

.block-span-8 {
    grid-column: span 8;
}

/* Block height variations */
.block-height-short {
    min-height: 200px;
}

.block-height-medium {
    min-height: 350px;
}

.block-height-tall {
    min-height: 500px;
}

/* Masonry block base */
.masonry-block {
    background: var(--trench-blue);
    padding: 32px;
    position: relative;
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.4s ease, transform 0.4s ease, border-style 0.3s ease;
    border: 1px solid rgba(123, 143, 163, 0.1);
    overflow: visible;
}

.masonry-block.in-view {
    opacity: 1;
    transform: translateY(0);
}

/* Geometric pattern border on blocks (subtle) */
.masonry-block::before {
    content: '';
    position: absolute;
    top: -1px;
    left: -1px;
    right: -1px;
    bottom: -1px;
    border: 1px solid rgba(123, 143, 163, 0.08);
    pointer-events: none;
    background-image:
        radial-gradient(circle at 0px 0px, rgba(123, 143, 163, 0.15) 1px, transparent 1px),
        radial-gradient(circle at 8px 0px, transparent 1px, transparent 1px);
    background-size: 16px 16px;
    background-position: top left;
    background-repeat: repeat-x;
    height: 1px;
    bottom: auto;
}

/* Study Cards (elevated) */
.study-card {
    border: 4px solid var(--signal-red);
    box-shadow: 2px 2px 0 var(--signal-red);
    transform: translateY(16px) translate(0, 0);
}

.study-card.in-view {
    transform: translate(0, 0);
}

.study-card:hover {
    border-style: dashed;
    animation: dashPulse 1s ease infinite;
}

@keyframes dashPulse {
    0%, 100% { border-style: dashed; }
    50% { border-style: dotted; }
}

/* Block icon */
.block-icon {
    margin-bottom: 20px;
    position: relative;
    z-index: 2;
}

.study-card .block-icon {
    position: absolute;
    top: -12px;
    left: -12px;
    width: 64px;
    height: 64px;
}

.study-card .block-icon svg {
    width: 96px;
    height: 96px;
}

.block-icon svg {
    transition: transform 0.3s ease-out;
}

.block-icon:hover svg {
    transform: rotate(15deg);
}

.block-icon:hover svg path,
.block-icon:hover svg circle,
.block-icon:hover svg rect,
.block-icon:hover svg polygon,
.block-icon:hover svg polyline,
.block-icon:hover svg line {
    fill: rgba(0, 229, 204, 0.15);
}

/* Block headings */
.block-heading {
    font-family: 'Share Tech Mono', monospace;
    font-weight: 400;
    font-size: clamp(1.2rem, 2.5vw, 1.8rem);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    line-height: 1.1;
    color: var(--foam-white);
    margin-bottom: 16px;
}

/* Block body text */
.block-body {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.8rem, 1vw, 0.95rem);
    line-height: 1.65;
    color: var(--foam-white);
    margin-bottom: 12px;
    letter-spacing: 0.01em;
}

.block-body:last-child {
    margin-bottom: 0;
}

/* Block caption */
.block-caption {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 0.85rem;
    color: var(--drift-gray);
    line-height: 1.5;
    margin-top: 8px;
}

/* Data callout numbers */
.data-callout {
    font-family: 'Archivo Black', sans-serif;
    font-weight: 400;
    font-size: clamp(3rem, 8vw, 7rem);
    color: var(--solar-amber);
    line-height: 1;
    margin: 16px 0;
}

/* --- Scene 4: THE ABYSS --- */
.scene-abyss {
    position: relative;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1;
    padding: 80px 48px 80px 96px;
    background: var(--final-abyss);
    overflow: hidden;
}

.abyss-content {
    text-align: center;
    position: relative;
    z-index: 2;
    max-width: 800px;
}

.abyss-question {
    font-family: 'Share Tech Mono', monospace;
    font-weight: 400;
    font-size: clamp(1.6rem, 4vw, 3.2rem);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    line-height: 1.25;
    color: var(--foam-white);
    margin-bottom: 48px;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.abyss-question.in-view {
    opacity: 1;
    transform: translateY(0);
}

.abyss-icon {
    display: flex;
    justify-content: center;
    animation: abyssPulse 4s ease-in-out infinite;
}

.abyss-icon svg {
    opacity: 0.8;
}

@keyframes abyssPulse {
    0%, 100% { transform: scale(1.0); }
    50% { transform: scale(1.05); }
}

/* Abyss blobs */
.abyss-blobs {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

.abyss-blob {
    position: absolute;
    fill: var(--phosphor-cyan);
}

.ab-1 {
    width: 500px;
    height: 500px;
    top: 5%;
    left: -10%;
    opacity: 0.06;
    animation: blobDrift1 25s ease-in-out infinite alternate;
}

.ab-2 {
    width: 400px;
    height: 400px;
    top: 60%;
    right: -5%;
    opacity: 0.08;
    animation: blobDrift2 30s ease-in-out infinite alternate;
}

.ab-3 {
    width: 350px;
    height: 350px;
    bottom: 10%;
    left: 15%;
    opacity: 0.05;
    animation: blobDrift3 28s ease-in-out infinite alternate;
}

.ab-4 {
    width: 300px;
    height: 300px;
    top: 20%;
    right: 20%;
    opacity: 0.07;
    animation: blobDrift4 22s ease-in-out infinite alternate;
}

.ab-5 {
    width: 450px;
    height: 450px;
    bottom: 20%;
    right: 30%;
    opacity: 0.04;
    animation: blobDrift5 26s ease-in-out infinite alternate;
}

.ab-6 {
    width: 280px;
    height: 280px;
    top: 40%;
    left: 40%;
    opacity: 0.10;
    animation: blobDrift6 20s ease-in-out infinite alternate;
}

/* --- Geometric Pattern Border Footer --- */
.geometric-border-footer {
    width: 100%;
    height: 4px;
    background-image: repeating-linear-gradient(
        90deg,
        var(--drift-gray) 0px,
        var(--drift-gray) 2px,
        transparent 2px,
        transparent 6px,
        var(--phosphor-cyan) 6px,
        var(--phosphor-cyan) 8px,
        transparent 8px,
        transparent 12px
    );
    opacity: 0.3;
    position: relative;
    z-index: 2;
}

/* --- Cursor plankton trail --- */
.plankton-dot {
    position: fixed;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--bioluminescent-green);
    opacity: 0.6;
    pointer-events: none;
    z-index: 9998;
    transition: opacity 0.8s ease;
}

.plankton-dot.fading {
    opacity: 0;
}

/* --- Responsive: Tablet --- */
@media (max-width: 1024px) {
    .masonry-grid {
        grid-template-columns: repeat(6, 1fr);
    }

    .block-span-4 {
        grid-column: span 3;
    }

    .block-span-6 {
        grid-column: span 6;
    }

    .block-span-8 {
        grid-column: span 6;
    }

    .scene-masonry {
        padding: 60px 24px 60px 72px;
    }

    .scene-abyss {
        padding: 60px 24px 60px 72px;
    }
}

/* --- Responsive: Mobile --- */
@media (max-width: 768px) {
    #specimen-bar {
        display: none;
    }

    .masonry-grid {
        grid-template-columns: 1fr;
    }

    .block-span-4,
    .block-span-6,
    .block-span-8 {
        grid-column: span 1;
    }

    .scene-masonry {
        padding: 40px 16px;
    }

    .scene-surface {
        padding-left: 16px;
    }

    .scene-abyss {
        padding: 40px 16px;
    }

    .theorem-band {
        height: 56px;
    }

    .theorem-band:hover {
        height: 80px;
    }

    .data-callout {
        font-size: clamp(2.5rem, 12vw, 5rem);
    }

    #cursor-glow {
        display: none;
    }
}

/* --- Selection styling --- */
::selection {
    background: var(--phosphor-cyan);
    color: var(--abyss-black);
}

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

::-webkit-scrollbar-track {
    background: var(--abyss-black);
}

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

::-webkit-scrollbar-thumb:hover {
    background: var(--phosphor-cyan);
}