/* Custom Styles for Hekayat Shasha Landing Page */

/* RTL Support and Base Styles */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Cairo', sans-serif;
    direction: rtl;
    text-align: right;
}

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

/* Header Scroll Effect */
#header.scrolled {
    background-color: rgba(26, 26, 64, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

/* Twinkling Stars Animation */
.stars {
    background: transparent url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="20" cy="20" r="1" fill="white" opacity="0.8"><animate attributeName="opacity" values="0.8;0.3;0.8" dur="2s" repeatCount="indefinite"/></circle><circle cx="80" cy="30" r="0.5" fill="white" opacity="0.6"><animate attributeName="opacity" values="0.6;0.2;0.6" dur="3s" repeatCount="indefinite"/></circle><circle cx="40" cy="70" r="1.5" fill="white" opacity="0.7"><animate attributeName="opacity" values="0.7;0.2;0.7" dur="2.5s" repeatCount="indefinite"/></circle><circle cx="70" cy="80" r="1" fill="white" opacity="0.5"><animate attributeName="opacity" values="0.5;0.1;0.5" dur="4s" repeatCount="indefinite"/></circle><circle cx="10" cy="60" r="0.8" fill="white" opacity="0.9"><animate attributeName="opacity" values="0.9;0.3;0.9" dur="1.8s" repeatCount="indefinite"/></circle></svg>') repeat;
    background-size: 200px 200px;
    animation: twinkle 20s linear infinite;
}

.stars-bg {
    background: transparent url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 200"><circle cx="40" cy="40" r="1" fill="white" opacity="0.8"><animate attributeName="opacity" values="0.8;0.2;0.8" dur="3s" repeatCount="indefinite"/></circle><circle cx="160" cy="60" r="0.5" fill="white" opacity="0.6"><animate attributeName="opacity" values="0.6;0.1;0.6" dur="4s" repeatCount="indefinite"/></circle><circle cx="80" cy="140" r="1.2" fill="white" opacity="0.7"><animate attributeName="opacity" values="0.7;0.3;0.7" dur="2s" repeatCount="indefinite"/></circle><circle cx="140" cy="160" r="1" fill="white" opacity="0.5"><animate attributeName="opacity" values="0.5;0.2;0.5" dur="5s" repeatCount="indefinite"/></circle><circle cx="20" cy="120" r="0.8" fill="white" opacity="0.9"><animate attributeName="opacity" values="0.9;0.4;0.9" dur="2.2s" repeatCount="indefinite"/></circle><circle cx="100" cy="20" r="0.6" fill="white" opacity="0.4"><animate attributeName="opacity" values="0.4;0.1;0.4" dur="3.5s" repeatCount="indefinite"/></circle></svg>') repeat;
    background-size: 300px 300px;
    animation: twinkleReverse 25s linear infinite;
}

@keyframes twinkle {
    0% { background-position: 0 0; }
    100% { background-position: 200px 200px; }
}

@keyframes twinkleReverse {
    0% { background-position: 300px 300px; }
    100% { background-position: 0 0; }
}

/* Parallax Effect for Hero */
.hero-section {
    background-attachment: fixed;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
}

/* High Quality Background Image Rendering */
.hero-section [style*="background-image"] {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    image-rendering: pixelated;
    image-rendering: high-quality;
    -ms-interpolation-mode: bicubic;
    background-size: cover !important;
    background-position: center center !important;
    background-repeat: no-repeat !important;
    min-height: 100vh;
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

/* Button Hover Effects */
.glow-button {
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(246, 176, 54, 0.3);
}

.glow-button:hover {
    box-shadow: 0 8px 25px rgba(246, 176, 54, 0.6);
    transform: translateY(-2px);
}

.glow-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s;
}

.glow-button:hover::before {
    left: 100%;
}

/* Value Cards Animation */
.value-card {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid transparent;
}

.value-card:hover {
    border-color: #F6B036;
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

/* Book Mockup 3D Effect */
.book-mockup {
    perspective: 1000px;
}

.book-mockup img {
    transform-style: preserve-3d;
    transition: transform 0.5s ease;
}

.book-mockup:hover img {
    transform: rotateY(-5deg) rotateX(5deg) scale(1.05);
}

/* Character Animation */
.character-container {
    animation: float 6s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-20px); }
}

.magic-glow {
    animation: pulse 4s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.2; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(1.1); }
}

/* Book Showcase Glow */
.book-glow {
    animation: bookGlow 3s ease-in-out infinite alternate;
}

@keyframes bookGlow {
    0% { opacity: 0.3; transform: scale(1); }
    100% { opacity: 0.5; transform: scale(1.05); }
}

/* Treasure Container Animation */
.treasure-container {
    animation: treasure 4s ease-in-out infinite;
}

@keyframes treasure {
    0%, 100% { transform: translateY(0px) scale(1); }
    50% { transform: translateY(-10px) scale(1.02); }
}

.treasure-glow {
    animation: treasureGlow 2s ease-in-out infinite alternate;
}

@keyframes treasureGlow {
    0% { opacity: 0.4; }
    100% { opacity: 0.6; }
}

/* Newsletter Form Styling */
#newsletter-form input:focus {
    transform: scale(1.02);
    box-shadow: 0 0 20px rgba(246, 176, 54, 0.3);
}

#newsletter-form button {
    transition: all 0.3s ease;
}

#newsletter-form button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(26, 26, 64, 0.3);
}

/* Scroll Animations */
.fade-in-up {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.6s ease;
}

.fade-in-up.active {
    opacity: 1;
    transform: translateY(0);
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    .hero-section {
        background-attachment: scroll;
    }
    
    .book-mockup img {
        max-width: 280px;
    }
    
    .character-container img {
        max-width: 200px;
    }
    
    .treasure-container img {
        max-width: 250px;
    }
    
    /* Reduce animation intensity on mobile for performance */
    .character-container {
        animation: floatMobile 4s ease-in-out infinite;
    }
    
    @keyframes floatMobile {
        0%, 100% { transform: translateY(0px); }
        50% { transform: translateY(-10px); }
    }
}

/* Accessibility Improvements */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .stars,
    .stars-bg {
        animation: none;
        background: none;
    }
}

/* Focus States for Accessibility */
a:focus,
button:focus,
input:focus {
    outline: 3px solid #F6B036;
    outline-offset: 2px;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .value-card {
        border: 2px solid #000;
    }
    
    .text-gray-200 {
        color: #fff !important;
    }
    
    .text-gray-300 {
        color: #fff !important;
    }
}

/* Print Styles */
@media print {
    .stars,
    .stars-bg,
    .magic-glow,
    .book-glow,
    .treasure-glow {
        display: none;
    }
    
    * {
        background: white !important;
        color: black !important;
    }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #F6B036;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #e09e2a;
}

/* Section Dividers */
.section-divider {
    height: 2px;
    background: linear-gradient(90deg, transparent, #F6B036, transparent);
    margin: 2rem 0;
}

/* Text Selection */
::selection {
    background-color: #F6B036;
    color: #1A1A40;
}

::-moz-selection {
    background-color: #F6B036;
    color: #1A1A40;
}

/* Additional Responsive Improvements */
@media (max-width: 640px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    h1 {
        font-size: 2rem !important;
        line-height: 1.2 !important;
    }
    
    h2 {
        font-size: 1.75rem !important;
        line-height: 1.3 !important;
    }
    
    .text-4xl {
        font-size: 2rem !important;
    }
    
    .text-5xl {
        font-size: 2.5rem !important;
    }
}