:root,
[data-theme="dark"] {
  --bg: #0b0d10;
  --bg-2: #101317;
  --surface: rgba(22, 26, 32, 0.72);
  --surface-solid: #161a20;
  --ink: #eceae4;
  --ink-soft: #b2b7c0;
  --ink-mute: #7f8692;
  --line: #232830;
  --accent: #2dd4bf;
  --accent-rgb: 45, 212, 191;
  --accent-ink: #0b0d10;
  --accent-soft: rgba(45, 212, 191, 0.1);
  --glow: rgba(45, 212, 191, 0.18);
}

[data-theme="light"] {
  --bg: #f6f5f1;
  --bg-2: #efede7;
  --surface: rgba(255, 255, 255, 0.8);
  --surface-solid: #ffffff;
  --ink: #15171c;
  --ink-soft: #464b56;
  --ink-mute: #767c88;
  --line: #e2dfd7;
  --accent: #0f766e;
  --accent-rgb: 15, 118, 110;
  --accent-ink: #ffffff;
  --accent-soft: rgba(15, 118, 110, 0.09);
  --glow: rgba(15, 118, 110, 0.12);
}

:root {
  --radius: 16px;
  --max: 1140px;
  --sans: "IBM Plex Sans", "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", "IBM Plex Sans Arabic", ui-monospace, "Cascadia Code", Consolas, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 84px;
  background: var(--bg);
}

body {
  margin: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  transition: opacity 0.18s ease, color 0.3s;
}

body.lang-fade {
  opacity: 0;
}

::selection {
  background: var(--accent);
  color: var(--accent-ink);
}

a {
  color: inherit;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1,
h2,
h3 {
  line-height: 1.2;
}

ul,
ol {
  margin: 0;
  padding: 0;
}

.container {
  position: relative;
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 24px;
}

.mono {
  font-family: var(--mono);
}

#bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.7;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(900px 500px at 85% -10%, var(--glow), transparent 60%),
    radial-gradient(700px 500px at -10% 40%, var(--glow), transparent 60%),
    var(--bg);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 56px 56px;
  opacity: 0.35;
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 30%, transparent 75%);
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 30%, transparent 75%);
}

.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  z-index: 100;
  background: linear-gradient(90deg, var(--accent), #60a5fa);
  transform: scaleX(0);
  transform-origin: left;
}

[dir="rtl"] .scroll-progress {
  transform-origin: right;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid transparent;
  transition: background 0.3s, border-color 0.3s;
}

.site-header.scrolled {
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom-color: var(--line);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  height: 72px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 600;
  white-space: nowrap;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: "IBM Plex Mono", monospace;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 0 24px var(--glow);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 26px;
  list-style: none;
  margin-inline-start: auto;
}

.nav-links a {
  position: relative;
  text-decoration: none;
  font-size: 15px;
  color: var(--ink-soft);
  transition: color 0.2s;
}

.nav-links a:not(.nav-cta)::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -4px;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transition: transform 0.3s var(--ease);
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--ink);
}

.nav-links a:hover::after,
.nav-links a.active::after {
  transform: scaleX(1);
}

.nav-links .nav-cta {
  padding: 7px 16px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  color: var(--accent);
  transition: background 0.2s, color 0.2s;
}

.nav-links .nav-cta:hover {
  background: var(--accent);
  color: var(--accent-ink);
}

.nav-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, transform 0.2s;
}

.tool-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.icon-btn {
  width: 38px;
  padding: 0;
}

[data-theme="dark"] .icon-moon,
[data-theme="light"] .icon-sun {
  display: none;
}

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 6px;
  background: none;
  border: 0;
  padding: 10px 6px;
  cursor: pointer;
}

.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--ink);
  transition: transform 0.25s;
}

.nav-toggle[aria-expanded="true"] span:first-child {
  transform: translateY(4px) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] span:last-child {
  transform: translateY(-4px) rotate(-45deg);
}

.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.8s var(--ease), transform 0.8s var(--ease);
}

.reveal.in {
  opacity: 1;
  transform: none;
}

.hero {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  align-items: center;
  gap: 56px;
  min-height: calc(100vh - 72px);
  padding-top: 40px;
  padding-bottom: 60px;
}

.hero-text > .reveal:nth-child(2) { transition-delay: 0.08s; }
.hero-text > .reveal:nth-child(3) { transition-delay: 0.16s; }
.hero-text > .reveal:nth-child(4) { transition-delay: 0.24s; }
.hero-text > .reveal:nth-child(5) { transition-delay: 0.32s; }
.hero-text > .reveal:nth-child(6) { transition-delay: 0.4s; }
.hero > .code-window { transition-delay: 0.3s; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 13px;
  color: var(--ink-soft);
}

.pulse {
  position: relative;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.pulse::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 2s ease-out infinite;
}

@keyframes pulse {
  from { transform: scale(1); opacity: 0.7; }
  to { transform: scale(3); opacity: 0; }
}

.hero h1 {
  font-size: clamp(46px, 7.5vw, 88px);
  font-weight: 700;
  letter-spacing: -0.035em;
  background: linear-gradient(120deg, var(--ink) 30%, var(--accent) 60%, var(--ink) 90%);
  background-size: 250% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shine 8s ease-in-out infinite;
}

@keyframes shine {
  0%, 100% { background-position: 100% 0; }
  50% { background-position: 0 0; }
}

.role-line {
  margin-top: 14px;
  font-size: clamp(16px, 2vw, 20px);
  color: var(--accent);
  min-height: 1.7em;
}

.prompt {
  color: var(--ink-mute);
}

.caret {
  display: inline-block;
  width: 9px;
  height: 1.1em;
  margin-inline-start: 3px;
  vertical-align: -0.18em;
  background: var(--accent);
  animation: blink 1s steps(1) infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

.hero-lead {
  max-width: 600px;
  margin-top: 22px;
  font-size: clamp(17px, 1.9vw, 20px);
  color: var(--ink-soft);
}

.hero-lead strong {
  color: var(--ink);
  font-weight: 600;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 34px;
}

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 13px 24px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  overflow: hidden;
  transition: transform 0.2s var(--ease), box-shadow 0.3s, border-color 0.2s, color 0.2s;
}

.btn:hover {
  transform: translateY(-2px);
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 8px 30px var(--glow);
}

.btn-primary::after {
  content: "";
  position: absolute;
  top: 0;
  left: -60%;
  width: 40%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.45), transparent);
  transform: skewX(-20deg);
  transition: left 0.6s var(--ease);
}

.btn-primary:hover::after {
  left: 130%;
}

.btn-ghost {
  border: 1px solid var(--line);
  background: var(--surface);
}

.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 44px;
  margin-top: 48px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
  list-style: none;
}

.hero-stats li {
  display: flex;
  flex-direction: column;
}

.stat-num {
  font-family: "IBM Plex Mono", monospace;
  font-size: 38px;
  font-weight: 500;
  color: var(--accent);
  line-height: 1.1;
}

.stat-label {
  margin-top: 4px;
  font-size: 14px;
  color: var(--ink-mute);
}

.code-window {
  border: 1px solid #232830;
  border-radius: var(--radius);
  background: rgba(13, 16, 20, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.02) inset, 0 0 60px var(--glow);
  overflow: hidden;
  text-align: left;
  animation: float 7s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -10px; }
}

.code-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 18px;
  border-bottom: 1px solid #232830;
  background: rgba(255, 255, 255, 0.02);
}

.dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #ff5f57;
}

.dot:nth-child(2) { background: #febc2e; }
.dot:nth-child(3) { background: #28c840; }

.code-file {
  margin-left: 10px;
  font-size: 12.5px;
  color: #7f8692;
}

.code-body {
  margin: 0;
  padding: 22px 22px 18px;
  min-height: 372px;
  font-size: 14px;
  line-height: 1.75;
  color: #d4d4d4;
  white-space: pre;
  overflow-x: auto;
}

.code-caret {
  width: 8px;
  background: #2dd4bf;
}

.code-caret.done {
  display: none;
}

.tk-k { color: #ff7ab2; }
.tk-t { color: #4ec9b0; }
.tk-n { color: #9cdcfe; }
.tk-s { color: #e8b98a; }
.tk-p { color: #c9ccd1; }

.code-status {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 22px;
  border-top: 1px solid #232830;
  font-size: 12.5px;
  color: #7f8692;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.6s var(--ease), transform 0.6s var(--ease);
}

.code-status.show {
  opacity: 1;
  transform: none;
}

.status-ok {
  color: #2dd4bf;
}

.check {
  display: inline-block;
}

.code-status.show .check {
  animation: pop 0.5s var(--ease);
}

@keyframes pop {
  0% { transform: scale(0); }
  70% { transform: scale(1.4); }
  100% { transform: scale(1); }
}

.section {
  padding-top: 110px;
  padding-bottom: 10px;
}

.section-head {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 44px;
}

.section-num {
  font-size: 14px;
  color: var(--accent);
}

.section-num::before {
  content: "// ";
  color: var(--ink-mute);
}

.section-head h2 {
  font-size: clamp(30px, 4vw, 44px);
  letter-spacing: -0.02em;
}

.spot {
  position: relative;
  isolation: isolate;
}

.spot::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: radial-gradient(360px circle at var(--mx, 50%) var(--my, 50%), var(--accent-soft), transparent 70%);
  opacity: 0;
  transition: opacity 0.3s;
}

.spot:hover::before {
  opacity: 1;
}

.about-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 48px;
  align-items: start;
}

.about-text p {
  margin-bottom: 18px;
  color: var(--ink-soft);
}

.about-text strong {
  color: var(--ink);
  font-weight: 600;
}

.about-card {
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.card-label {
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-mute);
  margin-bottom: 14px;
}

.about-card ul {
  list-style: none;
}

.about-card li {
  display: flex;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}

.about-card li::before {
  content: "▹";
  color: var(--accent);
}

[dir="rtl"] .about-card li::before {
  content: "◃";
}

.about-card li:last-child {
  border-bottom: 0;
}

.timeline {
  position: relative;
  list-style: none;
}

.timeline-item {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 32px;
  padding: 34px 0;
  border-top: 1px solid var(--line);
}

.timeline-item:last-child {
  border-bottom: 1px solid var(--line);
}

.timeline-meta {
  font-size: 13.5px;
  color: var(--ink-mute);
  padding-top: 5px;
}

.timeline-body h3 {
  font-size: 22px;
  letter-spacing: -0.01em;
}

.org {
  margin: 6px 0 16px;
  color: var(--accent);
  font-weight: 500;
}

.timeline-body ul {
  list-style: none;
  color: var(--ink-soft);
}

.timeline-body li {
  position: relative;
  padding-inline-start: 22px;
  margin-bottom: 9px;
}

.timeline-body li::before {
  content: "";
  position: absolute;
  inset-inline-start: 2px;
  top: 0.75em;
  width: 7px;
  height: 7px;
  border: 1.5px solid var(--accent);
  border-radius: 2px;
  transform: rotate(45deg);
}

.projects-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 20px;
}

.project-card {
  grid-column: span 2;
  display: flex;
  flex-direction: column;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: border-color 0.3s, transform 0.4s var(--ease), box-shadow 0.4s, opacity 0.8s var(--ease);
}

.project-card.featured {
  grid-column: span 3;
}

.project-card:hover {
  border-color: rgba(var(--accent-rgb), 0.5);
  transform: translateY(-4px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}

.project-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: var(--ink-mute);
  margin-bottom: 18px;
}

.project-date {
  color: var(--accent);
}

.project-card h3 {
  font-size: 20px;
  letter-spacing: -0.01em;
  margin-bottom: 12px;
}

.project-card p {
  margin-bottom: 22px;
  font-size: 15px;
  color: var(--ink-soft);
  flex: 1;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
}

.tags li {
  padding: 4px 11px;
  border: 1px solid rgba(var(--accent-rgb), 0.22);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 12.5px;
  transition: transform 0.2s, background 0.2s;
}

.tags li:hover {
  transform: translateY(-2px);
  background: rgba(var(--accent-rgb), 0.18);
}

.skills-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.skill-group {
  padding: 26px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: border-color 0.3s, opacity 0.8s var(--ease), transform 0.8s var(--ease);
}

.skill-group:hover {
  border-color: rgba(var(--accent-rgb), 0.5);
}

.edu-grid {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 56px;
}

.edu-item {
  padding: 24px 0;
  border-top: 1px solid var(--line);
}

.edu-item:first-child {
  border-top: 0;
  padding-top: 0;
}

.edu-date {
  font-size: 13px;
  color: var(--accent);
}

.edu-item h3 {
  font-size: 20px;
  margin: 8px 0 6px;
}

.edu-item p {
  color: var(--ink-soft);
  font-size: 15px;
}

.cert-list {
  list-style: none;
}

.cert-list li {
  display: flex;
  gap: 20px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
  color: var(--ink-soft);
  transition: color 0.2s, padding 0.3s var(--ease), opacity 0.8s var(--ease), transform 0.8s var(--ease);
}

.cert-list li:hover {
  color: var(--ink);
  padding-inline-start: 8px;
}

.cert-list li:first-child {
  padding-top: 0;
}

.cert-list span {
  flex-shrink: 0;
  color: var(--accent);
  font-size: 13px;
  padding-top: 2px;
}

.contact {
  padding-bottom: 120px;
}

.contact-lead {
  max-width: 560px;
  margin-bottom: 22px;
  color: var(--ink-soft);
  font-size: 19px;
}

.contact-email {
  display: inline-block;
  max-width: 100%;
  font-family: "IBM Plex Sans", sans-serif;
  font-size: clamp(22px, 4.6vw, 48px);
  font-weight: 700;
  letter-spacing: -0.02em;
  text-decoration: none;
  line-height: 1.3;
  word-break: break-all;
  background: linear-gradient(var(--accent), var(--accent)) no-repeat 0 100% / 100% 3px;
  padding-bottom: 4px;
  transition: color 0.3s, background-size 0.4s var(--ease);
}

.contact-email:hover {
  color: var(--accent);
  background-size: 100% 100%;
  color: var(--accent-ink);
}

.contact-links {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 40px;
  list-style: none;
}

.contact-links a {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 11px 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 15px;
  color: var(--ink-soft);
  text-decoration: none;
  transition: border-color 0.2s, color 0.2s, transform 0.2s var(--ease);
}

.contact-links a:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-2px);
}

.site-footer {
  border-top: 1px solid var(--line);
  padding: 28px 0;
  font-size: 14px;
  color: var(--ink-mute);
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

[dir="rtl"] body {
  line-height: 1.85;
}

[dir="rtl"] h1,
[dir="rtl"] h2,
[dir="rtl"] h3,
[dir="rtl"] .card-label {
  letter-spacing: 0;
}

[dir="rtl"] .hero h1 {
  line-height: 1.35;
}

@media (max-width: 1000px) {
  .hero {
    grid-template-columns: 1fr;
    min-height: auto;
    padding-top: 70px;
    gap: 48px;
  }

  .code-window {
    animation: none;
  }

  .about-grid,
  .edu-grid {
    grid-template-columns: 1fr;
    gap: 32px;
  }

  .skills-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .projects-grid {
    grid-template-columns: 1fr 1fr;
  }

  .project-card,
  .project-card.featured {
    grid-column: span 1;
  }
}

@media (max-width: 860px) {
  .nav-toggle {
    display: flex;
  }

  .nav-links {
    position: absolute;
    top: 72px;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    margin: 0;
    padding: 8px 24px 20px;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    display: none;
  }

  .nav-links.open {
    display: flex;
  }

  .nav-links a {
    display: block;
    padding: 12px 0;
    font-size: 17px;
  }

  .nav-links a:not(.nav-cta)::after {
    display: none;
  }

  .nav-links .nav-cta {
    margin-top: 8px;
    text-align: center;
  }
}

@media (max-width: 640px) {
  .brand-name {
    display: none;
  }

  .hero {
    padding-top: 48px;
  }

  .hero-stats {
    gap: 26px;
  }

  .stat-num {
    font-size: 30px;
  }

  .code-body {
    font-size: 12.5px;
    min-height: 0;
    padding: 18px;
  }

  .timeline-item {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .projects-grid,
  .skills-grid {
    grid-template-columns: 1fr;
  }

  .section {
    padding-top: 80px;
  }

  .footer-inner {
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }

  html {
    scroll-behavior: auto;
  }

  .reveal {
    opacity: 1;
    transform: none;
  }
}

[dir="rtl"] .eyebrow,
[dir="rtl"] .timeline-meta,
[dir="rtl"] .project-date {
  font-family: var(--sans);
}
