/* ═══════════════════════════════════════════════════════════
   BECOMING A WARLOCK - MAIN STYLESHEET
   Modern, readable, dark/light mode, responsive
   ═══════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────────────────── */
/* CSS CUSTOM PROPERTIES (THEME SYSTEM) */
/* ─────────────────────────────────────────────────────────── */

:root {
    /* Dark Mode Colors (Default) - Dark navy */
    --bg-primary: #0a0f1a;
    --bg-secondary: #0f1420;
    --bg-tertiary: #141925;
    --bg-elevated: #1a2332;

    --text-primary: #e8eaed;
    --text-secondary: #b0b0b0;
    --text-tertiary: #808080;

    --accent-cosmic: #5eead4;
    --accent-void: #5eead4;
    --accent-dim: #4dd4bd;

    --border-subtle: #1a2332;
    --border-medium: #2a3545;
    --border-strong: #3a4555;

    --shadow-small: 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-medium: 0 4px 16px rgba(0, 0, 0, 0.5);
    --shadow-large: 0 8px 32px rgba(0, 0, 0, 0.6);

    /* Typography Scale */
    --font-mono: 'SF Mono', 'Monaco', 'Cascadia Code', 'Roboto Mono', monospace;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    --font-heading: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;

    --text-xs: 0.75rem;    /* 12px */
    --text-sm: 0.875rem;   /* 14px */
    --text-base: 1rem;     /* 16px */
    --text-lg: 1.125rem;   /* 18px */
    --text-xl: 1.25rem;    /* 20px */
    --text-2xl: 1.5rem;    /* 24px */
    --text-3xl: 1.875rem;  /* 30px */
    --text-4xl: 2.25rem;   /* 36px */
    --text-5xl: 3rem;      /* 48px */

    /* Spacing Scale */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;
    --space-20: 5rem;

    /* Reading Optimized */
    --line-height-tight: 1.3;
    --line-height-normal: 1.6;
    --line-height-relaxed: 1.8;
    --reading-width: 70ch;
    --reading-width-narrow: 60ch;

    /* Modal Backdrop */
    --modal-backdrop: rgba(10, 15, 26, 0.95);
}

/* Light Mode Override - Warm off-white, easy on eyes */
.light-mode {
    --bg-primary: #f8f7f4;
    --bg-secondary: #f0efe9;
    --bg-tertiary: #e8e6dd;
    --bg-elevated: #fdfcfa;

    --text-primary: #1a1a1a;
    --text-secondary: #505050;
    --text-tertiary: #808080;

    --accent-cosmic: #14b8a6;
    --accent-void: #14b8a6;
    --accent-dim: #10a89a;

    --border-subtle: #e0e0e0;
    --border-medium: #c0c0c0;
    --border-strong: #a0a0a0;

    --shadow-small: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-medium: 0 4px 16px rgba(0, 0, 0, 0.12);
    --shadow-large: 0 8px 32px rgba(0, 0, 0, 0.16);

    /* Modal Backdrop */
    --modal-backdrop: rgba(248, 247, 244, 0.95);
}

/* ─────────────────────────────────────────────────────────── */
/* RESET & BASE STYLES */
/* ─────────────────────────────────────────────────────────── */

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Body Typography - Optimized for Book-Length Sustained Reading
   Desktop: 18px (var(--text-lg) = 1.125rem × 16px base)
   Mobile: 18px (1.125rem × 16px mobile base - see @media 768px)

   Design Rationale (Based on 2024 Typography Research):
   - 18px explicitly recommended as "a great size" for text-heavy pages
   - Range: 16-20px optimal for desktop book reading
   - Line-height: 1.6 (optimal: 1.5-1.7 for sustained reading)
   - Max-width: 70ch (optimal: 50-75 characters per line)
   - Font: Inter (modern, highly readable sans-serif)

   Why NOT smaller (16-17px):
   - 16px = minimum accessibility threshold (no safety margin)
   - Book-length content (2,500-word chapters) benefits from larger text
   - Reduces eye strain during sequential, sustained reading
   - Aligns with e-reader defaults (18-20px equivalent)

   References:
   - LearnUI Design: "16px minimum, 18px is a great size" (2024)
   - Toptal Typography Guide: 16-20px for text-heavy pages
   - iA (typography experts): Browser default (16px) or larger
   - WCAG: Line-height minimum 1.5, characters per line 50-75
*/
body {
    font-family: var(--font-body);
    font-size: var(--text-lg);  /* 18px - optimal for book reading */
    font-weight: 400;
    letter-spacing: 0.01em;
    line-height: var(--line-height-normal);  /* 1.6 - optimal for sustained reading */
    color: var(--text-primary);
    background-color: var(--bg-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
}

/* ─────────────────────────────────────────────────────────── */
/* TYPOGRAPHY */
/* ─────────────────────────────────────────────────────────── */

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    line-height: var(--line-height-tight);
    color: var(--text-primary);
    margin-bottom: var(--space-4);
}

h1 { font-size: var(--text-4xl); font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: var(--text-3xl); font-weight: 600; letter-spacing: -0.01em; }
h3 { font-size: var(--text-2xl); font-weight: 600; }
h4 { font-size: var(--text-xl); font-weight: 600; }
h5 { font-size: var(--text-lg); font-weight: 600; }
h6 { font-size: var(--text-base); font-weight: 600; }

p {
    margin-bottom: var(--space-5);
    max-width: var(--reading-width);
}

a {
    color: var(--accent-cosmic);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--accent-void);
}

strong {
    font-weight: 500;
    color: var(--text-primary);
}

em {
    font-style: italic;
}

code {
    font-family: var(--font-mono);
    font-size: 0.9em;
    padding: 0.15em 0.4em;
    background: var(--bg-tertiary);
    border-radius: 3px;
    border: 1px solid var(--border-subtle);
}

blockquote {
    margin: var(--space-6) 0;
    padding-left: var(--space-6);
    border-left: 3px solid var(--accent-cosmic);
    color: var(--text-secondary);
    font-style: italic;
}

/* ─────────────────────────────────────────────────────────── */
/* LANDING PAGE */
/* ─────────────────────────────────────────────────────────── */

.landing {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.landing-container {
    max-width: 800px;
    padding: var(--space-8);
    text-align: center;
    position: relative;
    z-index: 10;
}

.landing-header {
    margin-bottom: var(--space-12);
}

.warlock-sigil {
    width: 96px;
    height: 96px;
    margin: 0 auto var(--space-6);
    display: block;
}

.title-main {
    font-size: var(--text-5xl);
    font-weight: 700;
    margin-bottom: var(--space-4);
    color: var(--text-primary);
}

.subtitle {
    font-family: var(--font-body);
    font-size: var(--text-xl);
    font-weight: 400;
    color: var(--text-secondary);
    margin-bottom: var(--space-8);
}

.divider-cosmic {
    width: 200px;
    height: 1px;
    margin: var(--space-8) auto;
    background: var(--accent-cosmic);
    opacity: 0.3;
}

.tagline {
    font-family: var(--font-mono);
    font-size: var(--text-base);
    color: var(--text-tertiary);
    font-style: italic;
}

.landing-content {
    margin-bottom: var(--space-12);
}

.warning-box {
    background: var(--bg-elevated);
    border: 1px solid var(--border-medium);
    border-left: 4px solid var(--accent-cosmic);
    padding: var(--space-6);
    margin-bottom: var(--space-8);
    text-align: left;
    max-width: var(--reading-width-narrow);
    margin-left: auto;
    margin-right: auto;
}

.warning-box p {
    font-size: var(--text-base);
    margin-bottom: var(--space-3);
    max-width: none;
}

.warning-box p:last-child {
    margin-bottom: 0;
}

.cta-container {
    display: flex;
    gap: var(--space-4);
    justify-content: center;
    align-items: center;
    margin-bottom: var(--space-12);
}

.btn-portal {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4) var(--space-8);
    font-family: var(--font-heading);
    font-size: var(--text-lg);
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--accent-cosmic);
    background: transparent;
    border: 2px solid var(--accent-cosmic);
    border-radius: 0;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.btn-portal:hover {
    background: var(--bg-elevated);
    color: var(--accent-cosmic);
    border-color: var(--accent-dim);
    box-shadow: inset 0 0 16px rgba(94, 234, 212, 0.1);
    transform: none;
}

/* Optional scan line effect on hover */
.btn-portal::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent-cosmic), transparent);
    opacity: 0;
    transition: none;
}

.btn-portal:hover::before {
    animation: scanline 0.6s ease-out 0.1s forwards;
}

@keyframes scanline {
    0% {
        top: 0;
        opacity: 1;
    }
    100% {
        top: 100%;
        opacity: 0;
    }
}

.btn-theme {
    width: 44px;
    height: 44px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-medium);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.btn-theme:hover {
    background: var(--accent-cosmic);
    border-color: var(--accent-cosmic);
    transform: translateY(-2px) rotate(180deg);
}

.btn-theme:hover .theme-icon {
    color: var(--bg-primary);
}

.theme-icon {
    font-size: var(--text-lg);
    color: var(--text-secondary);
    transition: color 0.3s ease;
}

.landing-features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-6);
    margin-top: var(--space-12);
}

.feature {
    padding: var(--space-6);
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    transition: all 0.3s ease;
}

.feature:hover {
    border-color: var(--accent-cosmic);
    transform: translateY(-4px);
    box-shadow: var(--shadow-medium);
}

.feature-icon {
    width: 48px;
    height: 48px;
    display: block;
    margin: 0 auto var(--space-4);
    opacity: 0.8;
}

.feature h3 {
    font-size: var(--text-lg);
    margin-bottom: var(--space-3);
}

.feature p {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-bottom: 0;
    max-width: none;
}

.landing-footer {
    margin-top: var(--space-12);
    padding-top: var(--space-8);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.footer-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-6);
    margin-bottom: var(--space-4);
    width: 100%;
}

.social-links {
    display: flex;
    gap: var(--space-4);
    align-items: center;
    justify-content: center;
}

.social-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-medium);
    border-radius: 50%;
    transition: all 0.3s ease;
}

.social-link:hover {
    background: var(--accent-cosmic);
    border-color: var(--accent-cosmic);
    transform: translateY(-2px) rotate(180deg);
}

.social-icon {
    font-size: var(--text-lg);
    color: var(--text-secondary);
    transition: color 0.3s ease;
}

.social-link:hover .social-icon {
    color: var(--bg-primary);
}

/* Footer donate button - circular style matching theme/origin buttons */
.btn-donate {
    width: 44px;
    height: 44px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-elevated);
    border: 1px solid var(--border-medium);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-donate:hover {
    background: var(--accent-void);
    border-color: var(--accent-void);
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 4px 16px rgba(94, 234, 212, 0.3);
}

.btn-donate .donate-icon {
    font-size: 20px;
    transition: transform 0.3s ease;
}

.btn-donate:hover .donate-icon {
    transform: scale(1.1);
}

.footer-tagline {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    color: var(--text-tertiary);
    margin: 0;
    text-align: center;
}

.footer-copyright {
    font-family: var(--font-heading);
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    margin: var(--space-4) 0 0 0;
    text-align: center;
    opacity: 0.7;
}

/* ─────────────────────────────────────────────────────────── */
/* COUNTDOWN TIMER */
/* ─────────────────────────────────────────────────────────── */

.countdown-container {
    margin-top: var(--space-8);
    margin-bottom: var(--space-12);
    padding: var(--space-6);
    background: var(--bg-elevated);
    border: 1px solid var(--border-medium);
    border-radius: 8px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.countdown-label {
    font-family: var(--font-body);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    text-align: center;
    margin: 0 0 var(--space-4) 0;
    font-weight: 500;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.countdown-display {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-4);
}

.countdown-unit {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    transition: all 0.3s ease;
}

.countdown-unit:hover {
    border-color: var(--accent-cosmic);
    background: var(--bg-tertiary);
}

.countdown-value {
    font-family: var(--font-mono);
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--accent-cosmic);
    line-height: 1;
    text-align: center;
}

.countdown-label-small {
    font-family: var(--font-body);
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    margin-top: var(--space-2);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
}

/* Mobile: Stack into 2 columns, reduce font size */
@media (max-width: 768px) {
    .countdown-display {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-3);
    }

    .countdown-value {
        font-size: var(--text-xl);
    }

    .countdown-unit {
        padding: var(--space-3);
    }
}

/* Extra small: Compact layout */
@media (max-width: 480px) {
    .countdown-container {
        padding: var(--space-4);
        margin-top: var(--space-6);
    }

    .countdown-label {
        font-size: var(--text-xs);
        margin-bottom: var(--space-3);
    }

    .countdown-value {
        font-size: var(--text-lg);
    }

    .countdown-label-small {
        font-size: 10px;
        margin-top: 2px;
    }

    .countdown-unit {
        padding: var(--space-2);
    }
}

/* Light mode adjustments */
.light-mode .countdown-unit:hover {
    background: var(--bg-elevated);
}

/* ─────────────────────────────────────────────────────────── */
/* READER INTERFACE */
/* ─────────────────────────────────────────────────────────── */

.reading {
    display: grid;
    grid-template-columns: 300px 1fr;
    min-height: 100vh;
}

/* Fixed Theme Toggle Button - NO LONGER USED (moved to footer) */
.btn-theme-fixed {
    display: none;
}

.main-nav {
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-subtle);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.nav-header {
    padding: var(--space-8) var(--space-6);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-4);
}

.nav-home-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: transparent;
    border: none;
    transition: all 0.3s ease;
    isolation: isolate;
    flex-shrink: 0;
}

.nav-home-link:hover {
    background: var(--bg-elevated);
    border-color: var(--accent-cosmic);
    transform: scale(1.1);
}

.home-icon {
    width: 32px;
    height: 32px;
    display: block;
    object-fit: contain;
    /* Remove white background artifacts from PNG - same approach as warlock-sigil */
    mix-blend-mode: screen;
    filter: drop-shadow(0 0 8px rgba(94, 234, 212, 0.15));
}

.nav-title {
    font-size: var(--text-xl);
    margin: 0;
    flex: 1;
    color: var(--text-primary);
}

.nav-toggle {
    display: none;
    flex-direction: column;
    gap: 4px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-medium);
    border-radius: 6px;
    cursor: pointer;
    padding: var(--space-3);
    transition: all 0.3s ease;
    z-index: 1001;
}

.nav-toggle:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-cosmic);
}

.nav-toggle:active {
    transform: scale(0.95);
}

.nav-toggle span {
    width: 24px;
    height: 2px;
    background: var(--text-primary);
    transition: all 0.3s ease;
    transform-origin: center;
}

/* Hamburger to X animation when nav is open */
.main-nav.open ~ * .nav-toggle span:nth-child(1),
.nav-toggle.active span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}

.main-nav.open ~ * .nav-toggle span:nth-child(2),
.nav-toggle.active span:nth-child(2) {
    opacity: 0;
}

.main-nav.open ~ * .nav-toggle span:nth-child(3),
.nav-toggle.active span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

.nav-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.chapter-list {
    list-style: none;
    padding: var(--space-4) 0;
    flex: 1;
}

.chapter-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-6);
    margin-bottom: var(--space-1);
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.chapter-item:hover {
    background: var(--bg-tertiary);
}

.chapter-item.active {
    background: var(--bg-tertiary);
    border-left-color: var(--accent-void);
}

.chapter-icon {
    width: 24px;
    height: 24px;
    display: block;
    object-fit: contain;
    flex-shrink: 0;
    filter: grayscale(100%) brightness(0.7);
    opacity: 0.5;
    transition: all 0.3s ease;
}

.chapter-item.active .chapter-icon {
    filter: grayscale(0%) brightness(1);
    opacity: 1;
    transform: scale(1.3);
}

.chapter-title {
    font-size: var(--text-sm);
    font-family: var(--font-heading);
    color: var(--text-secondary);
}

.chapter-item.active .chapter-title {
    color: var(--text-primary);
    font-weight: 600;
}

.chapter-item.disabled {
    cursor: not-allowed;
    opacity: 0.2;
}

.chapter-item.disabled:hover {
    background: transparent;
    transform: none;
}

.chapter-item.disabled .chapter-icon {
    filter: grayscale(100%) brightness(0.4);
}

/* ─────────────────────────────────────────────────────────── */
/* READER MAIN CONTENT */
/* ─────────────────────────────────────────────────────────── */

.reader-main {
    padding: var(--space-8);
    max-width: 900px;
    margin: 0 auto;
    position: relative;
}

.reader-footer {
    margin-top: var(--space-16);
    padding-top: var(--space-8);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.chapter-content {
    margin-bottom: var(--space-12);
    min-height: 60vh;
    padding-top: var(--space-8);
}

/* Mobile: Extra padding to clear hamburger menu */
@media (max-width: 1024px) {
    .chapter-content {
        padding-top: 80px;
    }
}

/* Chapter Typography */
.chapter-content h1 {
    font-size: var(--text-4xl);
    margin-top: 0;
    margin-bottom: var(--space-6);
}

.chapter-content h2 {
    font-size: var(--text-2xl);
    margin-top: var(--space-10);
    margin-bottom: var(--space-5);
    padding-bottom: var(--space-3);
    border-bottom: 2px solid var(--border-subtle);
}

.chapter-content h3 {
    font-size: var(--text-xl);
    margin-top: var(--space-8);
    margin-bottom: var(--space-4);
}

.chapter-content h4 {
    font-size: var(--text-lg);
    margin-top: var(--space-6);
    margin-bottom: var(--space-3);
}

.chapter-content hr {
    margin: var(--space-8) 0;
    border: none;
    border-top: 1px solid var(--border-subtle);
}

.chapter-content ul,
.chapter-content ol {
    margin: var(--space-5) 0;
    padding-left: var(--space-8);
}

.chapter-content li {
    margin-bottom: var(--space-3);
    line-height: var(--line-height-relaxed);
}

.chapter-content li:last-child {
    margin-bottom: 0;
}

.chapter-content blockquote {
    margin: var(--space-6) 0;
    padding: var(--space-5) var(--space-6);
    background: var(--bg-tertiary);
    border-left: 4px solid var(--accent-cosmic);
    border-radius: 4px;
}

.chapter-content blockquote p {
    margin-bottom: var(--space-3);
}

.chapter-content blockquote p:last-child {
    margin-bottom: 0;
}

.chapter-content pre {
    margin: var(--space-6) 0;
    padding: var(--space-5);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    overflow-x: auto;
}

.chapter-content pre code {
    background: none;
    border: none;
    padding: 0;
    font-size: var(--text-sm);
}

/* Chapter Navigation Buttons */
.chapter-navigation {
    display: flex;
    justify-content: space-between;
    gap: var(--space-4);
    margin-top: var(--space-12);
    padding-top: var(--space-8);
    border-top: 1px solid var(--border-subtle);
}

.btn-nav {
    flex: 1;
    padding: var(--space-4) var(--space-6);
    font-family: var(--font-heading);
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--text-primary);
    background: var(--bg-elevated);
    border: 1px solid var(--border-medium);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
}

.btn-nav:hover:not(:disabled) {
    background: var(--accent-cosmic);
    border-color: var(--accent-cosmic);
    color: var(--bg-primary);
    transform: translateY(-2px);
}

.btn-nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* ─────────────────────────────────────────────────────────── */
/* PRIVACY POLICY MODAL */
/* ─────────────────────────────────────────────────────────── */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: var(--space-8);
    overflow-y: auto;
}

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--modal-backdrop);
    z-index: -1;
}

.modal-container {
    background: var(--bg-primary);
    border: 1px solid var(--border-medium);
    border-radius: 12px;
    box-shadow: var(--shadow-large);
    width: 100%;
    max-width: 700px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    position: relative;
    margin-bottom: var(--space-8);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-6);
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

.modal-title {
    margin: 0;
    font-size: var(--text-2xl);
    color: var(--text-primary);
    flex: 1;
}

.modal-close {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-elevated);
    border: 1px solid var(--border-medium);
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: var(--text-2xl);
    line-height: 1;
    transition: all 0.2s ease;
    flex-shrink: 0;
    margin-left: var(--space-4);
}

.modal-close:hover {
    background: var(--accent-cosmic);
    border-color: var(--accent-cosmic);
    color: var(--bg-primary);
}

.modal-close:active {
    transform: scale(0.95);
}

.modal-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-6);
    line-height: var(--line-height-relaxed);
}

/* Scrollbar styling for long content */
.modal-content::-webkit-scrollbar {
    width: 8px;
}

.modal-content::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

.modal-content::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: 4px;
}

.modal-content::-webkit-scrollbar-thumb:hover {
    background: var(--border-strong);
}

/* Content typography within modal */
.modal-content h1 {
    font-size: var(--text-2xl);
    margin-top: 0;
    margin-bottom: var(--space-5);
}

.modal-content h2 {
    font-size: var(--text-xl);
    margin-top: var(--space-6);
    margin-bottom: var(--space-3);
    border-bottom: none;
    padding-bottom: 0;
}

.modal-content h3 {
    font-size: var(--text-lg);
    margin-top: var(--space-5);
    margin-bottom: var(--space-3);
}

.modal-content p {
    margin-bottom: var(--space-4);
    max-width: none;
}

.modal-content ul,
.modal-content ol {
    margin: var(--space-4) 0;
    padding-left: var(--space-6);
}

.modal-content li {
    margin-bottom: var(--space-2);
}

.modal-content code {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
}

.modal-content a {
    color: var(--accent-cosmic);
    text-decoration: underline;
}

.modal-content a:hover {
    color: var(--accent-void);
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .modal {
        padding-top: var(--space-4);
        padding-bottom: var(--space-4);
    }

    .modal-container {
        max-height: 95vh;
        margin: 0 var(--space-4);
        max-width: none;
    }

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

    .modal-title {
        font-size: var(--text-xl);
    }

    .modal-close {
        width: 40px;
        height: 40px;
        font-size: var(--text-lg);
    }

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

    .modal-content h2 {
        font-size: var(--text-lg);
    }
}

/* Light mode adjustments */
.light-mode .modal-backdrop {
    background: rgba(0, 0, 0, 0.4);
}

/* ─────────────────────────────────────────────────────────── */
/* RESPONSIVE DESIGN */
/* ─────────────────────────────────────────────────────────── */

@media (max-width: 1024px) {
    .reading {
        grid-template-columns: 1fr;
    }

    .main-nav {
        position: fixed;
        left: -300px;
        width: 300px;
        z-index: 1000;
        transition: left 0.3s ease;
        box-shadow: var(--shadow-large);
    }

    .main-nav.open {
        left: 0;
    }

    .nav-toggle {
        display: flex;
        position: fixed;
        top: 16px;
        right: 16px;
        z-index: 1100;
    }

    .reader-main {
        grid-column: 1;
    }

    .btn-theme-fixed {
        top: var(--space-4);
        right: var(--space-4);
    }
}

/* Mobile Breakpoint: Typography optimized for sustained reading on small screens
   - Base font-size: 16px (meets 2024 WCAG minimum, was 14px = 15.75px body)
   - Body text: 18px (16px × 1.125rem = same as desktop for consistency)
   - Rationale: 2024 best practices recommend 16-20px for mobile text-heavy pages
   - Reference: "16px is minimum, 18px is a great size" (LearnUI, Toptal 2024)
*/
@media (max-width: 768px) {
    :root {
        font-size: 16px;  /* Was 14px - increased to meet 16px minimum standard */
    }

    .title-main {
        font-size: var(--text-3xl);
    }

    .landing-container {
        padding: var(--space-6);
    }

    .landing-features {
        grid-template-columns: 1fr;
    }

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

    .chapter-navigation {
        flex-direction: column;
    }

    .cta-container {
        flex-direction: column;
    }

    .btn-portal {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .warlock-sigil {
        width: 60px;
        height: 60px;
    }

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

    .footer-actions {
        gap: var(--space-4);
    }

    .social-links {
        gap: var(--space-3);
    }

    .social-link,
    .btn-theme {
        width: 40px;
        height: 40px;
    }
}

/* ─────────────────────────────────────────────────────────── */
/* PRINT STYLES */
/* ─────────────────────────────────────────────────────────── */

@media print {
    .main-nav,
    .chapter-navigation,
    .btn-theme {
        display: none;
    }

    .reader-main {
        max-width: none;
    }

    body {
        background: white;
        color: black;
    }
}

/* ─────────────────────────────────────────────────────────── */
/* FRAMEWORK ORIGIN MODAL */
/* ─────────────────────────────────────────────────────────── */

/* Origin Button - Custom Tri-Axis Convergence Sigil */
.btn-origin {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--border-medium);
    background: var(--bg-elevated);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
    padding: 0;
}

.btn-origin:hover {
    background: var(--accent-cosmic);
    border-color: var(--accent-cosmic);
    transform: translateY(-2px) rotate(180deg);
}

.origin-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
    filter: none;
    transition: filter 0.3s ease;
}

.btn-origin:hover .origin-icon {
    animation: rotate3d 0.6s ease;
    filter: brightness(0.1);
}

/* 3D Rotation Animation (emphasizes impossible geometry) */
@keyframes rotate3d {
    0% {
        transform: perspective(200px) rotateY(0deg);
    }
    50% {
        transform: perspective(200px) rotateY(15deg);
    }
    100% {
        transform: perspective(200px) rotateY(0deg);
    }
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--modal-backdrop);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: var(--space-6);
}

/* Modal Container */
.modal-container {
    background: var(--bg-elevated);
    border: 1px solid var(--border-medium);
    border-radius: 12px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

/* Modal Header */
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-6);
    border-bottom: 1px solid var(--border-subtle);
}

.modal-header h2 {
    font-size: var(--text-2xl);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.modal-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border-medium);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1.5rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
}

.modal-close:hover {
    background: var(--accent-cosmic);
    color: var(--bg-primary);
    border-color: var(--accent-cosmic);
}

/* Modal Body - Increased padding for breathing room */
.modal-body {
    padding: 48px;
}

/* Origin Content Specific Styles */
.origin-content {
    color: var(--text-secondary);
    line-height: 1.8;
}

.origin-intro {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: 32px;
    font-weight: 400;
    line-height: 1.6;
}

/* Divider lines - subtle section separation */
.origin-divider {
    border: none;
    border-top: 1px solid rgba(94, 234, 212, 0.15);
    margin: 32px 0;
}

/* Section paragraphs - clean, spacious */
.origin-section {
    margin-bottom: 24px;
    font-size: var(--text-base);
    color: var(--text-secondary);
    line-height: 1.7;
}

.section-label {
    font-size: var(--text-sm);
    color: var(--accent-cosmic);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    display: inline-block;
    margin-bottom: 8px;
}

/* Disclaimer - softer treatment (border only, no background) */
.origin-disclaimer {
    padding: 24px;
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--border-radius);
    background: transparent;
}

.origin-disclaimer p {
    margin: 0;
    font-size: var(--text-base);
    color: var(--text-primary);
    font-weight: 600;
    letter-spacing: 0.02em;
}

.origin-disclaimer p + p {
    margin-top: 8px;
}

/* Origin Footer - italic for emphasis */
.origin-footer {
    font-size: var(--text-lg);
    color: var(--accent-cosmic);
    font-weight: 500;
    text-align: center;
    font-style: italic;
    margin: 0;
}

/* ============================================
   DONATION MODAL STYLES
   ============================================ */

.donate-content {
    text-align: center;
    color: var(--text-secondary);
    line-height: 1.8;
}

.donate-intro {
    font-size: 1.25rem;
    color: var(--text-primary);
    margin-bottom: 32px;
    font-weight: 400;
    line-height: 1.6;
}

.donate-cta {
    margin: 32px 0;
}

.btn-donate-cta {
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-8);
    font-family: var(--font-heading);
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--bg-primary);
    background: var(--accent-void);
    border: 2px solid var(--accent-void);
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.3s ease;
    box-shadow: 0 4px 16px rgba(94, 234, 212, 0.3);
}

.btn-donate-cta:hover {
    background: transparent;
    color: var(--accent-void);
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(94, 234, 212, 0.4);
}

.btn-donate-cta .donate-icon {
    font-size: 1.5rem;
}

.donate-note {
    font-size: var(--text-sm);
    color: var(--text-tertiary);
    margin: 0;
    font-style: italic;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .modal-overlay {
        padding: var(--space-4);
    }

    .modal-header {
        padding: 32px;
    }

    .modal-body {
        padding: 32px;
    }

    .modal-header h2 {
        font-size: var(--text-xl);
    }

    .origin-intro {
        font-size: 1.25rem;
    }

    .origin-section {
        margin-bottom: 20px;
    }

    .origin-divider {
        margin: 24px 0;
    }
}

@media (max-width: 480px) {
    .modal-overlay {
        padding: var(--space-3);
    }

    .modal-header,
    .modal-body {
        padding: 24px;
    }

    .btn-origin {
        width: 40px;
        height: 40px;
    }

    .origin-intro {
        font-size: var(--text-lg);
    }

    .origin-section {
        font-size: var(--text-sm);
    }

    .origin-divider {
        margin: 20px 0;
    }
}
