/* ===== namu.club — Tree Growth System Aesthetic ===== */

:root {
    /* Color Palette from DESIGN.md */
    --sapwood: #F5F1E8;
    --dark-bark: #3D2817;
    --mid-bark: #5C4033;
    --trunk-brown: #6B4423;
    --weathered-wood: #8B7355;
    --spring-green: #9ACD32;
    --forest-green: #6B8E23;
    --lichen-gray: #A0A080;
    --sienna: #A0522D;
    --gradient-bottom: #4A3728;

    /* Typography */
    --font-display: 'Cormorant Garamond', Georgia, serif;
    --font-body: 'Lora', Georgia, serif;
    --font-label: 'Crimson Text', Georgia, serif;
    --font-mono: 'IBM Plex Mono', monospace;

    /* Seasonal override support */
    --accent-primary: var(--spring-green);
    --accent-secondary: var(--forest-green);
    --accent-tertiary: var(--trunk-brown);
}

/* Seasonal themes */
body.season-spring {
    --accent-primary: #9ACD32;
    --accent-secondary: #6B8E23;
    --accent-tertiary: #6B4423;
}

body.season-summer {
    --accent-primary: #6B8E23;
    --accent-secondary: #6B4423;
    --accent-tertiary: #8B5A2B;
}

body.season-autumn {
    --accent-primary: #8B5A2B;
    --accent-secondary: #A0522D;
    --accent-tertiary: #6B4423;
}

body.season-winter {
    --accent-primary: #A0A080;
    --accent-secondary: #8B7355;
    --accent-tertiary: #5C4033;
}

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

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

body {
    font-family: var(--font-body);
    background: linear-gradient(180deg, var(--dark-bark) 0%, var(--gradient-bottom) 100%);
    color: var(--sapwood);
    line-height: 1.8;
    overflow-x: hidden;
    position: relative;
    min-height: 100vh;
}

/* ===== Ripple Canvas ===== */
#ripple-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
}

/* ===== Navigation ===== */
#nav-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 36px;
    background-color: var(--sapwood);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-trunk {
    position: absolute;
    left: 50%;
    top: 0;
    width: 4px;
    height: 36px;
    background: linear-gradient(180deg, var(--dark-bark), var(--mid-bark));
    transform: translateX(-50%);
}

.nav-label {
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--dark-bark);
    letter-spacing: 0.05em;
    position: relative;
    z-index: 1;
    background: var(--sapwood);
    padding: 0 12px;
}

.scroll-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: rgba(61, 40, 23, 0.1);
}

.scroll-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--trunk-brown), var(--spring-green));
    transition: width 0.1s linear;
}

/* ===== Background Botanical ===== */
.bg-botanical {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bg-rings-svg {
    width: 80%;
    max-width: 800px;
    height: auto;
    opacity: 0.8;
}

/* ===== Trunk Spine ===== */
.trunk-spine {
    position: fixed;
    left: 50%;
    top: 36px;
    width: 8px;
    height: calc(100vh - 36px);
    background: linear-gradient(180deg, var(--dark-bark), var(--mid-bark));
    transform: translateX(-50%);
    z-index: 2;
    opacity: 0.6;
}

/* ===== Branch SVG Layer ===== */
.branch-svg-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 3;
    overflow: visible;
}

.branch-path {
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    opacity: 0;
    transition: opacity 0.6s ease-out;
}

.branch-path.visible {
    opacity: 1;
}

/* ===== Branch Markers ===== */
.branch-markers {
    position: fixed;
    left: 50%;
    top: 36px;
    transform: translateX(-50%);
    z-index: 4;
    width: 16px;
    height: calc(100vh - 36px);
    pointer-events: none;
}

.branch-marker {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 1.5px solid var(--trunk-brown);
    background: var(--dark-bark);
    left: 50%;
    transform: translateX(-50%);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.branch-marker.active {
    background: var(--spring-green);
    border-color: var(--spring-green);
}

/* ===== Sections ===== */
.section {
    position: relative;
    z-index: 5;
}

/* ===== Section 1: Opening ===== */
.section-opening {
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding-top: 36px;
}

.trunk-line {
    width: 2px;
    height: 0;
    background: linear-gradient(180deg, var(--dark-bark), var(--trunk-brown));
    position: absolute;
    left: 50%;
    top: 36px;
    transform: translateX(-50%);
    transition: height 0.4s ease-out;
}

.trunk-line.grown {
    height: calc(50vh - 36px);
}

.crown-leaves {
    position: relative;
    width: 120px;
    height: 80px;
    margin-bottom: 20px;
    opacity: 0;
    transition: opacity 0.8s ease-out;
}

.crown-leaves.visible {
    opacity: 1;
}

.leaf-svg {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%) translateY(-30px) rotate(0deg) scale(0.1);
    transition: transform 2s ease-out, opacity 0.8s ease-out;
    opacity: 0;
}

.leaf-svg.fallen {
    transform: translateX(-50%) translateY(0) rotate(0deg) scale(1);
    opacity: 1;
}

.leaf-2 { left: 30%; }
.leaf-2.fallen { transform: translateX(-50%) translateY(5px) rotate(-8deg) scale(1); }

.leaf-3 { left: 70%; }
.leaf-3.fallen { transform: translateX(-50%) translateY(8px) rotate(12deg) scale(1); }

.leaf-4 { left: 20%; top: 15px; }
.leaf-4.fallen { transform: translateX(-50%) translateY(10px) rotate(-5deg) scale(1); }

.leaf-5 { left: 80%; top: 10px; }
.leaf-5.fallen { transform: translateX(-50%) translateY(6px) rotate(7deg) scale(1); }

.title-text {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(2rem, 5vw, 3.8rem);
    letter-spacing: 0.02em;
    color: var(--sapwood);
    opacity: 0;
    transition: opacity 1s ease-out 1.2s;
    text-align: center;
}

.title-text.visible {
    opacity: 1;
}

.title-sub {
    font-family: var(--font-label);
    font-size: 0.85rem;
    color: var(--weathered-wood);
    letter-spacing: 0.05em;
    margin-top: 8px;
    opacity: 0;
    transition: opacity 1s ease-out 1.6s;
    font-style: italic;
}

.title-sub.visible {
    opacity: 1;
}

/* ===== Section 2: Branch Emergence ===== */
.section-branches {
    min-height: 200vh;
    padding: 60px 0;
    position: relative;
}

.branch-module {
    position: relative;
    max-width: 380px;
    opacity: 0;
    transform: translateX(0);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
    margin-bottom: 120px;
}

.branch-module.visible {
    opacity: 1;
}

.module-left {
    margin-left: calc(50% - 440px);
    margin-right: auto;
    transform: translateX(-30px);
}

.module-left.visible {
    transform: translateX(0);
}

.module-right {
    margin-right: calc(50% - 440px);
    margin-left: auto;
    transform: translateX(30px);
}

.module-right.visible {
    transform: translateX(0);
}

.module-inner {
    background: rgba(92, 64, 51, 0.3);
    border: 1px solid rgba(107, 68, 35, 0.3);
    border-radius: 4px;
    padding: 28px 24px;
    position: relative;
}

.module-large .module-inner {
    padding: 36px 32px;
}

.module-small .module-inner {
    padding: 20px 18px;
}

.module-leaf {
    margin-bottom: 12px;
}

.module-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(1.3rem, 2.5vw, 1.8rem);
    letter-spacing: 0.02em;
    color: var(--sapwood);
    margin-bottom: 10px;
}

.module-body {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(0.95rem, 1.1vw, 1.1rem);
    line-height: 1.8;
    color: rgba(245, 241, 232, 0.85);
    margin-bottom: 14px;
}

.module-label {
    font-family: var(--font-label);
    font-size: 0.8rem;
    font-variant: small-caps;
    color: var(--weathered-wood);
    letter-spacing: 0.04em;
}

/* ===== Section 3: Botanical Detail ===== */
.section-botanical {
    min-height: 250vh;
    padding: 80px 0;
}

.collage-zone {
    position: relative;
    max-width: 900px;
    margin: 0 auto;
    padding: 60px 40px;
}

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

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

.collage-bg {
    opacity: 0.8;
}

.collage-fg {
    opacity: 0.6;
    --parallax-factor: 0.92;
}

.collage-text-area {
    position: relative;
    z-index: 2;
    max-width: 600px;
    margin: 0 auto;
    padding: 120px 20px;
}

.section-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(2rem, 5vw, 3.8rem);
    letter-spacing: 0.02em;
    color: var(--sapwood);
    margin-bottom: 40px;
}

.botanical-title {
    text-align: center;
}

.botanical-text {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(0.95rem, 1.1vw, 1.1rem);
    line-height: 1.8;
    color: rgba(245, 241, 232, 0.85);
    margin-bottom: 24px;
}

.field-note {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--lichen-gray);
    opacity: 0.4;
    margin-top: 40px;
}

/* ===== Section 4: Ring Count ===== */
.section-rings {
    min-height: 200vh;
    padding: 80px 0;
}

.rings-title {
    text-align: center;
    margin-bottom: 60px;
}

.ring-timeline {
    position: relative;
    max-width: 800px;
    margin: 0 auto;
    padding: 0 40px;
}

/* Vertical spine through rings */
.ring-timeline::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(180deg, var(--trunk-brown), var(--mid-bark));
    transform: translateX(-50%);
    opacity: 0.4;
}

.ring-entry {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 80px;
    opacity: 0;
    transition: opacity 0.6s ease-out;
}

.ring-entry.visible {
    opacity: 1;
}

.ring-circle {
    position: relative;
    z-index: 2;
    flex-shrink: 0;
}

.ring-svg {
    width: 200px;
    height: 200px;
}

.ring-anim {
    animation: ringGlow 6s ease-in-out infinite;
}

@keyframes ringGlow {
    0%, 100% {
        stroke: var(--trunk-brown);
        filter: none;
    }
    50% {
        stroke: var(--spring-green);
        filter: drop-shadow(0 0 4px rgba(154, 205, 50, 0.15));
    }
}

@keyframes ringExpand {
    0% { transform: scale(1); }
    100% { transform: scale(1.03); }
}

.ring-label {
    position: absolute;
    max-width: 280px;
}

.ring-label-left {
    right: calc(50% + 130px);
    text-align: right;
}

.ring-label-right {
    left: calc(50% + 130px);
    text-align: left;
}

.ring-year {
    display: block;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.3rem;
    color: var(--sapwood);
    margin-bottom: 4px;
}

.ring-note {
    display: block;
    font-family: var(--font-body);
    font-size: 0.9rem;
    line-height: 1.6;
    color: rgba(245, 241, 232, 0.7);
}

/* ===== Section 5: Root Descent ===== */
.section-roots {
    min-height: 200vh;
    padding: 80px 0;
    background: linear-gradient(180deg, transparent 0%, rgba(107, 142, 35, 0.03) 30%, rgba(160, 160, 128, 0.05) 100%);
}

.roots-title {
    text-align: center;
    margin-bottom: 40px;
    color: var(--lichen-gray);
}

.roots-container {
    position: relative;
    max-width: 900px;
    margin: 0 auto;
    padding: 40px;
    min-height: 600px;
}

.roots-illustration {
    width: 100%;
    height: auto;
    position: absolute;
    top: 0;
    left: 0;
}

.roots-text-left,
.roots-text-right {
    position: relative;
    z-index: 2;
    max-width: 340px;
}

.roots-text-left {
    margin-bottom: 60px;
    margin-right: auto;
    padding-left: 20px;
}

.roots-text-right {
    margin-left: auto;
    padding-right: 20px;
    text-align: right;
}

.roots-text {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(0.95rem, 1.1vw, 1.1rem);
    line-height: 1.8;
    color: rgba(245, 241, 232, 0.8);
    margin-bottom: 12px;
}

.roots-nomenclature {
    font-family: var(--font-label);
    font-size: 0.8rem;
    font-style: italic;
    color: var(--lichen-gray);
    opacity: 0.6;
}

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

.fragment {
    position: absolute;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--lichen-gray);
    opacity: 0.25;
}

/* ===== Section 6: Closing ===== */
.section-closing {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 40px;
}

.whole-tree-container {
    width: 100%;
    max-width: 500px;
    margin-bottom: 60px;
    opacity: 0;
    transition: opacity 1s ease-out;
}

.whole-tree-container.visible {
    opacity: 1;
}

.whole-tree-svg {
    width: 100%;
    height: auto;
}

.closing-text-area {
    max-width: 600px;
    text-align: center;
    opacity: 0;
    transition: opacity 1s ease-out;
}

.closing-text-area.visible {
    opacity: 1;
}

.closing-statement {
    font-family: var(--font-display);
    font-weight: 300;
    font-size: clamp(1.2rem, 2.5vw, 2rem);
    line-height: 1.7;
    color: var(--sapwood);
    margin-bottom: 40px;
}

.closing-coda {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.6rem;
    color: var(--weathered-wood);
    letter-spacing: 0.08em;
    opacity: 0.7;
}

/* ===== Season Selector ===== */
.season-selector {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 600;
    display: none;
    gap: 8px;
    background: rgba(61, 40, 23, 0.9);
    padding: 12px;
    border-radius: 6px;
    border: 1px solid rgba(107, 68, 35, 0.4);
}

.season-selector.show {
    display: flex;
}

.season-btn {
    font-family: var(--font-label);
    font-size: 0.75rem;
    color: var(--sapwood);
    background: transparent;
    border: 1px solid var(--trunk-brown);
    padding: 4px 10px;
    border-radius: 3px;
    cursor: pointer;
    transition: background 0.3s ease, border-color 0.3s ease;
}

.season-btn:hover {
    background: rgba(107, 68, 35, 0.5);
    border-color: var(--spring-green);
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--dark-bark);
}

::-webkit-scrollbar-thumb {
    background: var(--trunk-brown);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--weathered-wood);
}

/* ===== Typography Breathing Animation ===== */
@keyframes typographyBreathe {
    0%, 100% { font-weight: 400; }
    50% { font-weight: 600; }
}

.section-title.breathing {
    animation: typographyBreathe 1.2s ease-in-out;
}

/* ===== Leaf Unfurl Animation ===== */
@keyframes leafUnfurl {
    0% {
        transform: scale(0.1, 1) rotate(-15deg);
        opacity: 0;
    }
    100% {
        transform: scale(1, 1) rotate(0deg);
        opacity: 1;
    }
}

.module-leaf svg {
    animation: leafUnfurl 0.8s ease-out both;
    animation-play-state: paused;
}

.branch-module.visible .module-leaf svg {
    animation-play-state: running;
}

/* ===== Responsive: Tablet ===== */
@media (max-width: 900px) {
    .module-left {
        margin-left: 60px;
    }

    .module-right {
        margin-right: 60px;
    }

    .ring-label-left {
        right: auto;
        left: 20px;
        text-align: left;
        top: -60px;
    }

    .ring-label-right {
        left: 20px;
        text-align: left;
        top: -60px;
    }

    .ring-entry {
        flex-direction: column;
    }

    .collage-zone {
        padding: 40px 20px;
    }

    .roots-text-left,
    .roots-text-right {
        max-width: 100%;
        margin: 0;
        padding: 20px;
        text-align: left;
    }
}

/* ===== Responsive: Mobile ===== */
@media (max-width: 600px) {
    .trunk-spine {
        left: 20px;
        width: 2px;
        transform: none;
        opacity: 0.4;
    }

    .branch-svg-layer {
        display: none;
    }

    .nav-trunk {
        left: 20px;
        transform: none;
    }

    .module-left,
    .module-right {
        margin-left: 40px;
        margin-right: 20px;
        max-width: none;
        transform: none;
    }

    .module-left.visible,
    .module-right.visible {
        transform: none;
    }

    .branch-module {
        margin-bottom: 60px;
        border-left: 2px solid var(--trunk-brown);
        padding-left: 16px;
    }

    .section-branches {
        padding: 40px 0;
    }

    .ring-timeline::before {
        left: 20px;
        transform: none;
    }

    .ring-circle {
        display: none;
    }

    .ring-label-left,
    .ring-label-right {
        position: relative;
        left: auto;
        right: auto;
        top: auto;
        text-align: left;
        padding-left: 40px;
    }

    .ring-entry {
        margin-bottom: 40px;
    }

    .section-title {
        font-size: clamp(1.5rem, 4vw, 2.4rem);
        padding: 0 20px;
    }

    .collage-layer {
        display: none;
    }

    .collage-text-area {
        padding: 40px 20px;
    }

    .roots-container {
        padding: 20px;
    }

    .roots-illustration {
        display: none;
    }

    .closing-statement {
        font-size: clamp(1rem, 2vw, 1.4rem);
    }

    .section-closing {
        padding: 60px 20px;
    }

    .whole-tree-container {
        max-width: 280px;
    }

    .fragment {
        display: none;
    }

    .branch-markers {
        left: 20px;
        transform: none;
    }
}
