/* ============ Tokens ============ */
:root {
  --bg: #0a0c12;
  --bg-2: #10131c;
  --surface: rgba(255, 255, 255, 0.035);
  --surface-2: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #e8eaf2;
  --muted: #9aa1b5;
  --dim: #6b7287;
  --accent: #7c6cff;
  --accent-2: #22d3ee;
  --grad: linear-gradient(120deg, var(--accent), var(--accent-2));
  --ok: #34d399;
  --radius: 18px;
  --radius-sm: 10px;
  --shadow: 0 20px 60px -20px rgba(0, 0, 0, 0.6);
  --font: "IBM Plex Sans Arabic", "Inter", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --nav-h: 72px;
}
html[lang="en"] { --font: "Inter", "IBM Plex Sans Arabic", system-ui, sans-serif; }

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: var(--nav-h); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
[hidden] { display: none !important; }
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
::selection { background: var(--accent); color: #fff; }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 3px; border-radius: 6px; }

.container { width: min(1140px, 100% - 32px); margin-inline: auto; }

/* ============ Background ============ */
.bg-grid {
  position: fixed; inset: 0; z-index: -2; pointer-events: none;
  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 80% 60% at 50% 0%, #000 30%, transparent 75%);
  opacity: 0.5;
}
.bg-glow {
  position: fixed; z-index: -1; pointer-events: none;
  inset: 0;
  background: radial-gradient(circle 450px at 50% 0, rgba(124, 108, 255, 0.22), rgba(34, 211, 238, 0.08) 40%, transparent 70%);
}

/* ============ Nav ============ */
.nav {
  position: fixed; inset-inline: 0; top: 0; z-index: 50; height: var(--nav-h);
  transition: background 0.3s, border-color 0.3s, backdrop-filter 0.3s;
  border-bottom: 1px solid transparent;
}
.nav.scrolled {
  background: rgba(10, 12, 18, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-color: var(--border);
}
.nav-inner { height: 100%; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.logo {
  font-family: var(--mono); font-weight: 500; font-size: 1.05rem; direction: ltr;
  display: inline-flex; align-items: center; gap: 2px;
}
.logo b { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.nav-links { display: flex; gap: 6px; }
.nav-links a {
  padding: 8px 14px; border-radius: 999px; color: var(--muted); font-size: 0.95rem;
  transition: color 0.2s, background 0.2s;
}
.nav-links a:hover, .nav-links a.active { color: var(--text); background: var(--surface-2); }
.nav-actions { display: flex; align-items: center; gap: 10px; }
.lang-btn {
  font: 600 0.85rem var(--font); color: var(--text); cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px;
  padding: 7px 14px; transition: border-color 0.2s;
}
.lang-btn:hover { border-color: var(--border-strong); }
.menu-btn { display: none; width: 40px; height: 40px; border: 1px solid var(--border); background: var(--surface-2); border-radius: 12px; cursor: pointer; position: relative; }
.menu-btn span { position: absolute; inset-inline-start: 11px; width: 18px; height: 2px; background: var(--text); border-radius: 2px; transition: transform 0.3s, top 0.3s; }
.menu-btn span:first-child { top: 15px; }
.menu-btn span:last-child { top: 22px; }
.menu-btn[aria-expanded="true"] span:first-child { top: 19px; transform: rotate(45deg); }
.menu-btn[aria-expanded="true"] span:last-child { top: 19px; transform: rotate(-45deg); }

/* ============ Buttons ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px; border-radius: 999px; font-weight: 600; font-size: 0.97rem;
  border: 1px solid transparent; cursor: pointer; font-family: inherit;
  transition: transform 0.2s, box-shadow 0.2s, background 0.2s, border-color 0.2s;
}
.btn:hover { transform: translateY(-2px); }
.btn-primary { background: var(--grad); color: #0a0c12; box-shadow: 0 10px 30px -10px rgba(124, 108, 255, 0.7); }
.btn-primary:hover { box-shadow: 0 14px 36px -10px rgba(34, 211, 238, 0.7); }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--border-strong); background: var(--surface-2); }
.btn-block { width: 100%; }

/* ============ Hero ============ */
.hero { min-height: 100vh; min-height: 100svh; display: flex; align-items: center; position: relative; padding: calc(var(--nav-h) + 40px) 0 80px; }
.hero-inner { display: grid; grid-template-columns: 1.2fr 1fr; gap: 56px; align-items: center; }
.badge {
  display: inline-flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--ok);
  background: rgba(52, 211, 153, 0.08); border: 1px solid rgba(52, 211, 153, 0.25);
  padding: 6px 14px; border-radius: 999px; margin-bottom: 22px;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.6); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 10px rgba(52, 211, 153, 0); } 100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); } }
.hero-hello { color: var(--muted); margin: 0 0 6px; font-size: 1.1rem; }
.hero-name { font-size: clamp(2.4rem, 6vw, 4.4rem); font-weight: 800; letter-spacing: -0.02em; }
html[lang="ar"] .hero-name { letter-spacing: 0; font-weight: 700; }
.hero-role {
  font-size: clamp(1.2rem, 2.6vw, 1.75rem); font-weight: 600; margin: 14px 0 18px;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
  min-height: 1.3em;
}
.caret { color: var(--accent-2); -webkit-text-fill-color: var(--accent-2); animation: blink 1s steps(1) infinite; margin-inline-start: 2px; }
@keyframes blink { 50% { opacity: 0; } }
.hero-tagline { color: var(--muted); font-size: 1.1rem; max-width: 34ch; margin: 0 0 32px; }
html[lang="en"] .hero-tagline { max-width: 46ch; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 32px; }

.socials { display: flex; gap: 10px; flex-wrap: wrap; }
.social {
  width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border); color: var(--muted);
  transition: color 0.2s, border-color 0.2s, transform 0.2s;
}
.social:hover { color: var(--text); border-color: var(--border-strong); transform: translateY(-2px); }
.social svg { width: 19px; height: 19px; }

.hero-visual { position: relative; display: grid; place-items: center; }
.hero-visual::before {
  content: ""; position: absolute; inset: 10% 5%; border-radius: 50%; z-index: -1;
  background: radial-gradient(circle, rgba(124, 108, 255, 0.35), rgba(34, 211, 238, 0.12) 50%, transparent 70%);
  filter: blur(30px);
}
.code-card {
  width: 100%; max-width: 460px; direction: ltr; text-align: left;
  background: rgba(16, 19, 28, 0.9); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-strong); border-radius: 16px; overflow: hidden;
  box-shadow: var(--shadow), 0 0 0 1px rgba(124, 108, 255, 0.08); animation: float 6s ease-in-out infinite;
}
.code-bar { display: flex; align-items: center; gap: 14px; padding: 12px 16px; border-bottom: 1px solid var(--border); background: rgba(255, 255, 255, 0.02); }
.code-bar span { font: 0.78rem var(--mono); color: var(--dim); }
.code-dots { display: flex; gap: 6px; }
.code-dots i { width: 10px; height: 10px; border-radius: 50%; background: #ff5f57; }
.code-dots i:nth-child(2) { background: #febc2e; }
.code-dots i:nth-child(3) { background: #28c840; }
.code-card pre { margin: 0; padding: 18px 20px 22px; font: 0.88rem/1.8 var(--mono); color: var(--muted); white-space: pre; overflow-x: auto; }
.code-card .k { color: #c792ea; } .code-card .s { color: #a5e3a0; } .code-card .p { color: #f78c6c; } .code-card .v { color: var(--accent-2); } .code-card .c { color: var(--dim); font-style: italic; }
@keyframes float { 50% { transform: translateY(-10px); } }

.scroll-hint { position: absolute; bottom: 28px; left: 50%; transform: translateX(-50%); width: 26px; height: 42px; border: 2px solid var(--border-strong); border-radius: 14px; }
.scroll-hint span { position: absolute; top: 8px; left: 50%; width: 4px; height: 8px; margin-left: -2px; border-radius: 2px; background: var(--muted); animation: scroll 1.8s infinite; }
@keyframes scroll { 0% { opacity: 1; transform: translateY(0); } 100% { opacity: 0; transform: translateY(14px); } }

/* ============ Sections ============ */
.section { padding: 110px 0; }
.section-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 48px; }
.section-head h2 { font-size: clamp(1.8rem, 4vw, 2.6rem); font-weight: 700; }
.section-head::after { content: ""; flex: 1; height: 1px; align-self: center; margin-inline-start: 10px; }
[dir="ltr"] .section-head::after { background: linear-gradient(to right, var(--border-strong), transparent); }
[dir="rtl"] .section-head::after { background: linear-gradient(to left, var(--border-strong), transparent); }
.eyebrow { font: 500 0.95rem var(--mono); color: var(--accent-2); }

/* About */
.about-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 48px; align-items: start; }
.about-text p { color: var(--muted); font-size: 1.08rem; margin: 0 0 18px; }
.about-text p:first-child { color: var(--text); }
.about-side { display: grid; gap: 14px; }
.stats { display: grid; gap: 14px; }
.lang-card { padding: 22px 24px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.lang-card h3 { font-size: 1rem; color: var(--muted); font-weight: 600; margin-bottom: 12px; }
.lang-card ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.lang-card li { display: flex; justify-content: space-between; gap: 12px; }
.lang-card li span:last-child { color: var(--accent-2); font-size: 0.92rem; }
.stat {
  padding: 22px 24px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.stat strong { font: 800 2.2rem var(--font); background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; direction: ltr; }
.stat span { color: var(--muted); }

/* Skills */
.skills-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.skill-card {
  padding: 28px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border);
  position: relative; overflow: hidden; transition: border-color 0.3s, transform 0.3s;
}
.skill-card::before {
  content: ""; position: absolute; inset: 0; opacity: 0; transition: opacity 0.3s;
  background: radial-gradient(400px circle at var(--mx, 50%) var(--my, 0%), rgba(124, 108, 255, 0.12), transparent 50%);
}
.skill-card:hover { border-color: var(--border-strong); transform: translateY(-4px); }
.skill-card:hover::before { opacity: 1; }
.skill-icon { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: rgba(124, 108, 255, 0.12); color: var(--accent); margin-bottom: 18px; }
.skill-icon svg { width: 24px; height: 24px; }
.skill-card h3 { font-size: 1.2rem; margin-bottom: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; position: relative; }
.chip {
  font: 500 0.82rem var(--mono); padding: 5px 11px; border-radius: 8px; direction: ltr;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
}

/* Projects */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 32px; }
.filter {
  font: 500 0.92rem var(--font); padding: 8px 18px; border-radius: 999px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); color: var(--muted); transition: all 0.2s;
}
.filter:hover { color: var(--text); }
.filter.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.projects-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; }
.project {
  display: flex; flex-direction: column; border-radius: var(--radius); overflow: hidden;
  background: var(--surface); border: 1px solid var(--border);
  transition: transform 0.35s, border-color 0.35s, box-shadow 0.35s, opacity 0.35s;
}
.project:hover { transform: translateY(-6px); border-color: var(--border-strong); box-shadow: var(--shadow); }
.project.hide { display: none; }
.project-cover { aspect-ratio: 16 / 10; position: relative; overflow: hidden; background: var(--bg-2); }
.project-cover img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.5s; }
.project:hover .project-cover img { transform: scale(1.05); }
.cover-btn { all: unset; display: block; width: 100%; height: 100%; cursor: zoom-in; position: relative; }
.cover-btn:focus-visible { outline: 2px solid var(--accent-2); outline-offset: -2px; }
.project-cover img { object-position: top center; }
.cover-zoom {
  position: absolute; bottom: 12px; inset-inline-end: 12px; display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 999px; font-size: 0.78rem; color: var(--text);
  background: rgba(10, 12, 18, 0.72); backdrop-filter: blur(6px); border: 1px solid var(--border-strong);
  opacity: 0.85; transition: opacity 0.2s;
}
.cover-zoom svg { width: 14px; height: 14px; }
.cover-btn:hover .cover-zoom { opacity: 1; }

.lightbox {
  width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; padding: 56px 72px;
  border: 0; background: rgba(5, 6, 10, 0.92); color: var(--text);
}
.lightbox[open] { display: grid; place-items: center; }
.lightbox::backdrop { background: transparent; }
.lightbox figure { margin: 0; display: grid; gap: 12px; justify-items: center; max-width: 100%; max-height: 100%; }
.lightbox img { max-width: 100%; max-height: calc(100vh - 150px); border-radius: 12px; border: 1px solid var(--border-strong); box-shadow: var(--shadow); }
.lightbox figcaption { color: var(--muted); font-size: 0.92rem; }
.lb-btn {
  position: absolute; width: 46px; height: 46px; border-radius: 50%; cursor: pointer; font-size: 1.5rem; line-height: 1;
  color: var(--text); background: var(--surface-2); border: 1px solid var(--border-strong); transition: background 0.2s;
}
.lb-btn:hover { background: rgba(255, 255, 255, 0.14); }
.lb-close { top: 16px; inset-inline-end: 16px; font-size: 1.1rem; }
.lb-prev, .lb-next { top: 50%; transform: translateY(-50%); }
.lb-prev { inset-inline-start: 14px; }
.lb-next { inset-inline-end: 14px; }
[dir="rtl"] .lb-prev, [dir="rtl"] .lb-next { transform: translateY(-50%) scaleX(-1); }
@media (max-width: 760px) { .lightbox { padding: 64px 12px; } .lb-prev, .lb-next { top: auto; bottom: 16px; transform: none; } [dir="rtl"] .lb-prev, [dir="rtl"] .lb-next { transform: scaleX(-1); } }

.project-cover .placeholder {
  position: absolute; inset: 0; display: grid; place-items: center;
  font: 700 2.4rem var(--mono); color: rgba(255, 255, 255, 0.9);
}
.project-cover .tag-featured {
  position: absolute; top: 12px; inset-inline-start: 12px; font-size: 0.75rem; font-weight: 600;
  padding: 4px 10px; border-radius: 999px; background: rgba(10, 12, 18, 0.7); backdrop-filter: blur(6px); border: 1px solid var(--border-strong);
}
.project-body { padding: 22px; display: flex; flex-direction: column; gap: 12px; flex: 1; }
.project-body h3 { font-size: 1.15rem; }
.project-body p { margin: 0; color: var(--muted); font-size: 0.95rem; flex: 1; }
.project-body .project-note { flex: 0; font: 0.78rem/1.6 var(--mono); color: var(--dim); padding: 8px 10px; border-radius: 8px; background: rgba(0, 0, 0, 0.25); border: 1px dashed var(--border-strong); }
.project-cover .tag-status {
  position: absolute; top: 12px; inset-inline-end: 12px; font-size: 0.75rem; font-weight: 600; color: #fbbf24;
  padding: 4px 10px; border-radius: 999px; background: rgba(10, 12, 18, 0.7); backdrop-filter: blur(6px); border: 1px solid rgba(251, 191, 36, 0.35);
}
.project-links { display: flex; gap: 16px; padding-top: 6px; }
.project-links a { display: inline-flex; align-items: center; gap: 6px; font-size: 0.9rem; font-weight: 600; color: var(--accent-2); }
.project-links a:hover { text-decoration: underline; text-underline-offset: 4px; }
.project-links svg { width: 16px; height: 16px; }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; top: 8px; bottom: 8px; inset-inline-start: 7px; width: 2px; background: linear-gradient(var(--accent), var(--accent-2), transparent); }
.tl-item { position: relative; padding-inline-start: 44px; padding-bottom: 40px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before { content: ""; position: absolute; inset-inline-start: 0; top: 6px; width: 16px; height: 16px; border-radius: 50%; background: var(--bg); border: 3px solid var(--accent); }
.tl-card { padding: 22px 26px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.tl-period { font: 500 0.85rem var(--mono); color: var(--accent-2); }
.tl-card h3 { font-size: 1.15rem; margin: 6px 0 2px; }
.tl-company { color: var(--muted); font-size: 0.95rem; }
.tl-card ul { margin: 12px 0 0; padding-inline-start: 20px; color: var(--muted); }
.tl-card li { margin-bottom: 4px; }

/* Contact */
.contact-card {
  display: grid; grid-template-columns: 1fr 1.1fr; gap: 48px; padding: 48px; border-radius: 28px;
  background: linear-gradient(160deg, rgba(124, 108, 255, 0.1), rgba(34, 211, 238, 0.04) 60%), var(--surface);
  border: 1px solid var(--border-strong);
}
.contact-info h2 { font-size: clamp(1.8rem, 4vw, 2.5rem); margin: 8px 0 14px; }
.contact-info > p { color: var(--muted); margin: 0 0 24px; }
.contact-email { display: inline-block; font: 600 1.15rem var(--mono); direction: ltr; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; margin-bottom: 8px; word-break: break-all; }
.contact-loc { color: var(--text); margin: 0 0 4px; }
.contact-reloc { color: var(--dim); margin: 0 0 20px; font-size: 0.93rem; }
.cv-inline { margin-bottom: 24px; }
.contact-form { display: grid; gap: 16px; }
.contact-form label { display: grid; gap: 6px; font-size: 0.9rem; color: var(--muted); }
.contact-form input, .contact-form textarea {
  font: inherit; color: var(--text); background: rgba(0, 0, 0, 0.25); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px; resize: vertical; transition: border-color 0.2s, box-shadow 0.2s;
}
.contact-form input:focus, .contact-form textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124, 108, 255, 0.2); }
.contact-form .invalid { border-color: #f87171; }
.form-note { margin: 0; min-height: 1.4em; font-size: 0.9rem; color: var(--ok); }
.form-note.err { color: #f87171; }

/* Footer */
.footer { border-top: 1px solid var(--border); padding: 28px 0; color: var(--dim); font-size: 0.9rem; }
.footer-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.footer p { margin: 0; }
.to-top { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; border: 1px solid var(--border); color: var(--muted); }
.to-top:hover { color: var(--text); border-color: var(--border-strong); }

/* Reveal */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity 0.7s ease, transform 0.7s ease; }
.reveal.in { opacity: 1; transform: none; }

/* ============ Responsive ============ */
@media (max-width: 980px) {
  .hero-inner { grid-template-columns: 1fr; text-align: center; gap: 64px; }
  .hero-visual { order: 1; }
  .code-card { margin-inline: auto; }
  .hero-tagline { margin-inline: auto; }
  .hero-cta, .hero-text .socials { justify-content: center; }
  .about-grid, .contact-card { grid-template-columns: 1fr; }
  .skills-grid, .projects-grid { grid-template-columns: repeat(2, 1fr); }
  .stats { grid-template-columns: repeat(3, 1fr); }
  .stat { flex-direction: column; align-items: flex-start; gap: 4px; }
}
@media (max-width: 760px) {
  .menu-btn { display: block; }
  .nav-links {
    position: fixed; top: var(--nav-h); inset-inline: 0; flex-direction: column; gap: 4px; padding: 16px;
    background: rgba(10, 12, 18, 0.96); backdrop-filter: blur(14px); border-bottom: 1px solid var(--border);
    transform: translateY(-120%); opacity: 0; pointer-events: none; transition: transform 0.3s, opacity 0.3s;
  }
  .nav-links.open { transform: none; opacity: 1; pointer-events: auto; }
  .nav-links a { padding: 12px 16px; border-radius: 12px; }
  .section { padding: 80px 0; }
  .skills-grid, .projects-grid, .stats { grid-template-columns: 1fr; }
  .stat { flex-direction: row; align-items: center; }
  .contact-card { padding: 28px 20px; }
  .code-card pre { font-size: 0.74rem; padding: 14px 16px 16px; }
  .scroll-hint { display: none; }
}

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