/* ------------------------------------------------------------------
   haskell.quest — styles.css
   A marble museum of pure functional programming.
   Palette (triadic, desaturated to marble tones):
     #f5f0e8  Marble White        (primary background)
     #ede6d8  Pale Veined Marble  (secondary surface)
     #c8bfb0  Vein Grey           (dividers / secondary)
     #8b7a3a  Gold-Amber          (accent 3 — decorative, lambda)
     #3a6b8b  Steel-Teal          (accent 2 — links, code annotations)
     #6b3a6b  Aubergine           (code text)
     #8b3a5c  Cranberry           (accent 1 — chapter markers, hover)
     #2c2824  Obsidian            (primary text)
     #1a1714  Shadow Depth        (text-shadow / box-shadow only)
     #3b3530  Warm body text ink
   ------------------------------------------------------------------ */

:root {
    --marble-white: #f5f0e8;
    --marble-pale: #ede6d8;
    --marble-vein: #c8bfb0;
    --gold-amber: #8b7a3a;
    --steel-teal: #3a6b8b;
    --aubergine: #6b3a6b;
    --cranberry: #8b3a5c;
    --obsidian: #2c2824;
    --shadow-depth: #1a1714;
    --body-ink: #3b3530;
    --ease-stone: cubic-bezier(0.23, 1, 0.32, 1);
    --tilt: 0deg;
    --scroll-progress: 0;
}

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

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

body {
    font-family: "Source Serif 4", "Cormorant Garamond", Georgia, serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.15vw, 1.2rem);
    line-height: 1.72;
    color: var(--body-ink);
    background-color: var(--marble-white);
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(200, 191, 176, 0.30) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(200, 191, 176, 0.22) 0%, transparent 40%),
        radial-gradient(ellipse at 60% 80%, rgba(139, 122, 58, 0.06) 0%, transparent 60%),
        linear-gradient(135deg, #f5f0e8 0%, #ede6d8 50%, #f5f0e8 100%);
    background-attachment: fixed;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Selection */
::selection {
    background: rgba(139, 122, 58, 0.35);
    color: var(--obsidian);
}

/* ------------------------------------------------------------------
   SHARED: carved typography, marble surfaces, tilt-3d panels
   ------------------------------------------------------------------ */

.carved {
    font-family: "Cormorant Garamond", "Source Serif 4", Georgia, serif;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    line-height: 1.05;
    color: var(--obsidian);
    text-shadow:
        1px 1px 0 #ede6d8,
        2px 2px 1px rgba(26, 23, 20, 0.15),
        -1px -1px 0 rgba(255, 255, 255, 0.55),
        0 0 22px rgba(245, 240, 232, 0.6);
}

.carved.light { font-weight: 300; }
.carved.tight { letter-spacing: 0.04em; }
.extra-spaced { letter-spacing: 0.22em; }

.code-mono {
    font-family: "Fira Code", "Source Code Pro", ui-monospace, monospace;
    font-weight: 400;
    font-size: 0.92em;
    letter-spacing: 0.02em;
    color: var(--aubergine);
    background: var(--marble-pale);
    padding: 0.12em 0.42em;
    border-radius: 1px;
    border-left: 2px solid var(--gold-amber);
    font-feature-settings: "calt" 1, "liga" 1;
}

.code-mono .sym {
    color: var(--steel-teal);
    padding: 0 0.08em;
}

em { font-style: italic; color: var(--obsidian); }

.accent-teal   { color: var(--steel-teal); font-style: italic; }
.accent-violet { color: var(--cranberry); font-style: italic; }

/* ------------------------------------------------------------------
   CHAMBERS (sections) — each is a full viewport "room"
   ------------------------------------------------------------------ */

.chamber {
    position: relative;
    min-height: 100vh;
    padding: clamp(3rem, 8vh, 7rem) clamp(1.25rem, 5vw, 5.5rem);
    padding-left: clamp(4.5rem, 12vw, 10rem);       /* room for stem nav */
    padding-right: clamp(1.25rem, 5vw, 5.5rem);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border-bottom: 1px solid rgba(200, 191, 176, 0.55);
}

.chamber::before {
    /* subtle per-chamber marble variation */
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(ellipse at var(--vx, 30%) var(--vy, 40%), rgba(200, 191, 176, 0.22) 0%, transparent 55%),
        radial-gradient(ellipse at 75% 70%, rgba(139, 122, 58, 0.04) 0%, transparent 60%);
    mix-blend-mode: multiply;
}

.chamber-i       { --vx: 22%; --vy: 35%; }
.chamber-ii      { --vx: 68%; --vy: 20%; background-color: var(--marble-white); }
.chamber-iii     { --vx: 40%; --vy: 60%; background-color: var(--marble-pale); }
.chamber-iv      { --vx: 15%; --vy: 70%; }
.chamber-v       { --vx: 55%; --vy: 45%; }
.f-pattern       { --vx: 30%; --vy: 50%; }
.chamber-threshold { --vx: 50%; --vy: 50%; }

/* ------------------------------------------------------------------
   LAMBDA WATERMARK — recurring decorative glyph
   ------------------------------------------------------------------ */

.lambda-watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) perspective(1200px) rotateY(var(--tilt, 0deg)) rotateX(-3deg);
    font-family: "Cormorant Garamond", serif;
    font-weight: 300;
    font-size: 42vw;
    line-height: 1;
    color: rgba(139, 122, 58, 0.05);
    pointer-events: none;
    user-select: none;
    z-index: 0;
    transition: transform 2.4s var(--ease-stone);
    will-change: transform;
}

.lambda-watermark.small { font-size: 28vw; opacity: 0.8; }

.chamber > *:not(.lambda-watermark):not(.threshold-floor) {
    position: relative;
    z-index: 1;
}

/* ------------------------------------------------------------------
   STEM NAVIGATION — vertical stem of the F, medallions
   ------------------------------------------------------------------ */

.stem-nav {
    position: fixed;
    top: 0;
    left: 0;
    width: clamp(3.75rem, 7vw, 5.25rem);
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: clamp(1rem, 2.5vh, 2rem);
    z-index: 50;
    background: linear-gradient(180deg,
        rgba(245, 240, 232, 0.35) 0%,
        rgba(237, 230, 216, 0.55) 50%,
        rgba(245, 240, 232, 0.35) 100%);
    border-right: 1px solid rgba(200, 191, 176, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.stem-nav::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 8%;
    bottom: 8%;
    width: 1px;
    background: linear-gradient(180deg,
        transparent,
        rgba(139, 122, 58, 0.35) 15%,
        rgba(139, 122, 58, 0.35) 85%,
        transparent);
}

.medallion {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    border: 2px solid var(--gold-amber);
    outline: 1px solid var(--marble-vein);
    outline-offset: 4px;
    background:
        radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.7), transparent 60%),
        linear-gradient(135deg, var(--marble-white), var(--marble-pale));
    box-shadow:
        inset 1px 1px 0 rgba(255, 255, 255, 0.7),
        inset -1px -1px 2px rgba(26, 23, 20, 0.12),
        2px 2px 0 rgba(26, 23, 20, 0.05);
    text-decoration: none;
    color: var(--obsidian);
    cursor: pointer;
    transition:
        transform 0.5s var(--ease-stone),
        border-color 0.4s var(--ease-stone),
        box-shadow 0.5s var(--ease-stone);
    will-change: transform;
}

.medallion .numeral {
    font-family: "Cormorant Garamond", serif;
    font-weight: 300;
    font-size: 1.35rem;
    letter-spacing: 0.04em;
    line-height: 1;
    color: var(--obsidian);
}

.medallion .medallion-label {
    font-family: "Source Serif 4", serif;
    font-style: italic;
    font-size: 0.58rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--body-ink);
    margin-top: 2px;
    opacity: 0.75;
}

.medallion:hover {
    transform: scale(1.08) rotate(-2deg);
    border-color: var(--cranberry);
    box-shadow:
        inset 1px 1px 0 rgba(255, 255, 255, 0.8),
        inset -1px -1px 2px rgba(26, 23, 20, 0.15),
        4px 4px 0 rgba(139, 58, 92, 0.18);
}

.medallion.is-active {
    border-color: var(--cranberry);
    background:
        radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.8), transparent 60%),
        linear-gradient(135deg, var(--marble-white), rgba(139, 58, 92, 0.08));
}

.medallion.is-active .numeral { color: var(--cranberry); }

/* Inline medallions (inside chamber headers) scale up */
.inline-medallion {
    width: 64px;
    height: 64px;
    flex-shrink: 0;
}
.inline-medallion .numeral { font-size: 1.65rem; }
.inline-medallion .medallion-label { display: none; }

/* ------------------------------------------------------------------
   OPENING CHAMBER — The Lambda Threshold
   ------------------------------------------------------------------ */

.chamber-threshold {
    align-items: center;
    text-align: center;
    min-height: 100vh;
    padding-top: 10vh;
    padding-bottom: 12vh;
}

.chamber-threshold .lambda-watermark {
    font-size: clamp(28rem, 42vw, 60rem);
    color: rgba(139, 122, 58, 0.055);
    animation: marble-tilt 22s ease-in-out infinite alternate;
}

@keyframes marble-tilt {
    0%   { transform: translate(-50%, -50%) perspective(1200px) rotateY(-5deg) rotateX(-3deg); }
    50%  { transform: translate(-50%, -50%) perspective(1200px) rotateY(0deg)  rotateX(-1deg); }
    100% { transform: translate(-50%, -50%) perspective(1200px) rotateY(5deg)  rotateX(-3deg); }
}

.threshold-inner {
    position: relative;
    z-index: 2;
    max-width: 1100px;
    margin: 0 auto;
}

.eyebrow {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.2rem;
    margin-bottom: clamp(1.5rem, 4vh, 3rem);
    color: var(--gold-amber);
    font-family: "Source Serif 4", serif;
    font-style: italic;
    font-size: 0.88rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

.eyebrow-rule {
    height: 1px;
    width: clamp(3rem, 10vw, 8rem);
    background: linear-gradient(90deg, transparent, var(--gold-amber), transparent);
}

.title {
    font-size: clamp(4rem, 10vw, 8rem);
    letter-spacing: 0.12em;
    color: var(--obsidian);
    margin-bottom: 1.25rem;
    text-shadow:
        2px 2px 0 #ede6d8,
        3px 3px 2px rgba(26, 23, 20, 0.22),
        -1px -1px 0 rgba(255, 255, 255, 0.7),
        -2px -2px 4px rgba(255, 255, 255, 0.4),
        0 0 50px rgba(245, 240, 232, 0.6);
}

.subtitle {
    font-family: "Source Serif 4", serif;
    font-style: italic;
    font-size: clamp(1.05rem, 1.4vw, 1.35rem);
    color: var(--body-ink);
    max-width: 52ch;
    margin: 0 auto clamp(2rem, 5vh, 3.5rem);
    line-height: 1.65;
}

.threshold-signature {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    color: var(--cranberry);
    font-family: "Cormorant Garamond", serif;
    font-style: italic;
    font-size: 0.9rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

.sig-line {
    width: clamp(1.5rem, 6vw, 4rem);
    height: 1px;
    background: var(--cranberry);
    opacity: 0.55;
}

.threshold-floor {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 14vh;
    pointer-events: none;
    background: linear-gradient(180deg,
        transparent,
        rgba(200, 191, 176, 0.35) 60%,
        rgba(139, 122, 58, 0.10));
    transform: perspective(1000px) rotateX(42deg);
    transform-origin: bottom center;
    opacity: 0.7;
}

/* ------------------------------------------------------------------
   F-PATTERN INTRODUCTION — shelves
   ------------------------------------------------------------------ */

.f-pattern {
    padding-top: clamp(4rem, 10vh, 8rem);
    padding-bottom: clamp(4rem, 10vh, 8rem);
    gap: clamp(3rem, 6vh, 5rem);
    justify-content: flex-start;
}

.shelf {
    position: relative;
    display: grid;
    gap: clamp(1.5rem, 3vw, 3rem);
    padding: clamp(1.5rem, 3vh, 2.75rem) clamp(1.5rem, 3vw, 2.75rem);
    background:
        linear-gradient(90deg, rgba(200, 191, 176, 0.25), rgba(245, 240, 232, 0.6) 20%, rgba(237, 230, 216, 0.4));
    border-top: 1px solid rgba(139, 122, 58, 0.35);
    border-bottom: 1px solid rgba(200, 191, 176, 0.65);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.55),
        0 8px 18px -16px rgba(26, 23, 20, 0.45);
    transform-origin: left center;
    transition: transform 1.2s var(--ease-stone), opacity 1s var(--ease-stone);
}

.shelf-top {
    width: 100%;
    grid-template-columns: minmax(0, 0.62fr) minmax(0, 0.38fr);
    align-items: center;
}

.shelf-middle {
    width: 60%;
    margin-left: 0;
    grid-template-columns: minmax(0, 1fr);
    transform: scale(0.98) translateY(4px);
    opacity: 0.96;
}

.shelf-marker {
    position: absolute;
    left: -0.4rem;
    top: -0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.18rem 0.65rem;
    background: var(--marble-white);
    border: 1px solid var(--gold-amber);
    color: var(--gold-amber);
    font-family: "Cormorant Garamond", serif;
    font-size: 0.78rem;
    letter-spacing: 0.25em;
    text-transform: uppercase;
}

.shelf-glyph { font-weight: 700; font-size: 0.95rem; color: var(--cranberry); }
.shelf-kicker { font-style: italic; letter-spacing: 0.22em; }

.shelf-content {
    max-width: 62ch;
}

.section-heading {
    font-size: clamp(2.2rem, 4.5vw, 3.6rem);
    margin-bottom: 1.2rem;
    color: var(--obsidian);
}

.lede {
    font-size: clamp(1.1rem, 1.4vw, 1.35rem);
    line-height: 1.6;
    color: var(--obsidian);
    margin-bottom: 1.1rem;
    font-style: italic;
    font-family: "Source Serif 4", serif;
}

.shelf-text p + p { margin-top: 0.9rem; }

/* Tilted panel on the right of the F's top bar */
.tilted-panel {
    position: relative;
    padding: clamp(1.5rem, 3vh, 2.5rem) clamp(1.2rem, 2.5vw, 2.2rem);
    background:
        radial-gradient(ellipse at 30% 30%, rgba(255, 255, 255, 0.5), transparent 60%),
        linear-gradient(140deg, var(--marble-pale), var(--marble-white));
    border: 1px solid rgba(200, 191, 176, 0.8);
    box-shadow:
        inset 1px 1px 0 rgba(255, 255, 255, 0.7),
        inset -2px -2px 8px rgba(26, 23, 20, 0.05),
        6px 8px 0 rgba(26, 23, 20, 0.03);
    transform: perspective(800px) rotateY(-8deg);
    transition: transform 1s var(--ease-stone);
    transform-origin: right center;
    will-change: transform;
    min-height: 200px;
    display: grid;
    align-items: center;
}

.panel-inner {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.9rem;
    text-align: center;
}

.panel-tag {
    font-family: "Source Serif 4", serif;
    font-style: italic;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    font-size: 0.72rem;
    color: var(--gold-amber);
}

.panel-code {
    font-size: clamp(1.4rem, 2.5vw, 2.1rem);
    color: var(--steel-teal);
    background: transparent;
    border: none;
    padding: 0;
    letter-spacing: 0.04em;
}

.panel-code.large { font-size: clamp(1.8rem, 3.2vw, 2.8rem); }

.panel-note {
    font-family: "Source Serif 4", serif;
    font-style: italic;
    font-size: 0.95rem;
    color: var(--body-ink);
    max-width: 24ch;
    line-height: 1.55;
}

.panel-glyph {
    font-family: "Cormorant Garamond", serif;
    font-weight: 300;
    font-size: 3.5rem;
    color: rgba(139, 122, 58, 0.25);
    line-height: 1;
}

.type-line {
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid rgba(200, 191, 176, 0.7);
    text-align: center;
}

.circuit-line {
    width: 100%;
    margin-top: 2rem;
    opacity: 0.7;
}

.circuit-svg {
    width: 100%;
    height: 80px;
    overflow: visible;
}

.circuit-stroke {
    stroke: var(--marble-vein);
    stroke-width: 1;
    fill: none;
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 1.8s var(--ease-stone);
}

.circuit-node {
    fill: var(--gold-amber);
    opacity: 0.85;
    transform-origin: center;
    transform: scale(0);
    transition: transform 0.5s var(--ease-stone);
}

.is-in-view .circuit-stroke { stroke-dashoffset: 0; }
.is-in-view .circuit-node { transform: scale(1); }
.is-in-view .circuit-node:nth-child(n+4) { transition-delay: 0.6s; }

/* ------------------------------------------------------------------
   CHAMBER HEADER (shared)
   ------------------------------------------------------------------ */

.chamber-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: clamp(2rem, 5vh, 3.5rem);
}

.chamber-header.center {
    justify-content: center;
    text-align: center;
}

.chamber-title-group {
    display: flex;
    flex-direction: column;
}

.chamber-kicker {
    font-family: "Source Serif 4", serif;
    font-style: italic;
    font-size: 0.85rem;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: var(--cranberry);
    margin-bottom: 0.4rem;
}

.chamber-title {
    font-size: clamp(2.5rem, 6vw, 5rem);
    color: var(--obsidian);
    letter-spacing: 0.1em;
}

/* ------------------------------------------------------------------
   CHAMBER I — PURITY
   ------------------------------------------------------------------ */

.purity-grid {
    display: grid;
    grid-template-columns: minmax(0, 0.62fr) minmax(0, 0.38fr);
    gap: clamp(2rem, 4vw, 4rem);
    align-items: start;
}

.chamber-grid {
    width: 100%;
}

.chamber-text {
    max-width: 62ch;
}

.chamber-text p { margin-bottom: 1.15rem; }

.reveal-line {
    opacity: 0;
    transform: translateX(-30px);
    transition:
        opacity 1.1s var(--ease-stone),
        transform 1.1s var(--ease-stone);
}

.is-revealed .reveal-line { opacity: 1; transform: translateX(0); }
.is-revealed .reveal-line:nth-child(1) { transition-delay: 0.00s; }
.is-revealed .reveal-line:nth-child(2) { transition-delay: 0.12s; }
.is-revealed .reveal-line:nth-child(3) { transition-delay: 0.24s; }
.is-revealed .reveal-line:nth-child(4) { transition-delay: 0.36s; }
.is-revealed .reveal-line:nth-child(5) { transition-delay: 0.48s; }

.reveal-line-code {
    background: var(--marble-pale);
    padding: 0.9rem 1.2rem;
    border-left: 3px solid var(--gold-amber);
    font-size: 1rem;
}

.reveal-line-code .code-mono {
    background: transparent;
    border: none;
    padding: 0;
    font-size: 1em;
    letter-spacing: 0.03em;
}

.chamber-panel {
    align-self: center;
    max-width: 420px;
    justify-self: end;
}

.large-tilt {
    transform: perspective(800px) rotateY(-15deg);
}

.is-revealed .large-tilt {
    transform: perspective(800px) rotateY(-8deg);
}

/* ------------------------------------------------------------------
   CHAMBER II — TYPES
   ------------------------------------------------------------------ */

.chamber-ii {
    align-items: center;
    text-align: center;
    justify-content: center;
}

.types-intro {
    max-width: 56ch;
    margin: 0 auto 3rem;
    font-style: italic;
    color: var(--body-ink);
    font-size: clamp(1.05rem, 1.35vw, 1.3rem);
    line-height: 1.65;
}

.type-tree {
    position: relative;
    width: min(900px, 100%);
    height: 380px;
    margin: 0 auto;
}

.type-tree-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.tree-line {
    stroke: var(--gold-amber);
    stroke-width: 1.25;
    fill: none;
    stroke-dasharray: 600;
    stroke-dashoffset: 600;
    transition: stroke-dashoffset 1.5s var(--ease-stone);
}

.is-revealed .tree-line:nth-of-type(1) { transition-delay: 0.2s; stroke-dashoffset: 0; }
.is-revealed .tree-line:nth-of-type(2) { transition-delay: 0.35s; stroke-dashoffset: 0; }
.is-revealed .tree-line:nth-of-type(3) { transition-delay: 0.5s;  stroke-dashoffset: 0; }
.is-revealed .tree-line:nth-of-type(4) { transition-delay: 0.9s;  stroke-dashoffset: 0; }
.is-revealed .tree-line:nth-of-type(5) { transition-delay: 1.05s; stroke-dashoffset: 0; }
.is-revealed .tree-line:nth-of-type(6) { transition-delay: 1.2s;  stroke-dashoffset: 0; }

.tree-node {
    position: absolute;
    left: calc((var(--nx) / 900) * 100%);
    top: calc((var(--ny) / 380) * 100%);
    transform: translate(-50%, -50%) scale(0.6);
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 2px solid var(--gold-amber);
    outline: 1px solid var(--marble-vein);
    outline-offset: 4px;
    background:
        radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.75), transparent 60%),
        linear-gradient(135deg, var(--marble-white), var(--marble-pale));
    box-shadow:
        inset 1px 1px 0 rgba(255, 255, 255, 0.7),
        inset -1px -1px 2px rgba(26, 23, 20, 0.12),
        2px 2px 0 rgba(26, 23, 20, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition:
        opacity 0.7s var(--ease-stone),
        transform 0.7s var(--ease-stone);
}

.tree-node.leaf {
    width: 44px;
    height: 44px;
    border-color: var(--cranberry);
}

.tree-node.leaf .node-type { color: var(--cranberry); }

.tree-node.node-root {
    width: 72px;
    height: 72px;
    border-color: var(--steel-teal);
}

.tree-node.node-root .node-type { color: var(--steel-teal); font-size: 1.5rem; }

.node-type {
    font-family: "Cormorant Garamond", serif;
    font-weight: 500;
    font-size: 1.1rem;
    letter-spacing: 0.05em;
    color: var(--obsidian);
}

.is-revealed .tree-node { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.is-revealed .tree-node:nth-of-type(1) { transition-delay: 0.1s; }
.is-revealed .tree-node:nth-of-type(2) { transition-delay: 0.55s; }
.is-revealed .tree-node:nth-of-type(3) { transition-delay: 0.75s; }
.is-revealed .tree-node:nth-of-type(4) { transition-delay: 0.95s; }
.is-revealed .tree-node:nth-of-type(5) { transition-delay: 1.3s; }
.is-revealed .tree-node:nth-of-type(6) { transition-delay: 1.5s; }
.is-revealed .tree-node:nth-of-type(7) { transition-delay: 1.7s; }

.types-caption {
    margin-top: 2.5rem;
    text-align: center;
    font-size: 1rem;
}

/* ------------------------------------------------------------------
   CHAMBER III — MONADS (chandelier)
   ------------------------------------------------------------------ */

.chamber-iii {
    background-color: var(--marble-pale);
    background-image:
        radial-gradient(ellipse at 30% 20%, rgba(200, 191, 176, 0.3) 0%, transparent 55%),
        radial-gradient(ellipse at 75% 80%, rgba(139, 122, 58, 0.07) 0%, transparent 60%);
}

.monads-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0 auto;
    width: 100%;
    max-width: 1200px;
    font-size: clamp(4rem, 11vw, 9rem);
    letter-spacing: 0.02em;
    line-height: 1;
    text-align: center;
    color: var(--obsidian);
}

.monad-letter {
    position: relative;
    display: inline-block;
    transition: transform 0.6s var(--ease-stone), color 0.6s var(--ease-stone);
}

.monads-chandelier {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: clamp(0.75rem, 1.5vw, 1.25rem);
    margin-top: 3.5rem;
    max-width: 1200px;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    position: relative;
}

.monad-card {
    position: relative;
    padding: 1.25rem 1rem 1rem;
    background:
        radial-gradient(ellipse at 30% 20%, rgba(255, 255, 255, 0.65), transparent 60%),
        linear-gradient(150deg, var(--marble-white), var(--marble-pale));
    border: 1px solid var(--marble-vein);
    box-shadow:
        inset 1px 1px 0 rgba(255, 255, 255, 0.6),
        3px 3px 0 rgba(26, 23, 20, 0.05);
    min-height: 220px;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    transform: translateY(20px);
    opacity: 0;
    transition:
        transform 0.9s var(--ease-stone),
        opacity 0.9s var(--ease-stone),
        box-shadow 0.4s var(--ease-stone);
    transform-style: preserve-3d;
    will-change: transform;
}

.is-revealed .monad-card { opacity: 1; transform: translateY(0); }
.is-revealed .monad-card[data-index="0"] { transition-delay: 0.08s; }
.is-revealed .monad-card[data-index="1"] { transition-delay: 0.18s; }
.is-revealed .monad-card[data-index="2"] { transition-delay: 0.28s; }
.is-revealed .monad-card[data-index="3"] { transition-delay: 0.38s; }
.is-revealed .monad-card[data-index="4"] { transition-delay: 0.48s; }
.is-revealed .monad-card[data-index="5"] { transition-delay: 0.58s; }

.monad-card:hover {
    transform: perspective(600px) rotateX(-3deg) rotateY(5deg) translateY(-3px);
    box-shadow:
        inset 1px 1px 0 rgba(255, 255, 255, 0.7),
        6px 10px 0 rgba(26, 23, 20, 0.07);
}

/* chandelier "thread" connecting title letter to card */
.monad-thread {
    position: absolute;
    top: -3.5rem;
    left: 50%;
    width: 1px;
    height: 3.5rem;
    background: linear-gradient(180deg, transparent, rgba(139, 122, 58, 0.75));
    transform-origin: top;
    transform: scaleY(0);
    transition: transform 0.8s var(--ease-stone);
}

.is-revealed .monad-card .monad-thread { transform: scaleY(1); }
.is-revealed .monad-card[data-index="0"] .monad-thread { transition-delay: 0.18s; }
.is-revealed .monad-card[data-index="1"] .monad-thread { transition-delay: 0.28s; }
.is-revealed .monad-card[data-index="2"] .monad-thread { transition-delay: 0.38s; }
.is-revealed .monad-card[data-index="3"] .monad-thread { transition-delay: 0.48s; }
.is-revealed .monad-card[data-index="4"] .monad-thread { transition-delay: 0.58s; }
.is-revealed .monad-card[data-index="5"] .monad-thread { transition-delay: 0.68s; }

.monad-name {
    font-family: "Cormorant Garamond", serif;
    font-weight: 700;
    font-size: 1.5rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--cranberry);
}

.monad-card p {
    font-family: "Source Serif 4", serif;
    font-size: 0.88rem;
    line-height: 1.55;
    color: var(--body-ink);
    font-style: italic;
    flex-grow: 1;
}

.monad-card .code-mono {
    font-size: 0.78rem;
    padding: 0.3rem 0.45rem;
    align-self: flex-start;
}

.monad-footer {
    margin-top: 3rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
}

.monad-footer .code-mono {
    font-size: clamp(0.95rem, 1.4vw, 1.3rem);
    background: transparent;
    border: none;
    padding: 0;
}

.monad-footer-tag {
    font-family: "Source Serif 4", serif;
    font-style: italic;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    font-size: 0.72rem;
    color: var(--gold-amber);
}

/* ------------------------------------------------------------------
   CHAMBER IV — LAZINESS
   ------------------------------------------------------------------ */

.laziness-column {
    width: 42%;
    min-width: 320px;
    max-width: 560px;
    margin-left: 0;
    display: flex;
    flex-direction: column;
    gap: 2.2rem;
}

.lazy-paragraph {
    font-family: "Source Serif 4", serif;
    font-size: clamp(1.05rem, 1.35vw, 1.3rem);
    line-height: 1.75;
    color: var(--body-ink);
    opacity: 0;
    transform: translateY(8px);
    transition:
        opacity 1.2s var(--ease-stone),
        transform 1.2s var(--ease-stone);
}

.lazy-paragraph.is-evaluated {
    opacity: 1;
    transform: translateY(0);
}

.lazy-paragraph.is-forgotten {
    opacity: 0.3;
}

.lazy-code {
    background: var(--marble-pale);
    padding: 1rem 1.25rem;
    border-left: 3px solid var(--gold-amber);
    line-height: 1.85;
}

.lazy-code .code-mono {
    background: transparent;
    border: none;
    padding: 0;
    font-size: 1em;
}

/* ------------------------------------------------------------------
   CHAMBER V — COMPOSITION
   ------------------------------------------------------------------ */

.chamber-v {
    align-items: center;
    text-align: center;
    justify-content: flex-start;
    padding-bottom: 0;
}

.composition-stage {
    position: relative;
    width: 100%;
    max-width: 1200px;
    margin: 2rem auto 0;
    min-height: 340px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(1rem, 3vw, 3rem);
}

.comp-block {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: clamp(140px, 18vw, 200px);
    height: clamp(140px, 18vw, 200px);
    border: 1.5px solid var(--gold-amber);
    outline: 1px solid var(--marble-vein);
    outline-offset: 5px;
    background:
        radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.7), transparent 60%),
        linear-gradient(135deg, var(--marble-white), var(--marble-pale));
    box-shadow:
        inset 1px 1px 0 rgba(255, 255, 255, 0.7),
        inset -1px -1px 3px rgba(26, 23, 20, 0.1),
        4px 4px 0 rgba(26, 23, 20, 0.06);
    transition: transform 1.4s var(--ease-stone), opacity 1.2s var(--ease-stone);
    will-change: transform;
}

.comp-left  { transform: translateX(calc(-1 * (50vw - 50% - 100px))); }
.comp-right { transform: translateX(calc(50vw - 50% - 100px)); }

.is-composed .comp-left  { transform: translateX(-24px); }
.is-composed .comp-right { transform: translateX(24px); }

.comp-glyph {
    font-family: "Cormorant Garamond", serif;
    font-style: italic;
    font-size: 4rem;
    font-weight: 300;
    color: var(--cranberry);
    line-height: 1;
}

.comp-caption {
    font-family: "Source Serif 4", serif;
    font-style: italic;
    font-size: 0.8rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--body-ink);
    opacity: 0.8;
}

.comp-operator {
    font-family: "Cormorant Garamond", serif;
    font-weight: 700;
    font-size: 3rem;
    color: var(--gold-amber);
    opacity: 0;
    transition: opacity 0.8s var(--ease-stone);
    transition-delay: 1.1s;
}

.is-composed .comp-operator { opacity: 1; }

.comp-merged {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    opacity: 0;
    transform: scale(0.92);
    transition: opacity 1.2s var(--ease-stone), transform 1.2s var(--ease-stone);
    transition-delay: 1.2s;
    pointer-events: none;
}

.is-composed .comp-merged {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

.comp-merged-sig {
    padding: 0.8rem 1.6rem;
    background: var(--marble-pale);
    border: 1px solid var(--gold-amber);
    box-shadow: 4px 4px 0 rgba(26, 23, 20, 0.06);
}

.comp-merged-sig .code-mono {
    background: transparent;
    border: none;
    padding: 0;
    font-size: clamp(1rem, 1.4vw, 1.25rem);
}

.comp-closing {
    font-family: "Cormorant Garamond", serif;
    font-style: italic;
    font-weight: 300;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    letter-spacing: 0.05em;
    text-transform: none;
    color: var(--obsidian);
    max-width: 24ch;
    line-height: 1.3;
    text-shadow:
        1px 1px 0 #ede6d8,
        2px 2px 1px rgba(26, 23, 20, 0.1),
        -1px -1px 0 rgba(255, 255, 255, 0.4);
}

.gold-flourish {
    width: 100%;
    height: 2px;
    margin-top: 3rem;
    background: linear-gradient(90deg,
        transparent 0%,
        var(--gold-amber) 15%,
        var(--gold-amber) 85%,
        transparent 100%);
    box-shadow: 0 1px 2px rgba(139, 122, 58, 0.4);
    transform: scaleX(0);
    transform-origin: center;
    transition: transform 1.6s var(--ease-stone);
    transition-delay: 1.8s;
}

.is-composed .gold-flourish { transform: scaleX(1); }

/* ------------------------------------------------------------------
   COLOPHON
   ------------------------------------------------------------------ */

.colophon {
    width: 100%;
    padding: clamp(3rem, 8vh, 5rem) clamp(1.25rem, 5vw, 4rem) clamp(3rem, 6vh, 4rem);
    margin-top: 3rem;
    text-align: center;
    background:
        radial-gradient(ellipse at 50% 0%, rgba(200, 191, 176, 0.4), transparent 70%),
        linear-gradient(180deg, rgba(237, 230, 216, 0.5), var(--marble-white));
    border-top: 1px solid rgba(200, 191, 176, 0.7);
}

.colophon-inner {
    max-width: 60ch;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.colophon-glyph {
    font-family: "Cormorant Garamond", serif;
    font-weight: 300;
    font-size: 4rem;
    color: var(--gold-amber);
    line-height: 1;
}

.colophon-text {
    font-family: "Source Serif 4", serif;
    font-style: italic;
    font-size: 1.05rem;
    line-height: 1.65;
    color: var(--body-ink);
}

.colophon-meta {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-family: "Cormorant Garamond", serif;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    font-size: 0.78rem;
    color: var(--cranberry);
}

.colophon-meta .dot { opacity: 0.5; }

/* ------------------------------------------------------------------
   RESPONSIVE
   ------------------------------------------------------------------ */

@media (max-width: 960px) {
    .stem-nav {
        width: 3.25rem;
        gap: 0.6rem;
    }
    .medallion {
        width: 40px;
        height: 40px;
    }
    .medallion .numeral { font-size: 1rem; }
    .medallion .medallion-label { display: none; }
    .inline-medallion { width: 52px; height: 52px; }
    .inline-medallion .numeral { font-size: 1.3rem; }

    .chamber {
        padding-left: 4.5rem;
        padding-right: 1.25rem;
    }
    .purity-grid,
    .shelf-top { grid-template-columns: 1fr; }

    .shelf-middle { width: 100%; }

    .chamber-panel,
    .tilted-panel { transform: perspective(800px) rotateY(-4deg); }

    .monads-chandelier { grid-template-columns: repeat(3, 1fr); }

    .laziness-column { width: 100%; min-width: 0; }

    .type-tree { height: 320px; }

    .comp-left  { transform: translateX(-120%); }
    .comp-right { transform: translateX(120%); }

    .monads-title { font-size: clamp(3rem, 12vw, 6rem); flex-wrap: nowrap; }
}

@media (max-width: 600px) {
    .chamber { padding-left: 4rem; padding-right: 1rem; }
    .chamber-header { flex-direction: column; align-items: flex-start; gap: 0.8rem; }
    .chamber-header.center { align-items: center; }
    .monads-chandelier { grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
    .monad-thread { display: none; }
    .type-tree { height: 260px; }
    .tree-node { width: 44px; height: 44px; }
    .tree-node.node-root { width: 56px; height: 56px; }
    .tree-node.leaf { width: 36px; height: 36px; }
    .node-type { font-size: 0.9rem; }
    .composition-stage { min-height: 280px; flex-wrap: wrap; }
}

/* reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001s !important;
        transition-duration: 0.001s !important;
    }
}
