/* ===== RESET & BASE ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --frozen-midnight: #0b0e1a;
    --ice-crystal: #b8d4e3;
    --sprite-magenta: #d94f8a;
    --pixel-cyan: #5fe4d6;
    --glacial-white: #e8eef3;
    --amber-pulse: #f0a848;
    --phantom-lavender: #a89cc8;
    --abyssal-blue: #1a2740;
    --frost-bg: rgba(184, 212, 227, 0.12);
    --frost-border: rgba(184, 212, 227, 0.2);
    --frost-border-inner: rgba(184, 212, 227, 0.08);
    --frost-glow: rgba(184, 212, 227, 0.08);
    --lighter-lavender: #c4b8e0;
    --panel-count: 7;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--frozen-midnight);
    color: var(--ice-crystal);
    font-family: 'Share Tech Mono', monospace;
    font-size: clamp(0.9rem, 1.5vw, 1.1rem);
    letter-spacing: 0.06em;
    line-height: 1.6;
}

/* ===== HORIZONTAL CONTAINER ===== */
#horizontal-container {
    display: grid;
    grid-template-columns: repeat(7, 100vw);
    grid-auto-flow: column;
    width: 700vw;
    height: 100vh;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: var(--sprite-magenta) var(--ice-crystal);
}

#horizontal-container::-webkit-scrollbar {
    height: 4px;
}

#horizontal-container::-webkit-scrollbar-track {
    background: var(--ice-crystal);
}

#horizontal-container::-webkit-scrollbar-thumb {
    background: var(--sprite-magenta);
    border-radius: 0;
}

/* ===== PANELS ===== */
.panel {
    width: 100vw;
    height: 100vh;
    scroll-snap-align: start;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

/* ===== FROST PANE ===== */
.frost-pane {
    background: var(--frost-bg);
    backdrop-filter: blur(16px) saturate(1.2);
    -webkit-backdrop-filter: blur(16px) saturate(1.2);
    border: 1px solid var(--frost-border);
    outline: 1px solid var(--frost-border-inner);
    outline-offset: 2px;
    box-shadow:
        inset 0 0 30px var(--frost-glow),
        0 0 60px rgba(95, 228, 214, 0.06),
        0 0 120px rgba(184, 212, 227, 0.04);
    border-radius: 2px;
    padding: 2rem;
    position: relative;
}

/* ===== PANEL HEADINGS ===== */
.panel-heading {
    font-family: 'Silkscreen', cursive;
    font-weight: 700;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    letter-spacing: 0.12em;
    text-transform: lowercase;
    color: var(--ice-crystal);
    margin-bottom: 1.5rem;
    opacity: 0;
    position: relative;
}

.panel-heading.revealed {
    opacity: 1;
}

.panel-heading::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    height: 2px;
    background: var(--pixel-cyan);
    width: 0;
    transition: none;
}

.panel-heading.revealed::after {
    animation: underlineDraw 600ms ease-out forwards;
}

@keyframes underlineDraw {
    from { width: 0; }
    to { width: 100%; }
}

/* ===== WAVE DIVIDER ===== */
.wave-divider-small {
    width: 100%;
    max-width: 200px;
    height: 8px;
    margin: 0.75rem auto;
    opacity: 0.6;
}

.wave-divider-small svg {
    width: 100%;
    height: 100%;
}

/* ===== PANEL 1: TITLE ===== */
.title-pane {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 80vw;
    max-width: 700px;
    height: 70vh;
    max-height: 600px;
}

.ghost-sprite {
    width: 128px;
    height: 128px;
    display: grid;
    grid-template-columns: repeat(16, 1fr);
    grid-template-rows: repeat(16, 1fr);
    image-rendering: pixelated;
    margin-bottom: 1rem;
    filter: drop-shadow(0 0 40px rgba(168, 156, 200, 0.5));
}

.ghost-sprite.bob {
    animation: bob 2.5s ease-in-out infinite;
}

@keyframes bob {
    0%, 100% { transform: translateY(-6px); }
    50% { transform: translateY(6px); }
}

.ghost-sprite span {
    display: block;
    opacity: 0;
    transition: opacity 25ms ease;
}

.ghost-sprite span.visible {
    opacity: 1;
}

.title-text {
    position: relative;
    text-align: center;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.title-underline {
    display: block;
    height: 2px;
    background: var(--pixel-cyan);
    width: 0;
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
}

.title-underline.drawing {
    animation: titleUnderlineDraw 600ms ease-out forwards;
}

@keyframes titleUnderlineDraw {
    from { width: 0; }
    to { width: 100%; }
}

.title-letters {
    font-family: 'Silkscreen', cursive;
    font-weight: 700;
    font-size: clamp(2.5rem, 8vw, 6rem);
    letter-spacing: 0.12em;
    text-transform: lowercase;
    color: var(--ice-crystal);
    display: inline-flex;
}

.title-letters .letter {
    display: inline-block;
    opacity: 0;
    transform: scale(0.5);
}

.title-letters .letter.pop {
    opacity: 1;
    transform: scale(1);
    transition: opacity 120ms cubic-bezier(0.34, 1.56, 0.64, 1),
                transform 120ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ===== GHOST END ===== */
.ghost-end {
    transform: scaleX(-1);
}

.ghost-end.bob {
    animation: bobFlipped 2.5s ease-in-out infinite;
}

@keyframes bobFlipped {
    0%, 100% { transform: scaleX(-1) translateY(-6px); }
    50% { transform: scaleX(-1) translateY(6px); }
}

/* ===== PANEL 2: WAVE ===== */
.wave-pane {
    width: 90vw;
    height: 85vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

#waveform-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.wave-pane .panel-heading {
    position: relative;
    z-index: 2;
}

/* ===== PANEL 3: GALLERY ===== */
.gallery-pane {
    width: 90vw;
    max-width: 900px;
    height: 85vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 1.5rem;
    flex: 1;
    width: 100%;
    padding: 1rem 0;
}

.gallery-card {
    background: var(--frost-bg);
    backdrop-filter: blur(12px) saturate(1.1);
    -webkit-backdrop-filter: blur(12px) saturate(1.1);
    border: 1px solid var(--frost-border);
    outline: 1px solid var(--frost-border-inner);
    outline-offset: 2px;
    box-shadow: inset 0 0 20px var(--frost-glow);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    transform: perspective(800px) rotateY(2deg);
    transition: transform 400ms ease;
    overflow: hidden;
}

.gallery-card:hover {
    transform: perspective(800px) rotateY(-1deg);
}

.card-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.card-label {
    font-family: 'VT323', monospace;
    font-size: clamp(0.8rem, 1.2vw, 1rem);
    color: var(--phantom-lavender);
    text-transform: lowercase;
}

.card-underline {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    background: var(--sprite-magenta);
    width: 0;
    transition: width 300ms ease-out;
}

.gallery-card:hover .card-underline {
    width: 100%;
}

/* Pixel Cube */
.pixel-cube-scene {
    width: 80px;
    height: 80px;
    perspective: 300px;
}

.pixel-cube {
    width: 80px;
    height: 80px;
    position: relative;
    transform-style: preserve-3d;
    animation: spinCube 12s linear infinite;
}

@keyframes spinCube {
    from { transform: rotateY(0deg) rotateX(15deg); }
    to { transform: rotateY(360deg) rotateX(15deg); }
}

.cube-face {
    position: absolute;
    width: 80px;
    height: 80px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    image-rendering: pixelated;
}

.cube-front  { transform: translateZ(40px); }
.cube-back   { transform: rotateY(180deg) translateZ(40px); }
.cube-right  { transform: rotateY(90deg) translateZ(40px); }
.cube-left   { transform: rotateY(-90deg) translateZ(40px); }
.cube-top    { transform: rotateX(90deg) translateZ(40px); }
.cube-bottom { transform: rotateX(-90deg) translateZ(40px); }

.cube-face span {
    display: block;
}

/* Pixel Objects */
.pixel-object {
    width: 64px;
    height: 64px;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    image-rendering: pixelated;
}

.pixel-object span {
    display: block;
}

/* ===== PANEL 4: STORY ===== */
.story-pane {
    width: 90vw;
    height: 85vh;
    display: flex;
    flex-direction: row;
    gap: 2rem;
}

.story-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: rgba(232, 238, 243, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    padding: 2rem;
    border-radius: 2px;
    color: var(--frozen-midnight);
}

.story-text .panel-heading {
    color: var(--frozen-midnight);
}

.story-text .panel-heading::after {
    background: var(--sprite-magenta);
}

.story-paragraph {
    margin: 0.75rem 0;
    line-height: 1.8;
}

.story-landscape {
    flex: 2;
    position: relative;
    overflow: hidden;
    border-radius: 2px;
    background: linear-gradient(180deg, var(--frozen-midnight) 0%, var(--abyssal-blue) 100%);
}

.landscape-layer {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    image-rendering: pixelated;
}

.mountains {
    height: 70%;
    z-index: 1;
    opacity: 0.8;
}

.trees {
    height: 45%;
    z-index: 2;
}

.ground {
    height: 15%;
    background: var(--abyssal-blue);
    z-index: 3;
}

.landscape-walker {
    position: absolute;
    bottom: 15%;
    left: 20%;
    width: 16px;
    height: 24px;
    z-index: 4;
    image-rendering: pixelated;
}

/* ===== PANEL 5: SPECTRUM ===== */
.spectrum-pane {
    width: 90vw;
    max-width: 800px;
    height: 85vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    background:
        var(--frost-bg),
        repeating-conic-gradient(var(--frozen-midnight) 0% 25%, var(--abyssal-blue) 0% 50%) 0 0 / 4px 4px;
}

.spectrum-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 1.25rem;
    flex: 1;
    width: 100%;
    padding: 1rem 0;
}

.spectrum-tile {
    background: var(--frost-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--frost-border);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
    transition: transform 300ms ease, box-shadow 300ms ease;
}

.spectrum-tile:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(95, 228, 214, 0.1);
}

.swatch {
    width: 48px;
    height: 48px;
    border: 2px solid rgba(184, 212, 227, 0.3);
    image-rendering: pixelated;
}

.swatch-label {
    font-family: 'VT323', monospace;
    font-size: clamp(0.8rem, 1.2vw, 1rem);
    color: var(--pixel-cyan);
    letter-spacing: 0.08em;
}

.swatch-name {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.7rem;
    color: var(--phantom-lavender);
    text-transform: lowercase;
    opacity: 0.8;
}

/* ===== PANEL 6: MOTION ===== */
.motion-pane {
    width: 90vw;
    height: 85vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

#motion-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.motion-pane .panel-heading {
    position: relative;
    z-index: 2;
}

/* ===== PANEL 7: END ===== */
.end-pane {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 80vw;
    max-width: 600px;
    height: 70vh;
    max-height: 500px;
}

.end-title {
    font-family: 'Silkscreen', cursive;
    font-weight: 400;
    font-size: clamp(1.2rem, 3vw, 2rem);
    letter-spacing: 0.12em;
    text-transform: lowercase;
    color: var(--ice-crystal);
    margin: 1rem 0;
}

.scroll-back {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 2rem;
    cursor: pointer;
    transition: opacity 300ms;
}

.scroll-back:hover {
    opacity: 0.8;
}

.scroll-back-arrow {
    font-size: 1.5rem;
    color: var(--amber-pulse);
    filter: drop-shadow(0 0 8px rgba(240, 168, 72, 0.5));
}

.scroll-back-text {
    font-family: 'VT323', monospace;
    font-size: clamp(0.8rem, 1.2vw, 1rem);
    color: var(--phantom-lavender);
    text-transform: lowercase;
}

/* ===== NAVIGATION ARROW ===== */
.nav-arrow {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 100;
    animation: pulseArrow 1.5s ease-in-out infinite;
    cursor: pointer;
}

.nav-arrow.flipped {
    right: auto;
    left: 20px;
}

.nav-arrow-icon {
    font-family: 'Silkscreen', cursive;
    font-size: 2rem;
    color: var(--pixel-cyan);
    text-shadow: 0 0 12px rgba(95, 228, 214, 0.5);
}

@keyframes pulseArrow {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1.0; }
}

/* ===== PANEL INDICATOR ===== */
.panel-indicator {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    display: flex;
    gap: 8px;
    padding: 6px 12px;
    background: rgba(11, 14, 26, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--frost-border);
    border-radius: 2px;
}

.indicator-dot {
    width: 12px;
    height: 12px;
    background: var(--phantom-lavender);
    opacity: 0.4;
    display: block;
    cursor: pointer;
    transition: opacity 300ms, background-color 300ms;
}

.indicator-dot.active {
    background: var(--pixel-cyan);
    opacity: 1;
}

/* ===== TRANSITION LINE ===== */
.transition-line {
    position: fixed;
    top: 0;
    left: 0;
    width: 0;
    height: 1px;
    background: var(--ice-crystal);
    z-index: 200;
    pointer-events: none;
    opacity: 0;
}

.transition-line.sweep {
    animation: sweepLine 200ms ease-out forwards;
}

@keyframes sweepLine {
    0% { width: 0; opacity: 1; }
    100% { width: 100vw; opacity: 0; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .ghost-sprite {
        width: 96px;
        height: 96px;
    }

    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(3, 1fr);
    }

    .story-pane {
        flex-direction: column;
    }

    .story-text {
        flex: none;
    }

    .story-landscape {
        flex: 1;
    }

    .spectrum-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(4, 1fr);
    }

    .frost-pane {
        backdrop-filter: blur(10px) saturate(1.2);
        -webkit-backdrop-filter: blur(10px) saturate(1.2);
    }

    .title-letters {
        font-size: clamp(2rem, 8vw, 4rem);
    }

    .pixel-cube-scene {
        width: 60px;
        height: 60px;
    }

    .pixel-cube {
        width: 60px;
        height: 60px;
    }

    .cube-face {
        width: 60px;
        height: 60px;
    }

    .cube-front  { transform: translateZ(30px); }
    .cube-back   { transform: rotateY(180deg) translateZ(30px); }
    .cube-right  { transform: rotateY(90deg) translateZ(30px); }
    .cube-left   { transform: rotateY(-90deg) translateZ(30px); }
    .cube-top    { transform: rotateX(90deg) translateZ(30px); }
    .cube-bottom { transform: rotateX(-90deg) translateZ(30px); }

    .pixel-object {
        width: 48px;
        height: 48px;
    }
}
