/* ------------------------------------------------------------
   Khalid Metwaly — profile
   Apple-inspired: system type, generous space, restrained color
   ------------------------------------------------------------ */

:root {
  --bg: #ffffff;
  --bg-gray: #f5f5f7;
  --bg-dark: #000000;
  --text: #1d1d1f;
  --text-muted: #6e6e73;
  --text-on-dark: #f5f5f7;
  --text-on-dark-muted: #a1a1a6;
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --line: rgba(0, 0, 0, 0.08);
  --card: #ffffff;
  --card-dark: #1d1d1f;
  --radius: 20px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
          "Helvetica Neue", Helvetica, Inter, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --bg-gray: #161617;
    --text: #f5f5f7;
    --text-muted: #a1a1a6;
    --line: rgba(255, 255, 255, 0.12);
    --card: #1d1d1f;
  }
}

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

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

img { display: block; max-width: 100%; }

h1, h2, h3 { margin: 0; letter-spacing: -0.02em; }

.container { max-width: 980px; margin: 0 auto; padding: 0 24px; }
.container--narrow { max-width: 680px; text-align: center; }

/* ---------- Navigation ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, 0.72);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid transparent;
  transition: border-color .3s ease;
}
.nav--scrolled { border-bottom-color: var(--line); }
@media (prefers-color-scheme: dark) {
  .nav { background: rgba(0, 0, 0, 0.72); }
}
.nav__inner {
  max-width: 980px; margin: 0 auto; padding: 0 24px;
  height: 52px; display: flex; align-items: center; gap: 32px;
}
.nav__brand { font-weight: 600; color: var(--text); font-size: 17px; }
.nav__brand:hover { text-decoration: none; }
.nav__links {
  display: flex; gap: 28px; list-style: none; margin: 0 auto; padding: 0;
}
.nav__links a {
  color: var(--text); font-size: 13px; opacity: .8; transition: opacity .2s;
}
.nav__links a:hover { opacity: 1; text-decoration: none; }
.nav__cta {
  font-size: 12px; padding: 6px 14px; border-radius: 999px;
  background: var(--accent); color: #fff; white-space: nowrap;
}
.nav__cta:hover { background: var(--accent-hover); text-decoration: none; }
@media (max-width: 720px) {
  .nav__links { display: none; }
  .nav__inner { justify-content: space-between; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 17px; font-weight: 400; border-radius: 999px;
  padding: 12px 24px; transition: background .2s, transform .2s;
}
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-hover); text-decoration: none; transform: translateY(-1px); }
.btn--link { color: var(--accent); padding-left: 8px; padding-right: 8px; }
.btn--lg { font-size: 19px; padding: 16px 32px; }

/* ---------- Hero ---------- */
.hero {
  min-height: calc(100vh - 52px);
  display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 80px 24px;
  background:
    radial-gradient(ellipse 60% 50% at 50% 0%, rgba(0, 113, 227, 0.10), transparent 70%),
    var(--bg);
}
.hero__inner { max-width: 760px; }
.hero__avatar {
  width: 160px; height: 160px; border-radius: 50%; margin: 0 auto 32px;
  object-fit: cover;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
}
.hero__eyebrow {
  margin: 0 0 12px; font-size: 19px; color: var(--text-muted); font-weight: 500;
}
.hero__title {
  font-size: clamp(48px, 9vw, 96px); font-weight: 700; line-height: 1.02;
  letter-spacing: -0.035em;
}
.hero__subtitle {
  margin: 24px auto 0; max-width: 620px;
  font-size: clamp(19px, 2.4vw, 26px); color: var(--text-muted); line-height: 1.35;
}
.hero__actions {
  display: flex; gap: 20px; justify-content: center; align-items: center;
  flex-wrap: wrap; margin-top: 36px;
}
.hero__employer {
  margin-top: 48px; font-size: 14px; color: var(--text-muted);
}
.hero__employer a {
  display: inline-flex; align-items: center; gap: 6px; color: var(--text); font-weight: 500;
}
.hero__employer img { border-radius: 4px; }

/* ---------- Sections ---------- */
.section { padding: 120px 0; }
.section--gray { background: var(--bg-gray); }
.section--dark { background: var(--bg-dark); color: var(--text-on-dark); }
.section--dark .section__eyebrow { color: var(--text-on-dark-muted); }
.section__eyebrow {
  margin: 0 0 8px; font-size: 15px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.08em;
}
.section__title {
  font-size: clamp(36px, 6vw, 64px); font-weight: 700; line-height: 1.07;
  margin-bottom: 48px;
}
.container--narrow .section__title { margin-bottom: 20px; }
@media (max-width: 720px) { .section { padding: 80px 0; } }

/* ---------- About ---------- */
.about__grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 40px;
}
.about__text {
  margin: 0; font-size: 21px; line-height: 1.45; color: var(--text-on-dark-muted);
}
.about__text:first-child { color: var(--text-on-dark); }
.stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px;
  margin-top: 72px; padding-top: 48px; border-top: 1px solid rgba(255,255,255,.14);
}
.stat { display: flex; flex-direction: column; gap: 6px; }
.stat__value {
  font-size: clamp(32px, 4.5vw, 48px); font-weight: 700; letter-spacing: -0.03em;
  background: linear-gradient(90deg, #2997ff, #a855f7);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.stat__label { font-size: 15px; color: var(--text-on-dark-muted); }
@media (max-width: 720px) {
  .about__grid, .stats { grid-template-columns: 1fr; }
}

/* ---------- Cards ---------- */
.card {
  background: var(--card); border-radius: var(--radius); padding: 36px;
  box-shadow: 0 2px 12px rgba(0,0,0,.06), 0 0 0 1px var(--line);
  transition: transform .3s ease, box-shadow .3s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 12px 32px rgba(0,0,0,.10), 0 0 0 1px var(--line); }
.card__title { font-size: 21px; font-weight: 600; margin-bottom: 20px; }
.card__meta { margin: 6px 0 0; color: var(--text-muted); font-size: 15px; }

/* ---------- Skills ---------- */
.skills {
  display: grid; grid-template-columns: 1fr 1fr; gap: 20px;
}
.card--wide { grid-column: 1 / -1; }
.skill-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.card--wide .skill-list { grid-template-columns: 1fr 1fr; column-gap: 40px; }
.skill-list li {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  font-size: 15px;
}
.level {
  position: relative; flex: 0 0 96px; height: 4px; border-radius: 999px;
  background: var(--line); overflow: hidden;
}
.level::after {
  content: ""; position: absolute; inset: 0; width: var(--l);
  background: var(--accent); border-radius: 999px;
}
@media (max-width: 720px) {
  .skills, .card--wide .skill-list { grid-template-columns: 1fr; }
  .card { padding: 28px; }
}

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 20px; }
.timeline__item {
  display: grid; grid-template-columns: 72px 1fr; gap: 28px; align-items: start;
  background: var(--card); border-radius: var(--radius); padding: 32px;
  box-shadow: 0 2px 12px rgba(0,0,0,.05), 0 0 0 1px var(--line);
}
.timeline__logo {
  width: 72px; height: 72px; border-radius: 18px; background: #fff;
  display: grid; place-items: center; padding: 12px;
  box-shadow: 0 0 0 1px var(--line);
}
.timeline__logo img { width: 100%; height: 100%; object-fit: contain; }
.timeline__period {
  display: block; font-size: 13px; font-weight: 600; color: var(--accent);
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px;
}
.timeline__role { font-size: 23px; font-weight: 600; }
.timeline__company { display: inline-block; margin-top: 4px; color: var(--text-muted); font-size: 15px; }
.timeline__body p { margin: 14px 0 0; color: var(--text-muted); font-size: 16px; }
@media (max-width: 560px) {
  .timeline__item { grid-template-columns: 1fr; gap: 16px; padding: 24px; }
}

/* ---------- Education ---------- */
.card--edu { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; align-items: start; }
.card--edu .card__title { margin-bottom: 0; }
.edu__facts { margin: 0; display: grid; gap: 14px; }
.edu__facts div { display: grid; grid-template-columns: 150px 1fr; gap: 12px; font-size: 15px; }
.edu__facts dt { color: var(--text-muted); }
.edu__facts dd { margin: 0; font-weight: 500; }
@media (max-width: 720px) {
  .card--edu { grid-template-columns: 1fr; }
  .edu__facts div { grid-template-columns: 1fr; gap: 2px; }
}

/* ---------- Contact ---------- */
.contact__lead { font-size: 21px; color: var(--text-on-dark-muted); margin: 0 0 36px; }
.social {
  list-style: none; margin: 40px 0 0; padding: 0;
  display: flex; gap: 28px; justify-content: center; flex-wrap: wrap;
}
.social a { color: var(--text-on-dark-muted); font-size: 15px; transition: color .2s; }
.social a:hover { color: var(--text-on-dark); text-decoration: none; }

/* ---------- Footer ---------- */
.footer { background: var(--bg-gray); border-top: 1px solid var(--line); }
.footer__inner {
  display: flex; justify-content: space-between; align-items: center;
  padding-top: 20px; padding-bottom: 20px; font-size: 12px; color: var(--text-muted);
}
.footer a { color: var(--text-muted); }

/* ---------- Reveal animation ---------- */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity .7s ease, transform .7s ease; }
.reveal.is-visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  html { scroll-behavior: auto; }
}

.stat__value--sm { font-size: clamp(26px, 3.2vw, 36px); white-space: nowrap; }

/* ---------- Hero social icons ---------- */
.hero__social {
  list-style: none; margin: 32px 0 0; padding: 0;
  display: flex; gap: 12px; justify-content: center;
}
.hero__social a {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  color: var(--text); background: var(--bg-gray); transition: transform .2s, background .2s;
}
.hero__social a:hover { transform: translateY(-2px); background: var(--accent); color: #fff; text-decoration: none; }
.hero__employer { margin-top: 28px; }

/* ---------- Services ---------- */
.services { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.service p { margin: 0; color: var(--text-muted); font-size: 15px; line-height: 1.5; }
.service .card__title { font-size: 19px; margin-bottom: 10px; }
.service__icon {
  width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center;
  background: linear-gradient(135deg, #0071e3, #5ac8fa); color: #fff; margin-bottom: 20px;
}
@media (max-width: 900px) { .services { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .services { grid-template-columns: 1fr; } }

/* ---------- Certifications ---------- */
.certs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.cert {
  appearance: none; border: 0; padding: 0; text-align: left; cursor: pointer;
  background: var(--card); border-radius: var(--radius); overflow: hidden;
  box-shadow: 0 2px 12px rgba(0,0,0,.06), 0 0 0 1px var(--line);
  transition: transform .3s ease, box-shadow .3s ease; font-family: inherit; color: var(--text);
  display: flex; flex-direction: column;
}
.cert:hover { transform: translateY(-4px); box-shadow: 0 16px 40px rgba(0,0,0,.12), 0 0 0 1px var(--line); }
.cert:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.cert img {
  width: 100%; aspect-ratio: 4 / 3; object-fit: cover; object-position: top;
  background: #fff; border-bottom: 1px solid var(--line);
}
.cert__year {
  margin: 16px 18px 0; font-size: 12px; font-weight: 600; color: var(--accent);
  letter-spacing: .06em;
}
.cert__level { margin: 2px 18px 0; font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }
.cert__name { margin: 6px 18px 18px; font-size: 15px; font-weight: 600; line-height: 1.3; }
@media (max-width: 900px) { .certs { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .certs { grid-template-columns: 1fr; } }

/* ---------- Clients ---------- */
.clients {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px;
}
.clients li {
  position: relative; aspect-ratio: 1; border-radius: 16px; background: var(--card);
  box-shadow: 0 0 0 1px var(--line); display: grid; place-items: center; padding: 18px;
  transition: transform .25s ease, box-shadow .25s ease;
}
.clients li:hover { transform: translateY(-3px); box-shadow: 0 10px 28px rgba(0,0,0,.10), 0 0 0 1px var(--line); z-index: 2; }
.clients img {
  width: 100%; height: 100%; object-fit: contain;
  filter: grayscale(1); opacity: .75; transition: filter .25s, opacity .25s;
}
.clients li:hover img { filter: none; opacity: 1; }
.clients span {
  position: absolute; left: 50%; bottom: -8px; transform: translate(-50%, 100%);
  background: var(--text); color: var(--bg); font-size: 12px; white-space: nowrap;
  padding: 6px 10px; border-radius: 8px; pointer-events: none; opacity: 0;
  transition: opacity .2s; z-index: 3;
}
.clients li:hover span { opacity: 1; }
@media (prefers-color-scheme: dark) {
  .clients li { background: #fff; }
}
@media (max-width: 900px) { .clients { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 560px) { .clients { grid-template-columns: repeat(3, 1fr); gap: 10px; } .clients span { display: none; } }

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 24px;
  background: rgba(0,0,0,.85); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  opacity: 0; transition: opacity .25s ease;
}
.lightbox[hidden] { display: none; }
.lightbox.is-open { opacity: 1; }
.lightbox__figure { margin: 0; max-width: min(1000px, 100%); text-align: center; transform: scale(.96); transition: transform .25s ease; }
.lightbox.is-open .lightbox__figure { transform: none; }
.lightbox__figure img {
  max-width: 100%; max-height: 78vh; border-radius: 12px; margin: 0 auto;
  box-shadow: 0 30px 80px rgba(0,0,0,.5); background: #fff;
}
.lightbox__figure figcaption { color: #f5f5f7; margin-top: 16px; font-size: 15px; }
.lightbox__close {
  position: absolute; top: 20px; right: 24px; width: 44px; height: 44px; border-radius: 50%;
  border: 0; background: rgba(255,255,255,.15); color: #fff; font-size: 28px; line-height: 1;
  cursor: pointer; transition: background .2s;
}
.lightbox__close:hover { background: rgba(255,255,255,.3); }

/* nav tweaks for more links */
.nav__links { gap: 22px; }

/* client tiles without a logo yet */
.clients__mono {
  font-size: 22px; font-weight: 700; letter-spacing: -0.02em; color: var(--text-muted);
  transition: color .25s;
}
.clients li:hover .clients__mono { color: var(--accent); }
@media (prefers-color-scheme: dark) { .clients__mono { color: #6e6e73; } }
.clients li .clients__mono {
  position: static; transform: none; opacity: 1; background: none; color: var(--text-muted);
  padding: 0; font-size: 22px; font-weight: 700; pointer-events: none;
}
.clients li:hover .clients__mono { color: var(--accent); opacity: 1; }
.certs { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 900px) { .certs { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .certs { grid-template-columns: 1fr; } }

/* ---------- Clients as buttons ---------- */
.section__lead { margin: -28px 0 40px; font-size: 17px; color: var(--text-muted); }
.clients li { padding: 0; }
.client {
  appearance: none; border: 0; background: none; cursor: pointer; font-family: inherit;
  width: 100%; height: 100%; padding: 18px; border-radius: 16px; display: grid; place-items: center;
}
.client:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.client img { width: 100%; height: 100%; object-fit: contain; filter: grayscale(1); opacity: .75; transition: filter .25s, opacity .25s; }
.client:hover img { filter: none; opacity: 1; }
.client span {
  position: absolute; left: 50%; bottom: -8px; transform: translate(-50%, 100%);
  background: var(--text); color: var(--bg); font-size: 12px; white-space: nowrap;
  padding: 6px 10px; border-radius: 8px; pointer-events: none; opacity: 0; transition: opacity .2s; z-index: 3;
}
.client:hover span { opacity: 1; }
@media (max-width: 560px) { .client span { display: none; } }

/* ---------- Detail sheet ---------- */
.sheet {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 24px;
  background: rgba(0,0,0,.55); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  opacity: 0; transition: opacity .25s ease;
}
.sheet[hidden] { display: none; }
.sheet.is-open { opacity: 1; }
.sheet__panel {
  position: relative; width: min(680px, 100%); max-height: 86vh; overflow: auto;
  background: var(--card); color: var(--text); border-radius: 24px; padding: 36px;
  box-shadow: 0 30px 80px rgba(0,0,0,.35); transform: translateY(16px) scale(.98); transition: transform .25s ease;
}
.sheet.is-open .sheet__panel { transform: none; }
.sheet__close {
  position: absolute; top: 16px; right: 16px; width: 36px; height: 36px; border-radius: 50%; border: 0;
  background: var(--bg-gray); color: var(--text); font-size: 22px; line-height: 1; cursor: pointer;
}
.sheet__close:hover { background: var(--line); }
.sheet__head { display: flex; gap: 20px; align-items: center; margin-bottom: 24px; padding-right: 40px; }
.sheet__logo {
  flex: 0 0 76px; width: 76px; height: 76px; border-radius: 18px; background: #fff; padding: 10px;
  box-shadow: 0 0 0 1px var(--line); display: grid; place-items: center;
}
.sheet__logo img { width: 100%; height: 100%; object-fit: contain; }
.sheet__title { font-size: 24px; font-weight: 700; }
.sheet__sub { margin: 2px 0 0; color: var(--text-muted); font-size: 15px; }
.sheet__meta {
  margin: 0 0 24px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px 24px;
  padding: 18px 20px; border-radius: 14px; background: var(--bg-gray);
}
.sheet__meta div { display: grid; gap: 2px; }
.sheet__meta dt { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); }
.sheet__meta dd { margin: 0; font-size: 15px; font-weight: 500; }
.sheet__block { margin-top: 20px; }
.sheet__block h4 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); }
.sheet__block p { margin: 0; font-size: 16px; line-height: 1.5; }
.sheet__block ul { margin: 0; padding-left: 20px; display: grid; gap: 8px; font-size: 15px; line-height: 1.5; }
@media (max-width: 560px) {
  .sheet { padding: 12px; align-items: end; }
  .sheet__panel { padding: 28px 22px; border-radius: 20px 20px 16px 16px; max-height: 92vh; }
  .sheet__meta { grid-template-columns: 1fr; }
}

/* ---------- Contact actions ---------- */
.contact__actions { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.btn--ghost { background: rgba(255,255,255,.12); color: var(--text-on-dark); border: 0; font-family: inherit; cursor: pointer; }
.btn--ghost:hover { background: rgba(255,255,255,.2); transform: translateY(-1px); }
