/* mystical.quest - Seapunk Oracle's Greenhouse */
/* Colors: #b5491e, #e8934a, #0d2b2b, #f5ece0, #2a9d8f, #d4726a, #6b6258, #a8dadc, #1a3c3c */
/* Fonts: Zilla Slab (display), Source Sans 3 (body), Caveat (accent) */

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

::selection {
    background: #a8dadc;
    color: #0d2b2b;
}

html {
    scroll-snap-type: y proximity;
    scroll-behavior: smooth;
}

body.tide-descent {
    font-family: 'Source Sans 3', sans-serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.72;
    letter-spacing: 0.01em;
    color: #6b6258;
    background: #f5ece0;
    overflow-x: hidden;
}

/* ========== GRAIN OVERLAY ========== */
body.tide-descent::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='256' height='256' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
    background-size: 256px 256px;
}

/* ========== POOL SECTIONS ========== */
.pool {
    min-height: 100vh;
    width: 100vw;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    scroll-snap-align: start;
    padding: 4rem 2rem;
}

/* ========== POOL 1: SURFACE ========== */
.pool--surface {
    background: #f5ece0;
    color: #b5491e;
}

.title-scattered {
    font-family: 'Zilla Slab', serif;
    font-weight: 700;
    font-size: clamp(2.5rem, 6vw, 5rem);
    letter-spacing: 0.03em;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.05em;
    width: 80%;
    max-width: 900px;
    color: #b5491e;
    position: relative;
    z-index: 2;
}

.title-scattered .letter {
    display: inline-block;
    transform: translateY(calc(sin(var(--i) * 0.8) * 12px));
    animation: letter-float 3s ease-in-out infinite;
    animation-delay: calc(var(--i) * 150ms);
}

.title-scattered .letter.dot {
    color: #d4726a;
}

@keyframes letter-float {
    0%, 100% { transform: translateY(calc(sin(var(--i) * 0.8) * 12px)); }
    50% { transform: translateY(calc(sin(var(--i) * 0.8) * 12px - 6px)); }
}

.invitation {
    font-family: 'Caveat', cursive;
    font-size: clamp(1.2rem, 2vw, 1.8rem);
    color: #6b6258;
    letter-spacing: 0.02em;
    margin-top: 2rem;
    opacity: 0;
    animation: fade-in 1.2s cubic-bezier(0.22, 1, 0.36, 1) 0.8s forwards;
    position: relative;
    z-index: 2;
}

@keyframes fade-in {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ========== POOL 2: SHALLOWS ========== */
.pool--shallows {
    background: linear-gradient(180deg, #f5ece0 0%, #e8ddd0 100%);
    color: #6b6258;
}

.split-60-40 {
    display: flex;
    width: 100%;
    max-width: 1200px;
    gap: 4rem;
    align-items: center;
    position: relative;
    z-index: 2;
}

.prose-column {
    flex: 0 0 58%;
    padding-left: 5%;
}

.section-heading {
    font-family: 'Zilla Slab', serif;
    font-weight: 700;
    font-size: clamp(1.5rem, 3.5vw, 2.8rem);
    letter-spacing: 0.03em;
    color: #b5491e;
    margin-bottom: 1.5rem;
}

.prose-column p {
    margin-bottom: 1.2rem;
    max-width: 55ch;
}

.annotation {
    font-family: 'Caveat', cursive;
    font-size: clamp(0.9rem, 1.1vw, 1.1rem);
    font-style: italic;
    letter-spacing: 0.02em;
    color: #e8934a;
    margin-top: 1rem;
}

.mandala-column {
    flex: 0 0 38%;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 300px;
}

/* ========== CORAL MANDALA ========== */
.coral-mandala {
    position: relative;
    width: clamp(200px, 25vw, 350px);
    height: clamp(200px, 25vw, 350px);
    animation: mandala-spin 120s linear infinite;
}

.mandala-petal {
    position: absolute;
    width: 60px;
    height: 120px;
    top: 50%;
    left: 50%;
    color: #b5491e;
    opacity: 0.7;
    transform-origin: 0% 0%;
    transform: rotate(calc(var(--i) * 30deg)) translateY(-60px);
    filter: blur(0.5px);
    animation: petal-pulse 8s ease-in-out infinite;
    animation-delay: calc(var(--i) * 0.67s);
}

@keyframes mandala-spin {
    to { transform: rotate(360deg); }
}

@keyframes petal-pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* ========== POOL 3: MID-DEPTH ========== */
.pool--mid {
    background: linear-gradient(180deg, #1a3c3c 0%, #163434 100%);
    color: #f5ece0;
}

.pool--mid .section-heading {
    color: #e8934a;
}

.stagger-cards {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 1100px;
    gap: 2rem;
    position: relative;
    z-index: 2;
}

.drift-card {
    padding: 2rem 2.5rem;
    margin-left: calc(var(--offset) * 15%);
    margin-top: calc(var(--offset) * 2vh);
    max-width: 500px;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s cubic-bezier(0.22, 1, 0.36, 1),
                transform 0.8s cubic-bezier(0.22, 1, 0.36, 1);
    transition-delay: calc(var(--offset) * 150ms);
    text-shadow: 0 2px 8px rgba(13, 43, 43, 0.5);
}

.drift-card.visible {
    opacity: 1;
    transform: translateY(0);
}

.drift-card h3 {
    font-family: 'Zilla Slab', serif;
    font-weight: 700;
    font-size: clamp(1.3rem, 2.5vw, 2rem);
    letter-spacing: 0.03em;
    color: #e8934a;
    margin-bottom: 0.8rem;
}

.drift-card p {
    color: #f5ece0;
    max-width: 45ch;
    line-height: 1.72;
}

/* ========== POOL 4: DEEP ========== */
.pool--deep {
    background: #0d2b2b;
    color: #f5ece0;
}

.pool--deep .section-heading {
    color: #2a9d8f;
}

.centered-narrow {
    max-width: 38ch;
    text-align: center;
    position: relative;
    z-index: 2;
}

.centered-narrow p {
    margin-bottom: 1.2rem;
    color: #a8dadc;
}

.centered-narrow .annotation {
    color: #2a9d8f;
    font-size: clamp(1rem, 1.3vw, 1.2rem);
}

/* ========== POOL 5: FLOOR ========== */
.pool--floor {
    background: #0d2b2b;
    color: #2a9d8f;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 3rem;
}

.domain-echo {
    font-family: 'Zilla Slab', serif;
    font-weight: 700;
    font-size: clamp(1rem, 1.5vw, 1.3rem);
    letter-spacing: 0.15em;
    text-transform: lowercase;
    color: #2a9d8f;
    opacity: 0.4;
}

.closing-sigil {
    width: clamp(80px, 12vw, 150px);
    height: clamp(80px, 12vw, 150px);
    color: #2a9d8f;
    animation: sigil-rotate 60s linear infinite;
}

@keyframes sigil-rotate {
    to { transform: rotate(360deg); }
}

/* ========== BOTANICALS ========== */
.botanicals {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}

.botanical {
    position: absolute;
    filter: blur(0.5px);
    transition: opacity 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Surface botanicals - warm colors */
.botanicals--surface .botanical { color: #b5491e; }
.botanical--1 { top: 5%; left: -2%; width: 120px; opacity: 0.14; transform: rotate(-15deg); }
.botanical--2 { top: 15%; right: 3%; width: 80px; opacity: 0.12; transform: rotate(20deg); }
.botanical--3 { bottom: 10%; left: 8%; width: 100px; opacity: 0.16; transform: rotate(-30deg); }
.botanical--4 { bottom: 5%; right: -1%; width: 140px; opacity: 0.1; transform: rotate(45deg) scaleX(-1); }
.botanical--5 { top: 60%; left: 45%; width: 60px; opacity: 0.08; transform: rotate(10deg); }

/* Shallows botanicals */
.botanicals--shallows .botanical { color: #b5491e; }
.botanical--6 { top: 10%; right: 2%; width: 40px; height: 200px; opacity: 0.12; }
.botanical--7 { bottom: 15%; left: 3%; width: 80px; opacity: 0.15; transform: rotate(-10deg); }

/* Mid-depth botanicals - transitioning to cool */
.botanicals--mid .botanical { color: #2a9d8f; }
.botanical--8 { top: 8%; left: 2%; width: 100px; opacity: 0.18; transform: rotate(-20deg); }
.botanical--9 { bottom: 12%; right: 3%; width: 80px; opacity: 0.15; transform: rotate(15deg); }

/* Deep botanicals - cool teal, more visible */
.botanicals--deep .botanical { color: #2a9d8f; }
.botanical--10 { top: 5%; left: 5%; width: 100px; opacity: 0.2; transform: rotate(-25deg); }
.botanical--11 { top: 15%; right: 8%; width: 80px; opacity: 0.18; transform: rotate(30deg); }
.botanical--12 { top: 30%; left: -1%; width: 40px; height: 180px; opacity: 0.15; }
.botanical--13 { bottom: 30%; right: 3%; width: 90px; opacity: 0.17; transform: rotate(-40deg) scaleX(-1); }
.botanical--14 { bottom: 15%; left: 12%; width: 70px; opacity: 0.2; transform: rotate(50deg); }
.botanical--15 { top: 50%; right: 15%; width: 110px; opacity: 0.12; transform: rotate(-10deg); }
.botanical--16 { bottom: 40%; left: 25%; width: 60px; opacity: 0.16; transform: rotate(5deg); }
.botanical--17 { top: 70%; right: 25%; width: 50px; opacity: 0.14; transform: rotate(25deg); }

/* ========== FLOATING PARTICLES ========== */
.particle-field {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 999;
    overflow: hidden;
}

.particle {
    position: absolute;
    left: var(--x);
    top: var(--y);
    width: var(--size);
    height: var(--size);
    color: #2a9d8f;
    opacity: 0.12;
    animation: particle-drift var(--dur) ease-in-out var(--delay) infinite;
}

@keyframes particle-drift {
    0% {
        transform: translateY(0) translateX(0);
        opacity: 0.08;
    }
    25% {
        transform: translateY(-30vh) translateX(15px);
        opacity: 0.2;
    }
    50% {
        transform: translateY(-60vh) translateX(-10px);
        opacity: 0.15;
    }
    75% {
        transform: translateY(-90vh) translateX(20px);
        opacity: 0.1;
    }
    100% {
        transform: translateY(-120vh) translateX(0);
        opacity: 0.08;
    }
}

/* ========== SHELL NAVIGATION ========== */
.shell-nav {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 500;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 1rem;
}

.shell-icon {
    width: 48px;
    height: 48px;
    border: none;
    background: rgba(13, 43, 43, 0.6);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #d4726a;
    backdrop-filter: blur(8px);
    animation: shell-pulse 3s ease-in-out infinite;
    transition: background 0.3s ease-out;
}

.shell-icon:hover {
    background: rgba(13, 43, 43, 0.85);
}

@keyframes shell-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(212, 114, 106, 0.3); }
    50% { box-shadow: 0 0 0 8px rgba(212, 114, 106, 0); }
}

.dot-track {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: flex-end;
    opacity: 0;
    transform: translateX(10px);
    transition: opacity 0.4s cubic-bezier(0.22, 1, 0.36, 1),
                transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
    pointer-events: none;
}

.shell-nav.open .dot-track {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

.dot-nav {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid #6b6258;
    background: transparent;
    cursor: pointer;
    position: relative;
    transition: all 0.3s ease-out;
    padding: 0;
}

.dot-nav.active {
    border-color: #2a9d8f;
    background: #2a9d8f;
}

.dot-nav:hover {
    border-color: #e8934a;
}

.dot-label {
    position: absolute;
    right: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    font-family: 'Caveat', cursive;
    font-size: 0.85rem;
    color: #f5ece0;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s ease-out;
    pointer-events: none;
}

.dot-nav:hover .dot-label {
    opacity: 0.8;
}

/* ========== SHAKE-ERROR INTERACTION ========== */
@keyframes gentle-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-3px) rotate(-0.5deg); }
    75% { transform: translateX(3px) rotate(0.5deg); }
}

.shaking {
    animation: gentle-shake 400ms ease-in-out !important;
}

.whisper {
    position: absolute;
    font-family: 'Caveat', cursive;
    font-size: clamp(0.85rem, 1vw, 1rem);
    font-style: italic;
    color: #e8934a;
    pointer-events: none;
    white-space: nowrap;
    z-index: 10;
    animation: whisper-float 2s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes whisper-float {
    0% { opacity: 0; transform: translateY(0); }
    20% { opacity: 0.9; }
    80% { opacity: 0.9; transform: translateY(-30px); }
    100% { opacity: 0; transform: translateY(-50px); }
}

/* ========== POOL ENTRY ANIMATIONS ========== */
.pool .section-heading,
.pool .prose-column p,
.pool .centered-narrow p,
.pool .annotation {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s cubic-bezier(0.22, 1, 0.36, 1),
                transform 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

.pool.in-view .section-heading {
    opacity: 1;
    transform: translateY(0);
}

.pool.in-view .prose-column p,
.pool.in-view .centered-narrow p {
    opacity: 1;
    transform: translateY(0);
}

.pool.in-view .prose-column p:nth-child(2) { transition-delay: 150ms; }
.pool.in-view .prose-column p:nth-child(3) { transition-delay: 300ms; }

.pool.in-view .centered-narrow p:nth-child(2) { transition-delay: 150ms; }
.pool.in-view .centered-narrow p:nth-child(3) { transition-delay: 300ms; }

.pool.in-view .annotation {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 450ms;
}

/* ========== BIOLUMINESCENT SPOTS (DEEP SECTIONS) ========== */
.pool--deep::after,
.pool--floor::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background:
        radial-gradient(circle at 15% 25%, rgba(42, 157, 143, 0.04) 0%, transparent 40%),
        radial-gradient(circle at 75% 15%, rgba(42, 157, 143, 0.03) 0%, transparent 35%),
        radial-gradient(circle at 45% 70%, rgba(42, 157, 143, 0.04) 0%, transparent 30%),
        radial-gradient(circle at 85% 60%, rgba(42, 157, 143, 0.03) 0%, transparent 45%),
        radial-gradient(circle at 25% 85%, rgba(42, 157, 143, 0.04) 0%, transparent 35%),
        radial-gradient(circle at 60% 40%, rgba(42, 157, 143, 0.02) 0%, transparent 50%);
    z-index: 0;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
    .split-60-40 {
        flex-direction: column;
        gap: 2rem;
    }
    .prose-column {
        flex: 1;
        padding-left: 0;
    }
    .mandala-column {
        flex: 1;
        min-height: 200px;
    }
    .stagger-cards {
        padding: 0 1rem;
    }
    .drift-card {
        margin-left: calc(var(--offset) * 5%);
    }
    .pool {
        padding: 3rem 1.5rem;
    }
    .title-scattered {
        width: 95%;
    }
    .botanical {
        display: none;
    }
}

/* ========== SURFACE POOL INITIAL STATE ========== */
.pool--surface {
    overflow: hidden;
}

.pool--surface .title-scattered .letter {
    opacity: 0;
    animation: letter-appear 0.6s cubic-bezier(0.22, 1, 0.36, 1) forwards,
               letter-float 3s ease-in-out 1s infinite;
    animation-delay: calc(var(--i) * 100ms), calc(var(--i) * 100ms + 1s);
}

@keyframes letter-appear {
    from {
        opacity: 0;
        transform: translateY(40px) rotate(calc(var(--i) * 2deg - 14deg));
    }
    to {
        opacity: 1;
        transform: translateY(calc(sin(var(--i) * 0.8) * 12px));
    }
}
