:root {
    /* Color Variables - Dark Theme (Default) */
    --bg-primary: #0f0f0f;
    --bg-secondary: #1a1a1a;
    --bg-card: #252525;
    --text-primary: #f0f0f0;
    --text-secondary: #a0a0a0;
    --accent: #007AFF;
    /* Premium Blue */
    --accent-hover: #0056b3;
    --border: #333333;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.5);

    /* Spacing */
    --measure: 65ch;
    --gap: 2rem;
    --container-padding: 2rem;
}

[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-card: #ffffff;
    --text-primary: #1a1a1a;
    --text-secondary: #555555;
    --accent: #007AFF;
    --accent-hover: #0056b3;
    --border: #e0e0e0;
    --shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
}

/* Reset & Base */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: inherit;
    transition: color 0.3s ease;
}

ul {
    list-style: none;
}

img {
    max-width: 100%;
    display: block;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    line-height: 1.2;
    margin-bottom: 1rem;
    font-weight: 700;
}

h1 {
    font-size: 3.5rem;
    letter-spacing: -2px;
}

h2 {
    font-size: 2.5rem;
    letter-spacing: -1px;
}

h3 {
    font-size: 1.5rem;
}

p {
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.section-title {
    text-align: start;
    margin-bottom: 3rem;
    font-size: 2.5rem;
    position: relative;
    display: block;
    left: 0;
    transform: none;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 0;
    transform: none;
    width: 60px;
    height: 4px;
    background-color: var(--accent);
    border-radius: 2px;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--container-padding);
}

.section {
    padding: 5rem 0;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.8rem 2rem;
    border-radius: 50px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.btn-primary {
    background-color: var(--accent);
    color: #000;
}

.btn-primary:hover {
    background-color: var(--accent-hover);
    transform: translateY(-2px);
}

.btn-secondary {
    background-color: transparent;
    border: 2px solid var(--accent);
    color: var(--text-primary);
    margin-left: 1rem;
}

.btn-secondary:hover {
    background-color: var(--accent);
    color: #000;
    transform: translateY(-2px);
}

/* Header & Nav */
header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    background-color: rgba(15, 15, 15, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding: 0.8rem 0;
}

[data-theme="light"] header {
    background-color: rgba(255, 255, 255, 0.85);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--container-padding);
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -1px;
    color: var(--accent);
    z-index: 1001;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.nav-links a {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
}

.nav-links a:hover {
    color: var(--accent);
}

.nav-controls {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    z-index: 1001;
}

#theme-toggle {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.2rem;
    cursor: pointer;
    transition: transform 0.3s ease;
    padding: 5px;
}

#theme-toggle:hover {
    transform: rotate(15deg);
    color: var(--accent);
}

.hamburger {
    display: none;
    cursor: pointer;
}

.bar {
    display: block;
    width: 25px;
    height: 3px;
    margin: 5px auto;
    background-color: var(--text-primary);
    transition: all 0.3s ease-in-out;
}

/* Hero Section */
#hero {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: radial-gradient(circle at center, var(--bg-secondary) 0%, var(--bg-primary) 100%);
    position: relative;
    padding-top: 60px;
    /* Offset for fixed header */
}

.hero-content {
    max-width: 800px;
}

.hero-content p {
    font-size: 1.2rem;
    margin-bottom: 2.5rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.scroll-indicator {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 50px;
    border: 2px solid var(--text-secondary);
    border-radius: 20px;
    display: flex;
    justify-content: center;
}

.scroll-indicator span {
    width: 6px;
    height: 6px;
    background-color: var(--accent);
    border-radius: 50%;
    margin-top: 10px;
    animation: scroll 2s infinite;
}

@keyframes scroll {
    0% {
        transform: translateY(0);
        opacity: 1;
    }

    50% {
        transform: translateY(15px);
        opacity: 1;
    }

    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

/* About Section */
.about-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4rem;
    align-items: center;
}

.about-image {
    position: relative;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.about-image img {
    border-radius: 20px;
    width: 100%;
    transition: transform 0.5s ease;
}

.about-image:hover img {
    transform: scale(1.05);
}

/* Skills Section */
.skills-category {
    margin-bottom: 3rem;
}

.skills-category h3 {
    margin-bottom: 1.5rem;
    color: var(--accent);
    font-size: 1.2rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.skills-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.skill-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    padding: 1rem 1.5rem;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    transition: all 0.3s ease;
}

.skill-card:hover {
    border-color: var(--accent);
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(212, 175, 55, 0.1);
}

.skill-card i {
    color: var(--accent);
}

.styled-list li {
    margin-bottom: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    color: var(--text-primary);
}

.styled-list {
    margin: 0;
}

.styled-list i {
    color: var(--accent);
}

.two-col-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4rem;
}

.tools-icons {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.tool-item {
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
    background-color: var(--bg-card);
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border: 1px solid var(--border);
}

/* Projects Section */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.project-card {
    background-color: var(--bg-card);
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--border);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.project-card:hover {
    transform: translateY(-10px);
    box-shadow: var(--shadow);
}

.project-image {
    position: relative;
    height: 250px;
    overflow: hidden;
}

.project-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.project-card:hover .project-image img {
    transform: scale(1.1);
}

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.project-card:hover .overlay {
    opacity: 1;
}

.view-btn {
    color: #fff;
    border: 1px solid #fff;
    padding: 0.5rem 1.5rem;
    border-radius: 30px;
    font-weight: 500;
}

.view-btn:hover {
    background-color: #fff;
    color: #000;
}

.project-info {
    padding: 1.5rem;
}

.project-info h3 {
    margin-bottom: 0.5rem;
    font-size: 1.25rem;
}

/* Experience Section */
.timeline {
    border-left: 2px solid var(--border);
    margin: 0;
    max-width: 600px;
    padding-left: 40px;
    position: relative;
}

.timeline-item {
    margin-bottom: 3rem;
    position: relative;
}

.timeline-dot {
    position: absolute;
    left: -49px;
    top: 0;
    width: 16px;
    height: 16px;
    background-color: var(--accent);
    border-radius: 50%;
    border: 4px solid var(--bg-primary);
}

.timeline-date {
    font-size: 0.9rem;
    color: var(--accent);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.timeline-content h3 {
    font-size: 1.5rem;
    margin-bottom: 0.2rem;
}

.timeline-content h4 {
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-weight: 400;
    margin-bottom: 1rem;
}

.timeline-content ul li {
    margin-bottom: 0.5rem;
    position: relative;
    padding-left: 1.5rem;
}

.timeline-content ul li::before {
    content: '•';
    color: var(--accent);
    position: absolute;
    left: 0;
}

/* Services Section */
.services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
}

.service-card {
    background-color: var(--bg-card);
    padding: 2.5rem;
    border-radius: 16px;
    text-align: center;
    border: 1px solid var(--border);
    transition: all 0.3s ease;
}

.service-card:hover {
    border-color: var(--accent);
    transform: translateY(-5px);
}

.service-card i {
    font-size: 2.5rem;
    color: var(--accent);
    margin-bottom: 1.5rem;
}

/* Objective Section */
.objective-box {
    background: linear-gradient(135deg, var(--bg-card), var(--bg-secondary));
    padding: 3rem;
    border-radius: 20px;
    text-align: center;
    border: 1px solid var(--border);
    max-width: 900px;
    margin: 0 auto;
}

.objective-box h2 {
    color: var(--accent);
    font-size: 2rem;
    margin-bottom: 1.5rem;
}

.objective-box p {
    font-size: 1.1rem;
    color: var(--text-primary);
}

/* Contact Section */
.contact-wrapper {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4rem;
}

.social-links {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}



.social-link {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background-color: var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    border: 1px solid var(--border);
    font-size: 1.2rem;
    transition: all 0.3s ease;
}

.social-link:hover {
    background-color: var(--accent);
    color: #000;
    transform: translateY(-5px);
}

/* Contact Form - Styling only (Static HTML) */
.form-group {
    position: relative;
    margin-bottom: 2rem;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 0.8rem 0;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--text-secondary);
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group textarea:focus {
    border-bottom-color: var(--accent);
}

.form-group label {
    position: absolute;
    top: 0.8rem;
    left: 0;
    color: var(--text-secondary);
    pointer-events: none;
    transition: 0.3s ease all;
}

.form-group input:focus~label,
.form-group input:not(:placeholder-shown)~label,
.form-group textarea:focus~label,
.form-group textarea:not(:placeholder-shown)~label {
    top: -20px;
    font-size: 0.8rem;
    color: var(--accent);
}

/* Footer */
footer {
    padding: 2rem 0;
    border-top: 1px solid var(--border);
    text-align: center;
    background-color: var(--bg-secondary);
}

.back-to-top {
    display: inline-block;
    margin-top: 1rem;
    font-size: 0.9rem;
    color: var(--accent);
}

/* Animations */
.fade-in-up {
    opacity: 0;
    transform: translateY(30px);
    animation: fadeInUp 0.8s forwards;
}

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.delay-1 {
    animation-delay: 0.2s;
}

.delay-2 {
    animation-delay: 0.4s;
}

.delay-3 {
    animation-delay: 0.6s;
}

.scroll-reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.8s ease;
}

.scroll-reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Responsive */
/* Responsive */
@media (max-width: 992px) {
    h1 {
        font-size: 2.8rem;
    }

    .about-grid {
        grid-template-columns: 1fr;
    }

    .two-col-grid {
        grid-template-columns: 1fr;
    }

    .section {
        padding: 4rem 0;
    }

    .logo {
        cursor: pointer;
    }
}

@media (max-width: 768px) {

    /* Improved Mobile Typography & Spacing */
    :root {
        --container-padding: 1.25rem;
        --gap: 1.5rem;
    }

    html {
        -webkit-text-size-adjust: 100%;
        /* Prevent font scaling in landscape */
        -webkit-tap-highlight-color: transparent;
        /* Remove blue tap highlight */
    }

    /* Fluid Typography using Clamp */
    h1 {
        font-size: clamp(2rem, 5vw + 1rem, 3.5rem);
    }

    h2 {
        font-size: clamp(1.75rem, 4vw + 1rem, 2.5rem);
    }

    h3 {
        font-size: clamp(1.25rem, 3vw + 0.5rem, 1.5rem);
    }

    .section-title {
        font-size: clamp(1.8rem, 4vw + 1rem, 2.5rem);
    }

    .section {
        padding: 3rem 0;
        /* Tighter spacing on mobile */
    }

    /* Container */
    .container {
        width: 100%;
        padding-left: var(--container-padding);
        padding-right: var(--container-padding);
        overflow-x: hidden;
        /* Safety net */
    }

    /* Navigation */
    .nav-links {
        position: fixed;
        right: -100%;
        top: 60px;
        flex-direction: column;
        background-color: var(--bg-card);
        width: 100%;
        height: calc(100vh - 60px);
        padding: 2rem;
        border-bottom: 1px solid var(--border);
        transition: right 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
        align-items: center;
        justify-content: flex-start;
        gap: 2rem;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        /* Smooth scroll on iOS */
    }

    .nav-links a {
        font-size: 1.25rem;
        /* Larger touch targets */
        padding: 10px;
        /* Touch padding */
        display: block;
        width: 100%;
        text-align: center;
    }

    /* Mobile First Layouts (Stacking) */
    .about-grid,
    .two-col-grid,
    .contact-wrapper {
        grid-template-columns: 1fr;
        gap: 2.5rem;
    }

    /* Grids */
    .projects-grid,
    .services-grid,
    .skills-grid {
        grid-template-columns: 1fr;
        /* Force stack on mobile */
        gap: 1.5rem;
    }

    /* Touch-Friendly Buttons */
    .cta-buttons {
        width: 100%;
        flex-direction: column;
        gap: 1rem;
    }

    .btn {
        width: 100%;
        /* Full width buttons for easy tapping */
        padding: 1rem;
        /* Larger touch zone */
        font-size: 1.1rem;
    }

    .btn-secondary {
        margin-left: 0;
    }

    /* Images & Media */
    img,
    video {
        max-width: 100%;
        height: auto;
        object-fit: cover;
    }

    /* Timeline Adjustments */
    .timeline {
        margin: 0;
        padding-left: 30px;
        border-left: 2px solid var(--border);
        width: 100%;
    }

    .timeline-dot {
        left: -37px;
        width: 12px;
        height: 12px;
        border-width: 2px;
    }

    /* Form Elements (Zoom Safe) */
    input,
    textarea {
        font-size: 16px;
        /* Prevents auto-zoom on iOS */
    }
}

/* Language Toggle Button */
#lang-toggle {
    background: transparent;
    border: 1px solid var(--accent);
    color: var(--text-primary);
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-family: 'Cairo', sans-serif;
    font-weight: 700;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

#lang-toggle:hover {
    background: var(--accent);
    color: #fff;
}

/* RTL Support (Arabic) */
html[lang="ar"] {
    direction: rtl;
    text-align: right;
}

html[lang="ar"] body {
    font-family: 'Cairo', 'Inter', sans-serif;
}

html[lang="ar"] .nav-links {
    right: auto;
    left: -100%;
    transition: left 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
}

html[lang="ar"] .nav-links.active {
    left: 0;
    right: auto;
}

html[lang="ar"] .btn-secondary {
    margin-left: 0;
    margin-right: 1rem;
}

/* Mobile stack - reset margins */
@media (max-width: 768px) {
    html[lang="ar"] .btn-secondary {
        margin-right: 0;
    }
}

html[lang="ar"] .timeline {
    border-left: none;
    border-right: 2px solid var(--border);
    padding-left: 0;
    padding-right: 40px;
}

html[lang="ar"] .timeline-dot {
    left: auto;
    right: -49px;
}

html[lang="ar"] .timeline-content ul li {
    padding-left: 0;
    padding-right: 1.5rem;
}

html[lang="ar"] .timeline-content ul li::before {
    left: auto;
    right: 0;
}

html[lang="ar"] .form-group label {
    left: auto;
    right: 0;
    transform-origin: right top;
}

/* Responsive RTL */
@media (max-width: 480px) {
    html[lang="ar"] .timeline {
        padding-right: 25px;
    }

    html[lang="ar"] .timeline-dot {
        right: -34px;
    }
}

@media (min-width: 481px) and (max-width: 768px) {

    /* Tablet Optimizations */
    .projects-grid {
        grid-template-columns: repeat(2, 1fr);
        /* 2 cols on tablet */
    }

    .services-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {

    /* Small Phone Polish */
    h1 {
        line-height: 1.1;
    }

    .hero-content p {
        font-size: 1rem;
        line-height: 1.5;
        padding: 0 5px;
    }

    .section-title::after {
        width: 40px;
        /* Smaller divider */
    }
}

/* ---------------------------------------------------
   Project Gallery Grids
--------------------------------------------------- */
.gallery-section {
    padding: 2rem 0 6rem;
}

.gallery-grid-large {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    align-items: start;
    /* Prevents items from stretching to row height */
}

.gallery-item {
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    /* aspect-ratio: 1 / 1; Removed for original size */
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.gallery-item:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow);
    border-color: var(--accent);
}

.gallery-item img {
    width: 100%;
    height: auto;
    /* Allow natural height */
    /* object-fit: cover; Removed to stop cropping */
    transition: transform 0.5s ease;
    display: block;
}

.gallery-item:hover img {
    transform: scale(1.05);
}

/* Video Grid */
.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
    align-items: start;
}

.video-item {
    border-radius: 12px;
    overflow: hidden;
    background-color: #000;
    border: 1px solid var(--border);
    position: relative;
}

.video-item video {
    width: 100%;
    height: auto;
    display: block;
}

/* Page Title specialized for gallery pages */
.gallery-header {
    text-align: center;
    padding: 20px 0 40px;
    /* Reduced top padding */
}

.gallery-header h1 {
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

/* Back Link */
.back-link-wrapper {
    padding-top: 100px;
    /* Clears fixed header */
    padding-bottom: 20px;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--accent);
    font-weight: 600;
    padding: 0.5rem 1.2rem;
    border: 1px solid var(--accent);
    border-radius: 30px;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.back-link:hover {
    background-color: var(--accent);
    color: #fff;
    transform: translateX(-5px);
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
}

html[lang="ar"] .back-link:hover {
    transform: translateX(5px);
}

/* Responsive adjustment for massive grids */
@media (max-width: 768px) {
    .gallery-grid-large {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.8rem;
    }
}

@media (max-width: 480px) {
    .gallery-grid-large {
        grid-template-columns: 1fr;
    }
}