/* namu.style - Living Digital Tree */
/* Forest-to-sky palette, East Asian botanical aesthetic */

:root {
    /* Palette from DESIGN.md */
    --bg-hero: #faf9f7;
    --bg-hero-alt: #f9f8f5;
    --bg-secondary: #f0f2ee;
    --bg-tertiary: #f1f3f0;
    --text-primary: #4a5a4a;
    --text-secondary: #8fa88f;
    --illustration-forest: #3d5a42;
    --illustration-sage: #6b8e6f;
    --accent-amber: #d4a574;
    --accent-olive: #7a8f7e;
    --border-muted: rgba(143, 168, 143, 0.2);

    /* Typography */
    --font-display: 'Lora', serif;
    --font-body: 'Inter', sans-serif;
    --font-calligraphic: 'Caveat', cursive;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    color: var(--text-primary);
    background-color: var(--bg-hero);
    overflow-x: hidden;
    line-height: 1.8;
}

/* Fixed Navigation Strip */
.nav-strip {
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 12px 4px;
    z-index: 100;
    opacity: 0;
    transition: opacity 0.6s ease;
    pointer-events: none;
}

.nav-strip.visible {
    opacity: 1;
    pointer-events: auto;
}

.nav-shape {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    cursor: pointer;
    transition: transform 0.2s ease;
    text-decoration: none;
}

.nav-shape:hover {
    transform: scale(1.15);
}

.nav-shape svg {
    transition: fill 0.2s ease;
}

.nav-shape.active svg path,
.nav-shape.active svg ellipse,
.nav-shape.active svg circle,
.nav-shape.active svg line {
    stroke: var(--accent-amber);
}

/* Section base */
.section {
    position: relative;
    width: 100%;
    overflow: hidden;
}

/* Section 1: Root (Hero) */
.section-root {
    min-height: 80vh;
    background-color: var(--bg-hero-alt);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.root-content {
    position: relative;
    z-index: 2;
    text-align: center;
    padding-top: 10vh;
}

.domain-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(2rem, 4.5vw, 3.5rem);
    letter-spacing: -0.01em;
    line-height: 1.3;
    color: var(--text-primary);
    opacity: 0;
    animation: fadeInTitle 1.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

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

.root-illustration {
    width: 100%;
    max-width: 1200px;
    margin-top: 6vh;
    position: relative;
    z-index: 1;
}

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

.root-line {
    stroke-dasharray: 800;
    stroke-dashoffset: 800;
    animation: drawRootLine 2.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.root-line-1 { animation-delay: 0.2s; }
.root-line-2 { animation-delay: 0.5s; }
.root-line-3 { animation-delay: 0.3s; }
.root-line-4 { animation-delay: 0.6s; }
.root-line-5 { animation-delay: 0.8s; }
.root-line-6 { animation-delay: 0.9s; }
.root-line-7 { animation-delay: 1.2s; }
.root-line-8 { animation-delay: 1.3s; }

@keyframes drawRootLine {
    0% { stroke-dashoffset: 800; }
    100% { stroke-dashoffset: 0; }
}

/* Section 2: Trunk */
.section-trunk {
    min-height: 80vh;
    background-color: var(--bg-hero);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 10vh 0;
    position: relative;
}

.trunk-line-container {
    position: absolute;
    left: 8%;
    top: 0;
    bottom: 0;
    width: 40px;
}

.trunk-line-svg {
    width: 100%;
    height: 100%;
}

.trunk-line {
    animation: trunkPulse 3s ease-in-out infinite;
}

@keyframes trunkPulse {
    0%, 100% { opacity: 0.16; }
    50% { opacity: 0.25; }
}

.trunk-content {
    max-width: 380px;
    margin: 0 auto;
    padding: 0 24px;
}

.trunk-leaves {
    position: absolute;
    right: 8%;
    top: 15%;
    display: flex;
    flex-direction: column;
    gap: 60px;
}

.leaf-cluster {
    opacity: 0;
    transition: opacity 0.8s ease;
}

.leaf-cluster.visible {
    opacity: 1;
}

.leaf-cluster-1 {
    animation: leafFloat1 7s ease-in-out infinite;
}

.leaf-cluster-2 {
    animation: leafFloat2 6s ease-in-out infinite;
    animation-delay: 1.5s;
}

.leaf-cluster-3 {
    animation: leafFloat3 8s ease-in-out infinite;
    animation-delay: 3s;
}

@keyframes leafFloat1 {
    0%, 100% { transform: rotate(0deg) translateY(0); }
    50% { transform: rotate(2deg) translateY(-4px); }
}

@keyframes leafFloat2 {
    0%, 100% { transform: rotate(0deg) translateY(0); }
    50% { transform: rotate(-2deg) translateY(-3px); }
}

@keyframes leafFloat3 {
    0%, 100% { transform: rotate(0deg) translateY(0); }
    50% { transform: rotate(1.5deg) translateY(-4px); }
}

/* Spine content (narrow centered column) */
.spine-content {
    max-width: 380px;
    margin: 0 auto;
    padding: 0 24px;
}

/* Section labels */
.section-label {
    font-family: var(--font-body);
    font-weight: 500;
    font-size: 0.9rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--text-secondary);
    opacity: 0.7;
    display: block;
    margin-bottom: 1.5rem;
}

/* Section headings */
.section-heading {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(2rem, 4.5vw, 3.5rem);
    letter-spacing: -0.01em;
    line-height: 1.3;
    color: var(--text-primary);
    margin-bottom: 2rem;
}

/* Body text */
.body-text p {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1rem, 1.1vw, 1.125rem);
    line-height: 1.8;
    letter-spacing: 0em;
    color: var(--text-primary);
    margin-bottom: 1.5em;
}

.body-text p:last-child {
    margin-bottom: 0;
}

.body-text em {
    font-style: italic;
    color: var(--illustration-sage);
}

/* Scroll reveal for body text lines */
.body-text p {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.body-text.revealed p {
    opacity: 1;
    transform: translateY(0);
}

/* Section 3: Crown */
.section-crown {
    min-height: 80vh;
    background: linear-gradient(180deg, var(--bg-hero) 0%, var(--bg-tertiary) 100%);
    padding: 10vh 0;
}

.crown-layout {
    display: grid;
    grid-template-columns: 30% 1fr 45%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    gap: 24px;
    align-items: start;
}

.crown-left {
    padding: 0 16px;
}

.crown-body-left {
    max-width: 100%;
}

.crown-right {
    display: flex;
    align-items: center;
    justify-content: center;
}

.crown-illustration {
    width: 100%;
    max-width: 500px;
    height: auto;
}

.crown-branch {
    stroke-dasharray: 400;
    stroke-dashoffset: 400;
    transition: stroke-dashoffset 1.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.crown-branch.drawn {
    stroke-dashoffset: 0;
}

.crown-leaf-group {
    transition: opacity 0.6s ease;
}

.crown-leaf-group.visible {
    opacity: 1 !important;
}

/* Section 4: Canopy */
.section-canopy {
    min-height: 80vh;
    background-color: #f0f2ee;
    padding: 10vh 0;
}

.canopy-layout {
    display: grid;
    grid-template-columns: 20% 1fr 35%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    gap: 24px;
    align-items: start;
}

.canopy-left {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 40px;
    padding-top: 60px;
}

.canopy-leaf-illustration {
    opacity: 0;
    transition: opacity 0.8s ease;
}

.canopy-leaf-illustration.visible {
    opacity: 1;
}

.canopy-leaf-float-1 {
    animation: leafDrift1 6s ease-in-out infinite;
}

.canopy-leaf-float-2 {
    animation: leafDrift2 7s ease-in-out infinite;
    animation-delay: 2s;
}

.canopy-leaf-float-3 {
    animation: leafDrift3 8s ease-in-out infinite;
    animation-delay: 4s;
}

@keyframes leafDrift1 {
    0%, 100% { transform: rotate(0deg) translateY(0); }
    50% { transform: rotate(-2deg) translateY(-4px); }
}

@keyframes leafDrift2 {
    0%, 100% { transform: rotate(0deg) translateY(0); }
    50% { transform: rotate(2deg) translateY(-3px); }
}

@keyframes leafDrift3 {
    0%, 100% { transform: rotate(0deg) translateY(0); }
    50% { transform: rotate(-1.5deg) translateY(-4px); }
}

.canopy-center {
    padding: 0 16px;
}

.canopy-right {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 40px;
}

.canopy-crown-illustration {
    width: 100%;
    max-width: 400px;
    height: auto;
    opacity: 0;
    transition: opacity 1s ease;
}

.canopy-crown-illustration.visible {
    opacity: 1;
}

.canopy-layer {
    transition: opacity 0.8s ease;
}

/* Section 5: Reflection */
.section-reflection {
    min-height: 60vh;
    background-color: var(--bg-hero);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10vh 0 6vh;
    position: relative;
}

.reflection-content {
    text-align: center;
    max-width: 380px;
}

.reflection-body p {
    text-align: left;
}

.reflection-leaf {
    margin-top: 3rem;
    display: flex;
    justify-content: center;
}

.closing-leaf-svg {
    opacity: 0;
    transition: opacity 0.6s ease;
}

.closing-leaf-svg.visible {
    opacity: 1;
    animation: leafRevealSpin 2s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes leafRevealSpin {
    0% { transform: rotate(0deg); opacity: 0; }
    30% { opacity: 1; }
    100% { transform: rotate(360deg); opacity: 1; }
}

.reflection-horizon {
    width: 80%;
    max-width: 600px;
    margin-top: 4rem;
}

.horizon-line-svg {
    width: 100%;
    display: block;
}

.horizon-line {
    stroke-dasharray: 1200;
    stroke-dashoffset: 1200;
    transition: stroke-dashoffset 1s ease;
}

.horizon-line.drawn {
    stroke-dashoffset: 0;
}

/* Calligraphic notes */
.calligraphic-note {
    font-family: var(--font-calligraphic);
    font-weight: 400;
    font-size: 1.3rem;
    color: var(--accent-amber);
    opacity: 0.3;
    display: block;
    margin-top: 2rem;
}

.reflection-date {
    text-align: center;
}

/* Scroll-based text color shifts */
.section-trunk .body-text p { color: var(--text-primary); }
.section-crown .body-text p { color: #5a6a5a; }
.section-canopy .body-text p { color: #6a7a6a; }
.section-reflection .body-text p { color: var(--text-primary); }

/* Hover states */
.body-text p:hover {
    background-color: var(--bg-tertiary);
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.section-heading:hover {
    background-color: var(--bg-tertiary);
    border-radius: 4px;
}

/* Responsive */
@media (max-width: 900px) {
    .crown-layout {
        grid-template-columns: 1fr;
        gap: 40px;
    }

    .crown-left {
        padding: 0;
    }

    .crown-right {
        order: -1;
    }

    .canopy-layout {
        grid-template-columns: 1fr;
        gap: 40px;
    }

    .canopy-left {
        flex-direction: row;
        justify-content: center;
        padding-top: 0;
        order: -1;
    }

    .canopy-right {
        padding-top: 0;
    }

    .trunk-line-container {
        display: none;
    }

    .trunk-leaves {
        display: none;
    }

    .nav-strip {
        display: none;
    }
}

@media (max-width: 600px) {
    .spine-content,
    .trunk-content {
        max-width: 100%;
        padding: 0 20px;
    }

    .section-heading {
        font-size: clamp(1.6rem, 4vw, 2.5rem);
    }

    .body-text p {
        font-size: 1rem;
    }

    .root-illustration {
        padding: 0 16px;
    }

    .canopy-left {
        gap: 20px;
    }

    .canopy-leaf-illustration {
        width: 40px;
        height: auto;
    }

    .crown-illustration {
        max-width: 300px;
    }

    .canopy-crown-illustration {
        max-width: 250px;
    }

    .reflection-horizon {
        width: 90%;
    }
}
