/* ==========================================================================
   KCD35 TECH // GLOBAL VARIABLES & CSS ARCHITECTURE
   ========================================================================== */
:root {
    --bg-base: #0F111A;
    --bg-surface: #1E212B;
    --text-primary: #F4F4F5;
    --text-muted: #8A8D98;
    --accent-cyan: #00D4FF;
    --font-primary: 'Inter', -apple-system, sans-serif;
}

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

body {
    background-color: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--font-primary);
    overflow-x: hidden; /* Strict horizontal containment */
    -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   THE "LAB" BACKGROUND ENGINE & PRE-LOADER
   ========================================================================== */
body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background-image: 
        linear-gradient(rgba(30, 33, 43, 0.3) 1px, transparent 1px),
        linear-gradient(90deg, rgba(30, 33, 43, 0.3) 1px, transparent 1px);
    background-size: 40px 40px;
    z-index: -2;
    pointer-events: none;
}

#loader-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--bg-base);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 2s ease, visibility 2s ease;
}

#loader-wrapper.fade-out {
    opacity: 0;
    visibility: hidden;
    transition: opacity 2s ease, visibility 2s ease;
}

#text-loader {
    width: 400px;
    max-width: 90vw;
}

.draw-slash {
    stroke: var(--accent-cyan);
    stroke-width: 4;
    stroke-linecap: round;
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    /* Draws instantly over 0.8s */
    animation: drawSlash 0.8s cubic-bezier(0.8, 0, 0.2, 1) forwards;
}

/* --- BASE TEXT PROPERTIES --- */
.anim-text {
    font-family: monospace; 
    font-size: 42px;
    font-weight: bold;
    letter-spacing: 4px;
    text-transform: uppercase;
    
    fill: transparent;
    stroke-width: 1px;
    stroke-dasharray: 400;
    stroke-dashoffset: 400;
    
    opacity: 0; /* Hidden before the sequence starts */
}

/* --- KODES (Left Side) --- */
.kodes-slide {
    stroke: var(--text-primary);
    /* 0.6s delay so it waits for the slash */
    animation: 
        slideKodes 0.8s 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) forwards,
        traceText 1.2s 0.6s ease-out forwards,
        fillBaseText 0.5s 1s ease forwards;
}

/* --- TECH (Right Side) --- */
.tech-slide {
    stroke: var(--accent-cyan);
    /* 0.6s delay so it waits for the slash */
    animation: 
        slideTech 0.8s 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) forwards,
        traceText 1.2s 0.6s ease-out forwards,
        fillCyanText 0.5s 1s ease forwards;
}

/* ==========================================================================
   ANIMATION KEYFRAMES
   ========================================================================== */
@keyframes drawSlash {
    0% { stroke-dashoffset: 200; }
    100% { stroke-dashoffset: 0; }
}

@keyframes traceText {
    0% { stroke-dashoffset: 400; }
    100% { stroke-dashoffset: 0; }
}

@keyframes fillBaseText {
    100% { fill: var(--text-primary); }
}

@keyframes fillCyanText {
    100% { fill: var(--accent-cyan); }
}

/* Slides in from the left */
@keyframes slideKodes {
    0% { opacity: 0; transform: translateX(-40px); }
    100% { opacity: 1; transform: translateX(0); }
}

/* Slides in from the right */
@keyframes slideTech {
    0% { opacity: 0; transform: translateX(40px); }
    100% { opacity: 1; transform: translateX(0); }
}

/* Class applied via JS to hide the loader */
.loader-hidden {
    opacity: 0;
    visibility: hidden;
}

/* ==========================================================================
   DYNAMIC HEADER & NAVIGATION LOGIC
   ========================================================================== */
#site-header {
    position: fixed;
    top: 0; left: 0; width: 100%;
    padding: 20px 8%;
    z-index: 1000;
    transition: all 0.4s ease;
}

#site-header.is-scrolled {
    background-color: rgba(30, 33, 43, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.nav-container { display: flex; justify-content: space-between; align-items: center; }
.brand-logo a { font-size: 1.5rem; font-weight: 800; color: var(--text-primary); text-decoration: none; letter-spacing: -1px; }
.brand-logo .cyan { color: var(--accent-cyan); }

.main-nav ul { list-style: none; display: flex; gap: 2.5rem; align-items: center; }
.main-nav a { color: var(--text-primary); text-decoration: none; font-size: 0.95rem; font-weight: 500; letter-spacing: 0.5px; transition: color 0.3s ease; }
.main-nav a:hover { color: var(--accent-cyan); }

.store-link { border: 1px solid var(--accent-cyan); padding: 8px 16px; border-radius: 4px; }
.store-link:hover { background: rgba(0, 212, 255, 0.1); }

.mobile-menu-toggle { display: none; flex-direction: column; gap: 6px; cursor: pointer; z-index: 2000; }
.mobile-menu-toggle span { display: block; width: 30px; height: 2px; background-color: var(--text-primary); transition: all 0.3s ease; }

/* ==========================================================================
   HERO SECTION, METRICS & BUTTONS
   ========================================================================== */
.hero-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: center;
    min-height: 100vh;
    padding: 120px 8% 0 8%;
    position: relative;
    overflow: hidden;
}

.hero-content {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.hero-status-tag {
    display: inline-flex;
    align-items: center; /* Locks the dot to the vertical center of the text */
    gap: 10px;
    background: rgba(0, 212, 255, 0.05);
    border: 1px solid rgba(0, 212, 255, 0.2);
    padding: 8px 16px;
    border-radius: 100px;
    font-size: 0.8rem;
    color: var(--accent-cyan);
    margin-bottom: 1.5rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    white-space: nowrap;
}

.pulse-dot {
    width: 8px; 
    height: 8px;
    min-width: 8px; /* Force minimum width */
    min-height: 8px; /* Force minimum height */
    flex-shrink: 0; /* CRITICAL: Tells mobile browsers NEVER to squish this */
    background-color: var(--accent-cyan);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--accent-cyan);
    animation: pulse 2s infinite;
}

.brand-title { font-size: 4rem; font-weight: 900; letter-spacing: -2px; margin-bottom: 0.5rem; }
.cyan-accent { color: var(--accent-cyan); }
.hero-headline { font-size: 1.8rem; color: var(--text-primary); margin-bottom: 1rem; }
.hero-subhead { font-size: 1.1rem; color: var(--text-muted); margin-bottom: 2.5rem; max-width: 90%; line-height: 1.6; }

.hero-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr); 
    width: 100%;
    max-width: 400px;
    gap: 0;
    margin: 0 0 2rem 0;
}

.metric-item { display: flex; flex-direction: column; align-items: flex-start; border-right: 1px solid rgba(255, 255, 255, 0.1); padding: 0 15px; }
.metric-item:first-child { padding-left: 0; }
.metric-item:last-child { border-right: none; }
.metric-value { font-size: 1.8rem; font-weight: 700; color: #fff; }
.metric-label { font-size: 0.75rem; text-transform: uppercase; color: rgba(255, 255, 255, 0.5); letter-spacing: 2px; }

.hero-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; max-width: 400px; }

.btn-primary, .btn-ghost {
    padding: 12px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    height: 55px;
    text-decoration: none;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.btn-primary { background-color: var(--accent-cyan); color: var(--bg-base); box-shadow: 0 0 15px rgba(0, 212, 255, 0.2); font-weight: 600; }
.btn-primary:hover { background-color: #fff; box-shadow: 0 0 25px rgba(0, 212, 255, 0.4); }

.btn-ghost { border: 1px solid var(--text-primary); color: var(--text-primary); }
.btn-ghost:hover { border-color: var(--accent-cyan); color: var(--accent-cyan); box-shadow: 0 0 15px rgba(0, 212, 255, 0.1); }

/* ==========================================================================
   THE DOM GLOBE ENGINE // CENTERING & 3D STAGE
   ========================================================================== */
.hero-visual {
    position: relative;
    width: 100%;
    height: 80vh; 
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: visible; /* Prevents edge-cutting */
    cursor: grab;
}

.hero-visual:active { cursor: grabbing; }

.globe-ambient-glow {
    position: absolute;
    width: 600px; height: 600px;
    background: radial-gradient(circle, rgba(0,212,255,0.08) 0%, rgba(15,17,26,0) 70%);
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    z-index: -1;
    animation: pulseLab 6s ease-in-out infinite alternate;
    pointer-events: none;
}

/* 1. Globe Stage */
#dom-globe-container {
    position: relative;
    width: 100%;
    height: 100%;
    margin: 0 auto;
    perspective: 1000px;
    pointer-events: none;
}

/* 2. Ghost Icons (Absolute dead center) */
.floating-icon {
    position: absolute;
    width: 32px; height: 32px;
    top: 50%; left: 50%;
    margin-top: -16px; margin-left: -16px;
    filter: grayscale(100%) brightness(500%);
    opacity: 0.15;
    transition: opacity 0.4s ease;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    outline: none;
    will-change: transform;
}

/* 3. Front Hover & Tech Icons */
.floating-icon.is-front:not(.live-link) { opacity: 0.5; }

/* 4. Active Social Icons */
.floating-icon.live-link {
    width: 60px; height: 60px;
    margin-top: -30px; margin-left: -30px; /* Offset adjusted for bigger size */
    pointer-events: auto;
}

.floating-icon.live-link.is-front {
    opacity: 1 !important;
    filter: none !important; 
    cursor: pointer;
    filter: contrast(100%) brightness(100%) saturate(100%) drop-shadow(0 0 10px rgba(0, 212, 255, 0.4)) !important;
}


/* ==========================================================================
   SECTIONS: SYSTEM CAPABILITIES & TECH STACK
   ========================================================================== */
.stack-container { padding: 5% 8%; background-color: var(--bg-base); }
.section-header h2 { font-size: 2.5rem; margin-bottom: 2rem; }

.stack-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
}

.stack-card {
    background: var(--bg-surface);
    padding: 2.5rem 2rem;
    border-left: 3px solid var(--accent-cyan);
    border-radius: 0 8px 8px 0;
    transition: transform 0.3s ease;
}

.stack-card:hover { transform: translateX(10px); }
.stack-card h3 { color: var(--text-primary); margin-bottom: 1rem; font-size: 1.3rem; }
.stack-card p { color: var(--text-muted); line-height: 1.6; }

/* ==========================================================================
   CONVEYOR BELT: PROJECT CARDS
   ========================================================================== */
.projects-container { padding: 5% 0; overflow: hidden; background: var(--bg-base); }
.projects-header { padding: 0 8%; margin-bottom: 3rem; }

/* FIXED: Changed from 100vw to 100% to stop horizontal scroll bug */
.conveyor-wrapper { 
    width: 100%; 
    /* Enable native hardware-accelerated swiping */
    overflow-x: auto; 
    overflow-y: hidden;
    position: relative; 
    -webkit-overflow-scrolling: touch; /* Butter-smooth iOS momentum */
    cursor: grab;
    /* Hide the ugly default scrollbars */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none;  /* IE and Edge */
}

.conveyor-wrapper::-webkit-scrollbar {
    display: none;
}

.conveyor-wrapper:active {
    cursor: grabbing;
}

#project-track {
    display: flex;
    width: max-content; 
    padding: 0 2rem;
    gap: 2rem;
}

#project-track.paused { animation-play-state: paused !important; }

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

.project-card {
    display: block;
    width: 400px;
    background: var(--bg-surface);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    text-decoration: none;
    transition: transform 0.4s ease, box-shadow 0.4s ease;
    cursor: pointer;
    overflow: hidden;
}

.card-image-wrapper { position: relative; height: 250px; overflow: hidden; }
.card-image-wrapper img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.5s ease; }
.card-overlay { position: absolute; inset: 0; background: rgba(15, 17, 26, 0.6); transition: opacity 0.4s ease; }

.card-meta { padding: 1.5rem; }
.card-meta h3 { color: var(--text-primary); font-size: 1.2rem; margin-bottom: 0.5rem; transition: color 0.3s ease; }
.tech-tag { color: var(--text-muted); font-size: 0.85rem; letter-spacing: 0.5px; }

.project-card:hover { transform: translateY(-10px); box-shadow: 0 10px 30px rgba(0, 212, 255, 0.15); border-color: rgba(0, 212, 255, 0.3); }
.project-card:hover .card-overlay { opacity: 0; }
.project-card:hover .card-image-wrapper img { transform: scale(1.05); }
.project-card:hover .card-meta h3 { color: var(--accent-cyan); }

/* ==========================================================================
   CONTACT PROTOCOL
   ========================================================================== */
.contact-container { padding: 5% 8%; background-color: var(--bg-surface); }
.contact-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4rem; align-items: center; }

.contact-copy h2 { font-size: 2.5rem; margin-bottom: 1rem; }
.contact-copy p { color: var(--text-muted); font-size: 1.1rem; margin-bottom: 2rem; line-height: 1.6; }

.custom-form { display: flex; flex-direction: column; gap: 1.5rem; }
.custom-input {
    padding: 15px;
    background: var(--bg-base);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text-primary);
    font-family: var(--font-primary);
    width: 100%;
    border-radius: 4px;
    transition: border-color 0.3s ease;
}
.custom-input:focus { outline: none; border-color: var(--accent-cyan); }
textarea.custom-input { resize: vertical; }

.form-feedback { display: none; padding: 1rem; margin-bottom: 1.5rem; font-size: 0.95rem; border-radius: 4px; }
.form-feedback.success { background: rgba(0, 212, 255, 0.1); border-left: 3px solid var(--accent-cyan); color: var(--accent-cyan); }
.form-feedback.error { background: rgba(255, 50, 50, 0.1); border-left: 3px solid #ff3232; color: #ff3232; }

/* ==========================================================================
   FOOTER & ANIMATIONS
   ========================================================================== */
#site-footer { background-color: var(--bg-base); border-top: 1px solid rgba(255, 255, 255, 0.05); padding: 3rem 8%; text-align: center; }
.footer-content p { color: var(--text-muted); font-size: 0.9rem; letter-spacing: 1px; text-transform: uppercase; }

.gsap-fade-up { opacity: 0; transform: translateY(40px); transition: opacity 0.8s ease-out, transform 0.8s ease-out; will-change: opacity, transform; }
.gsap-fade-up.is-visible { opacity: 1; transform: translateY(0); }
@keyframes pulse { 0% { opacity: 1; } 50% { opacity: 0.3; } 100% { opacity: 1; } }
@keyframes pulseLab { 0% { transform: translate(-50%, -50%) scale(0.9); opacity: 0.5; } 100% { transform: translate(-50%, -50%) scale(1.1); opacity: 1; } }

/* ==========================================================================
   SINGLE UNIFIED MOBILE MEDIA QUERY (Max-width: 768px)
   ========================================================================== */
@media screen and (max-width: 768px) {
    /* Navigation */
    .mobile-menu-toggle { display: flex; }
    .main-nav {
        position: fixed; top: 0; right: -100%; width: 100vw; height: 100vh;
        background: rgba(15, 17, 26, 0.98); backdrop-filter: blur(15px);
        display: flex; justify-content: center; align-items: center;
        transition: right 0.4s cubic-bezier(0.77, 0, 0.175, 1); z-index: 2000;
    }
    .main-nav.active { right: 0; }
    .main-nav ul { flex-direction: column; gap: 3rem; text-align: center; }
    .main-nav a { font-size: 1.5rem; letter-spacing: 2px; }
    
    .mobile-menu-toggle.active span:nth-child(1) { transform: translateY(8px) rotate(45deg); background-color: var(--accent-cyan); }
    .mobile-menu-toggle.active span:nth-child(2) { opacity: 0; }
    .mobile-menu-toggle.active span:nth-child(3) { transform: translateY(-8px) rotate(-45deg); background-color: var(--accent-cyan); }

    /* Hero Section */
    .hero-container { grid-template-columns: 1fr; padding: 100px 0 0 0; text-align: center; }
    .hero-content { align-items: center; text-align: center; padding: 0 5%; width: 100%;}
    .brand-title { font-size: 2.8rem; }
    .hero-headline { font-size: 1.4rem; justify-content: center; }
    .hero-subhead { font-size: 1rem; margin: 0 auto 2rem auto; }
    
    .hero-status-tag { 
        display: inline-flex; 
        align-self: center; 
        justify-content: center; 
        margin: 0 auto 1.5rem auto; /* Fixed the space in 1.5rem */
        padding: 8px 16px; /* Ensures it has enough breathing room on mobile */
        white-space: nowrap; /* Prevents the text from awkwardly wrapping to two lines */
        font-size: 0.65rem; /* Keeps it proportionate to mobile screens */
    }
    
    .hero-metrics { display: grid; grid-template-columns: repeat(3, 1fr); max-width: 340px; margin: 2rem auto; }
    .metric-item { align-items: center; padding: 0 5px; }
    .metric-value { font-size: 1.4rem; }
    .metric-label { font-size: 0.65rem; }

    .hero-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; max-width: 340px; justify-content: center; margin: 0 auto 2rem auto; }
    .btn-primary, .btn-ghost { height: 50px; font-size: 0.75rem; padding: 0 5px; letter-spacing: 0.5px; }

    /* Globe Adjustments */
    .hero-visual { height: 50vh; min-height: 420px; margin-top: 1rem; overflow: visible; outline: none; }
    .floating-icon { width: 28px; height: 28px; margin-top: -14px; margin-left: -14px; }
    .floating-icon.live-link { width: 42px; height: 42px; margin-top: -21px; margin-left: -21px; }

    /* Touch Overrides */
    .floating-icon.live-link { -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; user-select: none; }
    .floating-icon.live-link.is-front { filter: none !important; filter: drop-shadow(0 0 10px rgba(0, 212, 255, 0.4)) !important; opacity: 1 !important; }
    .floating-icon.live-link:active { opacity: 1; transform: scale(1.1) !important; transition: transform 0.1s ease; }

    /* Section Spacing Adjustments */
    .stack-container { padding: 15% 5%; }
    .section-header h2 { font-size: 2rem; text-align: center; }
    .projects-container { padding: 15% 0; }
    .projects-header { text-align: center; margin-bottom: 2rem; }
    .project-card { width: 85vw; max-width: 320px; }
    
    .contact-container { padding: 15% 5%; }
    .contact-grid { grid-template-columns: 1fr; gap: 2rem; text-align: center; }
    .contact-copy h2 { font-size: 2rem; }
    .custom-form button { align-self: center !important; width: 100%; }
    .floating-icon {
        -webkit-touch-callout: none !important;
        -webkit-user-select: none !important;
        user-select: none !important;
        -webkit-tap-highlight-color: rgba(0,0,0,0) !important;
    }

    /* 2. Absolute Front State (No pseudo-classes allowed) */
    .floating-icon.live-link.is-front {
        opacity: 1 !important;
        filter: none !important; 
        transform: translateZ(0); /* Hardware acceleration lock */
        filter: contrast(100%) brightness(100%) saturate(100%) drop-shadow(0 0 10px rgba(0, 212, 255, 0.4)) !important;
    }

}