/* ============================================
   BASE — Variables, Reset, Typography, Utilities, Animations
   ============================================
   
   UPDATED: Aligned with Masaha Order Platform design system.
   - Primary color: #EA4526 (deeper, more refined)
   - Fonts: Plus Jakarta Sans (display) + DM Sans (body)
   - Shadows: Layered system matching Order platform
   - Background: #F5F6FA (blue-tinted neutral)
   - Precise gray ramp (Tailwind-style)
   - Named cubic-bezier easing curves
   - Pill-shaped buttons with gradient + shimmer
   ============================================ */

/* ── CSS Variables (Aligned with Order Platform) ─── */
:root {
    /* Brand Colors — Masaha Red */
    --primary-color: #EA4526;
    --primary-dark: #D63B1E;
    --primary-hover: #D63B1E;
    --primary-light: #FF6B4F;
    --primary-lighter: #FF8A74;
    --primary-50: rgba(234, 69, 38, 0.05);
    --primary-100: rgba(234, 69, 38, 0.10);
    --primary-150: rgba(234, 69, 38, 0.15);
    --primary-200: rgba(234, 69, 38, 0.20);
    --primary-glow: rgba(234, 69, 38, 0.18);
    --primary-ghost: rgba(234, 69, 38, 0.06);

    /* Gradient Presets */
    --gradient-primary: linear-gradient(135deg, #EA4526 0%, #FF6B4F 100%);
    --gradient-primary-hover: linear-gradient(135deg, #D63B1E 0%, #EA4526 100%);
    --gradient-brand: linear-gradient(135deg, #EA4526 0%, #FF8A74 50%, #EA4526 100%);
    --gradient-shimmer: linear-gradient(90deg, #EA4526 0%, #FF6B4F 50%, #EA4526 100%);
    --gradient-ambient: 
        radial-gradient(ellipse at 20% 50%, rgba(234,69,38,0.06) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 20%, rgba(59,130,246,0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(234,69,38,0.03) 0%, transparent 50%);

    /* Secondary / Accent */
    --secondary-color: #2c3e50;
    --accent-color: #3B82F6;
    --accent-light: #60A5FA;

    /* Semantic Colors */
    --success-color: #10B981;
    --success-dark: #059669;
    --success-light: #34D399;
    --success-ghost: rgba(16, 185, 129, 0.08);
    --warning-color: #F59E0B;
    --warning-dark: #D97706;
    --warning-ghost: rgba(245, 158, 11, 0.08);
    --danger-color: #EF4444;
    --danger-dark: #DC2626;
    --danger-ghost: rgba(239, 68, 68, 0.08);
    --info-color: #3B82F6;
    --info-dark: #2563EB;
    --info-ghost: rgba(59, 130, 246, 0.08);

    /* Frost (AC / Climate) */
    --frost-color: #0EA5E9;
    --frost-ghost: rgba(14, 165, 233, 0.06);

    /* Neutral Scale — Full Gray Ramp */
    --gray-25: #FCFCFD;
    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-150: #ECEDF0;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;
    --gray-900: #111827;
    --gray-950: #0B0F19;

    /* Surfaces & Backgrounds */
    --background-color: #F5F6FA;
    --bg-subtle: #FAFBFE;
    --card-bg: #FFFFFF;
    --surface: #FFFFFF;
    --surface-raised: #FFFFFF;
    --surface-overlay: rgba(255, 255, 255, 0.96);
    --surface-glass: rgba(255, 255, 255, 0.72);
    --dark-bg: #111827;
    --backdrop: rgba(15, 23, 42, 0.5);

    /* Text Colors */
    --text-primary: #1F2937;
    --text-secondary: #4B5563;
    /* FIX: Improved contrast — was #6B7280 (4.48:1), now #57606A (5.0:1+) */
    --text-light: #57606A;
    --text-white: #ffffff;
    --text-muted: #57606A;

    /* Borders */
    --border-color: #E5E7EB;
    --border-light: #F3F4F6;
    --border-strong: #D1D5DB;

    /* Input */
    --input-bg: #F9FAFB;
    --input-focus: #FFFFFF;
    --input-border: #E5E7EB;
    --input-border-focus: #EA4526;
    --input-ring: 0 0 0 4px rgba(234, 69, 38, 0.18);

    /* Shadows — Layered System */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06),
                 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.07),
              0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.08),
                 0 4px 6px -4px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.08),
                 0 8px 10px -6px rgba(0, 0, 0, 0.03);
    --shadow-xl: 0 25px 50px -12px rgba(0, 0, 0, 0.18);
    --shadow-hover: 0 8px 30px rgba(0, 0, 0, 0.08),
                    0 0 0 1px rgba(234, 69, 38, 0.06);
    --shadow-primary: 0 4px 14px rgba(234, 69, 38, 0.25);
    --shadow-primary-lg: 0 10px 30px rgba(234, 69, 38, 0.3);
    --shadow-primary-glow: 0 0 20px rgba(234, 69, 38, 0.15),
                            0 0 60px rgba(234, 69, 38, 0.05);
    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.04),
                   0 4px 12px rgba(0, 0, 0, 0.03);
    --shadow-card-hover: 0 8px 30px rgba(0, 0, 0, 0.08),
                         0 0 0 1px rgba(234, 69, 38, 0.06);

    /* Border Radius — Refined Scale */
    --border-radius-xs: 4px;
    --border-radius-sm: 6px;
    --border-radius: 8px;
    --border-radius-md: 10px;
    --border-radius-lg: 14px;
    --border-radius-xl: 18px;
    --border-radius-2xl: 24px;
    --border-radius-3xl: 32px;
    --border-radius-full: 9999px;

    /* Easing Curves */
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-in: cubic-bezier(0.4, 0, 1, 1);
    --ease-out: cubic-bezier(0, 0, 0.2, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);

    /* Durations */
    --dur-instant: 100ms;
    --dur-fast: 150ms;
    --dur: 250ms;
    --dur-slow: 400ms;

    /* Transitions */
    --transition-fast: all 150ms var(--ease);
    --transition: all 250ms var(--ease);
    --transition-slow: all 400ms var(--ease);
    --transition-spring: all 400ms var(--ease-spring);
    --transition-color: color 150ms var(--ease), background-color 150ms var(--ease);
    --transition-shadow: box-shadow 250ms var(--ease);

    /* Typography — Premium Font Stack */
    --font-primary: 'Plus Jakarta Sans', 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-secondary: 'Plus Jakarta Sans', 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-body: 'DM Sans', 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    /* Type Scale */
    --text-xs: 0.75rem;
    --text-sm: 0.8125rem;
    --text-base: 0.9375rem;
    --text-md: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.75rem;
    --text-4xl: 2.25rem;
    --text-5xl: 3rem;

    /* Font Weights */
    --weight-regular: 400;
    --weight-medium: 500;
    --weight-semibold: 600;
    --weight-bold: 700;
    --weight-extrabold: 800;
}

/* RTL Font Override */
html[dir="rtl"],
html[lang="ar"],
.is-rtl {
    --font-primary: 'Cairo', 'Noto Kufi Arabic', 'Tajawal', 'Plus Jakarta Sans', sans-serif;
    --font-secondary: 'Cairo', 'Noto Kufi Arabic', 'Tajawal', 'Plus Jakarta Sans', sans-serif;
    --font-body: 'Cairo', 'Noto Kufi Arabic', 'Tajawal', 'DM Sans', sans-serif;
}

/* ── Reset ─────────────────────────────────── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    height: 100%;
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body, html {
    overflow-x: hidden;
}

body {
    background-color: var(--background-color);
    font-family: var(--font-body);
    line-height: 1.65;
    font-size: var(--text-base);
    min-height: 100%;
    color: var(--text-primary);
    position: relative;
}

section {
    padding: 100px 0;
    overflow: hidden;
    position: relative;
}

.container {
    padding: 0 20px;
}

/* ── Typography ────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-primary);
    font-weight: var(--weight-bold);
    line-height: 1.35;
    color: var(--gray-900);
    letter-spacing: -0.02em;
}

h1 { font-size: var(--text-4xl); font-weight: var(--weight-extrabold); letter-spacing: -0.03em; }
h2 { font-size: var(--text-2xl); font-weight: var(--weight-extrabold); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }

p {
    margin-bottom: 1.5rem;
    line-height: 1.65;
}

a {
    color: var(--primary-color);
    transition: color var(--dur-fast) var(--ease);
    text-decoration: none;
}

a:focus, a:hover {
    color: var(--primary-dark);
    text-decoration: none;
}

/* FIX: Accessibility — ensure inline content links are distinguishable */
main p a,
main li a,
.faq-answer a,
.footer-contact-text a {
    text-decoration: underline;
    text-underline-offset: 2px;
    text-decoration-thickness: 1px;
}
main p a:hover,
main li a:hover,
.faq-answer a:hover,
.footer-contact-text a:hover {
    text-decoration-thickness: 2px;
}

strong, b { font-weight: var(--weight-semibold); }

/* Autofill override */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 30px var(--surface) inset !important;
    -webkit-text-fill-color: var(--gray-800) !important;
}

::selection {
    background: var(--primary-200);
    color: var(--gray-900);
}

/* Custom scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: var(--border-radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ── Utilities ─────────────────────────────── */
.hidden {
    position: absolute;
    opacity: 0;
    visibility: hidden;
}

/* FIX: Bootstrap visually-hidden fallback for screen readers */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.btn-reset {
    border: none;
    background: transparent;
    outline: 0;
    padding: 0;
    margin: 0;
}

.skip-to-content {
    position: absolute;
    top: -60px;
    left: 0;
    padding: 12px 24px;
    background: var(--primary-color);
    color: #fff;
    font-weight: var(--weight-semibold);
    z-index: 1100;
    transition: top var(--dur) var(--ease);
    border-radius: 0 0 var(--border-radius-md) 0;
    font-size: var(--text-sm);
}

.skip-to-content:focus {
    top: 0;
    color: #fff;
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* Focus states — keyboard navigation */
:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.navbar-toggler:focus, input:focus, select:focus, textarea:focus {
    outline: 0;
    box-shadow: none;
}

/* Cursor helpers */
.back-to-top,
.faq-question,
.form-submit,
.gallery-nav-btn,
.hamburger,
.hero-image,
.mouse-scroll,
.section-dot,
.toast-close,
button {
    cursor: pointer;
}

/* Section title */
.section-title {
    text-align: center;
    margin-bottom: 70px;
    position: relative;
}

.section-title h2 {
    font-size: var(--text-4xl);
    font-weight: var(--weight-extrabold);
    margin-bottom: 1rem;
    color: var(--gray-900);
    letter-spacing: -0.03em;
}

.section-title p {
    font-size: var(--text-md);
    color: var(--text-secondary);
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.65;
}

.section-title::after {
    content: '';
    position: absolute;
    width: 60px;
    height: 4px;
    background: var(--gradient-primary);
    bottom: -15px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: var(--border-radius-full);
}

/* Scroll progress bar */
.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0;
    height: 3px;
    background: var(--gradient-primary);
    z-index: 1500;
    transition: width 0.1s;
    box-shadow: 0 1px 3px rgba(234, 69, 38, 0.3);
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--surface-overlay);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity var(--dur) var(--ease), visibility var(--dur) var(--ease);
}

.loader {
    width: 48px;
    height: 48px;
    border: 4px solid var(--primary-100);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 0.8s linear infinite;
}

.loading-text {
    position: absolute;
    bottom: calc(50% - 50px);
    color: var(--text-secondary);
    font-weight: var(--weight-medium);
    letter-spacing: 0.02em;
    margin-top: 20px;
    font-size: var(--text-base);
}

/* Lazy load */
.lazy-load {
    opacity: 1;
    transition: opacity 0.5s;
}

.lazy-load.loaded {
    opacity: 1;
}

/* ── Keyframe Animations ───────────────────── */
@keyframes pulse {
    0%   { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
    70%  { box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-16px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes scroll {
    0%   { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(20px); }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-20px); }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes fadeEffect {
    from { opacity: 0.7; transform: scale(0.95); }
    to   { opacity: 1; transform: scale(1); }
}

@keyframes pulse-icon {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.1); }
}

@keyframes float-circle {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-20px); }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.92); }
    to   { opacity: 1; transform: scale(1); }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Reduced motion */
@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 */
@media (prefers-contrast: high) {
    :root {
        --border-color: #000000;
        --border-light: #333333;
        --shadow-card: none;
        --shadow-card-hover: 0 0 0 2px #000000;
    }
}