/* ============================================================
   Elsayed Khaled — Portfolio
   Design tokens, dark/light, RTL, responsive
   ============================================================ */

:root {
    --bg: #0b0d12;
    --bg-soft: #11141c;
    --surface: rgba(255, 255, 255, 0.04);
    --surface-strong: rgba(255, 255, 255, 0.07);
    --border: rgba(255, 255, 255, 0.08);
    --text: #eef1f7;
    --text-soft: #aab1c2;
    --text-dim: #6d7689;
    --accent: #8b5cf6;
    --accent-2: #22d3ee;
    --accent-3: #f472b6;
    --grad: linear-gradient(135deg, #8b5cf6 0%, #6366f1 40%, #22d3ee 100%);
    --grad-soft: linear-gradient(135deg, rgba(139, 92, 246, 0.16), rgba(34, 211, 238, 0.10));
    --shadow-lg: 0 30px 80px -20px rgba(0, 0, 0, 0.6);
    --shadow-md: 0 14px 40px -12px rgba(0, 0, 0, 0.4);
    --radius: 20px;
    --radius-sm: 14px;
    --maxw: 1140px;
    --nav-h: 72px;
    --font-sans: 'Inter', 'Segoe UI', Tahoma, sans-serif;
    --font-display: 'Space Grotesk', var(--font-sans);
    --font-ar: 'Noto Kufi Arabic', var(--font-sans);
}

html.light {
    --bg: #f4f5f8;
    --bg-soft: #ffffff;
    --surface: rgba(10, 12, 20, 0.03);
    --surface-strong: rgba(10, 12, 20, 0.06);
    --border: rgba(10, 12, 20, 0.10);
    --text: #14171f;
    --text-soft: #4a5163;
    --text-dim: #8a93a6;
    --grad: linear-gradient(135deg, #7c3aed 0%, #6366f1 45%, #0891b2 100%);
    --grad-soft: linear-gradient(135deg, rgba(124, 58, 237, 0.10), rgba(8, 145, 178, 0.08));
    --shadow-lg: 0 30px 80px -28px rgba(60, 70, 120, 0.30);
    --shadow-md: 0 14px 40px -16px rgba(60, 70, 120, 0.22);
}

html[dir="rtl"] body { font-family: var(--font-ar); }

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

html { scroll-behavior: smooth; }

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    transition: background-color 0.4s ease, color 0.4s ease;
}

a { color: inherit; text-decoration: none; }
ul { list-style: none; }
img { display: block; max-width: 100%; }

.container { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }

/* Scroll progress */
.scroll-progress {
    position: fixed; top: 0; left: 0; height: 3px; width: 0;
    background: var(--grad); z-index: 2000;
    transition: width 0.1s linear;
}

/* Background ambience */
.bg-ambience { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.bg-ambience .orb { position: absolute; border-radius: 50%; filter: blur(90px); opacity: 0.5; }
.orb-1 { width: 480px; height: 480px; top: -160px; right: -120px; background: radial-gradient(circle, #8b5cf6, transparent 70%); }
.orb-2 { width: 420px; height: 420px; bottom: -160px; left: -120px; background: radial-gradient(circle, #22d3ee, transparent 70%); opacity: 0.35; }
.orb-3 { width: 360px; height: 360px; top: 40%; left: 50%; transform: translateX(-50%); background: radial-gradient(circle, #f472b6, transparent 70%); opacity: 0.25; }
.grid-overlay {
    position: absolute; inset: 0;
    background-image:
        linear-gradient(var(--border) 1px, transparent 1px),
        linear-gradient(90deg, var(--border) 1px, transparent 1px);
    background-size: 64px 64px;
    mask-image: radial-gradient(ellipse at 50% 0%, #000 30%, transparent 75%);
    opacity: 0.6;
}

/* ============================================================ NAV */
.nav {
    position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
    height: var(--nav-h);
    display: flex; align-items: center;
    transition: background 0.3s ease, box-shadow 0.3s ease, border 0.3s ease;
    border-bottom: 1px solid transparent;
}
.nav.scrolled {
    background: color-mix(in srgb, var(--bg) 75%, transparent);
    backdrop-filter: blur(18px) saturate(140%);
    -webkit-backdrop-filter: blur(18px) saturate(140%);
    border-bottom: 1px solid var(--border);
}
.nav-inner {
    width: 100%; max-width: var(--maxw); margin: 0 auto;
    padding: 0 24px;
    display: flex; align-items: center; gap: 18px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-family: var(--font-display); letter-spacing: .2px; }
.brand-mark {
    width: 34px; height: 34px; border-radius: 10px;
    display: grid; place-items: center; font-size: .85rem; font-weight: 700;
    background: var(--grad); color: #fff;
    box-shadow: 0 6px 18px -6px var(--accent);
}
.brand-mark.sm { width: 28px; height: 28px; border-radius: 8px; font-size: .7rem; }
.brand-dot { color: var(--accent-2); }

.nav-links { display: flex; gap: 4px; margin-left: auto; }
.nav-links a {
    padding: 8px 14px; border-radius: 10px; font-size: .92rem; font-weight: 500;
    color: var(--text-soft); transition: color .2s, background .2s;
}
.nav-links a:hover, .nav-links a.active { color: var(--text); background: var(--surface); }

.nav-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
    width: 40px; height: 40px; border-radius: 11px;
    display: grid; place-items: center; cursor: pointer;
    background: var(--surface); border: 1px solid var(--border);
    color: var(--text); transition: background .2s, transform .2s, border .2s;
}
.icon-btn:hover { background: var(--surface-strong); transform: translateY(-1px); }
.icon-btn svg { display: block; }
.icon-sun { display: none; }
html.light .icon-sun { display: block; }
html.light .icon-moon { display: none; }
#langLabel { font-weight: 700; font-size: .95rem; font-family: var(--font-ar); }

.nav-burger { display: none; flex-direction: column; gap: 4px; }
.nav-burger span { width: 18px; height: 2px; background: currentColor; border-radius: 2px; transition: transform .25s, opacity .25s; }
.nav-burger.open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav-burger.open span:nth-child(2) { opacity: 0; }
.nav-burger.open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* ============================================================ HERO */
.hero { padding: calc(var(--nav-h) + 60px) 0 40px; }
.hero-inner {
    max-width: var(--maxw); margin: 0 auto; padding: 0 24px;
    display: grid; grid-template-columns: 1.4fr 1fr; gap: 40px; align-items: center;
}
.eyebrow {
    display: inline-flex; align-items: center; gap: 8px;
    font-size: .82rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
    color: var(--accent-2); margin-bottom: 18px;
}
.eyebrow::before { content: ''; width: 28px; height: 1px; background: var(--accent-2); }
.hero-name {
    font-family: var(--font-display);
    font-size: clamp(2.6rem, 6vw, 4.4rem); line-height: 1; font-weight: 700;
    letter-spacing: -.02em;
    background: linear-gradient(180deg, var(--text), color-mix(in srgb, var(--text) 60%, transparent));
    -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.hero-role { font-size: clamp(1.1rem, 2.4vw, 1.6rem); margin-top: 12px; color: var(--text-soft); font-weight: 500; display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.type-text { color: var(--accent); font-weight: 700; }
.caret { display: inline-block; width: 2px; height: 1.1em; background: var(--accent); margin-left: 2px; animation: blink 1s step-end infinite; transform: translateY(2px); }
@keyframes blink { 50% { opacity: 0; } }
.hero-desc { margin-top: 18px; max-width: 540px; color: var(--text-soft); font-size: 1.05rem; }

.hero-cta { display: flex; gap: 12px; margin-top: 28px; flex-wrap: wrap; }
.btn {
    padding: 13px 24px; border-radius: 12px; font-weight: 600; font-size: .95rem;
    border: 1px solid transparent; cursor: pointer;
    transition: transform .2s, box-shadow .2s, background .2s, border .2s;
    display: inline-flex; align-items: center; gap: 8px;
}
.btn-primary { background: var(--grad); color: #fff; box-shadow: 0 14px 36px -14px var(--accent); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 20px 44px -14px var(--accent); }
.btn-ghost { background: var(--surface); border: 1px solid var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface-strong); transform: translateY(-2px); }

.socials { display: flex; gap: 10px; margin-top: 30px; flex-wrap: wrap; }
.socials a {
    width: 42px; height: 42px; border-radius: 12px;
    display: grid; place-items: center;
    background: var(--surface); border: 1px solid var(--border); color: var(--text-soft);
    transition: transform .2s, color .2s, background .2s, border .2s;
}
.socials a:hover { color: var(--text); transform: translateY(-3px); border-color: var(--accent); background: var(--surface-strong); }
.socials-lg a { width: auto; height: auto; padding: 10px 18px; font-weight: 600; font-size: .92rem; }

/* Portrait */
.hero-portrait { display: flex; justify-content: center; }
.portrait-ring {
    position: relative; width: 100%; max-width: 320px; aspect-ratio: 1 / 1;
    border-radius: 50%; padding: 4px; background: var(--grad);
    box-shadow: var(--shadow-lg);
}
.portrait-ring::after {
    content: ''; position: absolute; inset: -2px; border-radius: 50%;
    background: var(--grad); filter: blur(28px); opacity: .35; z-index: -1;
}
.portrait-ring img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.portrait-badge {
    position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%);
    display: inline-flex; align-items: center; gap: 8px;
    padding: 8px 14px; border-radius: 999px; font-size: .82rem; font-weight: 600;
    background: color-mix(in srgb, var(--bg) 80%, transparent);
    backdrop-filter: blur(10px); border: 1px solid var(--border);
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.2); }

/* Stats */
.hero-stats {
    max-width: var(--maxw); margin: 64px auto 0; padding: 0 24px;
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px;
}
.stat { text-align: center; padding: 22px 10px; border-top: 1px solid var(--border); }
.stat-num { display: block; font-family: var(--font-display); font-size: clamp(1.8rem, 3vw, 2.6rem); font-weight: 700; color: var(--text); }
.stat-label { font-size: .85rem; color: var(--text-dim); }

.scroll-cue {
    position: relative; display: block; width: 26px; height: 44px; margin: 56px auto 0;
    border: 2px solid var(--border); border-radius: 14px;
}
.scroll-cue span { position: absolute; top: 8px; left: 50%; transform: translateX(-50%); width: 4px; height: 8px; border-radius: 2px; background: var(--accent); animation: cue 1.6s ease-in-out infinite; }
@keyframes cue { 0%,100% { opacity: 0; transform: translate(-50%, 0); } 40% { opacity: 1; } 80% { opacity: 0; transform: translate(-50%, 14px); } }

/* ============================================================ SECTIONS */
.section { padding: 110px 0; }
.section-alt { background: var(--bg-soft); }
.section-head { max-width: 760px; margin-bottom: 56px; }
.kicker { display: inline-block; font-size: .82rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--accent-2); margin-bottom: 14px; }
.section-title { font-family: var(--font-display); font-size: clamp(1.8rem, 3.6vw, 2.6rem); font-weight: 700; letter-spacing: -.01em; line-height: 1.15; }

/* About */
.about-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 50px; align-items: start; }
.about-text p { margin-bottom: 18px; color: var(--text-soft); max-width: 60ch; }
.about-meta { margin-top: 28px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.about-meta li { display: flex; flex-direction: column; gap: 2px; font-size: .85rem; color: var(--text-dim); }
.about-meta strong { color: var(--text); font-size: .98rem; }
.about-meta a:hover { color: var(--accent); }

.about-card { position: relative; padding: 30px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); overflow: hidden; }
.card-glow { position: absolute; inset: 0; background: var(--grad-soft); opacity: .6; pointer-events: none; }
.about-card h3 { position: relative; font-family: var(--font-display); font-size: 1.05rem; margin-bottom: 18px; }
.principles { position: relative; display: flex; flex-direction: column; gap: 16px; }
.principles li { display: flex; align-items: flex-start; gap: 14px; }
.principles span { font-family: var(--font-display); font-weight: 700; color: var(--accent); }
.principles p { color: var(--text-soft); font-size: .96rem; }

/* Stack */
.stack-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; }
.stack-col { padding: 28px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.stack-col h3 { font-family: var(--font-display); font-size: 1.1rem; margin-bottom: 18px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips li { padding: 7px 13px; border-radius: 999px; font-size: .85rem; font-weight: 500; background: var(--surface-strong); border: 1px solid var(--border); color: var(--text); transition: color .2s, border .2s, transform .2s; }
.chips li:hover { color: var(--accent); border-color: var(--accent); transform: translateY(-2px); }

/* Journey timeline */
.timeline { position: relative; padding-left: 28px; }
.timeline::before { content: ''; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.timeline-item { position: relative; padding-bottom: 36px; list-style: none; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot { position: absolute; left: -28px; top: 6px; width: 12px; height: 12px; border-radius: 50%; background: var(--grad); box-shadow: 0 0 0 5px var(--bg), 0 0 0 6px var(--border); }
html[dir="rtl"] .timeline-dot { left: auto; right: -28px; }
.timeline-body { padding: 22px 26px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); }
.timeline-date { display: inline-block; font-size: .78rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--accent-2); margin-bottom: 8px; }
.timeline-body h3 { font-family: var(--font-display); font-size: 1.15rem; margin-bottom: 8px; }
.timeline-body p { color: var(--text-soft); font-size: .96rem; }

/* Work */
.work-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.work-card { border-radius: var(--radius); overflow: hidden; background: var(--surface); border: 1px solid var(--border); transition: transform .25s, box-shadow .25s, border .25s; }
.work-card:hover { transform: translateY(-6px); box-shadow: var(--shadow-md); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.work-thumb { height: 160px; display: grid; place-items: center; color: #fff; position: relative; overflow: hidden; }
.work-thumb::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 40%, var(--bg-soft)); }
.thumb-1 { background: linear-gradient(135deg, #7c3aed, #4338ca); }
.thumb-2 { background: linear-gradient(135deg, #0891b2, #0e7490); }
.thumb-3 { background: linear-gradient(135deg, #db2777, #9333ea); }
.work-mark { font-family: var(--font-display); font-weight: 700; font-size: 2rem; letter-spacing: .1em; }
.work-thumb svg { position: relative; z-index: 1; }
.work-body { padding: 22px; }
.work-tag { display: inline-block; font-size: .72rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--accent-2); margin-bottom: 8px; }
.work-body h3 { font-family: var(--font-display); font-size: 1.2rem; margin-bottom: 8px; }
.work-body p { color: var(--text-soft); font-size: .92rem; margin-bottom: 14px; }
.work-link { font-weight: 600; font-size: .9rem; color: var(--accent); display: inline-flex; align-items: center; gap: 6px; }
.work-link:hover span { transform: translateX(3px); }
.work-link.muted { color: var(--text-dim); }
.work-link span { transition: transform .2s; }

/* Contact */
.contact-wrap { position: relative; text-align: center; padding: 70px 30px; border-radius: 28px; background: var(--surface); border: 1px solid var(--border); overflow: hidden; }
.contact-glow { position: absolute; inset: 0; background: var(--grad-soft); opacity: .8; }
.contact-wrap > * { position: relative; }
.contact-title { font-family: var(--font-display); font-size: clamp(1.8rem, 4vw, 2.8rem); font-weight: 700; margin-bottom: 12px; }
.contact-sub { color: var(--text-soft); max-width: 50ch; margin: 0 auto 28px; }
.contact-email {
    display: inline-flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 600; font-size: clamp(1.05rem, 2.5vw, 1.5rem);
    padding: 14px 26px; border-radius: 14px; background: var(--surface-strong); border: 1px solid var(--border); color: var(--text);
    transition: transform .2s, color .2s, border .2s;
}
.contact-email:hover { color: var(--accent); border-color: var(--accent); transform: translateY(-2px); }

/* Phone button under email */
.contact-phone {
    display: inline-flex; align-items: center; gap: 8px; margin-top: 14px;
    font-family: var(--font-display); font-weight: 500; font-size: 1rem;
    padding: 10px 20px; border-radius: 12px; background: transparent; border: 1px solid var(--border); color: var(--text-soft);
    transition: color .2s, border .2s, transform .2s;
}
.contact-phone:hover { color: var(--accent); border-color: var(--accent); transform: translateY(-2px); }

/* Certifications */
.certs { margin-top: 40px; }
.certs-title { font-family: var(--font-display); font-size: 1.15rem; margin-bottom: 18px; color: var(--text); }
.certs-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.cert { display: flex; align-items: flex-start; gap: 14px; padding: 18px 20px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); transition: transform .2s, border .2s; }
.cert:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
.cert-icon { flex-shrink: 0; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--grad-soft); color: var(--accent); border: 1px solid var(--border); }
.cert div { display: flex; flex-direction: column; gap: 3px; }
.cert strong { font-size: .95rem; }
.cert span { font-size: .8rem; color: var(--text-dim); }

/* Education timeline variant */
.timeline-item.edu .timeline-body { background: transparent; border-style: dashed; }
.edu-dot { background: linear-gradient(135deg, #22d3ee, #6366f1) !important; }
.socials-lg { justify-content: center; margin-top: 30px; }

/* Footer */
.footer { padding: 44px 0 36px; border-top: 1px solid var(--border); }
.footer-inner { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 14px; }
.footer-brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 700; }
.footer-brand .brand-mark { color: #fff; }
.footer-copy, .footer-built { font-size: .84rem; color: var(--text-dim); }
.footer-built { text-align: right; }

/* Reveal on scroll */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity .7s cubic-bezier(.2,.7,.2,1), transform .7s cubic-bezier(.2,.7,.2,1); }
.reveal.in { opacity: 1; transform: none; }

/* RTL adjustments */
html[dir="rtl"] .nav-links { margin-left: 0; margin-right: auto; }
html[dir="rtl"] .timeline { padding-left: 0; padding-right: 28px; }
html[dir="rtl"] .timeline::before { left: auto; right: 5px; }
html[dir="rtl"] .footer-built { text-align: left; }
html[dir="rtl"] .eyebrow::before { margin-inline-end: 8px; }

/* ============================================================ RESPONSIVE */
@media (max-width: 960px) {
    .hero-inner { grid-template-columns: 1fr; text-align: center; }
    .hero-portrait { order: -1; }
    .hero-text { display: flex; flex-direction: column; align-items: center; }
    .hero-desc { margin-inline: auto; }
    .eyebrow { justify-content: center; }
    .hero-stats { grid-template-columns: repeat(2, 1fr); }
    .about-grid { grid-template-columns: 1fr; }
    .stack-grid { grid-template-columns: 1fr; }
    .work-grid { grid-template-columns: 1fr; }
    .certs-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
    .nav-links {
        position: fixed; top: var(--nav-h); right: 0; left: 0;
        flex-direction: column; gap: 4px; padding: 16px 24px 24px;
        background: color-mix(in srgb, var(--bg) 92%, transparent);
        backdrop-filter: blur(18px); border-bottom: 1px solid var(--border);
        transform: translateY(-130%); transition: transform .35s cubic-bezier(.2,.7,.2,1);
        pointer-events: none;
    }
    .nav-links.open { transform: none; pointer-events: auto; }
    .nav-links a { width: 100%; padding: 12px 16px; }
    .nav-burger { display: flex; }
    .section { padding: 80px 0; }
    .about-meta { grid-template-columns: 1fr 1fr; }
    .footer-inner { justify-content: center; text-align: center; }
    .footer-built { text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
    * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
    .reveal { opacity: 1; transform: none; }
    html { scroll-behavior: auto; }
}