/* ==========================================================================
   Abdalkarim Mohtasib — personal site
   Plain CSS, no build step. Colours are tokens; dark mode redefines them.
   ========================================================================== */

:root {
  --bg: #f6f4ee;
  --surface: #fffdf8;
  --ink: #1a1e1b;
  --muted: #565e59;
  --faint: #858c87;
  --rule: #e1ddd2;
  --accent: #2c6a4d;
  --accent-ink: #ffffff;
  --accent-soft: #e2ece5;
  --code-bg: #f0ede4;
  --shadow: 0 1px 2px rgba(26, 30, 27, 0.04), 0 8px 24px -12px rgba(26, 30, 27, 0.12);

  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --max: 1080px;
  --gutter: clamp(16px, 4vw, 40px);
  --radius: 10px;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1311;
    --surface: #161b18;
    --ink: #e7ebe7;
    --muted: #a3aba6;
    --faint: #6f7772;
    --rule: #252c28;
    --accent: #86c9a3;
    --accent-ink: #0f1311;
    --accent-soft: #1b2821;
    --code-bg: #121714;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0f1311;
  --surface: #161b18;
  --ink: #e7ebe7;
  --muted: #a3aba6;
  --faint: #6f7772;
  --rule: #252c28;
  --accent: #86c9a3;
  --accent-ink: #0f1311;
  --accent-soft: #1b2821;
  --code-bg: #121714;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

/* ---------- Base ---------- */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

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

a {
  color: inherit;
  text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}
a:hover { color: var(--accent); text-decoration-color: var(--accent); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

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

.wrap {
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.skip {
  position: absolute;
  left: -9999px;
  top: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 8px 14px;
  border-radius: 6px;
  z-index: 100;
  font-size: 14px;
}
.skip:focus { left: 8px; }

/* ---------- Top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}
.topbar.scrolled { border-bottom-color: var(--rule); }

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

.mark {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
}
.mark span { color: var(--accent); }

.nav {
  display: flex;
  align-items: center;
  gap: 4px;
}
.nav a {
  font-size: 14px;
  color: var(--muted);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 6px;
}
.nav a:hover { color: var(--ink); background: var(--accent-soft); }
.nav a.active { color: var(--ink); }

.theme-toggle {
  appearance: none;
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--muted);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  margin-left: 8px;
  flex: none;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--faint); }
.theme-toggle svg { width: 16px; height: 16px; }
.theme-toggle .moon { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .moon { display: block; }
}

@media (max-width: 720px) {
  .nav a { display: none; }
}

/* ---------- Hero ---------- */

.hero {
  padding: clamp(40px, 9vw, 104px) 0 clamp(48px, 8vw, 88px);
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 340px);
  gap: clamp(32px, 6vw, 80px);
  align-items: center;
}

.eyebrow {
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.eyebrow::before {
  content: "";
  width: 24px;
  height: 1px;
  background: currentColor;
}

.hero h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(42px, 7.4vw, 84px);
  line-height: 0.98;
  letter-spacing: -0.025em;
  margin: 0 0 14px;
  font-variation-settings: "opsz" 72;
}

.aka {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(18px, 2.2vw, 22px);
  color: var(--muted);
  margin: 0 0 28px;
}

.lede {
  font-size: clamp(17px, 1.9vw, 19.5px);
  line-height: 1.6;
  color: var(--ink);
  max-width: 34em;
  margin: 0 0 32px;
}
.lede em { font-family: var(--serif); font-size: 1.08em; }

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.links a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  padding: 8px 14px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--surface);
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.links a:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}
.links a.primary {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}
.links a.primary:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.links .arrow { font-family: var(--mono); font-size: 12px; opacity: 0.7; }

.portrait { margin: 0; }
.portrait .frame {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  aspect-ratio: 1 / 1;
  background: var(--accent-soft);
  box-shadow: var(--shadow);
}
.portrait img { width: 100%; height: 100%; object-fit: cover; }
.portrait figcaption {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--faint);
  margin-top: 12px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

@media (max-width: 760px) {
  .hero-grid { grid-template-columns: 1fr; }
  .portrait { order: -1; max-width: 168px; }
  .portrait .frame { border-radius: 14px; }
  .portrait figcaption { display: none; }
}

/* ---------- Sections ---------- */

.section {
  padding: clamp(56px, 8vw, 96px) 0;
  border-top: 1px solid var(--rule);
}

.section-head {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 24px;
  align-items: baseline;
  margin-bottom: clamp(28px, 4vw, 44px);
}

.section-num {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--faint);
  letter-spacing: 0.04em;
}

.section h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(30px, 4vw, 42px);
  line-height: 1.1;
  letter-spacing: -0.015em;
  margin: 0;
}

.section-body {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 24px;
}
.section-body > .content { grid-column: 2; min-width: 0; }

@media (max-width: 760px) {
  .section-head,
  .section-body { grid-template-columns: 1fr; gap: 8px; }
  .section-body > .content { grid-column: 1; }
}

/* ---------- About ---------- */

.prose p {
  font-size: 17.5px;
  max-width: 38em;
  margin: 0 0 1.1em;
}
.prose p:last-child { margin-bottom: 0; }

.facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 40px 0 0;
}
.facts div { background: var(--surface); padding: 18px 20px; }
.facts dt {
  font-family: var(--mono);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--faint);
  margin-bottom: 6px;
}
.facts dd { margin: 0; font-size: 15px; line-height: 1.45; }

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

/* ---------- Research themes ---------- */

.themes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.theme {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 24px 22px 22px;
  display: flex;
  flex-direction: column;
}
.theme .glyph {
  width: 40px;
  height: 40px;
  color: var(--accent);
  margin-bottom: 18px;
}
.theme h3 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 21px;
  line-height: 1.25;
  margin: 0 0 10px;
}
.theme p { font-size: 15px; color: var(--muted); margin: 0 0 16px; }
.theme .refs {
  margin-top: auto;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--faint);
}
.theme .refs a { color: var(--accent); text-decoration: none; }
.theme .refs a:hover { text-decoration: underline; }

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

/* ---------- Publications ---------- */

.pubs { list-style: none; margin: 0; padding: 0; }

.pub {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 20px;
  padding: 26px 0;
  border-bottom: 1px solid var(--rule);
}
.pub:first-child { padding-top: 0; }
.pub:last-child { border-bottom: 0; }
.pub:target .pub-title a { color: var(--accent); }

.pub-year {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--faint);
  padding-top: 4px;
}

.pub-kind {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 8px;
  border-radius: 4px;
  margin-bottom: 8px;
}

.pub-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(19px, 2.1vw, 22px);
  line-height: 1.3;
  letter-spacing: -0.005em;
  margin: 0 0 6px;
}
.pub-title a { text-decoration: none; }
.pub-title a:hover { text-decoration: underline; }

.pub-authors { font-size: 15px; color: var(--muted); margin: 0; }
.pub-authors strong { color: var(--ink); font-weight: 600; }
.pub-venue { font-size: 15px; color: var(--muted); margin: 2px 0 0; }
.pub-venue em { font-style: italic; color: var(--ink); }

.pub-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}
.chip {
  appearance: none;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 7px 10px;
  text-decoration: none;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.chip:hover,
.chip[aria-expanded="true"] { color: var(--accent); border-color: var(--accent); }

.bib {
  position: relative;
  margin-top: 12px;
  background: var(--code-bg);
  border: 1px solid var(--rule);
  border-radius: 8px;
}
.bib[hidden] { display: none; }
.bib pre {
  margin: 0;
  padding: 16px 18px;
  padding-right: 80px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--muted);
  overflow-x: auto;
  white-space: pre;
}
.bib .copy {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--surface);
}

@media (max-width: 560px) {
  .pub { grid-template-columns: 1fr; gap: 4px; }
  .pub-year { padding-top: 0; }
}

.scholar-note {
  margin-top: 28px;
  font-size: 14.5px;
  color: var(--muted);
}

/* ---------- Code ---------- */

.repos {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.repo {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 20px 22px;
  text-decoration: none;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.repo:hover {
  color: inherit;
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.repo-name {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.repo-name .arrow { color: var(--faint); transition: color 0.15s ease, transform 0.15s ease; }
.repo:hover .repo-name .arrow { color: var(--accent); transform: translate(2px, -2px); }
.repo p { margin: 0; font-size: 15px; color: var(--muted); }
.repo-meta {
  margin-top: auto;
  padding-top: 6px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--faint);
  display: flex;
  align-items: center;
  gap: 14px;
}
.lang-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #3572a5;
  margin-right: 6px;
  vertical-align: 0;
}

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

/* ---------- Path (education + experience) ---------- */

.path { list-style: none; margin: 0; padding: 0; position: relative; }
.path::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 10px;
  bottom: 10px;
  width: 1px;
  background: var(--rule);
}
.step {
  position: relative;
  padding: 0 0 32px 36px;
}
.step:last-child { padding-bottom: 0; }
.step::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--faint);
}
.step.now::before { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.step-when {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.step h3 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 21px;
  line-height: 1.3;
  margin: 2px 0 2px;
}
.step p { margin: 0; color: var(--muted); font-size: 15.5px; }

/* ---------- Footer ---------- */

.footer {
  border-top: 1px solid var(--rule);
  padding: clamp(48px, 7vw, 80px) 0 40px;
}
.contact-line {
  font-family: var(--serif);
  font-size: clamp(26px, 4vw, 40px);
  line-height: 1.2;
  letter-spacing: -0.015em;
  margin: 0 0 12px;
  max-width: 20em;
}
.contact-line a { color: var(--accent); }
.footer .small {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  margin-top: 56px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--faint);
}
.footer .small a { color: var(--muted); }

/* ---------- Print ---------- */

@media print {
  .topbar, .theme-toggle, .pub-actions, .bib, .portrait { display: none !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .section { padding: 18pt 0; border: 0; }
  a { text-decoration: none; }
}
