/* =========================================
   1. Design Tokens & Reset
   ========================================= */

:root {
    /* Modern Palette - Matches your new HTML */
    --primary-dark: #002b5e;
    --primary-light: #2563eb;
    --accent-glow: #3b82f6;
    --text-main: #1e293b;
    --text-muted: #64748b;
    
    /* Animation Curves */
    --ease-out-back: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    overflow-x: hidden; /* Prevent horizontal scroll from animations */
    touch-action: pan-y; /* Allow vertical scroll but intercept horizontal edge swipes */
}

/* =========================================
   2. Utility Classes & Glassmorphism
   ========================================= */

/* The "Frosted Glass" Effect */
.glass-panel {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

/* Portfolio iframe scaling */
.portfolio-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s var(--ease-smooth);
}

/* COWebs.lb - Enhanced Animations & Skills CSS */

/* =========================================
   3. Advanced Animations
   ========================================= */

/* Performance Optimized Scroll Animation */
.animate-on-scroll {
    opacity: 0;
    transform: translateY(40px);
    will-change: opacity, transform;
    transition: opacity 0.8s ease-out, transform 0.8s var(--ease-out-back);
}

.animate-on-scroll.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Stagger animation delays for multiple elements */
.animate-on-scroll:nth-child(1) { transition-delay: 0.1s; }
.animate-on-scroll:nth-child(2) { transition-delay: 0.2s; }
.animate-on-scroll:nth-child(3) { transition-delay: 0.3s; }
.animate-on-scroll:nth-child(4) { transition-delay: 0.4s; }

/* Hero pattern with subtle movement */
.hero-pattern {
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    background-size: 60px 60px;
}

/* Enhanced Skills Section Styling */
.skills-card {
    transition: all 0.3s ease;
    will-change: transform;
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border: 1px solid #e2e8f0;
}

.skills-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    border-color: #3b82f6;
}

.skill-category-title {
    background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* =========================================
   5. Skills Section (Total Redesign)
   ========================================= */

.skill-item {
    background: white;
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid #f1f5f9;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
    transition: transform 0.3s ease, border-color 0.3s ease;
}

.skill-item:hover {
    transform: translateX(5px);
    border-color: var(--accent-glow);
}

.skill-progress {
    height: 8px;
    background: #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
    margin-top: 10px;
}

.skill-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #2563eb, #06b6d4); /* Gradient from Blue to Cyan */
    border-radius: 10px;
    width: 0; /* JS will animate this */
    transition: width 1.5s cubic-bezier(0.22, 1, 0.36, 1);
    position: relative;
}

/* The "Glow Tip" at the end of the bar */
.skill-progress-bar::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 5px;
    background: rgba(255, 255, 255, 0.5);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
}

/* Typing Cursor */
.typing-animation::after {
    content: '|';
    animation: blink 1s step-end infinite;
    color: var(--primary-light);
}

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

.skill-percentage {
    font-weight: 600;
    color: #1d4ed8;
    font-size: 14px;
}

.skill-icon {
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    margin-right: 12px;
    flex-shrink: 0;
}

/* Service card hover effects */
/* =========================================
   4. Component Styling
   ========================================= */

/* Service Cards - The "Hover Lift" */
.service-card {
    position: relative;
    transition: transform 0.4s var(--ease-smooth), box-shadow 0.4s var(--ease-smooth);
    z-index: 1;
}

.service-card:hover {
    transform: translateY(-10px);
    /* Colored shadow glow instead of black */
    box-shadow: 0 20px 40px -10px rgba(37, 99, 235, 0.2); 
    border-color: rgba(59, 130, 246, 0.3);
}

.service-card .service-icon {
    transition: transform 0.4s var(--ease-out-back);
}

.service-card:hover .service-icon {
    transform: scale(1.15) rotate(5deg);
}

/* Navigation Links - Underline Effect */
.nav-link {
    position: relative;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0%;
    height: 2px;
    background: var(--primary-light);
    transition: width 0.3s var(--ease-smooth);
}

.nav-link:hover::after {
    width: 100%;
}

/* Primary Buttons */
.btn-animate {
    position: relative;
    overflow: hidden;
    z-index: 1;
    transition: transform 0.3s var(--ease-smooth), box-shadow 0.3s var(--ease-smooth);
}

.btn-animate::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(rgba(255,255,255,0.2), transparent);
    opacity: 0;
    transition: opacity 0.3s;
}

.btn-animate:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 20px -5px rgba(37, 99, 235, 0.4); /* Blue glow */
}

.btn-animate:hover::after {
    opacity: 1;
}

/* Social icons animation */
.social-icon {
    transition: all 0.3s ease;
}

.social-icon:hover {
    transform: translateY(-2px);
    color: #2196f3;
}

/* Typing animation */
.typing-animation {
    display: inline-block;
    overflow: hidden;
}

.typing-animation::after {
    content: '|';
    animation: blink-caret 1s step-end infinite;
    color: rgba(255,255,255,0.7);
}

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

/* Mobile optimization */
@media (max-width: 768px) {
    .service-card:hover,
    .btn-animate:hover {
        transform: none !important;
        box-shadow: 0 4px 6px rgba(0,0,0,0.1) !important;
    }
    
    .typing-animation::after {
        display: none;
    }
    
    .nav-link::after {
        display: none;
    }
    
    .skills-card:hover {
        transform: none !important;
    }
    
    .skill-item:hover {
        transform: none !important;
    }
}

/* Accessibility - Reduce motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Smooth scroll behavior */
html {
    scroll-behavior: smooth;
}

/* Performance optimization */
.service-card,
.btn-animate,
.nav-link,
.skills-card,
.skill-item {
    will-change: transform;
}

/* Header optimization for smooth scrolling */
#header {
    will-change: transform, box-shadow;
    transform: translateZ(0); /* Force hardware acceleration */
}

#header .logo {
    will-change: height;
    transition: height 0.2s ease-out;
}

#header .nav-container {
    will-change: padding;
    transition: padding 0.2s ease-out;
    position: relative;
}

/* Header shrinking effect */
#header.shrunk .logo {
    height: 60px; /* Shrink from 80px to 60px */
}

#header.shrunk .nav-container {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}

/* Hide desktop navigation when header is shrunk on mobile */
@media (max-width: 1024px) {
    #header.shrunk .desktop-nav {
        display: none;
    }
    
    #header.shrunk .hamburger {
        display: flex;
    }
}

/* =========================================
   6. Header & Navigation Logic
   ========================================= */

#header {
    transition: all 0.4s var(--ease-smooth);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

#header.shrunk {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 4px 20px -5px rgba(0, 0, 0, 0.05);
}

/* Keep software division pages in a dark header theme for contrast */
body.bg-slate-950 #header {
    background: rgba(2, 6, 23, 0.82);
    border-color: rgba(255, 255, 255, 0.08);
}

body.bg-slate-950 #header.shrunk {
    background: rgba(2, 6, 23, 0.92);
    box-shadow: 0 10px 30px -12px rgba(15, 23, 42, 0.8);
}

body.bg-slate-950 #header .desktop-nav > a {
    color: #cbd5e1;
}

body.bg-slate-950 #header .desktop-nav > a:hover {
    color: #e9d5ff;
}

body.bg-slate-950 #header .desktop-nav > a.bg-gradient-to-r {
    color: #ffffff;
}

body.bg-slate-950 #header .hamburger-line {
    background: #e2e8f0;
}

#header .logo {
    transition: height 0.4s var(--ease-smooth);
}

#header.shrunk .logo {
    height: 50px;
}

/* Hamburger Menu Icon */
.hamburger {
    display: none; /* Hidden on desktop */
    flex-direction: column;
    width: 30px;
    height: 30px;
    cursor: pointer;
    z-index: 101; /* Above mobile nav to stay clickable */
    position: relative;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
}

.hamburger span,
.hamburger-line {
    background: #1f2937;
    border-radius: 10px;
    height: 3px;
    margin: 3px 0;
    transition: .4s cubic-bezier(0.68, -0.6, 0.32, 1.6);
    display: block;
    width: 24px;
}

/* Hamburger Animation State */
.hamburger.open span:nth-of-type(1),
.hamburger.open .hamburger-line:nth-child(1) {
    transform-origin: bottom;
    transform: rotatez(45deg) translate(5px, 0px);
}

.hamburger.open span:nth-of-type(2),
.hamburger.open .hamburger-line:nth-child(2) {
    transform-origin: top;
    transform: rotatez(-45deg);
}

.hamburger.open span:nth-of-type(3),
.hamburger.open .hamburger-line:nth-child(3) {
    transform-origin: bottom;
    width: 50%;
    transform: translate(12px,-7px) rotatez(45deg);
}

/* Mobile Menu Overlay */
.mobile-nav {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    right: 0;
    width: 100%;
    background: #fff;
    border-radius: 0 0 1.5rem 1.5rem;
    box-shadow: 0 25px 50px -20px rgba(15, 23, 42, 0.35);
    border: 1px solid rgba(15, 23, 42, 0.08);
    margin: 0;
    padding: 0.5rem 0;
    transition: opacity 0.3s var(--ease-smooth), transform 0.3s var(--ease-smooth), max-height 0.4s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(-10px);
    max-height: 0;
    pointer-events: none;
    z-index: 40;
}

.mobile-nav.open {
    opacity: 1;
    transform: translateY(0);
    max-height: 420px;
    pointer-events: auto;
}

.mobile-nav ul {
    display: flex;
    flex-direction: column;
    padding: 0;
    margin: 0;
    list-style: none;
    width: 100%;
}

.mobile-nav li {
    width: 100%;
    border-bottom: 1px solid #f3f4f6;
}

.mobile-nav li:last-child {
    border-bottom: none;
}

.mobile-nav a {
    display: block;
    padding: 1rem 1.5rem;
    color: #374151;
    font-weight: 500;
    transition: all 0.3s ease;
    position: relative;
    text-decoration: none;
}

.mobile-nav a:hover {
    background-color: #f8fafc;
    color: #2563eb;
}

/* =========================================
   7. Media Queries (Mobile Optimization)
   ========================================= */

@media (max-width: 1024px) {
    /* Hide desktop navigation completely on mobile */
    .desktop-nav { 
        display: none !important; 
        visibility: hidden !important;
        opacity: 0 !important;
        height: 0 !important;
        overflow: hidden !important;
    }
    
    .desktop-nav ul,
    .desktop-nav li,
    .desktop-nav a {
        display: none !important;
        visibility: hidden !important;
    }
    
    /* Show hamburger menu on mobile */
    .hamburger { 
        display: flex !important; 
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
    }
}

@media (max-width: 768px) {
    /* Disable heavy hover effects on touch devices */
    .service-card:hover { transform: none; }
    
    .hero-pattern {
        background-size: 40px 40px; /* Smaller pattern */
    }
    
    h1 {
        font-size: 2.5rem !important;
    }
}

@media (max-width: 768px) {
    #header .nav-container {
        padding: 0.75rem 1rem;
    }

    #header.shrunk .nav-container {
        padding: 0.5rem 1rem;
    }

    #header.shrunk .logo {
        height: 50px;
    }

    .hamburger {
        padding: 0.375rem;
    }

    .hamburger-line {
        width: 20px;
        height: 2px;
        margin: 2px 0;
    }

    .mobile-nav a {
        padding: 0.875rem 1.5rem;
        font-size: 0.95rem;
    }
}

/* Fix for inline styles */
.skill-progress-bar[data-percentage] {
    width: 0%;
    transition: width 1.5s ease-in-out, transform 0.3s ease;
}
