/* ==========================================================
   mystery.boo
   Goblincore digital grimoire / vertical timeline excavation
   Palette: muted-vintage  /  Layout: timeline-vertical
   ----------------------------------------------------------
   Palette tokens (from DESIGN.md):
     --bg-loam:        #1A1510   (background deep)
     --bg-rotted:      #2A2318   (card front)
     --bg-mushroom:    #33291E   (card back)
     --grid-earth:     #3D3326   (grid overlay)
     --copper-patina:  #5A8A6A   (accent primary)
     --bronze-deep:    #5C4B3A   (rivet shadow)
     --dim-earth:      #7A6B55   (metadata)
     --dried-blood:    #8B4A3A   (accent secondary)
     --tarnished-brass:#8B7355   (spine)
     --worn-leather:   #A89070   (text secondary)
     --bokeh-warm:     #B8943C   (bokeh tone)
     --parchment-text: #C4B49A   (body text)
     --amber-lantern:  #C9A84C   (bokeh primary)
     --aged-parchment: #D4C4A0   (display text)
   ========================================================== */

:root {
    --bg-loam:         #1A1510;
    --bg-rotted:       #2A2318;
    --bg-mushroom:     #33291E;
    --grid-earth:      #3D3326;
    --copper-patina:   #5A8A6A;
    --bronze-deep:     #5C4B3A;
    --dim-earth:       #7A6B55;
    --dried-blood:     #8B4A3A;
    --tarnished-brass: #8B7355;
    --worn-leather:    #A89070;
    --bokeh-warm:      #B8943C;
    --parchment-text:  #C4B49A;
    --amber-lantern:   #C9A84C;
    --aged-parchment:  #D4C4A0;
}

/* ----- Reset / Base ----- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    background-color: #1A1510;
}

body {
    min-height: 100vh;
    font-family: 'Crimson Text', Georgia, serif;
    font-size: 1.05rem;
    line-height: 1.7;
    color: #C4B49A;
    background-color: #1A1510;
    overflow-x: hidden;
    position: relative;
    /* Faint vignette */
    background-image:
        radial-gradient(ellipse at 50% 0%, rgba(201, 168, 76, 0.04) 0%, transparent 60%),
        radial-gradient(ellipse at 50% 100%, rgba(90, 138, 106, 0.025) 0%, transparent 70%);
}

/* The archaeological grid overlay (fixed pseudo-element on body) */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    background-image:
        repeating-linear-gradient(0deg,
            rgba(61, 51, 38, 0.08) 0px,
            rgba(61, 51, 38, 0.08) 1px,
            transparent 1px,
            transparent 80px),
        repeating-linear-gradient(90deg,
            rgba(61, 51, 38, 0.08) 0px,
            rgba(61, 51, 38, 0.08) 1px,
            transparent 1px,
            transparent 80px);
}

/* Faint film-grain on top of everything (very subtle) */
body::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 2;
    opacity: 0.07;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.18  0 0 0 0 0.14  0 0 0 0 0.10  0 0 0 0.7 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
    mix-blend-mode: overlay;
}

.svg-defs {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* ----- Bokeh atmospheric layer ----- */
.bokeh-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
    opacity: 0;
    animation: bokehFadeIn 2s ease-out 0.2s forwards;
}

.bokeh-sublayer {
    position: absolute;
    inset: -10%;
    width: 120%;
    height: 120%;
}

/* Each layer uses many radial-gradient circles */
/* Background layer: very large, very faint -- distant lights */
.bokeh-back {
    background-image:
        radial-gradient(circle at 12% 8%, rgba(201, 168, 76, 0.07) 0%, rgba(201, 168, 76, 0) 25%),
        radial-gradient(circle at 82% 18%, rgba(184, 148, 60, 0.06) 0%, rgba(184, 148, 60, 0) 22%),
        radial-gradient(circle at 28% 42%, rgba(201, 168, 76, 0.05) 0%, rgba(201, 168, 76, 0) 24%),
        radial-gradient(circle at 70% 60%, rgba(201, 168, 76, 0.06) 0%, rgba(201, 168, 76, 0) 26%),
        radial-gradient(circle at 8% 80%, rgba(184, 148, 60, 0.05) 0%, rgba(184, 148, 60, 0) 22%),
        radial-gradient(circle at 92% 92%, rgba(201, 168, 76, 0.06) 0%, rgba(201, 168, 76, 0) 25%),
        radial-gradient(circle at 50% 30%, rgba(201, 168, 76, 0.04) 0%, rgba(201, 168, 76, 0) 30%);
    animation: bokehDrift 22s ease-in-out infinite alternate;
}

/* Midground layer: medium circles, moderate opacity -- room lights */
.bokeh-mid {
    background-image:
        radial-gradient(circle at 18% 22%, rgba(201, 168, 76, 0.10) 0%, rgba(201, 168, 76, 0) 8%),
        radial-gradient(circle at 36% 14%, rgba(184, 148, 60, 0.08) 0%, rgba(184, 148, 60, 0) 7%),
        radial-gradient(circle at 62% 26%, rgba(201, 168, 76, 0.09) 0%, rgba(201, 168, 76, 0) 9%),
        radial-gradient(circle at 88% 36%, rgba(201, 168, 76, 0.07) 0%, rgba(201, 168, 76, 0) 8%),
        radial-gradient(circle at 22% 56%, rgba(184, 148, 60, 0.08) 0%, rgba(184, 148, 60, 0) 8%),
        radial-gradient(circle at 48% 68%, rgba(201, 168, 76, 0.09) 0%, rgba(201, 168, 76, 0) 9%),
        radial-gradient(circle at 76% 78%, rgba(201, 168, 76, 0.08) 0%, rgba(201, 168, 76, 0) 8%),
        radial-gradient(circle at 14% 88%, rgba(184, 148, 60, 0.07) 0%, rgba(184, 148, 60, 0) 7%),
        radial-gradient(circle at 58% 92%, rgba(201, 168, 76, 0.08) 0%, rgba(201, 168, 76, 0) 8%);
    animation: bokehPulseMid 12s ease-in-out infinite alternate;
}

/* Foreground layer: small, slightly brighter -- close reflections */
.bokeh-fore {
    background-image:
        radial-gradient(circle at 32% 8%, rgba(201, 168, 76, 0.12) 0%, rgba(201, 168, 76, 0) 3%),
        radial-gradient(circle at 70% 12%, rgba(201, 168, 76, 0.10) 0%, rgba(201, 168, 76, 0) 2.5%),
        radial-gradient(circle at 12% 32%, rgba(184, 148, 60, 0.11) 0%, rgba(184, 148, 60, 0) 3%),
        radial-gradient(circle at 86% 28%, rgba(201, 168, 76, 0.10) 0%, rgba(201, 168, 76, 0) 2.5%),
        radial-gradient(circle at 42% 48%, rgba(201, 168, 76, 0.10) 0%, rgba(201, 168, 76, 0) 2.5%),
        radial-gradient(circle at 64% 54%, rgba(184, 148, 60, 0.11) 0%, rgba(184, 148, 60, 0) 3%),
        radial-gradient(circle at 24% 72%, rgba(201, 168, 76, 0.10) 0%, rgba(201, 168, 76, 0) 2.5%),
        radial-gradient(circle at 80% 70%, rgba(201, 168, 76, 0.11) 0%, rgba(201, 168, 76, 0) 3%),
        radial-gradient(circle at 50% 84%, rgba(184, 148, 60, 0.10) 0%, rgba(184, 148, 60, 0) 2.5%),
        radial-gradient(circle at 6% 50%, rgba(201, 168, 76, 0.10) 0%, rgba(201, 168, 76, 0) 2.5%),
        radial-gradient(circle at 96% 62%, rgba(201, 168, 76, 0.10) 0%, rgba(201, 168, 76, 0) 2.5%);
    animation: bokehPulseFore 8.5s ease-in-out infinite alternate;
}

@keyframes bokehFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes bokehDrift {
    0%   { transform: translate3d(0, 0, 0) scale(1); }
    100% { transform: translate3d(2%, -1.5%, 0) scale(1.04); }
}

@keyframes bokehPulseMid {
    0%   { opacity: 0.85; transform: scale(0.98); }
    50%  { opacity: 1;    transform: scale(1.03); }
    100% { opacity: 0.9;  transform: scale(1);    }
}

@keyframes bokehPulseFore {
    0%   { opacity: 0.7; transform: scale(0.96); }
    100% { opacity: 1;   transform: scale(1.05); }
}

/* ----- Cursor-following grid spotlight ----- */
.grid-spotlight {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 3;
    opacity: 0;
    transition: opacity 0.4s ease;
    background:
        radial-gradient(circle 200px at var(--mx, -200px) var(--my, -200px),
            rgba(61, 51, 38, 0.30) 0%,
            rgba(61, 51, 38, 0.18) 35%,
            rgba(61, 51, 38, 0) 80%);
    mix-blend-mode: screen;
}

.grid-spotlight.active {
    opacity: 1;
}

.grid-spotlight::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        repeating-linear-gradient(0deg,
            rgba(61, 51, 38, 0.55) 0px,
            rgba(61, 51, 38, 0.55) 1.5px,
            transparent 1.5px,
            transparent 80px),
        repeating-linear-gradient(90deg,
            rgba(61, 51, 38, 0.55) 0px,
            rgba(61, 51, 38, 0.55) 1.5px,
            transparent 1.5px,
            transparent 80px);
    -webkit-mask-image: radial-gradient(circle 200px at var(--mx, -200px) var(--my, -200px),
        rgba(0,0,0,1) 0%, rgba(0,0,0,0.6) 40%, rgba(0,0,0,0) 80%);
            mask-image: radial-gradient(circle 200px at var(--mx, -200px) var(--my, -200px),
        rgba(0,0,0,1) 0%, rgba(0,0,0,0.6) 40%, rgba(0,0,0,0) 80%);
}

/* ----- Masthead (small watermark at top of spine) ----- */
.masthead {
    position: relative;
    z-index: 6;
    text-align: center;
    padding: 60px 20px 30px;
    pointer-events: none;
}

.masthead-name {
    display: block;
    font-family: 'Abril Fatface', 'Lora', Georgia, serif;
    font-size: 1.2rem;
    color: #5C4B3A;
    opacity: 0.55;
    letter-spacing: 0.04em;
    line-height: 1;
}

.masthead-sub {
    display: block;
    margin-top: 10px;
    font-family: 'IBM Plex Mono', 'Courier New', monospace;
    font-size: 0.7rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: #5C4B3A;
    opacity: 0.5;
}

/* ----- Excavation column / spine ----- */
.excavation {
    position: relative;
    z-index: 4;
    padding: 60px 0 200px;
    max-width: 100%;
}

.spine {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 4px;
    transform: translateX(-50%);
    background: linear-gradient(
        180deg,
        #8B7355 0px,
        #7A6B55 2px,
        #8B7355 4px
    );
    background-size: 100% 4px;
    background-repeat: repeat-y;
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.5),
        0 0 12px rgba(201, 168, 76, 0.06);
    z-index: 4;
    /* The reveal animation: scale Y from 0 to 1 */
    transform-origin: top center;
    animation: spineDescend 1.5s cubic-bezier(0.4, 0, 0.2, 1) 0.6s both;
}

.spine-svg {
    display: none; /* visual is from the gradient bg */
}

@keyframes spineDescend {
    from { transform: translateX(-50%) scaleY(0); }
    to   { transform: translateX(-50%) scaleY(1); }
}

.terminus {
    position: absolute;
    left: 50%;
    width: 60px;
    height: 60px;
    transform: translateX(-50%);
    z-index: 5;
    opacity: 0;
    animation: terminusAppear 0.8s ease-out 2.1s forwards;
}

.terminus-top {
    top: -78px;
}

.terminus-bottom {
    bottom: -100px;
    width: 80px;
    height: 90px;
}

@keyframes terminusAppear {
    from { opacity: 0; transform: translateX(-50%) scale(0.7); }
    to   { opacity: 1; transform: translateX(-50%) scale(1);   }
}

/* ----- Timeline ----- */
.timeline {
    list-style: none;
    position: relative;
    z-index: 5;
    margin: 0 auto;
    padding: 0;
    max-width: 100%;
}

.node {
    position: relative;
    min-height: 240px;
    margin-bottom: 240px;
    padding: 0;
}

.node:last-child {
    margin-bottom: 0;
}

/* Pin rivet sitting on the spine */
.pin {
    position: absolute;
    top: 28px;
    left: 50%;
    width: 16px;
    height: 16px;
    transform: translateX(-50%) scale(0);
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%,
        #A89070 0%,
        #8B7355 45%,
        #5C4B3A 100%);
    box-shadow:
        0 1px 3px rgba(0, 0, 0, 0.6),
        inset 0 -1px 1px rgba(0, 0, 0, 0.4),
        inset 0 1px 1px rgba(168, 144, 112, 0.5),
        0 0 0 1px #2A2318;
    z-index: 6;
    transition: transform 0.3s ease;
}

.node.in-view .pin {
    animation: pinPop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes pinPop {
    from { transform: translateX(-50%) scale(0); }
    to   { transform: translateX(-50%) scale(1); }
}

.pin.pulse {
    animation: pinPulse 0.3s ease;
}

@keyframes pinPulse {
    0%   { transform: translateX(-50%) scale(1);   }
    50%  { transform: translateX(-50%) scale(1.3); box-shadow: 0 0 14px rgba(201, 168, 76, 0.6), 0 1px 3px rgba(0,0,0,0.6); }
    100% { transform: translateX(-50%) scale(1);   }
}

/* Connector line from spine to card */
.connector {
    position: absolute;
    top: 36px;
    height: 2px;
    width: 0;
    background: linear-gradient(90deg, #8B7355 0%, #7A6B55 50%, #8B7355 100%);
    box-shadow: 0 0 4px rgba(201, 168, 76, 0.05);
    z-index: 5;
    transition: width 0.4s ease-out 0.05s;
}

.node-left .connector {
    right: 50%;
    /* extends to the left of the spine */
    transform-origin: right center;
}

.node-right .connector {
    left: 50%;
    transform-origin: left center;
}

.node.in-view .connector {
    width: calc((100vw - 800px) / 2);
    max-width: calc(50vw - 200px);
}

/* Cards: alternating sides */
.card {
    position: absolute;
    top: 0;
    width: 400px;
    min-height: 240px;
    perspective: 1000px;
    cursor: pointer;
    z-index: 5;
    opacity: 0;
    transition:
        transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1),
        opacity 0.6s ease-out;
    outline: none;
}

.node-left .card {
    right: calc(50% + 60px); /* leaves room for connector */
    transform: translateX(-30px);
}

.node-right .card {
    left: calc(50% + 60px);
    transform: translateX(30px);
}

.node.in-view .card {
    opacity: 1;
    transform: translateX(0);
}

/* Card inner -- the flipping element */
.card-inner {
    position: relative;
    width: 100%;
    min-height: 240px;
    transition: transform 0.7s ease-in-out, box-shadow 0.7s ease-in-out;
    transform-style: preserve-3d;
    box-shadow:
        0 12px 28px rgba(0, 0, 0, 0.55),
        0 4px 10px rgba(0, 0, 0, 0.4),
        inset 0 0 0 1px rgba(168, 144, 112, 0.08);
}

.card.flipped .card-inner {
    transform: rotateY(180deg);
    box-shadow:
        0 18px 36px rgba(0, 0, 0, 0.65),
        0 6px 14px rgba(0, 0, 0, 0.45),
        inset 0 0 0 1px rgba(168, 144, 112, 0.12);
}

.card.flipping .card-inner {
    box-shadow:
        0 4px 10px rgba(0, 0, 0, 0.4),
        inset 0 0 0 1px rgba(168, 144, 112, 0.08);
}

.card-face {
    position: absolute;
    inset: 0;
    width: 100%;
    min-height: 240px;
    -webkit-backface-visibility: hidden;
            backface-visibility: hidden;
    border-radius: 2px;
    padding: 28px 28px 24px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Card front -- rotted wood with noise */
.card-front {
    background-color: #2A2318;
    background-image:
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='r'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.16  0 0 0 0 0.13  0 0 0 0 0.09  0 0 0 0.55 0'/></filter><rect width='100%' height='100%' filter='url(%23r)'/></svg>"),
        linear-gradient(135deg, rgba(139, 115, 85, 0.05) 0%, rgba(0, 0, 0, 0) 50%, rgba(0, 0, 0, 0.3) 100%);
    background-blend-mode: overlay, normal;
    border: 1px solid rgba(122, 107, 85, 0.22);
}

.card-back {
    background-color: #33291E;
    background-image:
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='f'><feTurbulence type='fractalNoise' baseFrequency='1.4' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.20  0 0 0 0 0.16  0 0 0 0 0.11  0 0 0 0.40 0'/></filter><rect width='100%' height='100%' filter='url(%23f)'/></svg>"),
        linear-gradient(135deg, rgba(168, 144, 112, 0.04) 0%, rgba(0, 0, 0, 0) 60%);
    background-blend-mode: overlay, normal;
    border: 1px solid rgba(122, 107, 85, 0.22);
    transform: rotateY(180deg);
}

/* Card-front bokeh -- subtle, more present than the page background */
.card-bokeh {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image:
        radial-gradient(circle at 22% 28%, rgba(201, 168, 76, 0.16) 0%, rgba(201, 168, 76, 0) 18%),
        radial-gradient(circle at 78% 38%, rgba(184, 148, 60, 0.14) 0%, rgba(184, 148, 60, 0) 16%),
        radial-gradient(circle at 60% 76%, rgba(201, 168, 76, 0.12) 0%, rgba(201, 168, 76, 0) 18%),
        radial-gradient(circle at 12% 82%, rgba(184, 148, 60, 0.12) 0%, rgba(184, 148, 60, 0) 16%);
    filter: blur(2px);
    opacity: 0.9;
    mix-blend-mode: screen;
}

/* Specimen badge */
.spx-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    display: inline-block;
    padding: 3px 8px;
    background: #2A2318;
    border: 1px solid #7A6B55;
    border-radius: 2px;
    font-family: 'IBM Plex Mono', 'Courier New', monospace;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    color: #A89070;
    text-transform: uppercase;
    z-index: 2;
    box-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* Card front content */
.card-front-content {
    position: relative;
    z-index: 1;
    margin-top: auto;
    padding-top: 30px;
}

.date-stamp {
    display: block;
    font-family: 'IBM Plex Mono', 'Courier New', monospace;
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    color: #7A6B55;
    text-transform: uppercase;
    margin-bottom: 14px;
}

.card-title {
    font-family: 'Abril Fatface', 'Lora', Georgia, serif;
    font-weight: 400;
    font-size: 2.4rem;
    line-height: 1.05;
    letter-spacing: -0.02em;
    color: #D4C4A0;
    text-shadow:
        0 1px 0 rgba(0,0,0,0.4),
        0 0 22px rgba(201, 168, 76, 0.06);
    margin-bottom: 16px;
    word-spacing: -0.05em;
}

.flip-hint {
    display: block;
    margin-top: 8px;
    font-family: 'IBM Plex Mono', 'Courier New', monospace;
    font-size: 0.7rem;
    letter-spacing: 0.18em;
    color: #5C4B3A;
    text-transform: uppercase;
    transition: color 0.4s ease;
}

.card:hover .flip-hint {
    color: #5A8A6A;
}

/* Card back content */
.back-header {
    font-family: 'Yanone Kaffeesatz', 'Oswald', sans-serif;
    font-weight: 700;
    font-size: 1.6rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #A89070;
    margin: 18px 0 14px;
    border-bottom: 1px solid rgba(122, 107, 85, 0.30);
    padding-bottom: 8px;
}

.card-body {
    font-family: 'Crimson Text', Georgia, serif;
    font-size: 1rem;
    line-height: 1.65;
    color: #C4B49A;
    margin-bottom: 14px;
}

.card-body em {
    color: #D4C4A0;
    font-style: italic;
}

.annotation {
    font-family: 'Crimson Text', Georgia, serif;
    font-size: 0.92rem;
    line-height: 1.6;
    font-style: italic;
    color: #A89070;
    padding: 10px 12px;
    border-left: 2px solid #5A8A6A;
    background: rgba(26, 21, 16, 0.4);
    margin-bottom: 16px;
}

.quoted {
    font-family: 'IBM Plex Mono', 'Courier New', monospace;
    font-style: normal;
    font-size: 0.85rem;
    color: #C4B49A;
    background: rgba(26, 21, 16, 0.55);
    padding: 1px 5px;
    letter-spacing: 0.02em;
}

.cross-refs {
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px dashed rgba(122, 107, 85, 0.3);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.ref-label {
    font-family: 'IBM Plex Mono', 'Courier New', monospace;
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #7A6B55;
}

.ref-link {
    font-family: 'IBM Plex Mono', 'Courier New', monospace;
    font-size: 0.78rem;
    letter-spacing: 0.06em;
    color: #5A8A6A;
    text-decoration: none;
    border-bottom: 1px dotted rgba(90, 138, 106, 0.5);
    padding: 1px 2px;
    transition: color 0.25s ease, border-color 0.25s ease, background 0.25s ease;
}

.ref-link:hover {
    color: #8B4A3A;
    border-bottom-color: #8B4A3A;
    background: rgba(139, 74, 58, 0.08);
}

.ref-link.inline-ref {
    font-family: 'Crimson Text', Georgia, serif;
    font-size: 1rem;
    font-style: italic;
}

/* ----- Decorative moths (scattered along the spine) ----- */
.moth {
    position: absolute;
    width: 60px;
    height: 45px;
    pointer-events: none;
    opacity: 0.55;
    z-index: 4;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.7));
    animation: mothBreath 6s ease-in-out infinite alternate;
}

.moth-1 {
    top: 380px;
    left: calc(50% - 14px);
    transform: translate(-50%, 0) rotate(-22deg);
}

.moth-2 {
    top: 1500px;
    left: calc(50% + 70px);
    transform: rotate(14deg);
    width: 50px;
    height: 38px;
    opacity: 0.45;
}

.moth-3 {
    top: 2700px;
    left: calc(50% - 130px);
    transform: rotate(-7deg);
    width: 42px;
    height: 32px;
    opacity: 0.4;
}

@keyframes mothBreath {
    0%   { transform: translateY(0) rotate(var(--rot, 0deg)) scale(1);    opacity: 0.5; }
    100% { transform: translateY(-2px) rotate(var(--rot, 0deg)) scale(1.02); opacity: 0.6; }
}

/* ----- Root tendrils ----- */
.tendril {
    position: absolute;
    width: 200px;
    height: 100px;
    pointer-events: none;
    opacity: 0.18;
    z-index: 3;
}

.tendril-1 {
    top: 700px;
    left: calc(50% + 2px);
    transform: rotate(2deg);
}

.tendril-2 {
    top: 1900px;
    right: calc(50% + 2px);
    transform: rotate(-3deg);
}

.tendril-3 {
    top: 3100px;
    left: calc(50% + 2px);
    transform: rotate(1deg);
}

/* ----- Responsive ----- */
@media (max-width: 1100px) {
    .card {
        width: 360px;
    }

    .node-left .card,
    .node-right .card {
        /* keep alternating but reduce gap */
    }

    .card-title {
        font-size: 2.1rem;
    }
}

@media (max-width: 900px) {
    .card {
        width: 320px;
    }

    .card-title {
        font-size: 1.9rem;
    }

    .card-face {
        padding: 24px 22px 20px;
    }
}

@media (max-width: 768px) {
    /* Single-column layout: spine moves to 8% from left */
    .spine {
        left: 8%;
    }

    .terminus {
        left: 8%;
    }

    .node-left,
    .node-right {
        /* All cards on the right */
    }

    .node-left .connector,
    .node-right .connector {
        right: auto;
        left: 8%;
    }

    .node.in-view .node-left .connector,
    .node.in-view .node-right .connector,
    .node.in-view .connector {
        width: 30px;
    }

    .node-left .card,
    .node-right .card {
        position: relative;
        right: auto;
        left: auto;
        margin-left: calc(8% + 50px);
        width: calc(100% - 8% - 70px);
        max-width: 480px;
        transform: translateX(20px);
    }

    .node.in-view .node-left .card,
    .node.in-view .node-right .card,
    .node.in-view .card {
        transform: translateX(0);
    }

    .node {
        margin-bottom: 200px;
        min-height: 220px;
    }

    .moth-1, .moth-2, .moth-3,
    .tendril-1, .tendril-2, .tendril-3 {
        opacity: 0.18;
    }

    .moth-1 { left: calc(8% + 24px); }
    .moth-2 { left: calc(8% - 30px); right: auto; }
    .moth-3 { left: calc(8% + 30px); }

    .tendril-1 { left: calc(8% + 4px); }
    .tendril-2 { right: auto; left: calc(8% - 196px); }
    .tendril-3 { left: calc(8% + 4px); }

    .card-title {
        font-size: 1.7rem;
    }

    .grid-spotlight {
        display: none;
    }
}

@media (max-width: 480px) {
    body {
        font-size: 1rem;
    }

    .card-title {
        font-size: 1.5rem;
    }

    .back-header {
        font-size: 1.3rem;
    }

    .card-face {
        padding: 22px 18px 18px;
    }

    .masthead {
        padding-top: 40px;
    }

    .masthead-name {
        font-size: 1.05rem;
    }

    .annotation {
        font-size: 0.86rem;
    }

    body::before {
        background-size: 60px 60px, 60px 60px;
        background-image:
            repeating-linear-gradient(0deg,
                rgba(61, 51, 38, 0.08) 0px,
                rgba(61, 51, 38, 0.08) 1px,
                transparent 1px,
                transparent 60px),
            repeating-linear-gradient(90deg,
                rgba(61, 51, 38, 0.08) 0px,
                rgba(61, 51, 38, 0.08) 1px,
                transparent 1px,
                transparent 60px);
    }
}
