/* ==================================================================
   PPADDL.com — Seapunk Antiquarian / Drowned Library
   --------------------------------------------------------------
   Palette:  #E8D5B7 sepia-parchment  |  #0D3B3E abyssal-teal
             #4EEADB bioluminescent-cyan  |  #1A2F2A kelp-ink
             #B8860B amber-varnish  |  #7B68AE phosphor-violet
             #F5F0E8 fog-pearl  |  #091F20 deep-void
   Fonts:    Libre Baskerville (headings), Lora (body),
             IBM Plex Mono (spine/meta), Inter, Space Grotesk
   ================================================================== */

:root {
    /* Palette */
    --parchment: #E8D5B7;
    --teal:      #0D3B3E;
    --cyan:      #4EEADB;
    --kelp:      #1A2F2A;
    --amber:     #B8860B;
    --violet:    #7B68AE;
    --pearl:     #F5F0E8;
    --abyss:     #091F20;

    /* Alpha variants */
    --cyan-10:   rgba(78, 234, 219, 0.10);
    --cyan-20:   rgba(78, 234, 219, 0.20);
    --cyan-30:   rgba(78, 234, 219, 0.30);
    --cyan-50:   rgba(78, 234, 219, 0.50);
    --amber-30:  rgba(184, 134, 11, 0.30);
    --amber-60:  rgba(184, 134, 11, 0.60);
    --parchment-15: rgba(232, 213, 183, 0.15);
    --parchment-30: rgba(232, 213, 183, 0.30);

    /* Typography */
    --font-heading: 'Libre Baskerville', 'Lora', Georgia, serif;
    --font-body:    'Lora', 'Libre Baskerville', Georgia, serif;
    --font-mono:    'IBM Plex Mono', 'Courier New', monospace;
    --font-ui:      'Inter', 'Helvetica Neue', sans-serif;
    --font-accent:  'Space Grotesk', 'Inter', sans-serif;

    /* Spacing */
    --rhythm: clamp(8rem, 15vh, 12rem);
    --gutter: clamp(2rem, 6vw, 5rem);

    /* Borders / motion */
    --border-soft: 1px solid rgba(184, 134, 11, 0.25);
    --ease-glide: cubic-bezier(0.4, 0, 0.2, 1);
}

@property --border-angle {
    syntax: '<angle>';
    inherits: false;
    initial-value: 0deg;
}

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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    font-family: var(--font-body);
    font-size: 18px;
    line-height: 1.85;
    color: var(--pearl);
    background: var(--abyss);
    overflow-x: hidden;
    position: relative;
    min-height: 100vh;
}

/* Layered background atmosphere (seapunk caustics + noise) */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at center, var(--teal) 0%, var(--abyss) 75%);
    z-index: -3;
    pointer-events: none;
}

#caustics-layer {
    position: fixed;
    inset: 0;
    z-index: -2;
    pointer-events: none;
    background:
        radial-gradient(ellipse 800px 400px at 20% 30%, var(--cyan-10) 0%, transparent 60%),
        radial-gradient(ellipse 600px 500px at 80% 60%, rgba(123, 104, 174, 0.06) 0%, transparent 70%),
        radial-gradient(ellipse 700px 300px at 50% 90%, var(--cyan-10) 0%, transparent 60%);
    background-size: 200% 200%;
    animation: causticsDrift 24s ease-in-out infinite alternate;
    opacity: 0.9;
    mix-blend-mode: screen;
}

@keyframes causticsDrift {
    0%   { background-position:   0%   0%,   100% 100%,  50% 50%; }
    50%  { background-position:  40%  60%,    60%  40%,  60% 30%; }
    100% { background-position: 100% 100%,    0%   0%,   40% 70%; }
}

#noise-layer {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    opacity: 0.035;
    background-image: repeating-conic-gradient(
        from 0deg at 50% 50%,
        var(--parchment) 0deg 1deg,
        transparent 1deg 3deg
    );
    background-size: 3px 3px;
    mix-blend-mode: overlay;
}

/* ============== Submersion Overlay ============== */
#submersion-overlay {
    position: fixed;
    inset: 0;
    background: var(--parchment);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition:
        background-color 1.6s var(--ease-glide),
        opacity 0.9s ease;
}

#submersion-overlay.phase-tint { background: var(--teal); }
#submersion-overlay.phase-deep { background: var(--abyss); }
#submersion-overlay.phase-done {
    opacity: 0;
    pointer-events: none;
}

#submersion-text {
    display: flex;
    gap: 0.08em;
    font-family: var(--font-heading);
    font-size: clamp(48px, 12vw, 96px);
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--kelp);
    transition: color 1.6s var(--ease-glide), text-shadow 1.6s var(--ease-glide);
}

#submersion-overlay.phase-tint #submersion-text,
#submersion-overlay.phase-deep #submersion-text {
    color: var(--cyan);
    text-shadow: 0 0 24px rgba(78, 234, 219, 0.45), 0 0 48px rgba(78, 234, 219, 0.18);
}

.letter {
    display: inline-block;
    opacity: 0;
    transform: translateY(-30px);
    animation: letterSink 0.9s var(--ease-glide) forwards;
}

.letter[data-index='0'] { animation-delay: 0.10s; }
.letter[data-index='1'] { animation-delay: 0.40s; }
.letter[data-index='2'] { animation-delay: 0.70s; }
.letter[data-index='3'] { animation-delay: 1.00s; }
.letter[data-index='4'] { animation-delay: 1.30s; }
.letter[data-index='5'] { animation-delay: 1.60s; }

@keyframes letterSink {
    0%   { opacity: 0; transform: translateY(-30px); }
    70%  { opacity: 1; transform: translateY(4px); }
    100% { opacity: 1; transform: translateY(0); }
}

#submersion-ripples {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.ripple {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 80px;
    height: 80px;
    border: 1px solid var(--amber);
    border-radius: 50%;
    opacity: 0;
    transform: translate(-50%, -50%);
}

.ripple-1 { animation: rippleExpand 2.4s 1.8s ease-out forwards; }
.ripple-2 { animation: rippleExpand 2.4s 2.2s ease-out forwards; }
.ripple-3 { animation: rippleExpand 2.4s 2.6s ease-out forwards; }

@keyframes rippleExpand {
    0%   { opacity: 0.5; width: 80px;  height: 80px; }
    100% { opacity: 0;   width: 480px; height: 480px; }
}

/* ============== Spine Column (F-pattern vertical stem) ============== */
#spine-column {
    position: fixed;
    left: clamp(16px, 2vw, 40px);
    top: 0;
    bottom: 0;
    width: 70px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 32px 0;
    opacity: 0;
    transition: opacity 1s var(--ease-glide);
}

#spine-column.visible { opacity: 1; }

.spine-line {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 2px;
    margin-left: -1px;
    background: linear-gradient(180deg,
        transparent 0%,
        var(--amber-60) 10%,
        var(--amber-60) 90%,
        transparent 100%);
    z-index: 0;
}

/* Traveling-light gradient along the spine — the signature border-animate */
.spine-glow {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 4px;
    margin-left: -2px;
    background: linear-gradient(180deg,
        transparent 0%,
        var(--cyan) 20%,
        var(--violet) 50%,
        var(--cyan) 80%,
        transparent 100%);
    background-size: 100% 300%;
    animation: spinePulse 8s linear infinite;
    opacity: 0.55;
    filter: blur(1px);
    z-index: 0;
}

@keyframes spinePulse {
    0%   { background-position: 0% -100%; }
    100% { background-position: 0% 200%; }
}

.spine-top-label,
.spine-bottom-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-family: var(--font-mono);
    font-size: 9px;
    letter-spacing: 0.2em;
    color: var(--amber);
    text-transform: uppercase;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    z-index: 1;
}

.spine-catalog { opacity: 0.8; }
.spine-catalog-num { opacity: 0.55; font-size: 8px; }
.spine-axis-mark { opacity: 0.5; }
.spine-axis-depth { font-size: 8px; opacity: 0.6; }

.spine-nodes {
    display: flex;
    flex-direction: column;
    gap: 44px;
    position: relative;
    z-index: 2;
}

.spine-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--amber);
    font-family: var(--font-mono);
    position: relative;
    transition: color 0.4s ease;
}

.spine-chapter-num {
    font-size: 10px;
    letter-spacing: 0.15em;
    opacity: 0.55;
    font-weight: 500;
    transition: opacity 0.3s ease, color 0.3s ease;
}

.spine-dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    border: 1.5px solid var(--amber);
    background: var(--abyss);
    transition: all 0.45s var(--ease-glide);
    flex-shrink: 0;
    position: relative;
}

.spine-dot::before {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 1px solid transparent;
    transition: all 0.5s ease;
}

.spine-node:hover .spine-dot,
.spine-node.active .spine-dot {
    background: var(--cyan);
    border-color: var(--cyan);
    box-shadow: 0 0 16px rgba(78, 234, 219, 0.6),
                0 0 32px rgba(78, 234, 219, 0.25);
}

.spine-node.active .spine-dot::before {
    border-color: var(--cyan-30);
    animation: dotPulse 2.4s ease-in-out infinite;
}

@keyframes dotPulse {
    0%, 100% { transform: scale(1); opacity: 0.5; }
    50%      { transform: scale(1.4); opacity: 0; }
}

.spine-label {
    font-family: var(--font-mono);
    font-size: 9px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--amber);
    opacity: 0;
    transform: translateX(-6px);
    transition: all 0.35s ease;
    white-space: nowrap;
    position: absolute;
    left: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%) translateX(-6px);
}

.spine-node:hover .spine-label,
.spine-node.active .spine-label {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
    color: var(--cyan);
}

.spine-node:hover .spine-chapter-num,
.spine-node.active .spine-chapter-num {
    opacity: 1;
    color: var(--cyan);
}

/* ============== Depth Indicator ============== */
#depth-indicator {
    position: fixed;
    right: clamp(16px, 2vw, 40px);
    bottom: 32px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    opacity: 0;
    transition: opacity 1s var(--ease-glide);
    padding: 12px 16px;
    border: 1px solid var(--amber-30);
    background: rgba(9, 31, 32, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

#depth-indicator.visible { opacity: 1; }

.depth-label {
    font-family: var(--font-mono);
    font-size: 9px;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--amber);
    opacity: 0.7;
}

.depth-value {
    font-family: var(--font-mono);
    font-size: 18px;
    font-weight: 500;
    color: var(--cyan);
    letter-spacing: 0.05em;
    transition: filter 0.2s ease;
}

.depth-value.blurring { filter: blur(2.5px); }

.depth-unit {
    font-family: var(--font-mono);
    font-size: 8px;
    letter-spacing: 0.15em;
    color: var(--parchment);
    opacity: 0.45;
    text-transform: uppercase;
}

/* ============== Bubble / Plankton Particle Field ============== */
#bubble-container {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 500;
    overflow: hidden;
}

.bubble {
    position: absolute;
    border-radius: 50%;
    border: 1px solid rgba(78, 234, 219, 0.35);
    background: radial-gradient(circle at 30% 30%,
        rgba(78, 234, 219, 0.20),
        rgba(78, 234, 219, 0.04) 60%,
        transparent 80%);
    box-shadow: 0 0 8px rgba(78, 234, 219, 0.12);
    animation: bubbleRise linear forwards;
}

@keyframes bubbleRise {
    0%   { transform: translate3d(0, 100vh, 0); opacity: 0; }
    10%  { opacity: 1; }
    90%  { opacity: 1; }
    100% { transform: translate3d(var(--drift, 0px), -20vh, 0); opacity: 0; }
}

/* ============== Chapter / Section Scaffold ============== */
.chapter {
    min-height: 100vh;
    position: relative;
    overflow: hidden;
    padding-block: var(--rhythm);
    /* 16-column grid per DESIGN.md: cols 1-2 spine (reserved), 3-14 content, 15-16 margin */
    display: grid;
    grid-template-columns: repeat(16, 1fr);
    column-gap: 0;
}

.chapter-content {
    grid-column: 3 / span 12;
    padding: 0 var(--gutter);
    position: relative;
    z-index: 2;
    opacity: 0;
    transform: translateY(28px);
    transition:
        opacity 0.9s var(--ease-glide),
        transform 0.9s var(--ease-glide),
        clip-path 0.9s var(--ease-glide);
    /* Page-turn initial state: folded corner */
    clip-path: polygon(0% 0%, 100% 0%, 100% 0%, 0% 0%);
}

.chapter-content.visible {
    opacity: 1;
    transform: translateY(0);
    clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%);
}

.chapter-content.page-turning {
    animation: pageTurnReveal 0.9s var(--ease-glide) forwards;
}

@keyframes pageTurnReveal {
    0%   { clip-path: polygon(0% 0%, 15% 0%, 0% 15%, 0% 0%); opacity: 0; }
    50%  { clip-path: polygon(0% 0%, 100% 0%, 60% 100%, 0% 80%); opacity: 0.7; }
    100% { clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%); opacity: 1; }
}

/* ============== Wave Bands (F-bar undulating edges) ============== */
.wave-band {
    position: absolute;
    left: 0;
    width: 100%;
    height: 90px;
    z-index: 2;
    pointer-events: none;
    background: linear-gradient(180deg, transparent, rgba(78, 234, 219, 0.03));
}

.wave-band-top {
    top: -1px;
    clip-path: polygon(0% 0%, 25% 55%, 50% 40%, 75% 60%, 100% 0%, 100% 100%, 0% 100%);
}

.wave-band-bottom {
    bottom: -1px;
    clip-path: polygon(0% 0%, 25% 55%, 50% 40%, 75% 60%, 100% 0%, 100% 100%, 0% 100%);
    transform: scaleY(-1);
}

/* ============== Chapter Backgrounds (gradient depth layers) ============== */
.chapter-surface {
    background: linear-gradient(180deg,
        var(--parchment) 0%,
        #c9b997 35%,
        var(--teal) 70%,
        var(--abyss) 100%);
}

.chapter-descent {
    background: linear-gradient(180deg,
        var(--abyss) 0%,
        var(--teal) 40%,
        var(--kelp) 100%);
}

.chapter-library {
    background: linear-gradient(180deg,
        var(--kelp) 0%,
        var(--abyss) 50%,
        #050E10 100%);
}

.chapter-specimens {
    background: linear-gradient(180deg,
        #050E10 0%,
        var(--abyss) 40%,
        #030A0B 100%);
}

.chapter-abyss {
    background: linear-gradient(180deg,
        #030A0B 0%,
        #010506 55%,
        #000203 100%);
}

/* ============== Chapter Header ============== */
.chapter-header {
    text-align: center;
    margin-bottom: clamp(3rem, 6vh, 5rem);
}

.chapter-tag {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.35em;
    color: var(--amber);
    opacity: 0.75;
    text-transform: uppercase;
    margin-bottom: 20px;
}

.section-heading {
    font-family: var(--font-heading);
    font-size: clamp(36px, 5.5vw, 56px);
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--parchment);
    line-height: 1.15;
    text-shadow: 0 0 40px rgba(78, 234, 219, 0.08);
}

.section-heading::after {
    content: '';
    display: block;
    width: 64px;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--amber), transparent);
    margin: 18px auto 0;
}

.section-subtitle {
    font-family: var(--font-body);
    font-style: italic;
    font-size: clamp(14px, 1.6vw, 17px);
    color: var(--parchment);
    opacity: 0.65;
    margin-top: 14px;
    letter-spacing: 0.02em;
}

/* ============== Hero / Chapter I ============== */
.chapter-surface .chapter-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - var(--rhythm) * 2);
    text-align: center;
}

.hero-meta {
    display: flex;
    align-items: center;
    gap: 14px;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.2em;
    color: var(--kelp);
    opacity: 0.7;
    text-transform: uppercase;
    margin-bottom: 36px;
}

.hero-meta-divider {
    width: 40px;
    height: 1px;
    background: var(--amber);
    opacity: 0.6;
}

.book-ornament {
    display: flex;
    align-items: stretch;
    justify-content: center;
    gap: 3px;
    margin-bottom: 40px;
    height: 68px;
}

.book-page {
    width: 46px;
    height: 68px;
    border: 1px solid var(--amber);
    background: rgba(232, 213, 183, 0.35);
    padding: 8px 6px;
    position: relative;
}

.book-page-left {
    transform: perspective(260px) rotateY(18deg);
    transform-origin: right center;
}

.book-page-right {
    transform: perspective(260px) rotateY(-18deg);
    transform-origin: left center;
}

.book-page-lines {
    display: flex;
    flex-direction: column;
    gap: 5px;
    height: 100%;
}

.book-page-lines span {
    height: 1px;
    background: var(--amber);
    opacity: 0.5;
    display: block;
}

.book-page-lines span:nth-child(2) { width: 75%; }
.book-page-lines span:nth-child(3) { width: 60%; }

.book-spine-ornament {
    width: 7px;
    height: 68px;
    background: linear-gradient(180deg, var(--amber), #8f6808 50%, var(--amber));
    border-radius: 1px;
    box-shadow: 0 0 12px rgba(184, 134, 11, 0.3);
}

.hero-title {
    font-family: var(--font-heading);
    font-size: clamp(56px, 12vw, 120px);
    font-weight: 700;
    letter-spacing: 0.04em;
    line-height: 1;
    color: var(--kelp);
    margin-bottom: 24px;
    display: flex;
    justify-content: center;
    gap: 0.04em;
    transition: color 1.5s var(--ease-glide);
}

.hero-letter {
    display: inline-block;
    opacity: 0;
    transform: translateY(-40px);
    animation: heroLetterDrop 0.9s var(--ease-glide) forwards;
    animation-delay: var(--letter-delay, 0s);
}

@keyframes heroLetterDrop {
    0%   { opacity: 0; transform: translateY(-40px); }
    70%  { opacity: 1; transform: translateY(6px); }
    100% { opacity: 1; transform: translateY(0); }
}

.hero-subtitle {
    font-family: var(--font-body);
    font-size: clamp(15px, 1.8vw, 20px);
    font-style: italic;
    line-height: 1.7;
    color: var(--kelp);
    max-width: 540px;
    letter-spacing: 0.01em;
    margin-bottom: 56px;
    opacity: 0;
    animation: fadeIn 1s 2.2s var(--ease-glide) forwards;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 0.85; transform: translateY(0); }
}

.marginalia {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.35;
    color: var(--amber);
    pointer-events: none;
}

.marginalia-left  { left: clamp(-20px, 2vw, 20px); }
.marginalia-right { right: clamp(-20px, 2vw, 20px); }

.marginalia-svg {
    width: 48px;
    height: 112px;
}

.scroll-hint {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    color: var(--kelp);
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    opacity: 0;
    animation: fadeIn 1s 2.8s var(--ease-glide) forwards;
    margin-top: 12px;
}

.scroll-hint-text { opacity: 0.6; }

.scroll-arrow {
    animation: arrowBounce 1.8s ease-in-out infinite;
    opacity: 0.7;
}

.paddle-icon {
    animation: paddlePulse 2.4s ease-in-out infinite;
    opacity: 0.5;
    margin-top: 4px;
}

@keyframes arrowBounce {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(8px); }
}

@keyframes paddlePulse {
    0%, 100% { transform: rotate(-4deg); opacity: 0.4; }
    50%      { transform: rotate(4deg);  opacity: 0.7; }
}

/* ============== F-Bars (Chapter II) ============== */
.f-bar {
    position: relative;
    margin-bottom: clamp(3rem, 6vh, 5rem);
}

.f-bar-wide {
    width: 85%;
    margin-left: 0;
    margin-right: auto;
    padding: 2.5rem 2rem;
    background: rgba(26, 47, 42, 0.45);
    border-top: 1px solid var(--amber-30);
    border-bottom: 1px solid var(--amber-30);
    clip-path: polygon(0% 6%, 100% 0%, 100% 94%, 0% 100%);
}

.f-bar-mid {
    width: 60%;
    margin-left: 8%;
    margin-right: auto;
    padding: 2rem 2rem;
    background: rgba(9, 31, 32, 0.55);
    border-left: 2px solid var(--amber);
    clip-path: polygon(0% 0%, 100% 4%, 100% 96%, 0% 100%);
}

.narrative-block {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 2.5rem;
    align-items: center;
}

@media (max-width: 768px) {
    .narrative-block {
        grid-template-columns: 1fr;
    }
    .f-bar-wide,
    .f-bar-mid {
        width: 100%;
        margin-left: 0;
    }
}

.pull-quote {
    font-family: var(--font-body);
    font-size: clamp(17px, 1.7vw, 20px);
    line-height: 1.9;
    color: var(--parchment);
    font-style: normal;
}

.pull-quote em {
    color: var(--cyan);
    font-style: italic;
}

.drop-cap {
    float: left;
    font-family: var(--font-heading);
    font-style: italic;
    font-size: 4.2em;
    line-height: 0.85;
    padding: 0.08em 0.14em 0 0;
    color: var(--cyan);
    text-shadow: 0 0 16px rgba(78, 234, 219, 0.25);
    font-weight: 700;
}

/* Book illustration: flutter pages */
.book-illustration {
    width: 140px;
    flex-shrink: 0;
}

.open-book {
    position: relative;
    display: grid;
    grid-template-columns: 1fr 4px 1fr;
    height: 110px;
    perspective: 400px;
}

.open-book-page {
    background: var(--parchment-15);
    border: 1px solid var(--amber-30);
    position: relative;
    overflow: hidden;
}

.open-book-page::before {
    content: '';
    position: absolute;
    left: 12%;
    right: 12%;
    top: 20%;
    bottom: 20%;
    background: repeating-linear-gradient(180deg,
        transparent 0px,
        transparent 8px,
        rgba(232, 213, 183, 0.4) 8px,
        rgba(232, 213, 183, 0.4) 9px);
}

.open-book-left  { transform: rotateY(12deg); transform-origin: right center; }
.open-book-right { transform: rotateY(-12deg); transform-origin: left center; }
.open-book-spine { background: linear-gradient(180deg, var(--amber), #8f6808, var(--amber)); }

.open-book-flutter {
    position: absolute;
    top: 0;
    right: 50%;
    width: 48%;
    height: 100%;
    background: var(--parchment-15);
    border: 1px solid var(--amber-30);
    transform-origin: right center;
    animation: pageFlutter 5s ease-in-out infinite;
    opacity: 0.6;
}

@keyframes pageFlutter {
    0%, 100% { transform: rotateY(0deg); }
    35%      { transform: rotateY(-170deg); }
    65%      { transform: rotateY(-170deg); }
}

/* ============== Marginalia Sidebar (second F-bar) ============== */
.marginalia-sidebar {
    font-family: var(--font-body);
    font-style: italic;
    font-size: 15px;
    line-height: 1.7;
    color: var(--parchment);
    opacity: 0.9;
}

.marginalia-marker {
    display: inline-block;
    font-family: var(--font-mono);
    font-style: normal;
    font-size: 11px;
    letter-spacing: 0.2em;
    color: var(--amber);
    margin-bottom: 12px;
    text-transform: uppercase;
    opacity: 0.85;
}

.marginalia-sidebar em {
    color: var(--cyan);
    font-weight: 500;
}

.marginalia-rule {
    display: block;
    height: 1px;
    margin: 16px 0;
    background: linear-gradient(90deg, var(--amber), transparent);
    opacity: 0.4;
}

.marginalia-annotation {
    font-size: 13px;
    opacity: 0.7;
    font-style: normal;
    font-family: var(--font-mono);
    letter-spacing: 0.02em;
}

.inline-link {
    color: var(--amber);
    text-decoration: none;
    border-bottom: 1px dotted var(--amber-60);
    transition: color 0.3s ease, border-color 0.3s ease, text-shadow 0.3s ease;
}

.inline-link:hover {
    color: var(--cyan);
    border-bottom-color: var(--cyan);
    text-shadow: 0 0 8px rgba(78, 234, 219, 0.4);
}

.inline-link:visited {
    color: var(--violet);
}

/* ============== Plankton Gap ============== */
.plankton-gap {
    position: relative;
    height: 120px;
    width: 100%;
    overflow: visible;
    margin: 2rem 0;
}

.plankton {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--cyan) 0%, transparent 70%);
    box-shadow: 0 0 10px var(--cyan), 0 0 20px rgba(78, 234, 219, 0.3);
    opacity: 0;
    animation: planktonFloat 6s ease-in-out infinite;
}

.plankton.p1 { left: 8%;  top: 20%; animation-delay: 0s;   animation-duration: 5s; }
.plankton.p2 { left: 18%; top: 70%; animation-delay: 0.7s; animation-duration: 6s; background: radial-gradient(circle, var(--violet), transparent 70%); box-shadow: 0 0 10px var(--violet); }
.plankton.p3 { left: 32%; top: 30%; animation-delay: 1.2s; animation-duration: 7s; }
.plankton.p4 { left: 45%; top: 80%; animation-delay: 1.8s; animation-duration: 5.5s; }
.plankton.p5 { left: 58%; top: 40%; animation-delay: 0.4s; animation-duration: 6.5s; background: radial-gradient(circle, var(--amber), transparent 70%); box-shadow: 0 0 10px var(--amber); }
.plankton.p6 { left: 72%; top: 65%; animation-delay: 2.2s; animation-duration: 5s; }
.plankton.p7 { left: 82%; top: 25%; animation-delay: 1.0s; animation-duration: 6s; }
.plankton.p8 { left: 92%; top: 55%; animation-delay: 1.6s; animation-duration: 7s; background: radial-gradient(circle, var(--violet), transparent 70%); box-shadow: 0 0 10px var(--violet); }

@keyframes planktonFloat {
    0%   { opacity: 0; transform: translate(0, 20px) scale(0.6); }
    25%  { opacity: 1; }
    50%  { opacity: 0.85; transform: translate(6px, -10px) scale(1); }
    75%  { opacity: 1; transform: translate(-6px, -20px) scale(0.9); }
    100% { opacity: 0; transform: translate(0, -30px) scale(0.6); }
}

/* ============== Specimen Row / Cards ============== */
.specimen-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 28px;
    margin-top: 2rem;
}

@media (min-width: 720px) {
    .specimen-row { grid-template-columns: repeat(2, 1fr); }
}

.specimen-card,
.folio-card,
.specimen-jar {
    position: relative;
    background: rgba(13, 59, 62, 0.55);
    padding: 1px;
    overflow: hidden;
    transition: transform 0.5s var(--ease-glide), box-shadow 0.5s ease;
}

.specimen-card:hover,
.folio-card:hover,
.specimen-jar:hover {
    transform: translateY(-4px);
    box-shadow:
        0 0 24px rgba(78, 234, 219, 0.22),
        0 0 48px rgba(78, 234, 219, 0.12);
}

.card-inner {
    padding: clamp(1.6rem, 2.5vw, 2.4rem);
    position: relative;
    z-index: 2;
    background: rgba(9, 31, 32, 0.85);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.card-ordinal {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.3em;
    color: var(--amber);
    opacity: 0.75;
    margin-bottom: 10px;
    text-transform: uppercase;
}

.specimen-card h3,
.folio-card h3,
.specimen-jar h3 {
    font-family: var(--font-heading);
    font-size: clamp(20px, 2vw, 24px);
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--cyan);
    margin-bottom: 14px;
    line-height: 1.3;
    text-shadow: 0 0 12px rgba(78, 234, 219, 0.15);
}

.specimen-card p,
.folio-card p,
.specimen-jar p {
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.85;
    color: var(--pearl);
    opacity: 0.82;
}

.card-footer {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--amber-30);
}

.card-meta {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.15em;
    color: var(--amber);
    opacity: 0.6;
}

/* ============== Border-Glow (traveling-light animation) ============== */
/* Per DESIGN.md spec: linear-gradient with background-position travel */
.border-glow {
    position: relative;
    isolation: isolate;
}

.border-glow::before {
    content: '';
    position: absolute;
    inset: -1px;
    background: linear-gradient(90deg,
        var(--teal),
        var(--cyan),
        var(--violet),
        var(--cyan),
        var(--teal));
    background-size: 300% 100%;
    animation: borderTravel 8s linear infinite;
    z-index: -1;
    opacity: 0;
    transition: opacity 0.6s var(--ease-glide);
}

.border-glow.in-view::before,
.border-glow:hover::before {
    opacity: 1;
}

@keyframes borderTravel {
    0%   { background-position:   0% 50%; }
    100% { background-position: 300% 50%; }
}

/* ============== Jellyfish Float (Chapter II decoration) ============== */
.jellyfish-float {
    position: absolute;
    right: clamp(-80px, 2vw, 40px);
    top: 25%;
    opacity: 0.45;
    pointer-events: none;
    animation: jellyfishDrift 9s ease-in-out infinite;
    filter: drop-shadow(0 0 16px rgba(78, 234, 219, 0.35));
}

.jellyfish-svg {
    width: clamp(120px, 14vw, 180px);
    height: auto;
}

@keyframes jellyfishDrift {
    0%, 100% { transform: translateY(0)    rotate(0deg); }
    25%      { transform: translateY(-24px) rotate(2.5deg); }
    50%      { transform: translateY(-12px) rotate(-1.5deg); }
    75%      { transform: translateY(-30px) rotate(1deg); }
}

@media (max-width: 1024px) {
    .jellyfish-float { display: none; }
}

/* ============== Library Grid (Chapter III) ============== */
.library-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 28px;
    margin-bottom: 4rem;
}

@media (min-width: 720px) {
    .library-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1100px) {
    .library-grid { grid-template-columns: repeat(3, 1fr); }
}

.folio-number {
    font-family: var(--font-heading);
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.18em;
    color: var(--amber);
    margin-bottom: 12px;
    opacity: 0.8;
    text-transform: uppercase;
}

.folio-ornament {
    margin-top: 20px;
    opacity: 0.5;
    color: var(--amber);
}

.ornament-line {
    width: 100%;
    height: 20px;
}

.folio-footnote {
    display: block;
    margin-top: 14px;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.15em;
    color: var(--amber);
    opacity: 0.6;
    text-transform: lowercase;
}

/* ============== Book Transition ============== */
.book-transition {
    display: flex;
    justify-content: center;
    padding: 3rem 0;
    perspective: 600px;
}

.book-spread {
    display: flex;
    align-items: stretch;
    gap: 0;
    cursor: pointer;
}

.book-leaf {
    width: 120px;
    height: 160px;
    background: rgba(232, 213, 183, 0.08);
    border: 1px solid var(--amber-30);
    padding: 18px 14px;
    position: relative;
    overflow: hidden;
    transition: transform 0.8s var(--ease-glide);
}

.book-leaf-left  { transform: rotateY(12deg); transform-origin: right center; }
.book-leaf-right { transform: rotateY(-12deg); transform-origin: left center; }

.book-spread:hover .book-leaf-left  { transform: rotateY(-45deg); }
.book-spread:hover .book-leaf-right { transform: rotateY(45deg); }

.book-gutter {
    width: 8px;
    background: linear-gradient(90deg,
        var(--amber-60),
        rgba(184, 134, 11, 0.15),
        var(--amber-60));
    box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.5);
}

.leaf-lines span {
    display: block;
    height: 1px;
    background: rgba(232, 213, 183, 0.25);
    margin-bottom: 14px;
    width: 100%;
}

.leaf-lines span:nth-child(3) { width: 70%; }
.leaf-lines span:nth-child(5) { width: 50%; }

.leaf-page-num {
    position: absolute;
    bottom: 8px;
    left: 0;
    right: 0;
    text-align: center;
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--amber);
    opacity: 0.5;
}

/* ============== Wave Divider ============== */
.wave-divider {
    margin: 3rem auto 1rem;
    width: 60%;
    max-width: 600px;
    opacity: 0.7;
}

.wave-divider svg {
    width: 100%;
    height: 40px;
}

/* ============== Specimen Gallery (Chapter IV) ============== */
.specimen-gallery {
    display: grid;
    grid-template-columns: 1fr;
    gap: 28px;
}

@media (min-width: 720px) {
    .specimen-gallery { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1100px) {
    .specimen-gallery { grid-template-columns: repeat(3, 1fr); }
}

.specimen-jar {
    text-align: center;
}

.specimen-jar .card-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 380px;
}

.jar-glow {
    position: absolute;
    top: 34%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(78, 234, 219, 0.12) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
    animation: jarGlowPulse 4s ease-in-out infinite;
}

@keyframes jarGlowPulse {
    0%, 100% { opacity: 0.7; transform: translate(-50%, -50%) scale(1); }
    50%      { opacity: 1;   transform: translate(-50%, -50%) scale(1.1); }
}

.jar-creature {
    margin-bottom: 20px;
    position: relative;
    z-index: 2;
    animation: creatureFloat 6s ease-in-out infinite;
}

@keyframes creatureFloat {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50%      { transform: translateY(-8px) rotate(1deg); }
}

.creature-svg {
    width: 110px;
    height: 110px;
    filter: drop-shadow(0 0 10px rgba(78, 234, 219, 0.4));
}

.specimen-meta {
    font-family: var(--font-mono);
    font-size: 11px !important;
    letter-spacing: 0.1em !important;
    color: var(--amber) !important;
    opacity: 0.75 !important;
    margin-bottom: 12px;
    text-transform: uppercase;
}

.specimen-tag {
    margin-top: 18px;
    padding: 8px 14px;
    border: 1px solid var(--amber-30);
    display: inline-flex;
    gap: 8px;
    align-items: center;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

.tag-label { color: var(--amber); opacity: 0.7; }
.tag-id    { color: var(--cyan); }

/* ============== Abyss (Chapter V) ============== */
.abyss-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: clamp(3rem, 6vh, 5rem);
}

.abyss-quote {
    max-width: 680px;
    position: relative;
    padding: 3rem 2.5rem 3rem 3.5rem;
    border-left: 2px solid var(--amber);
    text-align: left;
    background: rgba(9, 31, 32, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.quote-mark {
    position: absolute;
    top: 8px;
    left: 16px;
    font-family: var(--font-heading);
    font-style: italic;
    font-size: 72px;
    line-height: 1;
    color: var(--cyan);
    opacity: 0.4;
    text-shadow: 0 0 24px rgba(78, 234, 219, 0.3);
}

.abyss-quote p {
    font-family: var(--font-body);
    font-size: clamp(17px, 1.9vw, 22px);
    font-style: italic;
    line-height: 1.85;
    color: var(--parchment);
    margin-bottom: 1rem;
}

.abyss-quote cite {
    display: block;
    margin-top: 18px;
    font-family: var(--font-mono);
    font-size: 11px;
    font-style: normal;
    letter-spacing: 0.15em;
    color: var(--amber);
    opacity: 0.75;
    text-transform: uppercase;
}

/* Typewriter closing line */
.abyss-typewriter {
    font-family: var(--font-heading);
    font-style: italic;
    font-size: clamp(18px, 2.2vw, 26px);
    letter-spacing: 0.02em;
    color: var(--cyan);
    text-shadow:
        0 0 12px rgba(78, 234, 219, 0.55),
        0 0 28px rgba(78, 234, 219, 0.25);
    min-height: 2em;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
}

.typewriter-caret {
    display: inline-block;
    width: 2px;
    height: 1em;
    background: var(--cyan);
    box-shadow: 0 0 8px var(--cyan);
    animation: caretBlink 1s step-end infinite;
    margin-left: 4px;
}

@keyframes caretBlink {
    0%, 50%    { opacity: 1; }
    50.01%, 100% { opacity: 0; }
}

/* Compass rose + ascend */
.abyss-cta {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.compass-rose {
    margin-bottom: 8px;
    animation: compassSpin 36s linear infinite;
    opacity: 0.85;
}

.compass-svg {
    width: 110px;
    height: 110px;
    filter: drop-shadow(0 0 10px rgba(184, 134, 11, 0.25));
}

@keyframes compassSpin {
    0%   { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.cta-text {
    font-family: var(--font-body);
    font-style: italic;
    font-size: 15px;
    color: var(--pearl);
    opacity: 0.65;
    max-width: 460px;
}

.ascend-button {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 14px 34px;
    border: 1px solid var(--amber);
    background: transparent;
    color: var(--parchment);
    text-decoration: none;
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    transition: all 0.55s var(--ease-glide);
    position: relative;
    overflow: hidden;
}

.ascend-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg,
        transparent,
        rgba(78, 234, 219, 0.18),
        transparent);
    transition: left 0.7s var(--ease-glide);
}

.ascend-button:hover::before { left: 100%; }

.ascend-button:hover {
    border-color: var(--cyan);
    color: var(--cyan);
    box-shadow:
        0 0 20px rgba(78, 234, 219, 0.3),
        0 0 40px rgba(78, 234, 219, 0.15);
}

/* Tentacle decoration */
.tentacle-decoration {
    position: absolute;
    bottom: 40px;
    left: 0;
    width: 100%;
    height: 220px;
    pointer-events: none;
    opacity: 0.7;
}

.tentacle-svg {
    width: 100%;
    height: 100%;
    animation: tentacleWave 12s ease-in-out infinite alternate;
}

@keyframes tentacleWave {
    0%   { transform: translateY(0)    scaleX(1); }
    100% { transform: translateY(-8px) scaleX(1.05); }
}

/* Colophon */
.colophon {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-top: 5rem;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--amber);
    opacity: 0.55;
}

.colophon-rule {
    display: block;
    flex: 1;
    max-width: 100px;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--amber), transparent);
}

/* ============== Responsive ============== */
@media (max-width: 900px) {
    .chapter-content {
        grid-column: 2 / span 14;
        padding: 0 clamp(1rem, 4vw, 2.5rem);
    }

    #spine-column {
        width: 50px;
        left: 8px;
    }

    .spine-label,
    .spine-top-label,
    .spine-bottom-label {
        display: none;
    }

    .marginalia { display: none; }
}

@media (max-width: 600px) {
    body { font-size: 16px; }

    .chapter-content {
        grid-column: 1 / span 16;
        padding: 0 1rem;
    }

    .f-bar-wide,
    .f-bar-mid {
        width: 100%;
        margin-left: 0;
        clip-path: none;
        padding: 1.5rem 1.25rem;
    }

    .hero-title      { font-size: clamp(44px, 14vw, 80px); }
    .section-heading { font-size: clamp(28px, 7vw, 40px); }

    #depth-indicator {
        right: 8px;
        bottom: 8px;
        padding: 8px 12px;
    }

    .depth-value { font-size: 15px; }

    #spine-column { width: 40px; }
}
