/* ==========================================================================
   tanso.wiki — Monochrome Grimoire of Carbon
   ========================================================================== */

:root {
    --void: #0A0A0A;
    --parchment-dark: #141414;
    --ink-1A: #1A1A1A;
    --ink-medium: #2A2A2A;
    --ink-3A: #3A3A3A;
    --ash: #4A4A4A;
    --graphite: #6E6E6E;
    --silver-fog: #9A9A9A;
    --pewter: #B0B0B0;
    --moonlight: #C8C8C8;
    --frost: #E8E8E8;
    --parchment-light: #F2F0EB;

    --font-display: "Cormorant Garamond", "EB Garamond", Georgia, serif;
    --font-hand: "Caveat", "Comic Sans MS", cursive;
    --font-body: "EB Garamond", "Cormorant Garamond", Georgia, serif;
    --font-mono: "IM Fell DW Pica", "Courier New", monospace;
}

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

html, body {
    background: var(--void);
    color: var(--moonlight);
    font-family: var(--font-body);
    overflow-x: hidden;
}

body {
    min-height: 100vh;
    line-height: 1.72;
    letter-spacing: 0.005em;
    position: relative;
}

/* Subtle grain texture across whole body */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    background-image:
        repeating-linear-gradient(45deg, rgba(42, 42, 42, 0.06) 0 1px, transparent 1px 9px),
        repeating-linear-gradient(135deg, rgba(42, 42, 42, 0.05) 0 1px, transparent 1px 11px);
    opacity: 0.4;
    mix-blend-mode: screen;
}

/* ==========================================================================
   Spine SVG — full page vertical line
   ========================================================================== */
.spine-svg {
    position: absolute;
    top: 0;
    left: 28%;
    width: 6px;
    height: 100%;
    pointer-events: none;
    z-index: 2;
    overflow: visible;
}

#spinePath {
    stroke-dasharray: 1;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 0.4s linear;
}

/* ==========================================================================
   Mist Layers
   ========================================================================== */
.mist {
    position: fixed;
    left: -10%;
    width: 120%;
    height: 30vh;
    pointer-events: none;
    z-index: 3;
    opacity: 0.3;
    background: linear-gradient(
        to bottom,
        transparent 0%,
        rgba(10, 10, 10, 0.7) 50%,
        transparent 100%
    );
    mix-blend-mode: normal;
    will-change: transform, opacity;
}

.mist-1 {
    top: 5vh;
    animation: mist-drift 20s ease-in-out infinite;
}

.mist-2 {
    top: 50vh;
    animation: mist-drift 26s ease-in-out infinite reverse;
    animation-delay: -7s;
    opacity: 0.22;
}

.mist-3 {
    top: 80vh;
    animation: mist-drift 32s ease-in-out infinite;
    animation-delay: -14s;
    opacity: 0.28;
    height: 40vh;
}

@keyframes mist-drift {
    0%   { transform: translateY(-30px) translateX(-20px); opacity: 0.18; }
    25%  { transform: translateY(20px)  translateX(10px);  opacity: 0.34; }
    50%  { transform: translateY(50px)  translateX(-10px); opacity: 0.28; }
    75%  { transform: translateY(10px)  translateX(20px);  opacity: 0.32; }
    100% { transform: translateY(-30px) translateX(-20px); opacity: 0.18; }
}

body.illuminated-active .mist {
    opacity: 0.55;
    transition: opacity 1s ease;
}

/* ==========================================================================
   Ink Blot Navigation
   ========================================================================== */
.ink-blot {
    position: fixed;
    top: 28px;
    right: 32px;
    width: 46px;
    height: 46px;
    background: transparent;
    border: none;
    cursor: pointer;
    z-index: 100;
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ink-blot-inner {
    display: block;
    width: 100%;
    height: 100%;
    background: var(--ink-medium);
    border-radius: 48% 52% 56% 44% / 50% 46% 54% 50%;
    box-shadow:
        0 0 12px rgba(10, 10, 10, 0.8),
        inset -3px -4px 8px rgba(10, 10, 10, 0.5),
        inset 3px 3px 6px rgba(110, 110, 110, 0.15);
    position: relative;
    transition: background 0.4s ease, border-radius 0.6s ease;
}

.ink-blot-inner::after {
    content: "";
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 60% 40% 50% 50%;
    background: var(--ink-medium);
    top: -3px;
    left: 12px;
    box-shadow: 22px 32px 0 -1px var(--ink-medium);
}

.ink-blot:hover {
    transform: scale(1.15) rotate(-6deg);
}
.ink-blot:hover .ink-blot-inner {
    background: var(--ink-3A);
    border-radius: 52% 48% 44% 56% / 46% 54% 50% 50%;
}

/* ==========================================================================
   Table of Contents Panel
   ========================================================================== */
.toc-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: min(420px, 90vw);
    height: 100vh;
    background: linear-gradient(180deg, #161616 0%, #101010 100%);
    border-left: 1px solid var(--ink-3A);
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.7);
    transform: translateX(105%);
    transition: transform 0.4s ease-out;
    z-index: 90;
    padding: 80px 44px 40px;
    overflow-y: auto;
}

.toc-panel.open {
    transform: translateX(0);
}

.toc-inner::before {
    content: "";
    display: block;
    width: 60%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--ash), transparent);
    margin-bottom: 24px;
}

.toc-heading {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 2.4rem;
    color: var(--frost);
    letter-spacing: 0.04em;
    line-height: 1.05;
}

.toc-subheading {
    font-family: var(--font-hand);
    font-size: 1.1rem;
    color: var(--silver-fog);
    margin-bottom: 32px;
    transform: rotate(-1deg);
    transform-origin: left;
}

.toc-list {
    list-style: none;
}

.toc-item {
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.toc-panel.open .toc-item {
    opacity: 1;
    transform: translateX(0);
}

.toc-link {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 10px 0;
    color: var(--moonlight);
    text-decoration: none;
    font-family: var(--font-body);
    font-size: 1.05rem;
    border-bottom: 1px dotted var(--ink-3A);
    transition: color 0.3s ease;
}

.toc-link:hover {
    color: var(--frost);
}

.toc-num {
    font-family: var(--font-mono);
    color: var(--silver-fog);
    font-size: 0.85rem;
    width: 36px;
    flex-shrink: 0;
    letter-spacing: 0.06em;
}

.toc-title {
    font-family: var(--font-display);
    font-style: italic;
    font-size: 1.15rem;
}

.toc-leader {
    flex: 1;
    border-bottom: 1px dotted var(--ash);
    margin: 0 6px 4px;
    align-self: flex-end;
    height: 1px;
}

.toc-page {
    font-family: var(--font-mono);
    color: var(--silver-fog);
    font-size: 0.85rem;
    flex-shrink: 0;
}

.toc-scrim {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 10, 0.6);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
    z-index: 80;
}
.toc-scrim.active {
    opacity: 1;
    pointer-events: auto;
}

/* ==========================================================================
   Grimoire Container
   ========================================================================== */
.grimoire {
    position: relative;
    z-index: 4;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0;
}

/* ==========================================================================
   Opening Sequence
   ========================================================================== */
.opening {
    position: relative;
    height: 100vh;
    min-height: 720px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    padding-left: calc(28% + 60px);
    padding-right: 5vw;
    overflow: hidden;
}

.opening-spine {
    position: absolute;
    top: 0;
    left: 28%;
    width: 6px;
    height: 100%;
    overflow: visible;
}

#openingSpinePath {
    stroke-dasharray: 1200;
    stroke-dashoffset: 1200;
    animation: draw-opening-spine 2s ease-out forwards;
    animation-delay: 0.3s;
}

@keyframes draw-opening-spine {
    to { stroke-dashoffset: 0; }
}

.opening-title-block {
    position: relative;
    opacity: 0;
    animation: fade-title 0.8s ease-out forwards;
    animation-delay: 2.2s;
}

@keyframes fade-title {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}

.site-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(4rem, 10vw, 8rem);
    color: var(--frost);
    letter-spacing: 0.05em;
    line-height: 1;
}

.site-sub {
    display: inline-block;
    font-family: var(--font-hand);
    font-size: 2rem;
    color: var(--silver-fog);
    transform: rotate(1.5deg) translateX(-12px);
    margin-top: -8px;
}

.moth {
    position: absolute;
    top: -20px;
    right: -90px;
    width: 70px;
    height: 60px;
    opacity: 0;
    animation:
        moth-fade-in 1s ease-out forwards,
        moth-flutter 4s ease-in-out infinite;
    animation-delay: 3s, 4s;
}

@keyframes moth-fade-in {
    from { opacity: 0; transform: translate(20px, -10px); }
    to   { opacity: 0.85; transform: translate(0, 0); }
}

@keyframes moth-flutter {
    0%   { transform: translate(0, 0) rotate(-4deg); }
    25%  { transform: translate(8px, -6px) rotate(2deg); }
    50%  { transform: translate(-4px, 4px) rotate(-2deg); }
    75%  { transform: translate(6px, 2px) rotate(3deg); }
    100% { transform: translate(0, 0) rotate(-4deg); }
}

.opening-meta {
    margin-top: 56px;
    opacity: 0;
    animation: fade-title 1s ease-out forwards;
    animation-delay: 3.2s;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.meta-line {
    font-family: var(--font-mono);
    font-size: 0.92rem;
    color: var(--silver-fog);
    letter-spacing: 0.06em;
}
.meta-line:last-child {
    font-family: var(--font-hand);
    font-size: 1.05rem;
    color: var(--graphite);
    transform: rotate(-0.6deg);
    transform-origin: left;
    margin-top: 4px;
}

.opening-fade {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 80px;
    background: linear-gradient(to bottom, transparent, var(--void));
    pointer-events: none;
}

/* ==========================================================================
   Chapter / Node Layout
   ========================================================================== */
.chapter {
    position: relative;
    min-height: 90vh;
    display: flex;
    align-items: center;
    padding: 80px 0;
    width: 100%;
}

.chapter-left {
    justify-content: flex-start;
    padding-left: 5vw;
}

.chapter-right {
    justify-content: flex-end;
    padding-right: 5vw;
}

.chapter-illuminated {
    justify-content: flex-end;
    padding-right: 5vw;
}

/* Branch lines connecting spine to nodes */
.branch {
    position: absolute;
    top: 50%;
    width: clamp(120px, 14vw, 220px);
    height: 60px;
    transform: translateY(-50%);
    pointer-events: none;
}

.branch-right {
    left: calc(28% + 6px);
}

.branch-left {
    right: calc(72% + 6px);
}

.branch svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.branch path {
    stroke-dasharray: 600;
    stroke-dashoffset: 600;
    transition: stroke-dashoffset 0.8s ease-out;
}

.chapter.in-focus .branch path {
    stroke-dashoffset: 0;
}

/* Node card */
.node {
    position: relative;
    width: min(520px, 42vw);
    background: var(--parchment-dark);
    padding: 48px 44px 56px;
    color: var(--moonlight);
    clip-path: polygon(
        0% 1.2%, 1.4% 0%, 18% 0.6%, 35% 0.2%, 52% 1.0%, 70% 0%, 88% 0.8%, 99% 0.4%, 100% 2%,
        99.4% 22%, 100% 44%, 99.2% 66%, 100% 84%, 99% 99%,
        82% 100%, 64% 99.4%, 46% 100%, 28% 99.2%, 10% 100%, 0.4% 99.4%, 0% 98%,
        0.8% 78%, 0% 56%, 0.6% 34%, 0% 14%
    );
    filter: blur(6px);
    opacity: 0.3;
    transform: translateX(-30px);
    transition:
        filter 0.6s ease-out,
        opacity 0.5s ease-out,
        transform 0.7s ease-out;
}

.chapter-right .node {
    transform: translateX(30px);
}

.chapter.in-focus .node {
    filter: blur(0);
    opacity: 1;
    transform: translateX(0);
}

.node-solid {
    border: 1px solid var(--ink-3A);
    box-shadow: 0 0 0 1px var(--ink-1A) inset;
}

.node-dashed {
    border: 1px dashed var(--ash);
}

.node-textured {
    background-image:
        repeating-linear-gradient(45deg, rgba(42,42,42,0.4) 0 1px, transparent 1px 10px),
        repeating-linear-gradient(135deg, rgba(42,42,42,0.32) 0 1px, transparent 1px 12px);
    background-color: var(--parchment-dark);
    background-blend-mode: overlay;
}

.chapter-number {
    position: absolute;
    top: 18px;
    right: 22px;
    font-family: var(--font-mono);
    font-size: 0.95rem;
    color: var(--silver-fog);
    letter-spacing: 0.1em;
}

.node-label {
    display: block;
    font-family: var(--font-hand);
    font-size: clamp(0.9rem, 1.4vw, 1.1rem);
    color: var(--pewter);
    margin-bottom: 12px;
    letter-spacing: 0.02em;
    transform: rotate(-0.6deg);
    transform-origin: left;
}

.node-heading {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(2.2rem, 5.5vw, 4.8rem);
    line-height: 1.05;
    letter-spacing: 0.01em;
    color: var(--frost);
    margin-bottom: 24px;
}

.sequestration-heading {
    font-weight: 700;
    letter-spacing: 0.04em;
    word-spacing: -0.05em;
}

.node-body {
    font-family: var(--font-body);
    font-size: clamp(0.95rem, 1.4vw, 1.1rem);
    line-height: 1.72;
    letter-spacing: 0.005em;
    color: var(--moonlight);
    margin-bottom: 18px;
}

.node-body em {
    font-style: italic;
    color: var(--frost);
}

.dropcap {
    float: left;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 3.5em;
    line-height: 0.85;
    padding: 4px 10px 4px 6px;
    margin: 6px 12px 0 0;
    color: var(--frost);
    border: 1px solid var(--ink-3A);
    background: rgba(20, 20, 20, 0.6);
}

.node-formula {
    font-family: var(--font-mono);
    font-size: 1.05rem;
    color: var(--silver-fog);
    background: rgba(10, 10, 10, 0.5);
    border: 1px dotted var(--ash);
    padding: 12px 16px;
    margin-top: 18px;
    text-align: center;
    letter-spacing: 0.04em;
}

.node-formula sub {
    font-size: 0.7em;
}

.node-list {
    list-style: none;
    margin: 18px 0 8px;
    padding: 0;
}

.node-list li {
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--moonlight);
    padding: 7px 0;
    border-bottom: 1px dotted var(--ash);
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
}

.node-list li::before {
    content: "—";
    color: var(--graphite);
    margin-right: 10px;
}

.formula {
    font-family: var(--font-mono);
    font-size: 0.88rem;
    color: var(--silver-fog);
}

.node-quote {
    margin-top: 22px;
    padding: 18px 22px;
    border-left: 2px solid var(--ash);
    background: rgba(10, 10, 10, 0.4);
    position: relative;
}

.quote-mark {
    font-family: var(--font-display);
    font-size: 3rem;
    color: var(--ash);
    position: absolute;
    top: -10px;
    left: 6px;
    line-height: 1;
}

.quote-text {
    display: block;
    font-family: var(--font-display);
    font-style: italic;
    font-size: 1.1rem;
    color: var(--frost);
    margin-top: 8px;
    line-height: 1.55;
}

.quote-attr {
    display: block;
    font-family: var(--font-hand);
    font-size: 1rem;
    color: var(--graphite);
    margin-top: 8px;
    transform: rotate(-0.5deg);
    transform-origin: left;
}

.monospace-block {
    font-family: var(--font-mono);
    font-size: 0.95rem;
    color: var(--silver-fog);
    background: rgba(10, 10, 10, 0.4);
    border: 1px dotted var(--ash);
    padding: 14px 18px;
    line-height: 1.85;
    letter-spacing: 0.02em;
}

.node-footnote {
    font-family: var(--font-body);
    font-size: 0.92rem;
    color: var(--graphite);
    font-style: italic;
    margin-top: 18px;
    padding-top: 12px;
    border-top: 1px dotted var(--ink-3A);
}

.footnote-marker {
    color: var(--frost);
    cursor: help;
    font-family: var(--font-mono);
    margin-left: 2px;
    border-bottom: 1px dotted var(--silver-fog);
}

.footnote-marker:hover {
    color: var(--silver-fog);
}

.node-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 22px;
    padding-top: 16px;
    border-top: 1px dotted var(--ash);
}

.stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-label {
    font-family: var(--font-hand);
    font-size: 0.82rem;
    color: var(--graphite);
    letter-spacing: 0.02em;
}

.stat-value {
    font-family: var(--font-mono);
    font-size: 0.95rem;
    color: var(--frost);
    letter-spacing: 0.04em;
}

.node-list-thin {
    margin-top: 22px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.node-list-thin span {
    font-family: var(--font-body);
    font-size: 0.95rem;
    color: var(--moonlight);
    padding: 6px 0;
    border-bottom: 1px dotted var(--ink-3A);
    letter-spacing: 0.02em;
}

/* ==========================================================================
   Margin Annotations
   ========================================================================== */
.margin-note {
    position: absolute;
    font-family: var(--font-hand);
    font-size: 0.78rem;
    color: var(--graphite);
    line-height: 1.3;
    max-width: 160px;
    transform: rotate(var(--rot, 0deg));
    transform-origin: left top;
    opacity: 0;
    transition:
        opacity 0.6s ease 0.3s,
        transform 0.6s ease 0.3s;
    padding-left: 10px;
    border-left: 1px solid var(--ink-3A);
}

.chapter.in-focus .margin-note {
    opacity: 1;
}

.margin-note-left {
    bottom: -20px;
    left: -180px;
    text-align: right;
    border-left: none;
    border-right: 1px solid var(--ink-3A);
    padding-left: 0;
    padding-right: 10px;
    transform-origin: right top;
}

.margin-note-right {
    top: -10px;
    right: -180px;
}

@media (max-width: 1100px) {
    .margin-note { display: none; }
}

/* ==========================================================================
   Interludes
   ========================================================================== */
.interlude {
    position: relative;
    background: #0E0E0E;
    width: 100%;
    margin: 60px 0;
    padding: 60px 5vw 80px;
    overflow: hidden;
    border-top: 1px solid var(--ink-1A);
    border-bottom: 1px solid var(--ink-1A);
}

.interlude-secondary {
    background: #0B0B0B;
}

.interlude-mist {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to bottom,
        transparent 0%,
        rgba(10, 10, 10, 0.65) 40%,
        rgba(10, 10, 10, 0.45) 60%,
        transparent 100%
    );
    pointer-events: none;
    opacity: 0.3;
    animation: interlude-mist-drift 24s ease-in-out infinite;
}

.interlude-mist-dense {
    opacity: 0.45;
    animation-duration: 30s;
}

@keyframes interlude-mist-drift {
    0%, 100% { transform: translateY(-20px); }
    50%      { transform: translateY(40px); }
}

.root-illustration,
.molecule-illustration {
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    display: block;
    overflow: visible;
}

.root-path {
    stroke-dasharray: 800;
    stroke-dashoffset: 800;
    transition: stroke-dashoffset 1.2s ease-out;
}

.interlude.in-focus .root-path {
    stroke-dashoffset: 0;
}

.interlude.in-focus .root-path:nth-child(2)  { transition-delay: 0.0s; }
.interlude.in-focus .root-path:nth-child(3)  { transition-delay: 0.4s; }
.interlude.in-focus .root-path:nth-child(4)  { transition-delay: 0.6s; }
.interlude.in-focus .root-path:nth-child(5)  { transition-delay: 0.8s; }
.interlude.in-focus .root-path:nth-child(6)  { transition-delay: 1.0s; }
.interlude.in-focus .root-path:nth-child(7)  { transition-delay: 1.2s; }
.interlude.in-focus .root-path:nth-child(8)  { transition-delay: 1.4s; }
.interlude.in-focus .root-path:nth-child(9)  { transition-delay: 1.6s; }
.interlude.in-focus .root-path:nth-child(10) { transition-delay: 1.8s; }
.interlude.in-focus .root-path:nth-child(n+11) { transition-delay: 2.0s; }

.interlude-caption {
    text-align: center;
    margin-top: 36px;
    font-family: var(--font-hand);
    font-size: 1.15rem;
    color: var(--silver-fog);
    letter-spacing: 0.02em;
    transform: rotate(-0.4deg);
    position: relative;
    z-index: 2;
}

/* Pulse-attention for interlude moths */
.interlude g[transform^="translate"] {
    animation: pulse-attention 6s ease-in-out infinite;
    transform-origin: center;
}

@keyframes pulse-attention {
    0%, 100% { transform: translate(180px, 80px) scale(1) rotate(0deg); }
    50%      { transform: translate(180px, 80px) scale(1.05) rotate(-3deg); }
}

/* The second moth has different translation values, override on its g */
.molecule-illustration g[transform="translate(820,240)"] {
    animation: pulse-attention-2 6s ease-in-out infinite;
    animation-delay: -3s;
}

@keyframes pulse-attention-2 {
    0%, 100% { transform: translate(820px, 240px) scale(1) rotate(0deg); }
    50%      { transform: translate(820px, 240px) scale(1.06) rotate(2deg); }
}

/* ==========================================================================
   Illuminated Folio (light page)
   ========================================================================== */
.chapter-illuminated {
    transition: background 1.2s ease;
}

.chapter-illuminated.in-focus {
    background: radial-gradient(ellipse at right center, rgba(242, 240, 235, 0.04), transparent 60%);
}

.node-illuminated {
    background: var(--parchment-light);
    color: var(--ink-1A);
    border: 1px solid #C8C2B6;
    box-shadow:
        0 0 60px rgba(242, 240, 235, 0.18),
        inset 0 0 40px rgba(220, 215, 200, 0.4);
    transition:
        filter 1.2s ease-out,
        opacity 1.2s ease-out,
        transform 1.2s ease-out;
}

.node-illuminated .chapter-number {
    color: #6E6A60;
}

.node-illuminated .node-label {
    color: #5A564D;
}

.node-illuminated .node-heading {
    color: #1A1A1A;
}

.node-illuminated .node-body {
    color: #1A1A1A;
}

.node-illuminated .dropcap {
    color: #1A1A1A;
    border-color: #B8B2A4;
    background: rgba(220, 215, 200, 0.4);
}

.illuminated-postscript {
    font-family: var(--font-hand);
    font-size: 1.05rem;
    color: #6E6A60;
    margin-top: 20px;
    transform: rotate(-0.5deg);
    transform-origin: left;
}

.illuminated-glow {
    position: absolute;
    top: 50%;
    right: 0;
    width: 60vw;
    height: 80vh;
    transform: translateY(-50%);
    background: radial-gradient(ellipse, rgba(242, 240, 235, 0.07) 0%, transparent 70%);
    pointer-events: none;
    opacity: 0;
    transition: opacity 1.2s ease;
}

.chapter-illuminated.in-focus .illuminated-glow {
    opacity: 1;
}

/* ==========================================================================
   Closing Section
   ========================================================================== */
.closing {
    position: relative;
    min-height: 70vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 120px 5vw;
    text-align: center;
}

.closing-blot {
    width: 80px;
    height: 80px;
    background: var(--ink-1A);
    border-radius: 48% 52% 56% 44% / 50% 46% 54% 50%;
    box-shadow:
        0 0 30px rgba(10, 10, 10, 0.8),
        inset -6px -8px 16px rgba(10, 10, 10, 0.6),
        12px -8px 0 -2px var(--ink-medium),
        -10px 12px 0 -3px var(--ink-medium);
    margin-bottom: 36px;
    opacity: 0.85;
}

.closing-line {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(2rem, 4vw, 3rem);
    color: var(--frost);
    letter-spacing: 0.06em;
}

.closing-sub {
    font-family: var(--font-hand);
    font-size: 1.1rem;
    color: var(--silver-fog);
    margin-top: 12px;
    transform: rotate(-0.6deg);
}

.closing-mark {
    font-family: var(--font-mono);
    font-size: 1rem;
    color: var(--graphite);
    letter-spacing: 0.4em;
    margin-top: 36px;
}

/* ==========================================================================
   Footnote Tooltip
   ========================================================================== */
.footnote-tooltip {
    position: fixed;
    max-width: 280px;
    background: var(--parchment-dark);
    color: var(--moonlight);
    border: 1px solid var(--ink-3A);
    padding: 14px 18px;
    font-family: var(--font-body);
    font-size: 0.92rem;
    line-height: 1.5;
    pointer-events: none;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    z-index: 200;
    clip-path: polygon(
        0 8%, 4% 0, 30% 4%, 60% 0, 96% 4%, 100% 12%,
        96% 88%, 100% 100%, 70% 96%, 40% 100%, 8% 96%, 0 90%
    );
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.7);
}

.footnote-tooltip.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ==========================================================================
   Responsive Adjustments
   ========================================================================== */
@media (max-width: 900px) {
    .spine-svg, .opening-spine {
        left: 8%;
    }
    .branch-right { left: calc(8% + 6px); }
    .branch-left  { right: calc(92% + 6px); display: none; }
    .chapter-right { justify-content: flex-start; padding-left: 5vw; padding-right: 5vw; }
    .chapter-illuminated { justify-content: flex-start; padding-left: 5vw; padding-right: 5vw; }
    .chapter-left  { padding-left: calc(8% + 50px); padding-right: 5vw; }
    .chapter-right { padding-left: calc(8% + 50px); }
    .chapter-illuminated { padding-left: calc(8% + 50px); }
    .node { width: min(100%, 540px); padding: 32px 28px 40px; }
    .opening { padding-left: calc(8% + 40px); }
    .moth { right: 10px; }
    .branch-right { width: 50px; }
    .node-stats { grid-template-columns: 1fr; }
}
