/* ==========================================================================
   CSS Variables & Theme Setup - Muted Palette
   ========================================================================== */
:root {
    --bg-color: #f4f4f6;
    --text-bg: #ffffff;
    --text-main: #333333;
    --text-muted: #666666;
    
    --surface-color: rgba(255, 255, 255, 0.6);
    --surface-border: rgba(0, 0, 0, 0.05);
    --surface-blur: blur(12px);

    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
}

html {
    /* Removed scroll-behavior: smooth to prevent conflicts with custom JS scroll engine */
}

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

body {
    background-color: var(--bg-color);
    font-family: var(--font-body);
    color: var(--text-main);
    position: relative;
    user-select: none; /* Prevent text selection while dragging */
    transition: background-color 0.7s cubic-bezier(0.16, 1, 0.3, 1);
    overflow-x: hidden;
}

.ui-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    will-change: transform;
    pointer-events: none; /* Let clicks pass to canvas */
    z-index: 2; /* Render ON TOP of canvas */
}

/* Enable interactions on specific UI elements */
header, .overview-box, .nav-btn, .list-container, .contact-content {
    pointer-events: auto;
}

/* ==========================================================================
   Background Typography (Now scrolls)
   ========================================================================== */
.bg-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 0;
    pointer-events: none;
}

.splash-bg {
    height: 100vh;
    width: 100%;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.background-text {
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.background-text .line {
    font-family: var(--font-heading);
    font-size: clamp(8rem, 15vw, 18rem);
    font-weight: 800;
    line-height: 0.85;
    color: var(--text-bg);
    letter-spacing: -0.04em;
    text-transform: uppercase;
    text-shadow: 0 10px 30px rgba(0,0,0,0.03); 
}

/* ==========================================================================
   WebGL Canvas
   ========================================================================== */
#webgl-canvas {
    position: fixed; /* Fixed behind content */
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1; /* In front of background text, behind UI */
    outline: none;
}

/* ==========================================================================
   Foreground UI Layer
   ========================================================================== */
/* UI layer fixed positioning moved to Base Styles */

header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2.5rem;
    z-index: 10;
    transition: all 0.5s ease;
}

header.scrolled {
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: var(--surface-blur);
}

.header-left {
    display: flex;
    align-items: center;
    position: relative;
    z-index: 2;
}

.logo {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 800;
    text-decoration: none;
    color: var(--text-main);
    cursor: pointer;
}

#center-title {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-main);
    opacity: 0;
    pointer-events: none;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 2px;
}

#center-title::before {
    content: '/';
    margin-right: 0.8rem;
    color: var(--text-muted);
}

.navigation {
    display: flex;
    gap: 1rem;
    align-items: center;
    position: static;
    pointer-events: none;
}

.nav-btn {
    pointer-events: auto;
    background: var(--surface-color);
    backdrop-filter: var(--surface-blur);
    border: 1px solid var(--surface-border);
    padding: 0.8rem 2rem;
    border-radius: 50px;
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 4px 15px rgba(0,0,0,0.02);
    text-decoration: none;
    overflow: hidden;
    white-space: nowrap;
}

.nav-btn:hover {
    transform: translateY(-2px);
    color: var(--text-main);
    box-shadow: 0 6px 20px rgba(0,0,0,0.05);
}

.nav-btn.active {
    background: var(--surface-color);
    color: var(--text-main);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

/* ==========================================================================
   Project Modal
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
}

.modal-overlay.active {
    pointer-events: auto;
}

.modal-content {
    position: absolute;
    perspective: 1500px; /* 3D depth */
    opacity: 0; /* Hidden on page load */
    z-index: 101;
    container-type: inline-size;
}

.modal-card-flipper {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-front, .modal-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 16px;
    box-shadow: 0 30px 60px rgba(0,0,0,0.1);
    overflow: hidden;
    transition: border-radius 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-back {
    transform: rotateY(180deg);
}

.modal-compact-view {
    width: 100%;
    height: 100%;
    padding: 6cqi;
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-sizing: border-box;
    text-align: center;
}

.modal-compact-view .text {
    font-size: 5cqi;
    font-weight: 600;
    font-family: var(--font-heading);
    color: var(--text-main);
}

.modal-compact-view .desc {
    color: var(--text-muted);
    margin-top: 2cqi;
    font-size: 3cqi;
}

.modal-inner {
    padding: 6cqi;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    box-sizing: border-box;
    position: relative;
}

/* The flip is now managed dynamically via JS to allow continuous forward rotation! */
.modal-overlay.active .modal-front,
.modal-overlay.active .modal-back {
    border-radius: 24px;
}

.modal-close-btn {
    position: absolute;
    top: 3cqi;
    right: 4cqi;
    background: transparent;
    border: none;
    font-size: 6cqi;
    color: var(--text-main);
    cursor: pointer;
    line-height: 1;
    transition: transform 0.3s ease;
}

.modal-close-btn:hover {
    transform: scale(1.1) rotate(90deg);
}

#modal-title {
    font-family: var(--font-heading);
    font-size: 5cqi;
    margin-bottom: 2cqi;
    color: var(--text-main);
}

.modal-description {
    font-size: 2.5cqi;
    color: var(--text-muted);
    margin-bottom: 4cqi;
    line-height: 1.6;
}

.modal-gallery {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.gallery-placeholder {
    width: 100%;
    height: 300px;
    background: rgba(0,0,0,0.05);
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ==========================================================================
   Footer
   ========================================================================== */
.section {
    min-height: 100vh;
    padding: 6rem 2rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.splash-ui {
    height: 100vh;
    width: 100%;
    position: relative;
    padding: 0;
}

.overview-box {
    position: absolute;
    bottom: 2rem;
    left: 2rem;
    max-width: 320px;
    background: var(--surface-color);
    backdrop-filter: var(--surface-blur);
    padding: 1.5rem;
    border-radius: 16px;
    border: 1px solid var(--surface-border);
    box-shadow: 0 10px 30px rgba(0,0,0,0.02);
}

.overview-box h1 {
    font-family: var(--font-heading);
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.overview-box p {
    color: var(--text-muted);
    font-size: 1rem;
}

.section-content {
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    padding-top: 10rem; /* Space for the morphed title at the top */
}

.section-content.right-aligned {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    text-align: right;
}

.list-container {
    display: flex;
    flex-direction: column;
    gap: 4rem; /* large gap so spheres have space */
}

.list-item {
    background: var(--surface-color);
    backdrop-filter: var(--surface-blur);
    padding: 1.5rem 2.5rem;
    border-radius: 16px;
    border: 1px solid var(--surface-border);
    box-shadow: 0 10px 30px rgba(0,0,0,0.02);
    max-width: 500px;
    position: relative;
    /* Center text since spheres are behind */
    text-align: center;
}

.list-item .text {
    font-size: 1.5rem;
    font-weight: 600;
    font-family: var(--font-heading);
}

.list-item .desc {
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.footer {
    text-align: center;
    padding: 4rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .background-text .line {
        font-size: 5rem;
    }
    
    .navigation {
        width: 90%;
        gap: 0.5rem;
    }
    
    .nav-btn {
        padding: 0.8rem 1rem;
        font-size: 0.9rem;
    }
    
    .overview-box {
        bottom: 6rem; /* Make room for navigation */
        left: 1rem;
        right: 1rem;
        max-width: none;
    }
}
