:root {
    --bg-deep: #0c0a08;
    --bg-surface: #16130f;
    --grid-color: #4a3f35;
    --text-primary: #e8e0d4;
    --text-secondary: #9a8e7f;
    --accent-gold: #c4a34d;
    --border-dark: #2e2822;
    --highlight: #1e1a14;
    --cursor-x: 50%;
    --cursor-y: 50%;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-deep);
    color: var(--text-primary);
    font-family: 'Libre Baskerville', Georgia, serif;
    font-weight: 400;
    line-height: 1.7;
    overflow-x: hidden;
    cursor: crosshair;
}

/* Infinite Grid Background */
.grid-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 0;
    background:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 59px,
            rgba(74, 63, 53, 0.06) 59px,
            rgba(74, 63, 53, 0.06) 60px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 59px,
            rgba(74, 63, 53, 0.06) 59px,
            rgba(74, 63, 53, 0.06) 60px
        );
}

/* Cursor Radial Glow / Lantern */
.cursor-glow {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 1000;
    background: radial-gradient(
        circle 120px at var(--cursor-x) var(--cursor-y),
        rgba(196, 163, 77, 0.03),
        transparent
    );
}

/* Sections */
.section {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    overflow: hidden;
}

.grid-layer {
    position: absolute;
    top: -20%;
    left: -20%;
    width: 140%;
    height: 140%;
    pointer-events: none;
    z-index: 0;
    transform: rotate(var(--grid-rotation, 0deg));
    background:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 59px,
            rgba(74, 63, 53, 0.04) 59px,
            rgba(74, 63, 53, 0.04) 60px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 59px,
            rgba(74, 63, 53, 0.04) 59px,
            rgba(74, 63, 53, 0.04) 60px
        );
}

.section-content {
    position: relative;
    z-index: 1;
    max-width: 680px;
    width: 100%;
    padding: 4rem 2rem;
    margin: 0 auto;
}

/* Symbol Dividers */
.symbol-divider {
    position: relative;
    z-index: 2;
    text-align: center;
    padding: 0.5rem 0;
    overflow: hidden;
    white-space: nowrap;
}

.symbol-divider span {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: var(--accent-gold);
    opacity: 0.4;
    letter-spacing: 24px;
}

/* ========================================
   Section 1: The Axiom
   ======================================== */

.section-axiom {
    min-height: 100vh;
    background: linear-gradient(180deg, var(--bg-deep) 0%, var(--bg-surface) 100%);
}

.section-axiom .section-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 100vh;
    padding-top: 0;
    padding-bottom: 0;
}

.axiom-symbol {
    font-family: 'Playfair Display', serif;
    font-weight: 900;
    font-size: clamp(4rem, 12vw, 10rem);
    color: var(--accent-gold);
    opacity: 0.15;
    line-height: 1;
    margin-bottom: 1rem;
    animation: symbolPulse 6s ease-in-out infinite;
}

@keyframes symbolPulse {
    0%, 100% { opacity: 0.1; transform: scale(1); }
    50% { opacity: 0.2; transform: scale(1.02); }
}

.domain-name {
    font-family: 'Playfair Display', serif;
    font-weight: 900;
    font-size: clamp(3.5rem, 8vw, 8rem);
    letter-spacing: -0.04em;
    line-height: 0.95;
    color: var(--text-primary);
    margin-bottom: 2rem;
}

/* Character-by-character reveal */
.char-wrapper {
    display: inline-block;
}

.char-wrapper .char {
    display: inline-block;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.char-wrapper.revealed .char {
    opacity: 1;
    transform: translateY(0);
}

.domain-dot .char {
    color: var(--accent-gold);
}

.domain-quest {
    font-style: italic;
}

.axiom-line {
    width: 120px;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent-gold), transparent);
    margin: 0 auto 2rem;
    opacity: 0;
    transition: opacity 0.8s ease 0.3s;
}

.axiom-line.visible {
    opacity: 1;
}

.axiom-subtitle {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-style: italic;
    font-size: 15px;
    font-weight: 400;
    color: var(--text-secondary);
    letter-spacing: 0.06em;
    max-width: 400px;
    opacity: 0;
    transition: opacity 0.8s ease;
}

.axiom-subtitle.visible {
    opacity: 1;
}

.scroll-indicator {
    position: absolute;
    bottom: 3rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    animation: scrollBounce 3s ease-in-out infinite;
}

@keyframes scrollBounce {
    0%, 100% { transform: translateY(0); opacity: 0.5; }
    50% { transform: translateY(8px); opacity: 1; }
}

.scroll-arrow {
    font-size: 1.5rem;
    color: var(--accent-gold);
}

.scroll-text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.65rem;
    color: var(--text-secondary);
    letter-spacing: 0.12em;
    text-transform: lowercase;
}

/* ========================================
   Premise Sections
   ======================================== */

.section-premise {
    border-top: 1px solid var(--border-dark);
}

/* Watermark premise identifiers */
.premise-watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'JetBrains Mono', monospace;
    font-size: clamp(6rem, 12vw, 14rem);
    font-weight: 500;
    color: var(--text-primary);
    opacity: 0;
    pointer-events: none;
    z-index: 0;
    transition: opacity 0.6s ease;
}

.section-premise.watermark-visible .premise-watermark {
    opacity: 0.04;
}

.premise-marker {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    margin-bottom: 2rem;
}

.premise-number {
    font-family: 'Playfair Display', serif;
    font-weight: 900;
    font-size: clamp(3rem, 6vw, 5rem);
    color: var(--accent-gold);
    line-height: 1;
    opacity: 0.7;
}

.premise-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    color: var(--text-secondary);
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

.premise-heading {
    font-family: 'Playfair Display', serif;
    font-weight: 900;
    font-size: clamp(2rem, 5vw, 4.5rem);
    letter-spacing: -0.04em;
    line-height: 0.95;
    color: var(--text-primary);
    margin-bottom: 2.5rem;
}

/* Proof Block */
.proof-block {
    background: var(--highlight);
    border: 1px solid var(--border-dark);
    border-left: 3px solid var(--accent-gold);
    padding: 1.5rem 2rem;
    margin-bottom: 2rem;
    font-family: 'JetBrains Mono', monospace;
}

.proof-line {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    padding: 0.4rem 0;
    border-bottom: 1px solid rgba(74, 63, 53, 0.15);
}

.proof-line:last-child {
    border-bottom: none;
}

.line-number {
    color: var(--text-secondary);
    font-size: 0.75rem;
    min-width: 2rem;
    opacity: 0.6;
}

.formula {
    color: var(--accent-gold);
    font-size: 0.9rem;
    font-weight: 500;
    flex: 1;
}

.justification {
    color: var(--text-secondary);
    font-size: 0.7rem;
    font-style: italic;
    opacity: 0.6;
    text-align: right;
    min-width: 80px;
}

.premise-text {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-size: 18px;
    font-weight: 400;
    color: var(--text-secondary);
    line-height: 1.7;
    letter-spacing: 0.01em;
    margin-top: 1rem;
}

/* Floating Logic Symbols */
.logic-symbols-float {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.float-sym {
    position: absolute;
    left: var(--x);
    top: var(--y);
    font-family: 'Playfair Display', serif;
    font-size: clamp(2rem, 4vw, 4rem);
    color: var(--accent-gold);
    opacity: 0;
    animation: floatSymbol 8s ease-in-out infinite;
    animation-delay: var(--delay);
}

@keyframes floatSymbol {
    0%, 100% { opacity: 0; transform: translateY(10px) rotate(0deg); }
    20% { opacity: 0.06; }
    50% { opacity: 0.1; transform: translateY(-10px) rotate(5deg); }
    80% { opacity: 0.06; }
}

/* ========================================
   Section: The Theorem
   ======================================== */

.section-theorem {
    border-top: 1px solid var(--border-dark);
    background: linear-gradient(180deg, var(--bg-deep) 0%, var(--bg-surface) 50%, var(--bg-deep) 100%);
}

.theorem-border {
    border: 2px solid var(--border-dark);
    padding: 40px;
    position: relative;
    background: rgba(12, 10, 8, 0.6);
    transition: border-color 1.2s ease, box-shadow 1.2s ease;
}

.theorem-border:hover {
    border-color: var(--accent-gold);
    box-shadow: inset 0 0 40px rgba(196, 163, 77, 0.04);
}

.theorem-label {
    position: absolute;
    top: -0.7rem;
    left: 2rem;
    background: var(--bg-deep);
    padding: 0 1rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    color: var(--accent-gold);
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

.theorem-heading {
    font-family: 'Playfair Display', serif;
    font-weight: 900;
    font-size: clamp(2.5rem, 6vw, 5rem);
    letter-spacing: -0.04em;
    line-height: 0.95;
    color: var(--text-primary);
    margin-bottom: 2rem;
}

.theorem-formula {
    text-align: center;
    padding: 1.5rem 0;
}

.formula-large {
    font-family: 'JetBrains Mono', monospace;
    font-size: clamp(1rem, 2vw, 1.5rem);
    color: var(--accent-gold);
    font-weight: 500;
    letter-spacing: 0.02em;
}

.theorem-divider {
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent-gold), transparent);
    margin: 1.5rem 0;
}

.theorem-text {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-size: 18px;
    font-weight: 400;
    color: var(--text-secondary);
    line-height: 1.7;
    letter-spacing: 0.01em;
    text-align: center;
}

/* ========================================
   Section: QED
   ======================================== */

.section-qed {
    border-top: 1px solid var(--border-dark);
    min-height: 80vh;
}

.section-qed .section-content {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
}

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

.qed-symbol {
    font-size: clamp(3rem, 8vw, 6rem);
    color: var(--accent-gold);
    margin-bottom: 1.5rem;
    animation: qedPulse 4s ease-in-out infinite;
    cursor: pointer;
}

@keyframes qedPulse {
    0%, 100% { opacity: 0.6; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.05); }
}

.qed-phrase {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    font-style: italic;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    margin-bottom: 2rem;
}

.qed-line {
    width: 60px;
    height: 1px;
    background: var(--accent-gold);
    margin: 0 auto 2rem;
}

.qed-domain {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    color: var(--text-secondary);
    letter-spacing: 0.15em;
    margin-bottom: 1rem;
}

.qed-footnote {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-size: 0.8rem;
    font-weight: 400;
    color: var(--text-secondary);
    opacity: 0.5;
    font-style: italic;
}

/* ========================================
   Scroll Reveal Animations
   ======================================== */

.section-content {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

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

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

.proof-line {
    opacity: 0;
    transform: translateX(-20px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.revealed .proof-line {
    opacity: 1;
    transform: translateX(0);
}

.revealed .proof-line:nth-child(1) { transition-delay: 0.2s; }
.revealed .proof-line:nth-child(2) { transition-delay: 0.5s; }
.revealed .proof-line:nth-child(3) { transition-delay: 0.8s; }

/* ========================================
   Responsive
   ======================================== */

@media (max-width: 768px) {
    .section-content {
        padding: 3rem 1.5rem;
    }

    .proof-block {
        padding: 1rem 1.2rem;
    }

    .proof-line {
        flex-wrap: wrap;
        gap: 0.3rem;
    }

    .justification {
        min-width: auto;
        width: 100%;
        text-align: left;
        padding-left: 2rem;
    }

    .theorem-border {
        padding: 2rem 1.5rem;
    }
}

@media (max-width: 480px) {
    .section-content {
        padding: 2rem 1rem;
    }

    .premise-marker {
        flex-direction: column;
        gap: 0.3rem;
    }
}
