/* ========================================
   continua.quest — Styles
   Dark-academia split-screen codex
   ======================================== */

/* CSS Custom Properties */
:root {
    --color-deep-ground: #1c1410;
    --color-surface: #f5ede0;
    --color-accent-primary: #a0845c;
    --color-accent-highlight: #d4a955;
    --color-text-primary: #3a2e24;
    --color-text-secondary: #8b7355;
    --color-glitch: #b87333;
    --color-marble-vein: #e8dcc8;

    --space-xs: 0.5rem;
    --space-sm: 1rem;
    --space-md: 2rem;
    --space-lg: 4rem;
    --space-xl: 6rem;

    --ease-refined: cubic-bezier(0.25, 0.1, 0.25, 1);
    --marble-shift: 0;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Quicksand', sans-serif;
    font-weight: 400;
    color: var(--color-text-primary);
    background: var(--color-deep-ground);
    line-height: 1.7;
    overflow-x: hidden;
}

/* Split Screen Layout */
.split-screen {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* INDEX PANE */
.index-pane {
    width: clamp(280px, 38.2vw, 580px);
    flex-shrink: 0;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    background-color: var(--color-deep-ground);
    z-index: 10;
    overflow: hidden;
}

/* Marble texture via CSS gradients */
.index-pane::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(232, 220, 200, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(232, 220, 200, 0.04) 0%, transparent 40%),
        radial-gradient(ellipse at 50% 80%, rgba(232, 220, 200, 0.05) 0%, transparent 45%),
        radial-gradient(ellipse at 70% 60%, rgba(232, 220, 200, 0.03) 0%, transparent 35%),
        radial-gradient(circle at 30% 30%, rgba(160, 132, 92, 0.04) 0%, transparent 30%);
    transform: translateY(calc(var(--marble-shift) * 1px));
    transition: transform 0.5s var(--ease-refined);
    pointer-events: none;
}

.index-pane::after {
    content: '';
    position: absolute;
    inset: 0;
    background:
        repeating-conic-gradient(from 45deg at 25% 35%, transparent 0deg, rgba(232, 220, 200, 0.03) 2deg, transparent 4deg),
        repeating-conic-gradient(from 120deg at 75% 65%, transparent 0deg, rgba(232, 220, 200, 0.04) 1.5deg, transparent 3deg);
    filter: contrast(1.1) brightness(1.02);
    transform: translateY(calc(var(--marble-shift) * -0.5px));
    pointer-events: none;
    opacity: 0.7;
}

.index-inner {
    position: relative;
    z-index: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-md) var(--space-sm);
}

/* Column Capitals */
.column-capitals {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: var(--space-sm);
    padding-top: var(--space-md);
    margin-bottom: var(--space-md);
}

.capital-left, .capital-right {
    opacity: 0.6;
    flex-shrink: 0;
}

.wordmark-container {
    text-align: center;
}

.wordmark {
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: clamp(1.6rem, 3vw, 2.8rem);
    color: var(--color-accent-highlight);
    letter-spacing: 0.01em;
    line-height: 1.15;
}

.subtitle {
    font-family: 'Caveat', cursive;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.6vw, 1.2rem);
    color: var(--color-text-secondary);
    margin-top: var(--space-xs);
}

/* Chapter Navigation */
.chapter-nav {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    margin-top: var(--space-lg);
    flex-grow: 1;
}

.chapter-indicator {
    position: absolute;
    left: -12px;
    top: 0;
    width: 3px;
    height: 24px;
    background: var(--color-accent-highlight);
    border-radius: 2px;
    transition: top 0.4s var(--ease-refined);
}

.chapter-link {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    text-decoration: none;
    padding: 4px 0;
    transition: opacity 0.3s var(--ease-refined);
    opacity: 0.5;
}

.chapter-link.active {
    opacity: 1;
}

.chapter-numeral {
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--color-accent-highlight);
    min-width: 28px;
}

.chapter-label {
    font-family: 'Caveat', cursive;
    font-size: clamp(0.85rem, 1.4vw, 1rem);
    color: var(--color-text-secondary);
}

/* Index Ghost Quote */
.index-ghost-quote {
    font-family: 'Caveat', cursive;
    font-size: clamp(1rem, 1.8vw, 1.3rem);
    color: var(--color-accent-highlight);
    opacity: 0;
    text-align: center;
    padding: var(--space-sm);
    transition: opacity 0.6s var(--ease-refined);
    max-width: 90%;
}

.index-ghost-quote.visible {
    opacity: 0.4;
}

/* Compass Rose */
.compass-container {
    margin-top: auto;
    padding-bottom: var(--space-md);
}

.compass-rose {
    animation: compassRotate 720s linear infinite;
    opacity: 0.8;
}

@keyframes compassRotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.compass-rose.accelerate {
    animation-duration: 72s;
}

/* GUTTER */
.gutter {
    position: fixed;
    left: clamp(280px, 38.2vw, 580px);
    top: 0;
    width: 2px;
    height: 100vh;
    background: var(--color-accent-primary);
    box-shadow: 0 0 12px rgba(160, 132, 92, 0.15);
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
}

.infinity-knot {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 0.6s var(--ease-refined);
    background: var(--color-deep-ground);
    padding: 4px;
    border-radius: 50%;
}

.infinity-knot.visible {
    opacity: 1;
    animation: infinityPulse 2s var(--ease-refined) infinite;
}

@keyframes infinityPulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

/* CORPUS PANE */
.corpus-pane {
    margin-left: clamp(282px, calc(38.2vw + 2px), 582px);
    width: calc(100% - clamp(282px, calc(38.2vw + 2px), 582px));
    background: var(--color-surface);
    min-height: 100vh;
}

/* Scenes */
.scene {
    padding: clamp(2rem, 5vw, 6rem);
    min-height: 100vh;
    display: flex;
    align-items: center;
}

.scene-threshold,
.scene-finale {
    min-height: 100vh;
    justify-content: center;
}

.scene-content {
    max-width: 680px;
    width: 100%;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s var(--ease-refined), transform 0.6s var(--ease-refined);
}

.scene-content.visible {
    opacity: 1;
    transform: translateY(0);
}

.centered-statement {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.opening-quote {
    font-family: 'Quicksand', sans-serif;
    font-weight: 600;
    font-size: clamp(1.6rem, 3vw, 2.4rem);
    color: var(--color-text-primary);
    line-height: 1.4;
    max-width: 560px;
}

.closing-quote {
    font-family: 'Quicksand', sans-serif;
    font-weight: 600;
    font-size: clamp(1.6rem, 3vw, 2.4rem);
    color: var(--color-text-primary);
    line-height: 1.4;
}

.infinity-symbol {
    font-family: 'Nunito', sans-serif;
    font-size: 4rem;
    color: var(--color-accent-highlight);
    margin-top: var(--space-md);
    opacity: 0.6;
}

/* Chapter Titles */
.chapter-title {
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: clamp(2.4rem, 5.5vw, 4.8rem);
    color: var(--color-deep-ground);
    letter-spacing: 0.01em;
    line-height: 1.15;
    margin-bottom: var(--space-md);
}

/* Body text */
.scene-content p {
    font-family: 'Quicksand', sans-serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.2rem);
    color: var(--color-text-primary);
    line-height: 1.7;
    margin-bottom: var(--space-sm);
}

.scene-content p em {
    font-style: italic;
    color: var(--color-text-secondary);
}

/* Pull-Quote Breach */
.pull-quote-breach {
    margin: var(--space-md) 0;
    margin-left: clamp(-120px, -10vw, -60px);
    padding: var(--space-sm) var(--space-md);
    border-left: 3px solid var(--color-accent-highlight);
}

.pull-quote-text {
    font-family: 'Caveat', cursive;
    font-size: clamp(1.4rem, 2.5vw, 2rem);
    color: var(--color-accent-highlight);
    line-height: 1.4;
}

/* Acanthus Dividers */
.acanthus-divider {
    padding: var(--space-sm) clamp(2rem, 5vw, 6rem);
    display: flex;
    justify-content: center;
}

.acanthus-divider svg {
    width: 100%;
    max-width: 400px;
    height: 30px;
}

.acanthus-path {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 0.8s var(--ease-refined);
}

.acanthus-divider.drawn .acanthus-path {
    stroke-dashoffset: 0;
}

/* Palimpsest Glitch Effect */
.scene-palimpsest .scene-content.glitching {
    animation: palimpsestGlitch 200ms var(--ease-refined);
}

@keyframes palimpsestGlitch {
    0% { transform: translateY(0); filter: none; }
    25% { transform: translate(3px, -2px); filter: contrast(1.2); }
    50% { transform: translate(-3px, 2px); mix-blend-mode: difference; }
    75% { transform: translate(1px, -1px); }
    100% { transform: translateY(0); filter: none; }
}

/* Marble Initial Pulse */
@keyframes marblePulse {
    0% { opacity: 0.3; }
    50% { opacity: 1; }
    100% { opacity: 0.7; }
}

.index-pane.marble-pulse::before {
    animation: marblePulse 2s var(--ease-refined) forwards;
}

/* Mobile Bar */
.mobile-bar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--color-deep-ground);
    z-index: 100;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-sm);
    border-bottom: 1px solid var(--color-accent-primary);
}

.mobile-wordmark {
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--color-accent-highlight);
}

.mobile-chapters {
    display: flex;
    gap: var(--space-sm);
}

.mobile-chapter {
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    text-decoration: none;
    padding: 4px 8px;
    transition: color 0.3s var(--ease-refined);
}

.mobile-chapter.active {
    color: var(--color-accent-highlight);
}

/* Responsive: below 768px */
@media (max-width: 768px) {
    .index-pane,
    .gutter {
        display: none;
    }

    .mobile-bar {
        display: flex;
    }

    .corpus-pane {
        margin-left: 0;
        width: 100%;
        padding-top: 56px;
    }

    .pull-quote-breach {
        margin-left: 0;
    }

    .scene {
        padding: var(--space-md);
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .compass-rose {
        animation: none;
    }

    .scene-palimpsest .scene-content.glitching {
        animation: none;
    }

    .index-pane::before,
    .index-pane::after {
        transform: none;
    }

    .scene-content {
        opacity: 1;
        transform: none;
        transition: none;
    }

    .acanthus-path {
        stroke-dasharray: none;
        stroke-dashoffset: 0;
    }
}

/* Subtle background tone variations per scene */
.scene-threshold {
    background: var(--color-surface);
}

.scene-chapter:nth-of-type(odd) {
    background: color-mix(in srgb, var(--color-surface) 97%, var(--color-marble-vein) 3%);
}

.scene-chapter:nth-of-type(even) {
    background: color-mix(in srgb, var(--color-surface) 95%, var(--color-accent-primary) 5%);
}

.scene-finale {
    background: var(--color-surface);
}
