:root {
    --proof-parchment: #F4EEDB;
    --lambda-violet: #5B3FA8;
    --midnight-ink: #17142B;
    --type-lavender: #B7A4FF;
    --silver-theorem: #D8D3C7;
    --curry-coral: #FF7A6B;
    --lazy-mint: #A8E6CF;
    --newsreader: "Newsreader", serif;
    --commissioner: "Commissioner", sans-serif;
    --fraunces: "Fraunces", serif;
    --mono: "IBM Plex Mono", monospace;
}

/* IBM Plex Mono appears only sparingly in small annotations. */

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    background: var(--midnight-ink);
    color: var(--midnight-ink);
    font-family: var(--commissioner);
    overflow-x: hidden;
}

body.evaluating .lambda-lantern {
    transform: rotate(-18deg) scale(.82) translate(16vw, 4vh);
    filter: drop-shadow(0 0 40px rgba(255, 122, 107, .52));
}

body.evaluating .lambda-layer { opacity: .45; }
body.evaluating .arrow-corridor span { opacity: 1; transform: translateX(0) rotate(-8deg); }

.lambda-cloister { position: relative; }

.chamber {
    min-height: 100vh;
    position: relative;
    isolation: isolate;
    overflow: hidden;
    padding: clamp(56px, 8vw, 110px) clamp(28px, 8vw, 128px);
    display: grid;
    align-items: center;
}

.chamber::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -3;
    background-image:
        radial-gradient(circle at 18% 22%, rgba(183, 164, 255, .22), transparent 30%),
        radial-gradient(circle at 84% 70%, rgba(168, 230, 207, .16), transparent 26%),
        linear-gradient(116deg, rgba(244, 238, 219, .92), rgba(216, 211, 199, .72));
}

.chamber::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -2;
    opacity: .42;
    background-image:
        repeating-linear-gradient(0deg, transparent 0 18px, rgba(23, 20, 43, .035) 19px),
        repeating-linear-gradient(90deg, transparent 0 31px, rgba(91, 63, 168, .035) 32px);
    mix-blend-mode: multiply;
}

.pure-gate, .monad-well, .lazy-observatory {
    color: var(--proof-parchment);
}

.pure-gate::before {
    background:
        radial-gradient(circle at 37% 42%, rgba(183, 164, 255, .28), transparent 24%),
        radial-gradient(circle at 74% 18%, rgba(168, 230, 207, .14), transparent 28%),
        linear-gradient(129deg, #17142B 0%, #24194a 52%, #17142B 100%);
}

.curried-hall::before { background: linear-gradient(126deg, #F4EEDB, #D8D3C7 58%, rgba(183, 164, 255, .72)); }
.fold-atrium::before { background: linear-gradient(135deg, #F4EEDB 0%, #fff7e5 44%, #D8D3C7 100%); }
.monad-well::before { background: radial-gradient(circle at 50% 56%, rgba(91, 63, 168, .72), transparent 25%), linear-gradient(140deg, #17142B, #2b2460 55%, #17142B); }
.lazy-observatory::before { background: radial-gradient(circle at 72% 16%, rgba(168, 230, 207, .18), transparent 22%), linear-gradient(180deg, #17142B, #251b54 68%, #17142B); }
.type-garden::before { background: linear-gradient(132deg, #F4EEDB 0%, #e9f3df 42%, #D8D3C7 100%); }

.evaluation-spine {
    position: fixed;
    right: 22px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 20;
    display: flex;
    flex-direction: column;
    gap: 13px;
    padding: 14px 8px;
    border-left: 1px solid rgba(216, 211, 199, .48);
    background: rgba(23, 20, 43, .34);
    backdrop-filter: blur(12px);
}

.spine-mark {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    text-decoration: none;
    color: var(--silver-theorem);
    font-family: var(--fraunces);
    font-size: 18px;
    border: 1px solid rgba(216, 211, 199, .24);
    border-radius: 50%;
    transition: transform .45s ease, color .45s ease, background .45s ease, border-color .45s ease;
}

.spine-mark.active {
    color: var(--midnight-ink);
    background: var(--curry-coral);
    border-color: var(--curry-coral);
    transform: translateX(-8px) rotate(-12deg);
    box-shadow: 0 0 28px rgba(255, 122, 107, .48);
}

.diagonal-rule {
    position: absolute;
    width: 145vw;
    height: 2px;
    left: -20vw;
    top: 48%;
    transform: rotate(-29deg);
    background: linear-gradient(90deg, transparent, rgba(183, 164, 255, .58), rgba(91, 63, 168, .65), transparent);
    z-index: -1;
}

.paper-grain {
    position: absolute;
    inset: 0;
    background-image: radial-gradient(rgba(244, 238, 219, .18) 1px, transparent 1px);
    background-size: 7px 7px;
    opacity: .28;
}

.manuscript-panel {
    position: relative;
    max-width: 620px;
    padding: clamp(26px, 4vw, 48px);
    background: rgba(244, 238, 219, .88);
    color: var(--midnight-ink);
    border: 1px solid rgba(91, 63, 168, .32);
    box-shadow: 0 28px 70px rgba(23, 20, 43, .22);
    clip-path: polygon(0 0, calc(100% - 28px) 0, 100% 28px, 100% 100%, 30px 100%, 0 calc(100% - 30px));
}

.manuscript-panel::before {
    content: "";
    position: absolute;
    inset: 13px;
    border: 1px solid rgba(216, 211, 199, .9);
    pointer-events: none;
}

.nested-frame::after {
    content: "";
    position: absolute;
    inset: 31px;
    border: 1px dashed rgba(91, 63, 168, .32);
    transform: rotate(-1deg);
    pointer-events: none;
}

.chapter-label, .marginalia, .type-slip, .annotation-row, .paper-tabs, .continue-evaluation {
    font-family: var(--commissioner);
    letter-spacing: .12em;
    text-transform: uppercase;
    font-size: 12px;
}

h1, h2 {
    font-family: var(--newsreader);
    font-weight: 520;
    line-height: .95;
    margin: 0;
    color: var(--lambda-violet);
}

h1 { font-size: clamp(64px, 13vw, 168px); letter-spacing: -.07em; }
h2 { font-size: clamp(44px, 7vw, 92px); letter-spacing: -.045em; }

p { font-size: clamp(18px, 2vw, 24px); line-height: 1.62; }
code { font-family: var(--mono); color: var(--lambda-violet); }

.gate-panel { margin-left: min(8vw, 90px); margin-top: 22vh; background: rgba(244, 238, 219, .94); }
.gate-panel h1 { color: var(--midnight-ink); text-shadow: 0 1px 0 var(--type-lavender); }
.inscription { max-width: 520px; }

.lantern-stage {
    position: absolute;
    left: 44%;
    top: 19%;
    width: 420px;
    height: 420px;
    transform: translateX(-50%);
}

.lambda-lantern {
    position: absolute;
    inset: 0;
    border: 0;
    background: transparent;
    color: var(--type-lavender);
    cursor: pointer;
    transition: transform 1s cubic-bezier(.2, .9, .2, 1), filter 1s ease;
}

.lambda-layer {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-family: var(--fraunces);
    font-size: 360px;
    font-weight: 700;
    line-height: 1;
    text-shadow: 0 0 40px rgba(183, 164, 255, .32);
    transition: opacity .8s ease, transform .8s ease;
}

.layer-one { color: rgba(183, 164, 255, .72); transform: rotate(-12deg); }
.layer-two { color: rgba(91, 63, 168, .66); transform: scale(.72) rotate(11deg); }
.layer-three { color: rgba(168, 230, 207, .38); transform: scale(.46) rotate(-24deg); }
.lambda-core { position: absolute; left: 48%; top: 49%; transform: translate(-50%, -50%) rotate(-8deg); font-family: var(--mono); color: var(--lazy-mint); }

.arrow-corridor {
    position: absolute;
    left: 56%;
    top: 50%;
    display: flex;
    gap: 28px;
    transform: rotate(-18deg);
    pointer-events: none;
}

.arrow-corridor span {
    opacity: 0;
    transform: translateX(-80px) rotate(20deg);
    color: var(--curry-coral);
    font: 700 70px var(--fraunces);
    transition: opacity .75s ease, transform .85s cubic-bezier(.2, .9, .2, 1);
}

.arrow-corridor span:nth-child(2) { transition-delay: .09s; }
.arrow-corridor span:nth-child(3) { transition-delay: .18s; }
.arrow-corridor span:nth-child(4) { transition-delay: .27s; }
.arrow-corridor span:nth-child(5) { transition-delay: .36s; }

.evaluate-gesture {
    border: 1px solid var(--lambda-violet);
    background: transparent;
    color: var(--lambda-violet);
    font-family: var(--commissioner);
    text-transform: uppercase;
    letter-spacing: .16em;
    padding: 13px 18px;
    cursor: pointer;
    transition: background .35s ease, color .35s ease, transform .35s ease;
}

.evaluate-gesture:hover { background: var(--lambda-violet); color: var(--proof-parchment); transform: translateY(-3px); }

.marginalia {
    position: absolute;
    color: var(--silver-theorem);
    border-left: 1px solid currentColor;
    padding: 18px;
    max-width: 230px;
    line-height: 1.7;
}

.gate-note { right: 12vw; bottom: 14vh; }
.hall-note { left: 8vw; bottom: 10vh; color: var(--lambda-violet); }
.hall-note span { color: var(--curry-coral); }

.thread-drawing { position: absolute; inset: 8vh 7vw; width: 86vw; height: 80vh; pointer-events: none; }
.function-path, .bracket-path { fill: none; stroke: var(--lambda-violet); stroke-width: 3; stroke-linecap: round; stroke-dasharray: 1200; stroke-dashoffset: 1200; opacity: .68; }
.bracket-path { stroke: var(--curry-coral); stroke-width: 2; }
.chamber.in-view .function-path, .chamber.in-view .bracket-path { animation: drawPath 2.4s ease forwards; }

@keyframes drawPath { to { stroke-dashoffset: 0; } }

.doorway-stack { position: absolute; right: 12vw; top: 20vh; width: 360px; height: 480px; transform: rotate(-7deg); }
.door { position: absolute; bottom: 0; border: 2px solid var(--lambda-violet); background: rgba(244, 238, 219, .52); display: grid; place-items: start center; padding-top: 24px; font: 600 24px var(--fraunces); color: var(--lambda-violet); box-shadow: inset 0 0 0 16px rgba(183, 164, 255, .12); }
.door-one { width: 280px; height: 430px; right: 0; }
.door-two { width: 200px; height: 320px; right: 42px; }
.door-three { width: 128px; height: 220px; right: 78px; }
.hall-panel { margin-left: 13vw; transform: rotate(-1.2deg); }

.type-slip { margin-top: 24px; padding: 12px 14px; border-top: 1px solid var(--silver-theorem); border-bottom: 1px solid var(--silver-theorem); }

.atrium-panel { margin-left: auto; margin-right: 9vw; transform: rotate(1deg); }
.pleated-fan { position: absolute; left: 8vw; top: 22vh; width: 44vw; height: 58vh; display: flex; align-items: stretch; transform: perspective(900px) rotateY(-16deg) rotate(-7deg); }
.pleated-fan span { flex: 1; border: 1px solid rgba(91, 63, 168, .28); background: linear-gradient(90deg, rgba(91, 63, 168, .16), rgba(244, 238, 219, .8)); transform-origin: bottom center; animation: foldBreathe 4.8s ease-in-out infinite; }
.pleated-fan span:nth-child(even) { background: linear-gradient(90deg, rgba(255, 122, 107, .12), rgba(216, 211, 199, .68)); transform: skewY(-10deg); }
@keyframes foldBreathe { 50% { transform: skewY(7deg) translateY(-10px); } }

.annotation-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 26px; }
.annotation-row span, .paper-tabs span { border: 1px solid var(--silver-theorem); padding: 8px 12px; background: rgba(244, 238, 219, .7); color: var(--lambda-violet); }
.symbolic-quote { position: absolute; left: 11vw; bottom: 9vh; max-width: 520px; margin: 0; font: 600 clamp(38px, 6vw, 78px)/.98 var(--fraunces); color: rgba(91, 63, 168, .5); }

.well-ripples { position: absolute; left: 8vw; top: 10vh; width: 52vw; height: 76vh; display: grid; place-items: center; }
.well-ripples span { position: absolute; border-radius: 50%; border: 2px solid rgba(168, 230, 207, .42); width: calc(22% + var(--i, 0) * 16%); aspect-ratio: 1; animation: ripple 5s ease-in-out infinite; }
.well-ripples span:nth-child(1) { --i: 1; }
.well-ripples span:nth-child(2) { --i: 2; animation-delay: .3s; }
.well-ripples span:nth-child(3) { --i: 3; animation-delay: .6s; }
.well-ripples span:nth-child(4) { --i: 4; animation-delay: .9s; }
@keyframes ripple { 50% { transform: scale(1.08); border-color: rgba(255, 122, 107, .5); } }
.well-seal { width: 132px; height: 132px; display: grid; place-items: center; border-radius: 50%; background: var(--lambda-violet); color: var(--proof-parchment); font: 700 28px var(--fraunces); box-shadow: 0 0 70px rgba(183, 164, 255, .45); }
.well-panel { margin-left: auto; margin-right: 9vw; background: rgba(244, 238, 219, .9); }
.paper-tabs { position: absolute; right: 13vw; bottom: 10vh; display: flex; gap: 8px; transform: rotate(3deg); }

.theorem-stars { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; }
.observatory-panel { margin-left: 9vw; background: rgba(244, 238, 219, .9); }
.lantern-values { position: absolute; right: 11vw; top: 21vh; display: grid; grid-template-columns: repeat(3, 96px); gap: 24px; transform: rotate(-8deg); }
.lazy-lantern { width: 96px; height: 132px; border: 1px solid rgba(168, 230, 207, .7); border-radius: 48px 48px 18px 18px; background: rgba(244, 238, 219, .08); color: var(--lazy-mint); font: 700 42px var(--fraunces); box-shadow: inset 0 -22px 40px rgba(168, 230, 207, .12), 0 0 24px rgba(168, 230, 207, .12); cursor: pointer; transition: background .45s ease, color .45s ease, transform .45s ease; }
.lazy-lantern.revealed { background: rgba(168, 230, 207, .72); color: var(--midnight-ink); transform: translateY(-12px) rotate(8deg); }

.garden-grid { position: absolute; left: 8vw; top: 14vh; width: 48vw; height: 70vh; display: grid; grid-template-columns: repeat(2, minmax(150px, 1fr)); gap: 28px; transform: rotate(-6deg); }
.type-flower { display: grid; place-items: center; align-content: center; gap: 12px; min-height: 220px; border: 1px solid rgba(91, 63, 168, .32); background: rgba(244, 238, 219, .58); clip-path: polygon(50% 0, 100% 24%, 90% 100%, 10% 100%, 0 24%); color: var(--lambda-violet); box-shadow: 0 18px 42px rgba(23, 20, 43, .1); }
.type-flower strong { font: 700 72px var(--fraunces); }
.type-flower span { font-family: var(--commissioner); text-transform: uppercase; letter-spacing: .12em; }
.garden-panel { margin-left: auto; margin-right: 7vw; }
.continue-evaluation { display: inline-block; margin-top: 22px; color: var(--lambda-violet); text-decoration: none; border-bottom: 1px solid var(--curry-coral); padding-bottom: 8px; }
.final-seal { position: absolute; right: 12vw; bottom: 8vh; font-family: var(--newsreader); color: rgba(91, 63, 168, .36); font-size: clamp(42px, 7vw, 112px); margin: 0; transform: rotate(-4deg); }

@media (max-width: 860px) {
    .evaluation-spine { right: 8px; }
    .chamber { padding-right: 68px; }
    .lantern-stage, .doorway-stack, .pleated-fan, .well-ripples, .garden-grid { opacity: .36; left: 4vw; width: 80vw; }
    .manuscript-panel, .gate-panel, .hall-panel, .atrium-panel, .well-panel, .observatory-panel, .garden-panel { margin: 20vh 0 0; }
    .lantern-values { right: 18vw; grid-template-columns: repeat(3, 72px); }
    .lazy-lantern { width: 72px; height: 102px; }
    .symbolic-quote, .marginalia, .paper-tabs { display: none; }
}
