/* ============================================================
   logical.day -- a neomorphic theorem
   Strictly monochromatic, blue-gray substrate, tech-mono voice.
   ============================================================ */

/* -------- Tokens -------------------------------------------------- */
:root {
    /* Substrate / palette */
    --substrate:        #E0E5EC;
    --substrate-sky:    #E8EDF4;
    --substrate-deep:   #D4D9E2;
    --substrate-inset:  #B8C0CC;
    --light-shadow:     #FFFFFF;
    --dark-shadow:      #A3B1C6;
    --hover-tint:       #C8CCD4;

    /* Type colors */
    --ink-primary:      #2C2F36;
    --ink-body:         #4A4F5A;
    --ink-secondary:    #5C6170;
    --ink-tertiary:     #8A8F9A;
    --ink-accent:       #6B7B8D;
    --ink-ridge-soft:   #C8CCD4;

    /* Neomorphic shadow system */
    --shadow-embossed:
        8px 8px 16px rgba(163, 177, 198, 0.50),
        -8px -8px 16px rgba(255, 255, 255, 0.70);

    --shadow-embossed-sm:
        4px 4px 8px rgba(163, 177, 198, 0.45),
        -4px -4px 8px rgba(255, 255, 255, 0.70);

    --shadow-embossed-lg:
        14px 14px 28px rgba(163, 177, 198, 0.50),
        -14px -14px 28px rgba(255, 255, 255, 0.70);

    --shadow-inset:
        inset 6px 6px 12px rgba(163, 177, 198, 0.50),
        inset -6px -6px 12px rgba(255, 255, 255, 0.70);

    --shadow-inset-sm:
        inset 3px 3px 6px rgba(163, 177, 198, 0.55),
        inset -3px -3px 6px rgba(255, 255, 255, 0.75);

    --shadow-flat: none;

    /* Heading "embed" text shadow */
    --text-embed:
        1px 1px 2px rgba(255, 255, 255, 0.70),
        -1px -1px 2px rgba(163, 177, 198, 0.50);

    /* Easing */
    --ease-settle: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-deliberate: cubic-bezier(0.25, 0.1, 0.25, 1);
}

/* -------- Reset / base ------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--substrate);
    color: var(--ink-body);
    font-family: 'Space Mono', 'IBM Plex Mono', ui-monospace, Menlo, monospace;
    font-size: 17px;
    line-height: 1.85;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    overflow-x: hidden;
}

body {
    min-height: 100vh;
}

ul, ol { list-style: none; margin: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
em { font-style: italic; color: var(--ink-primary); }

/* -------- Atmospheric overlays ----------------------------------- */
.atmosphere {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 320px;
    background: linear-gradient(180deg, var(--substrate-sky) 0%, var(--substrate) 100%);
    pointer-events: none;
    z-index: 1;
}

/* Topographic contour patterns (CSS radial-gradient layers) */
.contour-bg {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: 0.85;
    background:
        radial-gradient(ellipse 1200px 320px at 20% 30%, transparent 38%, rgba(163, 177, 198, 0.08) 39%, rgba(163, 177, 198, 0.08) 40%, transparent 41%),
        radial-gradient(ellipse 980px 260px at 22% 32%, transparent 48%, rgba(163, 177, 198, 0.06) 49%, rgba(163, 177, 198, 0.06) 50%, transparent 51%),
        radial-gradient(ellipse 760px 200px at 24% 34%, transparent 58%, rgba(163, 177, 198, 0.05) 59%, rgba(163, 177, 198, 0.05) 60%, transparent 61%),
        radial-gradient(ellipse 1400px 360px at 80% 70%, transparent 42%, rgba(163, 177, 198, 0.07) 43%, rgba(163, 177, 198, 0.07) 44%, transparent 45%),
        radial-gradient(ellipse 1100px 280px at 78% 72%, transparent 52%, rgba(163, 177, 198, 0.05) 53%, rgba(163, 177, 198, 0.05) 54%, transparent 55%),
        radial-gradient(ellipse 880px 220px at 76% 74%, transparent 62%, rgba(163, 177, 198, 0.04) 63%, rgba(163, 177, 198, 0.04) 64%, transparent 65%);
    transform: translateY(var(--contour-offset, 0));
    transition: transform 0.05s linear;
}
.contour-bg--soft { opacity: 0.45; }

/* -------- Logic-gate ghost icons -------------------------------- */
.gate-icons {
    position: fixed;
    inset: 0;
    pointer-events: none;
    color: var(--ink-accent);
    z-index: 1;
}
.gate {
    position: absolute;
    opacity: 0.08;
    filter: drop-shadow(1px 1px 1px rgba(255, 255, 255, 0.7))
            drop-shadow(-1px -1px 1px rgba(163, 177, 198, 0.4));
}
.gate--and { top: 18vh;  left: 2.5vw;  width: 56px; }
.gate--or  { top: 62vh;  right: 3vw;   width: 64px; transform: rotate(8deg); }
.gate--not { top: 110vh; left: 3vw;    width: 52px; transform: rotate(-6deg); }
.gate--xor { top: 220vh; right: 2vw;   width: 60px; transform: rotate(4deg); }

/* -------- Navigation pill (floating top-right) ------------------ */
.nav-pill {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 50;
    display: inline-flex;
    align-items: center;
    gap: 14px;
    padding: 10px 16px;
    border-radius: 999px;
    background: var(--substrate);
    box-shadow: var(--shadow-embossed-sm);
    transition: box-shadow 0.4s var(--ease-deliberate),
                transform 0.4s var(--ease-deliberate);
}
.nav-pill:hover { transform: translateY(-1px); box-shadow: var(--shadow-embossed); }
.nav-pill.is-open { box-shadow: var(--shadow-inset-sm); }

.nav-label {
    font-family: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
    font-size: 12px;
    letter-spacing: 0.12em;
    color: var(--ink-secondary);
    text-transform: lowercase;
}

.nav-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--substrate);
    box-shadow:
        2px 2px 4px rgba(163, 177, 198, 0.55),
        -2px -2px 4px rgba(255, 255, 255, 0.85);
    transition: box-shadow 0.3s var(--ease-deliberate),
                transform 0.3s var(--ease-deliberate);
}
.nav-dot:hover { transform: scale(1.1); }
.nav-pill.is-open .nav-dot {
    box-shadow:
        inset 2px 2px 4px rgba(163, 177, 198, 0.6),
        inset -2px -2px 4px rgba(255, 255, 255, 0.85);
}

.nav-anchors {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    min-width: 200px;
    padding: 14px 18px;
    border-radius: 18px;
    background: var(--substrate);
    box-shadow: var(--shadow-embossed);
    font-family: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
    font-size: 12px;
    letter-spacing: 0.08em;
    color: var(--ink-secondary);
    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
    transition: opacity 0.35s var(--ease-settle),
                transform 0.35s var(--ease-settle);
}
.nav-pill.is-open .nav-anchors {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}
.nav-anchors li { padding: 5px 0; }
.nav-anchors a {
    display: block;
    transition: color 0.25s var(--ease-deliberate);
}
.nav-anchors a:hover { color: var(--ink-primary); }

/* -------- Theorem section base ---------------------------------- */
main { position: relative; z-index: 2; }

.theorem {
    position: relative;
    padding: 14vh 8vw;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.theorem + .divider { margin-top: -2vh; }
.theorem--landscape { min-height: 120vh; }
.theorem--closing   { min-height: 80vh; }

/* gentle "fog" between sections via ::before */
.theorem::before {
    content: "";
    position: absolute;
    top: -75px;
    left: 0;
    right: 0;
    height: 150px;
    pointer-events: none;
    background: linear-gradient(180deg,
        transparent 0%,
        rgba(224, 229, 236, 0.50) 50%,
        transparent 100%);
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
    transition: backdrop-filter 0.6s var(--ease-settle),
                -webkit-backdrop-filter 0.6s var(--ease-settle);
}
.theorem.is-fogging::before {
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

/* meta labels */
.meta-label {
    display: inline-block;
    font-family: 'Inter', system-ui, sans-serif;
    font-weight: 300;
    font-size: 11px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ink-tertiary);
    margin-bottom: 28px;
}

/* shared theorem heading */
.theorem-head { max-width: none; margin-bottom: 56px; }
.theorem-head--narrow { max-width: 65ch; margin-left: 38.2%; padding-right: 8vw; }

.theorem-title,
.hero-title,
.closing-title {
    font-family: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
    font-weight: 600;
    color: var(--ink-primary);
    text-transform: lowercase;
    letter-spacing: 0.12em;
    line-height: 1.1;
    margin: 0 0 18px;
    text-shadow: var(--text-embed);
}

.theorem-title { font-size: clamp(34px, 4.4vw, 56px); }

/* drop-cap on first letter for headings */
.theorem-title::first-letter,
.hero-title::first-letter,
.closing-title::first-letter {
    font-weight: 600;
    text-shadow:
        2px 2px 3px rgba(255, 255, 255, 0.85),
        -2px -2px 3px rgba(163, 177, 198, 0.55);
}

.theorem-lede {
    max-width: 65ch;
    color: var(--ink-body);
    font-size: 17px;
    line-height: 1.85;
    margin: 0;
}

/* QED markers */
.qed {
    display: block;
    width: 16px;
    height: 16px;
    margin: 56px 0 0 auto;
    margin-right: 8vw;
    border-radius: 3px;
    background: var(--substrate);
    box-shadow: var(--shadow-embossed-sm);
    animation: qed-pulse 4s ease-in-out infinite;
}
.qed--final {
    width: 22px;
    height: 22px;
    border-radius: 4px;
    box-shadow: var(--shadow-embossed);
}
@keyframes qed-pulse {
    0%, 100% {
        box-shadow:
            3px 3px 6px rgba(163, 177, 198, 0.40),
            -3px -3px 6px rgba(255, 255, 255, 0.65);
    }
    50% {
        box-shadow:
            5px 5px 10px rgba(163, 177, 198, 0.55),
            -5px -5px 10px rgba(255, 255, 255, 0.80);
    }
}

/* notation spans */
.notation {
    font-family: 'Fira Code', 'IBM Plex Mono', ui-monospace, Menlo, monospace;
    font-feature-settings: "liga" 1, "calt" 1;
    color: var(--ink-secondary);
    font-size: 15px;
    letter-spacing: 0.02em;
}

/* inset code/quote blocks */
.inset-block,
.axiom-formula,
.step-formula {
    margin: 22px 0;
    padding: 22px 26px;
    border-radius: 14px;
    background: var(--substrate);
    box-shadow: var(--shadow-inset);
    font-family: 'Fira Code', 'IBM Plex Mono', ui-monospace, Menlo, monospace;
    font-feature-settings: "liga" 1, "calt" 1;
    font-size: 14px;
    line-height: 1.7;
    color: var(--ink-secondary);
    white-space: pre-wrap;
    overflow-x: auto;
}
.inset-block code,
.axiom-formula code,
.step-formula code {
    font: inherit;
    color: inherit;
    background: none;
    padding: 0;
}

/* =============== Section I -- Hero =============== */
.theorem--hero {
    padding-top: 18vh;
    padding-bottom: 10vh;
    min-height: 100vh;
}
.hero-header {
    position: relative;
    z-index: 3;
}
.hero-title {
    font-size: clamp(48px, 7.2vw, 96px);
    margin: 0 0 28px;
    line-height: 1;
}
/* per-letter staggered fade-in */
.hero-title .letter {
    display: inline-block;
    opacity: 0;
    transform: translateY(14px);
    transition: opacity 0.7s var(--ease-settle),
                transform 0.7s var(--ease-settle);
}
.hero-title.is-typed .letter { opacity: 1; transform: translateY(0); }

.hero-subtitle {
    margin: 0;
    font-size: 16px;
    color: var(--ink-secondary);
}

.hero-ridgelines {
    position: absolute;
    left: 0; right: 0;
    bottom: 0;
    height: 56vh;
    pointer-events: none;
    z-index: 2;
}
.hero-ridgelines svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* =============== Section II -- Axioms =============== */
.theorem--axioms {
    padding-top: 14vh;
}
.axioms-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 36px;
    margin-top: 28px;
}
.axiom-card {
    position: relative;
    padding: 36px 32px 32px;
    border-radius: 22px;
    background: var(--substrate);
    box-shadow: var(--shadow-embossed);
    transition: box-shadow 0.4s var(--ease-deliberate),
                transform 0.4s var(--ease-deliberate);
}
.axiom-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-embossed-lg);
}
.axiom-card.is-pressed {
    transform: translateY(0);
    box-shadow: var(--shadow-inset);
}
.axiom-index {
    display: inline-block;
    font-family: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
    font-size: 13px;
    color: var(--ink-tertiary);
    letter-spacing: 0.12em;
    margin-bottom: 12px;
}
.axiom-title {
    font-family: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
    font-weight: 500;
    font-size: 22px;
    color: var(--ink-primary);
    margin: 0 0 14px;
    text-transform: lowercase;
    letter-spacing: 0.06em;
    text-shadow: var(--text-embed);
}
.axiom-body {
    font-size: 15px;
    line-height: 1.75;
    color: var(--ink-body);
    margin: 0 0 18px;
}
.axiom-formula { margin: 0; font-size: 13px; padding: 16px 18px; }

/* =============== Section III -- Landscape =============== */
.theorem--landscape {
    padding-top: 16vh;
    padding-bottom: 16vh;
}
.landscape-body {
    max-width: 65ch;
    margin-left: 38.2%;
    padding-right: 8vw;
}
.landscape-body p {
    margin: 0 0 24px;
    color: var(--ink-body);
    font-size: 17px;
    line-height: 1.85;
}

/* =============== Section IV -- Proof =============== */
.theorem--proof { padding-top: 14vh; }

.proof-steps {
    margin-top: 32px;
    max-width: 65ch;
    margin-left: 38.2%;
    padding-right: 8vw;
}
.proof-step {
    display: grid;
    grid-template-columns: 64px 1fr;
    gap: 24px;
    align-items: start;
    margin-bottom: 36px;
}
.step-marker {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--substrate);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-flat);
    transition: box-shadow 0.6s var(--ease-settle);
    flex: 0 0 48px;
}
.proof-step.is-active .step-marker {
    box-shadow: var(--shadow-inset-sm);
}
.step-num {
    font-family: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
    font-size: 12px;
    letter-spacing: 0.08em;
    color: var(--ink-tertiary);
    transition: color 0.6s var(--ease-settle);
}
.proof-step.is-active .step-num { color: var(--ink-secondary); }

.step-body { padding-top: 10px; }
.step-text {
    margin: 0 0 10px;
    font-size: 16px;
    line-height: 1.75;
    color: var(--ink-body);
}
.step-formula {
    margin: 12px 0 0;
    padding: 16px 20px;
    font-size: 13.5px;
}

/* =============== Section V -- Closing =============== */
.theorem--closing {
    align-items: stretch;
    padding: 8vh 8vw;
    text-align: center;
}
.closing-center {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6vh 0;
}
.closing-title {
    font-size: clamp(40px, 5.5vw, 72px);
    margin: 8px 0 18px;
}
.closing-rule {
    display: block;
    width: 88px;
    height: 6px;
    border-radius: 999px;
    background: var(--substrate);
    box-shadow: var(--shadow-embossed-sm);
    margin: 4px 0 22px;
}
.closing-line { margin: 0; color: var(--ink-tertiary); }
.closing-footer {
    margin-top: 24px;
    text-align: center;
}
.closing-footer .meta-label { margin: 0; }

.closing-ridgelines {
    position: relative;
    width: 100%;
    height: 22vh;
    pointer-events: none;
}
.closing-ridgelines--bottom { transform: scaleY(-1); }
.closing-ridgelines svg { width: 100%; height: 100%; display: block; }

/* -------- Ridgeline divider blocks ------------------------------ */
.divider {
    position: relative;
    width: 100%;
    height: 200px;
    pointer-events: none;
}
.divider--complex { height: 280px; }
.divider svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

/* -------- Reveal animation -------------------------------------- */
.reveal {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.9s var(--ease-settle),
                transform 0.9s var(--ease-settle);
    transition-delay: var(--reveal-delay, 0ms);
}
.reveal.is-revealed {
    opacity: 1;
    transform: translateY(0);
}

/* -------- Responsive -------------------------------------------- */
@media (max-width: 980px) {
    .theorem { padding: 12vh 6vw; }
    .axioms-grid { grid-template-columns: 1fr; gap: 22px; }
    .theorem-head--narrow,
    .landscape-body,
    .proof-steps {
        margin-left: 0;
        padding-right: 0;
    }
    .nav-pill { top: 16px; right: 16px; padding: 8px 14px; }
    .hero-title { font-size: clamp(40px, 12vw, 64px); }
}
@media (max-width: 600px) {
    body { font-size: 15px; }
    .theorem { padding: 10vh 5vw; }
    .proof-step { grid-template-columns: 48px 1fr; gap: 16px; }
    .step-marker { width: 40px; height: 40px; flex-basis: 40px; }
    .gate-icons { display: none; }
}
