/* ============================================
   CUP CODE STUDIO - MAIN STYLES
   Modern 2026 Design with Arabic Support
============================================ */

/* ============================================
   CSS VARIABLES (Color Palette)
============================================ */
:root {
    /* Primary Colors */
    --color-leaf-green: #76AD3F;
    --color-leaf-light: #A8D28F;
    --color-charcoal: #333333;
    --color-cream: #FBF3E3;
    
    /* Secondary Colors */
    --color-white: #FFFFFF;
    --color-light-gray: #EAEAEA;
    --color-error: #E53935;
    --color-warning: #FB8C00;
    --color-success: #2E7D32;
    
    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #76AD3F 0%, #A8D28F 100%);
    --gradient-dark: linear-gradient(135deg, #333333 0%, #555555 100%);
    --gradient-hero: linear-gradient(135deg, rgba(118, 173, 63, 0.9) 0%, rgba(51, 51, 51, 0.9) 100%);
    
    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.2);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.25);
    
    /* Typography */
    --font-arabic: 'Tajawal', 'Cairo', sans-serif;
    --font-english: 'Poppins', sans-serif;
    --font-body: 'Cairo', sans-serif;
    
    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
    
    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 30px;
}

/* Dark Mode Variables */
[data-theme="dark"] {
    --color-cream: #1a1a1a;
    --color-charcoal: #f5f5f5;
    --color-light-gray: #2a2a2a;
    --color-white: #121212;
}

/* ============================================
   RESET & BASE STYLES
============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: var(--font-body);
    background-color: var(--color-cream);
    color: var(--color-charcoal);
    line-height: 1.7;
    overflow-x: hidden;
    transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* Arabic Text Direction */
html[lang="ar"] {
    direction: rtl;
}

html[lang="en"] {
    direction: ltr;
    font-family: var(--font-english);
}

/* ============================================
   TYPOGRAPHY
============================================ */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-arabic);
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 1rem;
}

h1 { font-size: clamp(2.5rem, 5vw, 4rem); }
h2 { font-size: clamp(2rem, 4vw, 3rem); }
h3 { font-size: clamp(1.5rem, 3vw, 2rem); }
h4 { font-size: 1.5rem; }
h5 { font-size: 1.25rem; }
h6 { font-size: 1rem; }

p {
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

a {
    text-decoration: none;
    color: inherit;
    transition: all var(--transition-fast);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ============================================
   CONTAINER & LAYOUT
============================================ */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
}

.section-padding {
    padding: 5rem 0;
}

.bg-alternate {
    background-color: var(--color-white);
}

/* ============================================
   HEADER / NAVBAR
============================================ */
.header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-sm);
    z-index: 1000;
    transition: all var(--transition-normal);
}

[data-theme="dark"] .header {
    background: rgba(26, 26, 26, 0.98);
}

.header.scrolled {
    box-shadow: var(--shadow-md);
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    gap: 2rem;
    position: relative;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

.logo {
    height: 50px;
    width: auto;
}

.brand-text {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-leaf-green);
    font-family: var(--font-arabic);
}

/* Navigation Menu - Centered */
.nav-menu {
    display: flex;
    list-style: none;
    gap: 1.5rem;
    align-items: center;
    flex: 1;
    justify-content: center;
    margin: 0 2rem;
}

/* Language Switcher - Left Side */
.lang-switcher {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-left: auto;
    flex-shrink: 0;
}

.nav-link {
    position: relative;
    padding: 0.5rem 1rem;
    font-weight: 500;
    transition: color var(--transition-fast);
}

.nav-link:hover,
.nav-link.active {
    color: var(--color-leaf-green);
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%) scaleX(0);
    width: 80%;
    height: 2px;
    background: var(--gradient-primary);
    transition: transform var(--transition-normal);
}

.nav-link:hover::after,
.nav-link.active::after {
    transform: translateX(-50%) scaleX(1);
}

/* Dropdown Menu */
.nav-dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 1rem;
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all var(--transition-normal);
    list-style: none;
}

[data-theme="dark"] .dropdown-menu {
    background: #2a2a2a;
}

.nav-dropdown:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-menu li {
    padding: 0;
}

.dropdown-menu a {
    display: block;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.dropdown-menu a:hover {
    background: var(--color-leaf-light);
    color: white;
    transform: translateX(-5px);
}

html[lang="en"] .dropdown-menu a:hover {
    transform: translateX(5px);
}

/* Language Switcher */
.lang-switcher {
    position: relative;
}

.lang-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--gradient-primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-family: var(--font-arabic);
    font-weight: 600;
    transition: all var(--transition-fast);
}

.lang-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.lang-dropdown {
    position: absolute;
    top: 120%;
    right: 0;
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 0.5rem;
    min-width: 150px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all var(--transition-normal);
    z-index: 100;
}

[data-theme="dark"] .lang-dropdown {
    background: #2a2a2a;
}

.lang-switcher:hover .lang-dropdown,
.lang-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.lang-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: var(--font-arabic);
    font-size: 1rem;
    text-align: right;
    transition: all var(--transition-fast);
}

html[lang="en"] .lang-option {
    text-align: left;
}

.lang-option:hover {
    background: var(--color-leaf-light);
    color: white;
}

.lang-flag {
    font-size: 1.5rem;
}

/* Theme Toggle */
.theme-toggle {
    padding: 0.75rem;
    background: var(--color-light-gray);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--color-charcoal);
    transition: all var(--transition-fast);
}

.theme-toggle:hover {
    background: var(--color-leaf-green);
    color: white;
    transform: rotate(180deg);
}

/* Mobile Menu Toggle */
.nav-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
}

.hamburger {
    width: 30px;
    height: 3px;
    background: var(--color-charcoal);
    border-radius: 3px;
    transition: all var(--transition-fast);
}

.hamburger::before,
.hamburger::after {
    content: '';
    display: block;
    width: 30px;
    height: 3px;
    background: var(--color-charcoal);
    border-radius: 3px;
    transition: all var(--transition-fast);
}

.hamburger::before { transform: translateY(-8px); }
.hamburger::after { transform: translateY(5px); }

/* ============================================
   HERO SECTION
============================================ */
.hero {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding-top: 80px;
}

.hero-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

.hero-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--gradient-hero);
    z-index: 1;
}

.hero-video {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    min-width: 100%;
    min-height: 100%;
    width: auto;
    height: auto;
    object-fit: cover;
    z-index: 0;
}

.particles {
    position: absolute;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.hero-content {
    position: relative;
    z-index: 2;
    text-align: center;
    color: white;
    padding: 2rem;
}

.hero-title {
    font-size: clamp(2.5rem, 6vw, 5rem);
    font-weight: 800;
    margin-bottom: 1.5rem;
    text-shadow: 2px 4px 8px rgba(0, 0, 0, 0.3);
}

.hero-subtitle {
    font-size: clamp(1.1rem, 2vw, 1.5rem);
    max-width: 800px;
    margin: 0 auto 2.5rem;
    opacity: 0.95;
    line-height: 1.8;
}

.hero-cta {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Coffee Cup Animation */
.hero-icon {
    margin-top: 3rem;
    display: inline-block;
}

.coffee-cup {
    position: relative;
    width: 100px;
    height: 100px;
}

.cup-body {
    width: 80px;
    height: 60px;
    background: white;
    border-radius: 0 0 40px 40px;
    position: absolute;
    bottom: 0;
    left: 10px;
    box-shadow: var(--shadow-lg);
}

.cup-body::before {
    content: '';
    position: absolute;
    width: 25px;
    height: 30px;
    border: 3px solid white;
    border-radius: 0 15px 15px 0;
    right: -25px;
    top: 15px;
}

.steam {
    position: absolute;
    width: 5px;
    height: 30px;
    background: white;
    opacity: 0.7;
    border-radius: 50%;
    animation: steam-rise 2s ease-in-out infinite;
}

.steam:nth-child(1) { left: 30%; animation-delay: 0s; }
.steam:nth-child(2) { left: 50%; animation-delay: 0.5s; }
.steam:nth-child(3) { left: 70%; animation-delay: 1s; }

/* Scroll Indicator */
.scroll-indicator {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    color: white;
    z-index: 2;
}

.mouse {
    width: 30px;
    height: 50px;
    border: 2px solid white;
    border-radius: 20px;
    position: relative;
    margin: 0 auto 10px;
}

.wheel {
    width: 6px;
    height: 10px;
    background: white;
    border-radius: 3px;
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    animation: scroll-wheel 1.5s ease-in-out infinite;
}

/* ============================================
   BUTTONS
============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 2rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-family: var(--font-arabic);
    font-size: 1.1rem;
    cursor: pointer;
    border: none;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:hover::before {
    width: 300px;
    height: 300px;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: var(--color-charcoal);
    color: white;
}

.btn-secondary:hover {
    background: var(--color-leaf-green);
    transform: translateY(-3px);
}

.btn-outline {
    background: transparent;
    color: white;
    border: 2px solid white;
}

.btn-outline:hover {
    background: white;
    color: var(--color-leaf-green);
}

.btn-sm {
    padding: 0.6rem 1.5rem;
    font-size: 0.95rem;
}

/* ============================================
   SECTIONS
============================================ */
.section-header {
    margin-bottom: 3rem;
}

.section-title {
    color: var(--color-leaf-green);
    margin-bottom: 1rem;
    position: relative;
    display: inline-block;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 0;
    width: 60%;
    height: 4px;
    background: var(--gradient-primary);
    border-radius: 2px;
}

.section-subtitle {
    font-size: 1.2rem;
    color: var(--color-charcoal);
    opacity: 0.8;
    max-width: 700px;
    margin: 0 auto;
}

/* ============================================
   QUICK SECTIONS GRID
============================================ */
.quick-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.quick-card {
    position: relative;
    background: white;
    padding: 2.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-normal);
    overflow: hidden;
    border: 2px solid transparent;
}

.quick-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--gradient-primary);
    transform: scaleX(0);
    transition: transform var(--transition-normal);
}

.quick-card:hover {
    transform: translateY(-10px);
    box-shadow: var(--shadow-xl);
    border-color: var(--color-leaf-green);
}

.quick-card:hover::before {
    transform: scaleX(1);
}

.card-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    display: inline-block;
    animation: float 3s ease-in-out infinite;
}

.quick-card h3 {
    font-size: 1.8rem;
    color: var(--color-charcoal);
    margin-bottom: 1rem;
}

.quick-card p {
    color: var(--color-charcoal);
    opacity: 0.7;
    margin-bottom: 1.5rem;
}

.card-arrow {
    position: absolute;
    bottom: 2rem;
    right: 2rem;
    width: 40px;
    height: 40px;
    background: var(--color-leaf-green);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-normal);
}

html[lang="en"] .card-arrow {
    right: auto;
    left: 2rem;
}

.quick-card:hover .card-arrow {
    transform: translateX(-10px);
}

html[lang="en"] .quick-card:hover .card-arrow {
    transform: translateX(10px);
}

/* ============================================
   PROJECTS GRID
============================================ */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 2.5rem;
}

.project-card {
    background: white;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    transition: all var(--transition-normal);
}

.project-card:hover {
    transform: translateY(-10px);
    box-shadow: var(--shadow-xl);
}

.project-image {
    position: relative;
    width: 100%;
    height: 250px;
    overflow: hidden;
}

.project-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-slow);
}

.project-card:hover .project-image img {
    transform: scale(1.1);
}

.project-badge {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: var(--color-success);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 600;
}

html[lang="en"] .project-badge {
    right: auto;
    left: 1rem;
}

.badge-ai {
    background: var(--gradient-primary);
}

.project-content {
    padding: 2rem;
}

.project-content h3 {
    font-size: 1.6rem;
    margin-bottom: 1rem;
    color: var(--color-charcoal);
}

.project-content p {
    color: var(--color-charcoal);
    opacity: 0.7;
    margin-bottom: 1.5rem;
}

.project-tags {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.project-tags span {
    background: var(--color-light-gray);
    padding: 0.4rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
}

/* ============================================
   FOOTER
============================================ */
.footer {
    background: var(--color-charcoal);
    color: white;
    padding: 4rem 0 2rem;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 3rem;
    margin-bottom: 3rem;
}

.footer-logo {
    height: 60px;
    margin-bottom: 1rem;
}

.footer-section h4 {
    color: var(--color-leaf-green);
    margin-bottom: 1.5rem;
    font-size: 1.3rem;
}

.footer-section p {
    opacity: 0.8;
    margin-bottom: 1.5rem;
}

.footer-section ul {
    list-style: none;
}

.footer-section ul li {
    margin-bottom: 0.75rem;
}

.footer-section ul li a {
    opacity: 0.8;
    transition: all var(--transition-fast);
}

.footer-section ul li a:hover {
    opacity: 1;
    color: var(--color-leaf-green);
    padding-right: 5px;
}

html[lang="en"] .footer-section ul li a:hover {
    padding-right: 0;
    padding-left: 5px;
}

.social-links {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.social-links a {
    width: 45px;
    height: 45px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    transition: all var(--transition-fast);
}

.social-links a:hover {
    background: var(--color-leaf-green);
    transform: translateY(-5px);
}

.footer-bottom {
    text-align: center;
    padding-top: 2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.footer-bottom p {
    opacity: 0.7;
    margin: 0.5rem 0;
}

.footer-legal-info {
    margin-bottom: 1rem;
}

.commercial-registration {
    font-weight: 600;
    color: var(--color-leaf-green);
    opacity: 1 !important;
    margin: 0.75rem 0;
}

.commercial-registration i {
    color: var(--color-leaf-green);
    margin-left: 0.5rem;
}

.verified-badge {
    font-weight: 600;
    color: #4CAF50;
    opacity: 1 !important;
    margin: 0.75rem 0;
}

.verified-badge i {
    color: #4CAF50;
    margin-left: 0.5rem;
}

.footer-vision {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* ============================================
   BACK TO TOP BUTTON
============================================ */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 50px;
    height: 50px;
    background: var(--gradient-primary);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
    z-index: 999;
}

html[lang="en"] .back-to-top {
    right: auto;
    left: 2rem;
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
}

.back-to-top:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-xl);
}

/* ============================================
   UTILITY CLASSES
============================================ */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }

/* ============================================
   RESPONSIVE DESIGN
============================================ */
@media (max-width: 1024px) {
    .navbar {
        padding: 1rem;
    }
    
    .quick-grid,
    .projects-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: 1.5rem;
    }
}

@media (max-width: 768px) {
    .nav-toggle {
        display: flex;
    }
    
    .nav-menu {
        position: fixed;
        top: 80px;
        right: -100%;
        left: auto;
        transform: none;
        width: 300px;
        height: calc(100vh - 80px);
        background: white;
        flex-direction: column;
        padding: 2rem;
        box-shadow: var(--shadow-xl);
        transition: right var(--transition-normal);
    }
    
    html[lang="en"] .nav-menu {
        right: auto;
        left: -100%;
        transition: left var(--transition-normal);
    }
    
    .nav-menu.active {
        right: 0;
    }
    
    html[lang="en"] .nav-menu.active {
        left: 0;
    }
    
    [data-theme="dark"] .nav-menu {
        background: #1a1a1a;
    }
    
    .hero-cta {
        flex-direction: column;
    }
    
    .section-padding {
        padding: 3rem 0;
    }
    
    .footer-content {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 1rem;
    }
    
    .brand-text {
        display: none;
    }
    
    .hero-title {
        font-size: 2rem;
    }
    
    .hero-subtitle {
        font-size: 1rem;
    }
    
    .btn {
        padding: 0.8rem 1.5rem;
        font-size: 1rem;
    }
    
    .quick-grid,
    .projects-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   PERFORMANCE & COMPATIBILITY ENHANCEMENTS
============================================ */

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
        --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
        --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    }
    
    .btn-outline {
        border-width: 2px;
    }
}

/* Dark mode support (optional) */
@media (prefers-color-scheme: dark) {
    /* يمكن إضافة دعم الوضع الداكن هنا إذا لزم الأمر */
}

/* Slow connection optimizations */
.slow-connection * {
    animation: none !important;
    transition: none !important;
}

.slow-connection img {
    image-rendering: -webkit-optimize-contrast;
}

/* Save data mode - reduce image quality */
.save-data img {
    image-rendering: pixelated;
}

/* Loading state */
body:not(.loaded) {
    opacity: 0;
}

body.loaded {
    opacity: 1;
    transition: opacity 0.3s ease;
}

/* Touch device optimizations */
.touch-device .hover-effect:hover {
    transform: none;
}

.touch-device .btn {
    -webkit-tap-highlight-color: rgba(118, 173, 63, 0.3);
}

/* Print styles */
@media print {
    .header,
    .footer,
    .cta-section,
    .social-links,
    .nav-toggle,
    .lang-switcher {
        display: none !important;
    }
    
    body {
        background: white !important;
        color: black !important;
    }
    
    a[href]:after {
        content: " (" attr(href) ")";
    }
}

/* IE11 specific fixes */
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
    /* Grid fallback for IE11 */
    .projects-grid,
    .features-grid,
    .games-grid {
        display: -ms-flexbox;
        display: flex;
        -ms-flex-wrap: wrap;
        flex-wrap: wrap;
    }
    
    .project-card,
    .feature-card,
    .game-card {
        -ms-flex: 0 0 calc(33.333% - 2rem);
        flex: 0 0 calc(33.333% - 2rem);
    }
}

/* WebP support */
.webp img {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

.no-webp img {
    image-rendering: auto;
}

/* Accessibility improvements */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Focus visible for keyboard navigation */
*:focus-visible {
    outline: 3px solid var(--color-leaf-green);
    outline-offset: 2px;
}

/* Prevent text selection on buttons */
button,
.btn {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* GPU acceleration for animations */
.animate-fade-in-up,
.reveal,
.hover-effect {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    will-change: transform, opacity;
}

/* Smooth font rendering */
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* ============================================
   HERO IMAGE IMPROVEMENTS
============================================ */
.hero-image {
    position: relative;
    width: 100%;
    max-width: 500px;
    margin: 2rem auto;
    padding: 1rem;
    z-index: 1;
}

.hero-image img {
    width: 100%;
    height: auto;
    max-height: 400px;
    object-fit: contain;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    transition: transform var(--transition-normal);
}

.hero-image img:hover {
    transform: scale(1.05);
}

/* Game/App Cards Image Fix */
.project-card img,
.game-card img,
.app-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    transition: transform var(--transition-normal);
}

.project-card:hover img,
.game-card:hover img,
.app-card:hover img {
    transform: scale(1.1);
}

/* Feature Images */
.feature-image img {
    width: 100%;
    max-width: 400px;
    height: auto;
    object-fit: contain;
    margin: 0 auto;
    display: block;
}

/* Screenshot Gallery */
.screenshots-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.screenshot-item {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    cursor: pointer;
    transition: all var(--transition-normal);
}

.screenshot-item img {
    width: 100%;
    height: 250px;
    object-fit: cover;
    transition: transform var(--transition-normal);
}

.screenshot-item:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.screenshot-item:hover img {
    transform: scale(1.1);
}

/* Responsive Images */
@media (max-width: 768px) {
    .hero-image {
        max-width: 100%;
        padding: 0.5rem;
    }
    
    .hero-image img {
        max-height: 300px;
    }
    
    .project-card img,
    .game-card img,
    .app-card img {
        height: 180px;
    }
    
    .screenshot-item img {
        height: 200px;
    }
}

/* ============================================
   END OF PERFORMANCE ENHANCEMENTS
============================================ */
