/* ============================================
   aiice.quest - Vaporwave Desktop Paradise
   ============================================ */

/* CSS Custom Properties for Animation */
@property --wght {
    syntax: '<number>';
    initial-value: 300;
    inherits: false;
}
@property --casl {
    syntax: '<number>';
    initial-value: 0;
    inherits: false;
}
@property --slnt {
    syntax: '<number>';
    initial-value: 0;
    inherits: false;
}
@property --grad-pos {
    syntax: '<percentage>';
    initial-value: 0%;
    inherits: false;
}

/* ---- Color Palette ---- */
:root {
    --twilight-lavender: #c8b6ff;
    --digital-peach: #ffc8dd;
    --vapor-mint: #bde0fe;
    --soft-cream: #fff1e6;
    --haze-pink: #ffafcc;
    --deep-dusk: #2b2d42;
    --faded-iris: #8d99ae;
    --neon-coral: #ff6b6b;
    --ghost-periwinkle: #a2d2ff;
}

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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    font-family: 'DM Sans', sans-serif;
    color: var(--deep-dusk);
    background: var(--twilight-lavender);
    overflow-x: hidden;
    line-height: 1.75;
}

/* ---- Boot Screen ---- */
#boot-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 1;
    transition: opacity 0.6s ease;
}

#boot-screen.fade-out {
    opacity: 0;
    pointer-events: none;
}

#boot-screen.hidden {
    display: none;
}

.boot-text {
    font-family: 'Silkscreen', cursive;
    font-size: 14px;
    color: var(--ghost-periwinkle);
    letter-spacing: 2px;
}

.boot-cursor {
    font-family: 'Silkscreen', cursive;
    font-size: 14px;
    color: var(--ghost-periwinkle);
    animation: blink-cursor 0.8s step-end infinite;
}

@keyframes blink-cursor {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* ---- Desktop Background ---- */
#desktop-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -3;
    background: linear-gradient(
        135deg,
        var(--twilight-lavender),
        var(--digital-peach),
        var(--vapor-mint),
        var(--twilight-lavender)
    );
    background-size: 400% 400%;
    animation: desktop-gradient 30s ease infinite;
}

@keyframes desktop-gradient {
    0% { background-position: 0% 50%; }
    25% { background-position: 100% 0%; }
    50% { background-position: 100% 100%; }
    75% { background-position: 0% 100%; }
    100% { background-position: 0% 50%; }
}

/* ---- Perspective Grid Floor ---- */
#perspective-grid {
    position: fixed;
    bottom: -50%;
    left: -25%;
    width: 150%;
    height: 150%;
    z-index: -2;
    background:
        repeating-linear-gradient(
            90deg,
            var(--ghost-periwinkle) 0px,
            var(--ghost-periwinkle) 1px,
            transparent 1px,
            transparent 60px
        ),
        repeating-linear-gradient(
            0deg,
            var(--ghost-periwinkle) 0px,
            var(--ghost-periwinkle) 1px,
            transparent 1px,
            transparent 60px
        );
    transform: perspective(800px) rotateX(60deg);
    transform-origin: center top;
    opacity: 0.05;
    transition: opacity 0.3s ease;
    animation: grid-pulse 4s ease-in-out infinite;
}

@keyframes grid-pulse {
    0%, 100% { opacity: var(--grid-opacity-base, 0.05); }
    50% { opacity: var(--grid-opacity-peak, 0.08); }
}

/* ---- Flat Grid Overlay ---- */
#flat-grid-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background:
        repeating-linear-gradient(
            90deg,
            rgba(162, 210, 255, 0.08) 0px,
            rgba(162, 210, 255, 0.08) 1px,
            transparent 1px,
            transparent 120px
        ),
        repeating-linear-gradient(
            0deg,
            rgba(162, 210, 255, 0.08) 0px,
            rgba(162, 210, 255, 0.08) 1px,
            transparent 1px,
            transparent 120px
        );
    pointer-events: none;
}

/* ---- Scanline Overlay ---- */
#scanline-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9998;
    pointer-events: none;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.03) 2px,
        rgba(0, 0, 0, 0.03) 4px
    );
}

/* ---- Viewport Sections ---- */
.viewport-section {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 40px;
}

/* ---- Status Bar ---- */
.status-bar {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 14px;
    background: rgba(200, 182, 255, 0.4);
    border: 1px solid rgba(200, 182, 255, 0.5);
    border-radius: 4px;
    backdrop-filter: blur(8px);
    z-index: 10;
}

.status-text,
.status-time {
    font-family: 'Silkscreen', cursive;
    font-size: 12px;
    color: var(--deep-dusk);
}

/* ---- App Icons ---- */
.app-icon-cluster {
    position: absolute;
    top: 70px;
    right: 40px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    z-index: 5;
}

.mini-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.icon-shape {
    width: 40px;
    height: 36px;
    border-radius: 6px;
    border: 1px solid var(--ghost-periwinkle);
}

.icon-folder .icon-shape {
    background: linear-gradient(135deg, var(--vapor-mint), var(--ghost-periwinkle));
    border-top-left-radius: 6px;
    border-top-right-radius: 2px;
    position: relative;
}
.icon-folder .icon-shape::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 0;
    width: 18px;
    height: 6px;
    background: linear-gradient(135deg, var(--vapor-mint), var(--ghost-periwinkle));
    border-radius: 3px 3px 0 0;
}

.icon-file .icon-shape {
    background: linear-gradient(135deg, var(--soft-cream), var(--digital-peach));
}

.icon-label {
    font-family: 'Silkscreen', cursive;
    font-size: 10px;
    color: var(--deep-dusk);
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.6);
}

/* ============================================
   OS Window Component
   ============================================ */
.os-window {
    background: rgba(255, 241, 230, 0.92);
    border: 1px solid rgba(200, 182, 255, 0.5);
    border-radius: 8px;
    box-shadow:
        0 8px 32px rgba(43, 45, 66, 0.12),
        0 0 20px rgba(200, 182, 255, 0.3),
        0 0 60px rgba(200, 182, 255, 0.1);
    overflow: hidden;
    transition: transform 0.6s ease, box-shadow 0.6s ease;
}

.os-window:hover {
    transform: translateY(-2px);
    box-shadow:
        0 12px 40px rgba(43, 45, 66, 0.15),
        0 0 25px rgba(200, 182, 255, 0.35),
        0 0 70px rgba(200, 182, 255, 0.12);
}

/* Window Title Bar */
.window-titlebar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-bottom: 1px solid rgba(200, 182, 255, 0.3);
}

.traffic-lights {
    display: flex;
    gap: 6px;
}

.tl-btn {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: block;
}

.tl-close { background: var(--neon-coral); }
.tl-minimize { background: var(--haze-pink); }
.tl-maximize { background: var(--vapor-mint); }

.window-title {
    font-family: 'Silkscreen', cursive;
    font-size: 12px;
    color: var(--deep-dusk);
    opacity: 0.8;
}

.window-body {
    padding: 20px;
}

/* ---- Hero Window Positioning ---- */
#hero {
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.window-main {
    position: relative;
    z-index: 4;
    width: min(600px, 80vw);
    transform: rotate(-0.5deg);
}

.window-sunset {
    position: absolute;
    z-index: 2;
    width: min(320px, 50vw);
    top: 25%;
    left: 8%;
    transform: rotate(2deg);
}

.window-grid {
    position: absolute;
    z-index: 1;
    width: min(280px, 45vw);
    bottom: 12%;
    right: 8%;
    transform: rotate(-1.5deg);
}

/* Hero Title */
.hero-title {
    font-family: 'Recursive', sans-serif;
    font-size: clamp(2rem, 6vw, 5rem);
    font-variation-settings: 'wght' var(--wght, 300), 'CASL' var(--casl, 0), 'slnt' var(--slnt, 0);
    color: var(--deep-dusk);
    text-shadow: 0 0 10px rgba(255, 107, 107, 0.2);
    text-align: center;
    animation: font-breathe 6s ease-in-out infinite;
    line-height: 1.2;
    margin-bottom: 12px;
}

@keyframes font-breathe {
    0%, 100% {
        --wght: 300;
        --casl: 0;
        --slnt: 0;
    }
    33% {
        --wght: 700;
        --casl: 0.5;
        --slnt: -8;
    }
    66% {
        --wght: 500;
        --casl: 1;
        --slnt: -4;
    }
}

.hero-subtitle {
    font-family: 'DM Sans', sans-serif;
    font-size: clamp(0.95rem, 1.5vw, 1.15rem);
    color: var(--faded-iris);
    text-align: center;
    font-weight: 400;
}

.main-body {
    padding: 40px 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}

/* Sunset Window */
.sunset-body {
    padding: 0;
    height: 160px;
    overflow: hidden;
}

.sunset-gradient {
    width: 100%;
    height: 100%;
    background: linear-gradient(
        180deg,
        #ffafcc 0%,
        #ffc8dd 25%,
        #ff6b6b 50%,
        #c8b6ff 75%,
        #2b2d42 100%
    );
    background-size: 100% 200%;
    animation: sunset-loop 8s ease-in-out infinite alternate;
}

@keyframes sunset-loop {
    0% { background-position: 0% 0%; }
    100% { background-position: 0% 100%; }
}

/* Color Grid */
.color-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
}

.color-cell {
    aspect-ratio: 1;
    border-radius: 3px;
    animation: hue-shift 12s ease-in-out infinite;
}

.color-cell:nth-child(even) { animation-delay: -3s; }
.color-cell:nth-child(3n) { animation-delay: -6s; }
.color-cell:nth-child(4n) { animation-delay: -9s; }

@keyframes hue-shift {
    0%, 100% { filter: hue-rotate(0deg); }
    50% { filter: hue-rotate(30deg); }
}

/* ============================================
   Content Sections & Z-Layout
   ============================================ */
.content-section {
    padding: 80px 40px;
}

.content-window {
    width: min(750px, 88vw);
    max-width: 100%;
}

/* Morph animation for content windows */
.morph-window {
    clip-path: circle(20px at 50% 50%);
    opacity: 0;
    transition: clip-path 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                border-radius 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                opacity 0.3s ease;
}

.morph-window.morphed {
    clip-path: inset(0);
    border-radius: 8px;
    opacity: 1;
}

/* VHS Glitch on section entry */
@keyframes vhs-glitch {
    0% {
        clip-path: inset(0 0 85% 0);
        transform: translateX(0);
    }
    10% {
        clip-path: inset(15% 0 60% 0);
        transform: translateX(-5px);
    }
    20% {
        clip-path: inset(40% 0 30% 0);
        transform: translateX(3px);
    }
    30% {
        clip-path: inset(60% 0 10% 0);
        transform: translateX(-2px);
    }
    40% {
        clip-path: inset(20% 0 50% 0);
        transform: translateX(4px);
    }
    50% {
        clip-path: inset(70% 0 5% 0);
        transform: translateX(-3px);
    }
    60% {
        clip-path: inset(5% 0 80% 0);
        transform: translateX(2px);
    }
    100% {
        clip-path: inset(0);
        transform: translateX(0);
    }
}

.vhs-glitch {
    animation: vhs-glitch 0.3s linear forwards;
}

/* Z-Pattern Layout */
.z-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto 1fr;
    gap: 20px;
    min-height: 300px;
}

.z-top-left {
    grid-column: 1;
    grid-row: 1;
}

.z-top-right {
    grid-column: 2;
    grid-row: 1;
    text-align: right;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
}

.z-bottom-left {
    grid-column: 1;
    grid-row: 2;
}

.z-bottom-right {
    grid-column: 2;
    grid-row: 2;
    display: flex;
    align-items: center;
    justify-content: center;
}

.section-heading {
    font-family: 'Recursive', sans-serif;
    font-size: clamp(1.2rem, 3vw, 2rem);
    color: var(--deep-dusk);
    text-shadow: 0 0 10px rgba(255, 107, 107, 0.2);
    line-height: 1.3;
}

.timestamp {
    font-family: 'Silkscreen', cursive;
    font-size: 12px;
    color: var(--faded-iris);
}

.body-text {
    font-family: 'DM Sans', sans-serif;
    font-size: clamp(0.95rem, 1.5vw, 1.15rem);
    font-weight: 400;
    line-height: 1.75;
    color: var(--deep-dusk);
    margin-bottom: 16px;
}

.body-text:last-child {
    margin-bottom: 0;
}

/* ---- Photo Frames (Vintage Treatment) ---- */
.photo-frame {
    border: 2px solid var(--ghost-periwinkle);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 0 20px rgba(200, 182, 255, 0.3);
}

.vintage-photo {
    filter: saturate(0.6) contrast(0.85) brightness(1.1) sepia(0.25) hue-rotate(-10deg);
    position: relative;
}

.vintage-photo svg {
    display: block;
    width: 100%;
    height: auto;
}

/* Scanline overlay on photos */
.photo-frame::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.03) 2px,
        rgba(0, 0, 0, 0.03) 4px
    );
    pointer-events: none;
}

/* ============================================
   Dissolution Section (400vh+)
   ============================================ */
#dissolution {
    min-height: 200vh;
    flex-direction: column;
    justify-content: flex-start;
    padding-top: 100px;
    position: relative;
}

.floating-element {
    position: relative;
    max-width: 600px;
    margin: 60px auto;
    padding: 30px;
    background: rgba(255, 241, 230, 0.6);
    border: 1px solid transparent;
    border-radius: 8px;
    box-shadow: 0 0 20px rgba(200, 182, 255, 0.2);
    transition: border-color 1s ease, box-shadow 1s ease, opacity 1s ease, background 1s ease;
}

.floating-element.dissolved {
    border-color: transparent;
    box-shadow: none;
    background: rgba(255, 241, 230, 0);
}

.float-1 {
    align-self: flex-start;
    margin-left: 10%;
}

.float-2 {
    align-self: flex-end;
    margin-right: 8%;
}

.float-3 {
    align-self: center;
}

.float-4 {
    align-self: flex-start;
    margin-left: 15%;
}

.floating-text {
    font-family: 'Recursive', sans-serif;
    font-size: clamp(1.2rem, 2.5vw, 1.8rem);
    font-variation-settings: 'wght' 400, 'CASL' 0.5, 'slnt' -5;
    color: var(--deep-dusk);
    text-shadow: 0 0 10px rgba(255, 107, 107, 0.15);
}

.floating-text.body-text {
    font-family: 'DM Sans', sans-serif;
    font-size: clamp(0.95rem, 1.5vw, 1.15rem);
    font-variation-settings: normal;
}

.floating-text.whisper {
    font-size: clamp(1rem, 2vw, 1.4rem);
    color: var(--faded-iris);
    font-variation-settings: 'wght' 300, 'CASL' 1, 'slnt' -10;
}

.floating-photo {
    max-width: 260px;
    margin: 0 auto;
    display: block;
}

/* Final Domain Name */
#final-title {
    position: relative;
    margin-top: 120px;
    margin-bottom: 100px;
    text-align: center;
    z-index: 5;
}

.final-domain {
    font-family: 'Recursive', sans-serif;
    font-size: clamp(2.5rem, 7vw, 6rem);
    font-variation-settings: 'wght' 900, 'CASL' 1, 'slnt' 0;
    color: var(--deep-dusk);
    text-shadow:
        0 0 10px rgba(255, 107, 107, 0.4),
        0 0 30px rgba(255, 107, 107, 0.2),
        0 0 60px rgba(255, 107, 107, 0.1);
    animation: final-font-drift 8s ease-in-out infinite;
}

@keyframes final-font-drift {
    0%, 100% {
        font-variation-settings: 'wght' 900, 'CASL' 1, 'slnt' 0;
        text-shadow:
            0 0 10px rgba(255, 107, 107, 0.4),
            0 0 30px rgba(255, 107, 107, 0.2),
            0 0 60px rgba(255, 107, 107, 0.1);
    }
    33% {
        font-variation-settings: 'wght' 700, 'CASL' 0, 'slnt' -15;
        text-shadow:
            0 0 15px rgba(255, 107, 107, 0.5),
            0 0 40px rgba(255, 107, 107, 0.25),
            0 0 80px rgba(200, 182, 255, 0.15);
    }
    66% {
        font-variation-settings: 'wght' 1000, 'CASL' 0.5, 'slnt' -8;
        text-shadow:
            0 0 12px rgba(255, 107, 107, 0.45),
            0 0 35px rgba(255, 107, 107, 0.22),
            0 0 70px rgba(200, 182, 255, 0.12);
    }
}

/* ============================================
   Hero Window Morph Entry Animations
   ============================================ */
.window-main,
.window-sunset,
.window-grid {
    clip-path: circle(0px at 50% 50%);
    opacity: 0;
}

.window-main.entered {
    animation: window-morph-in 0.8s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.window-sunset.entered {
    animation: window-morph-in 0.8s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.window-grid.entered {
    animation: window-morph-in 0.8s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes window-morph-in {
    0% {
        clip-path: circle(20px at 50% 50%);
        opacity: 0;
    }
    30% {
        opacity: 1;
    }
    100% {
        clip-path: inset(0 round 8px);
        opacity: 1;
    }
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
    .viewport-section {
        padding: 40px 20px;
    }

    .window-sunset {
        width: min(220px, 55vw);
        top: 20%;
        left: 4%;
    }

    .window-grid {
        width: min(200px, 50vw);
        bottom: 8%;
        right: 4%;
    }

    .window-main {
        width: min(500px, 90vw);
    }

    .z-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto auto;
    }

    .z-top-left { grid-column: 1; grid-row: 1; }
    .z-top-right { grid-column: 1; grid-row: 2; text-align: left; justify-content: flex-start; }
    .z-bottom-left { grid-column: 1; grid-row: 3; }
    .z-bottom-right { grid-column: 1; grid-row: 4; }

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

    .status-bar {
        top: 10px;
        left: 10px;
        right: 10px;
    }

    .app-icon-cluster {
        top: 55px;
        right: 15px;
    }

    .floating-element {
        margin-left: 5% !important;
        margin-right: 5% !important;
    }

    .float-1, .float-2, .float-3, .float-4 {
        align-self: stretch;
    }
}

@media (max-width: 480px) {
    .window-sunset,
    .window-grid {
        display: none;
    }

    .app-icon-cluster {
        display: none;
    }

    .main-body {
        padding: 30px 20px;
    }
}
