/* ===================================================
   bcd.day - Goblincore Apothecary Curiosity Cabinet
   =================================================== */

/* --- CSS Custom Properties --- */
:root {
    --candy-cream: #FFF5E6;
    --mulberry-night: #4A1942;
    --hot-fuchsia: #FF2D8A;
    --goblin-chartreuse: #BAFF29;
    --electric-mauve: #C77DFF;
    --tangerine-pop: #FF8C42;
    --bark-brown: #3D2B1F;
    --vellum: #FFFDF7;
    --forest-dew: #2D6A4F;
    --deep-mulberry: #5C2D60;

    --font-display: 'Playfair Display', Georgia, serif;
    --font-handwritten: 'Caveat', cursive;
    --font-body: 'Nunito', 'Segoe UI', sans-serif;
}

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    background-color: var(--candy-cream);
    color: var(--bark-brown);
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(0.95rem, 1.8vw, 1.15rem);
    line-height: 1.7;
    overflow-x: hidden;
    position: relative;
}

/* Paper texture overlay on body */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* SVG filters hidden */
.svg-filters {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* --- Progress Stem --- */
.progress-stem {
    position: fixed;
    right: 16px;
    top: 0;
    height: 100vh;
    width: 30px;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.stem-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.stem-line {
    stroke-dasharray: 1200;
    stroke-dashoffset: 1200;
    transition: stroke-dashoffset 0.3s ease-out;
}

.stem-node {
    position: absolute;
    right: 5px;
    width: 20px;
    height: 20px;
    pointer-events: auto;
    cursor: pointer;
    opacity: 0.4;
    transition: opacity 0.5s ease, transform 0.3s ease;
    transform: scale(0.85);
}

.stem-node.active {
    opacity: 1;
    transform: scale(1.1);
}

.stem-node:hover {
    opacity: 0.8;
    transform: scale(1.05);
}

/* --- Section Base --- */
.section {
    min-height: 100vh;
    padding: 80px 5vw;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0.97);
    transition: opacity 0.6s ease, transform 0.4s ease, filter 0.4s ease;
}

.section.visible {
    opacity: 1;
    transform: scale(1);
}

.section.pulse {
    filter: brightness(1.08);
}

/* --- Section Headings --- */
.section-heading {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: clamp(2rem, 6vw, 5rem);
    letter-spacing: 0.04em;
    color: var(--mulberry-night);
    text-align: center;
    margin-bottom: 0.5em;
}

.section-heading.light-heading {
    color: var(--candy-cream);
}

.section-intro {
    text-align: center;
    margin-bottom: 3rem;
    max-width: 600px;
}

.caveat-text {
    font-family: var(--font-handwritten);
    font-weight: 700;
    font-size: clamp(1rem, 2.5vw, 1.6rem);
    letter-spacing: 0.01em;
    color: var(--bark-brown);
    opacity: 0.8;
}

.light-text {
    color: var(--candy-cream);
    opacity: 0.75;
}

/* ===================================================
   SECTION 1: HERO VITRINE
   =================================================== */
.section-hero {
    background: radial-gradient(ellipse at center, var(--deep-mulberry), var(--mulberry-night) 70%);
    position: relative;
    overflow: hidden;
    opacity: 1;
    transform: none;
}

.hero-spotlight {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 60vmax;
    height: 60vmax;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle, rgba(92,45,96,0.5) 0%, transparent 70%);
    pointer-events: none;
}

.hero-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 2;
}

.hero-mushroom {
    width: clamp(200px, 40vw, 400px);
    height: auto;
    transform: translateY(30%);
    opacity: 0;
    animation: mushroomGrow 2.5s ease-out forwards;
}

.mushroom-svg {
    width: 100%;
    height: auto;
    display: block;
    animation: mushroomBreathe 8s ease-in-out infinite;
}

@keyframes mushroomGrow {
    0% {
        transform: translateY(30%);
        opacity: 0;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes mushroomBreathe {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

.hero-title {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: clamp(3.5rem, 12vw, 10rem);
    letter-spacing: 0.04em;
    color: var(--candy-cream);
    opacity: 0;
    animation: fadeIn 1s ease-out 1.5s forwards;
    text-align: center;
    position: relative;
    margin-top: -1rem;
}

.hero-subtitle {
    font-family: var(--font-handwritten);
    font-weight: 700;
    font-size: clamp(1rem, 2.5vw, 1.6rem);
    color: var(--tangerine-pop);
    opacity: 0;
    animation: fadeIn 1s ease-out 2.5s forwards;
    text-align: center;
    margin-top: 0.5rem;
}

@keyframes fadeIn {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

/* Specimen pin below hero title */
.specimen-pin {
    position: absolute;
    bottom: 15%;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    animation: fadeIn 0.8s ease-out 3s forwards;
    z-index: 3;
}

/* Hero sticky fade on scroll */
.section-hero.scrolled .hero-mushroom {
    transition: transform 0.3s ease, opacity 0.3s ease;
}

/* ===================================================
   INTERSTITIAL STRIPS
   =================================================== */
.interstitial {
    height: clamp(60px, 15vh, 120px);
    overflow: hidden;
    position: relative;
    background-color: var(--candy-cream);
}

.interstitial-track {
    width: 200%;
    height: 100%;
    display: flex;
    align-items: center;
    will-change: transform;
}

.interstitial-pattern {
    width: 100%;
    height: 100%;
}

/* ===================================================
   SECTION 2: SPECIMEN GRID
   =================================================== */
.section-specimens {
    background-color: var(--candy-cream);
    padding-top: 100px;
    padding-bottom: 100px;
}

.specimen-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    max-width: 1100px;
    width: 100%;
}

/* Row 2 (3 items): items 3-5 span 3 cols */
.specimen-grid .specimen-card:nth-child(3),
.specimen-grid .specimen-card:nth-child(4),
.specimen-grid .specimen-card:nth-child(5) {
    /* Switch to 3-col subgrid via wrapper - handled separately */
}

/* 2-3-2 grid rhythm using grid areas */
.specimen-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 2rem;
    max-width: 1100px;
    width: 100%;
}

/* Row 1: 2 items, each spanning 3 cols */
.specimen-card:nth-child(1) { grid-column: 1 / 4; }
.specimen-card:nth-child(2) { grid-column: 4 / 7; }

/* Row 2: 3 items, each spanning 2 cols */
.specimen-card:nth-child(3) { grid-column: 1 / 3; }
.specimen-card:nth-child(4) { grid-column: 3 / 5; }
.specimen-card:nth-child(5) { grid-column: 5 / 7; }

/* Row 3: 2 wide items, each spanning 3 cols */
.specimen-card:nth-child(6) { grid-column: 1 / 4; }
.specimen-card:nth-child(7) { grid-column: 4 / 7; }

/* --- Specimen Cards --- */
.specimen-card {
    background: var(--vellum);
    padding: 1.5rem;
    position: relative;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.specimen-card:hover {
    transform: translateY(-4px);
}

.card-border-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

.card-border-svg svg {
    width: 100%;
    height: 100%;
}

.card-border-path {
    stroke: var(--bark-brown);
    stroke-dasharray: 400;
    stroke-dashoffset: 0;
    transition: stroke 0.6s ease, stroke-dashoffset 0.6s ease;
}

.specimen-card:hover .card-border-path {
    stroke: var(--hot-fuchsia);
    stroke-dashoffset: 400;
    animation: borderRedraw 0.6s ease forwards;
}

@keyframes borderRedraw {
    0% { stroke-dashoffset: 400; stroke: var(--hot-fuchsia); }
    100% { stroke-dashoffset: 0; stroke: var(--hot-fuchsia); }
}

.card-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 1;
}

.specimen-illustration {
    width: 100%;
    max-width: 180px;
    margin-bottom: 1rem;
}

.specimen-illustration svg {
    width: 100%;
    height: auto;
    display: block;
}

/* Moth wing flutter animation */
.moth-illustration svg {
    animation: mothFlutter 6s ease-in-out infinite;
}

@keyframes mothFlutter {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(1deg); }
    75% { transform: rotate(-1deg); }
}

/* --- Specimen Labels --- */
.specimen-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-direction: column;
    text-align: center;
    transition: transform 0.4s ease;
}

.specimen-card:hover .specimen-label {
    animation: labelSwing 0.4s ease-in-out;
}

@keyframes labelSwing {
    0% { transform: rotate(0deg); }
    30% { transform: rotate(3deg); }
    60% { transform: rotate(-1.5deg); }
    100% { transform: rotate(0deg); }
}

.label-tag {
    display: inline-block;
}

.label-name {
    font-family: var(--font-handwritten);
    font-weight: 700;
    font-size: clamp(0.9rem, 2vw, 1.3rem);
    font-style: italic;
    color: var(--bark-brown);
    opacity: 0.8;
}

.label-common {
    font-family: var(--font-body);
    font-weight: 600;
    font-size: clamp(0.8rem, 1.5vw, 1rem);
    color: var(--bark-brown);
    opacity: 0.6;
}

/* --- Collection Stamps --- */
.collection-stamp {
    position: absolute;
    top: 0.8rem;
    right: 0.8rem;
    font-family: var(--font-handwritten);
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--hot-fuchsia);
    opacity: 0.3;
    border: 1px solid var(--hot-fuchsia);
    border-radius: 50%;
    width: 3rem;
    height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease, transform 0.3s ease;
    cursor: pointer;
    z-index: 3;
}

.collection-stamp:hover,
.collection-stamp.pressed {
    animation: stampPulse 0.3s ease;
}

@keyframes stampPulse {
    0% { transform: scale(1); opacity: 0.3; }
    50% { transform: scale(1.15); opacity: 0.6; }
    100% { transform: scale(1); opacity: 0.3; }
}

/* ===================================================
   SECTION 3: CRYSTAL CABINET (Dark)
   =================================================== */
.section-crystals {
    background: var(--mulberry-night);
    padding-top: 100px;
    padding-bottom: 100px;
}

.crystal-display {
    display: flex;
    gap: 3rem;
    justify-content: center;
    flex-wrap: wrap;
    max-width: 1100px;
    width: 100%;
}

/* --- Crystal Jars --- */
.crystal-jar {
    position: relative;
    width: clamp(200px, 25vw, 300px);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
}

.jar-glass {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 80%;
    border: 1.5px solid rgba(255, 253, 247, 0.15);
    border-radius: 8px 8px 0 0;
    overflow: hidden;
    pointer-events: none;
}

/* Jar glass shimmer */
.jar-glass::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.02), transparent);
    animation: jarShimmer 12s linear infinite;
}

@keyframes jarShimmer {
    0% { left: -50%; }
    100% { left: 150%; }
}

.jar-content {
    width: 100%;
    margin-bottom: 1rem;
}

.jar-content svg {
    width: 100%;
    height: auto;
    display: block;
}

/* Crystal shimmer animation */
.jar-content polygon,
.jar-content rect {
    animation: crystalShimmer 8s ease-in-out infinite;
}

.crystal-jar:nth-child(2) .jar-content polygon,
.crystal-jar:nth-child(2) .jar-content rect {
    animation-delay: -2.5s;
}

.crystal-jar:nth-child(3) .jar-content polygon,
.crystal-jar:nth-child(3) .jar-content rect {
    animation-delay: -5s;
}

@keyframes crystalShimmer {
    0%, 100% { fill-opacity: 0.4; }
    50% { fill-opacity: 0.7; }
}

.jar-label {
    color: var(--candy-cream);
    font-size: clamp(1.1rem, 2.5vw, 1.5rem);
    text-align: center;
    margin-top: 0.5rem;
}

.jar-sublabel {
    color: var(--electric-mauve);
    font-size: clamp(0.8rem, 1.8vw, 1.1rem);
    text-align: center;
    opacity: 0.7;
}

/* ===================================================
   SECTION 4: BOTANICAL NOTES
   =================================================== */
.section-botanical {
    background-color: var(--candy-cream);
    padding-top: 100px;
    padding-bottom: 100px;
}

.botanical-grid {
    display: flex;
    flex-direction: column;
    gap: 4rem;
    max-width: 900px;
    width: 100%;
}

.botanical-entry {
    display: flex;
    align-items: center;
    gap: 3rem;
}

.botanical-entry-reverse {
    flex-direction: row-reverse;
}

.botanical-illustration {
    flex: 0 0 clamp(140px, 20vw, 220px);
}

.botanical-illustration svg {
    width: 100%;
    height: auto;
    display: block;
}

.botanical-text {
    flex: 1;
}

.botanical-name {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: clamp(1.3rem, 3vw, 2rem);
    letter-spacing: 0.04em;
    color: var(--mulberry-night);
    margin-bottom: 0.2em;
    font-style: italic;
}

.botanical-common {
    margin-bottom: 0.8em;
    color: var(--forest-dew);
}

.botanical-note {
    font-family: var(--font-body);
    font-weight: 400;
    line-height: 1.7;
    color: var(--bark-brown);
}

/* ===================================================
   SECTION 5: CABINET FOOTER
   =================================================== */
.section-footer {
    background: linear-gradient(180deg, var(--mulberry-night) 0%, #2a0f28 100%);
    padding-top: 80px;
    padding-bottom: 60px;
    min-height: 80vh;
}

.footer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2.5rem;
    max-width: 1000px;
    width: 100%;
}

.footer-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.drawer-pull {
    width: 50px;
    height: 25px;
}

.footer-title {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: clamp(1.5rem, 4vw, 3rem);
    color: var(--candy-cream);
    letter-spacing: 0.04em;
}

.footer-labels {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    width: 100%;
}

.apothecary-label {
    position: relative;
    padding: 1.8rem;
    background: rgba(255, 253, 247, 0.03);
}

.label-border {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.label-border svg {
    width: 100%;
    height: 100%;
}

.label-title {
    display: block;
    color: var(--tangerine-pop);
    font-size: clamp(1.1rem, 2.5vw, 1.5rem);
    margin-bottom: 0.8rem;
}

.label-body {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(0.85rem, 1.5vw, 1rem);
    color: var(--candy-cream);
    line-height: 1.7;
    opacity: 0.75;
}

.footer-wax-seal {
    margin-top: 1rem;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.footer-wax-seal svg {
    width: 60px;
    height: 60px;
}

.footer-wax-seal:hover {
    animation: stampPulse 0.3s ease;
}

.footer-date {
    color: var(--electric-mauve);
    font-size: clamp(0.9rem, 2vw, 1.2rem);
    opacity: 0.6;
    text-align: center;
}

/* ===================================================
   ANIMATIONS: Reduced motion
   =================================================== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    .hero-mushroom {
        opacity: 1;
        transform: none;
    }
    .hero-title,
    .hero-subtitle,
    .specimen-pin {
        opacity: 1;
    }
}

/* ===================================================
   RESPONSIVE
   =================================================== */
@media (max-width: 768px) {
    .section {
        padding: 40px 5vw;
    }

    .specimen-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .specimen-card:nth-child(1),
    .specimen-card:nth-child(2),
    .specimen-card:nth-child(3),
    .specimen-card:nth-child(4),
    .specimen-card:nth-child(5),
    .specimen-card:nth-child(6),
    .specimen-card:nth-child(7) {
        grid-column: 1 / -1;
    }

    .crystal-display {
        flex-direction: column;
        align-items: center;
        gap: 2rem;
    }

    .crystal-jar {
        width: clamp(220px, 70vw, 300px);
    }

    .botanical-entry,
    .botanical-entry-reverse {
        flex-direction: column;
        text-align: center;
    }

    .botanical-illustration {
        flex: 0 0 auto;
        width: clamp(140px, 40vw, 200px);
    }

    .footer-labels {
        grid-template-columns: 1fr;
    }

    .progress-stem {
        display: none;
    }

    .footer-header {
        flex-direction: column;
        gap: 0.8rem;
    }

    .drawer-pull {
        display: none;
    }
}

@media (max-width: 480px) {
    .hero-title {
        font-size: clamp(2.5rem, 15vw, 5rem);
    }

    .section-heading {
        font-size: clamp(1.5rem, 8vw, 3rem);
    }
}
