/* ============================================
   FINAL OPTIMIZATION & FIXES
   Production-Ready Enhancements
   ============================================ */

/* ============================================
   1. LIGHT MODE HERO FIX
   ============================================ */
[data-theme="light"] .hero-content h1 {
    color: var(--secondary-color);
}

[data-theme="light"] .hero-content p {
    color: var(--text-color);
}

[data-theme="light"] .hero-badge {
    background: rgba(248, 142, 2, 0.1);
    border-color: rgba(248, 142, 2, 0.3);
}

/* ============================================
   2. RTL SUPPORT ENHANCEMENTS
   ============================================ */
[dir="rtl"] .hero-cta {
    flex-direction: row-reverse;
}

[dir="rtl"] .btn-energy i,
[dir="rtl"] .btn-energy-outline i {
    transform: scaleX(-1);
}

[dir="rtl"] .solar-panels-group {
    left: 5%;
    right: auto;
}

[dir="rtl"] .solar-sun {
    left: 20%;
    right: auto;
}

/* ============================================
   3. RESPONSIVE IMPROVEMENTS
   ============================================ */

/* Better mobile spacing */
@media (max-width: 768px) {
    .hero-cta {
        gap: 0.75rem;
    }

    .hero-content {
        padding: 0 1rem;
    }
}

/* Tablet optimization */
@media (min-width: 769px) and (max-width: 1024px) {
    .hero-content h1 {
        font-size: 3.5rem;
    }

    .btn-energy,
    .btn-energy-outline {
        font-size: 1.05rem;
        padding: 0.95rem 2.25rem;
    }
}

/* ============================================
   4. TOUCH TARGET IMPROVEMENTS (Mobile UX)
   ============================================ */
@media (max-width: 768px) {

    .btn-energy,
    .btn-energy-outline {
        min-height: 48px;
        /* Accessibility standard */
        padding: 1rem 2rem;
    }

    .theme-toggle-btn,
    .mobile-menu-btn {
        min-width: 44px;
        min-height: 44px;
    }
}

/* ============================================
   5. ANIMATION PERFORMANCE OPTIMIZATION
   ============================================ */

/* 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;
    }

    .solar-sun,
    .solar-panel,
    .beam,
    .particle {
        animation: none !important;
    }
}

/* GPU acceleration for smooth animations */
.solar-sun,
.solar-panel,
.btn-energy,
.btn-energy-outline {
    will-change: transform;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

/* ============================================
   6. CONTRAST & READABILITY FIXES
   ============================================ */

/* Ensure proper contrast in light mode */
[data-theme="light"] .golden-gradient {
    background: linear-gradient(135deg, #D97706 0%, #EA580C 50%, #DC2626 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Better text shadow for readability on busy backgrounds */
.hero-content h1 {
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

[data-theme="light"] .hero-content h1 {
    text-shadow: 0 2px 10px rgba(255, 255, 255, 0.5);
}

/* ============================================
   7. OVERFLOW FIXES
   ============================================ */
.cinematic-hero {
    overflow-x: hidden;
}

.hero-layout {
    max-width: 100%;
    overflow: visible;
}

/* Prevent horizontal scroll on mobile */
@media (max-width: 768px) {
    body {
        overflow-x: hidden;
    }

    .container {
        padding-inline: 1rem;
    }
}

/* ============================================
   8. FOCUS STATES (Accessibility)
   ============================================ */
.btn-energy:focus,
.btn-energy-outline:focus,
.theme-toggle-btn:focus,
.mobile-menu-btn:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.btn-energy:focus:not(:focus-visible),
.btn-energy-outline:focus:not(:focus-visible) {
    outline: none;
}

/* ============================================
   9. LOADING STATE OPTIMIZATION
   ============================================ */
.hero-content,
.hero-visual {
    opacity: 0;
    animation: fadeIn 0.8s ease-out forwards;
}

.hero-content {
    animation-delay: 0.2s;
}

.hero-visual {
    animation-delay: 0.4s;
}

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

/* ============================================
   10. PRINT STYLES
   ============================================ */
@media print {
    .cinematic-hero {
        background: white !important;
    }

    .hero-space-bg,
    .solar-sun,
    .solar-panels-group,
    .energy-beams,
    .floating-particles {
        display: none !important;
    }

    .hero-content h1,
    .hero-content p {
        color: black !important;
    }
}

/* ============================================
   11. SAFARI-SPECIFIC FIXES
   ============================================ */
@supports (-webkit-appearance: none) {

    .btn-energy,
    .btn-energy-outline {
        -webkit-appearance: none;
        appearance: none;
    }
}

/* ============================================
   12. EDGE CASE FIXES
   ============================================ */

/* Very small screens */
@media (max-width: 360px) {
    .hero-content h1 {
        font-size: 1.75rem;
    }

    .btn-energy,
    .btn-energy-outline {
        font-size: 0.9rem;
        padding: 0.75rem 1.5rem;
    }

    .solar-panel {
        width: 50px;
        height: 90px;
    }
}

/* Very large screens */
@media (min-width: 1920px) {
    .hero-layout {
        max-width: 1600px;
        margin: 0 auto;
    }
}

/* ============================================
   13. HOVER STATE IMPROVEMENTS
   ============================================ */
@media (hover: hover) {

    .btn-energy:hover,
    .btn-energy-outline:hover {
        cursor: pointer;
    }
}

/* Touch devices - no hover */
@media (hover: none) {

    .btn-energy:active,
    .btn-energy-outline:active {
        transform: scale(0.98);
    }
}

/* ============================================
   14. Z-INDEX MANAGEMENT
   ============================================ */
.hero-space-bg {
    z-index: 0;
}

.hero-layout {
    z-index: 10;
}

.hero-content {
    z-index: 15;
}

.hero-visual {
    z-index: 10;
}

.hero-divider {
    z-index: 20;
}

header {
    z-index: 1000;
}

.nav-links.active {
    z-index: 1000;
}

.mobile-menu-btn {
    z-index: 1001;
}

/* ============================================
   15. SMOOTH SCROLLING ENHANCEMENTS
   ============================================ */
html {
    scroll-padding-top: 100px;
    /* Account for fixed header */
}

@media (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }
}

/* ============================================
   16. BUTTON CONSISTENCY
   ============================================ */
.btn-energy,
.btn-energy-outline,
.btn-primary,
.btn-outline {
    font-family: var(--font-sans);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

/* ============================================
   17. MOBILE MENU IMPROVEMENTS
   ============================================ */
@media (max-width: 900px) {
    .nav-links.active {
        align-items: center;
        justify-content: center;
    }

    .nav-links.active a {
        width: 100%;
        text-align: center;
        padding: 1rem;
        border-radius: 8px;
        transition: background-color 0.3s ease;
    }

    .nav-links.active a:hover {
        background-color: rgba(248, 142, 2, 0.1);
    }
}

/* ============================================
   18. GRADIENT CONSISTENCY
   ============================================ */
.golden-gradient,
.text-gradient {
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 50%, #FF8C00 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* ============================================
   19. SPACING SYSTEM CONSISTENCY
   ============================================ */
.hero-content {
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;
}

/* ============================================
   20. FINAL POLISH
   ============================================ */

/* Smooth color transitions */
* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Better image rendering */
img {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* Remove tap highlight on mobile */
* {
    -webkit-tap-highlight-color: transparent;
}

/* Better text selection */
::selection {
    background-color: var(--primary-color);
    color: white;
}

::-moz-selection {
    background-color: var(--primary-color);
    color: white;
}