/* ============================================================
   Mohanad Alawami — Portfolio (v5)
   Palette: neutral grayscale (matches a common shadcn/ui-style
   default theme), Geist (Latin) + Cairo (Arabic).
   Fonts loaded via <link> in index.html (with preconnect).
   ============================================================ */

:root {
  /* light */
  --bg: #ffffff;
  --fg: #0a0a0a;
  --muted: #f5f5f5;
  --muted-fg: #737373;
  --border: #e5e5e5;
  --card: #ffffff;
  --primary: #171717;
  --primary-fg: #fafafa;

  --container: 1180px;
  --gutter: 1.5rem;
  --radius: 0.625rem;
  --radius-lg: 1rem;
  --radius-full: 999px;
  --nav-h: 64px;

  --font-en: "Geist", -apple-system, "Segoe UI", sans-serif;
  --font-ar: "thmanyah sans", sans-serif;
  --font: var(--font-en);

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --dur: 0.3s;
}

:root[data-theme="dark"] {
  --bg: #0a0a0a;
  --fg: #fafafa;
  --muted: #262626;
  --muted-fg: #a1a1a1;
  --border: rgba(255, 255, 255, 0.1);
  --card: #171717;
  --primary: #e5e5e5;
  --primary-fg: #171717;
}

html[lang="ar"] { --font: var(--font-ar); }

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--muted-fg);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s var(--ease), color 0.3s var(--ease);
}
html[lang="ar"] body { line-height: 1.9; }
h1, h2, h3, p, ul { margin: 0; padding: 0; }
ul { list-style: none; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
em { font-style: normal; color: var(--fg); }
strong { font-weight: 600; color: var(--fg); }

::selection { background: var(--fg); color: var(--bg); }
:focus-visible { outline: 2px solid var(--fg); outline-offset: 3px; border-radius: 4px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; top: -3rem; left: 1rem; z-index: 1000;
  background: var(--fg); color: var(--bg); padding: 0.6rem 1rem;
  border-radius: var(--radius); font-size: 0.85rem; transition: top 0.2s var(--ease);
}
.skip-link:focus { top: 1rem; }

.container { width: min(var(--container), 100% - (var(--gutter) * 2)); margin-inline: auto; }
.narrow { max-width: 42rem; margin-inline: auto; }
.section { padding: clamp(4rem, 8vw, 6.5rem) 0; }
.section--alt { background: var(--muted); }

/* big centered section headings, no kicker — matches the reference */
.h2 {
  font-weight: 700;
  font-size: clamp(2rem, 4.5vw, 2.8rem);
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--fg);
  text-align: center;
  margin-bottom: 3rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted-fg);
  white-space: nowrap;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.2;
  border: 1px solid transparent;
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease), border-color var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
.btn svg { width: 13px; height: 13px; flex: none; }
.btn--primary { background: var(--primary); color: var(--primary-fg); }
.btn--primary:hover { opacity: 0.85; transform: translateY(-1px); }
.btn--outline { border-color: var(--border); color: var(--fg); }
.btn--outline:hover { background: var(--muted); transform: translateY(-1px); }

/* ============================================================
   Nav
   ============================================================ */
/* fully transparent at the top — merges with the page; gains its
   surface (bg + blur + hairline) only once the user scrolls */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 500;
  height: var(--nav-h);
  display: flex; align-items: center;
  background: transparent;
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s var(--ease), background 0.3s var(--ease);
}
.nav.is-scrolled {
  border-bottom-color: var(--border);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.nav__inner { display: flex; align-items: center; justify-content: space-between; gap: 2rem; }

.brand { font-weight: 600; font-size: 1.15rem; color: var(--fg); }

.nav-links { display: flex; gap: 1rem; }
.nav-links a {
  font-size: 0.9rem; font-weight: 500; color: var(--muted-fg);
  padding: 0.3rem 0.6rem; border-radius: var(--radius);
  transition: color 0.2s var(--ease), background 0.2s var(--ease);
}
.nav-links a:hover, .nav-links a.is-active { color: var(--fg); background: var(--muted); }

.nav__actions { display: flex; align-items: center; gap: 0.6rem; }

.theme-toggle {
  display: flex; align-items: center; justify-content: center;
  width: 31px; height: 31px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--bg); color: var(--fg);
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
}
.theme-toggle:hover { background: var(--muted); }
.theme-toggle svg { width: 14px; height: 14px; }
/* icon shows the theme you'll switch TO, not the current one:
   moon visible in light mode (click = go dark), sun visible in dark mode */
.icon-sun { display: none; }
:root[data-theme="dark"] .icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun { display: block; }

.lang-toggle {
  display: flex; align-items: center; justify-content: center; gap: 0.35rem;
  height: 31px; padding: 0 0.75rem;
  border-radius: var(--radius-full); border: 1px solid var(--border);
  background: var(--bg); color: var(--fg);
  font-size: 0.75rem; font-weight: 600; line-height: 1;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
}
.lang-toggle:hover { background: var(--muted); }
.lang-toggle svg { width: 13px; height: 13px; }
/* same rule: label shows the language you'll switch TO */
.lang-toggle__show-en { display: none; }
html[lang="ar"] .lang-toggle__show-en { display: inline; }
html[lang="ar"] .lang-toggle__show-ar { display: none; }

.nav-toggle {
  display: none; flex-direction: column; justify-content: center; gap: 5px;
  width: 32px; height: 32px;
}
.nav-toggle span { display: block; height: 2px; background: var(--fg); border-radius: 2px; transition: transform 0.25s var(--ease), opacity 0.25s var(--ease); }
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.mobile-menu {
  display: none; position: fixed; top: var(--nav-h); left: 0; right: 0;
  background: var(--bg); border-bottom: 1px solid var(--border);
  padding: 0.5rem var(--gutter) 1.25rem; flex-direction: column; z-index: 499;
}
.mobile-menu a { padding: 0.9rem 0; border-bottom: 1px solid var(--border); color: var(--fg); font-size: 1.05rem; }
.mobile-menu a:last-child { border-bottom: 0; }
.mobile-menu.is-open { display: flex; }

/* ============================================================
   Hero
   ============================================================ */
.hero {
  position: relative;
  min-height: 88svh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding-top: calc(var(--nav-h) + 8rem);
  padding-bottom: 3rem;
  text-align: center;
}
.hero__glow {
  position: absolute; inset: 0; z-index: 0;
  background: radial-gradient(55rem 34rem at 50% 0%, var(--muted), transparent 65%);
}
.hero__inner { position: relative; z-index: 1; max-width: 40rem; display: flex; flex-direction: column; align-items: center; }

.pill {
  display: flex; width: fit-content; margin-inline: auto;
  align-items: center; gap: 0.4rem;
  padding: 0.32rem 0.85rem; border-radius: var(--radius-full);
  border: 1px solid var(--border); background: var(--bg);
  font-size: 0.75rem; font-weight: 500; line-height: 1.4;
  color: var(--muted-fg); margin-bottom: 1.75rem;
}
.pill svg { width: 12px; height: 12px; }

.hero__title {
  font-weight: 700;
  font-size: clamp(2.6rem, 7vw, 4.5rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--fg);
}
html[lang="ar"] .hero__title { line-height: 1.4; font-feature-settings: "salt", "ss01", "swsh"; }

.hero__subtitle { margin-top: 0.85rem; font-size: 1.05rem; font-weight: 600; color: var(--fg); }

.hero__lede { margin-top: 1.5rem; max-width: 36rem; font-size: 1.08rem; color: var(--muted-fg); }
/* thmanyah sans ships alternate/swash letterforms behind these OpenType features — same technique reemaa.vercel.app uses on the same font. No manual tatweel needed, the font decides where to extend on its own. */
html[lang="ar"] .hero__lede { font-feature-settings: "salt", "ss01", "swsh"; }

.about__lede + .about__lede { margin-top: 1rem; }

.hero__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.65rem; margin-top: 2.25rem; }

.hero__scroll {
  position: relative; z-index: 1; margin-top: 4.5rem;
  display: flex; flex-direction: column; align-items: center; gap: 0.5rem;
  font-size: 0.8rem; color: var(--muted-fg);
}
.hero__scroll svg { width: 16px; height: 16px; animation: bob 1.8s ease-in-out infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(5px); } }

/* ============================================================
   About
   ============================================================ */
.about__lede { font-size: 1.15rem; color: var(--fg); text-align: justify; text-align-last: center; }

/* ============================================================
   Experience — vertical timeline, line on the inline-start
   (right in RTL, left in LTR), matching the reference
   ============================================================ */
.timeline {
  --tl-gap: 3rem;
  position: relative;
  padding-inline-start: var(--tl-gap);
}
.timeline::before {
  content: "";
  position: absolute;
  inset-inline-start: 6px;
  top: 8px; bottom: 8px;
  width: 1.5px;
  background: var(--fg);
  opacity: 0.75;
}
.tl-item { position: relative; padding-bottom: 3.5rem; }
.tl-item:last-child { padding-bottom: 0; }
/* hollow node on the line, aligned with the company row */
.tl-item::before {
  content: "";
  position: absolute;
  inset-inline-start: calc(-1 * var(--tl-gap) + 1px);
  top: 6px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--bg);
  border: 1.5px solid var(--fg);
}

.tl-company { display: flex; align-items: center; gap: 0.6rem; }
.tl-avatar {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card);
  font-family: var(--font-en);
  font-size: 0.8rem; font-weight: 700;
  color: var(--muted-fg);
  flex: none;
}
.tl-company h3 { font-size: 1.05rem; font-weight: 700; color: var(--fg); }

.tl-role { margin-top: 1rem; font-size: 1.15rem; font-weight: 700; color: var(--fg); }

.tl-meta {
  display: flex; flex-wrap: wrap; gap: 1.25rem;
  margin-top: 0.4rem;
  font-size: 0.8rem; color: var(--muted-fg);
}
.tl-meta > span { display: inline-flex; align-items: center; gap: 0.35rem; }
.tl-meta svg { width: 13px; height: 13px; flex: none; }

.tl-points { margin-top: 1rem; display: flex; flex-direction: column; gap: 0.6rem; }
.tl-points li {
  position: relative;
  padding-inline-start: 1.1rem;
  font-size: 0.95rem;
}
.tl-points li::before {
  content: "";
  position: absolute; inset-inline-start: 0; top: 0.6em;
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--muted-fg);
}

.tl-featured {
  margin-top: 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--card);
  padding: 1.25rem 1.4rem 1.4rem;
}
.tl-featured h4 { font-size: 0.95rem; font-weight: 700; color: var(--fg); margin: 0; }
.tl-featured .tl-points { margin-top: 0.75rem; }
.tl-featured .tl-points li { font-size: 0.9rem; }

.tl-tags { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1.25rem; }
.tl-tags li {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 0.5rem;
  padding: 0.3rem 0.7rem;
  font-size: 0.74rem; font-weight: 500;
  color: var(--muted-fg);
}

/* ============================================================
   Skills — tools row, then a 2-col grid of tagged category cards
   ============================================================ */
.tools { text-align: center; margin-bottom: 3.5rem; }
.tools h3 { font-size: 1.3rem; font-weight: 700; color: var(--fg); }
.tools p { margin-top: 0.4rem; font-size: 0.92rem; }
.tools__row {
  margin-top: 1.75rem;
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 1.75rem 2.25rem;
}
.tool { display: flex; flex-direction: column; align-items: center; gap: 0.6rem; }
.tool__icon {
  display: flex; align-items: center; justify-content: center;
  width: 46px; height: 46px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--fg);
}
.tool__icon svg { width: 20px; height: 20px; }
.tool span:last-child { font-size: 0.78rem; color: var(--muted-fg); }

.skill-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.1rem; }
.skill-card { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--card); padding: 1.5rem; transition: border-color var(--dur) var(--ease); }
.skill-card:hover { border-color: var(--muted-fg); }
.skill-card h3 { font-size: 1.05rem; font-weight: 700; color: var(--fg); margin-bottom: 1rem; }
.skill-card .tags { margin-top: 0; }

/* ============================================================
   Education
   ============================================================ */
.edu-card {
  display: flex; align-items: center; justify-content: flex-start; gap: 1.25rem;
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--card); padding: 1.25rem 1.5rem;
}
.edu-card h3 { font-size: 1.1rem; font-weight: 700; color: var(--fg); }
.edu-card p { margin-top: 0.3rem; font-size: 0.88rem; }
.edu-card__icon {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; flex: none;
  border-radius: 50%; border: 1px solid var(--border);
  background: var(--bg); color: var(--fg);
}
.edu-card__icon svg { width: 20px; height: 20px; }

.sub-heading {
  margin-top: 3rem; margin-bottom: 1.75rem;
  font-size: 1.15rem; font-weight: 700; color: var(--fg); text-align: center;
}

.dev-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.dev-card {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--card); padding: 1.4rem 1rem;
}
.dev-card__icon {
  display: flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; margin-bottom: 0.75rem;
  border-radius: 50%; border: 1px solid var(--border);
  background: var(--bg); color: var(--fg);
}
.dev-card__icon svg { width: 17px; height: 17px; }
.dev-card h4 { font-size: 0.92rem; font-weight: 700; color: var(--fg); line-height: 1.35; }
.dev-card p { margin-top: 0.3rem; font-size: 0.8rem; }

.lang-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 1rem; }
.lang-pill {
  display: inline-flex; align-items: center; gap: 0.5rem;
  border: 1px solid var(--border); border-radius: var(--radius-full);
  background: var(--card); padding: 0.6rem 1.1rem;
  font-size: 0.85rem;
}
.lang-pill svg { width: 15px; height: 15px; color: var(--muted-fg); flex: none; }
.lang-pill strong { color: var(--fg); font-weight: 700; }
.lang-pill span:last-child { color: var(--muted-fg); }

/* ============================================================
   Projects
   ============================================================ */
.project-grid { margin-top: 2.25rem; display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.25rem; }
.project-card { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--card); padding: 1.65rem; transition: border-color var(--dur) var(--ease); }
.project-card:hover { border-color: var(--muted-fg); }
.project-card:first-child { grid-column: 1 / -1; }
.project-card__head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.project-card__head h3 { font-size: 1.25rem; font-weight: 700; color: var(--fg); }
.project-card__role { margin-top: 0.25rem; font-size: 0.85rem; color: var(--fg); font-weight: 600; }
.project-card__desc { margin-top: 0.85rem; font-size: 0.92rem; }
.tags { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1.15rem; }
.tags li { font-size: 0.74rem; color: var(--muted-fg); border: 1px solid var(--border); border-radius: var(--radius-full); padding: 0.28rem 0.7rem; }

/* ============================================================
   Contact
   ============================================================ */
.contact-card {
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--card); padding: clamp(1.75rem, 4vw, 2.5rem);
  text-align: center;
}
.contact-card h3 { font-size: 1.2rem; font-weight: 700; color: var(--fg); }
.contact-card p { margin-top: 0.75rem; font-size: 0.95rem; max-width: 34rem; margin-inline: auto; }

.contact-email {
  margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
}
.contact-email a { font-size: 1.05rem; font-weight: 700; color: var(--fg); }
.contact-email svg { width: 17px; height: 17px; color: var(--muted-fg); }


.contact-via {
  display: block; margin-top: 1.75rem; padding-top: 1.5rem; border-top: 1px solid var(--border);
  font-size: 0.85rem; font-weight: 700; color: var(--fg);
}
.contact-icons { margin-top: 1rem; display: flex; justify-content: center; gap: 0.75rem; }
.icon-circle {
  display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--bg); color: var(--fg);
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.icon-circle:hover { background: var(--muted); border-color: var(--muted-fg); }
.icon-circle svg { width: 17px; height: 17px; }

.contact-open-desc { margin-top: 0.85rem; margin-bottom: 1.75rem; margin-inline: auto; max-width: 30rem; text-align: center; font-size: 0.95rem; color: var(--muted-fg); }

/* #contact is a <footer class="section section--alt">, so it inherits .section's
   large top+bottom padding. The bottom half of that padding landed after
   .footer__bar (the last thing in the footer), showing as dead muted-background
   space below the copyright row instead of the bar sitting flush at the page end. */
footer.section { padding-bottom: 0; }

.footer__bar { margin-top: 3rem; border-top: 1px solid var(--border); }
.footer__base { padding-block: 2.75rem; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 0.6rem; font-size: 0.8rem; color: var(--muted-fg); }
html[lang="ar"] .footer__base { font-feature-settings: "salt", "ss01", "swsh"; }

/* ============================================================
   Scroll reveal
   ============================================================ */
.reveal { opacity: 0; transform: translateY(20px); transition: opacity 0.6s var(--ease), transform 0.6s var(--ease); }
.reveal.is-visible { opacity: 1; transform: translateY(0); }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 900px) {
  .nav-links { display: none; }
  .nav-toggle { display: flex; }
  .skill-grid { grid-template-columns: repeat(2, 1fr); }
  .project-grid { grid-template-columns: 1fr; }
  .project-card:first-child { grid-column: auto; }
  .dev-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  :root { --gutter: 1.25rem; }
  .skill-grid { grid-template-columns: 1fr; }
  .nav__actions { gap: 0.35rem; }
  .lang-toggle { padding: 0 0.5rem; font-size: 0.72rem; }
  .footer__base { flex-direction: column; align-items: flex-start; }
  .timeline { --tl-gap: 2rem; }
  .dev-grid { grid-template-columns: 1fr; }
}

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