/* =========================================================
   reasoner.dev — The Architecture of Inference
   Palette:
     #0A0A12  Void Background
     #1A1A2E  Grid Substrate
     #7DF9FF  Inference Accent (Cyan Glow)
     #D4A853  Premise Marker (Warm Amber)
     #9B72CF  Conclusion Marker (Violet Logic)
     #C8C8D4  Body Text (Pale Silver)
     #3AAFA9  Derivation Link (Teal Bridge)
     #E63946  Contradiction Red
   ========================================================= */

:root {
    --void:        #0A0A12;
    --grid:        #1A1A2E;
    --cyan:        #7DF9FF;
    --amber:       #D4A853;
    --violet:      #9B72CF;
    --silver:      #C8C8D4;
    --teal:        #3AAFA9;
    --red:         #E63946;

    --display:     "Space Grotesk", "Inter", system-ui, sans-serif;
    --body:        "IBM Plex Sans", "Inter", system-ui, sans-serif;
    --mono:        "JetBrains Mono", "IBM Plex Mono", ui-monospace, monospace;

    --ease-spring: cubic-bezier(0.16, 1, 0.3, 1);
}

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

html, body {
    width: 100%;
    overflow-x: hidden;
}

html {
    scroll-behavior: smooth;
    background: var(--void);
}

body {
    font-family: var(--body);
    font-weight: 400;
    font-size: 18px;
    line-height: 1.72;
    color: var(--silver);
    background: var(--void);
    min-height: 100vh;
    position: relative;
}

::selection {
    background: var(--cyan);
    color: var(--void);
}

/* ---------------------------------------------------------
   Fixed grid substrate (logician's notebook)
   --------------------------------------------------------- */
.grid-overlay {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    background-image:
        linear-gradient(to right,  rgba(26, 26, 46, 0.35) 0.5px, transparent 0.5px),
        linear-gradient(to bottom, rgba(26, 26, 46, 0.35) 0.5px, transparent 0.5px);
    background-size: 64px 64px;
    mix-blend-mode: screen;
}

.grid-overlay::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 10%, rgba(125, 249, 255, 0.04), transparent 55%),
        radial-gradient(ellipse at 85% 90%, rgba(155, 114, 207, 0.04), transparent 55%);
}

/* ---------------------------------------------------------
   Proof tree SVG (fixed, full-viewport)
   --------------------------------------------------------- */
.proof-tree {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    z-index: 2;
    pointer-events: none;
}

.proof-tree .spine {
    opacity: 0.55;
    stroke-dasharray: 1800;
    stroke-dashoffset: 0;
}

.proof-tree .branch {
    opacity: 0.18;
    transition: opacity 800ms ease-out, stroke-width 800ms ease-out, filter 800ms ease-out;
}

.proof-tree .branch.is-active {
    opacity: 1;
    stroke-width: 1.4;
    filter: url(#cyanGlow);
}

.proof-tree .node {
    opacity: 0.25;
    transition: opacity 800ms var(--ease-spring), r 800ms var(--ease-spring);
}

.proof-tree .node.is-active {
    opacity: 1;
}

.proof-tree .node-premise.is-active   { filter: url(#amberGlow); }
.proof-tree .node-conclusion.is-active { filter: url(#cyanGlow); }

.proof-tree .connector {
    opacity: 0.12;
    transition: opacity 800ms ease-out;
}

.proof-tree .connector.is-active {
    opacity: 0.55;
}

/* ---------------------------------------------------------
   Turnstile background layer (decorative, slow rotation)
   --------------------------------------------------------- */
.turnstile-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 3;
    overflow: hidden;
}

.turnstile {
    position: absolute;
    width: 380px;
    height: 380px;
    opacity: 0.12;
    transform-origin: center center;
}

.turnstile-1 {
    top: 12%;
    right: -120px;
    width: 460px;
    height: 460px;
    animation: rotate-turnstile 100s linear infinite;
}

.turnstile-2 {
    top: 48%;
    left: -150px;
    width: 520px;
    height: 520px;
    animation: rotate-turnstile 120s linear infinite reverse;
    opacity: 0.10;
}

.turnstile-3 {
    bottom: 8%;
    right: 18%;
    width: 380px;
    height: 380px;
    animation: rotate-turnstile 140s linear infinite;
    opacity: 0.13;
}

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

/* ---------------------------------------------------------
   Quantifier particle field
   --------------------------------------------------------- */
.particle-field {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 4;
    overflow: hidden;
}

.particle {
    position: absolute;
    font-family: var(--mono);
    color: var(--grid);
    user-select: none;
    will-change: transform, opacity;
    animation-name: drift-up;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
}

@keyframes drift-up {
    0%   { transform: translateY(110vh); opacity: 0; }
    8%   { opacity: 1; }
    92%  { opacity: 1; }
    100% { transform: translateY(-25vh); opacity: 0; }
}

/* ---------------------------------------------------------
   Step indicator (bottom-right)
   --------------------------------------------------------- */
.step-indicator {
    position: fixed;
    bottom: 24px;
    right: 28px;
    z-index: 30;
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.12em;
    color: var(--silver);
    text-transform: lowercase;
    background: rgba(10, 10, 18, 0.65);
    border: 1px solid rgba(125, 249, 255, 0.22);
    padding: 8px 14px;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: baseline;
    gap: 6px;
    transition: border-color 600ms ease;
}

.step-indicator.is-active {
    border-color: rgba(125, 249, 255, 0.6);
}

.step-indicator .step-prefix { color: rgba(200, 200, 212, 0.6); }
.step-indicator .step-current { color: var(--cyan); font-weight: 600; }
.step-indicator .step-divider { color: rgba(200, 200, 212, 0.4); }
.step-indicator .step-total   { color: rgba(200, 200, 212, 0.7); }
.step-indicator .step-name    { color: var(--amber); margin-left: 8px; }

/* ---------------------------------------------------------
   Main proof container & zones
   --------------------------------------------------------- */
.proof {
    position: relative;
    z-index: 10;
}

.zone {
    position: relative;
    min-height: 100vh;
    width: 100%;
    padding: 10vh 8vw;
    display: flex;
    align-items: center;
    z-index: 10;
}

.zone-inner {
    position: relative;
    width: 100%;
    max-width: 720px;
    padding: 48px 56px;
    background: rgba(10, 10, 18, 0.78);
    border: 1px solid rgba(125, 249, 255, 0.18);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.zone-step {
    will-change: transform, opacity, filter;
}

/* Initial off-screen state for step zones */
.zone-step .zone-inner {
    opacity: 0;
    filter: blur(8px);
    transform: translateX(40px);
    transition:
        opacity   1200ms var(--ease-spring),
        filter    1200ms var(--ease-spring),
        transform 1200ms var(--ease-spring);
}

.zone-step.is-revealed .zone-inner {
    opacity: 1;
    filter: blur(0);
    transform: translateX(0);
}

/* Diagonal rotations (off-axis content zones) */
.zone-axiom       { justify-content: flex-start; }
.zone-axiom .zone-inner       { transform-origin: left center; transform: rotate(-3deg) translateX(40px); margin-left: 6vw; }
.zone-axiom.is-revealed .zone-inner { transform: rotate(-3deg) translateX(0); }

.zone-hypothesis  { justify-content: flex-end; }
.zone-hypothesis .zone-inner  { transform-origin: right center; transform: rotate(2.5deg) translateX(40px); margin-right: 4vw; }
.zone-hypothesis.is-revealed .zone-inner { transform: rotate(2.5deg) translateX(0); }

.zone-derivation  { justify-content: flex-start; }
.zone-derivation .zone-inner  { transform-origin: left center; transform: rotate(-2deg) translateX(40px); margin-left: 10vw; max-width: 760px; }
.zone-derivation.is-revealed .zone-inner { transform: rotate(-2deg) translateX(0); }

.zone-lemma       { justify-content: flex-end; }
.zone-lemma .zone-inner       { transform-origin: right center; transform: rotate(4deg) translateX(40px); margin-right: 6vw; }
.zone-lemma.is-revealed .zone-inner { transform: rotate(4deg) translateX(0); }

.zone-theorem     { justify-content: center; }
.zone-theorem .zone-inner     { transform-origin: center; transform: rotate(-1deg) translateX(40px); max-width: 820px; }
.zone-theorem.is-revealed .zone-inner { transform: rotate(-1deg) translateX(0); }

/* Prelude & coda are not rotated */
.zone-prelude {
    min-height: 100vh;
    align-items: center;
    justify-content: center;
}

.zone-prelude .zone-inner {
    max-width: 920px;
    padding: 64px 72px;
    background: transparent;
    border: none;
    backdrop-filter: none;
    text-align: left;
}

.zone-coda {
    min-height: 60vh;
    align-items: center;
    justify-content: center;
}

.zone-coda .zone-inner {
    background: transparent;
    border: none;
    text-align: center;
    max-width: 600px;
    padding: 32px;
}

/* ---------------------------------------------------------
   Prelude (title) styling
   --------------------------------------------------------- */
.proof-mark {
    font-family: var(--mono);
    font-size: 56px;
    color: var(--cyan);
    letter-spacing: -0.04em;
    line-height: 1;
    margin-bottom: 32px;
    opacity: 0.85;
    text-shadow: 0 0 18px rgba(125, 249, 255, 0.35);
}

.title {
    font-family: var(--display);
    font-weight: 600;
    font-size: clamp(64px, 11vw, 140px);
    line-height: 0.95;
    letter-spacing: -0.04em;
    color: var(--silver);
    margin-bottom: 24px;
    display: inline-flex;
    align-items: baseline;
    flex-wrap: wrap;
}

.title-line-1 { color: var(--silver); }
.title-line-2 { color: var(--cyan); }
.title-dot {
    color: var(--amber);
    font-weight: 600;
    margin: 0 -0.04em;
}

.subtitle {
    font-family: var(--display);
    font-weight: 400;
    font-size: clamp(18px, 1.6vw, 22px);
    color: rgba(200, 200, 212, 0.78);
    letter-spacing: 0.02em;
    margin-bottom: 40px;
    max-width: 560px;
}

.formal-line {
    border-left: 1.5px solid var(--cyan);
    padding: 12px 0 12px 18px;
    margin-bottom: 64px;
}

.formal-line .notation {
    color: var(--silver);
    opacity: 0.85;
    font-size: 15px;
}

.scroll-cue {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--teal);
    padding: 10px 0;
}

.scroll-cue-arrow {
    font-size: 16px;
    color: var(--cyan);
    animation: cue-bob 2.4s ease-in-out infinite;
}

@keyframes cue-bob {
    0%, 100% { transform: translateY(0); opacity: 0.8; }
    50%      { transform: translateY(6px); opacity: 1; }
}

/* ---------------------------------------------------------
   Zone header / title / body
   --------------------------------------------------------- */
.zone-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(125, 249, 255, 0.18);
}

.zone-tag {
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: rgba(200, 200, 212, 0.55);
}

.zone-symbol {
    font-family: var(--mono);
    font-size: 14px;
    color: var(--cyan);
    letter-spacing: 0.05em;
}

.zone-title {
    font-family: var(--display);
    font-weight: 600;
    font-size: clamp(56px, 9vw, 110px);
    line-height: 0.92;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    margin-bottom: 24px;
}

.premise-title    { color: var(--amber); }
.derivation-title { color: var(--cyan); }
.conclusion-title { color: var(--violet); }

.zone-lede {
    font-family: var(--display);
    font-weight: 400;
    font-size: clamp(19px, 1.7vw, 22px);
    line-height: 1.45;
    color: rgba(200, 200, 212, 0.92);
    margin-bottom: 26px;
    max-width: 580px;
    letter-spacing: 0.005em;
}

.zone-body {
    font-family: var(--body);
    font-weight: 400;
    font-size: 17px;
    line-height: 1.72;
    color: rgba(200, 200, 212, 0.86);
    max-width: 580px;
    margin-bottom: 30px;
}

.zone-body p + p { margin-top: 14px; }

.zone-body em {
    font-style: italic;
    color: var(--silver);
}

.zone-body code,
.notation {
    font-family: var(--mono);
    font-size: 14px;
    color: var(--cyan);
    letter-spacing: 0.01em;
}

.zone-body code {
    font-size: 14px;
    color: var(--cyan);
    background: rgba(125, 249, 255, 0.06);
    padding: 1px 6px;
    border: 1px solid rgba(125, 249, 255, 0.15);
}

/* Notation block beneath body */
.zone-notation {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 18px 22px;
    background: rgba(26, 26, 46, 0.55);
    border-left: 2px solid var(--teal);
    margin-bottom: 8px;
}

.zone-notation .notation {
    color: var(--silver);
    font-size: 13.5px;
    letter-spacing: 0.02em;
    white-space: pre;
    overflow-x: auto;
}

/* Contradiction badge inside Derivation */
.contradiction-badge {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    margin-top: 18px;
    padding: 8px 14px;
    border: 1px dashed rgba(230, 57, 70, 0.55);
    background: rgba(230, 57, 70, 0.05);
}

.contradiction-symbol {
    font-family: var(--mono);
    font-size: 18px;
    color: var(--red);
    font-weight: 600;
}

.contradiction-text {
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: rgba(200, 200, 212, 0.78);
}

/* Theorem QED */
.theorem-statement .notation {
    color: var(--violet);
}

.theorem-statement .notation:first-child {
    color: var(--silver);
}

.qed {
    margin-top: 28px;
    text-align: right;
}

.qed-mark {
    display: inline-block;
    color: var(--violet);
    font-size: 22px;
    line-height: 1;
    transform: translateY(-1px);
    text-shadow: 0 0 14px rgba(155, 114, 207, 0.55);
}

/* Coda */
.coda-text {
    font-family: var(--display);
    font-weight: 500;
    font-size: 26px;
    color: var(--silver);
    letter-spacing: 0.08em;
    text-transform: lowercase;
    margin-bottom: 12px;
}

.coda-sub {
    color: rgba(58, 175, 169, 0.78);
    font-size: 13px;
    letter-spacing: 0.04em;
}

/* ---------------------------------------------------------
   Responsive
   --------------------------------------------------------- */
@media (max-width: 900px) {
    .zone {
        padding: 8vh 5vw;
    }

    .zone-inner {
        padding: 32px 28px;
        max-width: 100%;
    }

    .zone-axiom .zone-inner       { transform: rotate(-2deg) translateX(20px); margin-left: 0; }
    .zone-axiom.is-revealed .zone-inner { transform: rotate(-2deg) translateX(0); }
    .zone-hypothesis .zone-inner  { transform: rotate(2deg)  translateX(20px); margin-right: 0; }
    .zone-hypothesis.is-revealed .zone-inner { transform: rotate(2deg) translateX(0); }
    .zone-derivation .zone-inner  { transform: rotate(-1.5deg) translateX(20px); margin-left: 0; }
    .zone-derivation.is-revealed .zone-inner { transform: rotate(-1.5deg) translateX(0); }
    .zone-lemma .zone-inner       { transform: rotate(2.5deg) translateX(20px); margin-right: 0; }
    .zone-lemma.is-revealed .zone-inner { transform: rotate(2.5deg) translateX(0); }
    .zone-theorem .zone-inner     { transform: rotate(-1deg)  translateX(20px); }
    .zone-theorem.is-revealed .zone-inner { transform: rotate(-1deg) translateX(0); }

    .title { font-size: clamp(48px, 14vw, 96px); }
    .zone-title { font-size: clamp(42px, 12vw, 80px); }

    .turnstile-1 { width: 320px; height: 320px; right: -160px; }
    .turnstile-2 { width: 360px; height: 360px; left: -180px; }
    .turnstile-3 { width: 280px; height: 280px; right: -50px; }
}

@media (max-width: 540px) {
    .zone-inner { padding: 26px 22px; }
    .proof-mark { font-size: 42px; }
    .step-indicator {
        right: 14px;
        bottom: 14px;
        font-size: 10px;
        padding: 6px 10px;
    }
    .zone-notation { padding: 14px 16px; }
    .zone-notation .notation { font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
    .turnstile,
    .particle,
    .scroll-cue-arrow {
        animation: none !important;
    }
    .zone-step .zone-inner {
        opacity: 1;
        filter: blur(0);
        transform: none !important;
    }
}
