:root {
    /* Dark Mode (Default) Variables */
    --bg-body: #0a0a0a;
    --bg-elev: #171717;
    --bg-elev-high: #262626;
    --text: #ededed;
    --text-muted: #a3a3a3;
    --primary: #3b82f6;
    /* Blue-500 */
    --primary-glow: rgba(59, 130, 246, 0.15);
    --stroke: #262626;
    --stroke-strong: #404040;
    --focus: #60a5fa;

    --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;

    --max-width: 1100px;
    --nav-height: 70px;
    --radius: 8px;
    --radius-sm: 4px;
}

[data-theme="light"] {
    --bg-body: #ffffff;
    --bg-elev: #f5f5f5;
    --bg-elev-high: #e5e5e5;
    --text: #171717;
    --text-muted: #525252;
    --primary: #2563eb;
    /* Blue-600 */
    --primary-glow: rgba(37, 99, 235, 0.1);
    --stroke: #e5e5e5;
    --stroke-strong: #d4d4d4;
    --focus: #3b82f6;
}

/* Reset & Base */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.6;
}

body {
    background-color: var(--bg-body);
    color: var(--text);
    transition: background-color 0.3s ease, color 0.3s ease;
    -webkit-font-smoothing: antialiased;
}

img {
    max-width: 100%;
    display: block;
}

a {
    text-decoration: none;
    color: inherit;
    transition: color 0.2s ease;
}

ul {
    list-style: none;
}

/* Layout Utilities */
.container {
    width: 90%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 1rem;
}

.section {
    padding: 80px 0;
}

.section__title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 2rem;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.section__title::after {
    content: '';
    display: block;
    height: 1px;
    background: var(--stroke);
    flex: 1;
}

/* Header / Nav */
.header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--nav-height);
    background: rgba(10, 10, 10, 0.8);
    /* fallback */
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--stroke);
    z-index: 1000;
    display: flex;
    align-items: center;
}

[data-theme="light"] .header {
    background: rgba(255, 255, 255, 0.8);
}

.header__inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: -0.025em;
}

.nav__list {
    display: flex;
    gap: 2rem;
}

.nav__link {
    font-size: 0.95rem;
    color: var(--text-muted);
    font-weight: 500;
}

.nav__link:hover,
.nav__link.active {
    color: var(--text);
}

.theme-toggle {
    background: transparent;
    border: 1px solid var(--stroke);
    color: var(--text);
    padding: 0.5rem;
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.theme-toggle:hover {
    background: var(--bg-elev);
}

/* Mobile Nav Toggle */
.nav-toggle {
    display: none;
    /* Hidden on desktop */
}

/* Hero Section */
.hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    padding-top: var(--nav-height);
    overflow-x: hidden;
}

.hero__grid {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    align-items: center;
    gap: 3rem;
}

.hero__image-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.8s ease-out;
}

.hero__image-blob {
    position: absolute;
    width: 140%;
    height: 140%;
    background: radial-gradient(circle, var(--primary-glow) 0%, rgba(0, 0, 0, 0) 70%);
    z-index: -1;
    opacity: 0.6;
}

.hero__img {
    width: 100%;
    max-width: 240px;
    border-radius: 20px;
    border: 1px solid var(--stroke);
    box-shadow: 0 15px 35px -5px rgba(0, 0, 0, 0.4);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    background: var(--bg-elev);
    /* Fallback */
}

.hero__img:hover {
    transform: translateY(-5px) scale(1.03) rotate(1deg);
    border-color: var(--primary);
    box-shadow: 0 20px 40px -5px var(--primary-glow), 0 0 0 4px rgba(59, 130, 246, 0.1);
}

.hero__content {
    display: flex;
    flex-direction: column;
}

.hero__greeting {
    color: var(--primary);
    font-weight: 600;
    margin-bottom: 1rem;
    display: block;
}

.hero__title {
    font-size: clamp(2.5rem, 5vw, 4rem);
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 1.5rem;
    letter-spacing: -0.03em;
}

.hero__subtitle {
    font-size: clamp(1.1rem, 2vw, 1.25rem);
    color: var(--text-muted);
    margin-bottom: 2.5rem;
    max-width: 90%;
    line-height: 1.6;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.btn-group {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn--primary {
    background: var(--primary);
    color: #fff;
}

.btn--primary:hover {
    filter: brightness(110%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--primary-glow);
}

.btn--outline {
    border: 1px solid var(--stroke-strong);
    color: var(--text);
}

.btn--outline:hover {
    border-color: var(--text);
    background: var(--bg-elev);
}

/* About Section */
.about__text p {
    margin-bottom: 1rem;
    color: var(--text-muted);
    font-size: 1.05rem;
}

.about__text strong {
    color: var(--text);
}

/* Skills Section */
.skills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
}

.skill-category h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--text);
    border-left: 3px solid var(--primary);
    padding-left: 0.75rem;
}

.skill-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.skill-tag {
    font-size: 0.9rem;
    padding: 0.35rem 0.85rem;
    background: var(--bg-elev);
    color: var(--text-muted);
    border-radius: 999px;
    border: 1px solid var(--stroke);
    transition: all 0.2s;
}

.skill-tag:hover {
    background: var(--bg-elev-high);
    color: var(--text);
    border-color: var(--stroke-strong);
}

/* Projects Section */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.project-card {
    background: var(--bg-elev);
    border: 1px solid var(--stroke);
    border-radius: var(--radius);
    padding: 2rem;
    transition: transform 0.2s, border-color 0.2s;
    display: flex;
    flex-direction: column;
}

.project-card:hover {
    transform: translateY(-4px);
    border-color: var(--primary);
}

.project-card__title {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.project-card__desc {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
    flex-grow: 1;
}

.project-card__link {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary);
    align-self: flex-start;
}

/* Experience Section */
.timeline {
    position: relative;
    max-width: 800px;
    margin: 0 auto;
    padding-left: 2rem;
    border-left: 2px solid var(--stroke);
}

.timeline__item {
    position: relative;
    margin-bottom: 3rem;
}

.timeline__item::before {
    content: '';
    position: absolute;
    left: -2.6rem;
    top: 0.25rem;
    width: 1rem;
    height: 1rem;
    background: var(--bg-body);
    border: 2px solid var(--primary);
    border-radius: 50%;
}

.timeline__date {
    font-size: 0.9rem;
    color: var(--primary);
    font-weight: 600;
    margin-bottom: 0.25rem;
    display: block;
}

.timeline__title {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
}

.timeline__company {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.timeline__desc ul {
    list-style-type: disc;
    padding-left: 1.25rem;
}

.timeline__desc li {
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

/* Certifications & Education */
.cert-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1rem;
}

.cert-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    background: var(--bg-elev);
    border: 1px solid var(--stroke);
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.9rem;
}

/* Contact */
.contact-actions {
    display: flex;
    gap: 2rem;
    justify-content: center;
    margin-top: 2rem;
    flex-wrap: wrap;
}

.contact-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.1rem;
    color: var(--text);
    padding: 1rem 2rem;
    background: var(--bg-elev);
    border-radius: var(--radius);
    border: 1px solid var(--stroke);
    transition: all 0.2s;
}

.contact-item:hover {
    border-color: var(--primary);
    background: var(--bg-elev-high);
}

/* Footer */
.footer {
    padding: 4rem 0 2rem;
    background: var(--bg-elev);
    border-top: 1px solid var(--stroke);
    margin-top: 4rem;
}

.footer__inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    text-align: center;
}

.footer__copy {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Antigravity Badge */
.footer__badge {
    display: inline-block;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border: 1px solid var(--stroke);
    background: var(--bg-elev-high);
    color: var(--text-muted);
    border-radius: 999px;
    transition: all 0.2s ease;
    text-decoration: none;
}

.footer__badge:hover {
    color: var(--text);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: var(--stroke-strong);
}

.footer__badge:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

/* Tablet Responsive */
@media (max-width: 968px) {
    .hero__grid {
        grid-template-columns: 1fr;
        text-align: center;
        gap: 3rem;
        padding-top: 2rem;
    }

    .hero {
        padding-bottom: 4rem;
    }

    .hero__image-wrapper {
        order: -1;
    }

    .hero__img {
        max-width: 200px;
    }

    .hero__content {
        align-items: center;
    }

    .btn-group {
        justify-content: center;
    }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .nav__list {
        display: none;
        /* Can be enhanced with JS toggle */
        position: absolute;
        top: var(--nav-height);
        left: 0;
        width: 100%;
        background: var(--bg-elev);
        flex-direction: column;
        padding: 2rem;
        border-bottom: 1px solid var(--stroke);
    }

    .nav__list.open {
        display: flex;
    }

    .nav-toggle {
        display: block;
        background: transparent;
        border: none;
        color: var(--text);
        font-size: 1.5rem;
        cursor: pointer;
    }

    .hero__title {
        font-size: 2.5rem;
    }

    .header__inner {
        padding: 0 1rem;
    }
}

/* Certificate Gallery */
.cert-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.cert-item {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--stroke);
    aspect-ratio: 1.4;
    /* landscape A4 approx */
    background: var(--bg-elev);
    cursor: pointer;
    group: cert-item;
}

.cert-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.cert-item:hover img {
    transform: scale(1.05);
}

.cert-item::after {
    content: '🔎';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.4);
    font-size: 2rem;
    opacity: 0;
    transition: opacity 0.2s;
}

.cert-item:hover::after {
    opacity: 1;
}

.cert-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    font-size: 0.8rem;
    text-align: center;
    backdrop-filter: blur(4px);
}

/* Language Switcher */
.lang-select {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--stroke);
    border-radius: var(--radius);
    padding: 0.35rem 0.5rem;
    cursor: pointer;
    font-size: 0.85rem;
    outline: none;
    transition: all 0.2s;
}

.lang-select:hover {
    background: var(--bg-elev);
    border-color: var(--stroke-strong);
}

.lang-select option {
    background: var(--bg-elev);
    color: var(--text);
}

/* RTL Support for Arabic */
[dir="rtl"] {
    direction: rtl;
    text-align: right;
}

[dir="rtl"] .skill-category h3 {
    border-left: none;
    border-right: 3px solid var(--primary);
    padding-left: 0;
    padding-right: 0.75rem;
}

[dir="rtl"] .timeline {
    border-left: none;
    border-right: 2px solid var(--stroke);
    padding-left: 0;
    padding-right: 2rem;
}

[dir="rtl"] .timeline__item::before {
    left: auto;
    right: -2.6rem;
}

[dir="rtl"] .timeline__desc ul {
    padding-left: 0;
    padding-right: 1.25rem;
}

[dir="rtl"] .project-card__link,
[dir="rtl"] .contact-item {
    direction: ltr;
    /* Keep phones/emails LTR if needed, or handle icons */
    justify-content: flex-end;
    /* Actually, flexbox flips, so justify-start becomes right. */
}

[dir="rtl"] .contact-item {
    flex-direction: row-reverse;
    /* To keep icon on the correct side relative to text if desired? No, usually in RTL icon is on right, text on left. Flexbox does row normally: Start (Right) -> End (Left). So Icon first (Right) is correct. */
}

/* Fix project link arrow in RTL */
[dir="rtl"] .project-card__link {
    align-self: flex-start;
    /* inherits */
}

/* Ensure Contact items (Phone/Email) display correctly in RTL mixed content */
[dir="rtl"] .contact-item span:first-child {
    /* The icon */
    margin-left: 0.75rem;
}