:root {
    --bg-color: #ffffff;
    --text-primary: #111827;
    --text-secondary: #4b5563;
    --accent-primary: #60fa71;
    --accent-secondary: #0f172a;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(0, 0, 0, 0.08);
    --card-radius: 8px;
    --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', Consolas, monospace;
    --font-arabic: 'IBM Plex Sans Arabic', 'Cairo', sans-serif;
    --transition-speed: 0.2s;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --grid-opacity: 0.06;
    --grid-size: 40px;
}

[data-theme="dark"] {
    --bg-color: #0a0a0a;
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --accent-primary: #60fa71;
    /* Lighter blue for dark mode */
    --accent-secondary: #f8fafc;
    --glass-bg: rgba(20, 20, 20, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --shadow-sm: 0 1px 2px 0 rgba(255, 255, 255, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.1);
    --grid-opacity: 0.05;
    --grid-size: 40px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-color);
    background-image:
        linear-gradient(to right, rgba(0, 0, 0, var(--grid-opacity)) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(0, 0, 0, var(--grid-opacity)) 1px, transparent 1px);
    background-size: var(--grid-size) var(--grid-size);
    color: var(--text-primary);
    font-family: var(--font-main);
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

[lang="ar"] body {
    direction: rtl;
    font-family: var(--font-arabic);
}

[data-theme="dark"] body {
    background-image:
        linear-gradient(to right, rgba(255, 255, 255, var(--grid-opacity)) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255, 255, 255, var(--grid-opacity)) 1px, transparent 1px);
}

a {
    text-decoration: none;
    color: inherit;
    transition: color var(--transition-speed) ease;
}

ul {
    list-style: none;
}

/* Typography */
h1,
h2,
h3 {
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

h1 {
    font-size: 4rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

h2 {
    font-size: 2.25rem;
    margin-bottom: 3rem;
    text-align: start;
    /* Updated to natural start alignment */
    display: block;
    margin-left: 0;
    margin-right: 0;
}


h2::after {
    content: '#';
    color: var(--accent-primary);
    margin-left: 0.25rem;
    font-size: 1.25em;
    /* Slightly larger */
    vertical-align: middle;
    /* Removed underline styles */
    position: static;
    width: auto;
    height: auto;
    background: none;
    opacity: 1;
}

[lang="ar"] h2::after {
    margin-right: 0.25rem;
    margin-left: 0;
}

/* Layout */
.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 2rem;
}

section {
    padding: 6rem 0;
}

/* Header */
header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    padding: 1rem 0;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--glass-border);
}

[data-theme="dark"] header {
    background: rgba(10, 10, 10, 0.9);
}

nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.logo img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--glass-border);
}

.nav-links {
    display: flex;
    gap: 2rem;
    align-items: center;
}

/* Mobile Menu Toggle */
.menu-toggle {
    display: none;
    flex-direction: column;
    gap: 6px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    z-index: 1001;
}

.menu-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background-color: var(--text-primary);
    transition: all 0.3s ease;
}

.menu-toggle.active span:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
}

.menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.menu-toggle.active span:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
}

.nav-links a {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    /* Ensure contents are centered */
    height: 100%;
}

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

/* Hero Section */
/* Hero Section */
.hero {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3rem;
    padding-top: 80px;
    text-align: center;
}

[lang="ar"] .hero {
    flex-direction: column;
    /* Keep column layout for RTL */
}

.hero-image {
    width: 250px;
    height: 250px;
    border-radius: 30px;
    /* Reduced radius */
    overflow: hidden;
    /* border removed */
    box-shadow: 0 0 30px rgba(var(--accent-rgb), 0.2);
    order: -1;
    /* Ensure image is on top */
}

.hero-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hero-content {
    max-width: 800px;
    display: flex;
    flex-direction: column;
    align-items: center;
}


[data-theme="dark"] .hero-image {
    border-color: #333;
}

.hero-content {
    max-width: 600px;
    text-align: left;
    order: 1;
    /* Content on left (visually start) */
}

[lang="ar"] .hero-content {
    text-align: right;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 2rem;
    background-color: var(--text-primary);
    color: white;
    border-radius: 6px;
    font-weight: 500;
    font-size: 1rem;
    transition: all var(--transition-speed) ease;
    border: none;
    cursor: pointer;
}

.btn:hover {
    background-color: var(--accent-primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

[data-theme="dark"] .btn {
    background-color: var(--accent-primary);
    color: var(--bg-color);
}

[data-theme="dark"] .btn:hover {
    background-color: #3bfa81;
}

.btn-sm {
    padding: 0.4rem 1rem;
    font-size: 0.85rem;
    border-radius: 4px;
}

.project-links {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

/* Projects Grid */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 2rem;
}

.project-card {
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: var(--card-radius);
    padding: 2.5rem;
    transition: all 0.5s cubic-bezier(0.23, 1, 0.32, 1);
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
    position: relative;
    overflow: hidden;
}

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

.project-card:hover::before {
    left: 100%;
}

.project-card:hover {
    transform: translateY(-12px) scale(1.03);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.12);
    border-color: var(--accent-primary);
    background: rgba(255, 255, 255, 0.6);
}

[data-theme="dark"] .project-card {
    background: rgba(30, 30, 30, 0.3);
    border-color: rgba(255, 255, 255, 0.05);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .project-card::before {
    background: linear-gradient(90deg,
            transparent,
            rgba(255, 255, 255, 0.05),
            transparent);
}

[data-theme="dark"] .project-card:hover {
    border-color: var(--accent-primary);
    background: rgba(40, 40, 40, 0.5);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.project-title {
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
    font-family: var(--font-mono);
    color: var(--text-primary);
}

.project-desc {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
}

.tags {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.tag {
    background: #f3f4f6;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-family: var(--font-mono);
    color: var(--text-secondary);
    border: 1px solid transparent;
}

[data-theme="dark"] .tag {
    background: #1f2937;
    color: #d1d5db;
}

[data-theme="dark"] .project-card:hover .tag {
    background: #374151;
    border-color: #4b5563;
}

.project-card:hover .tag {
    border-color: #e5e7eb;
    background: #fff;
}

/* Contact */
.contact {
    background: #f9fafb;
    border-top: 1px solid var(--glass-border);
    border-bottom: 1px solid var(--glass-border);
}

[data-theme="dark"] .contact {
    background: #0f0f0f;
    border-top: 1px solid var(--glass-border);
    border-bottom: 1px solid var(--glass-border);
}

.social-links {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-top: 3rem;
    flex-wrap: wrap;
    /* Allow wrapping on small screens */
}

.social-link {
    font-size: 1.25rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.social-link:hover {
    color: var(--accent-primary);
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
    background: #ffffff;
}

[data-theme="dark"] footer {
    background: #0a0a0a;
}

/* Animations */
.fade-in {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

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

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 0 1.5rem;
    }

    h1 {
        font-size: 2.5rem;
    }

    h2 {
        font-size: 1.75rem;
        text-align: center;
    }

    [lang="ar"] h2 {
        text-align: center;
    }

    [lang="ar"] .hero {
        flex-direction: column;
        /* Mirror layout for RTL */
    }


    .menu-toggle {
        display: flex;
    }

    .nav-links {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        /* Ensure full viewport height */
        background: rgba(255, 255, 255, 0.95);
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 3rem;
        padding: 2rem;
        padding-bottom: 80px;
        /* Added padding bottom */
        transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
        z-index: 1000;
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        transform: translateY(-100%);
        opacity: 0;
        visibility: hidden;
    }

    [data-theme="dark"] .nav-links {
        background: rgba(10, 10, 10, 0.95);
    }

    [lang="ar"] .nav-links {
        right: auto;
        left: 0;
        transform: translateY(-100%);
    }

    .nav-links.active {
        transform: translateY(0);
        opacity: 1;
        visibility: visible;
    }

    [lang="ar"] .nav-links.active {
        transform: translateY(0);
    }

    .nav-links a {
        font-size: 2rem;
        font-weight: 700;
        width: auto;
        justify-content: center;
        opacity: 0;
        transform: translateY(20px);
        transition: 0.4s ease forwards;
        color: var(--text-primary);
    }

    .nav-links.active a {
        opacity: 1;
        transform: translateY(0);
    }

    /* Staggered animation for links */
    .nav-links.active a:nth-child(1) {
        transition-delay: 0.1s;
    }

    .nav-links.active a:nth-child(2) {
        transition-delay: 0.2s;
    }

    .nav-links.active a:nth-child(3) {
        transition-delay: 0.3s;
    }

    .nav-links.active button {
        transition-delay: 0.4s;
        opacity: 1;
        transform: translateY(0);
    }

    /* Hero styles are now global, but we can adjust sizing for mobile if needed */
    .hero {
        min-height: 80vh;
        padding: 6rem 1rem 2rem;
    }

    .hero h1 {
        font-size: 2.5rem;
    }

    .hero-image {
        width: 200px;
        height: 200px;
    }

    [lang="ar"] .hero-content {
        text-align: center;
    }
}