/* =========================================================
   desca · work — Ethereal Blue Conservatory
   Twelve-plate folio in cyanotype on cotton
   ========================================================= */

:root {
    --cotton: #F4F1E8;
    --frostglass: #E8EEF5;
    --damp-morning: #C9D9EB;
    --cyanotype: #7FA1C9;
    --inkwell: #4A6FA5;
    --slate: #1F3047;
    --vapor: #B8C8E0;
    --pressed-rose: #E89AB8;
    --specimen-mint: #7FE0C9;
    --shear-magenta: #FF6B9E;
    --shear-cyan: #6BFFD0;
    --shear-yellow: #FFD66B;

    --serif-display: "Libre Baskerville", "Lora", Georgia, serif;
    --serif-body: "EB Garamond", "Lora", Georgia, serif;
    --smallcaps: "IM Fell English SC", "Lora", Georgia, serif;
    --mono: "DM Mono", "Inter", "Space Mono", monospace;
}

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

html, body {
    background: var(--cotton);
    color: var(--slate);
    font-family: var(--serif-body);
    font-size: 18px;
    line-height: 1.7;
    overflow-x: hidden;
    cursor: none;
}

body {
    position: relative;
    min-height: 100vh;
}

/* ===== Paper-grain overlay (subtle SVG noise via CSS) ===== */
.grain-overlay {
    position: fixed; inset: 0;
    pointer-events: none;
    z-index: 1;
    opacity: 0.05;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='280' height='280'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.29  0 0 0 0 0.19  0 0 0 0 0.27  0 0 0 0.6 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
    mix-blend-mode: multiply;
}

/* Guilloché back plane (visible only at edges) */
.guilloche-back {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: 0.42;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'><g fill='none' stroke='%23E8EEF5' stroke-width='0.5'><circle cx='40' cy='40' r='30'/><circle cx='120' cy='40' r='30'/><circle cx='40' cy='120' r='30'/><circle cx='120' cy='120' r='30'/><circle cx='80' cy='80' r='30'/><circle cx='40' cy='40' r='20'/><circle cx='120' cy='40' r='20'/><circle cx='40' cy='120' r='20'/><circle cx='120' cy='120' r='20'/><circle cx='80' cy='80' r='20'/></g></svg>");
    background-size: 160px 160px;
}

/* ===== Custom Cursor ===== */
.cursor {
    position: fixed;
    top: 0; left: 0;
    width: 48px; height: 48px;
    pointer-events: none;
    z-index: 10000;
    transform: translate(-50%, -50%);
    transition: opacity 0.3s;
    will-change: transform;
}
.cursor svg { width: 100%; height: 100%; overflow: visible; }
.cursor .cursor-fleuron { transform-origin: 24px 24px; transition: transform 0.4s ease; }
.cursor .cursor-ring {
    transform-origin: 24px 24px;
    opacity: 0;
    transition: opacity 0.3s ease;
    animation: ringRotate 16s linear infinite;
}
.cursor.is-hover .cursor-fleuron { transform: rotate(45deg); }
.cursor.is-hover .cursor-ring { opacity: 1; }

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

/* ===== Spine (right margin roman numerals) ===== */
.spine {
    position: fixed;
    right: 28px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 200;
    font-family: var(--smallcaps);
    color: var(--vapor);
    font-size: 0.84rem;
}
.spine ol { list-style: none; }
.spine li { padding: 4px 0; text-align: center; }
.spine a {
    color: var(--vapor);
    text-decoration: none;
    display: inline-block;
    padding: 2px 6px;
    transition: color 0.4s ease;
    letter-spacing: 0.04em;
    font-family: var(--serif-display);
    font-style: italic;
    font-size: 0.95rem;
}
.spine li.is-current a {
    color: var(--inkwell);
    position: relative;
}
.spine li.is-current a::before,
.spine li.is-current a::after {
    content: "❦";
    color: var(--cyanotype);
    font-size: 0.6rem;
    margin: 0 4px;
    opacity: 0.9;
}

/* ===== Sound Toggle ===== */
.sound-toggle {
    position: fixed;
    left: 28px;
    bottom: 28px;
    z-index: 200;
    background: transparent;
    border: none;
    color: var(--cyanotype);
    font-family: var(--serif-display);
    font-style: italic;
    font-size: 0.95rem;
    cursor: none;
    border-bottom: 1px solid var(--cyanotype);
    padding: 2px 4px;
    transition: color 0.3s ease, border-color 0.3s ease;
}
.sound-toggle:hover, .sound-toggle.is-on {
    color: var(--inkwell);
    border-color: var(--inkwell);
}

/* ===== Floating leaves layer ===== */
.leaves-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 5;
    overflow: hidden;
}
.leaf {
    position: absolute;
    opacity: 0.55;
    will-change: transform;
}

/* ===== Folio (main vertical procession) ===== */
.folio {
    position: relative;
    z-index: 10;
}

/* ===== Plate (vitrine) ===== */
.plate {
    position: relative;
    min-height: 100vh;
    padding: 0;
    display: flex;
    flex-direction: column;
    justify-content: stretch;
}
.plate:nth-child(even) { background: linear-gradient(to bottom, var(--cotton) 0%, var(--frostglass) 50%, var(--cotton) 100%); }
.plate:nth-child(odd)  { background: var(--cotton); }

/* Friezes */
.frieze {
    width: 100%;
    height: 80px;
    flex-shrink: 0;
    position: relative;
}
.frieze-svg { width: 100%; height: 100%; display: block; }
.frieze-num { font-size: 26px; font-style: italic; }
.frieze-line {
    stroke-dasharray: 1200;
    stroke-dashoffset: 1200;
}
.plate.is-active .frieze-line {
    animation: friezeDraw 1.0s cubic-bezier(.25,.8,.35,1) forwards;
}
.plate.is-active .frieze-line.frieze-right {
    animation-delay: 0.5s;
}
.plate.is-active .frieze-cartouche {
    animation: cartoucheIn 0.6s cubic-bezier(.2,.8,.3,1) 0.3s both;
}
@keyframes friezeDraw {
    to { stroke-dashoffset: 0; }
}
@keyframes cartoucheIn {
    from { transform: translate(600px, 40px) scale(0.7); filter: blur(2px); opacity: 0; }
    to { transform: translate(600px, 40px) scale(1); filter: blur(0); opacity: 1; }
}

/* ===== Frontispiece (Plate I) ===== */
.plate-frontispiece {
    position: relative;
    overflow: hidden;
}
.frontispiece-stage {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}
.back-plane {
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200' viewBox='0 0 200 200'><g fill='none' stroke='%23E8EEF5' stroke-width='0.4'><circle cx='100' cy='100' r='80'/><circle cx='100' cy='100' r='62'/><circle cx='100' cy='100' r='44'/><path d='M20 100 q40 -40 80 0 t80 0' /><path d='M100 20 q-40 40 0 80 t0 80' /></g></svg>");
    background-size: 220px;
    opacity: 0.5;
    z-index: 1;
}
.hero-plate {
    position: relative;
    z-index: 2;
    height: 70vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.hero-plate svg.botanical-fern {
    height: 100%;
    width: auto;
    max-width: 90vw;
}
.shear-pulse {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: transparent;
    z-index: 3;
    mix-blend-mode: screen;
}
.shear-pulse.is-pulsing::before, .shear-pulse.is-pulsing::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image: inherit;
}

.frontispiece-text {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 4;
    pointer-events: none;
    text-align: center;
}
.wordmark {
    font-family: var(--serif-display);
    font-style: italic;
    font-size: clamp(3.5rem, 9vw, 9rem);
    line-height: 0.95;
    color: var(--slate);
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 0.18em;
    pointer-events: auto;
    cursor: none;
    transition: filter 0.5s ease;
}
.wordmark em {
    font-style: italic;
    transition: text-shadow 0.22s ease;
}
.wordmark:hover em {
    text-shadow: -1px 0 0 var(--pressed-rose), 1px 0 0 var(--specimen-mint);
}
.wordmark-dot {
    display: inline-flex;
    width: clamp(1rem, 2.4vw, 2.4rem);
    height: clamp(1rem, 2.4vw, 2.4rem);
    align-items: center;
    justify-content: center;
}
.wordmark-dot svg { width: 100%; height: 100%; }

.frontispiece-caption {
    margin-top: 2rem;
    font-family: var(--smallcaps);
    font-size: 0.95rem;
    letter-spacing: 0.18em;
    color: var(--inkwell);
    text-transform: uppercase;
}

/* Corner ornaments (frontispiece + vitrines) */
.corner-orn {
    position: absolute;
    width: 80px;
    height: 80px;
    z-index: 4;
    pointer-events: none;
}
.corner-tl { top: 24px; left: 24px; }
.corner-tr { top: 24px; right: 24px; transform: scaleX(-1); }
.corner-bl { bottom: 24px; left: 24px; transform: scaleY(-1); }
.corner-br { bottom: 24px; right: 24px; transform: scale(-1); }
.corner-orn .orn-path {
    stroke-dasharray: 240;
    stroke-dashoffset: 240;
}
.plate.is-active .corner-orn .orn-path {
    animation: ornDraw 1.4s cubic-bezier(.22,.95,.3,1) forwards;
}
.plate.is-active .corner-tr .orn-path { animation-delay: 0.15s; }
.plate.is-active .corner-bl .orn-path { animation-delay: 0.3s; }
.plate.is-active .corner-br .orn-path { animation-delay: 0.45s; }
@keyframes ornDraw {
    from { stroke-dashoffset: 240; }
    to { stroke-dashoffset: 0; }
}

/* ===== Vitrine body (Plates II-XII) ===== */
.vitrine {
    flex: 1;
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 2.5rem 4rem 3rem;
    display: flex;
    flex-direction: column;
    gap: 1.6rem;
    position: relative;
}

.plate-caption {
    font-family: var(--smallcaps);
    font-style: italic;
    font-size: 1.05rem;
    color: var(--inkwell);
    text-align: center;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.section-title {
    font-family: var(--serif-display);
    font-style: italic;
    font-weight: 400;
    font-size: clamp(2.5rem, 4.5vw, 4.5rem);
    line-height: 1.05;
    color: var(--slate);
    text-align: center;
    letter-spacing: -0.01em;
    transition: text-shadow 0.22s ease;
    cursor: none;
}
.section-title:hover {
    text-shadow: -1px 0 0 var(--pressed-rose), 1px 0 0 var(--specimen-mint);
}

/* Plate figure (botanical illustration) */
.plate-figure {
    position: relative;
    width: 100%;
    max-width: 720px;
    margin: 1rem auto;
    padding: 1.4rem;
    border: 1px solid var(--cyanotype);
    background: var(--frostglass);
    aspect-ratio: 700 / 360;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: filter 0.3s ease;
}
.plate-figure svg.botanical {
    width: 100%;
    height: 100%;
    display: block;
}
.plate-figure:hover {
    filter: drop-shadow(-2px 0 0 var(--shear-magenta)) drop-shadow(2px 0 0 var(--shear-cyan));
}

.compass-figure { aspect-ratio: 1; max-width: 460px; }

.figure-caption {
    text-align: center;
    font-family: var(--smallcaps);
    font-size: 0.86rem;
    color: var(--cyanotype);
    margin-top: -0.4rem;
    letter-spacing: 0.05em;
    font-style: italic;
}

/* Scanline tear (ghost band) */
.scanline-tear {
    position: absolute;
    left: 0; right: 0;
    height: 8%;
    background: linear-gradient(to right, transparent 0%, var(--frostglass) 8%, var(--frostglass) 92%, transparent 100%);
    background-color: var(--frostglass);
    opacity: 0;
    pointer-events: none;
    z-index: 3;
    top: 40%;
    box-shadow: 0 0 0 1px rgba(127, 161, 201, 0.06);
}
.plate.is-active .scanline-tear {
    animation: tearShift 0.18s cubic-bezier(.5,.0,.5,1) 0.7s 1;
}
@keyframes tearShift {
    0% { transform: translateX(0); opacity: 0; }
    20% { transform: translateX(6px); opacity: 0.8; }
    100% { transform: translateX(0); opacity: 0; }
}

/* Vitrine body — manuscript grid */
.vitrine-body {
    display: grid;
    grid-template-columns: 1fr minmax(0, 64ch) 1fr;
    gap: 2rem;
    align-items: start;
    margin-top: 1rem;
}
.manuscript {
    font-family: var(--serif-body);
    font-size: 1.125rem;
    line-height: 1.7;
    color: var(--slate);
    position: relative;
}
.manuscript p {
    margin-bottom: 1.2em;
}
.manuscript p em { color: var(--inkwell); font-style: italic; }

/* Drop cap */
.dropcap {
    float: left;
    width: 6em;
    height: 6em;
    margin: 0.1em 1em 0 0;
    line-height: 1;
    position: relative;
}
.dropcap svg {
    width: 100%; height: 100%;
    stroke-dasharray: 360;
    stroke-dashoffset: 360;
}
.plate.is-active .dropcap svg path,
.plate.is-active .dropcap svg rect {
    animation: ornDraw 0.9s cubic-bezier(.22,.95,.3,1) 0.3s forwards;
}

/* Marginalia */
.margin-left, .margin-right {
    font-family: var(--smallcaps);
    font-size: 0.78rem;
    line-height: 1.5;
    color: var(--inkwell);
    letter-spacing: 0.06em;
    opacity: 0.3;
    transition: opacity 0.6s ease;
    text-transform: uppercase;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}
.margin-right { text-align: right; align-items: flex-end; }
.margin-left { text-align: left; }

.plate.is-active .margin-left { opacity: 1; transition-delay: 0.4s; }
.plate.is-active .margin-right { opacity: 1; transition-delay: 0.46s; }

.margin-note {
    font-style: italic;
    line-height: 1.5;
    max-width: 14rem;
}
.margin-note em { font-style: italic; color: var(--cyanotype); }

.margin-specimen {
    width: 4rem;
    height: 4rem;
    border: 0.5px solid var(--cyanotype);
    background: var(--frostglass);
    padding: 0.4rem;
    cursor: none;
    transition: transform 2.4s cubic-bezier(.45,.05,.55,.95);
    transform-origin: center;
}
.margin-specimen:hover {
    transform: rotate(360deg);
}
.margin-specimen svg { width: 100%; height: 100%; }

/* Mono accents */
.mono {
    font-family: var(--mono);
    font-size: 0.85rem;
    color: var(--inkwell);
    letter-spacing: 0;
}

/* Colophon */
.plate-colophon .vitrine-body {
    grid-template-columns: 1fr minmax(0, 64ch) 1fr;
}
.colophon-text {
    text-align: center;
    font-style: italic;
    color: var(--slate);
}
.colophon-text .colophon-line {
    margin-bottom: 1.2em;
    line-height: 1.65;
}
.colophon-sign {
    font-size: 2rem;
    color: var(--cyanotype);
    margin-top: 1.2rem;
    text-align: center;
}

/* ============== Hero RGB shear pulse animation ============== */
.botanical-fern {
    transition: filter 0.4s ease;
}
.is-pulsing .botanical-fern,
.botanical-fern.is-pulsing {
    animation: shearPulse 0.2s cubic-bezier(.16,1,.3,1) 1;
}
@keyframes shearPulse {
    0% { filter: drop-shadow(0 0 0 transparent) drop-shadow(0 0 0 transparent); }
    35% { filter: drop-shadow(-3px 0 0 var(--shear-magenta)) drop-shadow(3px 0 0 var(--shear-cyan)); }
    100% { filter: drop-shadow(0 0 0 transparent) drop-shadow(0 0 0 transparent); }
}

/* ===== Responsive (manuscript collapses on small screens) ===== */
@media (max-width: 1024px) {
    .vitrine { padding: 2rem 2rem; }
    .vitrine-body {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    .margin-left, .margin-right { text-align: left; align-items: flex-start; }
    .corner-orn { width: 60px; height: 60px; }
    .corner-tl { top: 12px; left: 12px; }
    .corner-tr { top: 12px; right: 12px; }
    .corner-bl { bottom: 12px; left: 12px; }
    .corner-br { bottom: 12px; right: 12px; }
    .spine { right: 8px; font-size: 0.78rem; }
    .spine a { font-size: 0.85rem; padding: 1px 3px; }
}

@media (max-width: 640px) {
    html, body { font-size: 16px; cursor: auto; }
    .cursor { display: none; }
    .vitrine { padding: 1.4rem 1.2rem; }
    .wordmark { gap: 0.1em; }
    .frontispiece-caption { font-size: 0.78rem; padding: 0 1rem; }
    .dropcap { width: 4.5em; height: 4.5em; margin: 0.1em 0.6em 0 0; }
    .spine { display: none; }
    .sound-toggle { left: 12px; bottom: 12px; font-size: 0.85rem; }
}
