/* ============================================
   THE EMERALD INDEX - DESIGN SYSTEM
   The pattern was always there.
   ============================================ */

/* ============================================
   COLOR PALETTE
   ============================================ */

:root {
    /* === CORE PALETTE (True Dark) === */
    --void-black: #050508;
    --charcoal: #0a0a0f;
    --obsidian: #0d0d14;
    --deep-space: #08080c;

    /* === PRIMARY ACCENT (Gold) === */
    --aged-gold: #d4af37;
    --amber: #f4d03f;
    --burnished-bronze: #b8860b;
    --ancient-copper: #996515;

    /* === MULTICOLOR ACCENTS === */
    --accent-globe: #d4af37;
    --accent-codex: #8b5cf6;
    --accent-gateway: #22d3ee;
    --accent-frequencies: #f59e0b;
    --accent-timeline: #f43f5e;
    --accent-network: #10b981;

    /* === MYSTICAL ACCENTS === */
    --burgundy: #1a0a1e;
    --aurora-green: #10b981;
    --cosmic-violet: #8b5cf6;
    --nebula-blue: #3b82f6;

    /* === TEXT COLORS === */
    --parchment: #e2e0db;
    --ancient-cream: #c8c3b8;
    --text-primary: #e2e0db;
    --text-secondary: #8a8a8f;
    --text-muted: #55555a;

    /* === UI SURFACES === */
    --panel-bg: rgba(10, 10, 15, 0.95);
    --panel-glass: rgba(12, 12, 18, 0.85);
    --panel-border: rgba(255, 255, 255, 0.06);
    --surface-highlight: rgba(255, 255, 255, 0.03);

    /* === GLOW EFFECTS === */
    --glow-gold: rgba(212, 175, 55, 0.4);
    --glow-green: rgba(16, 185, 129, 0.4);
    --glow-violet: rgba(139, 92, 246, 0.4);
    --glow-blue: rgba(34, 211, 238, 0.3);

    /* === GRADIENTS === */
    --gradient-void: radial-gradient(ellipse at center, #0a0a0f 0%, #050508 100%);
    --gradient-cosmos: radial-gradient(ellipse at 30% 20%, rgba(139, 92, 246, 0.05) 0%, transparent 50%),
                       radial-gradient(ellipse at 70% 80%, rgba(212, 175, 55, 0.04) 0%, transparent 50%);
    --gradient-gold-fade: linear-gradient(180deg, rgba(212, 175, 55, 0.1) 0%, transparent 100%);

    /* === CHAPTER COLORS === */
    --chapter-evidence: #f43f5e;
    --chapter-pattern: #d4af37;
    --chapter-source: #f59e0b;
    --chapter-controllers: #10b981;
    --chapter-convergence: #8b5cf6;

    /* === SEMANTIC COLORS === */
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #f43f5e;
    --info: #22d3ee;

    /* === SHADOWS === */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.6);
    --shadow-glow: 0 0 30px var(--glow-gold);

    /* === TRANSITIONS === */
    --transition-fast: 150ms ease-out;
    --transition-normal: 300ms ease-out;
    --transition-slow: 500ms ease-out;
    --transition-reveal: 800ms cubic-bezier(0.4, 0, 0.2, 1);

    /* === Z-INDEX LAYERS === */
    --z-base: 1;
    --z-panel: 100;
    --z-nav: 500;
    --z-overlay: 1000;
    --z-modal: 2000;
    --z-entrance: 9999;
}

/* ============================================
   TYPOGRAPHY
   ============================================ */

/* Fonts are loaded locally via css/fonts.css */

:root {
    /* === FONT FAMILIES === */
    --font-display: 'Cinzel', serif;
    --font-heading: 'Cormorant Garamond', serif;
    --font-body: 'Libre Baskerville', Georgia, serif;
    --font-mono: 'IBM Plex Mono', 'Consolas', monospace;

    /* === FONT SIZES (Modular Scale 1.25) === */
    --fs-xs: 0.64rem;     /* 10.24px */
    --fs-sm: 0.8rem;      /* 12.8px */
    --fs-base: 1rem;      /* 16px */
    --fs-md: 1.25rem;     /* 20px */
    --fs-lg: 1.563rem;    /* 25px */
    --fs-xl: 1.953rem;    /* 31.25px */
    --fs-2xl: 2.441rem;   /* 39px */
    --fs-3xl: 3.052rem;   /* 48.83px */
    --fs-display: 3.815rem; /* 61px */
    --fs-hero: 4.768rem;  /* 76.29px */

    /* === LINE HEIGHTS === */
    --lh-tight: 1.1;
    --lh-snug: 1.3;
    --lh-normal: 1.5;
    --lh-relaxed: 1.7;
    --lh-loose: 2;

    /* === LETTER SPACING === */
    --ls-tight: -0.02em;
    --ls-normal: 0;
    --ls-wide: 0.05em;
    --ls-wider: 0.1em;
    --ls-widest: 0.2em;
}

/* ============================================
   BASE TYPOGRAPHY STYLES
   ============================================ */

h1, .h1 {
    font-family: var(--font-display);
    font-size: var(--fs-display);
    font-weight: 700;
    line-height: var(--lh-tight);
    letter-spacing: var(--ls-wide);
    text-transform: uppercase;
    color: var(--aged-gold);
}

h2, .h2 {
    font-family: var(--font-display);
    font-size: var(--fs-2xl);
    font-weight: 600;
    line-height: var(--lh-snug);
    letter-spacing: var(--ls-wide);
    text-transform: uppercase;
    color: var(--parchment);
}

h3, .h3 {
    font-family: var(--font-heading);
    font-size: var(--fs-xl);
    font-weight: 600;
    line-height: var(--lh-snug);
    color: var(--aged-gold);
}

h4, .h4 {
    font-family: var(--font-heading);
    font-size: var(--fs-lg);
    font-weight: 500;
    line-height: var(--lh-normal);
    color: var(--ancient-cream);
}

h5, .h5 {
    font-family: var(--font-heading);
    font-size: var(--fs-md);
    font-weight: 500;
    line-height: var(--lh-normal);
    letter-spacing: var(--ls-wide);
    text-transform: uppercase;
    color: var(--text-secondary);
}

h6, .h6 {
    font-family: var(--font-mono);
    font-size: var(--fs-sm);
    font-weight: 500;
    line-height: var(--lh-normal);
    letter-spacing: var(--ls-wider);
    text-transform: uppercase;
    color: var(--text-muted);
}

p, .body-text {
    font-family: var(--font-body);
    font-size: var(--fs-base);
    line-height: var(--lh-relaxed);
    color: var(--text-primary);
}

.text-mono {
    font-family: var(--font-mono);
}

.text-display {
    font-family: var(--font-display);
}

.text-heading {
    font-family: var(--font-heading);
}

/* ============================================
   SPACING SYSTEM
   ============================================ */

:root {
    --space-1: 0.25rem;   /* 4px */
    --space-2: 0.5rem;    /* 8px */
    --space-3: 0.75rem;   /* 12px */
    --space-4: 1rem;      /* 16px */
    --space-5: 1.5rem;    /* 24px */
    --space-6: 2rem;      /* 32px */
    --space-7: 3rem;      /* 48px */
    --space-8: 4rem;      /* 64px */
    --space-9: 6rem;      /* 96px */
    --space-10: 8rem;     /* 128px */
}

/* ============================================
   COMPONENT: BUTTONS
   ============================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    font-family: var(--font-display);
    font-size: var(--fs-sm);
    font-weight: 500;
    letter-spacing: var(--ls-wider);
    text-transform: uppercase;
    text-decoration: none;
    border: 1px solid transparent;
    border-radius: 2px;
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transform: translateX(-100%);
    transition: transform var(--transition-slow);
}

.btn:hover::before {
    transform: translateX(100%);
}

.btn-primary {
    background: var(--aged-gold);
    color: var(--void-black);
    border-color: var(--aged-gold);
}

.btn-primary:hover {
    background: var(--burnished-bronze);
    border-color: var(--burnished-bronze);
    box-shadow: var(--shadow-glow);
    transform: translateY(-2px);
}

.btn-secondary {
    background: transparent;
    color: var(--aged-gold);
    border-color: var(--aged-gold);
}

.btn-secondary:hover {
    background: rgba(201, 162, 39, 0.1);
    box-shadow: 0 0 20px var(--glow-gold);
}

.btn-ghost {
    background: transparent;
    color: var(--parchment);
    border-color: rgba(240, 230, 211, 0.3);
}

.btn-ghost:hover {
    border-color: var(--parchment);
    background: rgba(240, 230, 211, 0.05);
}

/* ============================================
   COMPONENT: CARDS & PANELS
   ============================================ */

.panel {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 4px;
    padding: var(--space-5);
    position: relative;
    overflow: hidden;
}

/* Default top line — overridden by litho-panel when litho-lines.js loads */
.panel:not(.litho-panel)::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--aged-gold), transparent);
    opacity: 0.5;
}

.panel-glass {
    background: var(--panel-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.card {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 4px;
    padding: var(--space-5);
    transition: all var(--transition-normal);
}

/* When litho-card is applied, remove solid border and let litho frame handle it */
.card.litho-card {
    border: none;
}

.card:not(.litho-card):hover {
    border-color: var(--aged-gold);
    box-shadow: 0 0 30px rgba(201, 162, 39, 0.2);
    transform: translateY(-4px);
}

.card.litho-card:hover {
    box-shadow: 0 0 30px rgba(201, 162, 39, 0.2);
    transform: translateY(-4px);
}

.card-header {
    border-bottom: 1px solid var(--panel-border);
    padding-bottom: var(--space-4);
    margin-bottom: var(--space-4);
}

/* ============================================
   COMPONENT: NAVIGATION NODE
   ============================================ */

.nav-node {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--charcoal);
    border: 2px solid var(--panel-border);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
}

.nav-node::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 1px solid transparent;
    transition: all var(--transition-normal);
}

.nav-node:hover {
    border-color: var(--aged-gold);
    background: rgba(201, 162, 39, 0.1);
    transform: scale(1.1);
}

.nav-node:hover::after {
    border-color: var(--aged-gold);
    animation: pulse-ring 1.5s infinite;
}

.nav-node.active {
    border-color: var(--aged-gold);
    background: var(--aged-gold);
    color: var(--void-black);
    box-shadow: 0 0 30px var(--glow-gold);
}

/* ============================================
   COMPONENT: CHAPTER BADGE
   ============================================ */

.chapter-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) var(--space-3);
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    letter-spacing: var(--ls-wider);
    text-transform: uppercase;
    border-radius: 2px;
    background: rgba(0, 0, 0, 0.3);
}

.chapter-badge--evidence {
    color: var(--chapter-evidence);
    border: 1px solid var(--chapter-evidence);
}

.chapter-badge--pattern {
    color: var(--chapter-pattern);
    border: 1px solid var(--chapter-pattern);
}

.chapter-badge--source {
    color: var(--chapter-source);
    border: 1px solid var(--chapter-source);
}

.chapter-badge--controllers {
    color: var(--chapter-controllers);
    border: 1px solid var(--chapter-controllers);
}

.chapter-badge--convergence {
    color: var(--chapter-convergence);
    border: 1px solid var(--chapter-convergence);
}

/* ============================================
   COMPONENT: DATA DISPLAY
   ============================================ */

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

.stat-value {
    font-family: var(--font-display);
    font-size: var(--fs-3xl);
    font-weight: 700;
    color: var(--aged-gold);
    text-shadow: 0 0 20px var(--glow-gold);
    line-height: 1;
}

.stat-label {
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    color: var(--text-muted);
    letter-spacing: var(--ls-wider);
    text-transform: uppercase;
    margin-top: var(--space-2);
}

.data-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-3) 0;
    border-bottom: 1px solid rgba(201, 162, 39, 0.1);
    position: relative;
}

/* When litho-data-row is applied, remove solid border */
.data-row.litho-data-row {
    border-bottom: none;
    padding-bottom: calc(var(--space-3) + 2px);
}

.data-row:last-child {
    border-bottom: none;
}

.data-row.litho-data-row:last-child .litho-rule {
    display: none;
}

.data-label {
    font-family: var(--font-body);
    color: var(--text-secondary);
}

.data-value {
    font-family: var(--font-mono);
    color: var(--aged-gold);
}

/* ============================================
   COMPONENT: TOOLTIP
   ============================================ */

.tooltip {
    position: absolute;
    background: var(--panel-bg);
    border: 1px solid var(--aged-gold);
    border-radius: 4px;
    padding: var(--space-3) var(--space-4);
    font-family: var(--font-body);
    font-size: var(--fs-sm);
    color: var(--parchment);
    box-shadow: var(--shadow-lg), 0 0 20px var(--glow-gold);
    z-index: var(--z-overlay);
    pointer-events: none;
    opacity: 0;
    transform: translateY(4px);
    transition: all var(--transition-fast);
}

/* When litho-tooltip is applied, litho frame handles borders */
.tooltip.litho-tooltip {
    border: none;
    border-radius: 0;
}

.tooltip.visible {
    opacity: 1;
    transform: translateY(0);
}

.tooltip-title {
    font-family: var(--font-display);
    font-size: var(--fs-sm);
    color: var(--aged-gold);
    letter-spacing: var(--ls-wide);
    text-transform: uppercase;
    margin-bottom: var(--space-2);
}

/* ============================================
   COMPONENT: PROGRESS / LOADING
   ============================================ */

.progress-bar {
    height: 4px;
    background: var(--charcoal);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--aged-gold), var(--amber));
    border-radius: 2px;
    transition: width var(--transition-slow);
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmer 2s infinite;
}

/* ============================================
   ANIMATIONS
   ============================================ */

@keyframes pulse-ring {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

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

@keyframes glow-pulse {
    0%, 100% {
        box-shadow: 0 0 20px var(--glow-gold);
        opacity: 1;
    }
    50% {
        box-shadow: 0 0 40px var(--glow-gold), 0 0 60px var(--glow-gold);
        opacity: 0.8;
    }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

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

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Smooth page entrance — every page fades in on load */
body.auth-ready {
    animation: fade-in 0.4s ease-out;
}

@keyframes fade-in-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scale-in {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes draw-line {
    from { stroke-dashoffset: 1000; }
    to { stroke-dashoffset: 0; }
}

@keyframes particle-drift {
    0% {
        transform: translate(0, 0) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translate(var(--drift-x, 100px), var(--drift-y, -100px)) rotate(360deg);
        opacity: 0;
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

/* Animation utilities */
.animate-fade-in { animation: fade-in var(--transition-reveal); }
.animate-fade-in-up { animation: fade-in-up var(--transition-reveal); }
.animate-scale-in { animation: scale-in var(--transition-reveal); }
.animate-glow { animation: glow-pulse 2s infinite; }
.animate-float { animation: float 3s ease-in-out infinite; }
.animate-rotate { animation: rotate-slow 20s linear infinite; }

/* Text utilities */
.text-gold { color: var(--aged-gold); }
.text-amber { color: var(--amber); }
.text-green { color: var(--aurora-green); }
.text-violet { color: var(--cosmic-violet); }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.text-uppercase { text-transform: uppercase; }
.text-tracking-wide { letter-spacing: var(--ls-wide); }
.text-tracking-wider { letter-spacing: var(--ls-wider); }

/* Glow utilities */
.glow-gold { text-shadow: 0 0 20px var(--glow-gold); }
.glow-green { text-shadow: 0 0 20px var(--glow-green); }
.glow-violet { text-shadow: 0 0 20px var(--glow-violet); }
.glow-box { box-shadow: var(--shadow-glow); }

/* Layout utilities */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-col { flex-direction: column; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-5 { gap: var(--space-5); }

/* Spacing utilities */
.p-1 { padding: var(--space-1); }
.p-2 { padding: var(--space-2); }
.p-3 { padding: var(--space-3); }
.p-4 { padding: var(--space-4); }
.p-5 { padding: var(--space-5); }
.m-1 { margin: var(--space-1); }
.m-2 { margin: var(--space-2); }
.m-3 { margin: var(--space-3); }
.m-4 { margin: var(--space-4); }
.m-5 { margin: var(--space-5); }

/* ============================================
   SACRED GEOMETRY PATTERNS
   ============================================ */

.sacred-pattern {
    position: absolute;
    pointer-events: none;
    opacity: 0.1;
}

.sacred-pattern--flower-of-life {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ccircle cx='50' cy='50' r='25' fill='none' stroke='%230d9488' stroke-width='0.5'/%3E%3Ccircle cx='50' cy='25' r='25' fill='none' stroke='%230d9488' stroke-width='0.5'/%3E%3Ccircle cx='50' cy='75' r='25' fill='none' stroke='%230d9488' stroke-width='0.5'/%3E%3Ccircle cx='28.35' cy='37.5' r='25' fill='none' stroke='%230d9488' stroke-width='0.5'/%3E%3Ccircle cx='71.65' cy='37.5' r='25' fill='none' stroke='%230d9488' stroke-width='0.5'/%3E%3Ccircle cx='28.35' cy='62.5' r='25' fill='none' stroke='%230d9488' stroke-width='0.5'/%3E%3Ccircle cx='71.65' cy='62.5' r='25' fill='none' stroke='%230d9488' stroke-width='0.5'/%3E%3C/svg%3E");
    background-size: 200px 200px;
}

.sacred-pattern--metatron {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpolygon points='50,5 95,27.5 95,72.5 50,95 5,72.5 5,27.5' fill='none' stroke='%230d9488' stroke-width='0.3'/%3E%3Cpolygon points='50,20 80,35 80,65 50,80 20,65 20,35' fill='none' stroke='%230d9488' stroke-width='0.3'/%3E%3Ccircle cx='50' cy='50' r='30' fill='none' stroke='%230d9488' stroke-width='0.3'/%3E%3C/svg%3E");
    background-size: 150px 150px;
}

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

@media (max-width: 1200px) {
    :root {
        --fs-display: 3rem;
        --fs-hero: 4rem;
    }
}

@media (max-width: 768px) {
    :root {
        --fs-display: 2.25rem;
        --fs-hero: 2.75rem;
        --fs-3xl: 2rem;
        --fs-2xl: 1.75rem;
        --fs-xl: 1.5rem;
        --fs-lg: 1.25rem;
    }

    .panel {
        padding: var(--space-4);
    }
}

@media (max-width: 480px) {
    :root {
        --fs-display: 1.75rem;
        --fs-hero: 2rem;
        --fs-3xl: 1.5rem;
        --fs-2xl: 1.35rem;
        --fs-xl: 1.2rem;
        --fs-lg: 1.1rem;
    }
}

/* Small mobile (iPhone 12/13/14 standard) */
@media (max-width: 390px) {
    :root {
        --fs-display: 1.5rem;
        --fs-hero: 1.75rem;
        --fs-3xl: 1.35rem;
        --fs-2xl: 1.2rem;
        --fs-xl: 1.1rem;
        --fs-lg: 1rem;
    }
}

/* Very small mobile (iPhone SE, older devices) */
@media (max-width: 350px) {
    :root {
        --fs-display: 1.35rem;
        --fs-hero: 1.5rem;
        --fs-3xl: 1.2rem;
        --fs-2xl: 1.1rem;
        --fs-xl: 1rem;
        --fs-lg: 0.95rem;
    }
}

/* ============================================
   REDUCED MOTION
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================
   ENTRANCE EXPERIENCE
   ============================================ */

.entrance-overlay {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    z-index: var(--z-entrance);
    background: var(--void-black);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.entrance-overlay.skip-animation {
    transition: opacity 0.3s ease-out;
}

.entrance-overlay.departing {
    animation: entrance-depart 1.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes entrance-depart {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
    100% {
        opacity: 0;
        transform: scale(2);
    }
}

#entrance-canvas {
    position: absolute;
    inset: 0;
    width: 100vw;
    height: 100vh;
}

.entrance-content {
    position: relative;
    z-index: 2;
    text-align: center;
    padding: var(--space-8);
    max-width: 600px;
}

.entrance-symbols {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.entrance-title {
    font-family: var(--font-display);
    font-size: var(--fs-hero);
    font-weight: 500;
    color: var(--aged-gold);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    margin-bottom: var(--space-4);
    opacity: 0;
    transform: translateY(20px);
    transition: all 1s cubic-bezier(0.4, 0, 0.2, 1);
    text-shadow: 0 0 60px var(--glow-gold);
}

.entrance-title.visible {
    opacity: 1;
    transform: translateY(0);
}

.entrance-subtitle {
    font-family: var(--font-heading);
    font-size: var(--fs-xl);
    font-weight: 400;
    font-style: italic;
    color: var(--ancient-cream);
    margin-bottom: var(--space-8);
    opacity: 0;
    transform: translateY(20px);
    transition: all 1s cubic-bezier(0.4, 0, 0.2, 1) 0.3s;
}

.entrance-subtitle.visible {
    opacity: 0.9;
    transform: translateY(0);
}

.entrance-whisper {
    font-family: var(--font-body);
    font-size: var(--fs-lg);
    font-style: italic;
    color: var(--text-secondary);
    min-height: 3em;
    margin-bottom: var(--space-8);
    opacity: 0;
    transition: opacity 1s ease-in-out;
}

.entrance-begin {
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.entrance-begin.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.entrance-skip {
    display: block;
    margin: var(--space-6) auto 0;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-body);
    font-size: var(--fs-sm);
    cursor: pointer;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.5s ease-out;
    padding: var(--space-2) var(--space-4);
}

.entrance-skip.visible {
    opacity: 0.65;
    transform: translateY(0);
}

.entrance-skip:hover {
    opacity: 1;
    color: var(--ancient-cream);
}

.entrance-skip:focus-visible {
    outline: 2px solid rgba(201, 162, 39, 0.6);
    outline-offset: 3px;
    opacity: 1;
    color: var(--ancient-cream);
}

/* ============================================
   EMERALD INDEX LOADER
   ============================================ */

.athenaeum-loader {
    background: var(--void-black);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-6);
}

.sacred-geometry-loader {
    width: 120px;
    height: 120px;
}

.loader-svg {
    width: 100%;
    height: 100%;
}

.loader-circle {
    fill: none;
    stroke: var(--aged-gold);
    stroke-width: 0.5;
    transform-origin: center;
}

.loader-circle.outer {
    animation: rotate-cw 8s linear infinite;
}

.loader-circle.middle {
    animation: rotate-ccw 6s linear infinite;
    stroke: var(--aurora-green);
    opacity: 0.6;
}

.loader-circle.inner {
    animation: rotate-cw 4s linear infinite;
    stroke: var(--cosmic-violet);
    opacity: 0.4;
}

.loader-triangle {
    fill: none;
    stroke: var(--aged-gold);
    stroke-width: 0.8;
    transform-origin: center;
    animation: pulse-scale 2s ease-in-out infinite;
}

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

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

@keyframes pulse-scale {
    0%, 100% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.05); opacity: 1; }
}

.loader-text {
    font-family: var(--font-heading);
    font-size: var(--fs-lg);
    font-style: italic;
    color: var(--text-secondary);
    letter-spacing: 0.05em;
    animation: text-pulse 2s ease-in-out infinite;
}

@keyframes text-pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* ============================================
   EMERALD INDEX THEME OVERRIDES
   ============================================ */

body.magna-theme {
    background:
        /* Lapis wash — dominant atmosphere, deep midnight blue */
        radial-gradient(ellipse 1400px 900px at 20% 10%, rgba(25, 55, 110, 0.35), transparent 70%),
        /* Deep teal accent top-right — subtle, not turquoise-dominant */
        radial-gradient(ellipse 1000px 700px at 85% 5%, rgba(30, 80, 100, 0.20), transparent 65%),
        /* Violet anchor bottom — mystic depth */
        radial-gradient(ellipse 1800px 800px at 50% 100%, rgba(100, 50, 160, 0.22), transparent 70%),
        /* Warm gold center — lamplight warmth */
        radial-gradient(ellipse 900px 900px at 50% 40%, rgba(180, 140, 40, 0.10), transparent 55%),
        /* Turquoise whisper — garnish, not main course */
        radial-gradient(ellipse 800px 500px at 10% 60%, rgba(48, 180, 170, 0.12), transparent 60%),
        /* Deep indigo mid-field fill */
        radial-gradient(ellipse 1200px 700px at 60% 50%, rgba(20, 30, 70, 0.30), transparent 65%),
        /* Base — deep observatory blue-black */
        #0d1220;
    background-attachment: fixed;
    color: var(--text-primary);
    font-family: var(--font-body);
}

/* Noise grain overlay — tactile depth (z-index -1 so it never covers content) */
body.magna-theme::after {
    content: '';
    position: fixed;
    inset: 0;
    opacity: 1;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.09'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 512px 512px;
    pointer-events: none;
    z-index: -1;
    mix-blend-mode: overlay;
}

/* ============================================
   EMERALD INDEX HEADER
   ============================================ */

.athenaeum-header {
    background: linear-gradient(180deg, var(--charcoal) 0%, transparent 100%);
    padding: 0.3rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: nowrap;
    gap: 0.5rem;
    position: sticky;
    top: 0;
    z-index: var(--z-nav, 100);
    max-width: 100%;
    overflow: visible;
    box-sizing: border-box;
    will-change: auto;
    contain: style;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    flex-shrink: 0;
    min-width: 0;
}

.athenaeum-header .status-bar {
    flex-shrink: 1;
    min-width: 0;
    overflow: hidden;
}

.header-brand.is-clickable {
    cursor: pointer;
    user-select: none;
}

.header-brand.is-clickable:focus-visible {
    outline: 2px solid rgba(201, 162, 39, 0.6);
    outline-offset: 4px;
    border-radius: var(--radius-sm);
}

.header-titles h1 {
    font-family: var(--font-display);
    font-size: var(--fs-2xl);
    font-weight: 500;
    letter-spacing: 0.1em;
    margin: 0;
    background: linear-gradient(
        90deg,
        rgb(48, 213, 200) 0%,
        rgb(38, 97, 156) 30%,
        rgb(168, 112, 208) 60%,
        rgb(212, 175, 55) 85%,
        rgb(240, 200, 100) 100%
    );
    background-size: 200% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: logo-gradient-shift 8s ease-in-out infinite;
    filter: drop-shadow(0 0 12px rgba(48, 213, 200, 0.3))
            drop-shadow(0 0 24px rgba(168, 112, 208, 0.15));
}

@keyframes logo-gradient-shift {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.header-titles .subtitle {
    font-family: var(--font-heading);
    font-size: var(--fs-sm);
    font-style: italic;
    color: var(--text-secondary);
    margin: 0;
    letter-spacing: 0.05em;
}

.status-bar {
    display: flex;
    gap: var(--space-6);
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    color: var(--text-muted);
}

.status-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.status-item span {
    color: var(--aurora-green);
}

/* ============================================
   HEADER PYRAMID LOGO
   ============================================ */

.header-pyramid-logo {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    background: transparent;
    cursor: pointer;
    transition: opacity 0.3s, transform 0.3s, filter 0.3s;
    opacity: 0.95;
    filter: drop-shadow(0 0 6px rgba(48, 213, 200, 0.4))
            drop-shadow(0 0 14px rgba(168, 112, 208, 0.2));
}

.header-pyramid-logo:hover {
    opacity: 1;
    transform: scale(1.12);
    filter: drop-shadow(0 0 10px rgba(48, 213, 200, 0.6))
            drop-shadow(0 0 20px rgba(168, 112, 208, 0.35))
            drop-shadow(0 0 30px rgba(212, 175, 55, 0.2));
}

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

@media (max-width: 1024px) {
    .header-brand {
        max-width: 100%;
    }

    .header-titles h1 {
        font-size: var(--fs-xl);
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    .header-titles .subtitle {
        display: none;
    }

    .status-bar {
        width: auto;
        justify-content: flex-end;
        flex-wrap: nowrap;
        gap: var(--space-2);
        max-width: 100%;
        overflow: hidden;
    }

    .status-item {
        display: none;
    }

    .header-pyramid-logo {
        width: 36px;
        height: 36px;
        flex-shrink: 0;
        background: transparent;
    }

    /* Navigation menu responsive */
    .magna-theme .visualization-menu {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
        gap: var(--space-2);
        padding: var(--space-2) var(--space-3);
    }

    .magna-theme .nav-btn {
        padding: var(--space-2) var(--space-3);
        font-size: var(--fs-xs);
        text-align: center;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* ============================================
   EMERALD INDEX NAVIGATION MENU
   ============================================ */

.magna-theme .visualization-menu {
    background: linear-gradient(180deg, rgba(26, 26, 46, 0.95) 0%, rgba(10, 10, 15, 0.9) 100%);
    border-bottom: 1px solid var(--panel-border);
    padding: var(--space-3) var(--space-4);
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-2);
    overflow-x: hidden;
    overflow-y: visible;
    max-width: 100%;
    box-sizing: border-box;
    scrollbar-width: thin;
    scrollbar-color: var(--aged-gold) transparent;
    position: sticky;
    top: 0;
    z-index: var(--z-nav);
    backdrop-filter: blur(12px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}

.magna-theme .visualization-menu::-webkit-scrollbar {
    height: 4px;
}

.magna-theme .visualization-menu::-webkit-scrollbar-track {
    background: transparent;
}

.magna-theme .visualization-menu::-webkit-scrollbar-thumb {
    background: var(--aged-gold);
    border-radius: 2px;
}

.magna-theme .nav-btn {
    font-family: var(--font-heading);
    font-size: var(--fs-sm);
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid transparent;
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-sm);
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition-normal);
    position: relative;
}

.magna-theme .nav-btn:hover {
    color: var(--parchment);
    background: rgba(201, 162, 39, 0.1);
    border-color: rgba(201, 162, 39, 0.3);
}

.magna-theme .nav-btn.active {
    color: var(--aged-gold);
    background: rgba(201, 162, 39, 0.15);
    border-color: var(--aged-gold);
    text-shadow: 0 0 20px var(--glow-gold);
}

.magna-theme .nav-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 2px;
    background: var(--aged-gold);
    box-shadow: 0 0 10px var(--glow-gold);
}

.magna-theme .nav-btn:focus-visible {
    outline: 2px solid rgba(201, 162, 39, 0.6);
    outline-offset: 3px;
    color: var(--parchment);
}

/* Special Codex button */
.magna-theme .nav-btn.codex-special {
    background: linear-gradient(135deg, rgba(123, 44, 191, 0.2) 0%, rgba(201, 162, 39, 0.2) 100%);
    border-color: rgba(123, 44, 191, 0.4);
    color: var(--cosmic-violet);
}

.magna-theme .nav-btn.codex-special:hover {
    background: linear-gradient(135deg, rgba(123, 44, 191, 0.3) 0%, rgba(201, 162, 39, 0.3) 100%);
    border-color: var(--cosmic-violet);
    color: var(--parchment);
}

.magna-theme .nav-btn.codex-special.active {
    background: linear-gradient(135deg, rgba(123, 44, 191, 0.4) 0%, rgba(201, 162, 39, 0.4) 100%);
    border-color: var(--cosmic-violet);
    color: var(--parchment);
    text-shadow: 0 0 20px var(--glow-violet);
}

/* Special Protocol button */
.magna-theme .nav-btn.protocol-special {
    background: linear-gradient(135deg, rgba(78, 204, 163, 0.2) 0%, rgba(212, 165, 116, 0.2) 100%);
    border-color: rgba(78, 204, 163, 0.4);
    color: var(--aurora-green);
    text-decoration: none;
}

.magna-theme .nav-btn.protocol-special:hover {
    background: linear-gradient(135deg, rgba(78, 204, 163, 0.3) 0%, rgba(212, 165, 116, 0.3) 100%);
    border-color: var(--aurora-green);
    color: var(--parchment);
    box-shadow: 0 0 20px var(--glow-green);
}

/* ============================================
   EMERALD INDEX VISUALIZATION SECTIONS
   ============================================ */

.magna-theme .viz-section {
    background: transparent;
    color: var(--text-primary);
    padding: var(--space-6);
}

.magna-theme .viz-section h2 {
    font-family: var(--font-display);
    font-size: var(--fs-3xl);
    font-weight: 500;
    color: var(--aged-gold);
    text-align: center;
    margin-bottom: var(--space-6);
    letter-spacing: 0.1em;
    text-shadow: 0 0 40px var(--glow-gold);
}

.magna-theme .viz-section h3 {
    font-family: var(--font-heading);
    font-size: var(--fs-xl);
    font-weight: 600;
    color: var(--parchment);
    margin-bottom: var(--space-3);
}

.magna-theme .viz-section h4 {
    font-family: var(--font-heading);
    font-size: var(--fs-lg);
    font-weight: 500;
    color: var(--ancient-cream);
    margin-bottom: var(--space-2);
}

.magna-theme .viz-section p,
.magna-theme .viz-section li {
    font-family: var(--font-body);
    color: var(--text-secondary);
    line-height: 1.7;
}

.magna-theme .section-description {
    font-family: var(--font-heading);
    font-size: var(--fs-lg);
    font-style: italic;
    color: var(--text-secondary);
    text-align: center;
    max-width: 800px;
    margin: 0 auto var(--space-8);
}

/* ============================================
   EMERALD INDEX OVERVIEW CARDS
   ============================================ */

.magna-theme .overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--space-6);
    margin-bottom: var(--space-8);
}

.magna-theme .overview-card {
    background: var(--panel-glass);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.magna-theme .overview-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--aged-gold), var(--aurora-green), var(--cosmic-violet));
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.magna-theme .overview-card:hover {
    transform: translateY(-4px);
    border-color: var(--aged-gold);
    box-shadow: var(--shadow-glow);
}

.magna-theme .overview-card:hover::before {
    opacity: 1;
}

.magna-theme .overview-card h3 {
    font-family: var(--font-heading);
    font-size: var(--fs-lg);
    color: var(--ancient-cream);
    margin-bottom: var(--space-2);
}

.magna-theme .overview-card .stat-number {
    font-family: var(--font-mono);
    font-size: var(--fs-hero);
    font-weight: 600;
    color: var(--aged-gold);
    text-shadow: 0 0 30px var(--glow-gold);
    margin-bottom: var(--space-2);
}

.magna-theme .overview-card p {
    font-family: var(--font-body);
    font-size: var(--fs-sm);
    color: var(--text-muted);
}

.magna-theme .overview-card .mini-viz {
    margin-top: var(--space-4);
    height: 80px;
    opacity: 0.7;
}

/* ============================================
   EMERALD INDEX KEY INSIGHTS
   ============================================ */

.magna-theme .key-insights {
    background: var(--panel-glass);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    margin-bottom: var(--space-6);
}

.magna-theme .key-insights h3 {
    font-family: var(--font-display);
    font-size: var(--fs-xl);
    color: var(--aged-gold);
    margin-bottom: var(--space-4);
    letter-spacing: 0.05em;
}

.magna-theme .key-insights ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.magna-theme .key-insights li {
    position: relative;
    padding-left: var(--space-6);
    margin-bottom: var(--space-3);
    font-size: var(--fs-base);
}

.magna-theme .key-insights li::before {
    content: '◈';
    position: absolute;
    left: 0;
    color: var(--aurora-green);
    font-size: var(--fs-sm);
}

/* ============================================
   EMERALD INDEX CONTROLS & PANELS
   ============================================ */

.magna-theme .controls {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
    padding: var(--space-4);
    background: var(--panel-glass);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-6);
}

.magna-theme .controls label {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-family: var(--font-body);
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: color var(--transition-fast);
}

.magna-theme .controls label:hover {
    color: var(--parchment);
}

.magna-theme .controls input[type="checkbox"] {
    appearance: none;
    width: 18px;
    height: 18px;
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-xs);
    background: transparent;
    cursor: pointer;
    position: relative;
    transition: all var(--transition-fast);
}

.magna-theme .controls input[type="checkbox"]:checked {
    background: var(--aged-gold);
    border-color: var(--aged-gold);
}

.magna-theme .controls input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--void-black);
    font-size: 12px;
    font-weight: bold;
}

.magna-theme .info-panel {
    background: var(--panel-glass);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-md);
    padding: var(--space-4);
}

.magna-theme .info-panel h4 {
    font-family: var(--font-heading);
    color: var(--aged-gold);
    margin-bottom: var(--space-3);
}

/* ============================================
   EMERALD INDEX FOOTER
   ============================================ */

.magna-theme footer {
    background: linear-gradient(0deg, var(--charcoal) 0%, transparent 100%);
    padding: var(--space-8) var(--space-6);
    text-align: center;
    border-top: 1px solid var(--panel-border);
}

.magna-theme footer p {
    font-family: var(--font-heading);
    font-style: italic;
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

.magna-theme footer .disclaimer {
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    color: var(--text-muted);
    opacity: 0.6;
}

/* ============================================
   EMERALD INDEX VISUALIZATION OVERFLOW FIXES
   ============================================ */

/* Prevent horizontal overflow in athenaeum theme */
.magna-theme {
    overflow-x: hidden;
    max-width: 100vw;
}

.magna-theme .viz-section {
    position: relative;
    overflow-x: hidden;
    overflow-y: visible;
    max-width: 100%;
}

/* Fix visualization containers in athenaeum theme */
.magna-theme #visualization-container {
    overflow: hidden;
    position: relative;
    max-width: 100%;
}

/* Canvas and SVG containers */
.magna-theme .viz-section canvas {
    display: block;
    max-width: 100%;
}

.magna-theme .viz-section svg {
    display: block;
    max-width: 100%;
}

/* header overflow fix removed — single definition at line 1075 */

/* Fix navigation overflow */
.magna-theme .visualization-menu {
    overflow-x: auto;
    overflow-y: hidden;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
}

/* Ensure info panels don't overflow */
.magna-theme #earth-info-panel,
.magna-theme #codex-info-panel,
.magna-theme #codex-earth-panel,
.magna-theme .matrix-details-panel {
    max-width: calc(100% - 40px);
    overflow-y: auto;
    max-height: 80vh;
}

/* Mobile responsive overflow fixes for athenaeum */
@media (max-width: 768px) {
    .magna-theme {
        overflow-x: hidden;
    }

    .magna-theme .viz-section {
        overflow-x: hidden;
    }

    .magna-theme #earth-info-panel,
    .magna-theme #codex-info-panel,
    .magna-theme #codex-earth-panel,
    .magna-theme .matrix-details-panel {
        position: fixed;
        left: 10px;
        right: 10px;
        top: auto;
        bottom: 0;
        max-width: none;
        width: calc(100% - 20px);
        max-height: 50vh;
        border-radius: 12px 12px 0 0;
        transform: none;
    }

    .magna-theme .visualization-menu {
        padding: var(--space-2);
    }
}
