/* lupin.day - Herbarium of Impossible Lupins */
/* Color Palette */
:root {
    --paper-light: #f4edd8;
    --paper-dark: #e8d9b8;
    --ink-primary: #2d3a2e;
    --ink-secondary: #4a4a40;
    --lupin-violet: #7b4fa2;
    --impossible-pink: #e86f9e;
    --pollen-gold: #f4c842;
    --dried-rose: #c47a6c;
    --pressed-sage: #89a88b;
    --faded-sepia: #8b6f4e;
    --lupin-gradient: linear-gradient(135deg, #7b4fa2 0%, #e86f9e 45%, #f4c842 100%);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.8vw, 1.15rem);
    line-height: 1.72;
    color: var(--ink-secondary);
    background:
        repeating-linear-gradient(
            3deg,
            #f4edd8 0px,
            #f4edd8 1px,
            #f2e9d0 1px,
            #f2e9d0 2px
        ),
        radial-gradient(ellipse at center, transparent 40%, rgba(45,58,46,0.08) 100%);
    background-color: #f4edd8;
    overflow-x: hidden;
}

/* ====================== */
/* ENTRY OVERLAY          */
/* ====================== */
#entry-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        repeating-linear-gradient(
            3deg,
            #f4edd8 0px,
            #f4edd8 1px,
            #f2e9d0 1px,
            #f2e9d0 2px
        );
    background-color: #f4edd8;
    transition: clip-path 1.2s ease-in-out, opacity 0.6s ease;
    clip-path: inset(0 0 0 0);
}

#entry-overlay.tearing {
    clip-path: inset(0 0 100% 0);
}

#entry-overlay.hidden {
    opacity: 0;
    pointer-events: none;
    display: none;
}

#entry-svg {
    width: 300px;
    height: 450px;
    max-width: 80vw;
    max-height: 80vh;
}

/* Seed animation */
.seed-left, .seed-right {
    transition: transform 0.8s ease-in-out;
}

#entry-overlay.seed-crack .seed-left {
    transform: translateX(-12px) rotate(-15deg);
}

#entry-overlay.seed-crack .seed-right {
    transform: translateX(12px) rotate(15deg);
}

#stalk-line {
    stroke-dasharray: 360;
    stroke-dashoffset: 360;
    transition: stroke-dashoffset 1.5s ease-in-out;
}

#entry-overlay.stalk-grow #stalk-line {
    stroke-dashoffset: 0;
}

.leaf-node {
    opacity: 0;
    transform: scale(0);
    transform-origin: center bottom;
    transition: opacity 0.5s ease, transform 0.5s ease;
}

#entry-overlay.leaves-appear #leaf-node-1 {
    opacity: 1;
    transform: scale(1);
    transition-delay: 0s;
}

#entry-overlay.leaves-appear #leaf-node-2 {
    opacity: 1;
    transform: scale(1);
    transition-delay: 0.2s;
}

#entry-overlay.leaves-appear #leaf-node-3 {
    opacity: 1;
    transform: scale(1);
    transition-delay: 0.4s;
}

#flower-spire {
    opacity: 0;
    transform: scale(0);
    transform-origin: center bottom;
    transition: opacity 0.8s ease, transform 0.8s ease;
}

#entry-overlay.bloom #flower-spire {
    opacity: 1;
    transform: scale(1);
}

/* ====================== */
/* NAVIGATION             */
/* ====================== */
#site-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 20px 24px;
    pointer-events: none;
}

.nav-label {
    pointer-events: auto;
    background: var(--paper-light);
    border: 1px solid var(--paper-dark);
    padding: 8px 16px 6px;
    transform: rotate(-1.5deg);
    box-shadow: 2px 3px 8px rgba(139,111,78,0.15);
    clip-path: polygon(2% 0%, 98% 1%, 100% 3%, 99% 97%, 97% 100%, 3% 99%, 0% 96%, 1% 2%);
}

.nav-domain {
    display: block;
    font-family: 'Caveat', cursive;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--ink-primary);
    line-height: 1.2;
}

.nav-subtitle {
    display: block;
    font-family: 'Caveat', cursive;
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--faded-sepia);
    line-height: 1.2;
}

#home-btn {
    pointer-events: auto;
    background: var(--paper-light);
    border: 1px solid var(--paper-dark);
    padding: 6px;
    cursor: pointer;
    transform: rotate(2deg);
    box-shadow: 1px 2px 6px rgba(139,111,78,0.12);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

#home-btn:hover {
    transform: rotate(0deg) scale(1.1);
    box-shadow: 2px 4px 10px rgba(139,111,78,0.2);
}

/* ====================== */
/* MAIN LAYOUT            */
/* ====================== */
#herbarium {
    max-width: 1200px;
    margin: 0 auto;
    padding: 100px 20px 60px;
    position: relative;
    margin-left: calc(50% - 640px);
}

@media (max-width: 1300px) {
    #herbarium {
        margin-left: auto;
        margin-right: auto;
    }
}

/* ====================== */
/* CARD GRID              */
/* ====================== */
#card-grid,
.card-grid-section {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    padding: 0 10px;
}

/* ====================== */
/* SPECIMEN CARDS         */
/* ====================== */
.specimen-card {
    position: relative;
    transform: rotate(var(--card-rotation, 0deg));
    transition: transform 0.6s ease, box-shadow 0.6s ease;
    cursor: pointer;
    animation: cardPulse 3s ease-in-out infinite;
    animation-delay: calc(var(--card-rotation, 0) * 100);
}

.specimen-card:hover {
    animation-play-state: paused;
    transform: rotate(var(--card-rotation, 0deg)) translateY(-4px);
    z-index: 10;
}

.specimen-card:hover .card-inner {
    box-shadow:
        inset 0 0 0 8px var(--paper-light),
        inset 0 0 0 10px transparent,
        4px 8px 24px rgba(45,58,46,0.15);
    border-image: linear-gradient(135deg, #7b4fa2 0%, #e86f9e 45%, #f4c842 100%) 1;
}

@keyframes cardPulse {
    0%, 100% { transform: rotate(var(--card-rotation, 0deg)) scale(1); }
    50% { transform: rotate(var(--card-rotation, 0deg)) scale(1.008); }
}

.card-inner {
    background: var(--paper-light);
    border: 1px solid var(--paper-dark);
    padding: 28px 24px 20px;
    position: relative;
    overflow: hidden;
    box-shadow:
        inset 0 0 0 8px var(--paper-light),
        inset 0 0 0 9px var(--paper-dark),
        2px 4px 12px rgba(139,111,78,0.1);
    transition: box-shadow 0.6s ease, border-color 0.6s ease;
    clip-path: polygon(1% 0%, 99% 0.5%, 100% 1.5%, 99.5% 98%, 98% 100%, 2% 99.5%, 0% 98.5%, 0.5% 1%);
}

/* Herbarium Sheet */
.herbarium-sheet {
    min-height: 320px;
}

/* Field Sketch (wide, 2 columns) */
.field-sketch {
    grid-column: span 2;
    min-height: 280px;
}

.field-sketch .card-inner {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.sketch-illustration {
    flex: 0 0 180px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sketch-illustration svg {
    width: 100%;
    height: auto;
}

.sketch-text {
    flex: 1;
    min-width: 0;
}

/* Expedition Log (tall, 2 rows) */
.expedition-log {
    grid-row: span 2;
    min-height: 520px;
}

/* Foxing spots */
.card-foxing {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    background:
        radial-gradient(circle at var(--fox-x1, 20%) var(--fox-y1, 30%), rgba(139,111,78,0.12) 0%, transparent 8px),
        radial-gradient(circle at var(--fox-x2, 70%) var(--fox-y2, 60%), rgba(139,111,78,0.1) 0%, transparent 6px),
        radial-gradient(circle at 50% 80%, rgba(139,111,78,0.08) 0%, transparent 10px);
}

/* Fold lines */
.card-fold {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.card-fold::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: var(--fold-y, 50%);
    height: 1px;
    background: rgba(139,111,78,0.15);
}

.card-fold::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 55%;
    width: 1px;
    background: rgba(139,111,78,0.1);
}

/* Card border decoration */
.card-border-decor {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 60px;
    height: 60px;
    pointer-events: none;
}

.card-border-decor-right {
    left: auto;
    right: 0;
}

.leaf-corner {
    width: 100%;
    height: 100%;
}

/* Typography in cards */
.specimen-id {
    display: block;
    font-family: 'Courier Prime', monospace;
    font-size: 0.85rem;
    color: #6b7b8d;
    margin-bottom: 6px;
    letter-spacing: 0.05em;
}

.specimen-name {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: clamp(1.8rem, 4vw, 3.6rem);
    color: var(--ink-primary);
    letter-spacing: 0.04em;
    line-height: 1.15;
    margin-bottom: 4px;
    text-shadow: 0 0 1px rgba(45,58,46,0.3);
}

.specimen-subtitle {
    font-family: 'Caveat', cursive;
    font-weight: 400;
    font-size: clamp(1rem, 2vw, 1.3rem);
    color: var(--faded-sepia);
    margin-bottom: 14px;
    font-style: italic;
}

.field-notes {
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.8vw, 1.15rem);
    color: var(--ink-secondary);
    line-height: 1.72;
    margin-bottom: 12px;
    text-shadow: 0 0 1px rgba(45,58,46,0.15);
}

.marginalia {
    display: block;
    font-family: 'Caveat', cursive;
    font-weight: 400;
    font-size: clamp(0.85rem, 1.5vw, 1.1rem);
    color: var(--faded-sepia);
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px dashed rgba(139,111,78,0.25);
}

/* ====================== */
/* BREATH SPACES          */
/* ====================== */
.breath-space {
    width: 100%;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    margin: 40px 0;
}

.stalk-svg {
    height: 180px;
    width: auto;
}

.growing-stalk {
    stroke-dasharray: 180;
    stroke-dashoffset: 180;
    transition: stroke-dashoffset 1.5s ease-in-out;
}

.breath-space.visible .growing-stalk {
    stroke-dashoffset: 0;
}

.stalk-leaf {
    opacity: 0;
    transform: scale(0);
    transform-origin: center bottom;
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.breath-space.visible .stalk-leaf-1 {
    opacity: 1;
    transform: scale(1);
    transition-delay: 0.4s;
}

.breath-space.visible .stalk-leaf-2 {
    opacity: 1;
    transform: scale(1);
    transition-delay: 0.7s;
}

.breath-space.visible .stalk-leaf-3 {
    opacity: 1;
    transform: scale(1);
    transition-delay: 1s;
}

.breath-space-final {
    flex-direction: column;
    height: 260px;
    margin-bottom: 0;
}

.colophon {
    font-family: 'Caveat', cursive;
    font-size: 1.1rem;
    color: var(--faded-sepia);
    margin-top: 12px;
    text-align: center;
    opacity: 0.7;
}

/* ====================== */
/* CARD OVERLAY           */
/* ====================== */
#card-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(45,58,46,0.4);
    opacity: 1;
    transition: opacity 0.4s ease;
}

#card-overlay.card-overlay-hidden {
    opacity: 0;
    pointer-events: none;
}

#expanded-card {
    max-width: 80vw;
    max-height: 80vh;
    overflow-y: auto;
    background: var(--paper-light);
    border: 1px solid var(--paper-dark);
    padding: 40px 36px;
    box-shadow:
        inset 0 0 0 8px var(--paper-light),
        inset 0 0 0 9px var(--paper-dark),
        8px 16px 48px rgba(45,58,46,0.25);
    clip-path: polygon(1% 0%, 99% 0.5%, 100% 1.5%, 99.5% 98%, 98% 100%, 2% 99.5%, 0% 98.5%, 0.5% 1%);
    transform: scale(0.9);
    transition: transform 0.4s ease;
}

#card-overlay:not(.card-overlay-hidden) #expanded-card {
    transform: scale(1);
}

#expanded-card .specimen-name {
    font-size: clamp(2rem, 5vw, 4rem);
    margin-bottom: 8px;
}

#expanded-card .field-notes {
    font-size: clamp(1rem, 2vw, 1.2rem);
    max-width: 65ch;
}

#expanded-card .expanded-extra {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--paper-dark);
}

#expanded-card .classification {
    font-family: 'Courier Prime', monospace;
    font-size: 0.85rem;
    color: #6b7b8d;
    margin-bottom: 8px;
}

#expanded-card .dream-note {
    font-family: 'Caveat', cursive;
    font-size: 1.15rem;
    color: var(--lupin-violet);
    line-height: 1.5;
}

/* ====================== */
/* RESPONSIVE             */
/* ====================== */
@media (max-width: 768px) {
    #card-grid,
    .card-grid-section {
        grid-template-columns: repeat(2, 1fr);
        gap: 18px;
    }

    .field-sketch {
        grid-column: span 2;
    }

    .field-sketch .card-inner {
        flex-direction: column;
    }

    .sketch-illustration {
        flex: 0 0 auto;
        width: 100%;
        max-width: 200px;
        margin: 0 auto 12px;
    }

    .expedition-log {
        grid-row: span 1;
        min-height: auto;
    }

    #herbarium {
        padding: 90px 12px 40px;
    }

    .specimen-name {
        font-size: clamp(1.4rem, 3.5vw, 2.4rem);
    }

    .card-inner {
        padding: 20px 16px 16px;
    }
}

@media (max-width: 480px) {
    #card-grid,
    .card-grid-section {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .field-sketch {
        grid-column: span 1;
    }

    .specimen-card {
        transform: rotate(0deg);
        --card-rotation: 0deg;
    }

    .breath-space {
        height: 150px;
        margin: 24px 0;
    }

    #expanded-card {
        max-width: 95vw;
        max-height: 90vh;
        padding: 24px 18px;
    }

    .nav-label {
        padding: 6px 12px 4px;
    }

    .nav-domain {
        font-size: 1.2rem;
    }
}

/* ====================== */
/* REDUCED MOTION         */
/* ====================== */
@media (prefers-reduced-motion: reduce) {
    .specimen-card {
        animation: none;
    }

    #entry-overlay {
        display: none;
    }

    .growing-stalk,
    .stalk-leaf,
    .leaf-node,
    #flower-spire,
    #stalk-line {
        transition: none;
    }
}
