/* =========================================================
   Palette derived from the logo: blue → teal → green
   Two themes: [data-theme="light"] (default) and [data-theme="dark"]
   ========================================================= */
:root {
  --blue: #276ea2;
  --teal: #2c7b8a;
  --green: #3b915e;
  --grad: linear-gradient(135deg, #276ea2 0%, #2c7b8a 50%, #3b915e 100%);
  --radius: 14px;
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;

  /* light tokens */
  --bg: #ffffff;
  --bg-2: #f1f7f6;
  --surface: #ffffff;
  --heading: #0b2533;
  --text: #1b2c34;
  --text-2: #3a4d55;
  --muted: #5a6b73;
  --line: #dbe6e5;
  --line-strong: #c4d8d6;
  --link: #276ea2;
  --accent-text: #2c7b8a;
  --chip-bg: #eaf3f4;
  --chip-line: #d3e5e7;
  --chip-text: #123a4c;
  --input-bg: #fbfdfd;
  --shadow: 0 1px 2px rgba(11, 37, 51, .06), 0 10px 28px rgba(11, 37, 51, .08);

  --nav-bg: rgba(255, 255, 255, .82);
  --nav-text: #33464f;
  --nav-hover: rgba(11, 37, 51, .06);
  --nav-line: rgba(11, 37, 51, .08);

  --hero-bg:
    radial-gradient(55% 70% at 88% 5%, rgba(39,110,162,.18), transparent 70%),
    radial-gradient(50% 60% at 5% 100%, rgba(59,145,94,.16), transparent 70%),
    linear-gradient(180deg, #f6fafb, #eef6f5);
  --hero-text: #0b2533;
  --hero-text-2: #3a4d55;
  --hero-soft: rgba(11, 37, 51, .06);
  --hero-line: rgba(11, 37, 51, .12);
  --headline-grad: linear-gradient(90deg, #276ea2, #2c7b8a 50%, #3b915e);
  --orbit: rgba(11, 37, 51, .08);
  --badge-bg: rgba(59,145,94,.1);
  --badge-line: rgba(59,145,94,.3);
  --badge-text: #2a7449;

  --band-bg: #0b2533; /* contact band stays brand-dark in both themes */
  --foot-bg: #071a24;
}

[data-theme="dark"] {
  --bg: #0a1c25;
  --bg-2: #0d2430;
  --surface: #102a37;
  --heading: #eef6f8;
  --text: #d5e3e7;
  --text-2: #b3c6cc;
  --muted: #8ba2aa;
  --line: #1e3c4a;
  --line-strong: #2c5566;
  --link: #7cc4ea;
  --accent-text: #6fd0c0;
  --chip-bg: #133241;
  --chip-line: #21495a;
  --chip-text: #cfe6ec;
  --input-bg: #0d2430;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 12px 30px rgba(0,0,0,.35);

  --nav-bg: rgba(8, 26, 35, .82);
  --nav-text: rgba(255,255,255,.78);
  --nav-hover: rgba(255,255,255,.08);
  --nav-line: rgba(255,255,255,.08);

  --hero-bg:
    radial-gradient(60% 70% at 85% 10%, rgba(39,110,162,.5), transparent 70%),
    radial-gradient(50% 60% at 10% 100%, rgba(59,145,94,.4), transparent 70%),
    #0b2533;
  --hero-text: #ffffff;
  --hero-text-2: rgba(255,255,255,.78);
  --hero-soft: rgba(255,255,255,.05);
  --hero-line: rgba(255,255,255,.14);
  --headline-grad: linear-gradient(90deg, #7cc4ea, #8fdcae);
  --orbit: rgba(255,255,255,.09);
  --badge-bg: rgba(59,145,94,.18);
  --badge-line: rgba(143,220,174,.35);
  --badge-text: #bdf0cf;

  --band-bg: #081d28;
  --foot-bg: #051219;
  color-scheme: dark;
}

html[lang="ar"] { --font: "IBM Plex Sans Arabic", "IBM Plex Sans", system-ui, sans-serif; }

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 76px; }
body { margin: 0; font-family: var(--font); color: var(--text); background: var(--bg); line-height: 1.65; font-size: 17px; -webkit-font-smoothing: antialiased; transition: background-color .3s, color .3s; }
img { max-width: 100%; display: block; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0; color: var(--heading); }
html[lang="ar"] h1, html[lang="ar"] h2, html[lang="ar"] h3 { line-height: 1.45; }
.wrap { width: min(1140px, 100% - 40px); margin-inline: auto; }
.ico { flex: none; }
.flip { display: inline-flex; }
html[dir="rtl"] .flip { transform: scaleX(-1); }

/* ---------- Nav ---------- */
.nav { position: sticky; top: 0; z-index: 50; background: var(--nav-bg); backdrop-filter: saturate(160%) blur(12px); -webkit-backdrop-filter: saturate(160%) blur(12px); border-bottom: 1px solid var(--nav-line); }
.nav-in { display: flex; align-items: center; justify-content: space-between; height: 64px; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--heading); font-weight: 600; letter-spacing: .01em; }
.brand:hover { text-decoration: none; }
.avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; object-position: 50% 8%; background: var(--grad); box-shadow: 0 0 0 2px var(--bg), 0 0 0 3.5px var(--teal); }
.menu { display: flex; align-items: center; gap: 2px; margin-inline-start: auto; }
.menu a { color: var(--nav-text); padding: 8px 12px; border-radius: 8px; font-size: 15px; font-weight: 500; }
.menu a:hover { color: var(--heading); background: var(--nav-hover); text-decoration: none; }
.menu .lang { display: inline-flex; align-items: center; gap: 6px; margin-inline-start: 8px; border: 1px solid var(--line-strong); color: var(--heading); }
.nav-tools { display: flex; align-items: center; gap: 6px; order: 3; }
.theme-toggle { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line-strong); background: transparent; color: var(--heading); cursor: pointer; transition: background .2s; }
.theme-toggle:hover { background: var(--nav-hover); }
.theme-toggle .i-sun { display: none; }
[data-theme="dark"] .theme-toggle .i-sun { display: inline-flex; }
[data-theme="dark"] .theme-toggle .i-moon { display: none; }
.nav-toggle { display: none; background: none; border: 0; width: 40px; height: 40px; padding: 10px; cursor: pointer; }
.nav-toggle span { display: block; height: 2px; background: var(--heading); margin: 5px 0; border-radius: 2px; transition: transform .2s; }

/* ---------- Hero ---------- */
.hero { position: relative; overflow: hidden; color: var(--hero-text); padding: 64px 0 56px; background: var(--hero-bg); }
.orbits { position: absolute; width: 900px; inset-inline-end: -260px; top: -160px; fill: none; stroke: var(--orbit); stroke-width: 2; pointer-events: none; animation: spin 90s linear infinite; }
.orbits .node { fill: var(--bg); stroke: var(--hero-line); stroke-width: 3; }
@keyframes spin { to { transform: rotate(360deg); } }
.hero-in { position: relative; display: grid; grid-template-columns: 1.3fr 1fr; gap: 48px; align-items: center; }
.hero h1 { color: var(--hero-text); font-size: clamp(2.4rem, 5.5vw, 4rem); font-weight: 700; letter-spacing: -.02em; }
html[lang="ar"] .hero h1 { letter-spacing: 0; }
.headline { font-size: clamp(1.1rem, 2vw, 1.35rem); font-weight: 600; margin: 8px 0 18px; background: var(--headline-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tagline { color: var(--hero-text-2); max-width: 34em; margin: 0 0 28px; font-size: 1.05rem; }
.badge { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; padding: 6px 14px; border-radius: 999px; background: var(--badge-bg); border: 1px solid var(--badge-line); color: var(--badge-text); margin: 0 0 20px; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: #3fbf72; box-shadow: 0 0 0 0 rgba(63,191,114,.7); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 10px rgba(63,191,114,0); } 100% { box-shadow: 0 0 0 0 rgba(63,191,114,0); } }
.cta { display: flex; flex-wrap: wrap; gap: 12px; }
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 12px 22px; border-radius: 10px; font-weight: 600; font-size: 16px; border: 1px solid transparent; cursor: pointer; font-family: inherit; transition: transform .15s, box-shadow .15s, background .15s; }
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn.primary { background: var(--grad); color: #fff; box-shadow: 0 6px 18px rgba(44,123,138,.35); }
.btn.ghost { color: var(--hero-text); border-color: var(--hero-line); background: var(--hero-soft); }
.btn.ghost:hover { background: var(--nav-hover); }
.hero-meta { list-style: none; padding: 0; margin: 28px 0 0; display: flex; flex-wrap: wrap; gap: 20px; color: var(--hero-text-2); font-size: 15px; }
.hero-meta li { display: flex; align-items: center; gap: 6px; }
.hero-meta a { color: var(--hero-text); }

/* Portrait: cut-out photo standing on a gradient disc (echoes the logo) */
.hero-visual { display: flex; justify-content: center; padding-bottom: 20px; }
.portrait { --d: min(360px, 76vw); position: relative; width: var(--d); height: calc(var(--d) * 1.28); margin: 0; }
.portrait .disc { position: absolute; inset-inline: 0; bottom: 0; height: var(--d); border-radius: 50%; background: var(--grad); box-shadow: 0 30px 70px rgba(11,37,51,.28); }
.portrait .disc::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: radial-gradient(circle at 30% 25%, rgba(255,255,255,.22), transparent 55%); }
.portrait .ring { position: absolute; inset-inline: -18px; bottom: -18px; height: calc(var(--d) + 36px); border-radius: 50%; border: 2px dashed var(--hero-line); animation: spin 60s linear infinite; }
.portrait .ring i { position: absolute; width: 16px; height: 16px; border-radius: 50%; background: var(--bg); border: 3px solid var(--teal); transform: translate(-50%, -50%); }
.portrait .ring i:first-child { top: 14.6%; left: 85.4%; }
.portrait .ring i:last-child { top: 85.4%; left: 14.6%; border-color: var(--green); }
.portrait .clip { position: absolute; inset: 0; display: flex; justify-content: center; align-items: flex-end; overflow: hidden; border-radius: 0 0 calc(var(--d) / 2) calc(var(--d) / 2); }
.portrait .clip img { height: 96%; width: auto; max-width: none; object-fit: contain; object-position: bottom; filter: drop-shadow(0 8px 16px rgba(0,0,0,.22)); }
.portrait.cutout { height: calc(var(--d) * 1.33); }
/* Ordinary (non-transparent) photo: classic round frame */
.portrait.circle { height: var(--d); }
.portrait.circle .clip { inset: 10px; border-radius: 50%; }
.portrait.circle .clip img { width: 100%; height: 100%; object-fit: cover; object-position: center top; filter: none; }

.stats { position: relative; display: grid; grid-template-columns: repeat(4, 1fr); margin: 48px 0 0; border: 1px solid var(--hero-line); border-radius: var(--radius); background: var(--hero-soft); backdrop-filter: blur(6px); }
.stats div { padding: 22px 24px; }
.stats div + div { border-inline-start: 1px solid var(--hero-line); }
.stats dt { font-family: var(--mono); font-size: clamp(1.7rem, 3vw, 2.3rem); font-weight: 500; background: var(--headline-grad); -webkit-background-clip: text; background-clip: text; color: transparent; direction: ltr; unicode-bidi: isolate; display: inline-block; }
.stats dd { margin: 2px 0 0; color: var(--hero-text-2); font-size: 15px; }

/* ---------- Sections ---------- */
.sec { padding: 96px 0; }
.sec.tint { background: var(--bg-2); }
.kicker { display: inline-flex; align-items: center; gap: 10px; color: var(--accent-text); font-weight: 600; font-size: 14px; letter-spacing: .08em; text-transform: uppercase; margin: 0 0 10px; }
html[lang="ar"] .kicker { letter-spacing: 0; font-size: 15px; }
.kicker::before { content: ""; width: 26px; height: 2px; background: var(--grad); border-radius: 2px; }
.sec h2 { font-size: clamp(1.7rem, 3.2vw, 2.4rem); font-weight: 700; letter-spacing: -.015em; margin-bottom: 40px; max-width: 22em; }
html[lang="ar"] .sec h2 { letter-spacing: 0; }

.about { display: grid; grid-template-columns: 1fr 1.3fr; gap: 56px; }
.about h2 { margin-bottom: 0; }
.prose p { margin: 0 0 18px; color: var(--text-2); }
.prose .langs { padding: 14px 18px; background: var(--bg-2); border-radius: 10px; border-inline-start: 3px solid var(--teal); font-size: 15.5px; }

.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; transition: transform .2s, box-shadow .2s, border-color .2s; }
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--line-strong); }
.card-ico { display: inline-grid; place-items: center; width: 52px; height: 52px; border-radius: 12px; background: var(--grad); color: #fff; margin-bottom: 18px; }
.card h3 { font-size: 1.12rem; margin-bottom: 8px; }
.card p { margin: 0; color: var(--muted); font-size: 15.5px; }

.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; inset-inline-start: 9px; top: 8px; bottom: 8px; width: 2px; background: linear-gradient(var(--blue), var(--teal), var(--green)); border-radius: 2px; }
.timeline > li { position: relative; padding-inline-start: 44px; padding-bottom: 40px; }
.timeline > li:last-child { padding-bottom: 0; }
.timeline > li::before { content: ""; position: absolute; inset-inline-start: 0; top: 6px; width: 20px; height: 20px; border-radius: 50%; background: var(--bg); border: 4px solid var(--teal); box-sizing: border-box; }
.tl-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.tl-head h3 { font-size: 1.22rem; }
.org { margin: 2px 0 0; color: var(--accent-text); font-weight: 600; }
.org span { color: var(--muted); font-weight: 400; }
.period { font-family: var(--mono); font-size: 13.5px; color: var(--chip-text); background: var(--bg-2); border: 1px solid var(--line); padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
html[lang="ar"] .period { font-family: var(--font); font-size: 14px; }
.bullets { margin: 14px 0 0; padding: 0; list-style: none; }
.bullets li { position: relative; padding-inline-start: 22px; margin-bottom: 8px; color: var(--text-2); font-size: 16px; }
.bullets li::before { content: ""; position: absolute; inset-inline-start: 4px; top: .7em; width: 7px; height: 7px; border-radius: 50%; border: 2px solid var(--green); }

.skills { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.skill-group { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.skill-group h3 { font-size: 1.02rem; margin-bottom: 14px; }
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chips li { font-size: 14.5px; padding: 5px 12px; border-radius: 8px; background: var(--chip-bg); color: var(--chip-text); border: 1px solid var(--chip-line); }

.edu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; }
.sub { display: flex; align-items: center; gap: 10px; font-size: 1.1rem; color: var(--accent-text); margin-bottom: 18px; }
.edu-item { padding: 20px 22px; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); margin-bottom: 14px; }
.edu-item h4 { font-size: 1.05rem; margin: 10px 0 4px; }
.edu-item p { margin: 0; color: var(--muted); font-size: 15.5px; }

/* Contact band */
.contact { background: var(--band-bg); color: #fff; position: relative; overflow: hidden; }
.contact::before { content: ""; position: absolute; inset: 0; background: radial-gradient(50% 80% at 100% 0%, rgba(39,110,162,.35), transparent 70%), radial-gradient(40% 70% at 0% 100%, rgba(59,145,94,.3), transparent 70%); }
.contact-in { position: relative; display: grid; grid-template-columns: 1fr 1.1fr; gap: 56px; }
.contact h2 { color: #fff; margin-bottom: 16px; }
.contact .kicker { color: #8fdcae; }
.lead { color: rgba(255,255,255,.75); margin: 0 0 28px; }
.contact-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.contact-list li { display: flex; align-items: center; gap: 12px; color: rgba(255,255,255,.85); }
.contact-list .ico { color: #8fdcae; }
.contact-list a { color: #fff; }
.form { background: var(--surface); color: var(--text); border-radius: 18px; padding: 28px; display: grid; gap: 16px; box-shadow: 0 30px 70px rgba(0,0,0,.3); border: 1px solid var(--line); }
.form label { display: grid; gap: 6px; font-size: 14.5px; font-weight: 600; color: var(--heading); }
.form input, .form textarea { font: inherit; font-weight: 400; font-size: 16px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--input-bg); color: var(--text); width: 100%; }
.form input:focus, .form textarea:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(44,123,138,.2); }
.form textarea { resize: vertical; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form .btn { justify-self: start; }
.hp { position: absolute; inset-inline-start: -9999px; }
.alert { margin: 0; padding: 12px 14px; border-radius: 10px; font-size: 15px; }
.alert.ok { background: #e6f5ec; color: #1f6b3e; border: 1px solid #bfe3cd; }
.alert.err { background: #fdecec; color: #9b2c2c; border: 1px solid #f3c6c6; }

.foot { background: var(--foot-bg); color: rgba(255,255,255,.6); font-size: 14.5px; }
.foot-in { display: flex; justify-content: space-between; gap: 12px; padding: 22px 0; flex-wrap: wrap; }
.foot p { margin: 0; }
.foot a { color: rgba(255,255,255,.75); }

.reveal { opacity: 0; transform: translateY(16px); transition: opacity .6s ease, transform .6s ease; }
.reveal.in { opacity: 1; transform: none; }

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

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .hero-in, .about, .contact-in { grid-template-columns: 1fr; gap: 36px; }
  .hero-visual { order: -1; }
  .portrait { --d: min(250px, 64vw); }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stats div:nth-child(3) { border-inline-start: 0; }
  .stats div:nth-child(n+3) { border-top: 1px solid var(--hero-line); }
}
@media (max-width: 900px) {
  .nav-toggle { display: block; }
  .menu { position: absolute; top: 64px; inset-inline: 0; flex-direction: column; align-items: stretch; padding: 12px 20px 20px; background: var(--bg); border-bottom: 1px solid var(--line); box-shadow: var(--shadow); display: none; }
  .menu.open { display: flex; }
  .menu a { padding: 12px; }
  .menu .lang { margin: 8px 0 0; justify-content: center; }
  .nav-toggle[aria-expanded="true"] span:first-child { transform: translateY(3.5px) rotate(45deg); }
  .nav-toggle[aria-expanded="true"] span:last-child { transform: translateY(-3.5px) rotate(-45deg); }
}
@media (max-width: 640px) {
  body { font-size: 16px; }
  .wrap { width: calc(100% - 32px); }
  .sec { padding: 64px 0; }
  .hero { padding-top: 40px; }
  .cards, .skills, .edu-grid, .row2 { grid-template-columns: 1fr; }
  .tl-head { flex-direction: column; gap: 8px; }
  .form { padding: 20px; }
  .orbits { width: 600px; inset-inline-end: -300px; }
}
