/* ==========================================================================
   lune.dev — Victorian Naturalist's Moonlight Herbarium
   Color Palette: Midnight Herbarium
   Typography: Bebas Neue + Nunito + IBM Plex Mono
   ========================================================================== */

/* ---------- Palette Reference ----------
   Midnight Study:    #0F1B2E
   Deep Ink:          #162236
   Carrara Cream:     #F2EBE0
   Warm Ash:          #D4C8B8
   Rose Quartz:       #E8D4CC
   Aged Parchment:    #E8D5B7
   Warm Linen:        #D4C8B8
   Muted Gold:        #B8A07A
   Antique Brass:     #9A855F
   Pressed Sage:      #7A8B6B
   Moonflower White:  #F0E8D8
   Sepia Rust:        #A0654A
   Slate Blue:        #6B7B8F
   Card White:        #F8F4EE
   ========================================= */

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

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

body {
    background-color: #0F1B2E;
    color: #D4C8B8;
    font-family: 'Nunito', sans-serif;
    font-weight: 400;
    font-size: clamp(0.9rem, 1.3vw, 1.05rem);
    line-height: 1.75;
    letter-spacing: 0.005em;
    overflow-x: auto;
    overflow-y: hidden;
    height: 100vh;
    width: 100vw;
}

/* ---------- Horizontal Scroll Track ---------- */
#scroll-track {
    display: flex;
    flex-direction: row;
    height: 100vh;
    width: max-content;
    scroll-snap-type: x proximity;
    overflow-x: scroll;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

#scroll-track::-webkit-scrollbar {
    display: none;
}

/* ---------- Compartments (Base) ---------- */
.compartment {
    width: 100vw;
    height: 100vh;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    scroll-snap-align: start;
    position: relative;
    overflow: hidden;
}

/* ---------- Transition Veils ---------- */
.transition-veil {
    width: 30vw;
    height: 100vh;
    flex-shrink: 0;
    background-color: #0F1B2E;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.moonflower-veil {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ---------- Title Cartouche (Compartment 1) ---------- */
.compartment-title {
    background-color: #0F1B2E;
}

.cartouche-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 24px;
    animation: cartoucheFadeIn 1.4s cubic-bezier(0.22, 0.61, 0.36, 1) forwards;
}

@keyframes cartoucheFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.site-title {
    font-family: 'Bebas Neue', sans-serif;
    font-weight: 400;
    font-size: 12vw;
    letter-spacing: 0.15em;
    color: #E8D5B7;
    text-transform: uppercase;
    line-height: 1;
}

.ornamental-rule {
    width: 50vw;
    max-width: 600px;
}

.floral-rule {
    width: 100%;
    height: auto;
}

.subtitle {
    font-family: 'Nunito', sans-serif;
    font-weight: 400;
    font-size: 1rem;
    color: #D4C8B8;
    opacity: 0.4;
    letter-spacing: 0.05em;
}

/* ---------- Closing Cartouche ---------- */
.compartment-closing {
    background-color: #0F1B2E;
}

.ornamental-rule-top {
    margin-bottom: 8px;
}

.closing-title {
    font-family: 'Bebas Neue', sans-serif;
    font-weight: 400;
    font-size: clamp(2.5rem, 6vw, 5rem);
    letter-spacing: 0.12em;
    color: #E8D5B7;
    text-transform: uppercase;
    opacity: 0;
    transform: scale(0.85);
    transition: opacity 900ms cubic-bezier(0.22, 0.61, 0.36, 1),
                transform 900ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

.closing-title.visible {
    opacity: 1;
    transform: scale(1);
}

.closing-text {
    font-family: 'Nunito', sans-serif;
    font-weight: 400;
    font-size: clamp(0.9rem, 1.3vw, 1.05rem);
    color: #D4C8B8;
    opacity: 0.6;
    max-width: 480px;
    text-align: center;
    line-height: 1.75;
}

.closing-moonflower {
    margin-top: 16px;
    opacity: 0.5;
}

.closing-attribution {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #6B7B8F;
    opacity: 0.5;
    margin-top: 24px;
}

/* ---------- Botanical & Accent Colors ---------- */
.fern-frond path {
    fill: #7A8B6B;
}

.seed-dots .seed-brass {
    background: #9A855F;
}

.specimen-card .emphasis-text {
    color: #A0654A;
}

.marble-surface::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(ellipse at 60% 40%, #E8D4CC 0%, transparent 70%);
    opacity: 0.08;
    pointer-events: none;
}

/* ---------- Specimen Panels ---------- */
.compartment-specimen {
    background-color: #162236;
}

.marble-surface {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #F2EBE0;
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(212, 200, 184, 0.6) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 30%, rgba(232, 212, 204, 0.5) 0%, transparent 40%),
        radial-gradient(ellipse at 50% 80%, rgba(212, 200, 184, 0.4) 0%, transparent 60%),
        linear-gradient(135deg, rgba(255,255,255,0.08) 0%, transparent 50%);
    position: relative;
    overflow: hidden;
}

/* ---------- Specimen Grids ---------- */
.specimen-grid {
    display: grid;
    width: 85vw;
    max-width: 1100px;
    height: 80vh;
    position: relative;
    padding: 40px;
    gap: 0;
}

.specimen-grid-1 {
    grid-template-columns: 1.2fr 0.8fr 1fr;
    grid-template-rows: 1fr 1fr;
}

.specimen-grid-2 {
    grid-template-columns: 1fr 1fr 0.8fr 1.2fr;
    grid-template-rows: 1fr 1fr;
}

.specimen-grid-3 {
    grid-template-columns: 1.1fr 1fr 0.9fr 1fr;
    grid-template-rows: 1fr 1fr;
}

.specimen-grid-4 {
    grid-template-columns: 1.2fr 0.9fr 0.8fr 1.1fr;
    grid-template-rows: 1fr 1fr;
}

/* ---------- Specimen Cards ---------- */
.specimen-card {
    background-color: #F8F4EE;
    border: 1px solid #B8A07A;
    padding: 28px 24px;
    position: relative;
    z-index: 10;
    box-shadow: 3px 5px 15px rgba(15, 27, 46, 0.12);
    transition: transform 500ms ease-out, box-shadow 500ms ease-out;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow: hidden;
}

.specimen-card:hover {
    transform: scale(1.03) translateY(-4px) !important;
    box-shadow: 8px 12px 30px rgba(15, 27, 46, 0.2);
    z-index: 12;
}

/* Card placement - Grid 1 */
.card-1 {
    grid-column: 1 / 2;
    grid-row: 1 / 3;
    margin: 20px 10px 20px 20px;
}

.card-2 {
    grid-column: 2 / 3;
    grid-row: 1 / 2;
    margin: 30px -10px 5px 15px;
}

.card-3 {
    grid-column: 2 / 4;
    grid-row: 2 / 3;
    margin: -10px 20px 30px 10px;
}

/* Card placement - Grid 2 */
.card-4 {
    grid-column: 1 / 3;
    grid-row: 1 / 2;
    margin: 25px 10px 5px 15px;
}

.card-5 {
    grid-column: 3 / 4;
    grid-row: 1 / 3;
    margin: 15px 5px 15px -5px;
}

.card-6 {
    grid-column: 4 / 5;
    grid-row: 1 / 2;
    margin: 35px 20px 10px 10px;
}

.card-7 {
    grid-column: 1 / 3;
    grid-row: 2 / 3;
    margin: -5px 15px 25px 20px;
}

/* Card placement - Grid 3 */
.card-8 {
    grid-column: 1 / 2;
    grid-row: 1 / 2;
    margin: 20px 10px 5px 15px;
}

.card-9 {
    grid-column: 2 / 4;
    grid-row: 1 / 2;
    margin: 30px 5px 10px -10px;
}

.card-10 {
    grid-column: 4 / 5;
    grid-row: 1 / 3;
    margin: 15px 20px 20px 10px;
}

.card-11 {
    grid-column: 1 / 3;
    grid-row: 2 / 3;
    margin: -8px 15px 25px 20px;
}

/* Card placement - Grid 4 */
.card-12 {
    grid-column: 1 / 3;
    grid-row: 1 / 2;
    margin: 20px 10px 5px 15px;
}

.card-13 {
    grid-column: 3 / 5;
    grid-row: 1 / 2;
    margin: 30px 20px 10px -5px;
}

.card-14 {
    grid-column: 1 / 2;
    grid-row: 2 / 3;
    margin: -5px 10px 25px 20px;
}

.card-15 {
    grid-column: 2 / 4;
    grid-row: 2 / 3;
    margin: -10px 15px 20px 5px;
}

/* ---------- Specimen Labels ---------- */
.specimen-label {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #6B7B8F;
    display: inline-block;
    transform: rotate(1.5deg);
}

/* ---------- Specimen Headings ---------- */
.specimen-heading {
    font-family: 'Bebas Neue', sans-serif;
    font-weight: 400;
    font-size: clamp(1.8rem, 4vw, 3.5rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #0F1B2E;
    opacity: 0;
    transform: scale(0.85);
    transition: opacity 900ms cubic-bezier(0.22, 0.61, 0.36, 1),
                transform 900ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

.specimen-heading.visible {
    opacity: 1;
    transform: scale(1);
}

/* ---------- Specimen Text ---------- */
.specimen-text {
    font-family: 'Nunito', sans-serif;
    font-weight: 400;
    font-size: clamp(0.85rem, 1.2vw, 1rem);
    line-height: 1.75;
    color: #3a3a3a;
    max-width: 560px;
    letter-spacing: 0.005em;
}

.specimen-text-small {
    font-family: 'Nunito', sans-serif;
    font-weight: 400;
    font-size: clamp(0.75rem, 1vw, 0.85rem);
    line-height: 1.6;
    color: #6B7B8F;
    max-width: 400px;
}

/* ---------- Secondary Headings (for closing etc.) ---------- */
.closing-title,
.specimen-heading {
    font-family: 'Bebas Neue', sans-serif;
}

/* ---------- Seed Dots ---------- */
.seed-dots {
    display: flex;
    gap: 6px;
    align-items: center;
    padding-top: 4px;
}

.seed {
    display: inline-block;
    border-radius: 50%;
}

/* ---------- Botanical Illustrations ---------- */
.botanical-illustration {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
}

.fern-frond {
    width: 100%;
    max-width: 180px;
    height: auto;
}

.moonflower-illustration {
    width: 100%;
    max-width: 200px;
    height: auto;
}

/* ---------- Exhibit Bars ---------- */
.specimen-exhibit {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 8px 0;
}

.exhibit-bar {
    height: 6px;
    border-radius: 3px;
    transition: width 800ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* ---------- Instrument List ---------- */
.instrument-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 8px 0;
}

.instrument-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.instrument-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.instrument-name {
    font-family: 'Nunito', sans-serif;
    font-weight: 600;
    font-size: clamp(0.85rem, 1.1vw, 1rem);
    color: #3a3a3a;
    letter-spacing: 0.02em;
}

/* ---------- Moon Phases ---------- */
.moon-phases {
    display: flex;
    gap: 20px;
    align-items: center;
    justify-content: center;
    padding: 16px 0;
    flex-wrap: wrap;
}

.moon-phase {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.phase-label {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 0.6rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #6B7B8F;
}

/* ---------- Moonflower Motif ---------- */
.moonflower {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.moonflower-large {
    width: 200px;
    height: 200px;
}

.moonflower-medium {
    width: 48px;
    height: 48px;
}

.petal {
    position: absolute;
    border-radius: 50%;
    opacity: 0.85;
}

/* Large Moonflower Petals */
.moonflower-large .petal {
    width: 60px;
    height: 90px;
    top: 50%;
    left: 50%;
    transform-origin: center bottom;
}

.moonflower-large .petal-1 {
    background: #F0E8D8;
    transform: translate(-50%, -100%) rotate(0deg);
    animation: petalBreath1 10s ease-in-out infinite;
}
.moonflower-large .petal-2 {
    background: #E8D5B7;
    transform: translate(-50%, -100%) rotate(51.4deg);
    animation: petalBreath2 11s ease-in-out infinite;
}
.moonflower-large .petal-3 {
    background: #F0E8D8;
    transform: translate(-50%, -100%) rotate(102.8deg);
    animation: petalBreath1 9s ease-in-out infinite;
}
.moonflower-large .petal-4 {
    background: #D4C8B8;
    transform: translate(-50%, -100%) rotate(154.3deg);
    animation: petalBreath2 12s ease-in-out infinite;
}
.moonflower-large .petal-5 {
    background: #F0E8D8;
    transform: translate(-50%, -100%) rotate(205.7deg);
    animation: petalBreath1 10.5s ease-in-out infinite;
}
.moonflower-large .petal-6 {
    background: #E8D5B7;
    transform: translate(-50%, -100%) rotate(257.1deg);
    animation: petalBreath2 11.5s ease-in-out infinite;
}
.moonflower-large .petal-7 {
    background: #F0E8D8;
    transform: translate(-50%, -100%) rotate(308.6deg);
    animation: petalBreath1 9.5s ease-in-out infinite;
}

/* Medium Moonflower Petals */
.moonflower-medium .petal {
    width: 16px;
    height: 24px;
    top: 50%;
    left: 50%;
    transform-origin: center bottom;
}

.moonflower-medium .petal-1 {
    background: #F0E8D8;
    transform: translate(-50%, -100%) rotate(0deg);
    animation: petalBreath1 10s ease-in-out infinite;
}
.moonflower-medium .petal-2 {
    background: #E8D5B7;
    transform: translate(-50%, -100%) rotate(72deg);
    animation: petalBreath2 11s ease-in-out infinite;
}
.moonflower-medium .petal-3 {
    background: #F0E8D8;
    transform: translate(-50%, -100%) rotate(144deg);
    animation: petalBreath1 9s ease-in-out infinite;
}
.moonflower-medium .petal-4 {
    background: #D4C8B8;
    transform: translate(-50%, -100%) rotate(216deg);
    animation: petalBreath2 12s ease-in-out infinite;
}
.moonflower-medium .petal-5 {
    background: #F0E8D8;
    transform: translate(-50%, -100%) rotate(288deg);
    animation: petalBreath1 10.5s ease-in-out infinite;
}

@keyframes petalBreath1 {
    0%, 100% { transform: translate(-50%, -100%) rotate(var(--base-rotation, 0deg)); }
    50% { transform: translate(-50%, -100%) rotate(calc(var(--base-rotation, 0deg) + 2.5deg)); }
}

@keyframes petalBreath2 {
    0%, 100% { transform: translate(-50%, -100%) rotate(var(--base-rotation, 0deg)); }
    50% { transform: translate(-50%, -100%) rotate(calc(var(--base-rotation, 0deg) - 2.5deg)); }
}

/* Petal breathing with fixed rotations since CSS custom properties are complex */
@keyframes petalBreath1 {
    0%, 100% { opacity: 0.85; }
    50% { opacity: 0.7; }
}

@keyframes petalBreath2 {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 0.85; }
}

/* ---------- Overlay Moonflowers ---------- */
.overlay-moonflower {
    position: absolute;
    z-index: 15;
    opacity: 0.6;
    pointer-events: none;
}

.overlay-1 {
    top: 40%;
    left: 55%;
}

.overlay-2 {
    top: 30%;
    right: 15%;
    left: auto;
}

.overlay-3 {
    bottom: 25%;
    left: 45%;
}

.overlay-4 {
    top: 55%;
    right: 20%;
    left: auto;
}

/* ---------- Zoom-Focus on Motifs ---------- */
.moonflower,
.fern-frond,
.moonflower-illustration {
    transform: scale(0.9);
    filter: blur(1px);
    transition: transform 800ms cubic-bezier(0.22, 0.61, 0.36, 1),
                filter 800ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

.moonflower.focused,
.fern-frond.focused,
.moonflower-illustration.focused {
    transform: scale(1);
    filter: blur(0);
}

/* ---------- Fade-In for Body Text ---------- */
.specimen-text,
.specimen-text-small,
.specimen-label,
.instrument-list,
.moon-phases,
.specimen-exhibit,
.seed-dots {
    opacity: 0;
    transition: opacity 600ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

.specimen-text.visible,
.specimen-text-small.visible,
.specimen-label.visible,
.instrument-list.visible,
.moon-phases.visible,
.specimen-exhibit.visible,
.seed-dots.visible {
    opacity: 1;
}

/* Cartouche elements should be visible by default (they animate via keyframes) */
.compartment-title .subtitle,
.compartment-closing .closing-text,
.compartment-closing .closing-attribution {
    opacity: 0.4;
}
.compartment-closing .closing-text {
    opacity: 0.6;
}

/* ---------- Progress Bar ---------- */
#progress-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: rgba(15, 27, 46, 0.5);
    z-index: 100;
}

#progress-fill {
    height: 100%;
    width: 0%;
    background: #B8A07A;
    transition: width 100ms linear;
}

/* ---------- Compartment Numbers ---------- */
#compartment-numbers {
    position: fixed;
    bottom: 12px;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 40px;
    z-index: 100;
    pointer-events: none;
}

.comp-num {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 10px;
    letter-spacing: 0.08em;
    color: #B8A07A;
    opacity: 0.4;
    transition: opacity 400ms ease;
    pointer-events: auto;
    cursor: pointer;
}

.comp-num.active {
    opacity: 1;
}

/* ---------- Stagger Animations on Entry ---------- */
.compartment-specimen .specimen-card {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 600ms cubic-bezier(0.22, 0.61, 0.36, 1),
                transform 600ms cubic-bezier(0.22, 0.61, 0.36, 1),
                box-shadow 500ms ease-out;
}

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

.compartment-specimen.in-view .specimen-card:nth-child(1) {
    transition-delay: 0ms;
}
.compartment-specimen.in-view .specimen-card:nth-child(2) {
    transition-delay: 200ms;
}
.compartment-specimen.in-view .specimen-card:nth-child(3) {
    transition-delay: 400ms;
}
.compartment-specimen.in-view .specimen-card:nth-child(4) {
    transition-delay: 600ms;
}
.compartment-specimen.in-view .specimen-card:nth-child(5) {
    transition-delay: 800ms;
}

/* Override inline rotation on hover — keep the card's rotation but add lift */
.compartment-specimen.in-view .specimen-card:hover {
    opacity: 1;
}

/* ---------- Closing Compartment Fade-In ---------- */
.compartment-closing .cartouche-content {
    opacity: 0;
    transform: translateY(15px);
    transition: opacity 1000ms cubic-bezier(0.22, 0.61, 0.36, 1),
                transform 1000ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

.compartment-closing.in-view .cartouche-content {
    opacity: 1;
    transform: translateY(0);
}

/* ---------- Responsive Adjustments ---------- */
@media (max-width: 768px) {
    .specimen-grid {
        grid-template-columns: 1fr !important;
        grid-template-rows: auto !important;
        width: 90vw;
        height: auto;
        min-height: 80vh;
        padding: 20px;
        gap: 16px;
    }

    .specimen-card {
        grid-column: 1 / -1 !important;
        grid-row: auto !important;
        margin: 8px !important;
    }

    .site-title {
        font-size: 16vw;
    }

    .transition-veil {
        width: 15vw;
    }

    .moonflower-large {
        width: 120px;
        height: 120px;
    }

    .moonflower-large .petal {
        width: 36px;
        height: 54px;
    }

    #compartment-numbers {
        gap: 20px;
    }

    .ornamental-rule {
        width: 80vw;
    }
}
