/* =========================================
   1. VARIABLES & THEME SETUP
   ========================================= */
:root {
    /* Core HSL Colors for easier manipulation */
    --hue-primary: 220;
    --hue-secondary: 260;

    /* Light Mode Palette */
    --bg-body: #f8fafc;
    --bg-card: rgba(255, 255, 255, 0.7);
    --bg-glass: rgba(255, 255, 255, 0.6);
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-light: rgba(255, 255, 255, 0.5);
    --border-strong: rgba(226, 232, 240, 0.8);

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, hsl(var(--hue-primary), 90%, 60%), hsl(var(--hue-secondary), 80%, 60%));
    --gradient-text: linear-gradient(135deg, hsl(var(--hue-primary), 80%, 40%), hsl(var(--hue-secondary), 80%, 40%));

    /* Shadows */
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.025);
    --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.15);

    /* Structure */
    --container-width: 1100px;
    --header-height: 80px;
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 8px;

    /* Fonts */
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
}

body.dark-theme {
    /* Dark Mode Palette */
    --bg-body: #030712;
    /* Richer dark blue-black */
    --bg-card: rgba(17, 24, 39, 0.6);
    --bg-glass: rgba(17, 24, 39, 0.7);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-light: rgba(255, 255, 255, 0.05);
    --border-strong: rgba(255, 255, 255, 0.1);

    /* Gradients Adjusted */
    --gradient-text: linear-gradient(135deg, hsl(var(--hue-primary), 90%, 75%), hsl(var(--hue-secondary), 90%, 75%));

    /* Shadows */
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 30px rgba(59, 130, 246, 0.2);
}

/* =========================================
   2. RESET & BASE STYLES
   ========================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
    transition: background-color 0.4s ease, color 0.4s ease;

    /* Background blob effect */
    background-image:
        radial-gradient(circle at 10% 20%, rgba(59, 130, 246, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(139, 92, 246, 0.05) 0%, transparent 40%);
    background-attachment: fixed;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background-color: var(--text-muted);
    border-radius: 20px;
    border: 3px solid transparent;
    background-clip: content-box;
}

a {
    text-decoration: none;
    color: inherit;
    transition: all 0.2s ease;
}

ul {
    list-style: none;
}

/* =========================================
   3. UTILITIES
   ========================================= */
.container {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 24px;
}

.section {
    padding: 120px 0;
    position: relative;
}

.title-gradient {
    background: var(--gradient-text);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    display: inline-block;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 14px 32px;
    border-radius: 50px;
    font-weight: 600;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    z-index: 1;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    border: none;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.5);
}

.btn-outline {
    background: transparent;
    color: var(--text-main);
    border: 2px solid var(--border-strong);
}

.btn-outline:hover {
    border-color: hsl(var(--hue-primary), 80%, 60%);
    background: rgba(59, 130, 246, 0.05);
}

/* =========================================
   4. GLASSMORPHISM COMPONENTS
   ========================================= */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s;
}

.glass-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md), var(--shadow-glow);
    border-color: hsl(var(--hue-primary), 80%, 60%, 0.3);
}

/* =========================================
   5. HEADER & NAV
   ========================================= */
.header {
    height: var(--header-height);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    transition: all 0.3s ease;

    /* Glass Effect */
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(15px);
    border-bottom: 1px solid var(--border-light);
}

body.dark-theme .header {
    background: rgba(3, 7, 18, 0.1);
    /* Lighter touch on dark mode */
}

.header-container {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -1px;
    color: var(--text-main);
}

.logo span {
    color: hsl(var(--hue-primary), 90%, 60%);
}

.nav-list {
    display: flex;
    align-items: center;
    gap: 40px;
}

.nav-link {
    font-weight: 500;
    color: var(--text-muted);
    position: relative;
    padding: 5px 0;
}

.nav-link:hover,
.nav-link.active {
    color: var(--text-main);
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--gradient-primary);
    transition: width 0.3s ease;
}

.nav-link:hover::after {
    width: 100%;
}

/* =========================================
   6. CONTROLS (Theme/Lang)
   ========================================= */
.controls-group {
    display: flex;
    align-items: center;
    gap: 15px;
    background: var(--bg-glass);
    padding: 6px 12px;
    border-radius: 30px;
    border: 1px solid var(--border-strong);
}

.theme-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 4px;
    border-radius: 50%;
    transition: background 0.2s;
}

.theme-btn:hover {
    background: rgba(128, 128, 128, 0.1);
}

.lang-switch {
    display: flex;
    gap: 4px;
}

.lang-btn {
    border: none;
    background: none;
    font-size: 0.8rem;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-muted);
}

.lang-btn.active {
    background: var(--text-main);
    color: var(--bg-body);
}

/* =========================================
   7. HERO SECTION
   ========================================= */
.hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    padding-top: var(--header-height);
    position: relative;
    overflow: hidden;
}

.hero-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 60px;
    align-items: center;
}

.hero-content h1 {
    font-size: 4rem;
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 24px;
    letter-spacing: -2px;
}

.badge {
    display: inline-block;
    padding: 8px 16px;
    background: rgba(59, 130, 246, 0.1);
    color: hsl(var(--hue-primary), 80%, 55%);
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 24px;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.subtitle {
    font-size: 1.25rem;
    color: var(--text-muted);
    margin-bottom: 40px;
    max-width: 90%;
}

.hero-actions {
    display: flex;
    gap: 16px;
}

/* Hero Image with Abstract Blob */
.profile-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
}

.profile-img {
    width: 350px;
    height: 350px;
    object-fit: cover;
    border-radius: 40px;
    border: 1px solid var(--border-light);
    transform: rotate(3deg);
    transition: transform 0.4s ease;
    z-index: 2;
    box-shadow: 20px 20px 60px rgba(0, 0, 0, 0.1);
}

.profile-img:hover {
    transform: rotate(0deg) scale(1.02);
}

/* Blob behind image */
.profile-wrapper::before {
    content: '';
    position: absolute;
    width: 120%;
    height: 120%;
    background: var(--gradient-primary);
    filter: blur(80px);
    opacity: 0.4;
    z-index: 1;
    top: -10%;
    left: -10%;
    border-radius: 50%;
    animation: blob-bounce 8s infinite alternate;
}

@keyframes blob-bounce {
    0% {
        transform: translate(0, 0) scale(1);
    }

    100% {
        transform: translate(20px, -20px) scale(1.1);
    }
}

/* =========================================
   8. ABOUT SECTION
   ========================================= */
.section-header {
    margin-bottom: 60px;
    text-align: center;
    /* Default center, overridden for RTL usually */
}

[dir="rtl"] .section-header {
    text-align: right;
}

.section-title {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 10px;
}

.about-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 40px;
}

.about-text {
    font-size: 1.15rem;
    color: var(--text-muted);
    line-height: 1.8;
}

.about-details {
    margin-top: 30px;
    display: flex;
    gap: 40px;
}

.about-details li {
    display: flex;
    flex-direction: column;
}

.about-details strong {
    color: var(--text-main);
    font-size: 0.9rem;
    margin-bottom: 4px;
}

/* =========================================
   9. SKILLS GRID (BENTO STYLE)
   ========================================= */
.skills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
}

.skill-card {
    padding: 30px;
}

.skill-card h3 {
    font-size: 1.3rem;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.skill-list li {
    padding: 8px 0;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-muted);
    font-weight: 500;
}

.skill-list li:last-child {
    border-bottom: none;
}

/* =========================================
   10. PROJECTS
   ========================================= */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 24px;
}

.project-card {
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 2px;
    /* Gradient border trick starter */
    background: transparent;
}

.project-inner {
    background: var(--bg-card);
    height: 100%;
    padding: 30px;
    border-radius: 22px;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-light);
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s;
}

.project-card:hover .project-inner {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md), var(--shadow-glow);
    border-color: hsl(var(--hue-primary), 80%, 60%, 0.3);
}

.project-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
}

.project-status {
    font-size: 0.75rem;
    padding: 6px 12px;
    border-radius: 20px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.completed {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.working {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.concept {
    background: rgba(99, 102, 241, 0.15);
    color: #6366f1;
}

.project-card h3 {
    font-size: 1.4rem;
    margin-bottom: 10px;
}

.project-card p {
    color: var(--text-muted);
    margin-bottom: 20px;
    flex-grow: 1;
}

.project-tech {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 24px;
}

.project-tech span {
    font-size: 0.75rem;
    padding: 4px 10px;
    background: var(--bg-body);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    color: var(--text-muted);
}

.project-link {
    display: inline-flex;
    align-items: center;
    font-weight: 600;
    color: hsl(var(--hue-primary), 80%, 55%);
    gap: 5px;
}

.project-link:hover {
    gap: 8px;
}

/* =========================================
   11. CURRENTLY LEARNING
   ========================================= */
.focus-section .glass-card {
    padding: 40px;
    border-left: 5px solid hsl(var(--hue-primary), 80%, 60%);
    border-radius: 8px var(--radius-lg) var(--radius-lg) 8px;
}

[dir="rtl"] .focus-section .glass-card {
    border-left: none;
    border-right: 5px solid hsl(var(--hue-primary), 80%, 60%);
    border-radius: var(--radius-lg) 8px 8px var(--radius-lg);
}

/* =========================================
   12. CONTACT
   ========================================= */
.contact-container {
    max-width: 600px;
    margin: 0 auto;
    text-align: center;
}

.contact-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 40px;
}

.form-input {
    width: 100%;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 2px solid var(--border-strong);
    border-radius: 12px;
    font-family: inherit;
    font-size: 1rem;
    color: var(--text-main);
    transition: all 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: hsl(var(--hue-primary), 80%, 60%);
    background: var(--bg-body);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

.contact-socials {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-top: 50px;
    padding-top: 30px;
    border-top: 1px solid var(--border-light);
}

.social-link {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-muted);
}

.social-link:hover {
    color: var(--text-main);
}

.footer {
    text-align: center;
    padding: 40px 0;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* =========================================
   13. LANGUAGE UTILS (VISIBILITY)
   ========================================= */
.lang-en,
.lang-ar,
.lang-en-flex,
.lang-ar-flex,
.lang-en-grid,
.lang-ar-grid {
    display: none !important;
}

body.en-mode .lang-en {
    display: block !important;
}

body.ar-mode .lang-ar {
    display: block !important;
}

body.en-mode .lang-en-flex {
    display: flex !important;
}

body.ar-mode .lang-ar-flex {
    display: flex !important;
}

body.en-mode .lang-en-grid {
    display: grid !important;
}

body.ar-mode .lang-ar-grid {
    display: grid !important;
}

/* Form Visibility Override */
.contact-form .lang-en,
.contact-form .lang-ar {
    display: flex !important;
    gap: 20px;
    flex-direction: column;
}

body.ar-mode .contact-form .lang-en,
body.en-mode .contact-form .lang-ar {
    display: none !important;
}

/* Force Header to be LTR always (User Request) */
[dir="rtl"] .header {
    direction: ltr;
}

/* Responsive */
@media (max-width: 850px) {
    .hero-grid {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .profile-wrapper {
        order: -1;
        margin-bottom: 40px;
    }

    .hero-actions {
        justify-content: center;
    }

    .hero-content h1 {
        font-size: 2.8rem;
    }
}

@media (max-width: 600px) {
    .header-container {
        padding: 0 20px;
    }

    .nav-list {
        display: none;
    }

    /* Mobile Menu would be ideal, hiding for now */

    .btn {
        padding: 12px 24px;
        font-size: 0.9rem;
    }

    .profile-img {
        width: 250px;
        height: 250px;
    }
}

/* RTL overrides for specific flexible layouts */
/* NOTE: Header is NOT overridden here because of the force LTR rule above */
[dir="rtl"] .hero-grid {
    direction: rtl;
}

[dir="rtl"] .hero-content {
    text-align: right;
}

[dir="rtl"] .hero-actions {
    justify-content: flex-start;
}

[dir="rtl"] .project-link {
    flex-direction: row-reverse;
}

@media (max-width: 850px) {
    [dir="rtl"] .hero-content {
        text-align: center;
    }

    [dir="rtl"] .hero-actions {
        justify-content: center;
    }
}