/* ============================================================
   algoha.com — Mid-Century Tropical Algorithm
   Palette: #ff6b6b #20b2aa #fdf6e3 #2d6a4f #2c1810 #ffecd2 #fcb69f #48cae4
   Fonts: Playfair Display, Lato, Josefin Sans
   ============================================================ */

/* ---------- Custom Properties ---------- */
:root {
    --coral:    #ff6b6b;
    --teal:     #20b2aa;
    --sand:     #fdf6e3;
    --palm:     #2d6a4f;
    --volcanic: #2c1810;
    --peach:    #ffecd2;
    --salmon:   #fcb69f;
    --lagoon:   #48cae4;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--sand);
    color: var(--volcanic);
    font-family: 'Lato', sans-serif;
    font-weight: 400;
    line-height: 1.65;
    overflow-x: hidden;
}

/* ---------- Sunset Gradient Bands (Atmospheric Frame) ---------- */
.sunset-band-top {
    height: 6px;
    background: linear-gradient(90deg,
        var(--peach) 0%,
        var(--salmon) 25%,
        var(--coral) 50%,
        var(--salmon) 75%,
        var(--peach) 100%
    );
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

.sunset-band-bottom {
    height: 6px;
    background: linear-gradient(90deg,
        var(--peach) 0%,
        var(--salmon) 25%,
        var(--coral) 50%,
        var(--salmon) 75%,
        var(--peach) 100%
    );
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

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

/* ---------- Halftone Overlay ---------- */
.halftone-overlay {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle, var(--volcanic) 1px, transparent 1px);
    background-size: 4px 4px;
    opacity: 0.04;
    pointer-events: none;
    z-index: 2;
}

.illustration-halftone {
    opacity: 0.05;
    z-index: 1;
    border-radius: 8px;
}

/* ============================================================
   HERO SECTION — Arrival (0-100vh)
   ============================================================ */
.hero-section {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

.hero-bg {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg,
        var(--peach) 0%,
        var(--salmon) 40%,
        var(--coral) 80%,
        #e05555 100%
    );
    z-index: 0;
}

/* Geometric Birds in V-formation */
.birds-formation {
    position: absolute;
    top: 12%;
    right: 20%;
    z-index: 5;
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.bird {
    display: block;
    width: 18px;
    height: 8px;
    position: relative;
}

.bird::before,
.bird::after {
    content: '';
    position: absolute;
    top: 0;
    width: 0;
    height: 0;
}

.bird::before {
    left: 0;
    border-left: 8px solid transparent;
    border-bottom: 6px solid var(--volcanic);
}

.bird::after {
    right: 0;
    border-right: 8px solid transparent;
    border-bottom: 6px solid var(--volcanic);
}

.bird:nth-child(1) { transform: translateY(8px); }
.bird:nth-child(2) { transform: translateY(4px); }
.bird:nth-child(3) { transform: translateY(0); }
.bird:nth-child(4) { transform: translateY(4px); }
.bird:nth-child(5) { transform: translateY(8px); }

/* Geometric Mountains */
.mountains {
    position: absolute;
    bottom: 100px;
    left: 0;
    right: 0;
    z-index: 1;
    pointer-events: none;
}

.mountain {
    position: absolute;
    bottom: 0;
    width: 0;
    height: 0;
}

.mountain-1 {
    left: -5%;
    border-left: 280px solid transparent;
    border-right: 280px solid transparent;
    border-bottom: 320px solid var(--palm);
    opacity: 0.5;
}

.mountain-2 {
    right: -8%;
    border-left: 350px solid transparent;
    border-right: 350px solid transparent;
    border-bottom: 380px solid var(--palm);
    opacity: 0.35;
}

.mountain-3 {
    left: 30%;
    border-left: 200px solid transparent;
    border-right: 200px solid transparent;
    border-bottom: 240px solid var(--palm);
    opacity: 0.25;
}

/* Palm Fronds */
.frond {
    position: absolute;
    z-index: 3;
    pointer-events: none;
}

.frond-left-top {
    top: 0;
    left: -20px;
    width: 180px;
    height: 360px;
    opacity: 0;
    transform: translateX(-60px);
    transition: opacity 1.2s ease 0.5s, transform 1.2s ease 0.5s;
}

.frond-right-top {
    top: 0;
    right: -20px;
    width: 180px;
    height: 360px;
    opacity: 0;
    transform: translateX(60px);
    transition: opacity 1.2s ease 0.7s, transform 1.2s ease 0.7s;
}

.frond-left-top.visible,
.frond-right-top.visible {
    opacity: 1;
    transform: translateX(0);
}

/* Hero Content */
.hero-content {
    position: relative;
    z-index: 6;
    text-align: center;
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 1s ease 0.3s, transform 1s ease 0.3s;
}

.hero-content.visible {
    opacity: 1;
    transform: scale(1);
}

.starburst {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 180px;
    height: 180px;
    z-index: -1;
}

.starburst::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--coral);
    border-radius: 50%;
    opacity: 0.25;
    animation: starburst-pulse 3s ease-in-out infinite;
}

.starburst::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 220px;
    height: 220px;
    transform: translate(-50%, -50%) rotate(22.5deg);
    background: conic-gradient(
        from 0deg,
        transparent 0deg, var(--coral) 5deg, transparent 10deg,
        transparent 45deg, var(--coral) 50deg, transparent 55deg,
        transparent 90deg, var(--coral) 95deg, transparent 100deg,
        transparent 135deg, var(--coral) 140deg, transparent 145deg,
        transparent 180deg, var(--coral) 185deg, transparent 190deg,
        transparent 225deg, var(--coral) 230deg, transparent 235deg,
        transparent 270deg, var(--coral) 275deg, transparent 280deg,
        transparent 315deg, var(--coral) 320deg, transparent 325deg
    );
    opacity: 0.12;
    animation: starburst-spin 30s linear infinite;
}

@keyframes starburst-pulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.25; }
    50% { transform: translate(-50%, -50%) scale(1.15); opacity: 0.35; }
}

@keyframes starburst-spin {
    from { transform: translate(-50%, -50%) rotate(22.5deg); }
    to { transform: translate(-50%, -50%) rotate(382.5deg); }
}

.brand-name {
    font-family: 'Playfair Display', serif;
    font-weight: 900;
    font-size: clamp(4rem, 12vw, 8rem);
    color: var(--volcanic);
    letter-spacing: -0.02em;
    line-height: 1;
}

.brand-tagline {
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 300;
    font-size: clamp(0.75rem, 1.5vw, 1rem);
    text-transform: uppercase;
    letter-spacing: 0.25em;
    color: var(--volcanic);
    opacity: 0.65;
    margin-top: 1rem;
}

/* Wave Dividers */
.wave-divider {
    position: absolute;
    left: 0;
    width: 100%;
    z-index: 7;
    pointer-events: none;
}

.wave-divider-hero {
    bottom: 0;
}

.wave-divider-hero svg {
    width: 100%;
    height: 120px;
    display: block;
}

.wave-divider-mid {
    position: relative;
    margin: 2rem 0;
}

.wave-divider-mid svg {
    width: 100%;
    height: 60px;
    display: block;
}

.wave-divider-bottom {
    bottom: 0;
}

.wave-divider-bottom svg {
    width: 100%;
    height: 80px;
    display: block;
}

/* Wave animation */
.wave-1 { animation: wave-sway 6s ease-in-out infinite; }
.wave-2 { animation: wave-sway 5s ease-in-out infinite 0.5s; }
.wave-3 { animation: wave-sway 7s ease-in-out infinite 1s; }
.wave-4 { animation: wave-sway 4s ease-in-out infinite 1.5s; }

@keyframes wave-sway {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(-15px); }
}

/* ============================================================
   GARDEN SECTION — Magazine Spreads (100-250vh)
   ============================================================ */
.garden-section {
    background-color: var(--sand);
    padding: 6rem 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}

/* Tiki-geometry borders */
.tiki-border {
    width: 100%;
    max-width: 1100px;
}

.tiki-border svg {
    width: 100%;
    height: 30px;
    display: block;
}

/* Spreads */
.spread {
    display: flex;
    gap: 3rem;
    max-width: 1000px;
    width: 100%;
    align-items: center;
    padding: 2rem 0;
    opacity: 0;
    transition: opacity 0.8s ease, transform 0.8s ease;
}

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

.spread-right {
    flex-direction: row-reverse;
    transform: translateX(40px);
}

.spread.visible {
    opacity: 1;
    transform: translateX(0);
}

/* Spread Illustration Area */
.spread-illustration {
    flex: 1;
    min-height: 280px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(253,246,227,0.5), rgba(255,236,210,0.3));
    border-radius: 12px;
    overflow: hidden;
}

/* Botanical Corner Frames */
.botanical-frame {
    position: absolute;
    width: 80px;
    height: 80px;
    z-index: 3;
    pointer-events: none;
}

.botanical-tl { top: 8px; left: 8px; }
.botanical-br { bottom: 8px; right: 8px; }

.botanical-frame svg {
    width: 100%;
    height: 100%;
}

/* Monstera Leaf */
.monstera-leaf {
    position: absolute;
    width: 100px;
    height: 100px;
    background: var(--palm);
    clip-path: polygon(50% 0%, 80% 10%, 100% 35%, 95% 70%, 70% 90%, 50% 100%, 30% 90%, 5% 70%, 0% 35%, 20% 10%);
    opacity: 0.15;
}

.monstera-bg {
    top: 10px;
    left: 10px;
}

/* Sorting Bars Visualization */
.sort-container {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 200px;
    padding: 1rem;
    position: relative;
    z-index: 2;
}

.sort-bar {
    width: 28px;
    height: var(--bar-h);
    border-radius: 4px 4px 0 0;
    background: linear-gradient(180deg, var(--coral), var(--salmon));
    transition: height 0.4s ease, transform 0.3s ease, background 0.4s ease;
    position: relative;
}

.sort-bar.active {
    background: linear-gradient(180deg, var(--lagoon), var(--teal));
    transform: translateY(-4px);
}

.sort-bar.sorted {
    background: linear-gradient(180deg, var(--teal), var(--palm));
}

/* Palm Silhouette */
.palm-silhouette {
    position: absolute;
    z-index: 1;
    pointer-events: none;
}

.palm-sil-left {
    left: 5px;
    bottom: 5px;
    width: 60px;
    height: 120px;
}

.palm-sil-left svg {
    width: 100%;
    height: 100%;
}

/* Fractal Canvas */
.fractal-canvas {
    position: relative;
    z-index: 2;
    max-width: 100%;
}

/* Graph Canvas */
.graph-canvas {
    position: relative;
    z-index: 2;
    max-width: 100%;
}

/* Spread Text */
.spread-text {
    flex: 1.2;
}

.spread-label {
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 400;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.25em;
    color: var(--teal);
    display: block;
    margin-bottom: 0.5rem;
}

.spread-heading {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: clamp(1.6rem, 3vw, 2.2rem);
    color: var(--volcanic);
    margin-bottom: 1rem;
    line-height: 1.2;
}

.spread-body {
    font-family: 'Lato', sans-serif;
    font-size: 0.95rem;
    line-height: 1.65;
    color: rgba(44, 24, 16, 0.75);
    margin-bottom: 0.75rem;
}

/* Starburst Bullet Points */
.starburst-bullet {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 1rem;
}

.starburst-icon {
    width: 16px;
    height: 16px;
    position: relative;
    flex-shrink: 0;
}

.starburst-icon::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--coral);
    clip-path: polygon(
        50% 0%, 61% 35%, 98% 35%, 68% 57%,
        79% 91%, 50% 70%, 21% 91%, 32% 57%,
        2% 35%, 39% 35%
    );
}

.bullet-text {
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 400;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
    color: var(--volcanic);
    opacity: 0.65;
}

/* ============================================================
   GROVE SECTION — Binary Tree (250-350vh)
   ============================================================ */
.grove-section {
    background: var(--sand);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6rem 2rem;
    gap: 1.5rem;
    position: relative;
}

.grove-bg {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg,
        var(--sand) 0%,
        rgba(253,246,227,1) 40%,
        rgba(255,236,210,0.3) 100%
    );
    z-index: 0;
}

.grove-frond {
    position: absolute;
    z-index: 1;
    pointer-events: none;
}

.grove-frond-left {
    left: 0;
    top: 10%;
    width: 120px;
    height: 250px;
}

.grove-frond-right {
    right: 0;
    top: 15%;
    width: 120px;
    height: 250px;
}

.grove-frond svg {
    width: 100%;
    height: 100%;
}

.section-label {
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 400;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.25em;
    color: var(--teal);
    position: relative;
    z-index: 2;
}

.grove-title {
    font-family: 'Playfair Display', serif;
    font-weight: 900;
    font-size: clamp(2rem, 4vw, 3rem);
    color: var(--volcanic);
    position: relative;
    z-index: 2;
}

.grove-subtitle {
    font-family: 'Lato', sans-serif;
    font-size: 0.95rem;
    color: rgba(44, 24, 16, 0.5);
    position: relative;
    z-index: 2;
    margin-bottom: 1rem;
}

/* Tree Container */
.tree-container {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 700px;
}

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

/* Tree node circles */
.tree-svg .tree-node-circle {
    transition: opacity 0.6s ease, r 0.4s ease;
}

.tree-svg .tree-branch-line {
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
    transition: stroke-dashoffset 0.8s ease;
}

.tree-svg .tree-branch-line.drawn {
    stroke-dashoffset: 0;
}

.tree-svg .tree-leaf {
    opacity: 0;
    transition: opacity 0.5s ease 0.3s;
}

.tree-svg .tree-leaf.grown {
    opacity: 1;
}

.grove-caption {
    font-family: 'Playfair Display', serif;
    font-style: italic;
    font-size: clamp(0.9rem, 1.5vw, 1.1rem);
    color: rgba(44, 24, 16, 0.45);
    position: relative;
    z-index: 2;
    margin-top: 1rem;
}

/* ============================================================
   SUNSET SECTION (350vh+)
   ============================================================ */
.sunset-section {
    min-height: 70vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 6rem 2rem;
}

.sunset-bg {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg,
        var(--sand) 0%,
        var(--salmon) 30%,
        var(--coral) 55%,
        #c0392b 75%,
        var(--volcanic) 100%
    );
    z-index: 0;
}

/* Stars */
.stars-field {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
}

.geo-star {
    position: absolute;
    left: var(--x);
    top: var(--y);
    width: var(--size);
    height: var(--size);
    background: var(--peach);
    transform: rotate(45deg);
    opacity: 0;
    transition: opacity 0.8s ease;
    transition-delay: var(--delay);
}

.geo-star.twinkle {
    opacity: 0.7;
    animation: star-twinkle 3s ease-in-out infinite;
    animation-delay: var(--delay);
}

@keyframes star-twinkle {
    0%, 100% { opacity: 0.7; transform: rotate(45deg) scale(1); }
    50% { opacity: 0.3; transform: rotate(45deg) scale(0.6); }
}

.sunset-content {
    position: relative;
    z-index: 2;
    max-width: 600px;
    text-align: center;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 1.2s ease, transform 1.2s ease;
}

.sunset-content.visible {
    opacity: 1;
    transform: translateY(0);
}

.sunset-quote {
    font-family: 'Playfair Display', serif;
    font-style: italic;
    font-weight: 400;
    font-size: clamp(1.4rem, 3.5vw, 2.2rem);
    color: var(--sand);
    line-height: 1.5;
}

.sunset-divider {
    width: 60px;
    height: 2px;
    background: var(--peach);
    opacity: 0.4;
    margin: 2rem auto;
}

.sunset-sign {
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 300;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.3em;
    color: var(--peach);
    opacity: 0.5;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
    .spread {
        flex-direction: column;
        gap: 1.5rem;
    }

    .spread-right {
        flex-direction: column;
    }

    .spread-illustration {
        min-height: 220px;
        width: 100%;
    }

    .mountains {
        display: none;
    }

    .frond-left-top,
    .frond-right-top {
        width: 120px;
        height: 240px;
    }

    .birds-formation {
        right: 10%;
        top: 8%;
    }

    .grove-frond {
        display: none;
    }
}

@media (max-width: 480px) {
    .frond-left-top,
    .frond-right-top {
        width: 80px;
        height: 160px;
    }

    .sort-container {
        height: 140px;
    }

    .sort-bar {
        width: 20px;
    }

    .tree-container {
        max-width: 100%;
    }
}
