/* sustaining.quest - Design Language Stylesheet */
/* Color Palette:
   Deep Forest Floor: #1B2D1B
   Moss Canopy: #3A5F3A
   Lichen Sage: #7FA87F
   Amber Resin: #C4922A
   Ochre Clay: #B87333
   Unbleached Linen: #F2EDE4
   Weathered Bark: #6B5B4F
   River Stone: #8A9A8A
*/

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

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: 'Lora', Georgia, serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.15rem);
    line-height: 1.72;
    color: #6B5B4F;
    background-color: #F2EDE4;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Handmade paper texture via CSS noise */
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 viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 256px 256px;
}

/* ===== Typography ===== */
h1, h2, h3 {
    font-family: 'Cormorant Garamond', 'Garamond', serif;
    font-weight: 600;
    color: #3A5F3A;
    letter-spacing: 0.02em;
}

h2 {
    font-size: clamp(2.2rem, 5vw, 4rem);
    margin-bottom: 1.2rem;
    line-height: 1.15;
}

p {
    margin-bottom: 1.2rem;
}

.accent-label {
    font-family: 'IBM Plex Sans', 'Arial', sans-serif;
    font-weight: 400;
    font-size: 0.8rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #8A9A8A;
}

blockquote.ring-quote {
    position: relative;
    font-family: 'Lora', Georgia, serif;
    font-weight: 600;
    font-style: italic;
    font-size: clamp(1.1rem, 2vw, 1.3rem);
    line-height: 1.6;
    color: #3A5F3A;
    padding: 1.5rem 2rem;
    margin: 2rem 0;
    border-left: 3px solid #B87333;
}

.quote-arc {
    color: #C4922A;
    font-size: 1.8em;
    line-height: 0;
    vertical-align: -0.15em;
}

/* ===== Navigation ===== */
#seed-nav {
    position: fixed;
    top: 24px;
    left: 24px;
    z-index: 1000;
}

#seed-icon {
    cursor: pointer;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    width: 48px;
    height: 48px;
}

#seed-icon:hover {
    transform: scale(1.15);
}

#seed-icon .seed-sprout,
#seed-icon .seed-leaf {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

#seed-icon:hover .seed-sprout {
    stroke: #C4922A;
}

#nav-menu {
    position: absolute;
    top: -10px;
    left: -10px;
    width: 200px;
    height: 200px;
    pointer-events: none;
}

#nav-menu.nav-open {
    pointer-events: auto;
}

.nav-leaf {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    width: auto;
    padding: 6px 14px;
    background: rgba(27, 45, 27, 0.9);
    border-radius: 20px;
    text-decoration: none;
    opacity: 0;
    transform: scale(0.3);
    transition: opacity 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
                transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
                background 0.2s ease;
}

.nav-leaf:hover {
    background: rgba(58, 95, 58, 0.95);
}

#nav-menu.nav-open .nav-leaf {
    opacity: 1;
    transform: scale(1);
}

.nav-leaf[data-index="0"] { top: -10px; left: 70px; transition-delay: 0s; }
.nav-leaf[data-index="1"] { top: 30px; left: 100px; transition-delay: 0.05s; }
.nav-leaf[data-index="2"] { top: 75px; left: 105px; transition-delay: 0.1s; }
.nav-leaf[data-index="3"] { top: 120px; left: 90px; transition-delay: 0.15s; }
.nav-leaf[data-index="4"] { top: 155px; left: 55px; transition-delay: 0.2s; }

#nav-menu.nav-open .nav-leaf[data-index="0"] { transition-delay: 0s; }
#nav-menu.nav-open .nav-leaf[data-index="1"] { transition-delay: 0.05s; }
#nav-menu.nav-open .nav-leaf[data-index="2"] { transition-delay: 0.1s; }
#nav-menu.nav-open .nav-leaf[data-index="3"] { transition-delay: 0.15s; }
#nav-menu.nav-open .nav-leaf[data-index="4"] { transition-delay: 0.2s; }

.nav-label {
    font-family: 'IBM Plex Sans', sans-serif;
    font-weight: 400;
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #F2EDE4;
}

/* ===== Chapters Common ===== */
.chapter {
    position: relative;
    overflow: hidden;
}

/* ===== Chapter 1: Seed ===== */
#chapter-seed {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: #1B2D1B;
    position: relative;
}

/* Faint wood-grain texture for dark sections */
#chapter-seed::before,
.below-ground::before,
#site-footer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0.05;
    background-image: repeating-linear-gradient(
        90deg,
        transparent,
        transparent 8px,
        rgba(127, 168, 127, 0.3) 8px,
        rgba(127, 168, 127, 0.3) 9px
    );
}

.seed-point {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 8px;
    height: 8px;
    background: #C4922A;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 40px 15px rgba(196, 146, 42, 0.3),
                0 0 80px 30px rgba(196, 146, 42, 0.15);
    transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1),
                height 0.6s cubic-bezier(0.34, 1.56, 0.64, 1),
                opacity 0.6s ease;
    z-index: 1;
}

.seed-point.expanded {
    width: 300px;
    height: 300px;
    opacity: 0;
}

.seed-content {
    position: relative;
    z-index: 2;
    text-align: center;
    padding: 2rem;
}

#germinating-seed {
    width: 200px;
    height: 300px;
    margin: 0 auto 2rem;
}

.draw-path {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 1.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.draw-path.drawn {
    stroke-dashoffset: 0;
}

.seed-unfurl {
    transition: opacity 0.8s ease 0.6s;
}

.seed-unfurl.visible {
    opacity: 0.8;
}

#site-title {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: clamp(2.5rem, 7vw, 5rem);
    color: #F2EDE4;
    letter-spacing: 0em;
    transition: letter-spacing 1.2s cubic-bezier(0.34, 1.56, 0.64, 1),
                opacity 0.8s ease;
    opacity: 0;
}

#site-title.title-visible {
    letter-spacing: 0.02em;
    opacity: 1;
}

.seed-tagline {
    margin-top: 0.8rem;
    color: #8A9A8A;
    opacity: 0;
    transition: opacity 1s ease 0.8s;
}

.seed-tagline.visible {
    opacity: 1;
}

/* ===== Soil Horizon Dividers ===== */
.soil-horizon {
    width: 100%;
    height: 120px;
    background: linear-gradient(180deg, #1B2D1B 0%, #3A5F3A 30%, #B87333 65%, #6B5B4F 100%);
    position: relative;
    z-index: 5;
}

/* ===== Chapter 2: Root ===== */
.root-chapter {
    min-height: 150vh;
    position: relative;
}

.soil-cross-section {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

.above-ground {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 40%;
    background-color: #F2EDE4;
}

.below-ground {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60%;
    background-color: #1B2D1B;
    position: relative;
}

.soil-line {
    position: absolute;
    top: 40%;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, #B87333, #6B5B4F, #B87333);
    z-index: 2;
}

.root-network {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    height: 60%;
    z-index: 1;
    opacity: 0.4;
}

.root-path {
    stroke-dasharray: 600;
    stroke-dashoffset: 600;
    transition: stroke-dashoffset 2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.root-path.drawn {
    stroke-dashoffset: 0;
}

/* ===== Content Spine & Branch Panels ===== */
.content-spine {
    position: relative;
    z-index: 3;
    padding: 6rem 0;
    width: 85%;
    margin-left: 33%;
}

.branch-panel {
    background: rgba(242, 237, 228, 0.95);
    padding: 3rem 3.5rem;
    margin-bottom: -40px;
    position: relative;
    border-left: 3px solid #B87333;
    max-width: 600px;
    opacity: 0;
    transform: translateX(60px);
    transition: opacity 0.7s cubic-bezier(0.34, 1.56, 0.64, 1),
                transform 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.branch-panel.panel-visible {
    opacity: 1;
    transform: translateX(0);
}

/* Irregular top edges for panels */
.branch-panel::before {
    content: '';
    position: absolute;
    top: -8px;
    left: -3px;
    right: 0;
    height: 12px;
    background: rgba(242, 237, 228, 0.95);
    clip-path: polygon(0 100%, 5% 40%, 12% 80%, 20% 30%, 28% 70%, 35% 20%, 42% 60%, 50% 10%, 58% 50%, 65% 25%, 72% 65%, 80% 15%, 88% 55%, 95% 35%, 100% 100%);
}

.root-panel {
    background: rgba(242, 237, 228, 0.92);
}

/* Panel in dark areas gets adjusted */
.root-chapter .branch-panel {
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.2);
}

/* ===== Ring Numbers ===== */
.ring-number {
    position: absolute;
    top: -20px;
    right: 20px;
    width: 60px;
    height: 60px;
}

.ring-svg {
    width: 100%;
    height: 100%;
}

.ring-text {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
}

.branch-panel > .ring-number {
    position: absolute;
    top: 10px;
    right: 15px;
}

/* ===== Chapter 3: Growth ===== */
.growth-chapter {
    min-height: 200vh;
    background-color: #F0F2E8;
    position: relative;
}

.growth-spine {
    margin-left: 33%;
}

.growth-panel {
    max-width: 650px;
}

.growth-panel.panel-2 {
    margin-left: 30px;
}

.growth-panel.panel-3 {
    margin-left: 60px;
}

.growth-panel.panel-4 {
    margin-left: 90px;
    max-width: 700px;
}

/* Botanical Illustration: Fern */
.botanical-illustration {
    position: absolute;
    z-index: 2;
    opacity: 0.6;
}

.fern-crozier {
    right: 5%;
    top: 15%;
    width: 200px;
    height: 280px;
}

.fern-path,
.fern-frond {
    stroke-dasharray: 400;
    stroke-dashoffset: 400;
    transition: stroke-dashoffset 2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.fern-path.drawn,
.fern-frond.drawn {
    stroke-dashoffset: 0;
}

/* ===== Chapter 4: Canopy ===== */
.canopy-chapter {
    min-height: 200vh;
    background-color: #3A5F3A;
    position: relative;
}

.canopy-spine {
    margin-left: 20%;
}

.canopy-panel {
    background: rgba(242, 237, 228, 0.93);
    max-width: 620px;
    margin-bottom: -60px;
}

.canopy-panel.panel-2 {
    margin-left: 60px;
}

.canopy-panel.panel-3 {
    margin-left: 20px;
    max-width: 580px;
}

.canopy-panel.panel-4 {
    margin-left: 80px;
    max-width: 640px;
}

/* Canopy panels use clip-path for irregular edges */
.canopy-panel::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 0;
    right: 0;
    height: 10px;
    background: rgba(242, 237, 228, 0.93);
    clip-path: polygon(0 0, 8% 60%, 15% 20%, 22% 70%, 30% 30%, 38% 80%, 45% 10%, 52% 60%, 60% 25%, 68% 75%, 75% 15%, 82% 55%, 90% 30%, 100% 0);
}

/* Dappled light effect */
.dappled-light {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.light-spot {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(ellipse, rgba(196, 146, 42, 0.12) 0%, transparent 70%);
    animation: dapple 6s ease-in-out infinite alternate;
}

.light-spot:nth-child(2) { animation-delay: -1s; animation-duration: 7s; }
.light-spot:nth-child(3) { animation-delay: -2s; animation-duration: 5.5s; }
.light-spot:nth-child(4) { animation-delay: -3s; animation-duration: 8s; }
.light-spot:nth-child(5) { animation-delay: -0.5s; animation-duration: 6.5s; }
.light-spot:nth-child(6) { animation-delay: -4s; animation-duration: 7.5s; }
.light-spot:nth-child(7) { animation-delay: -2.5s; animation-duration: 5s; }

@keyframes dapple {
    0% { opacity: 0.4; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.2); }
    100% { opacity: 0.5; transform: scale(0.9); }
}

/* ===== Chapter 5: Return ===== */
.return-chapter {
    min-height: 100vh;
    background-color: #F2EDE4;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.return-spine {
    margin-left: 33%;
    width: 60%;
}

.return-panel {
    max-width: 500px;
    background: rgba(242, 237, 228, 0.8);
    border-left-color: #8A9A8A;
}

.return-panel h2 {
    color: #6B5B4F;
}

.return-panel p {
    color: #8A9A8A;
}

/* Falling Leaf */
#falling-leaf {
    position: relative;
    z-index: 5;
    margin-top: 4rem;
    animation: leafFall 8s ease-in-out infinite;
}

@keyframes leafFall {
    0% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(30px) rotate(8deg) translateX(15px); }
    50% { transform: translateY(60px) rotate(-5deg) translateX(-10px); }
    75% { transform: translateY(90px) rotate(6deg) translateX(12px); }
    100% { transform: translateY(120px) rotate(-3deg) translateX(-5px); }
}

.return-fade {
    width: 100%;
    height: 200px;
    background: linear-gradient(180deg, transparent 0%, #1B2D1B 100%);
    position: relative;
    z-index: 3;
}

.cycle-text {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-weight: 400;
    font-size: clamp(1.4rem, 3vw, 2rem);
    color: #8A9A8A;
    opacity: 0.5;
    text-align: center;
    padding: 3rem 2rem;
    background-color: #1B2D1B;
    width: 100%;
    position: relative;
    z-index: 4;
}

/* ===== Venation Overlays ===== */
.venation-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

/* ===== Footer ===== */
#site-footer {
    background-color: #1B2D1B;
    padding: 3rem 2rem 2rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.footer-roots {
    width: 100%;
    height: 80px;
    margin-bottom: 1.5rem;
    opacity: 0.5;
}

.footer-root-path {
    transition: stroke 0.3s ease;
}

.footer-text {
    position: relative;
    z-index: 2;
}

.footer-text .accent-label {
    color: #7FA87F;
    font-size: 0.75rem;
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
    .branch-panel {
        opacity: 1;
        transform: none;
        transition: opacity 0.2s ease;
    }

    .draw-path {
        stroke-dashoffset: 0;
        transition: none;
    }

    .seed-unfurl {
        opacity: 0.8;
        transition: none;
    }

    #site-title {
        opacity: 1;
        letter-spacing: 0.02em;
        transition: none;
    }

    .seed-tagline {
        opacity: 1;
        transition: none;
    }

    #falling-leaf {
        animation: none;
    }

    .light-spot {
        animation: none;
        opacity: 0.5;
    }

    .root-path {
        stroke-dashoffset: 0;
        transition: none;
    }

    .fern-path,
    .fern-frond {
        stroke-dashoffset: 0;
        transition: none;
    }

    .seed-point {
        transition: none;
    }
}

/* ===== Tablet ===== */
@media (max-width: 1024px) {
    .content-spine {
        margin-left: 25%;
        width: 90%;
    }

    .branch-panel {
        margin-bottom: -25px;
        padding: 2.5rem 2.5rem;
    }

    .canopy-panel {
        margin-bottom: -30px;
    }

    .growth-panel.panel-2 { margin-left: 15px; }
    .growth-panel.panel-3 { margin-left: 30px; }
    .growth-panel.panel-4 { margin-left: 45px; }

    .canopy-panel.panel-2 { margin-left: 30px; }
    .canopy-panel.panel-3 { margin-left: 10px; }
    .canopy-panel.panel-4 { margin-left: 40px; }

    .soil-horizon {
        height: 144px;
    }

    .fern-crozier {
        width: 150px;
        height: 210px;
        right: 2%;
    }
}

/* ===== Mobile ===== */
@media (max-width: 768px) {
    .content-spine {
        margin-left: 0;
        width: 100%;
        padding: 3rem 1.2rem;
    }

    .branch-panel {
        margin-bottom: 0;
        margin-left: 0 !important;
        max-width: 100% !important;
        padding: 2rem 1.5rem;
        transform: translateY(30px);
    }

    .branch-panel.panel-visible {
        transform: translateY(0);
    }

    .growth-spine,
    .canopy-spine,
    .return-spine {
        margin-left: 0;
        width: 100%;
    }

    .canopy-panel.panel-2,
    .canopy-panel.panel-3,
    .canopy-panel.panel-4 {
        margin-left: 0;
    }

    h2 {
        font-size: clamp(1.8rem, 5vw, 3rem);
    }

    #site-title {
        font-size: clamp(2rem, 8vw, 3.5rem);
    }

    .soil-horizon {
        height: 80px;
    }

    .fern-crozier {
        display: none;
    }

    .dappled-light {
        display: none;
    }

    #seed-nav {
        top: 16px;
        left: 16px;
    }

    .ring-number {
        width: 45px;
        height: 45px;
    }

    .nav-leaf[data-index="0"] { top: -5px; left: 55px; }
    .nav-leaf[data-index="1"] { top: 25px; left: 75px; }
    .nav-leaf[data-index="2"] { top: 60px; left: 80px; }
    .nav-leaf[data-index="3"] { top: 95px; left: 70px; }
    .nav-leaf[data-index="4"] { top: 125px; left: 45px; }

    .root-chapter .content-spine {
        padding-top: 45vh;
    }

    .soil-line {
        top: 35%;
    }

    .above-ground {
        height: 35%;
    }

    .below-ground {
        height: 65%;
    }
}