/* ============================================
   aiice.quest -- Subaquatic Quest
   Palette: #E8F4F8 #2DD4BF #06B6D4 #7C3AED
            #1E1B4B #0C0A2A #030712 #FBBF24 #34D399
   Fonts:   Geologica, Bricolage Grotesque,
            Hanken Grotesk, Azeret Mono
   ============================================ */

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

:root {
    --foam: #E8F4F8;
    --teal: #2DD4BF;
    --cyan: #06B6D4;
    --violet: #7C3AED;
    --indigo: #1E1B4B;
    --navy: #0C0A2A;
    --abyss: #030712;
    --gold: #FBBF24;
    --biolume: #34D399;

    --font-display: 'Geologica', system-ui, sans-serif;
    --font-heading: 'Bricolage Grotesque', system-ui, sans-serif;
    --font-body: 'Hanken Grotesk', system-ui, sans-serif;
    --font-mono: 'Azeret Mono', ui-monospace, monospace;
}

html, body {
    width: 100%;
    height: 100%;
    background: var(--abyss);
    color: var(--foam);
    font-family: var(--font-body);
    font-weight: 300;
    overflow: hidden;
}

body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* =========================================
   Horizontal scroll container
   ========================================= */
#scroll-container {
    display: flex;
    flex-direction: row;
    width: 100vw;
    height: 100vh;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    scrollbar-width: none;
}
#scroll-container::-webkit-scrollbar { display: none; }

.chamber {
    flex: 0 0 100vw;
    width: 100vw;
    height: 100vh;
    position: relative;
    scroll-snap-align: start;
    overflow: hidden;
    isolation: isolate;
}

/* Chamber backgrounds (depth gradient) */
#chamber-0 {
    background: linear-gradient(180deg, var(--foam) 0%, #B8D4E0 12%, #5570A0 35%, var(--indigo) 100%);
}
#chamber-1 {
    background: radial-gradient(ellipse at 70% 30%, rgba(45, 212, 191, 0.18) 0%, transparent 55%),
                linear-gradient(180deg, #2A2A6A 0%, var(--indigo) 100%);
}
#chamber-2 {
    background: radial-gradient(ellipse at 30% 40%, rgba(6, 182, 212, 0.15) 0%, transparent 55%),
                linear-gradient(180deg, var(--indigo) 0%, var(--navy) 100%);
}
#chamber-3 {
    background: radial-gradient(ellipse at 60% 35%, rgba(124, 58, 237, 0.18) 0%, transparent 60%),
                linear-gradient(180deg, var(--navy) 0%, #050414 100%);
}
#chamber-4 {
    background: radial-gradient(ellipse at 50% 50%, #07061A 0%, var(--abyss) 100%);
}

/* =========================================
   Caustic light (water surface refraction)
   ========================================= */
.caustic-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    background:
        radial-gradient(ellipse 60% 30% at 20% 30%, rgba(232, 244, 248, 0.05), transparent 70%),
        radial-gradient(ellipse 50% 35% at 70% 60%, rgba(232, 244, 248, 0.04), transparent 70%),
        radial-gradient(ellipse 45% 25% at 45% 80%, rgba(232, 244, 248, 0.03), transparent 70%),
        radial-gradient(ellipse 55% 30% at 85% 20%, rgba(232, 244, 248, 0.03), transparent 70%);
    mix-blend-mode: overlay;
    animation: caustic-drift 24s ease-in-out infinite alternate;
}
@keyframes caustic-drift {
    0%   { background-position: 0% 0%, 0% 0%, 0% 0%, 0% 0%; }
    100% { background-position: 4% 3%, -3% 2%, 2% -2%, -4% 4%; }
}

/* =========================================
   Particles (bioluminescent)
   ========================================= */
.particle-field {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 2;
}
.particle-field .particle {
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: radial-gradient(circle, currentColor 0%, transparent 70%);
    opacity: 0.6;
    animation: drift-particle var(--p-dur, 8s) ease-in-out var(--p-delay, 0s) infinite alternate;
    will-change: transform, opacity;
}
@keyframes drift-particle {
    0%   { transform: translate(0, 0) scale(1); opacity: 0.2; }
    50%  { opacity: 0.8; }
    100% { transform: translate(var(--p-dx, 12px), var(--p-dy, -28px)) scale(1.1); opacity: 0.3; }
}

/* =========================================
   Chamber 0 -- Surface
   ========================================= */
.wave-stack {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 22vh;
    z-index: 3;
    pointer-events: none;
    overflow: hidden;
}
.wave {
    position: absolute;
    left: -10%;
    width: 120%;
    height: 70%;
    bottom: 0;
    border-radius: 45% 55% 50% 50% / 100% 100% 0 0;
    background: var(--teal);
    opacity: 0.1;
    animation: wave-roll 7s ease-in-out infinite alternate;
}
.wave-1 { background: var(--teal);   opacity: 0.12; animation-duration: 7s; bottom: 0; }
.wave-2 { background: var(--cyan);   opacity: 0.08; animation-duration: 9s; bottom: 8%; animation-delay: -2s; }
.wave-3 { background: var(--biolume);opacity: 0.06; animation-duration: 11s; bottom: 14%; animation-delay: -4s; }
@keyframes wave-roll {
    0%   { border-radius: 45% 55% 50% 50% / 100% 100% 0 0; transform: translateX(-3%); }
    50%  { border-radius: 52% 48% 46% 54% / 100% 100% 0 0; transform: translateX(3%); }
    100% { border-radius: 48% 52% 53% 47% / 100% 100% 0 0; transform: translateX(-2%); }
}

.surface-content {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.6rem;
    padding: 0 6vw;
    text-align: center;
}

.logotype {
    position: relative;
    font-family: var(--font-display);
    font-weight: 100;
    font-size: clamp(48px, 12vw, 160px);
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--foam);
    line-height: 1;
    cursor: default;
    transition: font-variation-settings 600ms ease;
    font-variation-settings: 'wght' 100;
    user-select: none;
    margin-top: 4vh;
}
.logotype .logo-above {
    display: block;
    position: relative;
    clip-path: inset(0 0 50% 0);
}
.logotype .logo-below {
    display: block;
    position: absolute;
    inset: 0;
    color: var(--teal);
    opacity: 0.55;
    clip-path: inset(50% 0 0 0);
    transform: skewX(-3deg) translateY(2px);
    filter: blur(0.3px);
    pointer-events: none;
}
.logotype:hover {
    font-variation-settings: 'wght' 400;
}

.surface-tagline {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: clamp(14px, 1.4vw, 18px);
    color: var(--indigo);
    max-width: 42ch;
    line-height: 1.7;
    opacity: 0;
    animation: fade-up 1.4s 0.6s ease forwards;
}
@keyframes fade-up {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 0.85; transform: translateY(0); }
}

.scroll-hint {
    position: absolute;
    right: 5vw;
    bottom: 12vh;
    display: flex;
    align-items: center;
    gap: 14px;
    font-family: var(--font-mono);
    font-size: clamp(10px, 0.8vw, 13px);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--foam);
    opacity: 0.6;
    animation: hint-bob 2.4s ease-in-out infinite alternate;
}
.scroll-hint-arrow {
    font-size: 1.6em;
    color: var(--teal);
}
@keyframes hint-bob {
    from { transform: translateX(0); opacity: 0.45; }
    to   { transform: translateX(10px); opacity: 0.85; }
}

/* =========================================
   Chamber content (1-3)
   ========================================= */
.chamber-content {
    position: absolute;
    inset: 0;
    z-index: 6;
    padding: 8vh 8vw;
    display: grid;
    grid-template-columns: 1fr;
    align-content: center;
    gap: 1.4rem;
}

.specimen-label {
    font-family: var(--font-mono);
    font-size: clamp(10px, 0.8vw, 13px);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--foam);
    opacity: 0.55;
}

.chamber-heading {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: clamp(20px, 3.5vw, 44px);
    line-height: 1.15;
    max-width: 22ch;
    position: relative;
    color: var(--foam);
}
#chamber-1 .chamber-heading { color: var(--teal); }
#chamber-2 .chamber-heading { color: var(--cyan); }
#chamber-3 .chamber-heading { color: var(--violet); }

/* Refracted text effect */
.refracted::after {
    content: attr(data-text);
    position: absolute;
    left: 1px;
    top: 2px;
    transform: scaleY(1.02);
    pointer-events: none;
    z-index: -1;
}
#chamber-1 .refracted::after { color: rgba(45, 212, 191, 0.4); }
#chamber-2 .refracted::after { color: rgba(6, 182, 212, 0.4); }
#chamber-3 .refracted::after { color: rgba(124, 58, 237, 0.4); }

/* Floating cards */
.float-card {
    position: relative;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 1.4rem 1.6rem;
    max-width: 42ch;
    border-radius: 4px;
    border: 1px solid rgba(232, 244, 248, 0.15);
    background: rgba(232, 244, 248, 0.04);
    transform: rotate(var(--card-rotate, 0deg));
    box-shadow: 0 6px 30px rgba(0, 0, 0, 0.35),
                inset 0 0 30px rgba(232, 244, 248, 0.03);
    opacity: 0;
    transition: opacity 700ms ease, transform 700ms ease;
}
.float-card.in-view {
    opacity: 1;
}
.float-card.card-a { transition-delay: 0ms;   margin-left: 0; }
.float-card.card-b { transition-delay: 150ms; margin-left: 8vw; }
.float-card.card-c { transition-delay: 300ms; margin-left: 16vw; max-width: 32ch; }

.float-card:not(.in-view) { transform: rotate(var(--card-rotate, 0deg)) translateX(40px); }

#chamber-1 .float-card { background: rgba(45, 212, 191, 0.06); border-color: rgba(45, 212, 191, 0.18); }
#chamber-2 .float-card { background: rgba(6, 182, 212, 0.06);  border-color: rgba(6, 182, 212, 0.18); }
#chamber-3 .float-card { background: rgba(124, 58, 237, 0.06); border-color: rgba(124, 58, 237, 0.22); }

.float-card p {
    font-size: clamp(14px, 1.2vw, 17px);
    line-height: 1.7;
    color: var(--foam);
    max-width: 42ch;
}
.float-card em { font-style: italic; opacity: 0.9; }
.float-card strong { font-weight: 500; color: var(--foam); }

.card-annotation {
    font-family: var(--font-mono);
    font-size: clamp(10px, 0.8vw, 12px);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    opacity: 0.7;
}

/* Frosted ICE chamber cards: animated crystalline edges */
.frosted {
    border: 1px solid transparent;
    background-image:
        linear-gradient(rgba(6, 182, 212, 0.06), rgba(6, 182, 212, 0.06)),
        linear-gradient(120deg,
            rgba(232, 244, 248, 0) 0%,
            rgba(232, 244, 248, 0.55) 12%,
            rgba(232, 244, 248, 0) 24%,
            rgba(232, 244, 248, 0) 76%,
            rgba(232, 244, 248, 0.55) 88%,
            rgba(232, 244, 248, 0) 100%);
    background-origin: border-box;
    background-clip: padding-box, border-box;
    animation: ice-form 6s ease-in-out infinite alternate;
}
@keyframes ice-form {
    from { background-position: 0% 0%, 0% 0%; }
    to   { background-position: 0% 0%, 100% 100%; }
}

/* =========================================
   Jellyfish SVG
   ========================================= */
.jellyfish {
    position: absolute;
    z-index: 4;
    height: 55vh;
    width: auto;
    pointer-events: none;
    opacity: 0.85;
    will-change: transform;
}
.jellyfish-1 { top: 6vh;  right: 8vw; animation: jelly-bob 8s ease-in-out infinite alternate; }
.jellyfish-2 { top: 10vh; left: 4vw;  animation: jelly-bob 10s ease-in-out infinite alternate; transform: scaleX(-1); }
.jellyfish-3 { top: 4vh;  right: 4vw; animation: jelly-bob 12s ease-in-out infinite alternate; height: 65vh; }

.jellyfish .tentacles {
    transform-origin: 200px 220px;
    animation: tentacle-sway 4s ease-in-out infinite alternate;
}
@keyframes tentacle-sway {
    from { transform: skewX(-3deg); }
    to   { transform: skewX(3deg); }
}
@keyframes jelly-bob {
    from { transform: translateY(0); }
    to   { transform: translateY(-22px); }
}
.jellyfish-2 { animation-name: jelly-bob-flip; }
@keyframes jelly-bob-flip {
    from { transform: scaleX(-1) translateY(0); }
    to   { transform: scaleX(-1) translateY(-26px); }
}

/* =========================================
   Chamber 3 -- Alice poem
   ========================================= */
.alice-content {
    align-content: center;
}
.alice-poem {
    max-width: 52ch;
    margin-top: 1rem;
}
.alice-line {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: clamp(16px, 1.6vw, 22px);
    line-height: 2.0;
    color: var(--foam);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 600ms ease, transform 600ms ease;
}
.alice-poem.reveal .alice-line {
    opacity: 0.92;
    transform: translateY(0);
}
.alice-poem.reveal .alice-line:nth-child(1) { transition-delay: 0ms; }
.alice-poem.reveal .alice-line:nth-child(2) { transition-delay: 600ms; }
.alice-poem.reveal .alice-line:nth-child(3) { transition-delay: 1200ms; }
.alice-poem.reveal .alice-line:nth-child(4) { transition-delay: 1800ms; }
.alice-poem.reveal .alice-line:nth-child(5) { transition-delay: 2400ms; }
.alice-poem.reveal .alice-line:nth-child(6) { transition-delay: 3000ms; }
.alice-poem.reveal .alice-line:nth-child(7) { transition-delay: 3600ms; }
.alice-poem.reveal .alice-line:nth-child(8) { transition-delay: 4200ms; }
.alice-poem.reveal .alice-line:nth-child(9) { transition-delay: 4800ms; }

.violet-glow {
    color: var(--violet);
    text-shadow: 0 0 14px rgba(124, 58, 237, 0.6);
    font-weight: 400;
}

/* =========================================
   Chamber 4 -- Abyss
   ========================================= */
.abyss-vignette {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 32% 42%, rgba(251, 191, 36, 0.06) 0%, transparent 35%);
    z-index: 1;
    pointer-events: none;
}
.abyss-stage {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    padding: 0 6vw;
    z-index: 5;
    opacity: 0;
    transition: opacity 1.4s ease;
}
.abyss-stage.materialize {
    opacity: 1;
}
.anglerfish {
    width: clamp(360px, 60vw, 760px);
    height: auto;
}
.lure-glow {
    transform-origin: center;
    animation: lure-pulse 3.6s ease-in-out infinite alternate;
}
@keyframes lure-pulse {
    from { opacity: 0.45; transform: scale(0.9); filter: blur(0.4px); }
    to   { opacity: 1.0; transform: scale(1.08); filter: blur(0px); }
}
.abyss-text {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: clamp(14px, 1.3vw, 18px);
    color: var(--foam);
    opacity: 0.5;
    letter-spacing: 0.04em;
    text-align: center;
}
.return-bubble {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 14px;
    padding: 12px 0;
    text-decoration: none;
    cursor: pointer;
    margin-top: 1rem;
}
.bubble-circle {
    display: inline-block;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(232, 244, 248, 0.85), rgba(232, 244, 248, 0.05));
    box-shadow: 0 0 14px rgba(232, 244, 248, 0.3);
    animation: bubble-rise 3.4s ease-in-out infinite;
}
@keyframes bubble-rise {
    0%   { transform: translateY(8px) scale(0.85); opacity: 0.4; }
    60%  { opacity: 0.95; }
    100% { transform: translateY(-26px) scale(1.05); opacity: 0; }
}
.bubble-label {
    font-family: var(--font-mono);
    font-size: clamp(10px, 0.85vw, 13px);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--foam);
    opacity: 0.7;
    transition: opacity 300ms ease;
}
.return-bubble:hover .bubble-label { opacity: 1; }

/* =========================================
   Progress bar (sonar)
   ========================================= */
#progress-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3px;
    background: rgba(232, 244, 248, 0.06);
    z-index: 100;
}
#progress-fill {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0%;
    background: linear-gradient(90deg,
        var(--teal) 0%,
        var(--cyan) 35%,
        var(--violet) 70%,
        var(--gold) 100%);
    transition: width 120ms linear;
    box-shadow: 0 0 8px rgba(45, 212, 191, 0.5);
}
#progress-dot {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--foam);
    box-shadow: 0 0 12px var(--foam);
    transition: left 120ms linear;
    left: 0%;
}
.chamber-indicator {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: rgba(232, 244, 248, 0.4);
    transition: background 200ms ease, box-shadow 200ms ease;
}
.chamber-indicator.active {
    background: var(--biolume);
    box-shadow: 0 0 8px var(--biolume);
}

/* =========================================
   Depth readout
   ========================================= */
#depth-readout {
    position: fixed;
    top: 4vh;
    right: 4vw;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    font-family: var(--font-mono);
    text-transform: uppercase;
    pointer-events: none;
}
.depth-label {
    font-size: 10px;
    letter-spacing: 0.2em;
    color: var(--foam);
    opacity: 0.45;
}
#depth-value {
    font-family: var(--font-display);
    font-weight: 200;
    font-size: clamp(24px, 2.6vw, 38px);
    letter-spacing: 0.05em;
    color: var(--foam);
    opacity: 0.8;
    transition: color 600ms ease;
}
#depth-zone {
    font-size: 11px;
    letter-spacing: 0.18em;
    color: var(--foam);
    opacity: 0.55;
    transition: color 600ms ease;
}

/* =========================================
   Mobile fallback
   ========================================= */
@media (max-width: 767px) {
    html, body { overflow: auto; height: auto; }
    #scroll-container {
        flex-direction: column;
        width: 100vw;
        height: auto;
        overflow-x: hidden;
        overflow-y: auto;
        scroll-snap-type: y mandatory;
    }
    .chamber {
        flex: 0 0 auto;
        width: 100vw;
        height: 100vh;
        scroll-snap-align: start;
    }
    .wave-stack {
        top: 0;
        height: 18vh;
    }
    #progress-bar {
        left: auto;
        right: 0;
        top: 0;
        bottom: 0;
        width: 3px;
        height: 100vh;
    }
    #progress-fill {
        width: 100%;
        height: 0%;
        top: 0;
        left: 0;
        background: linear-gradient(180deg,
            var(--teal) 0%, var(--cyan) 35%,
            var(--violet) 70%, var(--gold) 100%);
        transition: height 120ms linear;
    }
    #progress-dot {
        left: 50%;
        top: 0;
        transition: top 120ms linear;
    }
    .chamber-indicator {
        left: 50%;
        top: var(--vpos, 0%);
        transform: translate(-50%, -50%);
    }
    .float-card.card-b { margin-left: 0; }
    .float-card.card-c { margin-left: 0; }
    .jellyfish { height: 40vh; opacity: 0.6; }
    #depth-readout { top: 2vh; right: 8vw; }
}

/* =========================================
   Reduced motion
   ========================================= */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    .particle-field .particle { display: none; }
    .wave { display: none; }
    .caustic-layer { animation: none; }
    .scroll-hint { animation: none; }
    .lure-glow { animation: none; opacity: 1; }
    .bubble-circle { animation: none; }
}
