/* ═══════════════════════════════════════════════════════════
   Hsoub Freelance — Design System v2 (upgrade layer)
   Modern, elegant, CRO + performance driven.
   Loads AFTER style.css so overrides cascade predictably.
   ═══════════════════════════════════════════════════════════ */

/* ═══ Design Tokens ═══ */
:root {
    --bg: #f6f7fb;
    --bg-card: #ffffff;
    --bg-header: #14161c;
    --bg-input: #f1f3f8;
    --text: #16181d;
    --text-secondary: #5b6472;
    --text-header: #ffffff;
    --border: #e6e8ee;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --accent: #7c3aed;
    --action: #10b981;
    --action-hover: #059669;
    --khamsat: #f3ad2d;
    --khamsat-bg: #fef3c7;
    --mostaql: #2caae2;
    --mostaql-bg: #e0f2fe;
    --danger: #ef4444;
    --success: #22c55e;
    --shadow: 0 1px 3px rgba(16, 24, 40, 0.06);
    --shadow-lg: 0 14px 40px rgba(16, 24, 40, 0.13);
    --radius: 14px;
    --radius-sm: 10px;
    --header-h: 72px;
}

[data-theme="dark"] {
    --bg: #0e1014;
    --bg-card: #171a21;
    --bg-header: #0a0c10;
    --bg-input: #1f232c;
    --text: #e7eaf0;
    --text-secondary: #9aa3b2;
    --text-header: #ffffff;
    --border: #272c37;
    --primary: #818cf8;
    --primary-hover: #a5b4fc;
    --accent: #a78bfa;
    --action: #34d399;
    --action-hover: #10b981;
    --khamsat-bg: #2d2510;
    --mostaql-bg: #0c1f2e;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 14px 40px rgba(0, 0, 0, 0.5);
}

/* ═══ Base Typography ═══ */
html {
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: "Cairo", "Segoe UI", Tahoma, Arial, sans-serif;
    font-size: 15px;
    letter-spacing: 0.005em;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

img {
    max-width: 100%;
    height: auto;
}

/* ═══ Focus visibility (a11y) ═══ */
:focus-visible {
    outline: 3px solid rgba(79, 70, 229, 0.45);
    outline-offset: 2px;
    border-radius: 6px;
}

/* ═══ Header refinement ═══ */
.header {
    background: linear-gradient(135deg, #14161c 0%, #2d1b69 55%, #14161c 100%);
    padding: 12px 24px;
}

[data-theme="dark"] .header {
    background: linear-gradient(135deg, #0a0c10 0%, #241557 55%, #0a0c10 100%);
}

.header-content {
    max-width: 1280px;
}

/* ═══ Quote banner ═══ */
.quote-banner {
    background: linear-gradient(90deg, #2d1b69, #4f46e5, #2d1b69);
    padding: 14px 24px;
}

.quote-icon {
    font-size: 18px;
    opacity: 0.6;
    margin-inline-end: 10px;
    vertical-align: middle;
}

.quote-text {
    font-size: 15px;
    font-weight: 600;
}

.quote-author {
    display: block;
    margin-top: 4px;
    font-size: 13px;
    opacity: 0.85;
}

/* ═══ Layout & ads ═══ */
.layout {
    max-width: 1720px;
}

.main {
    padding: 24px 0;
}

.ad-slot {
    border-radius: 16px;
}

/* ═══ Stats polish ═══ */
.stats-bar {
    gap: 16px;
    margin-bottom: 22px;
}

.stat-item {
    border-radius: var(--radius);
    padding: 22px 16px;
    box-shadow: var(--shadow);
}

.stat-item:hover {
    box-shadow: var(--shadow-lg);
}

.stat-value {
    font-size: 30px;
}

/* ═══ Tabs ═══ */
.tabs {
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.tab {
    font-weight: 600;
}

.tab.active {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.35);
}

.tab.active:hover {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
}

/* ═══ Filters ═══ */
.filters-bar {
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.search-box input:focus,
.form-input:focus,
.form-input:focus-visible {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.14);
}

.cat-pill.active {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.3);
}

.cat-pill:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(79, 70, 229, 0.06);
}

.today-switch input:checked + .switch-track {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
}

/* ═══ Cards ═══ */
.card {
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.card:hover {
    border-color: rgba(79, 70, 229, 0.4);
    box-shadow: 0 10px 34px rgba(79, 70, 229, 0.14);
}

.card-title {
    font-size: 15.5px;
}

/* ═══ Buttons ═══ */
.btn-primary {
    padding: 12px 22px;
    border-radius: 12px;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    box-shadow: 0 6px 18px rgba(79, 70, 229, 0.32);
    font-weight: 700;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #4338ca, #6d28d9);
    box-shadow: 0 10px 26px rgba(79, 70, 229, 0.45);
    transform: translateY(-2px);
}

.btn-page:hover:not(:disabled) {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
}

/* ═══ Hero (above the fold) ═══ */
.hero {
    padding: 58px 24px 50px;
    background:
        radial-gradient(900px 400px at 10% -12%, rgba(79, 70, 229, 0.15), transparent 60%),
        radial-gradient(820px 420px at 90% -12%, rgba(124, 58, 237, 0.13), transparent 60%),
        radial-gradient(500px 300px at 50% 115%, rgba(16, 185, 129, 0.08), transparent 60%),
        linear-gradient(180deg, #ffffff 0%, #f6f7fb 100%);
}

[data-theme="dark"] .hero {
    background:
        radial-gradient(900px 400px at 10% -12%, rgba(79, 70, 229, 0.22), transparent 60%),
        radial-gradient(820px 420px at 90% -12%, rgba(124, 58, 237, 0.2), transparent 60%),
        radial-gradient(500px 300px at 50% 115%, rgba(16, 185, 129, 0.1), transparent 60%),
        linear-gradient(180deg, #111318 0%, #0e1014 100%);
}

.hero-badge {
    background: rgba(16, 185, 129, 0.12);
    color: var(--action);
    border-color: rgba(16, 185, 129, 0.3);
}

[data-theme="dark"] .hero-badge {
    background: rgba(16, 185, 129, 0.16);
    color: #34d399;
}

.hero-title {
    color: var(--text);
}

.hero-sub {
    color: var(--text-secondary);
}

.hero-trust {
    color: var(--text-secondary);
}

/* ═══ Anchor scroll offset ═══ */
#results, #newsletter, #faq, #top {
    scroll-margin-top: 88px;
}

/* ═══ In-line CTA (after results) ═══ */
.inline-cta {
    padding: 8px 0 0;
}

.inline-cta-inner {
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.07), rgba(16, 185, 129, 0.07));
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 26px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.inline-cta-title {
    font-size: 19px;
    font-weight: 800;
    margin-bottom: 4px;
}

.inline-cta-text {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.7;
}

@media (max-width: 600px) {
    .inline-cta-inner {
        justify-content: center;
        text-align: center;
        padding: 24px 20px;
    }
}

/* ═══ Features / SEO content ═══ */
.features-section {
    padding: 48px 16px;
}

.features-inner {
    max-width: 1020px;
    margin: 0 auto;
}

.section-title {
    text-align: center;
    font-size: clamp(24px, 3.5vw, 32px);
    font-weight: 800;
    margin-bottom: 10px;
    line-height: 1.35;
}

.section-sub {
    text-align: center;
    color: var(--text-secondary);
    max-width: 640px;
    margin: 0 auto 30px;
    font-size: 15.5px;
    line-height: 1.8;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
}

.feature-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 28px 24px;
    box-shadow: var(--shadow);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s;
}

.feature-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.feature-icon {
    width: 50px;
    height: 50px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 19px;
    color: #fff;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    box-shadow: 0 8px 20px rgba(79, 70, 229, 0.3);
    margin-bottom: 16px;
}

.feature-title {
    font-size: 17px;
    font-weight: 800;
    margin-bottom: 8px;
}

.feature-text {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.8;
}

@media (max-width: 768px) {
    .features-grid {
        grid-template-columns: 1fr;
    }
}

/* ═══ FAQ ═══ */
.faq {
    padding: 8px 16px 40px;
}

.faq-inner {
    max-width: 820px;
    margin: 0 auto;
}

.faq-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.faq-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: border-color 0.2s;
}

.faq-item:hover {
    border-color: rgba(79, 70, 229, 0.35);
}

.faq-item summary {
    list-style: none;
    cursor: pointer;
    padding: 17px 20px;
    font-weight: 700;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 48px;
}

.faq-item summary::-webkit-details-marker {
    display: none;
}

.faq-item summary::after {
    content: "\f078";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: 13px;
    margin-right: auto;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    color: var(--primary);
    flex-shrink: 0;
}

.faq-item[open] summary::after {
    transform: rotate(180deg);
}

.faq-item p {
    padding: 0 20px 18px;
    color: var(--text-secondary);
    font-size: 14.5px;
    line-height: 1.9;
}

/* ═══ Newsletter (Next Step / CRO) ═══ */
.newsletter {
    padding: 20px 16px 60px;
}

.newsletter-inner {
    max-width: 760px;
    margin: 0 auto;
    text-align: center;
    background: linear-gradient(160deg, #4f46e5 0%, #7c3aed 60%, #0d9488 130%);
    border-radius: 24px;
    padding: 46px 32px;
    color: #fff;
    box-shadow: 0 26px 70px rgba(79, 70, 229, 0.28);
    position: relative;
    overflow: hidden;
}

.newsletter-inner::before,
.newsletter-inner::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
}

.newsletter-inner::before {
    width: 260px;
    height: 260px;
    top: -120px;
    right: -80px;
    background: rgba(255, 255, 255, 0.08);
}

.newsletter-inner::after {
    width: 180px;
    height: 180px;
    bottom: -90px;
    left: -60px;
    background: rgba(16, 185, 129, 0.18);
}

.newsletter-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 16px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.28);
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 18px;
    position: relative;
    z-index: 1;
}

.newsletter h2 {
    font-size: clamp(24px, 3.5vw, 32px);
    font-weight: 800;
    margin-bottom: 10px;
    position: relative;
    z-index: 1;
}

.newsletter-sub {
    color: rgba(255, 255, 255, 0.85);
    max-width: 480px;
    margin: 0 auto 26px;
    font-size: 15px;
    line-height: 1.8;
    position: relative;
    z-index: 1;
}

.newsletter-form {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    position: relative;
    z-index: 1;
}

.newsletter-field {
    position: relative;
    flex: 1;
    min-width: 260px;
    max-width: 380px;
}

.newsletter-field i {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.75);
    font-size: 15px;
    pointer-events: none;
}

.newsletter-field input {
    width: 100%;
    padding: 15px 46px 15px 16px;
    border-radius: 14px;
    border: 1.5px solid rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    font-family: inherit;
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
    min-height: 52px;
    direction: rtl;
}

.newsletter-field input::placeholder {
    color: rgba(255, 255, 255, 0.72);
}

.newsletter-field input:focus {
    border-color: #fff;
    background: rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.18);
}

.newsletter-field input.invalid {
    border-color: #fca5a5;
    box-shadow: 0 0 0 4px rgba(252, 165, 165, 0.25);
    animation: errorShake 0.4s ease;
}

.newsletter-form .btn-cta {
    min-height: 52px;
    padding: 14px 26px;
    box-shadow: 0 10px 26px rgba(5, 150, 105, 0.45);
}

.newsletter-note {
    color: rgba(255, 255, 255, 0.78);
    font-size: 12.5px;
    margin-top: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    position: relative;
    z-index: 1;
}

.newsletter-error {
    display: none;
    margin-top: 14px;
    padding: 10px 16px;
    background: rgba(239, 68, 68, 0.22);
    border: 1px solid rgba(252, 165, 165, 0.5);
    border-radius: 12px;
    font-size: 13.5px;
    font-weight: 600;
    color: #fecaca;
    position: relative;
    z-index: 1;
}

.newsletter-success {
    display: none;
    margin-top: 14px;
    padding: 12px 16px;
    background: rgba(16, 185, 129, 0.22);
    border: 1px solid rgba(110, 231, 183, 0.5);
    border-radius: 12px;
    font-size: 14px;
    font-weight: 700;
    color: #d1fae5;
    position: relative;
    z-index: 1;
}

/* ═══ Footer ═══ */
.footer {
    padding: 28px 16px calc(28px + env(safe-area-inset-bottom));
}

.footer-links {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 10px;
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 12.5px;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: var(--primary);
    text-decoration: underline;
}

/* ═══ Sticky Mobile CTA Bar ═══ */
.mobile-cta-bar {
    display: none;
}

@media (max-width: 768px) {
    body {
        padding-bottom: 86px;
    }

    .mobile-cta-bar {
        display: flex;
        gap: 10px;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
        background: rgba(255, 255, 255, 0.92);
        backdrop-filter: blur(14px);
        -webkit-backdrop-filter: blur(14px);
        border-top: 1px solid var(--border);
        box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.08);
        z-index: 200;
    }

    [data-theme="dark"] .mobile-cta-bar {
        background: rgba(14, 16, 20, 0.92);
    }

    .mobile-cta-bar .btn-cta {
        flex: 1;
        justify-content: center;
        padding: 13px 10px;
        font-size: 15px;
        min-height: 48px;
    }

    .mobile-cta-bar .btn-cta-secondary {
        background: rgba(79, 70, 229, 0.1);
    }

    /* Touch targets ≥ 44px */
    .tab,
    .btn-icon,
    .btn-page {
        min-height: 44px;
    }

    .cat-pill {
        min-height: 40px;
    }

    .footer {
        padding-bottom: calc(100px + env(safe-area-inset-bottom));
    }
}

/* ═══ Scroll reveal (progressive enhancement) ═══ */
.js .reveal {
    opacity: 0;
    transform: translateY(18px);
    transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1), transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.js .reveal.reveal-visible {
    opacity: 1;
    transform: translateY(0);
}

/* ═══ Reduced motion ═══ */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .js .reveal {
        opacity: 1;
        transform: none;
        transition: none;
    }
}
