/* =========================================================================
   CODECAVE - Digital Systems
   Minimalist, Black & White, Fluid Typography Theme
   ========================================================================= */

:root {
    /* Color Palette */
    --clr-background: #ffffff;
    --clr-foreground: #0a0a0a;
    --clr-accent: #000000;
    --clr-muted: #666666;
    --clr-border: rgba(0, 0, 0, 0.1);
    
    /* Typography */
    --font-primary: 'Outfit', sans-serif;
    --font-heading: 'Outfit', sans-serif; /* Reverted to Outfit */
    --font-luxury: 'Cormorant Garamond', serif; /* New Luxury Font */
    --font-calligraphy: 'Playfair Display', serif;
    --font-serif: 'Playfair Display', serif;

    /* Fluid Typography Clamps (Min-vw-Max) */
    --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
    --text-sm: clamp(0.875rem, 0.8rem + 0.38vw, 1rem);
    --text-base: clamp(1rem, 0.9rem + 0.5vw, 1.125rem);
    --text-lg: clamp(1.125rem, 1rem + 0.63vw, 1.25rem);
    --text-xl: clamp(1.25rem, 1.1rem + 0.75vw, 1.5rem);
    --text-2xl: clamp(1.25rem, 1.2rem + 1.5vw, 1.75rem);
    --text-3xl: clamp(1.75rem, 1.5rem + 2.5vw, 2.5rem);
    --text-huge: clamp(2.5rem, 2rem + 6vw, 4.5rem);
    --text-giant: clamp(3.5rem, 2rem + 8vw, 6rem);
    
    /* Spacing */
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-section: clamp(4rem, 10vw, 8rem);
    
    /* Layout */
    --max-width: 1400px;
    --nav-height: 80px;
}

/* Base Reset & Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

html {
    scroll-behavior: auto; /* Handled by GSAP if needed, but smooth scrolling is nice. Keep auto for scroll components to manage it. */
}

body {
    background-color: var(--clr-background);
    color: var(--clr-foreground);
    font-family: var(--font-primary);
    font-size: var(--text-base);
    line-height: 1.6;
    overflow-x: hidden;
    position: relative;
    /* Line Effect: Distinctive Grid */
    background-image: 
        linear-gradient(to right, rgba(0, 0, 0, 0.12) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(0, 0, 0, 0.12) 1px, transparent 1px);
    background-size: 60px 60px;
}

body, html {
    overflow-x: hidden;
    width: 100%;
}

/* 3D Canvas */
#webgl-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1; /* Behind everything */
    pointer-events: none; /* Let clicks pass through */
    opacity: 0.8; 
}

/* Typography Classes */
.calligraphy {
    font-family: var(--font-serif);
    font-style: italic;
    font-weight: 400;
    font-size: 1.1em;
    color: var(--clr-foreground);
    letter-spacing: 0;
    text-transform: none;
}

.italic-serif {
    font-family: var(--font-serif);
    font-style: italic;
    font-weight: 400;
}

.heading-huge {
    font-family: var(--font-heading);
    font-size: var(--text-huge);
    line-height: 1.05;
    font-weight: 800;
    letter-spacing: -0.04em;
    margin-bottom: var(--space-md);
}

.heading-giant {
    font-family: var(--font-heading);
    font-size: var(--text-giant);
    line-height: 0.95;
    font-weight: 800;
    letter-spacing: -0.05em;
}

.heading-large {
    font-family: var(--font-luxury);
    font-size: var(--text-3xl);
    line-height: 1.1;
    font-weight: 600;
    letter-spacing: 0;
}

.heading-medium {
    font-family: var(--font-luxury);
    font-size: var(--text-2xl);
    line-height: 1.3;
    font-weight: 600;
}

.large-accent {
    font-family: var(--font-primary);
    font-size: var(--text-base);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--clr-foreground);
    opacity: 1;
}

.lead {
    font-size: var(--text-xl);
    color: var(--clr-muted);
    max-width: 700px;
}

.text-reveal {
    opacity: 0;
    transform: translateY(30px);
}

/* Spacing Utilities */
.mt-2 { margin-top: 1rem; }
.mt-4 { margin-top: 2rem; }
.mt-8 { margin-top: 3.5rem; }
.mt-10 { margin-top: 4.5rem; }

/* Cartoon Aesthetic Lines (Scribbles) */
.accent-wrapper {
    position: relative;
    display: inline-block;
}

.scribble {
    position: absolute;
    pointer-events: none;
    z-index: -1;
}

.scribble-underline {
    bottom: -5px;
    left: 0;
    width: 100%;
    height: 12px;
}

.scribble-spark {
    top: -15px;
    right: -25px;
    width: 40px;
    height: 40px;
}

.scribble-circle {
    top: -10px;
    left: -10px;
    width: calc(100% + 20px);
    height: calc(100% + 20px);
}

.scribble-arrow {
    bottom: -30px;
    left: -40px;
    width: 50px;
    height: 50px;
    transform: rotate(15deg);
}

/* Layout Utilities */
section {
    padding: var(--space-section) 5%;
    max-width: var(--max-width);
    margin: 0 auto;
    position: relative;
    z-index: 10;
    overflow: hidden; /* Prevent localized overflow */
}

/* Header & Nav */
.header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--nav-height);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 5%;
    z-index: 1000;
    background-color: rgba(255, 255, 255, 0.7); /* Soft white background */
    backdrop-filter: blur(10px); /* Frosted glass effect */
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0,0,0,0.05);
    color: var(--clr-foreground);
    transition: background-color 0.3s ease;
}

.logo {
    text-decoration: none;
    color: var(--clr-foreground);
    z-index: 1001; /* Stay above overlay */
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.05em;
    font-family: var(--font-primary);
}

.logo-text .dot {
    color: inherit;
    font-weight: 800;
}

/* Desktop Nav */
.nav {
    display: flex;
    align-items: center;
    gap: 2.5rem;
}

@media (max-width: 900px) {
    .nav {
        display: none;
    }
}

.nav a {
    color: var(--clr-foreground);
    text-decoration: none;
    font-size: var(--text-sm);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    position: relative;
    transition: opacity 0.3s ease;
}

.nav a:hover {
    opacity: 0.7;
}

.nav a::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 1px;
    background-color: var(--clr-foreground);
    transition: width 0.3s ease;
}

.nav a:hover::after {
    width: 100%;
}

/* Buttons */
.btn-primary, .btn-outline {
    display: inline-block;
    padding: 1rem 2.5rem;
    font-size: var(--text-sm);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    text-decoration: none;
    border-radius: 50px;
    transition: all 0.4s ease;
    cursor: pointer;
}

.btn-primary {
    background-color: var(--clr-foreground);
    color: var(--clr-background) !important;
    border: 1px solid var(--clr-foreground);
}

.btn-primary:hover {
    background-color: transparent;
    color: var(--clr-foreground) !important;
}

/* For main content buttons */
main .btn-outline {
    border: 1px solid var(--clr-foreground);
    color: var(--clr-foreground);
    background: transparent;
}

main .btn-outline:hover {
    background-color: var(--clr-foreground);
    color: var(--clr-background);
}

main .btn-primary {
    background-color: var(--clr-foreground);
    color: var(--clr-background) !important;
    border: 1px solid var(--clr-foreground);
}

main .btn-primary:hover {
    background-color: transparent;
    color: var(--clr-foreground) !important;
}

/* Hero Section */
.hero {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-top: var(--nav-height);
}

.hero-content {
    max-width: 900px;
}

/* Generalized Blur for text overlays */
.hero-content, 
.services-intro, 
.why-intro, 
.featured-content, 
.cta-content {
    position: relative;
    z-index: 10;
}

.hero-content::before,
.services-intro::before,
.why-intro::before,
.featured-content::before,
.cta-content::before {
    content: '';
    position: absolute;
    top: -20%; 
    left: -5%; 
    right: -5%; 
    bottom: -20%;
    z-index: -1;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    mask-image: radial-gradient(circle at center, rgba(0,0,0,1) 0%, rgba(0,0,0,0) 80%);
    -webkit-mask-image: radial-gradient(circle at center, rgba(0,0,0,1) 0%, rgba(0,0,0,0) 80%);
    pointer-events: none;
    opacity: 0.9;
}

.marquee-tagline {
    text-align: center;
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--clr-muted);
    margin-bottom: 0;
    padding-top: 4rem; /* Spacing from hero */
}

/* Marquee Section */
.marquee-container {
    width: 100%;
    overflow: hidden;
    padding: 3rem 0;
    white-space: nowrap;
    position: relative;
    z-index: 5;
    border-top: 1px solid var(--clr-border);
    border-bottom: 1px solid var(--clr-border);
    background: transparent;
}

.marquee-content {
    display: inline-block;
    animation: scroll 40s linear infinite;
}

.marquee-content span {
    font-size: var(--text-2xl);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding-right: 4rem;
    color: var(--clr-foreground);
    display: inline-block;
}

.marquee-content .dot {
    color: var(--clr-muted);
    opacity: 0.3;
}

@keyframes scroll {
    from { transform: translateX(0); }
    to { transform: translateX(-50%); }
}

.hero .action-group {
    margin-top: 2rem;
}

/* Services */
.section-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 2rem;
}

.code-snippet {
    background-color: #111;
    color: #f1f1f1;
    padding: 1.5rem;
    border-radius: 8px;
    font-family: monospace;
    font-size: var(--text-sm);
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.service-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 4rem;
    border-top: 1px solid var(--clr-border);
    padding-top: 4rem;
}

.service-item h4 {
    font-size: var(--text-lg);
    font-weight: 600;
    margin-bottom: 1rem;
}

.service-item p {
    color: var(--clr-muted);
}

/* Why Us */
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 3rem;
    border-bottom: 1px solid var(--clr-border);
    padding-bottom: 4rem;
}

.feature h3 {
    font-size: var(--text-xl);
    margin-bottom: 1rem;
}

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

.stat {
    text-align: center;
}

.stat-number {
    font-size: var(--text-3xl);
    font-weight: 800;
    line-height: 1;
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: var(--text-sm);
    color: var(--clr-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Process */
.process-steps {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 3rem;
}

.process-step {
    position: relative;
}

.step-num {
    font-size: var(--text-huge);
    color: rgba(0,0,0,0.05);
    position: absolute;
    top: -2rem;
    left: -1rem;
    z-index: -1;
}

.process-step h4 {
    font-size: var(--text-xl);
    margin-bottom: 1rem;
}

/* Team */
.team-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 4rem;
}

.team-member {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.member-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background-color: var(--clr-foreground);
    color: var(--clr-background);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-lg);
    font-weight: 800;
}

.member-info h4 {
    font-size: var(--text-lg);
}

.member-info p {
    color: var(--clr-muted);
}

.member-socials {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.member-socials a {
    text-decoration: none;
    color: var(--clr-muted);
    transition: color 0.3s ease;
}

.member-socials a:hover {
    color: var(--clr-foreground);
}

.dot-sm {
    color: rgba(0,0,0,0.1);
    font-size: 0.6rem;
}

/* Portfolio */
.featured-project {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4rem;
    align-items: center;
}

.image-placeholder {
    width: 100%;
    aspect-ratio: 4/3;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: var(--text-lg);
    border-radius: 4px;
}

.tags {
    display: flex;
    gap: 1rem;
}

.tag {
    padding: 0.25rem 0.75rem;
    border: 1px solid var(--clr-border);
    border-radius: 50px;
    font-size: var(--text-xs);
    text-transform: uppercase;
}

.project-list {
    display: flex;
    flex-direction: column;
    margin-top: 4rem;
}

.project {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2.5rem 0;
    border-bottom: 1px solid var(--clr-border);
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.project:hover {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
    background-color: rgba(0,0,0,0.02);
}

.project-details h4 {
    font-size: var(--text-2xl);
    font-weight: 400;
}

.category {
    font-size: var(--text-sm);
    color: var(--clr-muted);
    margin-bottom: 0.5rem;
}

.project-link {
    text-transform: uppercase;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--clr-foreground);
    text-decoration: none;
    border-bottom: 1px solid var(--clr-foreground);
}

/* CTA */
.cta {
    text-align: center;
    padding: 8rem 5%;
}

/* Footer */
.footer {
    background-color: var(--clr-foreground);
    color: var(--clr-background);
    padding: 6rem 5% 2rem;
}

.footer-top {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 4rem;
    max-width: var(--max-width);
    margin: 0 auto;
}

.footer-brand .logo-text {
    font-size: var(--text-3xl);
    color: white;
}

.footer-links {
    display: flex;
    gap: 4rem;
}

.link-col {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.link-col h4 {
    color: var(--clr-muted);
    font-size: var(--text-sm);
    text-transform: uppercase;
    margin-bottom: 1rem;
}

.link-col a {
    color: white;
    text-decoration: none;
    transition: opacity 0.3s ease;
}

.link-col a:hover {
    opacity: 0.7;
}

.footer-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8rem;
    padding-top: 2rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    font-size: var(--text-sm);
    color: var(--clr-muted);
    max-width: var(--max-width);
    margin-left: auto;
    margin-right: auto;
}

.legal-links {
    display: flex;
    gap: 2rem;
}

.legal-links a {
    color: var(--clr-muted);
    text-decoration: none;
}

/* Project Narrative Section */
.project-narrative {
    background: #fcfcfc;
    border-top: 1px solid var(--clr-border);
    overflow: hidden; /* Prevent horizontal scroll from scribbles */
}

.narrative-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6rem;
    max-width: var(--max-width);
    margin: 0 auto;
}

.narrative-item h2 {
    margin-bottom: 2rem;
}

/* Image Filters */
.bw-filter {
    filter: grayscale(100%);
    transition: filter 0.5s ease, transform 0.5s ease;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
}

.bw-filter:hover {
    filter: grayscale(0%);
    transform: scale(1.05);
}


.image-container {
    overflow: hidden;
    border-radius: 12px;
    background: #eee;
    width: 100%;
    aspect-ratio: 16 / 10;
    max-height: 500px;
}

/* Burger Menu Button */
.burger-menu {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: flex-end;
    width: 30px;
    height: 30px;
    background: none;
    border: none;
    cursor: pointer;
    z-index: 1001;
    padding: 0;
}

.burger-menu .line {
    width: 100%;
    height: 2px;
    background-color: var(--clr-foreground);
    margin: 3px 0;
    transition: all 0.3s ease;
    border-radius: 2px;
}

.burger-menu .line-2 {
    width: 70%;
}

.burger-menu.active .line-1 {
    transform: rotate(45deg) translate(5px, 6px);
}

.burger-menu.active .line-2 {
    transform: rotate(-45deg) translate(0, -1px);
    width: 100%;
}

@media (max-width: 900px) {
    .burger-menu {
        display: flex;
    }
}

/* Mobile Menu Overlay */
.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 999;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.mobile-menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

.mobile-nav {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}

.mobile-nav a.logo {
    display: flex;
    align-items: center;
}


.mobile-nav a {
    font-size: var(--text-2xl);
    font-weight: 800;
    text-decoration: none;
    color: var(--clr-foreground);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.4s ease;
}

.mobile-menu-overlay.active .mobile-nav a {
    opacity: 1;
    transform: translateY(0);
}

/* Stagger Nav Links */
.mobile-menu-overlay.active .mobile-nav a:nth-child(1) { transition-delay: 0.1s; }
.mobile-menu-overlay.active .mobile-nav a:nth-child(2) { transition-delay: 0.15s; }
.mobile-menu-overlay.active .mobile-nav a:nth-child(3) { transition-delay: 0.2s; }
.mobile-menu-overlay.active .mobile-nav a:nth-child(4) { transition-delay: 0.25s; }
.mobile-menu-overlay.active .mobile-nav a:nth-child(5) { transition-delay: 0.3s; }
.mobile-menu-overlay.active .mobile-nav a:nth-child(6) { transition-delay: 0.35s; }

/* Responsive Layout Adjustments */
@media (max-width: 900px) {
    .hero-content {
        text-align: center;
        margin: 0 auto;
    }

    .service-list {
        grid-template-columns: 1fr;
    }

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

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

    .featured-project {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .footer-top {
        grid-template-columns: 1fr;
        gap: 4rem;
    }
}

@media (max-width: 600px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .project {
        flex-direction: column;
        align-items: flex-start;
        gap: 1.5rem;
    }

    .footer-links {
        flex-direction: column;
        gap: 3rem;
    }

    .footer-bottom {
        flex-direction: column;
        text-align: center;
        gap: 2rem;
    }

    .legal-links {
        justify-content: center;
    }
    
    .scribble-spark {
        width: 30px;
        height: 30px;
        right: -15px;
    }

    /* Project Page Specific Mobile Fixes */
    .narrative-grid {
        grid-template-columns: 1fr;
        gap: 4rem;
    }

    .project-header {
        padding: 6rem 5% 3rem 5%;
    }

    .image-container {
        aspect-ratio: auto; /* Allow height to adapt on mobile */
        max-height: 400px;
    }

    .image-container img {
        height: auto;
        object-fit: contain;
    }

    .accent-wrapper svg {
        max-width: 100%;
    }
}

/* Intro Loader - Pure White for Brand Clarity */
#intro-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #ffffff;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.intro-visual {
    position: relative;
    width: 400px;
    height: 400px;
}

#intro-canvas {
    width: 100%;
    height: 100%;
}

.intro-content {
    margin-top: -1rem; /* Move wordmark closer to animated logo */
    display: flex;
    flex-direction: column;
    align-items: center;
}

.header-logo-symbol {
    height: 35px;
    width: auto;
    display: block;
}

.intro-wordmark {
    height: 180px;
    width: auto;
    opacity: 0;
    transform: translateY(10px); /* Tighter start position */
}
