/* ============================================
   freedom.study -- styles.css
   Evolved-minimal, split-screen dialectical
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --neon-violet: #8B5CF6;
    --neon-cyan: #06D6A0;
    --study-dark: #121218;
    --paper-white: #F0ECE4;
    --rebellion-red: #EF4444;
    --neutral-slate: #64748B;
    --split-gold: #D4A843;
    --split-ratio: 50%;
}

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

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

body {
    background: var(--study-dark);
    color: var(--paper-white);
    font-family: 'Outfit', sans-serif;
    font-weight: 400;
    font-size: clamp(15px, 1.6vw, 19px);
    line-height: 1.75;
    overflow-x: hidden;
}

/* --- Typography --- */
h1, h2, h3 {
    font-family: 'Crimson Pro', serif;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.data-ref {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--neutral-slate);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: inline-block;
    margin-top: 1.5rem;
    border-left: 2px solid var(--split-gold);
    padding-left: 0.5rem;
}

/* --- Split Section Layout --- */
.split-section {
    position: relative;
    min-height: 100vh;
    display: grid;
    grid-template-columns: var(--split-ratio) 2px calc(100% - var(--split-ratio) - 2px);
    overflow: hidden;
}

.split-section[data-split="60-40"] { --split-ratio: 60%; }
.split-section[data-split="30-70"] { --split-ratio: 30%; }
.split-section[data-split="50-50"] { --split-ratio: 50%; }
.split-section[data-split="40-60"] { --split-ratio: 40%; }

.split-left,
.split-right {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(2rem, 5vw, 6rem);
    overflow: hidden;
}

.split-left {
    background: var(--study-dark);
}

.split-right {
    background: var(--study-dark);
}

/* --- Gradient Mesh Backgrounds --- */
.gradient-mesh {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}

.gradient-mesh--warm {
    background:
        radial-gradient(ellipse at 20% 30%, rgba(139, 92, 246, 0.08) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 70%, rgba(139, 92, 246, 0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(212, 168, 67, 0.03) 0%, transparent 70%);
}

.gradient-mesh--cool {
    background:
        radial-gradient(ellipse at 80% 30%, rgba(6, 214, 160, 0.08) 0%, transparent 60%),
        radial-gradient(ellipse at 20% 70%, rgba(6, 214, 160, 0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(212, 168, 67, 0.03) 0%, transparent 70%);
}

.split-content {
    position: relative;
    z-index: 2;
    max-width: 480px;
}

/* --- Split Divider Line --- */
.split-divider {
    position: relative;
    width: 2px;
    background: var(--split-gold);
    z-index: 10;
    will-change: transform;
}

.split-divider::before,
.split-divider::after {
    content: '';
    position: absolute;
    left: 0;
    width: 2px;
    height: 100%;
    background: var(--split-gold);
}

/* --- Hero Section --- */
#hero {
    --split-ratio: 50%;
}

.hero-title {
    font-size: clamp(48px, 10vw, 120px);
    font-weight: 800;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.hero-title--left {
    color: var(--paper-white);
    text-align: right;
    transform: translateX(-30px);
}

.hero-title--right {
    color: var(--paper-white);
    text-align: left;
    transform: translateX(30px);
}

.hero-title.visible {
    opacity: 1;
    transform: translateX(0);
}

.freedom-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: clamp(11px, 1.2vw, 14px);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin-top: 2rem;
    opacity: 0;
    transition: opacity 0.5s ease 1.8s;
}

.freedom-label--left {
    color: var(--neon-violet);
}

.freedom-label--right {
    color: var(--neon-cyan);
}

.freedom-label.visible {
    opacity: 1;
}

.freedom-desc {
    font-size: clamp(14px, 1.4vw, 17px);
    color: var(--neutral-slate);
    margin-top: 1rem;
    max-width: 360px;
    opacity: 0;
    transition: opacity 0.5s ease 2s;
}

.freedom-desc.visible {
    opacity: 1;
}

/* --- Section Titles --- */
.section-title {
    font-size: clamp(28px, 5vw, 64px);
    line-height: 1.1;
    margin-bottom: 1.5rem;
    position: relative;
}

.split-left .section-title {
    color: var(--neon-violet);
}

.split-right .section-title {
    color: var(--neon-cyan);
}

.section-body {
    color: var(--paper-white);
    opacity: 0.85;
    max-width: 420px;
}

/* --- Glitch Text Effect --- */
.glitch-text {
    position: relative;
}

.glitch-text::before,
.glitch-text::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
}

.glitch-text::before {
    color: var(--rebellion-red);
    z-index: -1;
}

.glitch-text::after {
    color: var(--neon-cyan);
    z-index: -1;
}

.glitch-text.glitching::before {
    animation: glitch-red 0.3s steps(3) forwards;
    opacity: 0.7;
}

.glitch-text.glitching::after {
    animation: glitch-cyan 0.3s steps(3) forwards;
    opacity: 0.7;
}

@keyframes glitch-red {
    0% { clip-path: inset(10% 0 80% 0); transform: translate(-2px, 0); }
    33% { clip-path: inset(40% 0 30% 0); transform: translate(2px, 0); }
    66% { clip-path: inset(70% 0 10% 0); transform: translate(-3px, 0); }
    100% { clip-path: inset(0 0 0 0); transform: translate(0); opacity: 0; }
}

@keyframes glitch-cyan {
    0% { clip-path: inset(80% 0 5% 0); transform: translate(2px, 0); }
    33% { clip-path: inset(20% 0 50% 0); transform: translate(-2px, 0); }
    66% { clip-path: inset(5% 0 70% 0); transform: translate(3px, 0); }
    100% { clip-path: inset(0 0 0 0); transform: translate(0); opacity: 0; }
}

/* --- Split Line Glitch Animation --- */
@keyframes line-glitch {
    0%, 90%, 100% { transform: translateX(0); }
    92% { transform: translateX(-3px); }
    94% { transform: translateX(3px); }
    96% { transform: translateX(-2px); }
    98% { transform: translateX(2px); }
}

.split-divider.glitching {
    animation: line-glitch 5s ease-in-out infinite;
}

/* --- Margin Annotations --- */
.margin-annotation {
    position: absolute;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--neutral-slate);
    opacity: 0;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    letter-spacing: 0.02em;
    line-height: 1.4;
    max-height: 70vh;
    overflow: hidden;
    z-index: 3;
    transition: opacity 0.8s ease;
    will-change: transform;
}

.margin-annotation.visible {
    opacity: 0.3;
}

.margin-annotation--left {
    left: clamp(8px, 1.5vw, 20px);
    top: 50%;
    transform: translateY(-50%);
}

.margin-annotation--right {
    right: clamp(8px, 1.5vw, 20px);
    top: 50%;
    transform: translateY(-50%);
}

/* --- Scroll Indicator --- */
.scroll-indicator {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    text-align: center;
    opacity: 0;
    transition: opacity 0.5s ease 2.5s;
}

.scroll-indicator.visible {
    opacity: 1;
}

.scroll-indicator__text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--neutral-slate);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    display: block;
    margin-bottom: 0.5rem;
}

.scroll-indicator__arrow {
    width: 1px;
    height: 30px;
    background: var(--split-gold);
    margin: 0 auto;
    position: relative;
    animation: scroll-pulse 2s ease-in-out infinite;
}

.scroll-indicator__arrow::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: -4px;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 6px solid var(--split-gold);
}

@keyframes scroll-pulse {
    0%, 100% { opacity: 0.4; transform: translateY(0); }
    50% { opacity: 1; transform: translateY(5px); }
}

/* --- Convergence Section --- */
.convergence-section {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--study-dark);
    text-align: center;
    padding: clamp(3rem, 8vw, 8rem);
    overflow: hidden;
}

.convergence-section::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 30% 40%, rgba(139, 92, 246, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 60%, rgba(6, 214, 160, 0.06) 0%, transparent 50%);
    pointer-events: none;
}

.convergence-content {
    position: relative;
    z-index: 2;
    max-width: 680px;
}

.convergence-title {
    font-size: clamp(32px, 5vw, 56px);
    color: var(--paper-white);
    margin-bottom: 2rem;
}

.convergence-body {
    color: var(--paper-white);
    opacity: 0.8;
    margin-bottom: 1.5rem;
}

.convergence-line {
    width: 60px;
    height: 2px;
    background: linear-gradient(90deg, var(--neon-violet), var(--split-gold), var(--neon-cyan));
    margin: 3rem auto;
}

.convergence-coda {
    font-family: 'Crimson Pro', serif;
    font-size: clamp(18px, 2.5vw, 28px);
    font-weight: 600;
    color: var(--split-gold);
    letter-spacing: 0.05em;
}

/* --- Reveal Animations --- */
.split-section .split-content {
    opacity: 0;
    transform: translateY(30px);
    filter: blur(10px);
    transition: opacity 0.6s ease, transform 0.6s ease, filter 0.6s ease;
}

.split-section.revealed .split-content {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
}

.convergence-content {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.convergence-section.revealed .convergence-content {
    opacity: 1;
    transform: translateY(0);
}

/* --- Opening Sequence: Body hidden until animation starts --- */
body.loading .split-section,
body.loading .convergence-section {
    visibility: hidden;
}

body.loading #hero {
    visibility: visible;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .split-section {
        grid-template-columns: 1fr 2px 1fr;
    }

    .split-left,
    .split-right {
        padding: clamp(1.5rem, 4vw, 3rem);
    }

    .margin-annotation {
        display: none;
    }

    .hero-title {
        font-size: clamp(32px, 12vw, 60px);
    }

    .section-title {
        font-size: clamp(22px, 6vw, 40px);
    }

    .split-content {
        max-width: 100%;
    }

    .section-body,
    .freedom-desc {
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .split-section {
        grid-template-columns: 1fr;
        grid-template-rows: auto 2px auto;
    }

    .split-divider {
        width: 100%;
        height: 2px;
    }

    .split-left,
    .split-right {
        min-height: 50vh;
    }
}
