/* ============================================
   aiice.quest - The Glacier Quest
   ============================================ */

/* --- CSS Variables / Palette --- */
:root {
    --abyssal-blue: #050d1a;
    --frozen-midnight: #0c1b33;
    --ice-cavern: #162a4a;
    --glacial-cyan: #7ef5ff;
    --dream-lilac: #c4a1ff;
    --dormant-amber: #f5c842;
    --frost-white: #e8f0f8;
    --ice-mist: #b8cfe0;
    --fracture-rose: #ff6b8a;
    --pale-azure: #c2dff0;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--abyssal-blue);
    color: var(--frost-white);
    font-family: 'Nunito', sans-serif;
    font-weight: 300;
    font-size: 18px;
    line-height: 1.8;
    overflow-x: hidden;
    position: relative;
}

/* --- Progress Indicator --- */
.progress-indicator {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60vh;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.progress-line {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 0%;
    background: linear-gradient(to bottom, var(--glacial-cyan), var(--dream-lilac));
    transition: height 0.3s ease;
    border-radius: 1px;
    box-shadow: 0 0 8px rgba(126, 245, 255, 0.4);
}

.progress-diamond {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--dormant-amber);
    transform: rotate(45deg);
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
    z-index: 2;
}

.progress-diamond:hover,
.progress-diamond.active {
    opacity: 1;
    box-shadow: 0 0 10px rgba(245, 200, 66, 0.6);
    transform: rotate(45deg) scale(1.3);
}

/* --- Quest Line SVG --- */
.quest-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

/* --- Sections Base --- */
.section {
    position: relative;
    overflow: hidden;
}

/* --- Section 1: The Crevasse Mouth (Hero) --- */
.section-hero {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, #0c1b33 0%, #050d1a 70%, #030810 100%);
}

/* Breath Fog Effect */
.breath-fog {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 2;
}

.fog-circle {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255,255,255,0.04) 0%, transparent 70%);
    animation: fogPulse var(--fog-duration, 8s) ease-in-out infinite;
    opacity: 0;
}

.fog-1 {
    width: 350px;
    height: 350px;
    top: 20%;
    left: 15%;
    --fog-duration: 7s;
    animation-delay: 0.3s;
}

.fog-2 {
    width: 280px;
    height: 280px;
    top: 55%;
    right: 20%;
    --fog-duration: 9s;
    animation-delay: 2s;
}

.fog-3 {
    width: 400px;
    height: 400px;
    top: 30%;
    left: 50%;
    transform: translateX(-50%);
    --fog-duration: 10s;
    animation-delay: 4s;
}

.fog-4 {
    width: 300px;
    height: 300px;
    top: 30%;
    left: 25%;
    --fog-duration: 8s;
    animation-delay: 1s;
}

.fog-5 {
    width: 350px;
    height: 350px;
    top: 40%;
    right: 15%;
    --fog-duration: 10s;
    animation-delay: 3s;
}

@keyframes fogPulse {
    0%, 100% { opacity: 0; }
    50% { opacity: 1; }
}

/* Frost Veins */
.frost-veins {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 3;
}

.frost-vein {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 3s ease-out;
}

.frost-veins-hero .frost-vein {
    animation: drawFrostVein 3s ease-out forwards;
    animation-delay: 1s;
}

.section.visible .frost-vein {
    stroke-dashoffset: 0;
}

@keyframes drawFrostVein {
    to {
        stroke-dashoffset: 0;
    }
}

/* Snowflake Mandalas */
.snowflake-mandala {
    position: absolute;
    pointer-events: none;
    z-index: 2;
}

.mandala-hero {
    width: 400px;
    height: 400px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    animation: mandalaFadeIn 2.5s ease-out 0.8s forwards;
}

.mandala-section {
    width: 250px;
    height: 250px;
    top: 10%;
    right: 5%;
    opacity: 0.12;
}

.mandala-large {
    width: 80vw;
    height: 80vw;
    max-width: 900px;
    max-height: 900px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0.05;
}

.mandala-center {
    width: 300px;
    height: 300px;
    z-index: 3;
}

.mandala-rotate {
    animation: rotateMandala 30s linear infinite;
    transform-origin: center;
}

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

@keyframes mandalaFadeIn {
    to { opacity: 1; }
}

.mandala-draw line,
.mandala-draw circle {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    animation: drawMandalaPath 2.5s ease-out 0.8s forwards;
}

@keyframes drawMandalaPath {
    to { stroke-dashoffset: 0; }
}

/* Hero Content */
.hero-content {
    position: relative;
    z-index: 10;
    text-align: center;
}

.hero-title {
    font-family: 'Cinzel Decorative', serif;
    font-weight: 700;
    font-size: clamp(3rem, 10vw, 8rem);
    letter-spacing: 0.3em;
    color: var(--frost-white);
    text-shadow: 0 0 30px rgba(126, 245, 255, 0.5), 0 0 60px rgba(126, 245, 255, 0.2);
    opacity: 0;
    transform: scale(0.95);
    animation: heroTitleIn 1.2s ease-out 1.5s forwards;
}

@keyframes heroTitleIn {
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.hero-subtitle {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--glacial-cyan);
    opacity: 0;
    animation: fadeIn 1s ease-out 2.8s forwards;
    margin-top: 1.5rem;
}

@keyframes fadeIn {
    to { opacity: 0.7; }
}

/* Floating Ice Shards */
.ice-shard {
    position: absolute;
    background: linear-gradient(135deg, var(--ice-cavern), var(--frozen-midnight));
    border: 1px solid rgba(126, 245, 255, 0.1);
    pointer-events: none;
    z-index: 1;
    animation: floatShard var(--float-duration, 20s) ease-in-out infinite alternate;
}

.shard-1 {
    width: 30px;
    height: 45px;
    clip-path: polygon(50% 0%, 100% 40%, 80% 100%, 20% 100%, 0% 40%);
    top: 15%;
    left: 8%;
    opacity: 0.4;
    --float-duration: 18s;
}

.shard-2 {
    width: 20px;
    height: 35px;
    clip-path: polygon(30% 0%, 100% 30%, 70% 100%, 0% 70%);
    top: 65%;
    right: 12%;
    opacity: 0.3;
    --float-duration: 22s;
    animation-delay: -5s;
}

.shard-3 {
    width: 40px;
    height: 25px;
    clip-path: polygon(20% 0%, 80% 0%, 100% 50%, 80% 100%, 20% 100%, 0% 50%);
    top: 40%;
    left: 85%;
    opacity: 0.25;
    --float-duration: 25s;
    animation-delay: -10s;
}

.shard-4 {
    width: 15px;
    height: 25px;
    clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
    top: 80%;
    left: 30%;
    opacity: 0.35;
    --float-duration: 16s;
    animation-delay: -3s;
}

.shard-5 {
    width: 25px;
    height: 40px;
    clip-path: polygon(40% 0%, 100% 20%, 90% 80%, 10% 100%, 0% 40%);
    top: 25%;
    right: 25%;
    opacity: 0.2;
    --float-duration: 23s;
    animation-delay: -8s;
}

.shard-6 { width: 22px; height: 36px; clip-path: polygon(50% 0%, 100% 40%, 80% 100%, 20% 100%, 0% 40%); top: 20%; left: 5%; opacity: 0.3; --float-duration: 19s; }
.shard-7 { width: 28px; height: 18px; clip-path: polygon(20% 0%, 80% 0%, 100% 50%, 80% 100%, 20% 100%, 0% 50%); top: 70%; right: 8%; opacity: 0.25; --float-duration: 21s; animation-delay: -4s; }
.shard-8 { width: 18px; height: 30px; clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%); top: 15%; right: 15%; opacity: 0.3; --float-duration: 17s; }
.shard-9 { width: 32px; height: 20px; clip-path: polygon(30% 0%, 100% 30%, 70% 100%, 0% 70%); top: 50%; left: 3%; opacity: 0.2; --float-duration: 24s; animation-delay: -7s; }
.shard-10 { width: 14px; height: 24px; clip-path: polygon(50% 0%, 100% 40%, 80% 100%, 20% 100%, 0% 40%); top: 85%; right: 20%; opacity: 0.35; --float-duration: 15s; animation-delay: -2s; }
.shard-11 { width: 20px; height: 32px; clip-path: polygon(40% 0%, 100% 20%, 90% 80%, 10% 100%, 0% 40%); top: 10%; left: 10%; opacity: 0.3; --float-duration: 20s; }
.shard-12 { width: 16px; height: 28px; clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%); top: 30%; right: 5%; opacity: 0.25; --float-duration: 22s; animation-delay: -6s; }
.shard-13 { width: 24px; height: 16px; clip-path: polygon(20% 0%, 80% 0%, 100% 50%, 80% 100%, 20% 100%, 0% 50%); top: 60%; left: 15%; opacity: 0.2; --float-duration: 18s; animation-delay: -3s; }
.shard-14 { width: 12px; height: 20px; clip-path: polygon(50% 0%, 100% 40%, 80% 100%, 20% 100%, 0% 40%); top: 80%; right: 25%; opacity: 0.35; --float-duration: 16s; animation-delay: -9s; }
.shard-15 { width: 26px; height: 38px; clip-path: polygon(30% 0%, 100% 30%, 70% 100%, 0% 70%); top: 45%; left: 80%; opacity: 0.15; --float-duration: 25s; animation-delay: -12s; }
.shard-16 { width: 22px; height: 34px; clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%); top: 20%; left: 8%; opacity: 0.3; --float-duration: 19s; }
.shard-17 { width: 18px; height: 26px; clip-path: polygon(40% 0%, 100% 20%, 90% 80%, 10% 100%, 0% 40%); top: 60%; right: 10%; opacity: 0.25; --float-duration: 21s; animation-delay: -5s; }

@keyframes floatShard {
    from { transform: translateY(0); }
    to { transform: translateY(-20px); }
}

/* --- Section 2: Chamber of Reflections --- */
.section-descent-1 {
    min-height: 80vh;
    padding: 120px 0;
    background: var(--frozen-midnight);
    clip-path: polygon(0 3%, 100% 0, 100% 97%, 0 100%);
    margin-top: -30px;
}

.section-content {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 40px;
    position: relative;
    z-index: 10;
}

.section-header {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-size: clamp(1.6rem, 4vw, 3rem);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--pale-azure);
    margin-bottom: 3rem;
    text-align: center;
}

/* Glass Panels */
.glass-panel {
    background: rgba(22, 42, 74, 0.4);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(126, 245, 255, 0.08);
    padding: 2rem 2.5rem;
    margin-bottom: 1.5rem;
    border-radius: 4px;
    position: relative;
}

.glass-panel h3 {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 400;
    font-size: 1.4rem;
    color: var(--frost-white);
    margin-bottom: 0.8rem;
    letter-spacing: 0.05em;
}

.glass-panel p {
    color: var(--ice-mist);
    opacity: 0.85;
    font-size: 17px;
    line-height: 1.8;
}

/* Panel Slide Animation */
.panel-slide {
    opacity: 0;
    transform: translateX(60px);
    transition: opacity 0.6s cubic-bezier(0.34, 1.56, 0.64, 1),
                transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.panel-slide.visible {
    opacity: 1;
    transform: translateX(0);
}

/* Panel Cascade */
.panel-cascade {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.panel-cascade .glass-panel {
    margin-left: calc(var(--index, 0) * 40px);
}

.panel-cascade .glass-panel:nth-child(1) { --index: 0; }
.panel-cascade .glass-panel:nth-child(2) { --index: 1; }
.panel-cascade .glass-panel:nth-child(3) { --index: 2; }

/* --- Section 3: The Frozen Library --- */
.section-descent-2 {
    min-height: 80vh;
    padding: 120px 0;
    background: linear-gradient(180deg, var(--abyssal-blue), var(--frozen-midnight));
    clip-path: polygon(0 0, 100% 5%, 100% 100%, 0 95%);
    margin-top: -60px;
}

.library-content {
    max-width: 700px;
}

.library-shelf {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.library-panel {
    padding: 2.5rem 2rem;
    border-left: 2px solid rgba(126, 245, 255, 0.12);
}

.library-panel h3 {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: clamp(1.2rem, 3vw, 2rem);
    color: var(--pale-azure);
    margin-bottom: 1rem;
    font-style: italic;
}

.library-panel p {
    font-size: 17px;
    line-height: 1.9;
}

/* --- Section 4: The Algorithm Garden --- */
.section-descent-3 {
    min-height: 80vh;
    padding: 120px 0;
    background: var(--abyssal-blue);
    clip-path: polygon(0 7%, 100% 0, 100% 93%, 0 100%);
    margin-top: -60px;
}

.garden-content {
    max-width: 1000px;
}

.garden-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
}

.garden-panel.pentagon {
    clip-path: polygon(50% 0%, 100% 38%, 82% 100%, 18% 100%, 0% 38%);
    padding: 3.5rem 2.5rem 2.5rem;
    text-align: center;
}

.garden-panel.hexagon {
    clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
    padding: 2.5rem 3rem;
    text-align: center;
}

.garden-panel h3 {
    font-size: 1.2rem;
}

.garden-panel p {
    font-size: 15px;
    line-height: 1.7;
}

/* --- Section 5: The Dream Chamber --- */
.section-dream {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at center, var(--ice-cavern) 0%, var(--abyssal-blue) 70%);
    clip-path: circle(100% at 50% 50%);
}

.dream-viewport {
    position: relative;
    width: 90vw;
    height: 90vw;
    max-width: 700px;
    max-height: 700px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Rotating Text Ring */
.rotating-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    animation: rotateRing 60s linear infinite;
}

.ring-text-svg {
    width: 100%;
    height: 100%;
}

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

/* Dream Content Panels */
.dream-panels {
    position: absolute;
    inset: 15%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1rem;
    z-index: 5;
}

.dream-panel {
    background: rgba(22, 42, 74, 0.5);
    border-radius: 8px;
    padding: 1.5rem 2rem;
    text-align: center;
}

.dream-panel p {
    font-size: 15px;
    line-height: 1.7;
}

/* --- Section 6: The Ascent --- */
.section-ascent {
    min-height: 60vh;
    padding: 100px 0 120px;
    background: linear-gradient(180deg, var(--abyssal-blue) 0%, var(--frozen-midnight) 50%, var(--abyssal-blue) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.breath-fog-ascent {
    z-index: 2;
}

.ascent-content {
    text-align: center;
    max-width: 700px;
    position: relative;
    z-index: 10;
}

.ascent-title {
    font-family: 'Cinzel Decorative', serif;
    font-weight: 700;
    font-size: clamp(2rem, 5vw, 4rem);
    color: var(--frost-white);
    text-shadow: 0 0 20px rgba(245, 200, 66, 0.3);
    margin-bottom: 2rem;
    letter-spacing: 0.1em;
}

.ascent-text {
    color: var(--ice-mist);
    opacity: 0.85;
    font-size: 18px;
    line-height: 1.9;
    margin-bottom: 3rem;
}

.quest-terminus {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.terminus-diamond {
    width: 40px;
    height: 40px;
    animation: pulseDiamond 2s ease-in-out infinite;
}

@keyframes pulseDiamond {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

.terminus-label {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--dormant-amber);
    opacity: 0.8;
}

/* Ascent bottom fog gradient */
.ascent-fog-bottom {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 150px;
    background: linear-gradient(to bottom, transparent, rgba(232, 240, 248, 0.05));
    pointer-events: none;
    z-index: 5;
}

/* --- Mobile Adaptations --- */
@media (max-width: 768px) {
    .progress-indicator {
        display: none;
    }

    .section-descent-1 {
        clip-path: polygon(0 2%, 100% 0, 100% 98%, 0 100%);
    }

    .section-descent-2 {
        clip-path: polygon(0 0, 100% 2%, 100% 100%, 0 98%);
    }

    .section-descent-3 {
        clip-path: polygon(0 3%, 100% 0, 100% 97%, 0 100%);
    }

    .garden-grid {
        grid-template-columns: 1fr;
    }

    .garden-panel.pentagon,
    .garden-panel.hexagon {
        clip-path: none;
        padding: 2rem;
        border-radius: 4px;
    }

    .dream-viewport {
        width: 95vw;
        height: auto;
        min-height: 500px;
    }

    .rotating-ring {
        display: none;
    }

    .dream-panels {
        position: relative;
        inset: unset;
    }

    .section-content {
        padding: 0 20px;
    }

    .panel-cascade .glass-panel {
        margin-left: 0;
    }

    .ice-shard:nth-child(even) {
        display: none;
    }
}
