/* op9.rs — A Botanical Monograph
 * Palette: deep-burgundy herbarium
 * Typography: Poiret One (display), Cormorant Garamond (body)
 */

:root {
    --burgundy: #3A0820;          /* Herbarium burgundy (primary background) */
    --burgundy-deep: #200010;     /* Deep maroon (darkest shadows) */
    --gold: #C8A048;              /* Aged gold (art-deco accents, borders) */
    --parchment: #F0E8D0;         /* Parchment cream (text, page bg) */
    --crystal: #7848A0;           /* Crystal violet (crystalline accents) */
    --sage: #608858;              /* Botanical sage (plant tones) */
    --brown: #8A6840;             /* Specimen brown (secondary text) */

    --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease: cubic-bezier(0.4, 0.0, 0.2, 1);

    --serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
    --display: "Poiret One", "Cormorant Garamond", serif;
}

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

html { scroll-behavior: smooth; }

body {
    background: var(--burgundy);
    color: var(--parchment);
    font-family: var(--serif);
    font-size: clamp(15px, 1vw, 17px);
    line-height: 1.85;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Paper-aged texture overlay (full viewport, fixed) */
.paper-texture {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    background-color: transparent;
    background-image:
        repeating-radial-gradient(circle at 13% 22%, rgba(240, 232, 208, 0.025) 0 1px, transparent 1px 4px),
        repeating-radial-gradient(circle at 78% 64%, rgba(200, 160, 72, 0.025) 0 1px, transparent 1px 5px),
        repeating-radial-gradient(circle at 41% 88%, rgba(120, 72, 160, 0.020) 0 1px, transparent 1px 6px),
        repeating-conic-gradient(from 0deg at 50% 50%, rgba(240, 232, 208, 0.015) 0deg 1deg, transparent 1deg 3deg);
    mix-blend-mode: screen;
    opacity: 0;
    animation: paper-fade-in 1200ms var(--ease) forwards;
}

@keyframes paper-fade-in {
    to { opacity: 1; }
}

/* Art-deco viewport border (fixed, ornamental corners) */
.deco-border {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 2;
}

.deco-corner {
    position: absolute;
    width: 80px;
    height: 80px;
    opacity: 0;
    animation: corner-fade 900ms var(--ease) 600ms forwards;
}

.deco-corner-tl { top: 14px; left: 14px; }
.deco-corner-tr { top: 14px; right: 14px; }
.deco-corner-bl { bottom: 14px; left: 14px; }
.deco-corner-br { bottom: 14px; right: 14px; }

@keyframes corner-fade {
    from { opacity: 0; transform: scale(0.85); }
    to   { opacity: 1; transform: scale(1); }
}

/* Thin gold rules along the viewport edges (drawn after corners) */
.deco-border::before,
.deco-border::after {
    content: "";
    position: absolute;
    background: var(--gold);
    opacity: 0.55;
    transform-origin: 0 0;
    animation: rule-draw 1100ms var(--ease) 800ms forwards;
}

.deco-border::before {
    top: 17px; left: 94px;
    height: 1px;
    width: calc(100% - 188px);
    transform: scaleX(0);
}

.deco-border::after {
    bottom: 17px; left: 94px;
    height: 1px;
    width: calc(100% - 188px);
    transform: scaleX(0);
}

@keyframes rule-draw {
    to { transform: scaleX(1); }
}

/* Main column */
#monograph {
    position: relative;
    z-index: 3;
    max-width: 760px;
    margin: 0 auto;
    padding: 0 36px;
}

/* ================= Cover ================= */
.cover {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 96px 0 56px;
    position: relative;
}

.cover-inner {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 40px;
    align-items: center;
}

.cover-meta {
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: var(--gold);
    font-family: var(--display);
    font-size: 12px;
    letter-spacing: 0.32em;
    text-transform: uppercase;
    opacity: 0;
    animation: fade-up 900ms var(--ease) 1100ms forwards;
}

.cover-meta-top { gap: 4px; }
.cover-meta-bottom { gap: 4px; animation-delay: 1500ms; }

.meta-line { display: block; }

.cover-title-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 28px;
    width: 100%;
}

.crystal {
    width: 110px;
    height: 176px;
    flex-shrink: 0;
    overflow: visible;
}

.crystal-strokes path,
.crystal-strokes line,
.crystal-strokes-violet path,
.crystal-strokes-violet line {
    stroke-dasharray: 800;
    stroke-dashoffset: 800;
    animation: stroke-draw 1400ms var(--ease) 700ms forwards;
}

.crystal-strokes-violet path,
.crystal-strokes-violet line {
    animation-delay: 1100ms;
    animation-duration: 1100ms;
}

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

.cover-text {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}

.cover-eyebrow {
    font-family: var(--display);
    font-size: 12px;
    letter-spacing: 0.36em;
    text-transform: uppercase;
    color: var(--gold);
    opacity: 0;
    animation: fade-up 900ms var(--ease) 600ms forwards;
}

.cover-domain {
    font-family: var(--display);
    font-weight: 400;
    font-size: clamp(40px, 6.4vw, 88px);
    letter-spacing: 0.06em;
    line-height: 1;
    color: var(--parchment);
    opacity: 0;
    animation: domain-rise 1100ms var(--ease) 300ms forwards;
}

.domain-prefix { color: var(--parchment); }
.domain-dot {
    color: var(--gold);
    margin: 0 0.04em;
    display: inline-block;
    transform-origin: center;
    animation: dot-pulse 4200ms ease-in-out 1800ms infinite;
}
.domain-suffix {
    color: var(--gold);
    font-style: italic;
    font-family: "Cormorant Garamond", serif;
    font-size: 0.82em;
    margin-left: 0.04em;
}

@keyframes domain-rise {
    from { opacity: 0; transform: translateY(20px); letter-spacing: 0.16em; }
    to   { opacity: 1; transform: translateY(0); letter-spacing: 0.06em; }
}

@keyframes dot-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.45; }
}

.cover-subtitle {
    font-family: var(--serif);
    font-style: italic;
    color: var(--parchment);
    opacity: 0.78;
    font-size: 17px;
    max-width: 460px;
    line-height: 1.5;
    animation: fade-up 900ms var(--ease) 900ms forwards;
    opacity: 0;
}

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

.cover-subtitle { animation-fill-mode: forwards; }

.scroll-cue {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 28px;
    color: var(--gold);
    font-family: var(--display);
    font-size: 11px;
    letter-spacing: 0.36em;
    text-transform: uppercase;
    opacity: 0;
    animation: fade-up 900ms var(--ease) 1900ms forwards, cue-bob 3000ms ease-in-out 2400ms infinite;
}

.scroll-cue-line {
    width: 36px;
    height: 1px;
    background: var(--gold);
    opacity: 0.6;
}

@keyframes cue-bob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(6px); }
}

/* ================= Crystal dividers ================= */
.divider {
    display: flex;
    justify-content: center;
    padding: 36px 0;
}

.divider-svg {
    width: 100%;
    max-width: 520px;
    height: 60px;
    overflow: visible;
}

.divider-svg line,
.divider-svg path {
    stroke-dasharray: 600;
    stroke-dashoffset: 600;
    transition: stroke-dashoffset 1100ms var(--ease);
}

.divider.in-view .divider-svg line,
.divider.in-view .divider-svg path {
    stroke-dashoffset: 0;
}

.divider-crystal {
    transform-origin: center;
    transition: transform 600ms var(--spring);
}

/* ================= Specimen pages ================= */
.specimen {
    padding: 28px 0;
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 600ms var(--spring), transform 600ms var(--spring);
}

.specimen.in-view {
    opacity: 1;
    transform: translateY(0);
}

.specimen-frame {
    position: relative;
    background:
        linear-gradient(180deg, rgba(240, 232, 208, 0.985), rgba(240, 232, 208, 0.96)),
        repeating-linear-gradient(0deg, rgba(138, 104, 64, 0.04) 0 1px, transparent 1px 4px),
        repeating-linear-gradient(90deg, rgba(138, 104, 64, 0.03) 0 1px, transparent 1px 5px);
    color: var(--burgundy-deep);
    padding: 56px 48px 64px;
    border: 1px solid var(--gold);
    box-shadow:
        0 0 0 4px rgba(58, 8, 32, 0.4) inset,
        0 0 0 5px rgba(200, 160, 72, 0.6) inset,
        0 28px 60px -32px rgba(0, 0, 0, 0.6);
    transition: box-shadow 400ms var(--ease);
    /* Reveal art-deco border via clip-path on entry */
    clip-path: inset(8% 8% 8% 8% round 2px);
    transition: clip-path 700ms var(--spring), box-shadow 400ms var(--ease);
}

.specimen.in-view .specimen-frame {
    clip-path: inset(0 0 0 0 round 2px);
}

.specimen-frame::before,
.specimen-frame::after {
    content: "";
    position: absolute;
    pointer-events: none;
    background-repeat: no-repeat;
}

/* Top art-deco fillet */
.specimen-frame::before {
    top: 12px; left: 12px; right: 12px;
    height: 14px;
    background-image:
        linear-gradient(90deg, var(--gold) 0 1px, transparent 1px 100%),
        repeating-linear-gradient(90deg, var(--gold) 0 6px, transparent 6px 12px);
    background-size: 100% 1px, 100% 1px;
    background-position: 0 0, 0 6px;
    opacity: 0.7;
}

.specimen-frame::after {
    bottom: 12px; left: 12px; right: 12px;
    height: 14px;
    background-image:
        linear-gradient(90deg, var(--gold) 0 1px, transparent 1px 100%),
        repeating-linear-gradient(90deg, var(--gold) 0 6px, transparent 6px 12px);
    background-size: 100% 1px, 100% 1px;
    background-position: 0 12px, 0 6px;
    opacity: 0.7;
}

.specimen-frame:hover {
    box-shadow:
        0 0 0 4px rgba(58, 8, 32, 0.4) inset,
        0 0 0 5px rgba(200, 160, 72, 0.95) inset,
        0 0 38px rgba(200, 160, 72, 0.18),
        0 28px 60px -32px rgba(0, 0, 0, 0.6);
}

.specimen-header {
    text-align: center;
    margin-bottom: 36px;
    border-bottom: 1px solid rgba(138, 104, 64, 0.4);
    padding-bottom: 24px;
}

.specimen-tag {
    display: inline-block;
    font-family: var(--display);
    font-size: 13px;
    letter-spacing: 0.32em;
    text-transform: uppercase;
    color: var(--gold);
    margin-bottom: 14px;
    transition: letter-spacing 200ms var(--ease);
}

.specimen-title {
    font-family: var(--display);
    font-weight: 400;
    font-size: clamp(28px, 3.5vw, 44px);
    letter-spacing: 0.06em;
    color: var(--burgundy);
    line-height: 1.2;
    margin-bottom: 10px;
}

.specimen-title em {
    font-family: var(--serif);
    font-style: italic;
    font-weight: 500;
    color: var(--brown);
}

.specimen-collected {
    font-family: var(--serif);
    font-style: italic;
    font-size: 13px;
    color: var(--brown);
    letter-spacing: 0.02em;
}

.specimen-body {
    display: grid;
    grid-template-columns: 1fr 220px;
    gap: 40px;
    align-items: start;
}

.specimen-text {
    color: var(--burgundy-deep);
}

.specimen-text p {
    margin-bottom: 18px;
    font-size: 16px;
    line-height: 1.85;
}

.specimen-text p.lead {
    font-size: 18px;
    color: var(--burgundy);
    font-style: italic;
    border-left: 1px solid var(--gold);
    padding-left: 18px;
    margin-bottom: 26px;
}

.specimen-text em {
    color: var(--burgundy);
    font-style: italic;
}

.specimen-text code {
    font-family: var(--serif);
    font-style: italic;
    font-size: 0.94em;
    color: var(--brown);
    background: rgba(138, 104, 64, 0.08);
    padding: 0 4px;
    border-radius: 1px;
}

/* Sidebar (botanical field notes) */
.specimen-sidebar {
    border-left: 1px solid rgba(138, 104, 64, 0.4);
    padding-left: 22px;
    color: var(--burgundy-deep);
    font-size: 14px;
}

.sidebar-title {
    font-family: var(--display);
    font-size: 12px;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: var(--gold);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(200, 160, 72, 0.5);
}

.field-notes {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 6px 14px;
    font-size: 13px;
    line-height: 1.45;
    margin-bottom: 24px;
}

.field-notes dt {
    font-family: var(--display);
    font-size: 11px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--brown);
    align-self: baseline;
}

.field-notes dd {
    color: var(--burgundy);
    font-style: italic;
}

.field-notes code {
    font-style: normal;
    font-family: var(--serif);
}

/* Botanical-style ruler */
.ruler {
    margin-top: 18px;
    display: flex;
    align-items: flex-end;
    height: 22px;
    border-bottom: 1px solid var(--brown);
    position: relative;
    gap: 0;
}

.ruler span {
    flex: 1;
    border-right: 1px solid var(--brown);
    height: 8px;
}

.ruler span:nth-child(odd) {
    height: 14px;
}

.ruler span:last-child { border-right: none; }

.ruler-label {
    position: absolute;
    bottom: -18px;
    left: 0;
    right: 0;
    text-align: center;
    font-family: var(--display);
    font-size: 10px;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: var(--brown);
    font-style: normal;
}

/* Code leaf (specimen II) */
.code-leaf {
    background: rgba(58, 8, 32, 0.04);
    border: 1px solid rgba(138, 104, 64, 0.35);
    border-left: 2px solid var(--gold);
    padding: 18px 20px;
    margin: 18px 0 22px;
    font-family: "Cormorant Garamond", serif;
    font-size: 14px;
    font-style: italic;
    line-height: 1.7;
    color: var(--burgundy-deep);
    overflow-x: auto;
    white-space: pre;
}

.code-leaf code {
    background: transparent;
    padding: 0;
    color: inherit;
}

.code-leaf .kw  { color: var(--crystal); font-style: normal; }
.code-leaf .fn  { color: var(--burgundy); font-style: normal; font-weight: 600; }
.code-leaf .ty  { color: var(--brown); }
.code-leaf .lt  { color: var(--sage); font-style: normal; }
.code-leaf .vt  { color: var(--gold); font-style: normal; }

/* Anatomy list */
.anatomy-list {
    list-style: none;
    margin-bottom: 20px;
}

.anatomy-list li {
    display: flex;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 13px;
    color: var(--burgundy-deep);
    font-style: italic;
    line-height: 1.5;
}

.anatomy-num {
    font-family: var(--display);
    font-style: normal;
    color: var(--gold);
    min-width: 24px;
    letter-spacing: 0.1em;
}

.anatomy-list code {
    font-style: normal;
    color: var(--brown);
}

.anatomy-figure {
    margin-top: 16px;
    padding: 12px;
    border: 1px dashed rgba(138, 104, 64, 0.5);
}

.anatomy-figure svg {
    width: 100%;
    height: auto;
    max-height: 200px;
}

/* Companion list (specimen III) */
.companion-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}

.companion-list li {
    display: grid;
    grid-template-columns: 16px auto 1fr;
    align-items: center;
    gap: 8px;
    padding: 8px 10px 8px 6px;
    border-bottom: 1px solid rgba(138, 104, 64, 0.25);
    transition: background 240ms var(--ease), transform 360ms var(--spring);
    cursor: default;
}

.companion-stem {
    width: 10px;
    height: 18px;
    background:
        linear-gradient(180deg, var(--sage) 0%, var(--sage) 70%, transparent 70%),
        radial-gradient(circle at 50% 25%, var(--gold) 0 2px, transparent 2px);
    background-repeat: no-repeat;
    background-size: 2px 100%, 100% 100%;
    background-position: center, center;
    position: relative;
}

.companion-stem::before,
.companion-stem::after {
    content: "";
    position: absolute;
    width: 6px;
    height: 4px;
    border-radius: 50%;
    background: var(--sage);
    opacity: 0.85;
}

.companion-stem::before { top: 5px; left: -3px; transform: rotate(-30deg); }
.companion-stem::after  { top: 8px; right: -3px; transform: rotate(30deg); }

.companion-name {
    font-family: var(--display);
    font-size: 13px;
    letter-spacing: 0.18em;
    text-transform: lowercase;
    color: var(--burgundy);
    transition: letter-spacing 220ms var(--ease), color 220ms var(--ease);
}

.companion-note {
    font-style: italic;
    font-size: 12px;
    color: var(--brown);
    text-align: right;
}

.companion-list li:hover {
    background: rgba(200, 160, 72, 0.08);
    transform: translateX(3px);
}

.companion-list li:hover .companion-name {
    letter-spacing: 0.24em;
    color: var(--burgundy-deep);
}

.companion-list li:hover .companion-stem {
    animation: leaf-sway 1400ms var(--spring);
}

@keyframes leaf-sway {
    0%   { transform: rotate(0); }
    35%  { transform: rotate(-6deg); }
    65%  { transform: rotate(4deg); }
    100% { transform: rotate(0); }
}

.sidebar-foot {
    font-style: italic;
    font-size: 11px;
    color: var(--brown);
    letter-spacing: 0.04em;
    border-top: 1px solid rgba(138, 104, 64, 0.3);
    padding-top: 10px;
}

/* Specimen hover (gold border brighten + crystal rotate) */
.specimen:hover .specimen-tag {
    letter-spacing: 0.40em;
}

.specimen:hover ~ .divider .divider-crystal {
    transform: rotate(2deg);
}

.divider:hover .divider-crystal {
    transform: rotate(2deg);
}

/* Body text letter-spacing on section hover */
.specimen:hover .specimen-text p {
    letter-spacing: 0.01em;
}

.specimen-text p { transition: letter-spacing 220ms var(--ease); }

/* ================= Colophon ================= */
.colophon {
    padding: 80px 0 96px;
    text-align: center;
    color: var(--parchment);
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 700ms var(--spring), transform 700ms var(--spring);
}

.colophon.in-view {
    opacity: 1;
    transform: translateY(0);
}

.colophon-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
}

.colophon-crystal {
    width: 120px;
    height: 120px;
    margin-bottom: 14px;
    transition: transform 600ms var(--spring);
}

.colophon-crystal:hover {
    transform: rotate(2deg);
}

.colophon-crystal g path,
.colophon-crystal g polygon,
.colophon-crystal g line {
    stroke-dasharray: 700;
    stroke-dashoffset: 700;
    transition: stroke-dashoffset 1400ms var(--ease);
}

.colophon.in-view .colophon-crystal g path,
.colophon.in-view .colophon-crystal g polygon,
.colophon.in-view .colophon-crystal g line {
    stroke-dashoffset: 0;
}

.colophon-line {
    font-family: var(--serif);
    font-style: italic;
    font-size: 15px;
    color: var(--parchment);
    opacity: 0.78;
    max-width: 460px;
    line-height: 1.6;
}

.colophon-mark {
    margin-top: 14px;
    font-family: var(--display);
    font-size: 12px;
    letter-spacing: 0.32em;
    text-transform: lowercase;
    color: var(--gold);
}

/* ================= Responsive ================= */
@media (max-width: 720px) {
    #monograph { padding: 0 22px; }

    .cover-title-row { gap: 14px; flex-wrap: wrap; justify-content: center; }
    .crystal { width: 70px; height: 112px; }
    .crystal-left, .crystal-right { display: none; }

    .specimen-frame { padding: 40px 26px 44px; }
    .specimen-body {
        grid-template-columns: 1fr;
        gap: 28px;
    }
    .specimen-sidebar {
        border-left: none;
        border-top: 1px solid rgba(138, 104, 64, 0.4);
        padding-left: 0;
        padding-top: 22px;
    }

    .deco-corner { width: 56px; height: 56px; }
    .deco-corner-tl { top: 10px; left: 10px; }
    .deco-corner-tr { top: 10px; right: 10px; }
    .deco-corner-bl { bottom: 10px; left: 10px; }
    .deco-corner-br { bottom: 10px; right: 10px; }
    .deco-border::before { top: 13px; left: 70px; width: calc(100% - 140px); }
    .deco-border::after  { bottom: 13px; left: 70px; width: calc(100% - 140px); }

    .companion-list li { grid-template-columns: 16px 1fr; }
    .companion-note { grid-column: 2; text-align: left; }
}

@media (max-width: 460px) {
    .cover-domain { font-size: 48px; }
    .specimen-title { font-size: 26px; }
    .specimen-frame { padding: 32px 18px 36px; }
    .code-leaf { padding: 14px; font-size: 13px; }
}
