/* =====================================================
   gabs.cafe — a twilight herb garden
   Palette:
     Deep Loam        #2C1E14
     Hearthstone      #6B4832
     Copper Lantern   #C4763B
     Dried Sage       #7A8B6F
     Lavender Haze    #9B8EA2
     Candlelight Cream #F5EDE0
     Moth Wing        #E8DBC8
     Twilight Indigo  #3B3654
     Beeswax Glow     #E8C870
   ===================================================== */

:root {
    --c-loam: #2C1E14;
    --c-hearth: #6B4832;
    --c-copper: #C4763B;
    --c-sage: #7A8B6F;
    --c-lavender: #9B8EA2;
    --c-cream: #F5EDE0;
    --c-mothwing: #E8DBC8;
    --c-indigo: #3B3654;
    --c-beeswax: #E8C870;

    --font-display: "Lora", Georgia, serif;
    --font-body: "Libre Baskerville", Georgia, serif;
    --font-hand: "Caveat", "Lora", cursive;

    --scroll-progress: 0;
    --content-max: 1100px;
    --pad-x: clamp(2rem, 5vw, 6rem);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-body);
    color: var(--c-loam);
    line-height: 1.75;
    letter-spacing: 0.01em;
    overflow-x: hidden;
    background: linear-gradient(
        to bottom,
        var(--c-cream) 0%,
        var(--c-cream) 12%,
        var(--c-mothwing) 38%,
        #C9B7A4 60%,
        #6B5C6E 82%,
        var(--c-indigo) 100%
    );
    background-attachment: fixed;
    min-height: 100vh;
}

/* Linen texture overlay (subtle SVG pattern via inline data URI) */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: 0.06;
    z-index: 0;
    background-image:
        repeating-linear-gradient(0deg, transparent 0 3px, rgba(107, 72, 50, 0.4) 3px 4px),
        repeating-linear-gradient(90deg, transparent 0 3px, rgba(107, 72, 50, 0.4) 3px 4px);
}

/* Color overlay shifts with scroll progress for twilight effect */
body::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    background: var(--c-indigo);
    opacity: calc(var(--scroll-progress) * 0.32);
    transition: opacity 0.4s linear;
}

main, section, footer, .moth-nav {
    position: relative;
    z-index: 2;
}

/* =====================================================
   MOTH NAVIGATION
   ===================================================== */
.moth-nav {
    position: fixed;
    top: clamp(1rem, 2vw, 1.8rem);
    right: clamp(1rem, 2vw, 1.8rem);
    z-index: 100;
}

.moth-trigger {
    width: 56px;
    height: 56px;
    background: transparent;
    border: 1px solid rgba(107, 72, 50, 0.25);
    border-radius: 50%;
    cursor: pointer;
    padding: 8px;
    transition: border-color 0.4s ease, background 0.4s ease;
}
.moth-trigger:hover {
    border-color: var(--c-beeswax);
    background: rgba(232, 200, 112, 0.12);
}

.moth-icon {
    width: 100%;
    height: 100%;
    overflow: visible;
}
.moth-icon .wing {
    fill: var(--c-sage);
    fill-opacity: 0.6;
    stroke: var(--c-hearth);
    stroke-width: 1.2;
    transform-origin: 30px 32px;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1), fill-opacity 0.4s ease;
}
.moth-icon .moth-body {
    fill: var(--c-hearth);
    stroke: var(--c-loam);
    stroke-width: 1;
}
.moth-icon .antenna {
    fill: none;
    stroke: var(--c-hearth);
    stroke-width: 1;
}
.moth-trigger:hover .wing-left {
    transform: rotate(-30deg);
}
.moth-trigger:hover .wing-right {
    transform: rotate(30deg);
}
.moth-trigger:hover .moth-icon {
    filter: drop-shadow(0 0 6px var(--c-beeswax));
}

/* Active state (toggled by JS) */
.moth-nav.is-active .wing-left {
    transform: rotate(-32deg);
}
.moth-nav.is-active .wing-right {
    transform: rotate(32deg);
}
.moth-nav.is-active .moth-icon {
    filter: drop-shadow(0 0 8px var(--c-beeswax));
}

/* Overlay */
.moth-overlay {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: clamp(280px, 30vw, 380px);
    background: rgba(245, 237, 224, 0.94);
    border-left: 1px solid var(--c-lavender);
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    padding: clamp(4rem, 8vh, 6rem) clamp(1.5rem, 3vw, 2.5rem) 2rem;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    pointer-events: none;
}
.moth-nav.is-active .moth-overlay {
    transform: translateX(0);
    pointer-events: auto;
}
.overlay-heading {
    font-family: var(--font-hand);
    color: var(--c-sage);
    font-size: 1.4rem;
    margin: 0 0 1.5rem;
    text-align: center;
    letter-spacing: 0.04em;
}
.overlay-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.overlay-list li {
    margin-bottom: 1.2rem;
    border-bottom: 1px dashed rgba(155, 142, 162, 0.4);
    padding-bottom: 0.6rem;
}
.overlay-list a {
    font-family: var(--font-hand);
    color: var(--c-hearth);
    text-decoration: none;
    font-size: 1.3rem;
    letter-spacing: 0.02em;
    transition: color 0.3s ease;
    display: block;
}
.overlay-list a:hover {
    color: var(--c-copper);
}
.overlay-foot {
    font-family: var(--font-hand);
    color: var(--c-lavender);
    font-size: 1rem;
    text-align: center;
    margin-top: 2rem;
    font-style: italic;
}

/* =====================================================
   HERO — The Garden Gate
   ===================================================== */
.hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(2rem, 6vh, 5rem) var(--pad-x);
    perspective: 1400px;
    overflow: hidden;
}

.hero-stage {
    position: relative;
    width: 100%;
    max-width: 900px;
    aspect-ratio: 8 / 7;
    transform-style: preserve-3d;
}

.hero-backdrop {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: 6px;
    opacity: 0;
    animation: backdropFade 2s ease-out 1.2s forwards;
}

@keyframes backdropFade {
    to { opacity: 1; }
}

.gate {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
    transform-style: preserve-3d;
}

.gate-half {
    transform-origin: center;
    transition: transform 1.6s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
}
.gate-left {
    transform-origin: left center;
}
.gate-right {
    transform-origin: right center;
}

/* Path drawing for ironwork */
.draw-path {
    stroke-dasharray: 800;
    stroke-dashoffset: 800;
    animation: drawIron 3s cubic-bezier(0.4, 0, 0.2, 1) 0.4s forwards;
}

@keyframes drawIron {
    to { stroke-dashoffset: 0; }
}

/* Gate opens (class added by JS after draw completes) */
.gate.is-open .gate-left {
    transform: perspective(800px) rotateY(-35deg);
}
.gate.is-open .gate-right {
    transform: perspective(800px) rotateY(35deg);
}

.lantern {
    transform-origin: center top;
    animation: lanternSway 6s ease-in-out infinite;
}
.lantern-right {
    animation-delay: -3s;
}
@keyframes lanternSway {
    0%, 100% { transform: rotate(-1.5deg); }
    50% { transform: rotate(1.5deg); }
}

.hero-title-wrap {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 6%;
    text-align: center;
    z-index: 5;
    opacity: 0;
    animation: titleFade 1.4s ease-out 4.6s forwards;
    pointer-events: none;
}

@keyframes titleFade {
    from { opacity: 0; }
    to { opacity: 1; }
}

.hero-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(2.8rem, 7vw, 5.5rem);
    color: var(--c-hearth);
    letter-spacing: 0.15em;
    line-height: 1.15;
    margin: 0;
    animation: titleGather 2.4s cubic-bezier(0.4, 0, 0.2, 1) 4.6s forwards;
    text-shadow: 0 1px 0 rgba(245, 237, 224, 0.9);
}

@keyframes titleGather {
    from { letter-spacing: 0.15em; }
    to { letter-spacing: 0.03em; }
}

.hero-sub {
    font-family: var(--font-hand);
    color: var(--c-sage);
    font-size: clamp(1.1rem, 2vw, 1.6rem);
    margin: 0.4rem 0 0;
    letter-spacing: 0.04em;
}

.hero-hint {
    font-family: var(--font-hand);
    color: var(--c-lavender);
    font-size: clamp(0.9rem, 1.5vw, 1.1rem);
    margin: 1.4rem 0 0;
    opacity: 0.8;
    animation: floatHint 3s ease-in-out infinite;
}

@keyframes floatHint {
    0%, 100% { transform: translateY(0); opacity: 0.6; }
    50% { transform: translateY(6px); opacity: 1; }
}

/* =====================================================
   SPECIMEN SECTIONS
   ===================================================== */
.specimen {
    min-height: 90vh;
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: center;
    gap: clamp(2rem, 5vw, 5rem);
    max-width: var(--content-max);
    margin: 0 auto;
    padding: clamp(3rem, 8vh, 7rem) var(--pad-x);
}

.specimen-illustration {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.botanical {
    width: 100%;
    max-width: 480px;
    height: auto;
    filter: drop-shadow(0 2px 8px rgba(107, 72, 50, 0.08));
    transition: filter 1s ease;
}

.botanical g[stroke] {
    transition: stroke 1.5s ease;
}

/* Stroke shifts to lighter cream in twilight */
body[data-twilight="deep"] .botanical g[stroke] {
    stroke: var(--c-mothwing);
}

.specimen-label {
    font-family: var(--font-hand);
    color: var(--c-sage);
    font-size: clamp(0.95rem, 1.5vw, 1.15rem);
    margin: 1.4rem 0 0;
    letter-spacing: 0.03em;
    font-style: normal;
    text-align: center;
}
.specimen-label em {
    font-family: var(--font-display);
    font-style: italic;
    color: var(--c-hearth);
    font-weight: 400;
}

.specimen-text {
    display: flex;
    align-items: center;
}

.page-frame {
    position: relative;
    background: rgba(245, 237, 224, 0.78);
    border: 1px solid var(--c-lavender);
    border-radius: 14px;
    padding: clamp(1.6rem, 3vw, 2.6rem) clamp(1.5rem, 3vw, 2.4rem);
    max-width: 38em;
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.7) inset,
        0 8px 24px rgba(60, 38, 20, 0.06);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.page-frame::before {
    content: "";
    position: absolute;
    inset: 6px;
    border: 1px dashed rgba(155, 142, 162, 0.35);
    border-radius: 9px;
    pointer-events: none;
}

.section-heading {
    font-family: var(--font-display);
    font-weight: 600;
    font-style: italic;
    font-size: clamp(1.6rem, 3.5vw, 2.6rem);
    color: var(--c-hearth);
    margin: 0 0 1.2rem;
    letter-spacing: 0.02em;
    line-height: 1.3;
}

.page-frame p {
    margin: 0 0 1.1rem;
    font-size: clamp(1rem, 1.8vw, 1.15rem);
    color: var(--c-loam);
    text-align: left;
    font-family: var(--font-body);
}
.page-frame p:last-child {
    margin-bottom: 0;
}

.annotation {
    font-family: var(--font-hand) !important;
    color: var(--c-sage) !important;
    font-size: clamp(1rem, 1.7vw, 1.25rem) !important;
    line-height: 1.5 !important;
    margin-top: 1.6rem !important;
    padding-top: 1rem;
    border-top: 1px dashed rgba(155, 142, 162, 0.4);
    letter-spacing: 0.02em;
}

/* Alternating layout */
.specimen-right .specimen-illustration {
    order: 2;
}
.specimen-right .specimen-text {
    order: 1;
    justify-content: flex-end;
}
.specimen-left .specimen-text {
    justify-content: flex-start;
}

/* Twilight section adjustments */
.specimen.twilight .page-frame {
    background: rgba(245, 237, 224, 0.86);
    border-color: rgba(155, 142, 162, 0.6);
}

/* =====================================================
   VINE DIVIDERS
   ===================================================== */
.vine-divider {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 0 var(--pad-x);
}
.vine-divider svg {
    width: 100%;
    height: 60px;
    overflow: visible;
}
.vine-path {
    stroke-dasharray: 1500;
    stroke-dashoffset: 1500;
    transition: stroke-dashoffset 1.6s ease-out;
}
.vine-divider.is-revealed .vine-path {
    stroke-dashoffset: 0;
}

/* =====================================================
   REVEAL ANIMATION
   ===================================================== */
.reveal {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
    will-change: opacity, transform;
}
.reveal.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* =====================================================
   COLOPHON
   ===================================================== */
.colophon {
    padding: clamp(4rem, 10vh, 8rem) var(--pad-x) clamp(3rem, 6vh, 5rem);
    text-align: center;
    color: var(--c-cream);
    position: relative;
    z-index: 3;
}
.colophon-inner {
    max-width: 540px;
    margin: 0 auto;
}
.moon {
    width: 80px;
    height: 80px;
    margin: 0 auto 1.5rem;
    display: block;
    filter: drop-shadow(0 0 20px rgba(245, 237, 224, 0.4));
    animation: moonGlow 5s ease-in-out infinite;
}
@keyframes moonGlow {
    0%, 100% { filter: drop-shadow(0 0 16px rgba(245, 237, 224, 0.3)); }
    50% { filter: drop-shadow(0 0 28px rgba(245, 237, 224, 0.55)); }
}
.colophon-text {
    font-family: var(--font-display);
    font-style: italic;
    font-size: clamp(1.2rem, 2.5vw, 1.6rem);
    color: var(--c-cream);
    margin: 0 0 0.8rem;
    letter-spacing: 0.05em;
}
.colophon-sub {
    font-family: var(--font-hand);
    color: var(--c-mothwing);
    font-size: clamp(0.95rem, 1.4vw, 1.15rem);
    margin: 0;
    opacity: 0.85;
}

/* =====================================================
   FAUNA LAYER (moths and fireflies)
   ===================================================== */
.fauna-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 4;
    opacity: 0;
    transition: opacity 1.2s ease;
}
.fauna-layer.is-active {
    opacity: 1;
}

.drift-moth {
    position: absolute;
    width: 36px;
    height: 24px;
    will-change: transform;
}
.drift-moth-1 {
    top: 65%;
    left: 12%;
    animation: drift1 11s ease-in-out infinite;
}
.drift-moth-2 {
    top: 78%;
    left: 70%;
    animation: drift2 9s ease-in-out infinite;
}
.drift-moth-3 {
    top: 86%;
    left: 35%;
    animation: drift3 13s ease-in-out infinite;
    width: 28px;
    height: 18px;
}

@keyframes drift1 {
    0%   { transform: translate(0, 0) rotate(-4deg); }
    25%  { transform: translate(40px, -28px) rotate(6deg); }
    50%  { transform: translate(80px, 12px) rotate(-2deg); }
    75%  { transform: translate(36px, 32px) rotate(4deg); }
    100% { transform: translate(0, 0) rotate(-4deg); }
}
@keyframes drift2 {
    0%   { transform: translate(0, 0) rotate(3deg); }
    33%  { transform: translate(-46px, -22px) rotate(-5deg); }
    66%  { transform: translate(-22px, 34px) rotate(2deg); }
    100% { transform: translate(0, 0) rotate(3deg); }
}
@keyframes drift3 {
    0%   { transform: translate(0, 0) rotate(0deg); }
    50%  { transform: translate(60px, -36px) rotate(8deg); }
    100% { transform: translate(0, 0) rotate(0deg); }
}

.firefly {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--c-beeswax);
    border-radius: 50%;
    box-shadow: 0 0 10px 2px var(--c-beeswax), 0 0 18px 4px rgba(232, 200, 112, 0.5);
    will-change: transform, opacity;
}
.firefly-1 { top: 70%; left: 22%; animation: blink 3.5s ease-in-out infinite, fly1 14s linear infinite; }
.firefly-2 { top: 82%; left: 55%; animation: blink 4.2s ease-in-out infinite 0.6s, fly2 16s linear infinite; }
.firefly-3 { top: 76%; left: 80%; animation: blink 3s ease-in-out infinite 1.1s, fly3 12s linear infinite; }
.firefly-4 { top: 90%; left: 18%; animation: blink 4.8s ease-in-out infinite 1.8s, fly1 18s linear infinite; }
.firefly-5 { top: 88%; left: 65%; animation: blink 3.6s ease-in-out infinite 0.3s, fly2 13s linear infinite; }
.firefly-6 { top: 72%; left: 45%; animation: blink 4s ease-in-out infinite 2.2s, fly3 15s linear infinite; }

@keyframes blink {
    0%, 100% { opacity: 0; }
    25% { opacity: 0.8; }
    50% { opacity: 1; }
    75% { opacity: 0.6; }
}
@keyframes fly1 {
    0%   { transform: translate(0, 0); }
    25%  { transform: translate(40px, -50px); }
    50%  { transform: translate(80px, 20px); }
    75%  { transform: translate(20px, 40px); }
    100% { transform: translate(0, 0); }
}
@keyframes fly2 {
    0%   { transform: translate(0, 0); }
    33%  { transform: translate(-60px, -40px); }
    66%  { transform: translate(30px, -70px); }
    100% { transform: translate(0, 0); }
}
@keyframes fly3 {
    0%   { transform: translate(0, 0); }
    50%  { transform: translate(-50px, 50px); }
    100% { transform: translate(0, 0); }
}

/* =====================================================
   TWILIGHT TEXT/COLOR ADJUSTMENTS BY SCROLL
   ===================================================== */
body[data-twilight="dusk"] .page-frame p {
    color: #3a2a1c;
}
body[data-twilight="deep"] .page-frame {
    background: rgba(245, 237, 224, 0.92);
}
body[data-twilight="deep"] .page-frame p {
    color: var(--c-loam);
}
body[data-twilight="deep"] .section-heading {
    color: var(--c-hearth);
}

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 820px) {
    .specimen {
        grid-template-columns: 1fr;
        gap: 2rem;
        padding: clamp(2.5rem, 6vh, 5rem) var(--pad-x);
    }
    .specimen-right .specimen-illustration,
    .specimen-right .specimen-text {
        order: initial;
        justify-content: center;
    }
    .specimen-left .specimen-text {
        justify-content: center;
    }
    .botanical {
        max-width: 360px;
    }
    .moth-overlay {
        width: 80vw;
    }
    .hero-stage {
        aspect-ratio: 4 / 5;
    }
}

@media (max-width: 480px) {
    .page-frame {
        padding: 1.4rem 1.2rem;
    }
    .moth-trigger {
        width: 48px;
        height: 48px;
    }
}
