/* ==========================================================================
   transactology.xyz — Atlas of Exchange Ecologies
   Botanical, magazine-spread, dark-neon, variable-fluid typography
   Fonts: Fraunces, Source Serif 4, Space Grotesk (Google Fonts).
   ========================================================================== */

:root {
    /* Palette (exact hex from DESIGN.md) */
    --bg-deep:      #0A0E1A;  /* Abyssal midnight */
    --bg-surface:   #111822;  /* Dark greenhouse glass */
    --bg-mtn-far:   #1A2830;  /* Furthest mountain layer */
    --neon-green:   #4AE08A;  /* Bioluminescent chlorophyll */
    --neon-cyan:    #2AE0D0;  /* Electric mineral water */
    --neon-magenta: #E04A8A;  /* Exotic bloom pink */
    --neon-amber:   #E0A04A;  /* Pollen-dust gold */
    --text-primary: #E0F0E8;  /* Pale botanical white */
    --text-second:  #B8C8C0;  /* Misted sage */
    --accent-jade:  #A0D8C0;  /* Soft jade */
    --rule:         #2A3A32;  /* Dark fern frame */
    --fern-deep:    #2A3A32;

    /* Spring easings */
    --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --spring-soft: cubic-bezier(0.22, 1.2, 0.36, 1);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg-deep);
    color: var(--text-primary);
    font-family: "Source Serif 4", Georgia, serif;
    font-weight: 400;
    font-size: 17px;
    line-height: 1.75;
    -webkit-font-smoothing: antialiased;
}

body {
    overflow-x: hidden;
}

html {
    scroll-behavior: smooth;
}

/* The scrolling atlas: a mandatory scroll-snap column of spreads */
.atlas {
    height: 100vh;
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    scroll-behavior: smooth;
}

.spread {
    position: relative;
    width: 100vw;
    min-height: 100vh;
    padding: 56px 72px;
    display: grid;
    grid-template-columns: 55% 45%;
    gap: 48px;
    scroll-snap-align: start;
    background: var(--bg-deep);
    overflow: hidden;
}

.spread::before {
    /* faint vignette to feel like pressed paper */
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(
        ellipse at 50% 40%,
        rgba(74, 224, 138, 0.04) 0%,
        rgba(10, 14, 26, 0) 55%
    );
    pointer-events: none;
}

/* ==========================================================================
   Typography
   ========================================================================== */

.cover-title,
h1, h2 {
    font-family: "Fraunces", Georgia, serif;
    color: var(--text-primary);
    font-weight: 700;
    font-variation-settings: 'opsz' 72, 'SOFT' 0, 'WONK' 1;
    margin: 0;
}

h1 {
    font-size: clamp(2.8rem, 7vw, 6rem);
    letter-spacing: 0.02em;
    line-height: 1.02;
}

h2 {
    font-size: clamp(1.5rem, 3.5vw, 2.5rem);
    font-weight: 600;
    color: var(--accent-jade);
    line-height: 1.1;
    margin-bottom: 0.6em;
    letter-spacing: 0.005em;
}

.classification {
    font-family: "Space Grotesk", "Inter", sans-serif;
    font-weight: 500;
    font-size: 12px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(74, 224, 138, 0.7);
    display: inline-block;
}

p {
    color: var(--text-second);
    margin: 0 0 1.1em;
}

em {
    font-style: italic;
    color: var(--accent-jade);
}

/* ==========================================================================
   Spread 0 — Cover Plate
   ========================================================================== */

.spread-cover {
    grid-template-columns: 1fr;
    padding: 48px 72px;
}

.cover-wrap {
    display: grid;
    grid-template-rows: auto auto auto 1fr auto;
    gap: 22px;
    height: 100%;
    position: relative;
    z-index: 1;
}

.cover-header,
.cover-footer {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    border-top: 1px solid var(--rule);
    padding-top: 14px;
}

.cover-footer {
    border-top: 1px solid var(--rule);
    border-bottom: none;
    padding-top: 14px;
    margin-top: 8px;
}

.cover-title {
    font-size: clamp(3rem, 8vw, 7rem);
    letter-spacing: 0.01em;
    line-height: 1;
    transform-origin: left bottom;
    animation: breathe 4s ease-in-out infinite alternate;
    color: var(--text-primary);
    text-shadow: 0 0 24px rgba(74, 224, 138, 0.18);
}

@keyframes breathe {
    0%   { font-size: clamp(3rem, 8vw, 7rem);    letter-spacing: 0.01em; }
    100% { font-size: clamp(3.2rem, 8.5vw, 7.5rem); letter-spacing: 0.02em; }
}

.cover-subtitle {
    font-family: "Fraunces", Georgia, serif;
    font-style: italic;
    font-weight: 400;
    color: var(--accent-jade);
    font-size: clamp(1.1rem, 1.8vw, 1.5rem);
    margin: -6px 0 0;
}

.cover-blurb {
    max-width: 62ch;
    font-size: 16px;
    color: var(--text-second);
    margin: 0;
}

.cover-illustration {
    align-self: stretch;
    justify-self: center;
    width: 100%;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cover-illustration svg {
    width: 100%;
    height: 100%;
    max-height: 58vh;
    filter: drop-shadow(0 0 24px rgba(74, 224, 138, 0.08));
}

/* ==========================================================================
   Specimen Spreads
   ========================================================================== */

.spread-specimen {
    align-items: stretch;
}

.plate {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
}

.plate-frame {
    width: 100%;
    max-width: 640px;
    aspect-ratio: 1 / 1;
    background: linear-gradient(180deg, var(--bg-surface) 0%, var(--bg-deep) 100%);
    border: 1px solid var(--rule);
    position: relative;
    overflow: hidden;
    box-shadow:
        inset 0 0 0 1px rgba(74, 224, 138, 0.05),
        0 40px 80px -40px rgba(0, 0, 0, 0.8);
}

.plate-frame::before {
    /* inner rule */
    content: "";
    position: absolute;
    inset: 18px;
    border: 1px solid rgba(42, 58, 50, 0.6);
    pointer-events: none;
}

.composition {
    width: 100%;
    height: 100%;
    display: block;
}

.plate-border {
    fill: none;
    stroke: var(--rule);
    stroke-width: 1;
    stroke-dasharray: 3 2;
    opacity: 0.7;
}

.plate-tag {
    font-family: "Space Grotesk", "Inter", sans-serif;
    font-weight: 500;
    font-size: 10px;
    letter-spacing: 0.18em;
    fill: rgba(184, 200, 192, 0.55);
    text-transform: uppercase;
}

/* Mountain layers inside plates */
.mtn { opacity: 0.9; }
.mtn-back { fill: var(--bg-surface); }
.mtn-mid  { fill: #162028; }
.mtn-fore { fill: var(--bg-mtn-far); }

/* ==========================================================================
   Description column
   ========================================================================== */

.description {
    display: flex;
    flex-direction: column;
    justify-content: center;
    max-width: 52ch;
    padding: 24px 8px;
}

.description > .classification {
    margin-bottom: 1rem;
}

.description p {
    font-size: 17px;
    line-height: 1.75;
}

.taxonomy {
    margin: 1.2em 0 1.4em;
    padding: 16px 18px;
    border: 1px solid var(--rule);
    background: rgba(17, 24, 34, 0.5);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 24px;
    font-size: 14px;
}

.taxonomy div {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.taxonomy dt {
    font-family: "Space Grotesk", "Inter", sans-serif;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 10px;
    color: rgba(74, 224, 138, 0.75);
}

.taxonomy dd {
    margin: 0;
    color: var(--text-primary);
    font-family: "Source Serif 4", Georgia, serif;
    font-size: 14px;
    line-height: 1.4;
}

.field-note {
    border-left: 2px solid var(--neon-green);
    padding-left: 14px;
    font-style: italic;
    color: var(--text-second);
    font-size: 15px;
}

.field-note .classification {
    display: block;
    margin-bottom: 4px;
    color: var(--neon-green);
    font-style: normal;
}

/* Per-spread accent color: changes border & field-note accent per plate */
#spread-1 .field-note { border-left-color: var(--neon-green); }
#spread-1 .field-note .classification { color: var(--neon-green); }
#spread-2 .field-note { border-left-color: var(--neon-cyan); }
#spread-2 .field-note .classification { color: var(--neon-cyan); }
#spread-3 .field-note { border-left-color: var(--neon-magenta); }
#spread-3 .field-note .classification { color: var(--neon-magenta); }
#spread-4 .field-note { border-left-color: var(--neon-amber); }
#spread-4 .field-note .classification { color: var(--neon-amber); }

/* ==========================================================================
   Spring-physics reveal animations
   ========================================================================== */

.reveal {
    opacity: 0;
    transform: translateY(15px);
    transition: transform 500ms var(--spring), opacity 500ms var(--spring-soft);
}

.spread.is-active .reveal {
    animation: springReveal 500ms var(--spring) both;
}

@keyframes springReveal {
    0%   { transform: translateY(15px); opacity: 0; }
    70%  { transform: translateY(-3px); opacity: 1; }
    100% { transform: translateY(0);    opacity: 1; }
}

.spread.is-active .reveal:nth-of-type(1) { animation-delay: 60ms; }
.spread.is-active .reveal:nth-of-type(2) { animation-delay: 180ms; }
.spread.is-active .reveal:nth-of-type(3) { animation-delay: 300ms; }
.spread.is-active .reveal:nth-of-type(4) { animation-delay: 420ms; }

/* Entire spread spring slide */
.spread {
    transform: translateY(30px);
    opacity: 0;
    transition:
        transform 700ms var(--spring),
        opacity 600ms var(--spring-soft);
}

.spread.is-active,
.spread.has-entered {
    transform: translateY(0);
    opacity: 1;
}

/* ==========================================================================
   Icon hover wobble (applied to foliage and index icons)
   ========================================================================== */

.leaf,
.index-item .idx-icon {
    transform-origin: center;
    transition: transform 300ms var(--spring);
    cursor: pointer;
}

.leaf:hover,
.index-item:hover .idx-icon {
    animation: wobble 400ms var(--spring) both;
}

@keyframes wobble {
    0%   { transform: rotate(0deg); }
    25%  { transform: rotate(2deg); }
    55%  { transform: rotate(-1.5deg); }
    80%  { transform: rotate(0.5deg); }
    100% { transform: rotate(0deg); }
}

.leaf-crown {
    animation: pulseGlow 3.2s ease-in-out infinite alternate;
    transform-box: fill-box;
    transform-origin: center;
}

@keyframes pulseGlow {
    0%   { filter: drop-shadow(0 0 2px rgba(224, 240, 232, 0.2)); }
    100% { filter: drop-shadow(0 0 8px rgba(224, 240, 232, 0.55)); }
}

/* Particles drift */
.particles circle {
    animation: drift 7s ease-in-out infinite alternate;
}
.particles circle:nth-child(2) { animation-duration: 6s; animation-delay: -2s; }
.particles circle:nth-child(3) { animation-duration: 8s; animation-delay: -3s; }
.particles circle:nth-child(4) { animation-duration: 9s; animation-delay: -1s; }
.particles circle:nth-child(5) { animation-duration: 5.5s; animation-delay: -4s; }
.particles circle:nth-child(6) { animation-duration: 7.5s; animation-delay: -0.5s; }

@keyframes drift {
    0%   { transform: translate(0, 0);   opacity: 0.35; }
    100% { transform: translate(6px, -8px); opacity: 0.9; }
}

/* Pattern icons — drawn-in via stroke-dasharray set in JS */
.pattern-icon {
    transform-origin: center;
    stroke-dasharray: var(--len, 120);
    stroke-dashoffset: var(--len, 120);
    transition: stroke-dashoffset 700ms var(--spring);
}

.spread.is-active .pattern-icon,
.spread.has-entered .pattern-icon {
    stroke-dashoffset: 0;
}

.pattern-icon:hover {
    animation: wobble 400ms var(--spring) both;
}

/* ==========================================================================
   Spread 5 — Index
   ========================================================================== */

.spread-index {
    grid-template-columns: 1fr;
    padding: 72px 10vw;
    align-items: start;
}

.index-wrap {
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 28px;
    padding: 36px 0;
}

.index-header {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--rule);
}

.index-header h2 {
    font-size: clamp(2rem, 4vw, 3.2rem);
    color: var(--text-primary);
}

.index-header p {
    max-width: 60ch;
    color: var(--text-second);
}

.index-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
}

.index-item {
    --accent: var(--neon-green);
    display: grid;
    grid-template-columns: 56px 44px 1fr auto;
    align-items: center;
    gap: 20px;
    padding: 18px 4px;
    border-bottom: 1px dashed var(--rule);
    transition: transform 400ms var(--spring),
                background 300ms ease;
    cursor: pointer;
    color: var(--text-primary);
}

.index-item:hover {
    transform: translateX(6px);
    background: rgba(17, 24, 34, 0.55);
}

.idx-num {
    font-family: "Space Grotesk", "Inter", sans-serif;
    font-weight: 600;
    font-size: 13px;
    letter-spacing: 0.18em;
    color: var(--accent);
}

.idx-icon {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
}

.idx-icon svg {
    width: 100%;
    height: 100%;
}

.idx-title {
    font-family: "Fraunces", Georgia, serif;
    font-weight: 600;
    font-size: clamp(1rem, 1.4vw, 1.25rem);
    color: var(--text-primary);
    letter-spacing: 0.005em;
}

.idx-meta {
    font-family: "Space Grotesk", "Inter", sans-serif;
    font-size: 11px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--text-second);
    white-space: nowrap;
}

.index-footer {
    margin-top: 12px;
    border-top: 1px solid var(--rule);
    padding-top: 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.index-footer p {
    font-size: 14px;
    font-style: italic;
    color: var(--text-second);
    max-width: 62ch;
    margin: 0;
}

/* ==========================================================================
   Rail (spread indicator) + progress bar
   ========================================================================== */

.rail {
    position: fixed;
    right: 22px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 20;
}

.rail-dot {
    width: 38px;
    height: 20px;
    border: none;
    background: transparent;
    color: rgba(184, 200, 192, 0.45);
    font-family: "Space Grotesk", "Inter", sans-serif;
    font-size: 10px;
    letter-spacing: 0.16em;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    position: relative;
    transition: color 300ms var(--spring), transform 300ms var(--spring);
}

.rail-dot::before {
    content: "";
    width: 18px;
    height: 1px;
    background: currentColor;
    margin-right: 8px;
    transition: width 300ms var(--spring), background 300ms ease;
}

.rail-dot.active {
    color: var(--neon-green);
    transform: translateX(-4px);
}

.rail-dot.active::before {
    width: 28px;
    background: var(--neon-green);
}

.rail-dot:hover {
    color: var(--accent-jade);
}

.progress {
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    height: 2px;
    background: rgba(42, 58, 50, 0.35);
    z-index: 30;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--neon-green), var(--neon-cyan));
    transition: width 200ms var(--spring-soft);
}

/* ==========================================================================
   Responsive — collapse to single column on mobile
   ========================================================================== */

@media (max-width: 900px) {
    .spread {
        grid-template-columns: 1fr;
        padding: 48px 28px;
        gap: 28px;
    }
    .spread-cover {
        padding: 40px 24px;
    }
    .cover-illustration svg {
        max-height: 40vh;
    }
    .plate-frame {
        max-width: 520px;
        margin: 0 auto;
    }
    .description {
        padding: 0;
    }
    .taxonomy {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    .rail {
        right: 8px;
        gap: 8px;
    }
    .rail-dot {
        width: 26px;
        font-size: 9px;
    }
    .rail-dot::before {
        width: 10px;
    }
    .rail-dot.active::before {
        width: 16px;
    }
    .index-item {
        grid-template-columns: 40px 32px 1fr;
        grid-template-rows: auto auto;
    }
    .idx-meta {
        grid-column: 3 / 4;
        grid-row: 2;
    }
    .spread-index {
        padding: 48px 24px;
    }
}

@media (max-width: 520px) {
    h1 { font-size: clamp(2.2rem, 10vw, 3.2rem); }
    .cover-title { font-size: clamp(2.4rem, 11vw, 3.6rem); }
    .spread { padding: 36px 18px; }
}
