:root {
  --bg: #09090f;
  --panel: rgba(18, 18, 30, 0.78);
  --panel-strong: rgba(22, 22, 36, 0.95);
  --text: #f5f7ff;
  --muted: #b8bdd3;
  --line: rgba(255,255,255,0.08);
  --primary: #8b5cf6;
  --primary-2: #b58cff;
  --shadow: 0 20px 60px rgba(73, 35, 150, 0.35);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --grid-line: rgba(255,255,255,0.03);
  --header-bg: rgba(9,9,15,0.62);
  --chip-bg: rgba(255,255,255,0.04);
  --chip-line: rgba(255,255,255,0.08);
  --surface: rgba(255,255,255,0.03);
  --surface-2: rgba(255,255,255,0.04);
  --border-soft: rgba(255,255,255,0.08);
  --card-bg: rgba(16,16,28,0.82);
  --nav-mobile-bg: rgba(13,13,22,0.96);
  --accent-text: #ddd2ff;
  --accent-text-2: #d6c6ff;
  --accent-text-3: #e8ddff;
  --accent-text-4: #f3ecff;
  --accent-text-5: #f1eaff;
  --accent-text-6: #f4efff;
}

body[data-theme="light"] {
  --bg: #f4f2fb;
  --panel: rgba(255, 255, 255, 0.82);
  --panel-strong: rgba(255, 255, 255, 0.96);
  --text: #17152b;
  --muted: #57536f;
  --line: rgba(20, 10, 50, 0.09);
  --primary: #7c3aed;
  --primary-2: #6d28d9;
  --shadow: 0 20px 50px rgba(124, 58, 237, 0.14);
  --grid-line: rgba(20,10,50,0.045);
  --header-bg: rgba(244,242,251,0.72);
  --chip-bg: rgba(20,10,50,0.045);
  --chip-line: rgba(20,10,50,0.09);
  --surface: rgba(20,10,50,0.035);
  --surface-2: rgba(20,10,50,0.05);
  --border-soft: rgba(20,10,50,0.09);
  --card-bg: rgba(255,255,255,0.92);
  --nav-mobile-bg: rgba(255,255,255,0.98);
  --accent-text: #6d28d9;
  --accent-text-2: #6d28d9;
  --accent-text-3: #5b21b6;
  --accent-text-4: #4c1d95;
  --accent-text-5: #4c1d95;
  --accent-text-6: #4c1d95;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: 'Inter', sans-serif;
  background: radial-gradient(circle at top, rgba(139,92,246,0.16), transparent 25%), var(--bg);
  color: var(--text);
  overflow-x: hidden;
  transition: background .35s ease, color .35s ease;
}

body[data-lang="ar"],
body[data-lang="ar-eg"] {
  font-family: 'Cairo', 'Inter', sans-serif;
}

/* Letter-spacing breaks Arabic letter-joining (cursive shaping), which is what
   caused the garbled/disconnected look in the hero heading and section titles.
   Reset it everywhere while in Arabic mode. */
body[data-lang="ar"] *,
body[data-lang="ar-eg"] * {
  letter-spacing: normal;
}

body[data-lang="ar"] .lead,
body[data-lang="ar-eg"] .lead,
body[data-lang="ar"] .panel p,
body[data-lang="ar-eg"] .panel p {
  line-height: 2;
}

body[data-lang="ar"] .hero h1,
body[data-lang="ar-eg"] .hero h1 {
  line-height: 1.35;
  font-weight: 700;
}

body[data-lang="ar"] .section-heading h2,
body[data-lang="ar-eg"] .section-heading h2 {
  line-height: 1.45;
}

body[data-lang="ar"] .timeline-top h3,
body[data-lang="ar-eg"] .timeline-top h3,
body[data-lang="ar"] .project-card h3,
body[data-lang="ar-eg"] .project-card h3,
body[data-lang="ar"] .cert-body h3,
body[data-lang="ar-eg"] .cert-body h3 {
  line-height: 1.6;
}

html[dir="rtl"] .info-list li strong { text-align: left; }
html[dir="rtl"] .project-card ul { padding-left: 0; padding-right: 18px; }
html[dir="rtl"] .timeline-top,
html[dir="rtl"] .footer-wrap { direction: rtl; }
html[dir="rtl"] .cert-link,
html[dir="rtl"] .lang-switch { direction: ltr; }

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
.container { width: min(1180px, calc(100% - 40px)); margin: 0 auto; }

.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 38px 38px;
  mask-image: radial-gradient(circle at center, black 30%, transparent 85%);
  pointer-events: none;
  z-index: -3;
}

.bg-orb {
  position: fixed;
  width: 380px;
  height: 380px;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.28;
  z-index: -2;
}
.orb-1 { background: #8b5cf6; top: -120px; right: -120px; }
.orb-2 { background: #4f2dc8; bottom: -160px; left: -120px; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(18px);
  background: var(--header-bg);
  border-bottom: 1px solid var(--line);
}

.nav-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 82px;
}

.controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lang-switch {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--chip-bg);
}
.lang-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: 'Inter', 'Cairo', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: .2s ease;
}
.lang-btn:hover { color: var(--text); }
.lang-btn.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
}

.theme-btn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--chip-bg);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: .2s ease;
  flex-shrink: 0;
}
.theme-btn:hover { border-color: var(--primary-2); }
.theme-btn svg { width: 20px; height: 20px; }
.theme-btn .icon-sun { display: none; }
body[data-theme="light"] .theme-btn .icon-moon { display: none; }
body[data-theme="light"] .theme-btn .icon-sun { display: block; }

@media (max-width: 760px) {
  .controls { order: 2; }
  .lang-switch { padding: 3px; }
  .lang-btn { padding: 6px 8px; font-size: 0.74rem; }
}

.brand {
  font-weight: 800;
  letter-spacing: 0.3px;
  font-size: 1.05rem;
}

.nav {
  display: flex;
  gap: 26px;
}

.nav a {
  color: var(--muted);
  font-size: 0.96rem;
  transition: 0.25s ease;
}
.nav a:hover { color: var(--text); }

.menu-btn {
  display: none;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
}
.menu-btn span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text);
  margin: 4px auto;
}

.hero {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 48px;
  align-items: center;
  min-height: calc(100vh - 82px);
  padding: 48px 0 28px;
}

.eyebrow,
.section-tag,
.project-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--accent-text);
  padding: 10px 14px;
  border: 1px solid rgba(139, 92, 246, 0.28);
  border-radius: 999px;
  background: rgba(139, 92, 246, 0.1);
  backdrop-filter: blur(10px);
}

.hero h1 {
  margin: 18px 0 18px;
  font-size: clamp(2.8rem, 6vw, 5.4rem);
  line-height: 0.95;
  letter-spacing: -0.05em;
}
.hero h1 .accent {
  color: var(--primary-2);
  text-shadow: 0 0 20px rgba(181, 140, 255, 0.3);
}
.lead {
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.85;
  max-width: 650px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 30px;
}

.btn {
  height: 52px;
  padding: 0 22px;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  transition: transform .25s ease, box-shadow .25s ease, background .25s ease;
}
.btn:hover { transform: translateY(-2px); }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 12px 35px rgba(139,92,246,0.38);
}
.btn-secondary {
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text);
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-top: 34px;
}
.stat-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
}
.stat-card strong { display: block; margin-bottom: 8px; font-size: 0.97rem; }
.stat-card span { color: var(--muted); font-size: 0.88rem; line-height: 1.6; }

.hero-visual {
  position: relative;
  min-height: 640px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.portrait-frame {
  position: relative;
  width: min(470px, 100%);
  border-radius: 32px;
  padding: 14px;
  background: linear-gradient(145deg, rgba(181,140,255,0.35), rgba(255,255,255,0.05));
  box-shadow: var(--shadow);
}
.portrait-frame::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  background: linear-gradient(140deg, rgba(181,140,255,0.22), transparent 55%);
  z-index: -1;
}
.portrait-frame img {
  border-radius: 24px;
  aspect-ratio: 1 / 1.15;
  object-fit: cover;
  object-position: center;
  filter: saturate(1.06) contrast(1.04);
}

.floating-card {
  position: absolute;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid var(--border-soft);
  background: var(--card-bg);
  box-shadow: var(--shadow);
  color: var(--accent-text-5);
  max-width: 220px;
  backdrop-filter: blur(14px);
}
.card-1 { top: 72px; left: 0; }
.card-2 { right: 0; bottom: 95px; }

.section { padding: 72px 0; }
.section-heading { margin-bottom: 28px; }
.section-heading h2 {
  margin: 14px 0 0;
  font-size: clamp(2rem, 4vw, 3rem);
  letter-spacing: -0.03em;
}

.about-grid,
.contact-wrap {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 22px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  transition: background .35s ease, border-color .35s ease, box-shadow .35s ease;
}
.panel p {
  color: var(--muted);
  line-height: 1.85;
  margin: 0 0 16px;
}
.panel p:last-child { margin-bottom: 0; }

.info-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.info-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border-soft);
}
.info-list li:last-child { border-bottom: 0; }
.info-list span { color: var(--muted); }
.info-list strong { text-align: right; }

.timeline {
  display: grid;
  gap: 18px;
}
.timeline-item { position: relative; overflow: hidden; }
.timeline-item::after {
  content: "";
  position: absolute;
  inset: auto -10% -60% auto;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(139,92,246,0.16), transparent 65%);
}
.timeline-top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: baseline;
  margin-bottom: 12px;
}
.timeline-top h3,
.project-card h3 { margin: 0; font-size: 1.15rem; }
.timeline-top span { color: var(--accent-text-2); font-size: 0.94rem; }

.timeline-list {
  position: relative;
  margin: 16px 0 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.85;
}
.timeline-progression {
  position: relative;
  margin: 16px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--border-soft);
  color: var(--accent-text-2);
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.7;
}
html[dir="rtl"] .timeline-list { padding-left: 0; padding-right: 18px; }

.projects-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}
.project-card ul {
  margin: 18px 0 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.85;
}
.project-badge { margin-bottom: 16px; }
.project-badge.soft { background: var(--surface-2); color: var(--accent-text-3); }

.skills-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}
.skill-chip {
  padding: 14px 18px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  color: var(--accent-text-4);
}

.certs-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
}

.cert-card {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.cert-thumb {
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--line);
  background: #fff;
  cursor: zoom-in;
  position: relative;
}
.cert-thumb img {
  width: 100%;
  height: auto;
  display: block;
  transition: transform .35s ease;
}
.cert-thumb:hover img { transform: scale(1.03); }

.cert-body h3 {
  margin: 0 0 8px;
  font-size: 1.05rem;
  line-height: 1.4;
}
.cert-meta {
  display: block;
  color: var(--muted);
  font-size: 0.88rem;
  margin-bottom: 12px;
}
.cert-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--primary-2);
}
.cert-link:hover { color: var(--text); }

.cert-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(5,5,10,0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
}
.cert-lightbox.open {
  opacity: 1;
  pointer-events: auto;
}
.cert-lightbox img {
  max-width: min(1100px, 100%);
  max-height: 90vh;
  border-radius: 14px;
  box-shadow: var(--shadow);
  background: #fff;
}
.cert-lightbox-close {
  position: absolute;
  top: 22px;
  right: 28px;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.12);
  color: #fff;
  font-size: 1.3rem;
  cursor: pointer;
}

@media (max-width: 720px) {
  .certs-grid { grid-template-columns: 1fr; }
}

.contact-wrap {
  align-items: center;
}
.contact-links {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.contact-links a {
  padding: 16px 18px;
  border-radius: 16px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  color: var(--accent-text-6);
}
.contact-links a:hover {
  border-color: rgba(181,140,255,0.42);
  background: rgba(139,92,246,0.08);
}

.site-footer {
  padding: 24px 0 50px;
}
.footer-wrap {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  border-top: 1px solid var(--border-soft);
  padding-top: 24px;
  color: var(--muted);
}
.footer-wrap p { margin: 0; }
.footer-credit {
  margin-top: 6px !important;
  font-size: 0.85rem;
  opacity: 0.75;
}

.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity .7s ease, transform .7s ease;
}
.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}
.delay-1 { transition-delay: .12s; }
.delay-2 { transition-delay: .22s; }

@media (max-width: 1024px) {
  .hero,
  .about-grid,
  .contact-wrap,
  .projects-grid {
    grid-template-columns: 1fr;
  }
  .hero { padding-top: 38px; }
  .hero-visual { min-height: auto; order: -1; }
  .portrait-frame { width: min(460px, 100%); }
  .hero-stats { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .nav {
    position: absolute;
    top: 82px;
    right: 20px;
    width: min(240px, calc(100% - 40px));
    padding: 16px;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: var(--nav-mobile-bg);
    flex-direction: column;
    gap: 14px;
    transform: scale(.96);
    opacity: 0;
    pointer-events: none;
    transition: .25s ease;
  }
  .nav.open {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1);
  }
  .menu-btn { display: block; }
  .hero h1 { font-size: clamp(2.45rem, 12vw, 4.1rem); }
  .panel { padding: 22px; border-radius: 22px; }
  .timeline-top,
  .footer-wrap {
    flex-direction: column;
    align-items: flex-start;
  }
  .floating-card { display: none; }
}
