/* =============================================================
   layer-2.wiki — molten encyclopedia / blobitecture × marble-classical
   palette: #E8DFD2 #9A8E7E #3E4E6B #F4EFE6 #0E1116 #13161B #B8553A #5C7A6E
   typefaces: Major Mono Display / JetBrains Mono / Spectral / IBM Plex Sans Condensed
   ============================================================= */

:root {
    --ink: #0E1116;
    --volcanic: #13161B;
    --parchment: #E8DFD2;
    --bone: #F4EFE6;
    --vein: #9A8E7E;
    --sienna: #B8553A;
    --verdigris: #5C7A6E;
    --ultramarine: #3E4E6B;

    /* eight blob radii — driven by JS rAF */
    --r1: 47%;
    --r2: 53%;
    --r3: 68%;
    --r4: 32%;
    --r5: 41%;
    --r6: 67%;
    --r7: 33%;
    --r8: 59%;

    --scroll: 0;
    --slump: 0;

    --gutter-w: 24px;
}

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

html { scroll-behavior: smooth; }

body {
    font-family: 'Spectral', Georgia, serif;
    font-weight: 300;
    background: var(--parchment);
    color: var(--ink);
    line-height: 1.55;
    overflow-x: hidden;
    font-feature-settings: "onum" 1, "smcp" 0;
}

/* small caps for the technical acronyms */
.cite, dt, .mast-item, .commit-msg, .niche-content .plates {
    font-variant-numeric: oldstyle-nums;
}

a { color: inherit; text-decoration: none; border-bottom: 1px dotted currentColor; }

/* =================== TRIPTYCH NAV =================== */
.triptych {
    position: fixed;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.tri-plate {
    width: 56px;
    height: 38px;
    background: var(--bone);
    border: 1px solid var(--vein);
    color: var(--ink);
    font-family: 'Major Mono Display', monospace;
    font-size: 9px;
    letter-spacing: 0.1em;
    display: flex; align-items: center; justify-content: center;
    border-radius: 38% 62% 55% 45% / 50% 45% 55% 50%;
    transition: transform 0.4s ease, background 0.4s ease;
    text-decoration: none;
}
.tri-plate:hover { transform: rotate(-1.2deg); background: var(--parchment); }
.tri-center { background: var(--ink); color: var(--bone); font-size: 8px; }

/* =================== GUTTER RIVER =================== */
.gutter-river {
    position: fixed;
    left: 50%;
    top: 0;
    transform: translateX(-50%);
    width: var(--gutter-w);
    height: 100vh;
    z-index: 5;
    pointer-events: none;
    opacity: 0.55;
    overflow: hidden;
}
.gutter-svg {
    width: 100%;
    height: 480vh;
    transform: translateY(calc(var(--scroll) * -0.92 * 1px));
}

/* =================== SPREAD BASE =================== */
.spread {
    position: relative;
    padding: 60px clamp(20px, 5vw, 80px);
    width: 100%;
    overflow: hidden;
}
.dark-spread {
    background: var(--volcanic);
    color: var(--bone);
}
.light-spread {
    background: var(--parchment);
    color: var(--ink);
}

.spread-header {
    margin-bottom: 40px;
    border-bottom: 0.5px solid var(--vein);
    padding-bottom: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: baseline;
}
.spread-num {
    font-family: 'Major Mono Display', monospace;
    font-size: clamp(1.6rem, 4vw, 2.6rem);
    color: var(--sienna);
    letter-spacing: 0.04em;
}
.spread-title {
    font-family: 'Major Mono Display', monospace;
    font-size: clamp(1.4rem, 4vw, 3.6rem);
    letter-spacing: 0.04em;
    font-weight: 400;
    line-height: 1.05;
}
.spread-stand {
    font-family: 'Spectral', serif;
    font-style: italic;
    font-size: 1.05rem;
    color: var(--vein);
    flex-basis: 100%;
}
.byline {
    flex-basis: 100%;
    font-family: 'IBM Plex Sans Condensed', sans-serif;
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--vein);
}

/* =================== SPREAD 1 — COVER =================== */
.spread-cover {
    min-height: 110vh;
    display: flex;
    flex-direction: column;
    padding: 24px clamp(20px, 6vw, 100px) 60px;
}

.masthead-ribbon {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    border-top: 1px solid var(--bone);
    border-bottom: 1px solid var(--bone);
    padding: 10px 4px;
    font-family: 'Major Mono Display', monospace;
    font-size: 11px;
    letter-spacing: 0.12em;
    color: var(--bone);
    margin-bottom: clamp(20px, 6vh, 70px);
}
.mast-sep { opacity: 0.5; }

.cover-grid {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 0.85fr;
    gap: 60px;
    align-items: center;
    position: relative;
}

.cover-headline {
    font-family: 'Major Mono Display', monospace;
    font-weight: 400;
    line-height: 0.92;
    letter-spacing: 0.04em;
    color: var(--bone);
}
.cover-headline .line {
    display: block;
}
.cover-headline .line:first-child {
    font-size: clamp(3.2rem, 13vw, 13rem);
}
.cover-headline .line:nth-child(2) {
    font-size: clamp(3.2rem, 13vw, 13rem);
    color: var(--sienna);
}
.cover-headline .subline {
    font-size: clamp(0.9rem, 1.8vw, 1.6rem);
    margin-top: 30px;
    letter-spacing: 0.18em;
    color: var(--vein);
}
.cover-headline .subline2 {
    font-size: clamp(1.0rem, 2.4vw, 2.2rem);
    color: var(--bone);
    letter-spacing: 0.08em;
    margin-top: 6px;
}

.bust-cover {
    width: 100%;
    max-width: 420px;
    justify-self: center;
    align-self: center;
}
.bust-svg { width: 100%; height: auto; display: block; }

#bustCranium {
    transform-origin: 210px 230px;
    transition: d 0.3s ease;
}

.fingerprint {
    position: absolute;
    bottom: 10px;
    right: 10px;
    width: 60px;
    text-align: center;
}
.fingerprint svg { width: 40px; height: 40px; }
.fp-caption {
    display: block;
    font-family: 'IBM Plex Sans Condensed', sans-serif;
    font-size: 9px;
    letter-spacing: 0.16em;
    color: var(--bone);
    opacity: 0.6;
    text-transform: uppercase;
}

/* =================== SPREAD 2 — EDITORIAL =================== */
.spread-editorial {
    min-height: 140vh;
}
.spread-body.two-page {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: calc(var(--gutter-w) + 40px);
    position: relative;
}

.page {
    position: relative;
}

.four-col {
    column-count: 2;
    column-gap: 28px;
    column-rule: 0.5px solid var(--vein);
}
.four-col p {
    font-family: 'Spectral', serif;
    font-size: 11pt;
    line-height: 1.65;
    text-align: justify;
    hyphens: auto;
    margin-bottom: 1em;
    text-indent: 1.2em;
}
.four-col .lead { text-indent: 0; }
.four-col .lead {
    break-after: column;
}

.dropcap {
    font-family: 'Major Mono Display', monospace;
    font-size: 4.6rem;
    line-height: 0.9;
    color: var(--sienna);
    float: left;
    padding: 0 10px 0 0;
    margin-top: 4px;
}
.cite {
    font-family: 'IBM Plex Sans Condensed', sans-serif;
    font-size: 9px;
    color: var(--sienna);
    letter-spacing: 0.06em;
    vertical-align: super;
    padding: 0 2px;
    text-transform: uppercase;
}

.footnote-marg {
    font-family: 'IBM Plex Sans Condensed', sans-serif;
    font-size: 10.5px;
    line-height: 1.35;
    color: var(--vein);
    text-align: left !important;
    text-indent: 0 !important;
    border-left: 0.5px solid var(--vein);
    padding-left: 8px;
    margin-top: 0.6em;
    break-inside: avoid;
}
.ftn-mark { color: var(--sienna); margin-right: 4px; font-weight: 700; }

/* diagram blob */
.diagram-page {
    display: flex;
    align-items: center;
    justify-content: center;
}
.blob {
    border-radius: var(--r1) var(--r2) var(--r3) var(--r4) / var(--r5) var(--r6) var(--r7) var(--r8);
    background: var(--bone);
    padding: 32px;
    position: relative;
    transition: border-radius 0.05s linear;
    border: 0.5px solid var(--vein);
}
.blob-diagram {
    width: 100%;
    aspect-ratio: 6 / 7;
    background: var(--bone);
    display: flex;
    align-items: center;
    justify-content: center;
}
.diagram-svg { width: 100%; height: auto; }
.diagram-label {
    font-family: 'Major Mono Display', monospace;
    font-size: 10px;
    fill: var(--bone);
    letter-spacing: 0.1em;
}
.diagram-binom {
    font-family: 'JetBrains Mono', monospace;
    font-style: italic;
    font-size: 9px;
    fill: var(--ink);
    text-anchor: middle;
}

.l2-organism {
    transform-origin: center;
    animation: breathe 6.4s ease-in-out infinite;
}
.l2-organism#org2 { animation-duration: 7.1s; animation-delay: -2s; }
.l2-organism#org3 { animation-duration: 8.3s; animation-delay: -4s; }

@keyframes breathe {
    0%, 100% { transform: scale(1.0); }
    50% { transform: scale(1.012); }
}

/* pull quote breaching the gutter */
.pull-quote {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    font-size: clamp(1.3rem, 4vw, 3.2rem);
    line-height: 1.1;
    letter-spacing: -0.01em;
    color: var(--ink);
    background: var(--parchment);
    padding: 28px clamp(20px, 4vw, 50px);
    max-width: 70%;
    text-align: center;
    border-top: 0.5px solid var(--vein);
    border-bottom: 0.5px solid var(--vein);
    z-index: 6;
}
.pull-gutter {
    bottom: 8%;
}
.pull-quote cite {
    display: block;
    margin-top: 10px;
    font-family: 'IBM Plex Sans Condensed', sans-serif;
    font-size: 10px;
    font-style: normal;
    font-weight: 300;
    letter-spacing: 0.15em;
    color: var(--vein);
    text-transform: uppercase;
}

/* =================== SPREAD 3 — BESTIARY =================== */
.spread-bestiary {
    min-height: 220vh;
}
.bestiary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 50px clamp(40px, 5vw, 80px);
    align-items: start;
}
.specimen {
    padding: 28px;
    background: var(--bone);
    position: relative;
}
.specimen:nth-child(odd) {
    transform: translateY(20px);
}
.specimen:nth-child(3n) {
    transform: translateY(-30px) rotate(-0.6deg);
}
.specimen:nth-child(5n) {
    transform: translateY(40px) rotate(0.4deg);
}
.spec-figure {
    width: 100%;
    aspect-ratio: 10/9;
    background: transparent;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.spec-figure svg { width: 100%; height: 100%; }
.spec-binom {
    font-family: 'JetBrains Mono', monospace;
    font-style: italic;
    font-weight: 400;
    font-size: 1.1rem;
    color: var(--ink);
    margin-bottom: 8px;
    letter-spacing: -0.005em;
}
.spec-meta {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 12px;
    font-family: 'IBM Plex Sans Condensed', sans-serif;
    font-size: 10.5px;
    color: var(--vein);
    margin-bottom: 12px;
    border-top: 0.5px solid var(--vein);
    border-bottom: 0.5px solid var(--vein);
    padding: 8px 0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.spec-meta dt { font-weight: 400; }
.spec-meta dd { color: var(--ink); }
.spec-desc {
    font-family: 'Spectral', serif;
    font-size: 10.5pt;
    line-height: 1.6;
    margin-bottom: 14px;
    text-align: justify;
    hyphens: auto;
}
.spec-flow {
    border-top: 0.5px dashed var(--vein);
    padding-top: 10px;
}
.spec-flow svg { width: 100%; height: 30px; }

.specimen.extinct {
    background: var(--parchment);
    border: 1px dashed var(--ultramarine);
}
.specimen.extinct .spec-binom { color: var(--ultramarine); }
.specimen.extinct .spec-desc { color: var(--ultramarine); }
.specimen.extinct .spec-meta { border-color: var(--ultramarine); color: var(--ultramarine); }
.specimen.extinct .spec-meta dd { color: var(--ultramarine); }

/* =================== SPREAD 4 — LONG READ =================== */
.spread-longread {
    min-height: 260vh;
    background: var(--volcanic);
    color: var(--bone);
}
.spread-longread .spread-num { color: var(--sienna); }
.spread-longread .spread-title { color: var(--bone); }
.spread-longread .spread-stand { color: var(--vein); }
.spread-longread .byline { color: var(--vein); }

.longread-body.three-col {
    column-count: 3;
    column-gap: 36px;
    column-rule: 0.5px solid var(--vein);
    font-family: 'Spectral', serif;
    font-size: 11pt;
    line-height: 1.7;
    text-align: justify;
    hyphens: auto;
}
.longread-body p { margin-bottom: 1em; text-indent: 1.2em; }
.longread-body .lead { text-indent: 0; }
.longread-body .dropcap { color: var(--sienna); }

.dropcap-draw {
    /* the drawn drop-cap — outline only until it gets the .drawn class */
    font-family: 'Major Mono Display', monospace;
    font-size: 5.4rem;
    line-height: 0.9;
    color: transparent;
    -webkit-text-stroke: 1px var(--sienna);
    float: left;
    padding: 0 12px 0 0;
    margin-top: 4px;
    transition: color 1.4s ease, -webkit-text-stroke-color 1.4s ease;
}
.dropcap-draw.drawn {
    color: var(--sienna);
    -webkit-text-stroke: 1px transparent;
}

.spread-longread .cite { color: var(--sienna); }
.spread-longread .footnote-marg { color: var(--vein); border-color: var(--vein); }

.blob-aside {
    background: var(--ink);
    border: 0.5px solid var(--vein);
    color: var(--bone);
    padding: 22px;
    break-inside: avoid;
    margin-bottom: 1.4em;
    font-family: 'IBM Plex Sans Condensed', sans-serif;
}
.blob-aside h4 {
    font-family: 'Major Mono Display', monospace;
    font-size: 12px;
    letter-spacing: 0.12em;
    color: var(--sienna);
    margin-bottom: 12px;
    text-transform: uppercase;
}
.key-terms {
    font-size: 10.5px;
    line-height: 1.45;
}
.key-terms dt {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    color: var(--bone);
    margin-top: 8px;
    font-size: 10px;
    letter-spacing: 0.04em;
}
.key-terms dd {
    color: var(--vein);
    margin-bottom: 6px;
}

.pull-inline {
    position: static;
    transform: none;
    background: transparent;
    color: var(--bone);
    border-color: var(--vein);
    text-align: left;
    max-width: 100%;
    column-span: all;
    margin: 1.5em 0;
    padding: 22px 0;
    font-size: clamp(1.4rem, 3.4vw, 2.6rem);
}
.pull-inline cite { color: var(--vein); }

/* =================== SPREAD 5 — FOLDOUT =================== */
.spread-foldout {
    min-height: 180vh;
    overflow: hidden;
}
.foldout-caption {
    font-family: 'Major Mono Display', monospace !important;
    font-style: normal !important;
    color: var(--sienna) !important;
    letter-spacing: 0.1em !important;
    font-size: 11px !important;
}
.foldout-rail {
    overflow-x: auto;
    overflow-y: hidden;
    width: 100%;
    padding: 30px 0 60px;
    -webkit-overflow-scrolling: touch;
    cursor: grab;
}
.foldout-rail::-webkit-scrollbar { height: 12px; }
.foldout-rail::-webkit-scrollbar-track { background: var(--parchment); border-top: 0.5px solid var(--vein); }
.foldout-rail::-webkit-scrollbar-thumb { background: var(--vein); border-radius: 6px; }

.foldout-rail.dragging { cursor: grabbing; }

.foldout-inner {
    width: 240vw;
    min-width: 2400px;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 40px;
    padding: 0 60px;
    position: relative;
    align-items: stretch;
}
.frieze {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 60px;
    opacity: 0.4;
}

.aedicula {
    position: relative;
    padding-top: 60px;
}
.niche-svg {
    width: 100%;
    height: auto;
    display: block;
    filter: drop-shadow(0 6px 20px rgba(14,17,22,0.08));
}
.niche-content {
    position: absolute;
    top: 110px;
    left: 14%;
    right: 14%;
    bottom: 30px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow: hidden;
}
.niche-name {
    font-family: 'JetBrains Mono', monospace;
    font-style: italic;
    font-size: 0.95rem;
    color: var(--ink);
    text-align: center;
    border-bottom: 0.5px solid var(--vein);
    padding-bottom: 8px;
}
.plates {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.plate {
    background: var(--parchment);
    border: 0.5px solid var(--vein);
    padding: 5px 8px;
    font-family: 'Major Mono Display', monospace;
    font-size: 8.5px;
    letter-spacing: 0.06em;
    color: var(--ink);
    border-radius: 38% 62% 50% 50% / 50% 50% 55% 45%;
    text-align: center;
    transition: transform 0.18s ease;
    transform-style: preserve-3d;
    will-change: transform;
}
.plate::before {
    content: attr(data-attr);
    display: block;
    font-size: 7px;
    letter-spacing: 0.1em;
    color: var(--vein);
    text-transform: uppercase;
    margin-bottom: 2px;
}
.aedicula.extinct-niche .niche-name { color: var(--ultramarine); }
.aedicula.extinct-niche .plate { color: var(--ultramarine); border-color: var(--ultramarine); }
.aedicula.extinct-niche .plate::before { color: var(--ultramarine); }

/* =================== SPREAD 6 — COLOPHON =================== */
.spread-colophon {
    min-height: 90vh;
}
.colophon-grid {
    display: grid;
    grid-template-columns: 1fr 1.4fr 1fr;
    gap: 40px clamp(30px, 4vw, 70px);
    align-items: start;
}

.colophon-mark {
    background: var(--bone);
    padding: 24px;
    text-align: center;
}
.colophon-mark svg { width: 100%; height: auto; max-width: 240px; }
.mark-caption {
    font-family: 'IBM Plex Sans Condensed', sans-serif;
    font-style: italic;
    font-size: 11px;
    color: var(--vein);
    margin-top: 10px;
    letter-spacing: 0.04em;
}

.colophon-text { padding: 0 10px; }
.col-section-title {
    font-family: 'Major Mono Display', monospace;
    font-size: 12px;
    letter-spacing: 0.12em;
    color: var(--sienna);
    margin-bottom: 8px;
    margin-top: 18px;
}
.colophon-text p {
    font-family: 'Spectral', serif;
    font-size: 11pt;
    line-height: 1.6;
    margin-bottom: 12px;
    color: var(--ink);
}
.closing {
    font-style: italic;
    color: var(--vein) !important;
    border-top: 0.5px solid var(--vein);
    padding-top: 14px;
    margin-top: 20px !important;
}
.micro-links {
    font-family: 'IBM Plex Sans Condensed', sans-serif;
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--vein) !important;
}
.micro-links a { border-bottom: 0.5px dotted var(--vein); }

.changelog {
    border-left: 0.5px solid var(--vein);
    padding-left: 22px;
}
.commit-list {
    list-style: none;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: var(--ink);
    counter-reset: commit;
}
.commit-list li {
    display: grid;
    grid-template-columns: 16px 70px 1fr;
    gap: 6px;
    align-items: center;
    padding: 8px 0;
    border-bottom: 0.5px dashed var(--vein);
}
.pebble-glyph {
    display: inline-block;
    width: 12px;
    height: 10px;
    background: var(--vein);
    border-radius: 47% 53% 68% 32% / 41% 67% 33% 59%;
}
.commit-list li:nth-child(odd) .pebble-glyph { background: var(--ink); border-radius: 38% 62% 55% 45% / 50% 45% 55% 50%; }
.commit-list li:nth-child(3n) .pebble-glyph { background: var(--verdigris); border-radius: 60% 40% 60% 40% / 40% 60% 40% 60%; }
.sha {
    color: var(--sienna);
    font-weight: 700;
    letter-spacing: 0.02em;
}
.commit-msg {
    color: var(--vein);
    font-size: 9.5px;
    line-height: 1.3;
}

/* =================== MOBILE =================== */
@media (max-width: 880px) {
    :root { --gutter-w: 12px; }

    .triptych {
        flex-direction: row;
        top: auto;
        bottom: 8px;
        left: 50%;
        transform: translateX(-50%);
    }

    .gutter-river {
        width: 100%;
        height: 12px;
        top: auto;
        position: absolute;
    }

    .cover-grid {
        grid-template-columns: 1fr;
        gap: 30px;
    }
    .cover-headline { text-align: left; }

    .spread-body.two-page,
    .colophon-grid {
        grid-template-columns: 1fr;
    }
    .four-col, .longread-body.three-col {
        column-count: 1;
    }
    .pull-quote { font-size: 1.4rem; max-width: 90%; padding: 16px; }
    .pull-inline { font-size: 1.3rem; }

    .changelog {
        border-left: none;
        border-top: 0.5px solid var(--vein);
        padding-left: 0;
        padding-top: 20px;
    }

    .cover-headline .line:first-child,
    .cover-headline .line:nth-child(2) {
        font-size: clamp(2.6rem, 14vw, 5rem);
    }

    .specimen:nth-child(odd),
    .specimen:nth-child(3n),
    .specimen:nth-child(5n) {
        transform: none;
    }
}

/* prevent scroll bleed */
.spread > .blob,
.spread > * { will-change: border-radius; }
