/* ==========================================================================
   Mahmoud M. Hammad — academic website
   One stylesheet for every page. Colors are tokens; dark mode redefines them.
   ========================================================================== */

:root {
  --bg: #f8f7f4;
  --surface: #ffffff;
  --surface-2: #f1efe9;
  --text: #18212d;
  --muted: #5a6575;
  --line: #e3dfd6;
  --accent: #1f3864;          /* navy, matches the CV */
  --accent-strong: #142645;
  --accent-soft: #e6ecf6;
  --gold: #a5741a;
  --gold-soft: #f7efdf;
  --green: #2e7d4f;
  --green-soft: #e3f2e9;
  --shadow: 0 1px 2px rgba(20, 30, 50, .05), 0 8px 24px rgba(20, 30, 50, .06);
  --radius: 14px;
  --maxw: 1080px;
  --serif: "Source Serif 4", "Source Serif Pro", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e131a; --surface: #151c26; --surface-2: #1b2430; --text: #e6eaf0; --muted: #9ba7b6;
    --line: #273242; --accent: #9dbcf5; --accent-strong: #c3d6fb; --accent-soft: #1c2a42;
    --gold: #e0b866; --gold-soft: #2e2615; --green: #7fd1a0; --green-soft: #15291e;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e131a; --surface: #151c26; --surface-2: #1b2430; --text: #e6eaf0; --muted: #9ba7b6;
  --line: #273242; --accent: #9dbcf5; --accent-strong: #c3d6fb; --accent-soft: #1c2a42;
  --gold: #e0b866; --gold-soft: #2e2615; --green: #7fd1a0; --green-soft: #15291e;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 16px/1.65 var(--sans); text-rendering: optimizeLegibility;
}
img { max-width: 100%; display: block; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent-strong); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { font-family: var(--serif); line-height: 1.2; margin: 0 0 .5em; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: clamp(2rem, 4.5vw, 3rem); }
h2 { font-size: clamp(1.45rem, 2.6vw, 1.85rem); }
h3 { font-size: 1.12rem; font-family: var(--sans); font-weight: 600; letter-spacing: 0; }
p { margin: 0 0 1em; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 16px; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

/* ---------- header / nav ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap { display: flex; align-items: center; gap: 16px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 600; white-space: nowrap; }
.brand .mono {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  background: var(--accent); color: var(--bg); font: 700 14px/1 var(--serif); letter-spacing: .02em;
}
.nav { margin-left: auto; display: flex; align-items: center; gap: 2px; }
.nav a {
  color: var(--muted); text-decoration: none; font-size: .93rem; font-weight: 500;
  padding: 7px 11px; border-radius: 8px; white-space: nowrap;
}
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }
.icon-btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  width: 36px; height: 36px; border-radius: 9px; display: inline-grid; place-items: center; cursor: pointer;
}
.icon-btn:hover { color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }
.menu-btn { display: none; }
@media (max-width: 960px) {
  .menu-btn { display: inline-grid; margin-left: auto; }
  .nav {
    position: absolute; top: 64px; left: 0; right: 0; flex-direction: column; align-items: stretch;
    background: var(--surface); border-bottom: 1px solid var(--line); padding: 8px 16px 14px; display: none;
  }
  .nav.open { display: flex; }
  .nav a { padding: 10px 12px; }
}

/* ---------- hero ---------- */
.hero { padding: 56px 0 40px; }
.hero .wrap { display: grid; grid-template-columns: 1fr 280px; gap: 48px; align-items: center; }
.eyebrow { font-size: .78rem; letter-spacing: .14em; text-transform: uppercase; color: var(--gold); font-weight: 600; margin-bottom: 12px; }
.hero h1 { margin-bottom: 10px; }
.hero .role { font-size: 1.12rem; color: var(--text); margin-bottom: 4px; }
.hero .affil { color: var(--muted); margin-bottom: 22px; }
.hero .lead { font-size: 1.05rem; max-width: 60ch; color: var(--text); }
.portrait { position: relative; }
.portrait img {
  width: 100%; height: auto; aspect-ratio: 4 / 5; object-fit: cover; object-position: center 20%;
  border-radius: 20px; box-shadow: var(--shadow);
}
.portrait::before {
  content: ""; position: absolute; inset: 14px -14px -14px 14px; border-radius: 22px;
  border: 1.5px solid var(--gold); z-index: -1; opacity: .7;
}
@media (max-width: 760px) {
  .hero { padding-top: 32px; }
  .hero .wrap { grid-template-columns: 1fr; gap: 28px; }
  .portrait { max-width: 220px; order: -1; }
}

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 22px 0 18px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; text-decoration: none; font-weight: 600; font-size: .93rem;
  padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text);
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.btn.primary:hover { background: var(--accent-strong); color: var(--bg); }
.btn svg { width: 17px; height: 17px; }

.profiles { display: flex; flex-wrap: wrap; gap: 8px; }
.profiles a {
  display: inline-flex; align-items: center; gap: 7px; font-size: .86rem; color: var(--muted); text-decoration: none;
  padding: 6px 11px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
}
.profiles a:hover { color: var(--accent); border-color: var(--accent); }
.profiles .badge-ic {
  width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center;
  font: 700 9.5px/1 var(--sans); color: #fff;
}

/* ---------- sections ---------- */
main { display: block; }
.section { padding: 44px 0; }
.section + .section { border-top: 1px solid var(--line); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.section-head h2 { margin: 0; }
.section-head a { font-size: .92rem; font-weight: 500; text-decoration: none; }
.page-head { padding: 48px 0 8px; }
.page-head p { color: var(--muted); max-width: 70ch; font-size: 1.05rem; }
.kicker { font-size: .78rem; letter-spacing: .14em; text-transform: uppercase; color: var(--gold); font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }

.grid { display: grid; gap: 18px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 860px) { .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 620px) { .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; } }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 22px; box-shadow: var(--shadow);
}
.card h3 { margin-bottom: 6px; }
.card p:last-child, .card ul:last-child { margin-bottom: 0; }
.card .tag-row { margin-top: 10px; }
.area-ic {
  width: 38px; height: 38px; border-radius: 10px; background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; margin-bottom: 12px;
}
.area-ic svg { width: 20px; height: 20px; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.stat b { display: block; font: 600 1.7rem/1.1 var(--serif); color: var(--accent); }
.stat span { font-size: .82rem; color: var(--muted); }
@media (max-width: 860px) { .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 460px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* news */
.news { list-style: none; margin: 0; padding: 0; }
.news li { display: grid; grid-template-columns: 96px 1fr; gap: 16px; padding: 12px 0; border-bottom: 1px dashed var(--line); }
.news li:last-child { border-bottom: 0; }
.news time { font-size: .82rem; font-weight: 600; color: var(--gold); padding-top: 2px; white-space: nowrap; }
@media (max-width: 520px) { .news li { grid-template-columns: 1fr; gap: 2px; } }

/* tags / badges */
.tag {
  display: inline-block; font-size: .76rem; font-weight: 600; letter-spacing: .02em;
  padding: 3px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); margin: 0 6px 6px 0;
}
.tag.gold { background: var(--gold-soft); color: var(--gold); }
.tag.green { background: var(--green-soft); color: var(--green); }
.tag.plain { background: var(--surface-2); color: var(--muted); }

/* timeline */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 8px; bottom: 8px; width: 2px; background: var(--line); }
.timeline li { position: relative; padding: 0 0 18px 30px; }
.timeline li::before {
  content: ""; position: absolute; left: 1px; top: 7px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--accent);
}
.timeline li.current::before { background: var(--accent); }
.timeline .when { font-size: .82rem; color: var(--gold); font-weight: 600; }
.timeline .what { font-weight: 600; }
.timeline .where { color: var(--muted); font-size: .93rem; }

/* publications */
.pub-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 8px 0 26px; position: sticky; top: 64px; z-index: 5; background: var(--bg); padding: 12px 0; border-bottom: 1px solid var(--line); }
.chip {
  border: 1px solid var(--line); background: var(--surface); color: var(--muted); font: 500 .88rem var(--sans);
  padding: 7px 13px; border-radius: 999px; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.chip .n { opacity: .7; margin-left: 4px; font-size: .8rem; }
.search {
  margin-left: auto; flex: 1 1 220px; max-width: 320px; font: 400 .93rem var(--sans); color: var(--text);
  padding: 9px 13px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
}
@media (max-width: 620px) { .search { margin-left: 0; max-width: none; } .pub-tools { position: static; } }
.year-group h3 { font-family: var(--serif); font-size: 1.3rem; color: var(--accent); margin: 26px 0 8px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.pub { display: grid; grid-template-columns: 52px 1fr; gap: 14px; padding: 14px 0; border-bottom: 1px dashed var(--line); }
.pub:last-child { border-bottom: 0; }
.pub .pid { font: 600 .8rem/1 var(--sans); color: var(--muted); background: var(--surface-2); border-radius: 8px; padding: 7px 0; text-align: center; height: fit-content; }
.pub .title { font-weight: 600; color: var(--text); margin-bottom: 2px; line-height: 1.45; }
.pub .authors { font-size: .93rem; color: var(--muted); }
.pub .authors .me { color: var(--text); font-weight: 600; }
.pub .venue { font-size: .93rem; font-style: italic; color: var(--muted); }
.pub .meta { margin-top: 7px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.pub .meta .tag { margin: 0; }
.pub .meta a.link {
  font-size: .8rem; font-weight: 600; text-decoration: none; padding: 3px 10px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--accent);
}
.pub .meta a.link:hover { border-color: var(--accent); }
.pub .note { font-size: .86rem; color: var(--muted); margin-top: 4px; }
.empty { color: var(--muted); padding: 20px 0; display: none; }

/* lists */
.clean { list-style: none; margin: 0; padding: 0; }
.clean li { padding: 9px 0; border-bottom: 1px dashed var(--line); }
.clean li:last-child { border-bottom: 0; }
.dot { padding-left: 1.1em; margin: 0; }
.dot li { margin: 4px 0; }

table.simple { width: 100%; border-collapse: collapse; font-size: .95rem; }
table.simple th, table.simple td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.simple th { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
table.simple td.code { font-weight: 600; color: var(--accent); white-space: nowrap; }
.table-wrap { overflow-x: auto; }

details.more { margin-top: 10px; }
details.more summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: .93rem; list-style: none; }
details.more summary::-webkit-details-marker { display: none; }
details.more summary::after { content: " ▾"; }
details.more[open] summary::after { content: " ▴"; }

.toc { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.toc a { font-size: .88rem; text-decoration: none; padding: 6px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--muted); }
.toc a:hover { color: var(--accent); border-color: var(--accent); }

/* footer */
.site-footer { margin-top: 40px; border-top: 1px solid var(--line); padding: 28px 0 40px; color: var(--muted); font-size: .9rem; }
.site-footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; }
.site-footer a { color: var(--muted); }

@media print {
  .site-header, .site-footer, .pub-tools, .actions, .menu-btn { display: none !important; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; }
}
