/* ============================================
   whitepapers.xyz — Inflated 3D Research Aesthetic
   ============================================ */

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

:root {
    --deep-bg: #0a0e27;
    --bg: #1a1a2e;
    --surface: #141831;
    --coral: #ff6b6b;
    --cyan: #22d3ee;
    --lavender: #c4b5fd;
    --green: #34d399;
    --amber: #fbbf24;
    --light: #e8eaf6;
    --white: #f8f9ff;
    --radius: 24px;
    --shadow-depth: 0 8px 32px rgba(0,0,0,0.4), 0 2px 8px rgba(0,0,0,0.3);
    --shadow-hover: 0 16px 48px rgba(0,0,0,0.5), 0 4px 16px rgba(0,0,0,0.3);
    --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --smooth: cubic-bezier(0.16, 1, 0.3, 1);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', sans-serif;
    font-size: 17px;
    line-height: 1.65;
    font-weight: 400;
    background: var(--deep-bg);
    color: var(--light);
    overflow-x: hidden;
    position: relative;
}

/* --- SVG Filters (hidden) --- */
.svg-filters {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* --- Noise Overlay --- */
.noise-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    pointer-events: none;
    opacity: 0.04;
    mix-blend-mode: overlay;
    filter: url(#noise);
    width: 100%;
    height: 100%;
}

/* --- Dot Grid --- */
.dot-grid {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-image: radial-gradient(circle, rgba(255,255,255,0.12) 1.5px, transparent 1.5px);
    background-size: 48px 48px;
}

/* --- Connection Lines --- */
.connection-lines {
    position: fixed;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    width: 100%;
    height: 100%;
}

/* --- Marginalia --- */
.marginalia {
    position: fixed;
    font-family: 'Space Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.08em;
    color: rgba(196, 181, 253, 0.35);
    writing-mode: vertical-rl;
    text-orientation: mixed;
    left: 24px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    transition: color 0.6s ease;
}

.marginalia--right {
    left: auto;
    right: 24px;
    writing-mode: vertical-lr;
}

.marginalia--inline {
    position: absolute;
    writing-mode: horizontal-tb;
    left: 40px;
    top: 40px;
    font-size: 11px;
    color: rgba(196, 181, 253, 0.3);
}

/* --- Chapter Progress --- */
.chapter-progress {
    position: fixed;
    right: 0;
    top: 0;
    width: 3px;
    height: 100vh;
    z-index: 100;
    background: rgba(255,255,255,0.05);
}

.chapter-progress__fill {
    width: 100%;
    height: 0%;
    background: linear-gradient(180deg, var(--cyan), var(--coral));
    transition: height 0.3s ease;
    border-radius: 0 0 2px 2px;
}

/* --- Chapters --- */
.chapter {
    min-height: 100vh;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 80px 60px;
    z-index: 2;
}

.chapter__inner {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 24px;
    max-width: 1200px;
    width: 100%;
    position: relative;
}

/* --- Modules (Inflated 3D Blocks) --- */
.module {
    background: linear-gradient(135deg, rgba(20, 24, 49, 0.9), rgba(26, 26, 46, 0.95));
    border-radius: var(--radius);
    padding: 40px;
    position: relative;
    box-shadow: var(--shadow-depth);
    border: 1px solid rgba(255,255,255,0.06);
    transition: transform 0.5s var(--spring), box-shadow 0.5s ease;
    overflow: hidden;
    /* Blur-focus initial state */
    opacity: 0;
    filter: blur(16px);
    transform: translateY(40px) scale(0.96);
}

.module.in-view {
    opacity: 1;
    filter: blur(0px);
    transform: translateY(0) scale(1);
    transition: opacity 0.8s var(--smooth), filter 0.8s var(--smooth), transform 0.8s var(--smooth);
}

/* Module noise texture */
.module::before {
    content: '';
    position: absolute;
    inset: 0;
    filter: url(#noise-heavy);
    opacity: 0.08;
    mix-blend-mode: overlay;
    pointer-events: none;
    border-radius: var(--radius);
}

/* Directional lighting gradient */
.module::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.04) 0%, transparent 50%, rgba(0,0,0,0.1) 100%);
    pointer-events: none;
    border-radius: var(--radius);
}

.module:hover {
    transform: translateY(-4px) scale(1.01);
    box-shadow: var(--shadow-hover);
}

/* Module sizes */
.module--span2 { grid-column: span 4; }
.module--span3 { grid-column: span 5; }
.module--span4 { grid-column: span 7; }

.module--offset { grid-column-start: 7; }
.module--float { justify-self: end; }

.module--large { z-index: 5; }
.module--medium { z-index: 3; }
.module--small { z-index: 2; padding: 28px; }

/* --- Module Label (academic notation) --- */
.module__label {
    font-family: 'Space Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--lavender);
    opacity: 0.5;
    display: block;
    margin-bottom: 16px;
}

/* --- Chapter Title (kinetic) --- */
.chapter-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: clamp(40px, 6vw, 80px);
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.05;
    color: var(--white);
    margin-bottom: 20px;
}

.chapter-title .char {
    display: inline-block;
    opacity: 0;
    transform: translateY(30px) scale(0.8);
    transition: opacity 0.5s var(--spring), transform 0.5s var(--spring);
}

.chapter-title.animated .char {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* --- Module Title --- */
.module__title {
    font-family: 'Syne', sans-serif;
    font-size: clamp(22px, 2.5vw, 32px);
    font-weight: 700;
    color: var(--white);
    margin-bottom: 14px;
    line-height: 1.2;
}

/* --- Module Body --- */
.module__body {
    font-size: 16px;
    line-height: 1.65;
    color: var(--light);
    opacity: 0.85;
    font-weight: 400;
}

/* --- Stats --- */
.module__stat {
    text-align: center;
}

.stat__number {
    font-family: 'Space Grotesk', sans-serif;
    font-size: clamp(36px, 4vw, 56px);
    font-weight: 700;
    color: var(--cyan);
    display: block;
    line-height: 1.1;
}

.stat__label {
    font-family: 'Space Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--lavender);
    opacity: 0.6;
    margin-top: 8px;
    display: block;
}

/* --- CTA Button --- */
.cta-button {
    display: inline-block;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.01em;
    padding: 16px 40px;
    border-radius: 60px;
    background: linear-gradient(135deg, var(--coral), #ff8a8a);
    color: var(--white);
    text-decoration: none;
    margin-top: 24px;
    margin-right: 12px;
    transition: transform 0.4s var(--spring), box-shadow 0.4s ease;
    box-shadow: 0 4px 20px rgba(255, 107, 107, 0.3);
}

.cta-button:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 32px rgba(255, 107, 107, 0.5);
}

.cta-button--secondary {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.2);
    box-shadow: none;
}

.cta-button--secondary:hover {
    background: rgba(255,255,255,0.05);
    box-shadow: 0 4px 20px rgba(255,255,255,0.1);
}

/* --- Chapter-specific accents --- */
.chapter--hero .module--large {
    border-top: 2px solid var(--coral);
}

.chapter--discovery .module--large {
    border-top: 2px solid var(--cyan);
}

.chapter--reading .module--large {
    border-top: 2px solid var(--green);
}

.chapter--collab .module--large {
    border-top: 2px solid var(--amber);
}

.chapter--cta .module--cta {
    text-align: center;
    background: linear-gradient(135deg, rgba(26, 26, 46, 0.95), rgba(10, 14, 39, 0.98));
    border: 1px solid rgba(255, 107, 107, 0.15);
    grid-column: 3 / 11;
}

/* --- Responsive --- */
@media (max-width: 900px) {
    .chapter {
        padding: 60px 24px;
    }
    .chapter__inner {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    .module--span2,
    .module--span3,
    .module--span4 {
        grid-column: span 1;
    }
    .module--offset {
        grid-column-start: auto;
    }
    .chapter--cta .module--cta {
        grid-column: span 1;
    }
    .marginalia {
        display: none;
    }
    .marginalia--inline {
        display: block;
        position: relative;
        left: 0;
        top: 0;
        writing-mode: horizontal-tb;
        margin-bottom: 12px;
    }
}
