/* ===========================================================
   continua.quest — A Scandinavian dive log on continuation.
   Palette (sunset-warm against cold paper, hand-mixed):
     #f1e8d4  Munken cream      #2a221b  archival ink
     #e8dcc1  vellum shadow     #c14a2b  sunset rust
     #e08545  reef coral        #f2c66e  Lofoten gold
     #7a5b3e  foxing umber      #3a5d6e  cold-water indigo
     #bcd2da  pencil grid (12-col rule)
   Typography:
     EB Garamond, Cormorant Garamond, IM Fell DW Pica.
   =========================================================== */

:root {
    --cream:   #f1e8d4;
    --vellum:  #e8dcc1;
    --ink:     #2a221b;
    --rust:    #c14a2b;
    --coral:   #e08545;
    --gold:    #f2c66e;
    --umber:   #7a5b3e;
    --indigo:  #3a5d6e;
    --pencil:  #bcd2da;

    --serif:    "EB Garamond", "Cormorant Garamond", Georgia, serif;
    --display:  "Cormorant Garamond", "EB Garamond", Georgia, serif;
    --margin:   "IM Fell DW Pica", "EB Garamond", Georgia, serif;

    /* Plate scroll multipliers */
    --scroll: 0px;
    --plate-1-rate: 0.96;
    --plate-3-rate: 1.04;
    --plate-5-rate: 1.08;
    --plate-6-rate: 1.14;

    /* Text column position (off-center to the right) */
    --col-start: 38%;
    --col-end:   84%;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
    background: var(--cream);
    color: var(--ink);
    font-family: var(--serif);
    font-size: 1.07rem;
    line-height: 1.62;
    letter-spacing: 0;
    font-feature-settings: "smcp" 0, "liga" 1, "kern" 1;
    overflow-x: hidden;
    min-height: 100vh;
}

/* =====================================================
   PLATES — print-plate registration parallax
   ===================================================== */

.plate {
    position: fixed;
    inset: 0;
    pointer-events: none;
    will-change: transform;
}

/* Plate 0 — Stock: cream paper field with noise+fiber */
.plate-0 {
    background: var(--cream);
    z-index: -10;
}
.plate-0::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 12%, rgba(241, 232, 212, 0) 60%, rgba(122, 91, 62, 0.06) 100%),
        radial-gradient(ellipse at 88% 92%, rgba(241, 232, 212, 0) 55%, rgba(122, 91, 62, 0.07) 100%);
    pointer-events: none;
}
.paper-noise {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0.55;
    mix-blend-mode: multiply;
}

/* Plate 1 — Foxing: aged-paper blooms */
.plate-1 {
    z-index: -9;
    transform: translateY(calc(var(--scroll) * (var(--plate-1-rate) - 1)));
    height: 600vh;
}
.plate-1 svg {
    width: 100%;
    height: 100%;
    mix-blend-mode: multiply;
    opacity: 0.8;
}

/* Plate 2 — Rule grid: 12-column pencil-blue */
.plate-2 {
    z-index: -8;
    height: 100vh;
}
.grid-rules {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    padding: 0 4vw;
    opacity: 0.5;
}
.grid-rules > span {
    border-right: 1px solid var(--pencil);
}
.grid-rules > span:first-child {
    border-left: 1px solid var(--pencil);
}

/* Plate 6 — Marginalia stamp (corner) */
.plate-6 {
    z-index: 5;
    transform: translateY(calc(var(--scroll) * (var(--plate-6-rate) - 1)));
}
.corner-stamp {
    position: absolute;
    top: 24px;
    right: 28px;
    width: 84px;
    height: 84px;
    transform: rotate(-8deg);
    opacity: 0.85;
}

/* =====================================================
   FOLIO — main document container
   ===================================================== */

.folio {
    position: relative;
    z-index: 1;
    max-width: 100%;
    padding: 6rem 4vw 6rem;
}

/* =====================================================
   CHAPTERS — long vertical document, two-column layout
   ===================================================== */

.chapter {
    position: relative;
    display: grid;
    grid-template-columns: 32% 1fr;
    column-gap: 4%;
    min-height: 132vh;
    padding: 6rem 0 4rem;
    align-items: start;
}

.gutter {
    position: relative;
    padding-right: 1rem;
    padding-top: 0.5rem;
    border-right: 1px solid rgba(58, 93, 110, 0.18);
}

.textblock {
    position: relative;
    max-width: 540px;
    padding-left: 0.4rem;
}

/* margin-note: the lab-notebook annotations */
.margin-note {
    font-family: var(--margin);
    font-size: 0.84em;
    color: var(--indigo);
    line-height: 1.45;
    margin-bottom: 1.4rem;
}
.margin-note .folio-num {
    display: block;
    text-align: center;
    color: var(--rust);
    font-family: var(--margin);
    font-size: 0.86em;
    letter-spacing: 0.18em;
    margin-bottom: 0.6rem;
    transform: translateY(calc(var(--scroll) * (var(--plate-6-rate) - 1) * 0.06));
}
.margin-note .annotation {
    margin: 0 0 0.7rem 0;
    font-style: italic;
    color: var(--indigo);
}
.margin-note .annotation em {
    font-style: normal;
    color: var(--ink);
}
.margin-note .footmark {
    color: var(--rust);
    font-size: 1em;
    margin-right: 0.18em;
}

.iso-sketch {
    width: 100%;
    max-width: 200px;
    display: block;
    margin-top: 0.4rem;
    opacity: 0.85;
}

/* =====================================================
   SECTION MARKERS, headings, drop caps
   ===================================================== */

.section-marker {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    margin-bottom: 1.4rem;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid var(--rust);
    transform: translateY(calc(var(--scroll) * (var(--plate-5-rate) - 1) * 0.06));
}
.section-marker .numeral {
    font-family: var(--display);
    font-size: clamp(1.6rem, 2.8vw, 2.4rem);
    font-weight: 500;
    color: var(--rust);
    letter-spacing: 0.02em;
}
.section-marker .chapter-name {
    font-family: var(--display);
    font-size: clamp(1.4rem, 2.4vw, 2rem);
    font-weight: 300;
    color: var(--ink);
    letter-spacing: 0.005em;
}

h1.site-title {
    font-family: var(--display);
    font-size: clamp(2.4rem, 5.2vw, 4.4rem);
    font-weight: 300;
    letter-spacing: 0.005em;
    color: var(--ink);
    margin: 0 0 0.4rem 0;
    line-height: 1.05;
}
h1.site-title .dot {
    color: var(--rust);
    margin: 0 -0.04em;
}

.site-sub {
    font-family: var(--display);
    font-style: italic;
    font-size: 1.18rem;
    color: var(--indigo);
    margin: 0 0 2.2rem 0;
    font-weight: 300;
}

.lead { margin-top: 0.8rem; }

p {
    margin: 0 0 1.05em 0;
    text-align: justify;
    text-justify: inter-word;
    hyphens: auto;
}

.dropcap {
    float: left;
    font-family: var(--display);
    font-weight: 600;
    color: var(--rust);
    font-size: 5em;
    line-height: 0.86;
    padding: 0.05em 0.08em 0 0;
    margin: 0.05em 0.06em -0.06em 0;
    font-style: normal;
}

em {
    font-style: italic;
    /* Latin binomials are italic; this is the only italic in body. */
}

/* fleuron divider — minnow glyphs */
.fleuron {
    text-align: center;
    margin: 2.4rem 0;
    opacity: 0.9;
}
.fleuron svg {
    width: 80px;
    height: 14px;
}

/* =====================================================
   §I. Premise — library stamp, slow rotation
   ===================================================== */

.library-stamp {
    width: 220px;
    height: 220px;
    margin: 0 auto 1.6rem;
    animation: stamp-rotate 40s linear infinite;
}
.library-stamp svg { width: 100%; height: 100%; }

@keyframes stamp-rotate {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

.margin-i {
    margin-top: 1.2rem;
}

/* =====================================================
   §II. The Limit — three poses + asymptote
   ===================================================== */

.hero-fish {
    margin: 2rem 0 2.4rem;
}
.three-poses {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    gap: 1.4rem 2rem;
    align-items: end;
    margin-bottom: 1.6rem;
}
.three-poses .pose {
    text-align: center;
}
.three-poses .pose svg {
    width: 100%;
    max-width: 220px;
    height: auto;
}
.three-poses .pose figcaption {
    font-family: var(--margin);
    font-size: 0.84em;
    color: var(--indigo);
    margin-top: 0.4rem;
    font-style: italic;
}
.three-poses .pose-hero {
    grid-column: 1 / -1;
    margin-top: 0.6rem;
}
.three-poses .pose-hero svg {
    max-width: 100%;
    width: 100%;
}

#asymptote-path {
    stroke-dasharray: 600;
    stroke-dashoffset: 600;
    transition: stroke-dashoffset 1.4s ease-out;
}
#asymptote-path.drawn { stroke-dashoffset: 0; }

.equation {
    font-family: var(--serif);
    font-size: 1.08rem;
    text-align: center;
    color: var(--ink);
    padding: 1.1rem 0.8rem;
    margin: 0.8rem 0;
    border-top: 1px solid var(--indigo);
    border-bottom: 1px solid var(--indigo);
    background: rgba(232, 220, 193, 0.4);
}
.equation .eq-text {
    font-style: italic;
}
.equation sub {
    font-size: 0.7em;
    font-style: italic;
}
.equation .eq-and::before { content: "and"; font-style: normal; color: var(--rust); font-size: 0.86em; padding: 0 0.4em; }

/* =====================================================
   §III. The Fish — school of yellow tangs
   ===================================================== */

.tang-school {
    position: relative;
    width: 100%;
    height: 520px;
    margin-top: 1.6rem;
    overflow: visible;
}
.tang {
    position: absolute;
    width: 38px;
    height: 26px;
    transition: transform 280ms cubic-bezier(0.2, 0.7, 0.3, 1);
    will-change: transform;
}
.tang svg { width: 100%; height: 100%; }
.tang:hover { transform: rotate(4deg) scale(1.06); }

/* =====================================================
   §IV. The Lesson — mandarinfish + shape-outside
   ===================================================== */

.mandarin-fig {
    margin: 2rem 0 2.4rem;
}
.mandarin-svg {
    float: left;
    width: 56%;
    max-width: 360px;
    height: auto;
    margin: 0.4rem 1.2rem 0.8rem 0;
    shape-outside: ellipse(50% 50% at 50% 50%);
    shape-margin: 0.4rem;
}
.lesson-text {
    overflow: visible;
}
.lesson-text p {
    margin-bottom: 1.05em;
}
.lesson-text .caption-it {
    font-style: italic;
    color: var(--indigo);
    border-left: 2px solid var(--rust);
    padding-left: 0.9rem;
    margin-top: 1.2rem;
    font-family: var(--display);
    font-size: 1.05rem;
}

/* clear after mandarinfig if needed */
.mandarin-fig::after {
    content: "";
    display: block;
    clear: both;
}

/* =====================================================
   §V. The Drill — interactive, shake-error, moray
   ===================================================== */

.moray-wrap {
    margin-top: 1.4rem;
    width: 100%;
    max-width: 220px;
}
.moray-wrap svg {
    width: 100%;
    height: auto;
}
#moray-mouth {
    transition: d 240ms cubic-bezier(0.4, 0.1, 0.4, 1);
}

.drills {
    margin: 1.6rem 0 1.4rem;
}
.drill {
    margin-bottom: 1.6rem;
    padding: 1rem 1.1rem;
    background: rgba(232, 220, 193, 0.36);
    border: 1px solid rgba(122, 91, 62, 0.22);
    border-left: 3px solid var(--rust);
}
.drill label {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    align-items: flex-start;
}
.drill-prompt {
    font-family: var(--serif);
    font-size: 1.18rem;
    color: var(--ink);
    letter-spacing: 0.02em;
}
.drill-prompt em {
    font-style: italic;
    color: var(--indigo);
}
.drill-input {
    font-family: var(--serif);
    font-size: 1.08rem;
    padding: 0.5rem 0.8rem;
    border: 1px solid var(--ink);
    background: var(--cream);
    color: var(--ink);
    border-radius: 0;
    width: 60%;
    max-width: 240px;
    outline: none;
    transition: background-color 220ms ease-out, border-color 220ms ease-out;
}
.drill-input:focus {
    border-color: var(--rust);
}
.drill-input.shaking {
    animation: shake-error 320ms ease-in-out;
    background: rgba(193, 74, 43, 0.18);
    border-color: var(--rust);
}
.drill-input.correct {
    border-color: var(--indigo);
    color: var(--indigo);
}
.drill.correct {
    border-left-color: var(--indigo);
    opacity: 0.78;
}
.drill-hint {
    font-family: var(--margin);
    font-size: 0.86em;
    color: var(--umber);
    font-style: italic;
    margin: 0.4rem 0 0;
}

@keyframes shake-error {
    0%, 100% { transform: translateX(0); }
    20%      { transform: translateX(-12px); }
    40%      { transform: translateX(11px); }
    60%      { transform: translateX(-7px); }
    80%      { transform: translateX(4px); }
}

@keyframes moray-yawn {
    0%, 100% { transform: scaleY(1); }
    50%      { transform: scaleY(1.4); }
}
.moray-head.yawn {
    transform-origin: 160px 158px;
    animation: moray-yawn 240ms ease-in-out;
}

.drills-foot {
    font-family: var(--margin);
    font-size: 0.9em;
    color: var(--indigo);
    font-style: italic;
    margin-top: 1rem;
}
.drills-foot.complete::after {
    content: "  ✓ continued.";
    color: var(--rust);
    font-style: normal;
    margin-left: 0.4em;
}

/* =====================================================
   §VI. Colophon — back-page in IM Fell
   ===================================================== */

.textblock-colophon {
    font-family: var(--margin);
    color: var(--ink);
    font-size: 0.96rem;
    line-height: 1.7;
}
.textblock-colophon p { font-family: var(--margin); }
.colophon-line {
    font-style: italic;
    color: var(--indigo);
    margin-bottom: 1.4rem;
}
.ref-plate {
    list-style: none;
    padding: 0;
    margin: 1rem 0 1.6rem;
    border-top: 1px solid var(--umber);
    border-bottom: 1px solid var(--umber);
    padding: 0.8rem 0;
}
.ref-plate li {
    padding: 0.16rem 0;
    color: var(--umber);
    font-size: 0.92rem;
    font-style: italic;
}
.ref-plate li em { color: var(--ink); font-style: italic; }

.isbn {
    font-family: var(--margin);
    color: var(--rust);
    letter-spacing: 0.16em;
    font-size: 0.9rem;
    text-transform: uppercase;
    margin-top: 1.2rem;
}

.wax-seal {
    margin: 2rem auto;
    width: 140px;
    height: 140px;
    filter: drop-shadow(2px 3px 0 rgba(42, 34, 27, 0.18));
}
.wax-seal svg { width: 100%; height: 100%; transform: rotate(-6deg); }

.finis {
    text-align: center;
    font-family: var(--display);
    font-style: italic;
    color: var(--rust);
    font-size: 1.2rem;
    margin-top: 2rem;
    letter-spacing: 0.08em;
}

/* =====================================================
   Latin binomial hover card
   ===================================================== */

.binomial-card {
    position: fixed;
    top: 0; left: 0;
    width: 200px;
    min-height: 64px;
    background: var(--cream);
    border: 1px solid var(--ink);
    padding: 0.6rem 0.7rem;
    font-family: var(--margin);
    color: var(--ink);
    font-size: 0.86rem;
    line-height: 1.32;
    box-shadow: 2px 2px 0 rgba(42, 34, 27, 0.14);
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%, calc(-100% - 8px));
    transition: opacity 180ms ease-out;
    z-index: 50;
}
.binomial-card.visible { opacity: 1; }
.card-silhouette {
    width: 56px;
    height: 28px;
    float: right;
    margin-left: 6px;
}
.card-silhouette svg { width: 100%; height: 100%; }
.card-name {
    margin: 0;
    font-style: italic;
    font-family: var(--serif);
    color: var(--rust);
    font-size: 0.96rem;
}
.card-common {
    margin: 0.2rem 0 0;
    color: var(--indigo);
}
em.binomial {
    cursor: help;
    background: linear-gradient(transparent 86%, rgba(224, 133, 69, 0.22) 86%);
}

/* =====================================================
   Intro stamp landing — first-paint moment
   ===================================================== */

.intro-stamp {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--cream);
    z-index: 100;
    opacity: 1;
    pointer-events: all;
    transition: opacity 480ms ease-out 200ms;
}
.intro-stamp svg {
    width: 220px;
    height: 220px;
    transform: rotate(5deg);
    transition: transform 600ms cubic-bezier(0.2, 0.8, 0.3, 1);
}
.intro-stamp.settled svg { transform: rotate(0deg); }
.intro-stamp.gone {
    opacity: 0;
    pointer-events: none;
}

/* =====================================================
   Custom cursors over fish illustrations + drill fields
   ===================================================== */

.hero-fish, .mandarin-fig, .tang-school, .moray-wrap, .library-stamp, .wax-seal {
    cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'><path d='M12 3v6M9 6h6M12 9c-2 4 0 8 0 12M8 14c0 0 4 4 8 0' stroke='%23c14a2b' stroke-width='1.6' fill='none' stroke-linecap='round'/></svg>") 12 12, default;
}

.drill-input {
    cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'><path d='M5 18 L18 5 L20 7 L7 20 Z M5 18 L4 21 L7 20' stroke='%23c14a2b' stroke-width='1.6' fill='%23f1e8d4' stroke-linecap='round'/></svg>") 5 18, text;
}

/* =====================================================
   Responsive — collapse to single column under 720px
   ===================================================== */

@media (max-width: 880px) {
    :root {
        --col-start: 8%;
        --col-end:   92%;
    }
    .chapter {
        grid-template-columns: 1fr;
        column-gap: 0;
        padding: 4rem 0 3rem;
        min-height: auto;
    }
    .gutter {
        border-right: none;
        border-bottom: 1px solid rgba(58, 93, 110, 0.18);
        padding-bottom: 1.2rem;
        margin-bottom: 1.4rem;
    }
    .textblock { max-width: 100%; }
    .three-poses { grid-template-columns: 1fr; }
    .three-poses .pose-hero { grid-column: 1; }
    .mandarin-svg {
        float: none;
        width: 100%;
        max-width: 360px;
        margin: 0 auto 1rem;
        display: block;
        shape-outside: none;
    }
    .tang-school { height: 320px; }
    .corner-stamp { top: 12px; right: 14px; width: 64px; height: 64px; }
}

@media (max-width: 480px) {
    body { font-size: 1rem; }
    .folio { padding: 2.4rem 5vw 4rem; }
    h1.site-title { font-size: 2.2rem; }
}

/* =====================================================
   Reduced motion — collapse all rates to 1.0
   ===================================================== */

@media (prefers-reduced-motion: reduce) {
    :root {
        --plate-1-rate: 1;
        --plate-3-rate: 1;
        --plate-5-rate: 1;
        --plate-6-rate: 1;
    }
    .library-stamp { animation: none; }
    .intro-stamp { transition: opacity 200ms; }
    .intro-stamp svg { transition: none; transform: none; }
    .drill-input.shaking { animation: none; background: rgba(193, 74, 43, 0.18); }
    .moray-head.yawn { animation: none; }
    #asymptote-path { transition: none; stroke-dashoffset: 0; }
    .tang { transition: none; }
    .plate-1, .plate-6 { transform: none !important; }
}
