/* addrenvoy.com — A Botanical Codex of Network Addressing */

:root {
    --abyssal-ink: #0a0e1a;
    --observatory-blue: #111b2e;
    --parchment-glow: #d4cfc4;
    --copper-verdigris: #3d8b7a;
    --specimen-gold: #c7a84e;
    --midnight-teal: #1a4a5e;
    --pollen-light: #6bc4a6;
    --root-red: #8b3d3d;

    --font-display: "Playfair Display", Georgia, serif;
    --font-mono: "Space Mono", "Courier New", monospace;
    --font-specimen: "Cormorant Garamond", "Times New Roman", serif;
}

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

html {
    scroll-behavior: smooth;
    scroll-snap-type: y mandatory;
}

body {
    background: var(--abyssal-ink);
    color: var(--parchment-glow);
    font-family: var(--font-mono);
    overflow-x: hidden;
    line-height: 1.75;
    letter-spacing: 0.03em;
}

/* Subtle moonlit vignette */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse at 50% 40%, rgba(61, 139, 122, 0.06) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 80%, rgba(199, 168, 78, 0.03) 0%, transparent 55%);
    pointer-events: none;
    z-index: 0;
}

/* Particle canvas */
#particle-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 1;
}

/* Stem progress indicator */
#stem-indicator {
    position: fixed;
    right: 16px;
    top: 10vh;
    height: 80vh;
    width: 34px;
    z-index: 5;
    pointer-events: none;
    overflow: visible;
}

#stem-path {
    stroke-dasharray: 1200;
    stroke-dashoffset: 1200;
    transition: stroke-dashoffset 0.25s linear;
}

.stem-leaf {
    opacity: 0;
    transform-origin: 10px 0px;
    transition: opacity 0.9s ease-out;
    stroke-dasharray: 80;
    stroke-dashoffset: 80;
}

.stem-leaf.sprouted {
    opacity: 0.85;
    animation: leaf-draw 1.4s ease-out forwards;
}

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

/* Plates */
#codex {
    position: relative;
    z-index: 2;
}

.plate {
    position: relative;
    min-height: 100vh;
    width: 100%;
    scroll-snap-align: start;
    padding: 6vh 7vw 6vh 5vw;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

#plate-2 { background: var(--observatory-blue); }
#plate-4 { background: var(--observatory-blue); }

/* Decorative engraved frame */
.plate-frame {
    position: absolute;
    inset: 3vh 4vw;
    width: calc(100% - 8vw);
    height: calc(100% - 6vh);
    opacity: 0.3;
    transition: opacity 1.2s ease-in-out;
    pointer-events: none;
    z-index: 1;
}

.plate.in-view .plate-frame {
    opacity: 0.7;
}

/* Plate meta (number + latin) */
.plate-meta {
    position: absolute;
    top: 4vh;
    left: 5vw;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    z-index: 3;
    font-family: var(--font-specimen);
    font-weight: 300;
    font-style: italic;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--specimen-gold);
    font-size: 0.72rem;
}

.plate-number {
    color: var(--specimen-gold);
    font-weight: 400;
    letter-spacing: 0.12em;
}

.plate-latin {
    color: var(--copper-verdigris);
    font-size: 0.68rem;
    opacity: 0.85;
}

/* Plate titles */
.plate-title {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: clamp(2.4rem, 5.5vw, 5rem);
    letter-spacing: 0.02em;
    line-height: 1.05;
    color: var(--parchment-glow);
    margin-bottom: 1.5rem;
    position: relative;
    z-index: 3;
}

.plate-title.centered {
    text-align: center;
    margin-top: 2rem;
}

/* ===== PLATE I: HERO ===== */
.hero-stage {
    display: grid;
    place-items: center;
    position: relative;
    z-index: 3;
    width: 100%;
    max-width: 1200px;
}

.hero-specimen {
    position: relative;
    width: min(60vmin, 600px);
    height: min(60vmin, 600px);
    margin-bottom: 2rem;
}

.specimen-svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.specimen-svg .draw {
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    animation: path-draw 4s ease-in-out forwards;
}

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

/* Callout labels */
.callout-label {
    position: absolute;
    font-family: var(--font-specimen);
    font-size: 0.78rem;
    font-weight: 300;
    font-style: italic;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--specimen-gold);
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.4s ease-out;
}

.callout-label.visible { opacity: 1; }

.label-1 { top: 8%; right: -8%; }
.label-2 { top: 24%; left: -14%; text-align: right; }
.label-3 { top: 48%; right: -10%; }
.label-4 { top: 68%; left: -12%; text-align: right; }
.label-5 { bottom: -10%; left: 50%; transform: translateX(-50%); text-align: center; }

.hero-title {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: clamp(3rem, 7vw, 6rem);
    color: var(--parchment-glow);
    text-align: center;
    letter-spacing: 0.5em;
    line-height: 1.05;
    margin-top: 2rem;
    animation: title-condense 1.5s 3s ease-out forwards;
}

@keyframes title-condense {
    to { letter-spacing: 0.02em; }
}

.hero-subtitle {
    font-family: var(--font-mono);
    font-size: 0.92rem;
    color: var(--copper-verdigris);
    text-align: center;
    margin-top: 1.4rem;
    letter-spacing: 0.08em;
    min-height: 1.75em;
}

.callout-line {
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    animation: path-draw 2s 2s ease-out forwards;
}

/* ===== PLATE II: SPLIT ===== */
.split-layout {
    display: grid;
    grid-template-columns: 60% 40%;
    width: 100%;
    max-width: 1400px;
    gap: 3vw;
    align-items: center;
    position: relative;
    z-index: 3;
}

.split-illustration {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.split-illustration svg {
    width: 100%;
    max-width: 520px;
    height: auto;
    overflow: visible;
}

.illustration-signature {
    font-family: var(--font-specimen);
    font-style: italic;
    font-weight: 300;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--copper-verdigris);
    margin-top: 1rem;
}

.split-text {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding-right: 2vw;
}

.split-body {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.annotation {
    font-family: var(--font-mono);
    font-size: 0.95rem;
    line-height: 1.75;
    color: var(--parchment-glow);
    letter-spacing: 0.03em;
    min-height: 1.75em;
}

.annotation::after,
.plate-caption::after,
.colophon-line::after,
.colophon-sig::after,
.specimen-tag::after,
.hero-subtitle::after {
    content: "";
    display: inline-block;
}

.specimen-tag {
    font-family: var(--font-specimen);
    font-style: italic;
    font-weight: 300;
    font-size: 0.78rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--specimen-gold);
    border-top: 1px solid var(--midnight-teal);
    padding-top: 1rem;
    margin-top: 1rem;
    min-height: 1em;
}

/* ===== PLATE III: RADIAL ===== */
.radial-composition {
    position: relative;
    width: min(70vmin, 700px);
    height: min(70vmin, 700px);
    margin: 1rem auto;
    z-index: 3;
}

.radial-svg {
    width: 100%;
    height: 100%;
    overflow: visible;
    animation: radial-spin 240s linear infinite;
}

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

.radial-labels {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.radial-label {
    position: absolute;
    font-family: var(--font-specimen);
    font-style: italic;
    font-weight: 300;
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--specimen-gold);
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.5s ease-out;
}

.radial-label.visible { opacity: 1; }

.pos-n  { top: -3%;  left: 50%; transform: translateX(-50%); }
.pos-ne { top: 10%;  right: -8%; }
.pos-e  { top: 50%;  right: -10%; transform: translateY(-50%); }
.pos-se { bottom: 10%; right: -4%; }
.pos-s  { bottom: -3%; left: 50%; transform: translateX(-50%); }
.pos-sw { bottom: 10%; left: -8%; text-align: right; }
.pos-w  { top: 50%;  left: -14%; transform: translateY(-50%); }
.pos-nw { top: 10%;  left: -8%; text-align: right; }

.plate-caption {
    font-family: var(--font-mono);
    font-size: 0.88rem;
    color: var(--parchment-glow);
    text-align: center;
    max-width: 640px;
    margin: 2rem auto 0;
    opacity: 0.85;
    letter-spacing: 0.03em;
    position: relative;
    z-index: 3;
    min-height: 1.75em;
}

/* ===== PLATE IV: SPECIMEN GRID ===== */
.specimen-grid {
    position: relative;
    width: 100%;
    max-width: 1000px;
    height: min(62vh, 560px);
    margin-top: 2rem;
    z-index: 3;
}

.specimen-card {
    position: absolute;
    width: 180px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
}

.specimen-card svg {
    width: 100%;
    height: 180px;
    overflow: visible;
}

.specimen-card figcaption {
    font-family: var(--font-specimen);
    font-style: italic;
    font-weight: 300;
    font-size: 0.72rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--specimen-gold);
    text-align: center;
    min-height: 1em;
}

/* Irregular cluster positions */
.spec-1 { top: 0;     left: 5%;  transform: rotate(-3deg); }
.spec-2 { top: 4%;    left: 38%; transform: rotate(1.5deg); }
.spec-3 { top: 2%;    right: 4%; transform: rotate(-1deg); }
.spec-4 { bottom: 4%; left: 14%; transform: rotate(2deg); }
.spec-5 { bottom: 0;  left: 44%; transform: rotate(-2deg); }
.spec-6 { bottom: 6%; right: 8%; transform: rotate(1deg); }

/* ===== PLATE V: COLOPHON ===== */
.colophon-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    position: relative;
    z-index: 3;
    text-align: center;
}

.colophon-motif {
    width: min(32vmin, 260px);
    height: min(32vmin, 260px);
    overflow: visible;
    animation: colophon-rotate 90s linear infinite;
}

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

.colophon-line {
    font-family: var(--font-mono);
    font-size: 1rem;
    color: var(--parchment-glow);
    max-width: 640px;
    letter-spacing: 0.04em;
    min-height: 1.75em;
}

.colophon-sig {
    font-family: var(--font-specimen);
    font-style: italic;
    font-weight: 300;
    font-size: 0.82rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--specimen-gold);
    margin-top: 1rem;
    min-height: 1em;
}

/* Typewriter cursor */
.cursor {
    display: inline-block;
    width: 1px;
    height: 1em;
    background: var(--specimen-gold);
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: blink 0.8s step-end infinite;
}

@keyframes blink {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
}

/* Path drawing utility (for scroll-triggered plates) */
.plate:not(#plate-1) .draw {
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
}

.plate:not(#plate-1).in-view .draw {
    animation: path-draw 3.5s ease-in-out forwards;
}

.plate#plate-4.in-view .specimen-card.spec-1 .draw { animation-delay: 0ms; }
.plate#plate-4.in-view .specimen-card.spec-2 .draw { animation-delay: 400ms; }
.plate#plate-4.in-view .specimen-card.spec-3 .draw { animation-delay: 800ms; }
.plate#plate-4.in-view .specimen-card.spec-4 .draw { animation-delay: 1200ms; }
.plate#plate-4.in-view .specimen-card.spec-5 .draw { animation-delay: 1600ms; }
.plate#plate-4.in-view .specimen-card.spec-6 .draw { animation-delay: 2000ms; }

/* Responsive */
@media (max-width: 900px) {
    html { scroll-snap-type: none; }
    .plate { min-height: auto; padding: 10vh 8vw; }

    .split-layout {
        grid-template-columns: 1fr;
        gap: 3rem;
    }

    .specimen-grid {
        height: auto;
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 2rem;
    }

    .specimen-card {
        position: relative;
        top: auto !important;
        bottom: auto !important;
        left: auto !important;
        right: auto !important;
        width: 140px;
    }

    #stem-indicator { display: none; }

    .callout-label { font-size: 0.65rem; }
    .label-1 { top: -2%; right: -4%; }
    .label-2 { top: 20%; left: -8%; }
    .label-3 { top: 50%; right: -4%; }
    .label-4 { top: 72%; left: -8%; }

    .radial-label { font-size: 0.62rem; }
}

@media (max-width: 600px) {
    .plate-meta { font-size: 0.6rem; top: 2.5vh; }
    .hero-specimen { width: 80vmin; height: 80vmin; }
    .radial-composition { width: 85vmin; height: 85vmin; }
    .callout-label { display: none; }
}
