/* =============================================
   muhan.dev - Crystalline Botanical Garden
   Palette: Crystallized Twilight
   ============================================= */

:root {
    --deep-ground: #0B1929;
    --primary-dark: #1A3A5C;
    --mid-tone: #3A5A7A;
    --accent-blue: #8FBDD3;
    --light-accent: #B8D4E3;
    --surface-light: #E8F0F6;
    --pure-light: #F4F8FB;
    --warm-highlight: #C9A87C;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 300;
    background: var(--pure-light);
    color: var(--mid-tone);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* =============================================
   Navigation Diamonds
   ============================================= */

.navigation-diamonds {
    position: fixed;
    right: 24px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 20px;
    z-index: 1000;
}

.diamond {
    width: 6px;
    height: 6px;
    background: var(--accent-blue);
    border: none;
    cursor: pointer;
    transform: rotate(45deg);
    opacity: 0.35;
    transition: opacity 0.4s ease, transform 0.6s cubic-bezier(0.23, 1, 0.32, 1), background-color 0.4s ease;
    padding: 0;
    outline: none;
}

.diamond.active {
    opacity: 1;
    background: var(--primary-dark);
    animation: diamond-pulse 4s ease-in-out infinite;
}

.diamond:hover {
    opacity: 0.8;
    transform: rotate(0deg) scale(1.5);
}

@keyframes diamond-pulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

/* =============================================
   Scroll Container
   ============================================= */

.scroll-container {
    position: relative;
}

/* =============================================
   Sections - Base
   ============================================= */

.section {
    position: relative;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Pre-entry state (default) */
.section .section-inner {
    opacity: 0;
    transition: opacity 1.2s ease-out;
}

.section .crystal-frame {
    opacity: 0.2;
}

/* Active state */
.section.active .section-inner {
    opacity: 1;
}

.section.active .crystal-frame {
    animation: frame-pulse 4s ease-in-out infinite;
}

/* Post-exit state */
.section.visited .section-inner {
    opacity: 0.7;
}

.section.visited .crystal-frame {
    opacity: 0.25;
    animation: none;
}

/* Staggered entry choreography */
.section .section-label {
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.8s ease-out 0.2s, transform 0.8s ease-out 0.2s;
}

.section .display-title,
.section .section-heading,
.section .statement-word,
.section .closing-title {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.9s ease-out 0.3s, transform 0.9s ease-out 0.3s;
}

.section .subtitle,
.section .body-text,
.section .closing-text {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.9s ease-out 0.5s, transform 0.9s ease-out 0.5s;
}

.section .crystal-fern,
.section .hex-cluster,
.section .geometric-lotus,
.section .dissolving-botanical,
.section .infinity-lemniscate {
    opacity: 0;
    transition: opacity 1.2s ease-out 0.8s;
}

.section .feature-stack {
    opacity: 0;
    transform: translateY(15px);
    transition: opacity 1s ease-out 0.4s, transform 1s ease-out 0.4s;
}

.section.active .section-label,
.section.active .display-title,
.section.active .section-heading,
.section.active .statement-word,
.section.active .closing-title,
.section.active .subtitle,
.section.active .body-text,
.section.active .closing-text,
.section.active .crystal-fern,
.section.active .hex-cluster,
.section.active .geometric-lotus,
.section.active .dissolving-botanical,
.section.active .infinity-lemniscate,
.section.active .feature-stack {
    opacity: 1;
    transform: translateY(0);
}

/* =============================================
   Crystal Frame
   ============================================= */

.crystal-frame {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    bottom: 20px;
    border: 1px solid var(--light-accent);
    pointer-events: none;
    clip-path: polygon(
        30px 0%,
        calc(100% - 30px) 0%,
        100% 30px,
        100% calc(100% - 30px),
        calc(100% - 30px) 100%,
        30px 100%,
        0% calc(100% - 30px),
        0% 30px
    );
    z-index: 5;
}

/* Refraction pseudo-element on crystal frames */
.crystal-frame::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: 2px solid transparent;
    border-image: linear-gradient(
        135deg,
        transparent 0%,
        var(--surface-light) 20%,
        var(--accent-blue) 40%,
        var(--light-accent) 60%,
        var(--warm-highlight) 70%,
        var(--accent-blue) 80%,
        transparent 100%
    ) 1;
    opacity: 0;
    transition: opacity 0.8s ease;
    clip-path: inherit;
}

.section.active .crystal-frame::after {
    opacity: 0.15;
}

@keyframes frame-pulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.6; }
}

/* Dark section frames */
[data-theme="dark"] .crystal-frame {
    border-color: var(--mid-tone);
}

/* =============================================
   Section Inner / Grid System
   ============================================= */

.section-inner {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 1200px;
    height: 100%;
    display: flex;
    align-items: center;
    padding: 60px 80px;
}

.section-inner.grid-left {
    justify-content: flex-start;
}

.section-inner.grid-right {
    justify-content: flex-end;
    flex-direction: row-reverse;
}

/* Golden ratio partitions: 1:1.618 */
.content-partition {
    flex: 1.618;
    max-width: 520px;
}

.illustration-partition {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Center-aligned sections */
.section-features .section-inner,
.section-statement .section-inner,
.section-closing .section-inner {
    justify-content: center;
    flex-direction: column;
    text-align: center;
    padding: 60px;
}

/* =============================================
   Section Backgrounds
   ============================================= */

.section-hero {
    background: radial-gradient(ellipse at center, var(--pure-light) 0%, var(--surface-light) 100%);
}

.section-narrative {
    background: radial-gradient(ellipse at center, var(--pure-light) 0%, var(--surface-light) 100%);
}

.section-features {
    background: linear-gradient(180deg, var(--deep-ground) 0%, var(--primary-dark) 100%);
}

.section-statement {
    background: radial-gradient(ellipse at center, var(--pure-light) 0%, var(--surface-light) 100%);
}

.section-closing {
    background: linear-gradient(180deg, var(--deep-ground) 0%, var(--primary-dark) 100%);
}

/* =============================================
   Typography - Display / Headlines
   ============================================= */

.display-title {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-size: clamp(2.5rem, 7vw + 0.5rem, 7rem);
    letter-spacing: 0.04em;
    color: var(--primary-dark);
    line-height: 1.05;
    margin-bottom: 12px;
}

.section-heading {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-size: clamp(2rem, 5vw + 0.5rem, 4rem);
    letter-spacing: 0.04em;
    color: var(--primary-dark);
    line-height: 1.1;
    margin-bottom: 24px;
}

.statement-word {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-size: clamp(3rem, 10vw + 0.5rem, 8rem);
    letter-spacing: 0.04em;
    color: var(--primary-dark);
    line-height: 1;
    margin-bottom: 32px;
    position: relative;
}

/* Refraction shimmer on statement text */
.statement-word::after {
    content: 'Infinite';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        var(--accent-blue) 45%,
        var(--light-accent) 50%,
        var(--accent-blue) 55%,
        transparent 100%
    );
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    opacity: 0;
    animation: shimmer-text 6s ease-in-out infinite;
}

@keyframes shimmer-text {
    0%, 100% { opacity: 0; }
    50% { opacity: 0.3; }
}

.closing-title {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-size: clamp(3rem, 10vw + 0.5rem, 7rem);
    letter-spacing: 0.04em;
    color: var(--surface-light);
    line-height: 1;
    margin-bottom: 20px;
}

/* =============================================
   Typography - Body / Reading
   ============================================= */

.subtitle {
    font-family: 'DM Sans', sans-serif;
    font-weight: 500;
    font-size: clamp(0.7rem, 0.8vw + 0.3rem, 0.85rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent-blue);
    margin-top: 16px;
}

.body-text {
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 300;
    font-size: clamp(0.95rem, 1vw + 0.5rem, 1.15rem);
    line-height: 1.85;
    letter-spacing: 0.01em;
    color: var(--mid-tone);
    max-width: 42ch;
}

.closing-text {
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 300;
    font-size: clamp(0.95rem, 1vw + 0.5rem, 1.15rem);
    line-height: 1.85;
    letter-spacing: 0.01em;
    color: var(--light-accent);
}

/* =============================================
   Typography - Accent / Labels / UI
   ============================================= */

.section-label {
    font-family: 'DM Sans', sans-serif;
    font-weight: 500;
    font-size: clamp(0.7rem, 0.8vw + 0.3rem, 0.85rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent-blue);
    display: block;
    margin-bottom: 16px;
}

.feature-label {
    font-family: 'DM Sans', sans-serif;
    font-weight: 500;
    font-size: clamp(0.7rem, 0.8vw + 0.3rem, 0.85rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent-blue);
}

.closing-label {
    font-family: 'DM Sans', sans-serif;
    font-weight: 500;
    font-size: clamp(0.7rem, 0.8vw + 0.3rem, 0.85rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent-blue);
    display: block;
    margin-top: 32px;
    opacity: 0.6;
}

/* =============================================
   Hero Section
   ============================================= */

.hero-title {
    font-size: clamp(3rem, 8vw + 0.5rem, 7rem);
}

.hero-fern {
    color: var(--accent-blue);
}

/* Scale-hover on botanical illustrations */
.crystal-fern,
.hex-cluster,
.geometric-lotus,
.dissolving-botanical {
    transition: transform 0.6s cubic-bezier(0.23, 1, 0.32, 1), opacity 1.2s ease-out 0.8s;
}

.crystal-fern:hover,
.hex-cluster:hover,
.geometric-lotus:hover,
.dissolving-botanical:hover {
    transform: scale(1.08);
}

/* Infinity Lemniscate */
.infinity-lemniscate {
    margin-top: 24px;
    color: var(--accent-blue);
}

.lemniscate-path {
    stroke-dasharray: 300;
    stroke-dashoffset: 300;
}

.section.active .lemniscate-seg-1 {
    animation: draw-path 2s ease-out 1s forwards;
}

.section.active .lemniscate-seg-2 {
    animation: draw-path 2s ease-out 1.4s forwards;
}

.section.active .lemniscate-seg-3 {
    animation: draw-path 2.5s ease-out 1.8s forwards;
}

.section.active .lemniscate-seg-4 {
    animation: draw-path 2.5s ease-out 2.2s forwards;
}

@keyframes draw-path {
    to { stroke-dashoffset: 0; }
}

/* Lemniscate hover: faster crystallization */
.infinity-lemniscate:hover .lemniscate-path {
    animation-duration: 0.8s !important;
}

.infinity-lemniscate {
    transition: transform 0.6s cubic-bezier(0.23, 1, 0.32, 1), opacity 1.2s ease-out 0.8s;
    cursor: default;
}

.infinity-lemniscate:hover {
    transform: scale(1.05);
}

/* Infinity Watermark */
.infinity-watermark {
    position: absolute;
    bottom: 40px;
    left: 40px;
    opacity: 0.08;
    pointer-events: none;
}

.infinity-watermark.watermark-br {
    bottom: 40px;
    left: auto;
    right: 40px;
    opacity: 0.1;
}

/* =============================================
   Fracture Zones
   ============================================= */

.fracture-zone {
    height: 20vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--pure-light);
    position: relative;
}

.fracture-line {
    height: 1px;
    width: 0%;
    background: linear-gradient(90deg, transparent 0%, var(--accent-blue) 30%, var(--accent-blue) 70%, transparent 100%);
    transition: width 1.2s ease-out;
}

.fracture-zone.visible .fracture-line {
    width: 60%;
}

/* =============================================
   Feature Grid Section
   ============================================= */

.feature-stack {
    display: flex;
    flex-direction: column;
    gap: 48px;
    align-items: center;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 20px;
    transition: transform 0.6s cubic-bezier(0.23, 1, 0.32, 1);
}

.feature-item:hover {
    transform: scale(1.08);
}

.feature-offset-left {
    transform: translateX(-40px);
}

.feature-offset-center {
    transform: translateX(0);
}

.feature-offset-right {
    transform: translateX(40px);
}

.feature-item:hover.feature-offset-left {
    transform: translateX(-40px) scale(1.08);
}

.feature-item:hover.feature-offset-center {
    transform: scale(1.08);
}

.feature-item:hover.feature-offset-right {
    transform: translateX(40px) scale(1.08);
}

.feature-icon {
    color: var(--accent-blue);
    flex-shrink: 0;
}

/* =============================================
   Statement Section
   ============================================= */

.statement-content {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.geometric-lotus {
    margin-top: 8px;
}

/* Refraction line */
.refraction-line {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    width: 120px;
    height: 2px;
    background: linear-gradient(
        90deg,
        var(--surface-light),
        var(--accent-blue),
        var(--light-accent),
        var(--warm-highlight),
        var(--accent-blue),
        var(--surface-light)
    );
    opacity: 0.25;
    pointer-events: none;
}

/* =============================================
   Closing Section
   ============================================= */

.closing-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.dissolving-botanical {
    margin-top: 24px;
}

/* Particle float animation */
.particle {
    animation: particle-float 8s ease-in-out infinite;
}

.particle:nth-child(odd) {
    animation-delay: -2s;
    animation-duration: 10s;
}

.particle:nth-child(even) {
    animation-delay: -5s;
    animation-duration: 7s;
}

@keyframes particle-float {
    0%, 100% { transform: translate(0, 0) rotate(45deg); opacity: 0.2; }
    25% { transform: translate(-2px, -4px) rotate(50deg); opacity: 0.15; }
    50% { transform: translate(1px, -6px) rotate(42deg); opacity: 0.1; }
    75% { transform: translate(-1px, -3px) rotate(48deg); opacity: 0.18; }
}

/* =============================================
   SVG Branch Line Animations
   ============================================= */

.branch-line {
    stroke-dasharray: 400;
    stroke-dashoffset: 400;
}

.section.active .branch-line {
    animation: draw-branch 2.5s ease-out 0.8s forwards;
}

@keyframes draw-branch {
    to { stroke-dashoffset: 0; }
}

/* Crystal leaf reveal */
.crystal-leaf {
    opacity: 0;
}

.section.active .crystal-leaf {
    animation: leaf-reveal 0.6s ease-out forwards;
}

.section.active .crystal-leaf:nth-child(2) { animation-delay: 1.2s; }
.section.active .crystal-leaf:nth-child(3) { animation-delay: 1.4s; }
.section.active .crystal-leaf:nth-child(4) { animation-delay: 1.6s; }
.section.active .crystal-leaf:nth-child(5) { animation-delay: 1.8s; }
.section.active .crystal-leaf:nth-child(6) { animation-delay: 2.0s; }
.section.active .crystal-leaf:nth-child(7) { animation-delay: 2.2s; }
.section.active .crystal-leaf:nth-child(8) { animation-delay: 2.4s; }
.section.active .crystal-leaf:nth-child(9) { animation-delay: 1.3s; }
.section.active .crystal-leaf:nth-child(10) { animation-delay: 1.5s; }
.section.active .crystal-leaf:nth-child(11) { animation-delay: 1.7s; }
.section.active .crystal-leaf:nth-child(12) { animation-delay: 1.9s; }
.section.active .crystal-leaf:nth-child(13) { animation-delay: 2.1s; }
.section.active .crystal-leaf:nth-child(14) { animation-delay: 2.3s; }

@keyframes leaf-reveal {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: var(--leaf-opacity, 0.35); transform: scale(1); }
}

/* Hex seed reveal */
.hex-seed {
    opacity: 0;
}

.section.active .hex-seed {
    animation: hex-appear 0.5s ease-out forwards;
}

.section.active .hex-seed:nth-child(1) { animation-delay: 1.0s; }
.section.active .hex-seed:nth-child(2) { animation-delay: 1.15s; }
.section.active .hex-seed:nth-child(3) { animation-delay: 1.3s; }
.section.active .hex-seed:nth-child(4) { animation-delay: 1.45s; }
.section.active .hex-seed:nth-child(5) { animation-delay: 1.6s; }
.section.active .hex-seed:nth-child(6) { animation-delay: 1.2s; }
.section.active .hex-seed:nth-child(7) { animation-delay: 1.75s; }
.section.active .hex-seed:nth-child(8) { animation-delay: 1.5s; }
.section.active .hex-seed:nth-child(9) { animation-delay: 1.9s; }
.section.active .hex-seed:nth-child(10) { animation-delay: 1.65s; }
.section.active .hex-seed:nth-child(11) { animation-delay: 2.0s; }
.section.active .hex-seed:nth-child(12) { animation-delay: 1.85s; }

@keyframes hex-appear {
    from { opacity: 0; transform: scale(0.6); }
    to { opacity: var(--hex-opacity, 0.35); transform: scale(1); }
}

/* Crystal bud pulse */
.crystal-bud {
    animation: bud-pulse 5s ease-in-out infinite;
}

.crystal-bud:nth-of-type(2) { animation-delay: -1.5s; }
.crystal-bud:nth-of-type(3) { animation-delay: -3s; }

@keyframes bud-pulse {
    0%, 100% { opacity: 0.2; }
    50% { opacity: 0.5; }
}

/* =============================================
   Scale-Hover Interactions
   ============================================= */

/* Text link hover pattern */
a {
    color: var(--mid-tone);
    text-decoration: none;
    transition: color 0.4s ease, transform 0.6s cubic-bezier(0.23, 1, 0.32, 1);
    display: inline-block;
}

a:hover {
    color: var(--accent-blue);
    transform: scale(1.02);
}

/* =============================================
   Responsive - Tablet (below 768px)
   ============================================= */

@media (max-width: 768px) {
    .section {
        min-height: 100vh;
        height: auto;
    }

    .section-inner {
        flex-direction: column !important;
        padding: 60px 32px;
        text-align: center;
    }

    .section-inner.grid-left,
    .section-inner.grid-right {
        justify-content: center;
    }

    .content-partition {
        max-width: 100%;
    }

    .illustration-partition {
        margin-top: 32px;
    }

    .crystal-fern,
    .hex-cluster,
    .geometric-lotus,
    .dissolving-botanical {
        transform: scale(0.6);
    }

    .crystal-fern:hover,
    .hex-cluster:hover,
    .geometric-lotus:hover,
    .dissolving-botanical:hover {
        transform: scale(0.65);
    }

    .crystal-frame {
        clip-path: polygon(
            15px 0%,
            calc(100% - 15px) 0%,
            100% 15px,
            100% calc(100% - 15px),
            calc(100% - 15px) 100%,
            15px 100%,
            0% calc(100% - 15px),
            0% 15px
        );
    }

    .body-text {
        max-width: 100%;
    }

    .feature-offset-left,
    .feature-offset-right {
        transform: translateX(0);
    }

    .feature-item:hover.feature-offset-left,
    .feature-item:hover.feature-offset-right {
        transform: scale(1.08);
    }

    .navigation-diamonds {
        right: 12px;
        gap: 14px;
    }

    .fracture-zone {
        height: 12vh;
    }
}

/* =============================================
   Responsive - Mobile (below 480px)
   ============================================= */

@media (max-width: 480px) {
    .navigation-diamonds {
        position: fixed;
        right: auto;
        top: auto;
        bottom: 16px;
        left: 50%;
        transform: translateX(-50%);
        flex-direction: row;
        gap: 18px;
    }

    .section-inner {
        padding: 40px 20px;
    }

    .statement-word {
        font-size: clamp(2.5rem, 12vw, 5rem);
    }

    .closing-title {
        font-size: clamp(2.5rem, 12vw, 5rem);
    }

    .infinity-watermark {
        display: none;
    }

    .fracture-zone {
        height: 8vh;
    }
}

/* =============================================
   Rotating circle animation (used in dark sections)
   ============================================= */

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