/*
 * ============================================================================
 * BrainyGaming Stylesheet
 * ============================================================================
 * ya zalameh: this is organized like a pro, don't mess it up
 * 
 * TABLE OF CONTENTS:
 * 1. CSS Variables
 * 2. Base & Reset
 * 3. Typography
 * 4. Layout (Container, Grid, Spacing)
 * 5. Components
 *    5.1 Buttons
 *    5.2 Cards
 *    5.3 Forms
 *    5.4 Navigation & Header
 *    5.5 Footer
 *    5.6 Modals
 *    5.7 Cookie Banner
 * 6. Utilities
 * 7. Animations
 * 8. RTL Support
 * 9. Responsive & Media Queries
 * 10. Accessibility
 * ============================================================================
 */


/* ============================================================================
   1. CSS VARIABLES
   ============================================================================ */
/* shuf: all design tokens in one place, makes theming a breeze */
:root {
    /* Colors */
    --primary: #3E76F7;
    --primary-hover: #2D5ED6;
    --soft-blue: #E0E9FD;
    --mint: #DAF2E9;
    --white: #FFFFFF;
    --bg-page: #F8FAFF;
    --text-main: #0F172A;
    --text-muted: #64748B;
    --border: #E5E7EB;

    /* Shadows */
    --card-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.05);

    /* Border Radius - mashy: consistent rounding everywhere */
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 32px;

    /* Transitions - ya 3adi: keep it on transform/opacity, layout animations are a headache */
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    /* Animation Tokens */
    --anim-fast: 0.2s;
    --anim-normal: 0.4s;
    --anim-slow: 0.8s;
    --ease-out-expo: cubic-bezier(0.19, 1, 0.22, 1);
    --ease-in-out-cubic: cubic-bezier(0.645, 0.045, 0.355, 1);

    /* Layout */
    --header-height: 80px;
    --container-max: 1280px;

    /* Spacing Scale - mashy: this is the main spacing scale, don't freestyle it */
    --space-4: 4px;
    --space-8: 8px;
    --space-12: 12px;
    --space-16: 16px;
    --space-24: 24px;
    --space-32: 32px;
    --space-48: 48px;
    --space-64: 64px;
}


/* ============================================================================
   2. BASE & RESET
   ============================================================================ */
/* khalas: clean slate for consistent rendering */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-page);
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
}


/* ============================================================================
   3. TYPOGRAPHY
   ============================================================================ */
h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--text-main);
    line-height: 1.2;
    margin-bottom: 1rem;
    font-weight: 700;
}

h1 {
    font-size: 3.5rem;
    letter-spacing: -0.02em;
}

h2 {
    font-size: 2.5rem;
    letter-spacing: -0.01em;
}

h3 {
    font-size: 1.75rem;
}

h4 {
    font-size: 1.25rem;
}

p {
    margin-bottom: 1.5rem;
    color: var(--text-muted);
}

a {
    color: inherit;
    text-decoration: none;
}


/* ============================================================================
   4. LAYOUT (Container, Grid, Spacing)
   ============================================================================ */
.container {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 1.5rem;
}

.section {
    padding: 100px 0;
}

.grid {
    display: grid;
    gap: 2rem;
}

/* Spacing utilities - 3adi: use these instead of random margins */
.mb-4 {
    margin-bottom: 1rem;
}

.mb-8 {
    margin-bottom: 2rem;
}

.mt-8 {
    margin-top: 2rem;
}

.py-20 {
    padding-top: 5rem;
    padding-bottom: 5rem;
}


/* ============================================================================
   5. COMPONENTS
   ============================================================================ */

/* 5.1 Buttons - shuf: all button styles in one place */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.875rem 2rem;
    border-radius: var(--radius-lg);
    font-weight: 600;
    text-decoration: none;
    transition: var(--transition);
    cursor: pointer;
    border: none;
    font-size: 1rem;
    font-family: inherit;
}

.btn-primary {
    background-color: var(--primary);
    color: var(--white);
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(62, 118, 247, 0.3);
}

.btn-secondary {
    background-color: var(--soft-blue);
    color: var(--primary);
}

.btn-secondary:hover,
.btn-secondary:focus {
    background-color: #d0defb;
    transform: translateY(-2px);
}

/* 5.2 Cards */
.card {
    background: var(--white);
    padding: 2.5rem;
    border-radius: var(--radius-md);
    box-shadow: var(--card-shadow);
    transition: var(--transition);
    border: 1px solid var(--border);
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

/* 5.3 Forms */
input[type="text"],
input[type="email"],
input[type="password"],
textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 1rem;
    transition: var(--transition);
    background-color: var(--white);
    color: var(--text-main);
}

/* mashy: better placeholder contrast */
input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}

input:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(62, 118, 247, 0.1);
    background-color: var(--white);
}

/* 5.4 Navigation & Header */
header {
    height: var(--header-height);
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    transition: var(--transition);
}

header.scrolled,
header.is-scrolled {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    background: rgba(255, 255, 255, 0.95);
    height: 70px;
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--text-main);
}

/* mashy: logo image sizing - keep it reasonable */
.logo img {
    height: 40px;
    width: auto;
    object-fit: contain;
}

/* Footer logo sizing - slightly larger */
footer .logo img {
    height: 48px;
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 2.5rem;
    align-items: center;
}

.nav-links a {
    color: var(--text-muted);
    font-weight: 500;
    transition: var(--transition);
}

.nav-links a:hover,
.nav-links a:focus {
    color: var(--primary);
}

.header-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-main);
}

/* 5.5 Footer */
footer {
    background: var(--white);
    border-top: 1px solid var(--border);
    padding: 80px 0 40px;
}

.footer-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1.5fr;
    gap: 4rem;
    margin-bottom: 4rem;
}

.footer-brand {
    display: flex;
    flex-direction: column;
}

.footer-links {
    list-style: none;
}

.footer-links li {
    margin-bottom: 1rem;
}

.footer-links a {
    color: var(--text-muted);
    transition: var(--transition);
}

.footer-links a:hover,
.footer-links a:focus {
    color: var(--primary);
}

.footer-bottom {
    margin-top: 60px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.footer-legal {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.footer-legal a {
    color: var(--text-muted);
    font-size: 0.875rem;
    transition: var(--transition);
}

.footer-legal a:hover,
.footer-legal a:focus {
    color: var(--primary);
}

.footer-legal button {
    background: none;
    border: none;
    padding: 0;
    color: var(--text-muted);
    font-size: 0.875rem;
    cursor: pointer;
    text-decoration: underline;
    font-family: inherit;
}

.footer-legal button:hover,
.footer-legal button:focus {
    color: var(--primary);
}

/* Social icons placeholder */
.socials {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.social-icon {
    width: 32px;
    height: 32px;
    background: var(--soft-blue);
    border-radius: 50%;
    display: inline-block;
}

/* Newsletter form */
.newsletter-form {
    display: flex;
    gap: 0.5rem;
}

.newsletter-form input {
    flex: 1;
}

.newsletter-form button {
    padding: 0.5rem 1rem;
}

/* Footer attribution - mashy: credit where credit is due */
.footer-attribution {
    margin-left: 1rem;
    opacity: 0.8;
    font-size: 0.875rem;
}

.footer-attribution a {
    color: var(--primary);
    font-weight: 500;
}

.footer-attribution a:hover,
.footer-attribution a:focus {
    text-decoration: underline;
}

/* Footer visibility override - mashy: ensure footer is always visible */
/* khalas: footer is loaded dynamically via include.js AFTER IntersectionObserver runs,
   so reveal animation never triggers. Force footer to be visible. */
footer.section,
footer .container,
footer .footer-brand {
    opacity: 1 !important;
    transform: none !important;
    visibility: visible !important;
}


/* 5.6 Modals - khalas: reusable modal system */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--anim-normal) var(--ease-out-expo),
        visibility var(--anim-normal);
}

.modal-backdrop.is-active {
    opacity: 1;
    visibility: visible;
}

.modal-dialog {
    background: var(--white);
    border-radius: var(--radius-md);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    padding: 2.5rem;
    transform: scale(0.9) translateY(20px);
    transition: transform var(--anim-normal) var(--ease-out-expo);
}

.modal-backdrop.is-active .modal-dialog {
    transform: scale(1) translateY(0);
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
    z-index: 10;
}

.modal-close:hover,
.modal-close:focus {
    color: var(--text-main);
    background: var(--bg-page);
}

.modal-content {
    text-align: center;
}

.modal-illust {
    margin-bottom: 1.5rem;
}

.modal-illust svg {
    display: block;
    margin: 0 auto;
}

.modal-subtitle {
    font-size: 1.125rem;
    margin-bottom: 2rem;
}

.modal-highlights {
    list-style: none;
    padding: 0;
    margin-bottom: 2.5rem;
    text-align: left;
    display: inline-block;
}

.modal-highlights li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    font-size: 0.9375rem;
}

.modal-highlights li::before {
    content: "✓";
    color: var(--primary);
    font-weight: 700;
    font-size: 1.125rem;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.modal-disclaimer {
    margin-top: 1.5rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

/* Checkbox for "Don't show again" */
.checkbox-container {
    display: block;
    position: relative;
    padding-left: 28px;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-muted);
    user-select: none;
}

.checkbox-container input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    position: absolute;
    left: 0;
    height: 18px;
    width: 18px;
    background-color: var(--white);
    border: 2px solid var(--border);
    border-radius: 4px;
    transition: all 0.2s;
}

.checkbox-container:hover input~.checkmark {
    border-color: var(--primary);
}

.checkbox-container input:checked~.checkmark {
    background-color: var(--primary);
    border-color: var(--primary);
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

.checkbox-container input:checked~.checkmark:after {
    display: block;
}

.checkbox-container .checkmark:after {
    left: 5px;
    top: 2px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* 5.7 Cookie Banner - shuf: GDPR compliance, no spam */
.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--white);
    border-top: 1px solid var(--border);
    padding: 1.5rem;
    box-shadow: 0 -10px 25px rgba(0, 0, 0, 0.05);
    z-index: 3000;
    transform: translateY(100%);
    opacity: 0;
    transition: transform var(--anim-normal) var(--ease-out-expo),
        opacity var(--anim-normal);
}

.cookie-banner.is-visible {
    transform: translateY(0);
    opacity: 1;
}

.cookie-banner-container {
    max-width: var(--container-max);
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
}

.cookie-banner-content h3 {
    margin-bottom: 0.5rem;
    font-size: 1.125rem;
}

.cookie-banner-content p {
    margin-bottom: 0;
    font-size: 0.9375rem;
}

.cookie-banner-content a {
    color: var(--primary);
    text-decoration: underline;
}

.cookie-banner-actions {
    display: flex;
    gap: 0.75rem;
    flex-shrink: 0;
}

/* Consent Modal Specific Styles */
.consent-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    margin-bottom: 1rem;
    background: var(--bg-page);
    border-radius: var(--radius-sm);
    text-align: left;
}

.consent-info h4 {
    margin-bottom: 0.25rem;
    font-size: 1rem;
}

.consent-info p {
    font-size: 0.8125rem;
    margin-bottom: 0;
    color: var(--text-muted);
}

/* Switch Toggle - mashy: clean toggle design */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider-toggle {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border);
    transition: 0.3s;
    border-radius: 24px;
}

.slider-toggle:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.switch input:checked+.slider-toggle {
    background-color: var(--primary);
}

.switch input:checked+.slider-toggle:before {
    transform: translateX(20px);
}

.switch input:disabled+.slider-toggle {
    opacity: 0.5;
    cursor: not-allowed;
}


/* ============================================================================
   6. UTILITIES
   ============================================================================ */
.text-center {
    text-align: center;
}

.text-left {
    text-align: left;
}

.text-right {
    text-align: right;
}

/* Visibility utilities */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Language visibility - khalas: show/hide based on lang attribute */
[lang="ar"] .lang-en {
    display: none !important;
}

[lang="en"] .lang-ar {
    display: none !important;
}

:not([lang="ar"]) .lang-ar {
    display: none !important;
}

/* Hover effects */
.hover-lift {
    transition: var(--transition);
}

.hover-lift:hover {
    transform: translateY(-3px);
}

.pulse-primary {
    animation: pulse-ring 2s cubic-bezier(0.455, 0.03, 0.515, 0.955) infinite;
}


/* ============================================================================
   7. ANIMATIONS
   ============================================================================ */
/* ya 3adi: smooth animations, nothing crazy */

@keyframes pulse-ring {
    0% {
        box-shadow: 0 0 0 0 rgba(62, 118, 247, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(62, 118, 247, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(62, 118, 247, 0);
    }
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-20px);
    }
}

@keyframes blob {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    33% {
        transform: translate(30px, -50px) scale(1.1);
    }

    66% {
        transform: translate(-20px, 20px) scale(0.9);
    }
}

@keyframes slide-in-bottom {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Scroll Reveal - shuf: elements fade in as you scroll */
.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s var(--ease-out-expo),
        transform 0.8s var(--ease-out-expo);
}

.reveal.active {
    opacity: 1;
    transform: translateY(0);
}

/* Decorative background circles */
.bg-circles {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    z-index: -1;
    pointer-events: none;
}

.circle {
    position: absolute;
    border-radius: 50%;
    opacity: 0.4;
    filter: blur(60px);
}

.circle-1 {
    width: 400px;
    height: 400px;
    background: var(--soft-blue);
    top: -100px;
    right: -100px;
    animation: blob 20s infinite alternate var(--ease-in-out-cubic);
}

.circle-2 {
    width: 300px;
    height: 300px;
    background: var(--mint);
    bottom: 10%;
    left: -50px;
    animation: blob 25s infinite alternate-reverse var(--ease-in-out-cubic);
}

.hero-media {
    animation: float 6s infinite ease-in-out;
}

/* FAQ Accordion animation */
.faq-item i {
    transition: transform var(--anim-normal) var(--ease-out-expo);
}

.faq-item.active i {
    transform: rotate(180deg);
}


/* ============================================================================
   8. RTL SUPPORT
   ============================================================================ */
/* mashy: proper Arabic support, respect the direction */
[dir="rtl"] {
    font-family: 'Cairo', sans-serif;
}

[dir="rtl"] .logo {
    flex-direction: row-reverse;
}

[dir="rtl"] .btn i {
    margin-left: 0;
    margin-right: 0.5rem;
}

[dir="rtl"] .modal-highlights {
    text-align: right;
}

[dir="rtl"] .checkbox-container {
    padding-left: 0;
    padding-right: 28px;
}

[dir="rtl"] .checkmark {
    left: auto;
    right: 0;
}


/* ============================================================================
   9. RESPONSIVE & MEDIA QUERIES
   ============================================================================ */
/* shuf: mobile-first approach, scales beautifully */

@media (max-width: 1024px) {
    h1 {
        font-size: 2.5rem;
    }

    h2 {
        font-size: 2rem;
    }

    .section {
        padding: 60px 0;
    }

    .footer-grid {
        grid-template-columns: 1fr 1fr;
        gap: 2rem;
    }
}

@media (max-width: 768px) {
    h1 {
        font-size: 2rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    .nav-links {
        position: fixed;
        top: var(--header-height);
        left: 0;
        right: 0;
        background: var(--white);
        flex-direction: column;
        padding: 2rem;
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
        display: none;
        gap: 1.5rem;
    }

    .nav-links.active {
        display: flex;
    }

    .mobile-menu-toggle {
        display: block;
    }

    .footer-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .footer-bottom {
        flex-direction: column;
        align-items: flex-start;
        gap: 1.5rem;
    }

    .cookie-banner-container {
        flex-direction: column;
        align-items: flex-start;
        gap: 1.5rem;
    }

    .cookie-banner-actions {
        width: 100%;
        flex-direction: column;
    }

    .cookie-banner-actions .btn {
        width: 100%;
        font-size: 0.875rem;
        padding: 0.75rem 1rem;
    }

    .modal-dialog {
        width: 95%;
        padding: 2rem 1.5rem;
        max-height: 95vh;
    }

    /* Mobile bottom sheet style for modals */
    .modal-backdrop {
        align-items: flex-end;
    }

    .modal-backdrop.is-active .modal-dialog {
        border-radius: var(--radius-md) var(--radius-md) 0 0;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.75rem;
    }

    .container {
        padding: 0 1rem;
    }

    .btn {
        padding: 0.75rem 1.5rem;
        font-size: 0.9375rem;
    }
}


/* ============================================================================
   10. ACCESSIBILITY
   ============================================================================ */
/* khalas: make it accessible for everyone, no excuses */

.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary);
    color: white;
    padding: 8px 16px;
    z-index: 10000;
    transition: top 0.3s;
    text-decoration: none;
    border-radius: 0 0 4px 0;
    font-weight: 600;
}

.skip-link:focus {
    top: 0;
    outline: 2px solid var(--primary-hover);
    outline-offset: 2px;
}

/* Focus states - shuf: keyboard navigation needs love too */
*:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

button:focus,
a:focus,
input:focus,
textarea:focus,
select:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Reduce motion for accessibility - ya zalameh: respect user preferences */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-delay: -1ms !important;
        animation-duration: 1ms !important;
        animation-iteration-count: 1 !important;
        background-attachment: initial !important;
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        transition-delay: 0ms !important;
    }

    .modal-backdrop,
    .modal-dialog,
    .cookie-banner {
        transition: none !important;
        animation: none !important;
    }
}