/* ==========================================================================
   lungless.dev — Styles
   Swiss International Style + Forest-Floor Ecology
   ========================================================================== */

/* CSS Custom Properties */
:root {
    --dark-loam: #2b2118;
    --wet-bark: #4a3d2e;
    --moss-canopy: #4a5d3f;
    --lichen-gold: #8a7a5e;
    --birch-paper: #f2ece3;
    --dried-fern: #d4cab8;
    --spring-sprout: #7a8a5e;
    --salamander-orange: #c4713a;
    --body-text-dark: #3d3429;

    --font-display: 'Zilla Slab', serif;
    --font-body: 'Source Serif 4', serif;
    --font-caption: 'Space Grotesk', sans-serif;

    --grid-max: 1280px;
    --grid-gutter: 24px;
    --col: calc((100% - 11 * var(--grid-gutter)) / 12);
}

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

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(17px, 1.8vw, 20px);
    line-height: 1.72;
    letter-spacing: 0.005em;
    color: var(--body-text-dark);
    background-color: var(--birch-paper);
    overflow-x: hidden;
}

/* Z-Pattern Diagonal Guides */
.z-guides {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: var(--grid-max);
    height: 100vh;
    pointer-events: none;
    z-index: 1;
}

.z-guide-line {
    stroke: rgba(74, 93, 63, 0.08);
    stroke-width: 1px;
    fill: none;
}

/* Floating Leaf Motifs */
.leaf-motifs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
    overflow: hidden;
}

.leaf-motif {
    position: absolute;
    opacity: 0.08;
    animation: leafSpin 120s linear infinite;
}

@keyframes leafSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Grid Container */
.grid-container {
    max-width: var(--grid-max);
    margin: 0 auto;
    padding: 0 var(--grid-gutter);
    position: relative;
    z-index: 5;
}

/* Section Base */
.section {
    min-height: 100vh;
    position: relative;
    transition: background-color 0.8s ease;
    overflow: hidden;
}

/* Section Labels */
.section-label {
    font-family: var(--font-caption);
    font-weight: 500;
    font-size: 13px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--spring-sprout);
    display: block;
    margin-bottom: 2rem;
}

/* ==========================================================================
   Section 1: Canopy (Hero)
   ========================================================================== */
.section-canopy {
    background-color: var(--birch-paper);
    display: flex;
    align-items: center;
    min-height: 100vh;
    padding: 8vh 0;
}

.canopy-content {
    width: 50%;
    padding-left: calc(var(--col) + var(--grid-gutter));
}

.hero-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(48px, 8vw, 120px);
    letter-spacing: -0.02em;
    line-height: 1.05;
    color: var(--dark-loam);
    margin-bottom: 0;
}

.hero-subtitle {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(24px, 4vw, 48px);
    letter-spacing: -0.02em;
    line-height: 1.05;
    color: var(--moss-canopy);
    margin-top: -0.1em;
    margin-bottom: 2rem;
}

.hero-tagline {
    font-family: var(--font-body);
    font-size: clamp(17px, 1.8vw, 22px);
    line-height: 1.72;
    color: var(--lichen-gold);
    max-width: 380px;
}

/* Breathing Membrane Canvas */
.breathing-membrane {
    position: absolute;
    top: 0;
    right: 0;
    width: 40%;
    height: 100%;
    z-index: 3;
}

/* ==========================================================================
   Capillary Dividers
   ========================================================================== */
.capillary-divider {
    position: relative;
    height: 40px;
    overflow: visible;
    z-index: 5;
}

.capillary-svg {
    width: 100%;
    height: 40px;
    display: block;
}

.capillary-path {
    fill: none;
    stroke: var(--lichen-gold);
    stroke-width: 0.8;
    opacity: 0.3;
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 2s ease;
}

.capillary-path.capillary-branch {
    stroke-width: 0.5;
    opacity: 0.2;
}

.capillary-divider.visible .capillary-path {
    stroke-dashoffset: 0;
}

/* ==========================================================================
   Section 2: Understory
   ========================================================================== */
.section-understory {
    background-color: var(--dark-loam);
    padding: 12vh 0;
    min-height: 100vh;
    display: flex;
    align-items: center;
}

.understory-content {
    width: 58%;
    padding-left: calc(var(--col) + var(--grid-gutter));
}

.section-understory .section-label {
    color: var(--spring-sprout);
}

.section-heading {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(28px, 4vw, 56px);
    letter-spacing: -0.02em;
    line-height: 1.1;
    color: var(--dried-fern);
    margin-bottom: 3rem;
}

.section-heading em {
    font-style: italic;
    color: var(--spring-sprout);
}

.section-understory .prose-block p {
    color: var(--dried-fern);
    margin-bottom: 1.5rem;
}

.section-understory .prose-block em {
    color: var(--spring-sprout);
    font-style: italic;
}

/* Fern Containers */
.fern-container {
    position: absolute;
    top: 0;
    right: 0;
    width: 35%;
    height: 100%;
    pointer-events: none;
    z-index: 4;
    overflow: hidden;
}

.fern-frond {
    position: absolute;
    opacity: 0;
    transform: scale(0) rotate(-30deg);
    transform-origin: bottom center;
    transition: opacity 0.6s ease, transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.fern-frond.visible {
    opacity: 0.3;
    transform: scale(1) rotate(0deg);
}

/* ==========================================================================
   Section 3: Forest Floor
   ========================================================================== */
.section-forest-floor {
    background-color: var(--moss-canopy);
    padding: 12vh 0;
    min-height: 100vh;
    display: flex;
    align-items: center;
}

.forest-floor-content {
    width: 58%;
    padding-left: calc(var(--col) + var(--grid-gutter));
}

.section-forest-floor .section-label {
    color: var(--spring-sprout);
    opacity: 0.7;
}

.section-forest-floor .section-heading {
    color: var(--birch-paper);
}

.section-forest-floor .prose-block p {
    color: var(--dried-fern);
    margin-bottom: 1.5rem;
}

.emphasis-text {
    font-size: clamp(19px, 2.2vw, 26px);
    line-height: 1.6;
    font-weight: 400;
    color: var(--birch-paper) !important;
}

.salamander-highlight {
    color: var(--salamander-orange);
    font-weight: 600;
}

/* ==========================================================================
   Section 4: Mycelium (Footer)
   ========================================================================== */
.section-mycelium {
    background-color: var(--dark-loam);
    padding: 8vh 0 4vh;
    min-height: 50vh;
    position: relative;
}

.mycelium-content {
    text-align: center;
    padding: 4vh 0 2vh;
}

.section-mycelium .section-label {
    color: var(--lichen-gold);
    opacity: 0.5;
}

.mycelium-text {
    font-family: var(--font-body);
    font-size: clamp(19px, 2.2vw, 26px);
    color: var(--dried-fern);
    font-style: italic;
    opacity: 0.8;
    margin-top: 1rem;
}

.mycelium-network {
    width: 100%;
    height: 400px;
    display: block;
    margin: 0 auto;
    overflow: visible;
}

.mycelium-line {
    stroke: var(--lichen-gold);
    stroke-width: 0.5;
    fill: none;
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    transition: stroke-dashoffset 2s ease;
}

.mycelium-node {
    fill: var(--lichen-gold);
    opacity: 0.6;
}

.mycelium-node-link {
    fill: var(--salamander-orange);
    opacity: 0;
    transition: opacity 0.3s ease;
    cursor: pointer;
}

.section-mycelium.visible .mycelium-line {
    stroke-dashoffset: 0;
}

.section-mycelium.visible .mycelium-node-link {
    opacity: 0.5;
}

.signature-mark {
    position: absolute;
    bottom: 3vh;
    right: 5vw;
    width: 40px;
    height: 40px;
    opacity: 0;
    transition: opacity 1s ease 1.5s;
}

.section-mycelium.visible .signature-mark {
    opacity: 1;
}

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

/* ==========================================================================
   Fade-In Animations (Scroll Triggered)
   ========================================================================== */
.fade-in-element {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275),
                transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.fade-in-element.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Prose Block Spacing */
.prose-block {
    margin-bottom: 2.5rem;
}

.prose-block p {
    margin-bottom: 1.5rem;
}

.prose-block p:last-child {
    margin-bottom: 0;
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 768px) {
    .canopy-content {
        width: 85%;
        padding-left: var(--grid-gutter);
    }

    .breathing-membrane {
        width: 100%;
        opacity: 0.2;
    }

    .understory-content,
    .forest-floor-content {
        width: 90%;
        padding-left: var(--grid-gutter);
    }

    .fern-container {
        width: 20%;
        opacity: 0.5;
    }

    .z-guides {
        display: none;
    }

    .mycelium-network {
        height: 250px;
    }
}

@media (max-width: 480px) {
    .canopy-content,
    .understory-content,
    .forest-floor-content {
        width: 100%;
        padding-left: 16px;
        padding-right: 16px;
    }

    .fern-container {
        display: none;
    }
}
