/* --- VARIABLES & THEME --- */
:root {
    --primary: #c084fc;
    --secondary: #a78bfa;
    --accent: #fbbf24;
    --cyan: #67e8f9;
    --purple: #a78bfa;
    --green: #86efac;
    --bg-dark: #0f172a;
    --bg-darker: #020617;
    --bg-card: #1e293b;
    --bg-hover: #334155;
    --border: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    
    /* Gradients */
    --gradient-1: linear-gradient(135deg, #c084fc 0%, #a78bfa 50%, #67e8f9 100%);
    
    /* Spacing & Effects */
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-glow: 0 0 30px rgba(192,132,252,0.3);
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Fonts */
    --font-primary: 'Tajawal', sans-serif;
    --font-code: 'Fira Code', monospace;
}

/* Light Theme overrides */
[data-theme="light"] {
    --bg-dark: #ffffff;
    --bg-darker: #f8f9fa;
    --bg-card: #ffffff;
    --bg-hover: #f1f3f5;
    --border: #e5e7eb;
    --text-primary: #1f2937;
    --text-secondary: #4b5563;
    --text-muted: #9ca3af;
}

/* --- RESET & BASE --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: var(--font-primary);
    font-weight: 500;
    background: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.7;
    transition: background 0.3s, color 0.3s;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 { 
    font-weight: 700;
    line-height: 1.2;
}
a { 
    text-decoration: none; 
    color: inherit;
}
ul { list-style: none; }
img { max-width: 100%; height: auto; }

/* Accessibility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* --- LOADER --- */
.loader-screen {
    position: fixed;
    top: 0; left: 0; 
    width: 100%; 
    height: 100%;
    background: var(--bg-darker);
    display: flex; 
    justify-content: center; 
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s;
}
.loader-content { text-align: center; }
.loader-code-text {
    font-family: var(--font-code); 
    color: var(--primary);
    margin-bottom: 2rem; 
    text-align: left;
}
.code-line {
    opacity: 0;
    animation: fadeInLine 0.5s forwards;
}
.code-line[data-line="1"] { animation-delay: 0s; }
.code-line[data-line="2"] { animation-delay: 0.2s; }
.code-line[data-line="3"] { animation-delay: 0.4s; }
@keyframes fadeInLine {
    to { opacity: 1; }
}
.loader-spinner-wrapper {
    margin: 2rem auto;
}
.loader-spinner {
    width: 50px; 
    height: 50px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { 
    to { transform: rotate(360deg); } 
}
.loader-percentage {
    color: var(--text-muted);
    font-family: var(--font-code);
    font-size: 0.9rem;
}

/* --- HEADER & NAV --- */
.main-header {
    position: fixed; 
    top: 0; left: 0; 
    width: 100%;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    z-index: 1000;
    transition: all 0.3s;
}
.main-header.scrolled {
    background: rgba(15, 23, 42, 0.95);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
.nav-container {
    max-width: 1200px; 
    margin: 0 auto; 
    padding: 1rem 2rem;
    display: flex; 
    justify-content: space-between; 
    align-items: center;
}
.brand-logo {
    font-family: var(--font-code); 
    font-size: 1.5rem;
    font-weight: 700; 
    color: var(--primary);
}
.logo-bracket { color: var(--purple); }
.nav-menu { 
    display: flex; 
    gap: 2rem; 
    align-items: center;
}
.nav-link {
    color: var(--text-secondary); 
    font-weight: 600; 
    font-size: 0.95rem;
    transition: color 0.2s; 
    display: flex; 
    align-items: center; 
    gap: 0.5rem;
}
.nav-link:hover, 
.nav-link.active { 
    color: var(--primary); 
}
.nav-controls { 
    display: flex; 
    gap: 0.8rem; 
    align-items: center;
}
.theme-toggle, .menu-toggle {
    background: var(--bg-card); 
    border: 1px solid var(--border);
    color: var(--text-primary); 
    padding: 0.5rem 0.8rem;
    border-radius: 8px; 
    cursor: pointer; 
    transition: all 0.2s;
}
.theme-toggle:hover,
.menu-toggle:hover {
    background: var(--bg-hover);
    transform: scale(1.05);
}
.menu-toggle { 
    display: none; 
    flex-direction: column;
    gap: 4px;
}
.menu-toggle span {
    width: 20px;
    height: 2px;
    background: var(--text-primary);
    transition: all 0.3s;
}

/* --- HERO SECTION --- */
.hero-section {
    min-height: 100vh; 
    display: flex; 
    align-items: center;
    position: relative; 
    padding: 6rem 0 4rem; 
    overflow: hidden;
}
.hero-background {
    position: absolute; 
    top: 0; left: 0; 
    width: 100%; 
    height: 100%; 
    z-index: -1;
}
.code-grid-bg {
    position: absolute; 
    width: 100%; 
    height: 100%;
    background-image: 
        linear-gradient(var(--bg-hover) 1px, transparent 1px),
        linear-gradient(90deg, var(--bg-hover) 1px, transparent 1px);
    background-size: 40px 40px; 
    opacity: 0.1;
}
.hero-container {
    max-width: 1200px; 
    margin: 0 auto; 
    padding: 0 2rem;
    display: grid; 
    grid-template-columns: 1fr 1fr; 
    gap: 4rem; 
    align-items: center;
}
.hero-greeting { 
    font-family: var(--font-code); 
    color: var(--primary); 
    margin-bottom: 1rem; 
    font-size: 1.1rem;
}
.greeting-cursor {
    animation: blink 1s infinite;
}
@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}
.hero-name {
    font-family: var(--font-code); 
    font-size: clamp(2rem, 5vw, 3.5rem);
    line-height: 1.2; 
    margin-bottom: 1.5rem;
}
.name-prefix, .name-suffix { 
    color: var(--purple); 
    font-size: 0.6em;
}
.name-value {
    display: block; 
    background: var(--gradient-1);
    -webkit-background-clip: text; 
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.hero-title {
    font-family: var(--font-code); 
    font-size: 1.25rem;
    color: var(--cyan); 
    margin-bottom: 2rem;
}
.hero-description {
    color: var(--text-secondary); 
    font-size: 1.1rem;
    margin-bottom: 2.5rem; 
    max-width: 550px;
}
.hero-buttons { 
    display: flex; 
    gap: 1.5rem;
    flex-wrap: wrap;
}
.btn {
    display: inline-flex; 
    align-items: center; 
    gap: 0.5rem;
    padding: 0.8rem 1.5rem; 
    border-radius: 8px; 
    font-weight: 600;
    transition: transform 0.2s, box-shadow 0.2s;
}
.btn:hover { 
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(192, 132, 252, 0.3);
}
.btn-primary { 
    background: var(--gradient-1); 
    color: #fff;
    border: none;
}
.btn-secondary { 
    border: 1px solid var(--primary); 
    color: var(--primary);
    background: transparent;
}
.btn-secondary:hover {
    background: var(--primary);
    color: white;
}

/* Hero Image & Badges */
.hero-image-wrapper { 
    position: relative; 
    display: flex; 
    justify-content: center;
}
.hero-image-container { 
    width: 350px; 
    height: 350px; 
    position: relative;
}
.profile-image-glow {
    position: absolute;
    inset: -20px;
    background: radial-gradient(circle, rgba(192, 132, 252, 0.3), transparent 70%);
    animation: pulse 3s ease-in-out infinite;
    z-index: 1;
}
@keyframes pulse {
    0%, 100% { opacity: 0.5; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.05); }
}
.profile-image-frame {
    width: 100%; 
    height: 100%; 
    border-radius: 50%;
    border: 4px solid var(--primary); 
    background: var(--bg-card);
    display: flex; 
    align-items: center; 
    justify-content: center;
    box-shadow: 0 0 50px rgba(192, 132, 252, 0.2);
    position: relative; 
    z-index: 2;
}
.floating-badge {
    position: absolute; 
    background: var(--bg-card);
    border: 1px solid var(--border); 
    padding: 0.8rem 1.2rem;
    border-radius: 12px; 
    display: flex; 
    align-items: center; 
    gap: 0.8rem;
    box-shadow: var(--shadow-sm); 
    z-index: 3; 
    min-width: 180px;
    animation: floatBadge 3s ease-in-out infinite;
}
@keyframes floatBadge {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}
.floating-badge i { 
    font-size: 1.5rem; 
    color: var(--primary);
}
.badge-content {
    flex: 1;
}
.badge-title { 
    display: block; 
    font-weight: 700; 
    font-size: 0.9rem;
}
.badge-libs { 
    display: block; 
    font-size: 0.75rem; 
    color: var(--text-muted);
}
.badge-1 { 
    top: 0; 
    right: -20px;
    animation-delay: 0s;
}
.badge-2 { 
    bottom: 20px; 
    right: -20px;
    animation-delay: 0.5s;
}
.badge-3 { 
    bottom: 50%; 
    left: -40px;
    animation-delay: 1s;
}

/* Scroll Indicator */
.scroll-indicator {
    position: absolute; 
    bottom: 2rem; 
    left: 50%; 
    transform: translateX(-50%);
    display: flex; 
    flex-direction: column; 
    align-items: center;
    gap: 0.5rem; 
    color: var(--text-muted);
}
.scroll-mouse {
    width: 26px; 
    height: 40px; 
    border: 2px solid var(--text-muted);
    border-radius: 20px; 
    position: relative;
}
.scroll-wheel {
    width: 4px; 
    height: 8px; 
    background: var(--primary);
    border-radius: 2px; 
    position: absolute;
    top: 6px; 
    left: 50%; 
    transform: translateX(-50%);
    animation: scrollWheel 2s infinite;
}
@keyframes scrollWheel {
    0% { top: 6px; opacity: 1; }
    100% { top: 20px; opacity: 0; }
}
.scroll-text {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* --- SECTIONS GENERAL --- */
.section { 
    padding: 5rem 0;
}
.section-container { 
    max-width: 1200px; 
    margin: 0 auto; 
    padding: 0 2rem;
}
.section-header {
    display: flex; 
    align-items: center; 
    gap: 1.5rem; 
    margin-bottom: 3rem;
}
.section-number { 
    font-family: var(--font-code); 
    color: var(--primary); 
    font-size: 1.5rem; 
    font-weight: 700;
}
.section-title { 
    font-family: var(--font-code); 
    font-size: clamp(1.5rem, 4vw, 2rem);
    white-space: nowrap;
}
.title-bracket { 
    color: var(--purple);
}
.section-line { 
    flex: 1; 
    height: 1px; 
    background: var(--border);
}

/* --- ABOUT SECTION --- */
.about-content {
    display: grid; 
    grid-template-columns: 1.2fr 0.8fr; 
    gap: 4rem; 
    align-items: center;
}
.about-text { 
    font-size: 1.05rem; 
    color: var(--text-secondary); 
    margin-bottom: 2rem;
}
.timeline-title {
    color: var(--text-primary);
    font-size: 1.2rem;
}
.timeline-achievements {
    display: grid;
    gap: 1rem;
}
.achievement-item {
    display: flex; 
    align-items: center; 
    gap: 0.8rem;
    color: var(--text-primary); 
    font-size: 1rem;
    padding: 1rem; 
    background: var(--bg-card);
    border: 1px solid var(--border); 
    border-radius: 8px;
    transition: border-color 0.3s;
}
.achievement-item:hover {
    border-color: var(--primary);
}
.achievement-item i { 
    color: var(--primary); 
    font-size: 1.2rem;
}

.code-block {
    background: var(--bg-darker); 
    padding: 2rem; 
    border-radius: 12px;
    font-family: var(--font-code); 
    font-size: 0.9rem; 
    border: 1px solid var(--border);
}
.code-line { 
    margin-bottom: 0.5rem;
}
.code-line.indent { 
    padding-left: 1.5rem;
}
.code-keyword { color: var(--purple); }
.code-variable { color: var(--cyan); }
.code-string { color: var(--green); }
.code-operator { color: var(--text-secondary); }
.code-property { color: var(--cyan); }
.code-brace { color: var(--text-primary); }

/* --- SKILLS SECTION --- */
.skills-grid {
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); 
    gap: 2rem;
}
.skill-category {
    background: var(--bg-card); 
    padding: 2rem; 
    border-radius: 12px;
    border: 1px solid var(--border); 
    transition: transform 0.3s, border-color 0.3s;
}
.skill-category:hover { 
    border-color: var(--primary); 
    transform: translateY(-5px);
}
.category-title {
    color: var(--primary); 
    margin-bottom: 1.5rem; 
    font-family: var(--font-code);
    font-size: 1.2rem; 
    border-bottom: 1px solid var(--border); 
    padding-bottom: 0.5rem;
}
.skill-items {
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); 
    gap: 1rem;
}
.skill-item {
    background: var(--bg-darker); 
    padding: 0.8rem 0.5rem; 
    border-radius: 8px;
    border: 1px solid var(--border); 
    text-align: center;
    transition: all 0.2s; 
    display: flex; 
    align-items: center; 
    justify-content: center;
}
.skill-item:hover {
    border-color: var(--cyan); 
    background: rgba(103, 232, 249, 0.05);
    transform: translateY(-2px);
}
.skill-name {
    font-size: 0.9rem; 
    color: var(--text-primary); 
    font-weight: 500;
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    gap: 0.5rem;
}
.skill-name i { 
    font-size: 1.5rem; 
    color: var(--primary); 
    margin-bottom: 0.2rem;
}

/* --- EXPERIENCE (TIMELINE) --- */
.timeline {
    position: relative; 
    border-left: 2px solid var(--border);
    margin-left: 1rem; 
    padding-left: 2rem;
}
.timeline-item { 
    margin-bottom: 3rem; 
    position: relative;
}
.timeline-marker {
    position: absolute; 
    left: -2.6rem; 
    top: 0; 
    width: 16px; 
    height: 16px;
    background: var(--primary); 
    border-radius: 50%; 
    border: 3px solid var(--bg-dark);
    transition: transform 0.3s;
}
.timeline-item:hover .timeline-marker {
    transform: scale(1.2);
}
.timeline-content {
    background: var(--bg-card); 
    padding: 2rem; 
    border-radius: 12px;
    border: 1px solid var(--border); 
    transition: transform 0.2s, border-color 0.3s;
}
.timeline-content:hover { 
    transform: translateX(5px); 
    border-color: var(--primary);
}
.timeline-header {
    display: flex; 
    justify-content: space-between; 
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.timeline-year { 
    font-family: var(--font-code); 
    color: var(--cyan); 
    font-size: 0.9rem;
}
.timeline-badge {
    background: var(--primary); 
    color: #fff; 
    padding: 0.2rem 0.6rem;
    border-radius: 20px; 
    font-size: 0.7rem; 
    font-weight: 700;
}
.timeline-company { 
    color: var(--text-muted); 
    font-size: 0.9rem; 
    margin-bottom: 1rem;
}
.timeline-description { 
    font-size: 0.95rem; 
    margin-bottom: 1rem;
    color: var(--text-secondary);
}
.timeline-tags { 
    display: flex; 
    gap: 0.5rem; 
    flex-wrap: wrap;
}
.tag {
    background: var(--bg-darker); 
    color: var(--primary); 
    padding: 0.3rem 0.6rem;
    border-radius: 4px; 
    font-size: 0.8rem; 
    font-family: var(--font-code);
}

/* --- CONTACT SECTION --- */
.contact-info { 
    display: grid; 
    gap: 1.5rem; 
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    margin-bottom: 2rem;
}
.contact-item {
    background: var(--bg-card); 
    padding: 2rem; 
    border-radius: 12px;
    border: 1px solid var(--border); 
    display: flex; 
    align-items: center; 
    gap: 1.5rem;
    transition: border-color 0.3s, transform 0.3s;
}
.contact-item:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
}
.contact-icon {
    font-size: 1.5rem; 
    color: var(--primary); 
    background: var(--bg-darker);
    width: 50px; 
    height: 50px; 
    display: flex; 
    align-items: center; 
    justify-content: center;
    border-radius: 10px;
    flex-shrink: 0;
}
.contact-details {
    flex: 1;
}
.contact-label { 
    display: block; 
    font-size: 0.85rem; 
    color: var(--text-muted);
}
.contact-value { 
    font-family: var(--font-code); 
    font-weight: 600; 
    color: var(--text-primary);
    word-break: break-word;
}
.contact-value:hover {
    color: var(--primary);
}

/* --- FOOTER --- */
.main-footer {
    border-top: 1px solid var(--border); 
    padding: 2rem 0; 
    margin-top: 4rem;
    background: var(--bg-darker);
}
.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
}
.footer-content { 
    display: flex; 
    justify-content: center; 
    align-items: center;
}
.footer-text { 
    font-size: 0.9rem; 
    color: var(--text-muted);
    text-align: center;
}
.footer-copyright {
    color: var(--primary);
    font-weight: 600;
}

/* --- PARTICLES --- */
.particle {
    position: absolute; 
    color: var(--primary); 
    opacity: 0.2;
    font-family: var(--font-code); 
    animation: floatParticle linear infinite;
    pointer-events: none;
}
@keyframes floatParticle {
    0% { transform: translateY(100vh) rotate(0deg); opacity: 0; }
    50% { opacity: 0.3; }
    100% { transform: translateY(-100px) rotate(360deg); opacity: 0; }
}

/* --- MEDIA QUERIES --- */
@media (max-width: 900px) {
    .hero-container { 
        grid-template-columns: 1fr; 
        text-align: center;
    }
    .hero-content {
        order: 2;
    }
    .hero-buttons { 
        justify-content: center;
    }
    .hero-image-wrapper { 
        order: 1; 
        margin-bottom: 2rem;
    }
    .hero-image-container { 
        width: 280px; 
        height: 280px;
    }
    .floating-badge { 
        display: none;
    }
    .about-content { 
        grid-template-columns: 1fr;
    }
    .about-image-wrapper { 
        display: none;
    }
}

@media (max-width: 768px) {
    .menu-toggle { 
        display: flex;
    }
    .nav-menu {
        position: fixed; 
        top: 70px; 
        left: -100%; 
        width: 100%; 
        height: calc(100vh - 70px);
        background: var(--bg-dark); 
        flex-direction: column; 
        justify-content: center;
        transition: left 0.3s; 
        border-top: 1px solid var(--border);
    }
    .nav-menu.active { 
        left: 0;
    }
    .hero-name { 
        font-size: 2.5rem;
    }
    .section-title { 
        font-size: 1.5rem;
    }
    .contact-info { 
        grid-template-columns: 1fr;
    }
    .skills-grid {
        grid-template-columns: 1fr;
    }
    .skill-items {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .hero-buttons {
        flex-direction: column;
        width: 100%;
    }
    .btn {
        width: 100%;
        justify-content: center;
    }
    .section {
        padding: 3rem 0;
    }
    .timeline {
        margin-left: 0.5rem;
        padding-left: 1.5rem;
    }
}

/* Performance optimizations */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
