/* logical.day — Design System
   Colors: #0f0d0a, #1a1410, #2a2218, #3d3425, #e8d5b5, #c4a882, #d4956a, #4dcea6, #8b6cc7, #67c5d4
   Fonts: Libre Baskerville (display), Source Sans 3 (body), Fira Code (logic symbols) */

:root {
    --bg-deepest: #0f0d0a;
    --bg-dark: #1a1410;
    --bg-medium: #2a2218;
    --bg-lighter: #3d3425;
    --aurora-green: #4dcea6;
    --aurora-violet: #8b6cc7;
    --warm-amber: #d4956a;
    --warm-parchment: #e8d5b5;
    --muted-gold: #c4a882;
    --cool-teal: #67c5d4;
    --font-display: "Libre Baskerville", Georgia, serif;
    --font-body: "Source Sans 3", "Source Sans Pro", sans-serif;
    --font-mono: "Fira Code", monospace;
    --elastic-in: cubic-bezier(0.34, 1.56, 0.64, 1);
    --elastic-out: cubic-bezier(0.68, -0.55, 0.27, 1.55);
}

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

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    background-color: var(--bg-deepest);
    color: var(--warm-parchment);
    font-family: var(--font-body);
    font-weight: 400;
    line-height: 1.7;
    overflow-x: hidden;
    position: relative;
}

/* Soil grain texture overlay */
body::after {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.04;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
    background-repeat: repeat;
}

.svg-filters {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* ============================================
   Scroll Progress Thermometer
   ============================================ */

.scroll-thermometer {
    position: fixed;
    left: 0;
    bottom: 0;
    width: 3px;
    height: 0%;
    background: linear-gradient(to top, var(--warm-amber), var(--aurora-violet));
    z-index: 1000;
    transition: height 0.1s linear;
}

/* ============================================
   Ember Particles
   ============================================ */

.ember-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
    overflow: hidden;
}

.ember {
    position: absolute;
    bottom: -10px;
    left: var(--x);
    width: var(--size);
    height: var(--size);
    background: var(--warm-amber);
    border-radius: 50%;
    opacity: 0;
    box-shadow: 0 0 6px var(--warm-amber), 0 0 12px rgba(212, 149, 106, 0.4);
    animation: emberRise var(--dur) ease-in-out var(--delay) infinite;
}

@keyframes emberRise {
    0% { opacity: 0; transform: translateY(0) scale(1); }
    10% { opacity: 0.8; }
    50% { opacity: 0.6; transform: translateY(-50vh) scale(0.8); }
    100% { opacity: 0; transform: translateY(-100vh) scale(0.3); }
}

/* ============================================
   Common Section Styles
   ============================================ */

.section {
    position: relative;
    min-height: 100vh;
    padding: 80px 48px;
    overflow: hidden;
}

.section-heading {
    font-family: var(--font-display);
    font-size: clamp(32px, 5vw, 72px);
    font-weight: 700;
    color: var(--warm-parchment);
    letter-spacing: 0.02em;
    margin-bottom: 16px;
    text-align: center;
}

.section-epigraph {
    font-family: var(--font-body);
    font-size: clamp(16px, 2vw, 20px);
    font-weight: 300;
    color: var(--muted-gold);
    text-align: center;
    max-width: 68ch;
    margin: 0 auto 60px;
    font-style: italic;
    opacity: 0.85;
}

/* ============================================
   Section 1: The Threshold
   ============================================ */

.threshold {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-deepest);
    padding: 0;
}

.aurora-layer {
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    opacity: 0.12;
    pointer-events: none;
    mix-blend-mode: screen;
}

.aurora-green {
    background: linear-gradient(135deg, transparent 20%, #4dcea6 40%, transparent 60%, #4dcea6 80%, transparent 100%);
    background-size: 400% 400%;
    animation: auroraShift1 25s ease-in-out infinite alternate;
}

.aurora-violet {
    background: linear-gradient(200deg, transparent 15%, #8b6cc7 35%, transparent 55%, #8b6cc7 75%, transparent 95%);
    background-size: 400% 400%;
    animation: auroraShift2 33s ease-in-out infinite alternate;
    opacity: 0.10;
}

.aurora-amber {
    background: linear-gradient(310deg, transparent 25%, #d4956a 45%, transparent 65%, #d4956a 85%, transparent 100%);
    background-size: 400% 400%;
    animation: auroraShift3 41s ease-in-out infinite alternate;
    opacity: 0.06;
}

@keyframes auroraShift1 {
    0% { background-position: 0% 50%; }
    100% { background-position: 100% 50%; }
}

@keyframes auroraShift2 {
    0% { background-position: 100% 0%; }
    100% { background-position: 0% 100%; }
}

@keyframes auroraShift3 {
    0% { background-position: 50% 100%; }
    100% { background-position: 50% 0%; }
}

.threshold-content {
    position: relative;
    z-index: 2;
    text-align: center;
}

.threshold-title {
    font-family: var(--font-display);
    font-size: clamp(48px, 8vw, 120px);
    font-weight: 700;
    color: var(--warm-parchment);
    letter-spacing: 0.03em;
    margin-bottom: 16px;
    text-shadow: 0 0 80px rgba(77, 206, 166, 0.3), 0 0 160px rgba(139, 108, 199, 0.2);
}

.threshold-subtitle {
    font-family: var(--font-body);
    font-size: clamp(16px, 2.5vw, 24px);
    font-weight: 300;
    color: var(--muted-gold);
    letter-spacing: 0.08em;
    text-transform: lowercase;
    opacity: 0;
    animation: fadeInUp 1.5s ease 0.8s forwards;
}

.threshold-symbol {
    font-family: var(--font-mono);
    font-size: clamp(36px, 5vw, 64px);
    color: var(--aurora-green);
    margin-top: 40px;
    opacity: 0;
    animation: fadeInUp 1.5s ease 1.4s forwards;
    text-shadow: 0 0 40px rgba(77, 206, 166, 0.5);
}

.scroll-indicator {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
    opacity: 0;
    animation: fadeInUp 1.5s ease 2s forwards;
    cursor: pointer;
}

.scroll-arrow {
    font-size: 28px;
    color: var(--muted-gold);
    opacity: 0.5;
    animation: bounceDown 2s ease-in-out infinite;
    display: inline-block;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes bounceDown {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(12px); }
}

/* ============================================
   Section 2: Premises
   ============================================ */

.premises {
    background: linear-gradient(180deg, var(--bg-deepest) 0%, var(--bg-dark) 50%, var(--bg-medium) 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.premises-fog {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at 50% 50%, rgba(42, 34, 24, 0.6) 0%, transparent 70%);
    pointer-events: none;
}

.floating-symbols {
    position: relative;
    width: 100%;
    max-width: 900px;
    height: 400px;
    margin-top: 40px;
}

.float-sym {
    position: absolute;
    font-family: var(--font-mono);
    font-size: clamp(24px, 4vw, 48px);
    color: var(--warm-amber);
    opacity: 0;
    animation: floatDrift 8s ease-in-out infinite;
    text-shadow: 0 0 20px rgba(212, 149, 106, 0.4);
    cursor: default;
    transition: color 0.6s var(--elastic-in), text-shadow 0.6s var(--elastic-in), transform 0.6s var(--elastic-in);
}

.float-sym:hover {
    color: var(--aurora-green);
    text-shadow: 0 0 30px rgba(77, 206, 166, 0.6);
    transform: scale(1.3) !important;
}

.float-sym:nth-child(1)  { left: 5%;  top: 10%; animation-delay: 0s; }
.float-sym:nth-child(2)  { left: 25%; top: 60%; animation-delay: 0.7s; }
.float-sym:nth-child(3)  { left: 45%; top: 20%; animation-delay: 1.4s; }
.float-sym:nth-child(4)  { left: 70%; top: 45%; animation-delay: 2.1s; }
.float-sym:nth-child(5)  { left: 85%; top: 15%; animation-delay: 2.8s; }
.float-sym:nth-child(6)  { left: 15%; top: 75%; animation-delay: 3.5s; }
.float-sym:nth-child(7)  { left: 55%; top: 70%; animation-delay: 4.2s; }
.float-sym:nth-child(8)  { left: 35%; top: 40%; animation-delay: 4.9s; }
.float-sym:nth-child(9)  { left: 80%; top: 65%; animation-delay: 5.6s; }
.float-sym:nth-child(10) { left: 60%; top: 5%;  animation-delay: 6.3s; }
.float-sym:nth-child(11) { left: 10%; top: 45%; animation-delay: 7s; }
.float-sym:nth-child(12) { left: 90%; top: 35%; animation-delay: 7.7s; }

@keyframes floatDrift {
    0%   { opacity: 0; transform: translateY(20px) rotate(-5deg); }
    20%  { opacity: 0.7; }
    50%  { opacity: 1; transform: translateY(-15px) rotate(3deg); }
    80%  { opacity: 0.7; }
    100% { opacity: 0; transform: translateY(20px) rotate(-5deg); }
}

/* ============================================
   Basalt Column Dividers
   ============================================ */

.basalt-divider {
    height: 60px;
    background: var(--bg-dark);
    opacity: 0.6;
    overflow: hidden;
}

.basalt-divider svg {
    display: block;
}

/* ============================================
   Section 3: Masonry Grid (The Foundations)
   ============================================ */

.masonry-section {
    background: var(--bg-dark);
    padding-bottom: 120px;
}

.masonry-grid {
    columns: 3;
    column-gap: 16px;
    max-width: 1200px;
    margin: 0 auto;
}

.thought-block {
    break-inside: avoid;
    background: var(--bg-medium);
    padding: 24px;
    margin-bottom: 16px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transform: translateY(24px) scale(0.97);
    transition:
        background-color 0.6s var(--elastic-in),
        transform 0.6s var(--elastic-in),
        box-shadow 0.6s var(--elastic-in),
        opacity 0.6s ease;
}

.thought-block.block-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.thought-block:hover {
    background: var(--bg-lighter);
    transform: translateY(-3px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

.block-axiom { border-left: 3px solid var(--aurora-green); }
.block-axiom .block-label { color: var(--aurora-green); }

.block-theorem { border-left: 3px solid var(--aurora-violet); }
.block-theorem .block-label { color: var(--aurora-violet); }

.block-lemma { border-left: 3px solid var(--warm-amber); }
.block-lemma .block-label { color: var(--warm-amber); }

.block-definition { border-left: 3px solid var(--cool-teal); }
.block-definition .block-label { color: var(--cool-teal); }

.block-corollary { border-left: 3px solid var(--muted-gold); }
.block-corollary .block-label { color: var(--muted-gold); }

.block-label {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin-bottom: 12px;
}

.block-symbol {
    font-family: var(--font-mono);
    font-size: clamp(18px, 2vw, 24px);
    color: var(--warm-parchment);
    margin-bottom: 16px;
    padding: 12px 0;
    border-bottom: 1px solid rgba(232, 213, 181, 0.1);
}

.block-text {
    font-family: var(--font-body);
    font-size: 17px;
    font-weight: 400;
    color: var(--muted-gold);
    line-height: 1.7;
    max-width: 68ch;
    opacity: 0.85;
}

/* ============================================
   Section 4: The Stream / Derivation
   ============================================ */

.stream-section {
    background: linear-gradient(180deg, var(--bg-dark) 0%, var(--bg-deepest) 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stream-container {
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
}

/* Bubble stream — horizontal band 120px tall */
.bubble-stream {
    position: relative;
    height: 120px;
    margin-bottom: 60px;
    overflow: hidden;
}

.bubble {
    position: absolute;
    width: var(--size, 32px);
    height: var(--size, 32px);
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(103, 197, 212, 0.15), transparent);
    box-shadow: inset 3px 3px 6px rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: bubbleDrift var(--duration, 12s) linear var(--delay, 0s) infinite;
    top: calc(50% - var(--size, 32px) / 2 + (var(--delay, 0s) * 3));
    cursor: default;
    transition: transform 0.6s var(--elastic-in);
}

.bubble:hover {
    transform: scale(1.3);
}

@keyframes bubbleDrift {
    0% { left: -60px; opacity: 0; }
    5% { opacity: 0.6; }
    90% { opacity: 0.6; }
    100% { left: calc(100% + 60px); opacity: 0; }
}

.bubble-symbol {
    font-family: var(--font-mono);
    font-size: calc(var(--size, 32px) * 0.45);
    color: var(--warm-amber);
    opacity: 0.6;
}

.derivation-steps {
    background: var(--bg-medium);
    border-radius: 12px;
    padding: 40px;
    max-width: 600px;
    margin: 0 auto;
}

.step {
    font-family: var(--font-mono);
    font-size: clamp(14px, 1.8vw, 18px);
    padding: 14px 0;
    border-bottom: 1px solid rgba(232, 213, 181, 0.06);
    opacity: 0;
    transform: translateX(-20px);
    transition: opacity 0.6s ease, transform 0.6s var(--elastic-in);
    display: flex;
    align-items: baseline;
    gap: 16px;
}

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

.step:last-child {
    border-bottom: none;
}

.step-number {
    color: var(--aurora-green);
    font-weight: 700;
    min-width: 28px;
}

.step-content {
    color: var(--warm-parchment);
}

.step-rule {
    color: var(--muted-gold);
    font-size: 0.85em;
    opacity: 0.7;
}

.step-qed {
    margin-top: 8px;
    padding-top: 20px;
    border-top: 2px solid var(--aurora-green);
    border-bottom: none;
}

.step-qed .step-number {
    font-size: 1.2em;
}

.step-qed .step-content {
    font-family: var(--font-display);
    font-style: italic;
    color: var(--aurora-green);
}

/* ============================================
   Section 5: The Clearing / Canopy
   ============================================ */

.canopy-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-deepest);
    padding: 0;
}

.canopy-aurora {
    opacity: 0;
    transition: opacity 2s ease;
}

.canopy-aurora.aurora-active {
    opacity: 0.12;
}

.canopy-content {
    position: relative;
    z-index: 2;
    text-align: center;
    max-width: 720px;
    padding: 40px;
}

.canopy-heading {
    margin-bottom: 32px;
}

.canopy-text {
    font-family: var(--font-body);
    font-size: clamp(17px, 2vw, 22px);
    font-weight: 300;
    color: var(--warm-parchment);
    line-height: 1.8;
    margin-bottom: 40px;
    max-width: 68ch;
    opacity: 0.9;
}

.canopy-symbol {
    font-family: var(--font-mono);
    font-size: clamp(48px, 6vw, 80px);
    color: var(--aurora-green);
    margin-bottom: 24px;
    text-shadow: 0 0 60px rgba(77, 206, 166, 0.5), 0 0 120px rgba(139, 108, 199, 0.3);
    animation: pulseGlow 4s ease-in-out infinite;
}

@keyframes pulseGlow {
    0%, 100% { text-shadow: 0 0 60px rgba(77, 206, 166, 0.5), 0 0 120px rgba(139, 108, 199, 0.3); }
    50% { text-shadow: 0 0 80px rgba(77, 206, 166, 0.7), 0 0 160px rgba(139, 108, 199, 0.5); }
}

.canopy-conclusion {
    font-family: var(--font-display);
    font-size: clamp(20px, 3vw, 32px);
    font-weight: 700;
    color: var(--warm-parchment);
    letter-spacing: 0.04em;
}

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

@media (min-width: 1024px) {
    .section {
        padding: 80px 48px;
    }
}

@media (max-width: 1024px) {
    .masonry-grid {
        columns: 2;
    }
    .section {
        padding: 60px 24px;
    }
}

@media (max-width: 640px) {
    .section {
        padding: 60px 16px;
    }

    .masonry-grid {
        columns: 1;
    }

    .floating-symbols {
        height: 300px;
    }

    .float-sym {
        font-size: 24px;
    }

    .bubble-stream {
        height: 100px;
    }

    .derivation-steps {
        padding: 24px;
    }
}
