/* Mehdi Dagdoug — site styles */

:root {
  --bg: #f7f5f0;
  --surface: #fffdf8;
  --ink: #1c1e24;
  --ink-2: #26282e;
  --muted: #4a4d55;
  --rule: #e2ddd2;
  --rule-strong: #1c1e24;
  --accent: #2b3f7e;
  --accent-hover: #1d2d61;
  --accent-soft: #e5e9f3;
  --on-accent: #ffffff;
  --fig-ink: #50535b;
  --fig-muted: #b5b1a8;

  --display: "EB Garamond", "Iowan Old Style", Georgia, serif;
  --serif: "Source Serif 4", "Iowan Old Style", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --wrap: 1100px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121419;
    --surface: #191c23;
    --ink: #ebe8e1;
    --ink-2: #dedbd4;
    --muted: #b6b8bf;
    --rule: #2b2f39;
    --rule-strong: #ebe8e1;
    --accent: #a8b9ee;
    --accent-hover: #c8d3f6;
    --accent-soft: #232b45;
    --on-accent: #121419;
    --fig-ink: #b8b6b0;
    --fig-muted: #4c505a;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #121419;
  --surface: #191c23;
  --ink: #ebe8e1;
  --ink-2: #dedbd4;
  --muted: #b6b8bf;
  --rule: #2b2f39;
  --rule-strong: #ebe8e1;
  --accent: #a8b9ee;
  --accent-hover: #c8d3f6;
  --accent-soft: #232b45;
  --on-accent: #121419;
  --fig-ink: #b8b6b0;
  --fig-muted: #4c505a;
  color-scheme: dark;
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.65;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent-hover); }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
/* colleague names: same look as the text, with only a faint dotted underline to show they are links */
a.person { color: inherit; font-weight: inherit; text-decoration: underline dotted 1px; text-decoration-color: color-mix(in srgb, currentColor 30%, transparent); text-underline-offset: 3px; }
a.person:hover { color: var(--accent); text-decoration-style: solid; text-decoration-color: currentColor; }

h1, h2, h3, h4 { font-weight: 500; line-height: 1.2; margin: 0; }
h2 { font-family: var(--display); font-size: 34px; letter-spacing: -0.005em; margin-bottom: 18px; }
p { margin: 0 0 1em; }
img { max-width: 100%; height: auto; display: block; }

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

/* ---------- header ---------- */

.site-header {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--rule);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 24px; min-height: 72px; }
.brand { font-family: var(--display); font-size: 25px; font-weight: 500; color: var(--ink); text-decoration: none; white-space: nowrap; }
.brand:hover { color: var(--accent); }
.nav { display: flex; gap: 2px; font-size: 18px; font-weight: 500; }
.nav a {
  color: var(--ink); text-decoration: none; padding: 7px 12px; border-radius: 6px; white-space: nowrap;
}
.nav a:hover { color: var(--accent); background: var(--accent-soft); }
.nav a[aria-current="page"] { color: var(--accent); box-shadow: inset 0 -2px 0 var(--accent); border-radius: 0; }
.nav .nav-cv { border: 1px solid var(--rule); margin-left: 8px; }

/* ---------- shared bits ---------- */

.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 7px; padding: 0; margin: 0 0 24px; }
.chips li {
  font-size: 15.5px; font-weight: 600; line-height: 1.35; white-space: nowrap;
  color: var(--accent); background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  border-radius: 999px; padding: 5px 12px;
}

.btn {
  display: inline-block; font-size: 17px; font-weight: 600; text-decoration: none; line-height: 1.3;
  padding: 10px 20px; border-radius: 8px; border: 1px solid var(--rule); background: var(--surface); color: var(--ink);
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }

.card { background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; padding: 22px 24px; }
.card-title {
  font-family: var(--mono); font-size: 15.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--accent); margin: 0 0 12px;
}
.card p, .card ul { font-size: 17.5px; line-height: 1.55; margin: 0 0 12px; }
.card > :last-child { margin-bottom: 0; }
.card-more { font-size: 16.5px; }
.plain { list-style: none; padding: 0; margin: 0; }
.plain li { padding: 3px 0; }

.page-head { padding: 56px 0 24px; }
.page-head h1 { font-family: var(--display); font-size: clamp(44px, 6vw, 60px); letter-spacing: -0.01em; margin-bottom: 10px; }
.page-sub { color: var(--ink-2); font-size: 19px; max-width: 46em; }
.page-kicker { font-family: var(--mono); font-size: 14px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); margin: 0 0 8px; }

.section-title {
  font-family: var(--display); font-size: 36px; font-weight: 500;
  margin: 40px 0 0; padding-bottom: 6px;
}

/* ---------- home ---------- */

.hero {
  display: grid; grid-template-columns: 270px 1fr; gap: 48px; align-items: start;
  padding: 60px 0 44px;
}
.hero-photo {
  width: 100%; aspect-ratio: 4 / 5; object-fit: cover; object-position: 50% 20%;
  border-radius: 8px; box-shadow: 0 1px 2px rgb(0 0 0 / .08), 0 12px 32px -12px rgb(20 30 60 / .35);
}
.hero-name {
  font-family: var(--display); font-weight: 500; color: var(--accent);
  font-size: clamp(42px, 5vw, 60px); line-height: 1.02; letter-spacing: -0.01em; margin: 4px 0 14px;
}
.role { font-size: 24px; font-weight: 600; line-height: 1.3; color: var(--ink); margin-bottom: 4px; }
.affiliation { font-size: 20px; line-height: 1.45; color: var(--ink); margin-bottom: 22px; }
.lead { font-size: 20px; line-height: 1.6; color: var(--ink); max-width: 40em; }
.program { font-size: 19px; line-height: 1.6; max-width: 40em; margin-top: -4px; }
.program a { text-decoration-color: color-mix(in srgb, currentColor 35%, transparent); }
.contact-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; font-size: 19px; margin-bottom: 20px; }
.contact-line .email { font-weight: 600; }
.contact-line .sep { color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 0; }

.info-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; padding: 0 0 56px; }

.research-intro { max-width: 46em; padding-bottom: 8px; }
.research-intro p { font-size: 19.5px; line-height: 1.7; }
.research-intro p:last-child { font-weight: 600; }
.theme-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin: 24px 0 64px; }
.theme { display: flex; flex-direction: column; border-top: 4px solid var(--accent); scroll-margin-top: 96px; }
.theme-title { font-family: var(--display); font-size: 27px; font-weight: 600; margin: 0 0 12px; }
.theme-why { font-size: 18px; font-weight: 600; line-height: 1.5; margin: 0 0 10px; }
.theme-what { font-size: 17.5px; line-height: 1.6; margin: 0 0 16px; }
.theme-papers-title {
  font-family: var(--mono); font-size: 13.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--accent); margin: auto 0 6px; padding-top: 12px; border-top: 1px solid var(--rule);
}
.theme-papers { list-style: none; padding: 0; margin: 0; }
.theme-papers li { font-size: 16px; line-height: 1.45; padding: 5px 0; }
.theme-papers a { color: var(--ink); text-decoration-color: var(--rule); }
.theme-papers a:hover { color: var(--accent); text-decoration-color: currentColor; }
.tyear { white-space: nowrap; }

.about { padding: 44px 0 48px; border-top: 1px solid var(--rule); }
.about p { max-width: 42em; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 56px; padding: 40px 0 72px; border-top: 1px solid var(--rule); }
.mini-list { list-style: none; padding: 0; margin: 0 0 16px; }
.mini-list li { padding: 12px 0; border-bottom: 1px solid var(--rule); display: grid; gap: 2px; }
.mini-list li:first-child { padding-top: 0; }
.mini-title { font-weight: 600; font-size: 18px; line-height: 1.4; color: var(--ink); text-decoration: none; }
a.mini-title:hover { color: var(--accent); text-decoration: underline; }
.mini-meta { font-size: 16px; color: var(--ink-2); line-height: 1.45; }
.mini-date { font-family: var(--mono); font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }
.more { font-size: 17px; }

/* ---------- publications ---------- */

.year-group { margin-top: 28px; }
.year {
  font-family: var(--display); font-size: 32px; font-weight: 600; line-height: 1;
  border-top: 3px solid var(--rule-strong); padding: 12px 0 4px; margin: 0;
}

.pub { display: grid; grid-template-columns: 1fr; gap: 36px; align-items: start; padding: 22px 0 24px; }
.pub + .pub { border-top: 1px solid var(--rule); }
.pub.has-fig { grid-template-columns: 1fr 300px; }
.pub-body { position: relative; padding-left: 52px; }
.pub-num { position: absolute; left: 0; top: 3px; font-family: var(--mono); font-size: 16px; font-weight: 500; color: var(--ink); }
.pub-title { font-family: var(--serif); font-size: 21.5px; font-weight: 600; line-height: 1.35; margin-bottom: 6px; }
.pub-title a { color: var(--ink); text-decoration: none; }
.pub-title a:hover { color: var(--accent); text-decoration: underline; }
.pub-authors { font-size: 18px; color: var(--ink-2); margin-bottom: 2px; }
.pub-authors .me { color: var(--ink); font-weight: 600; }
.pub-venue { font-size: 18px; color: var(--ink-2); margin-bottom: 0; }
.journal { font-style: italic; font-weight: 600; color: var(--accent); }
.pub-links { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 0; }
.pub-links a {
  font-family: var(--mono); font-size: 13px; letter-spacing: 0.04em; text-decoration: none;
  border: 1px solid var(--rule); background: var(--surface); border-radius: 999px; padding: 3px 13px;
}
.pub-links a:hover { border-color: var(--accent); background: var(--accent-soft); }

.pub-fig { margin: 4px 0 0; background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; padding: 10px; }
.pub-fig svg, .pub-fig img { display: block; width: 100%; height: auto; border-radius: 4px; }

/* figure palette (generated SVG illustrations) */
.pub-fig .fi { --c: var(--fig-ink); }
.pub-fig .fa { --c: var(--accent); }
.pub-fig .fm { --c: var(--fig-muted); }
.pub-fig .dot { fill: var(--c); }
.pub-fig .line { fill: none; stroke: var(--c); stroke-linecap: round; stroke-linejoin: round; }
.pub-fig .ring, .pub-fig .box { fill: var(--surface); stroke: var(--c); }
.pub-fig rect.fa:not(.box) { fill: var(--accent); }
.pub-fig rect.fs { fill: var(--accent-soft); }

/* ---------- talks ---------- */

.talk-section .section-title, .section-title.ruled { border-bottom: 3px solid var(--rule-strong); }
.talk-list { list-style: none; padding: 0; margin: 0 0 24px; }
.talk { display: grid; grid-template-columns: 40px 104px 1fr; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--rule); }
.talk-num { font-family: var(--mono); font-size: 15px; font-weight: 500; color: var(--ink); padding-top: 2px; text-align: right; }
.talk-date { font-family: var(--mono); font-size: 14px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); padding-top: 3px; }
.talk-title { display: block; font-weight: 600; font-size: 19px; line-height: 1.4; }
.talk-event { display: block; font-size: 17.5px; color: var(--ink-2); line-height: 1.5; }
.talk-with { display: block; font-size: 16px; color: var(--muted); }

/* ---------- students ---------- */

.student-section .section-title { border-bottom: 3px solid var(--rule-strong); margin-bottom: 20px; }
.student-grid { list-style: none; padding: 0; margin: 0 0 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.student { display: grid; gap: 2px; align-content: start; }
.student-name { font-weight: 600; font-size: 20px; }
.student-years { font-family: var(--mono); font-size: 13.5px; letter-spacing: 0.06em; color: var(--accent); margin-bottom: 4px; }
.student-meta { font-size: 16.5px; color: var(--ink-2); line-height: 1.45; }
.student-topic { font-size: 16.5px; font-style: italic; color: var(--ink-2); margin-top: 4px; }

/* ---------- text pages (Teaching, Service) ---------- */

.prose { max-width: 46em; padding-bottom: 64px; }
.prose h2 { font-size: 36px; margin: 40px 0 16px; padding-bottom: 6px; border-bottom: 3px solid var(--rule-strong); }
.prose h2:first-child { margin-top: 8px; }
.prose h3 { font-family: var(--serif); font-size: 20px; font-weight: 600; margin: 28px 0 10px; }
.prose ul { padding-left: 0; list-style: none; margin: 0 0 16px; }
.prose li { position: relative; padding: 8px 0 8px 22px; border-bottom: 1px solid var(--rule); line-height: 1.55; }
.prose li::before { content: ""; position: absolute; left: 2px; top: 1.05em; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.prose strong { font-weight: 600; }

/* ---------- publications: view switch, topics, thesis ---------- */

.head-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 32px; flex-wrap: wrap; }
.head-row h1 { margin-bottom: 0; }
.view-switch { display: inline-flex; padding: 4px; gap: 4px; border: 1px solid var(--rule); border-radius: 999px; background: var(--surface); }
.view-switch[hidden] { display: none; }
.view-switch button {
  font: inherit; font-size: 17px; font-weight: 600; line-height: 1.2; cursor: pointer;
  color: var(--ink); background: transparent; border: 0; border-radius: 999px; padding: 9px 20px;
}
.view-switch button:hover { color: var(--accent); }
.view-switch button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.view-switch button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.topic-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin-top: 20px; align-items: start; }
.topic-grid[hidden] { display: none; }
.topic-block { padding: 22px 24px 18px; border-top: 4px solid var(--accent); }
.topic { font-family: var(--display); font-size: 28px; font-weight: 600; line-height: 1.15; margin: 0; }
.topic-count { font-family: var(--mono); font-size: 13.5px; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); margin: 4px 0 0; }
.topic-year {
  font-family: var(--mono); font-size: 14px; font-weight: 600; letter-spacing: 0.08em; color: var(--ink);
  margin: 18px 0 0; padding-bottom: 4px; border-bottom: 2px solid var(--rule-strong);
}
.topic-list { list-style: none; padding: 0; margin: 0; }
.topic-list li { display: grid; grid-template-columns: 30px 1fr; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--rule); }
.topic-list li:last-child { border-bottom: 0; }
.tnum { font-family: var(--mono); font-size: 14px; font-weight: 500; padding-top: 2px; }
.ttitle { display: block; font-weight: 600; font-size: 17.5px; line-height: 1.4; color: var(--ink); text-decoration: none; }
.ttitle:hover { color: var(--accent); text-decoration: underline; }
.tmeta { display: block; font-size: 15.5px; line-height: 1.45; margin-top: 2px; }

.thesis-section { padding-bottom: 64px; }
.thesis { margin-top: 20px; max-width: 46em; }
.thesis-title { font-family: var(--display); font-size: 28px; font-weight: 500; margin-bottom: 10px; }
.thesis-title a { color: var(--ink); text-decoration: none; }
.thesis-title a:hover { color: var(--accent); text-decoration: underline; }
.thesis p { font-size: 18px; margin-bottom: 4px; }
.thesis .pub-links { margin-top: 14px; }

/* ---------- teaching & service ---------- */

.section-note { font-size: 18.5px; margin: 14px 0 0; max-width: 46em; }
.subsection { font-family: var(--serif); font-size: 21px; font-weight: 600; margin: 32px 0 4px; }

.course-grid { list-style: none; padding: 0; margin: 20px 0 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.course { display: grid; gap: 4px; height: 100%; text-decoration: none; color: var(--ink); }
.course:hover { border-color: var(--accent); color: var(--ink); }
.course-code { font-family: var(--mono); font-size: 15.5px; font-weight: 600; letter-spacing: 0.06em; color: var(--accent); }
.course-title { font-size: 20px; font-weight: 600; line-height: 1.35; }
.course-link { font-size: 16px; color: var(--accent); margin-top: 6px; }
.course-sub { font-size: 16.5px; }
.term { white-space: nowrap; }
.student-topic .label { font-style: normal; font-weight: 600; }
.student-now { font-size: 16.5px; font-weight: 600; color: var(--accent); margin-top: 6px; }
.journal-list { list-style: none; padding: 0; margin: 12px 0 64px; columns: 2; column-gap: 40px; }
.journal-list li { padding: 8px 0; border-bottom: 1px solid var(--rule); break-inside: avoid; font-style: italic; }

.table { width: 100%; border-collapse: collapse; margin: 12px 0 8px; font-size: 17.5px; line-height: 1.45; }
.table th {
  text-align: left; font-family: var(--mono); font-size: 13.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--accent); padding: 8px 16px 8px 0; border-bottom: 2px solid var(--rule-strong);
}
.table td { padding: 12px 16px 12px 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
.table .t-main { font-weight: 600; width: 50%; }
.table .t-sub { display: block; font-weight: 400; }
.table .t-when { white-space: normal; }

.rows { list-style: none; padding: 0; margin: 12px 0 64px; }
.rows li { padding: 12px 0; border-bottom: 1px solid var(--rule); }

.dated-list { list-style: none; padding: 0; margin: 8px 0 8px; }
.dated-list li { display: grid; grid-template-columns: 200px 1fr; gap: 20px; padding: 14px 0; border-bottom: 1px solid var(--rule); }
.dated-when { font-family: var(--mono); font-size: 14.5px; font-weight: 500; letter-spacing: 0.04em; color: var(--accent); padding-top: 3px; }
.dated-title { display: block; font-weight: 600; font-size: 18.5px; line-height: 1.45; }
.dated-sub { display: block; font-size: 17.5px; line-height: 1.5; }

/* ---------- footer ---------- */

.site-footer { border-top: 1px solid var(--rule); padding: 32px 0 48px; font-size: 16px; color: var(--ink-2); }
.footer-inner { display: flex; justify-content: space-between; gap: 32px; flex-wrap: wrap; }
.footer-name { font-family: var(--display); font-size: 21px; color: var(--ink); }
.footer-links { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: flex-start; }

/* ---------- responsive ---------- */

@media (max-width: 1000px) {
  .header-inner { flex-direction: column; align-items: stretch; gap: 0; padding-top: 10px; }
  .nav { overflow-x: auto; scrollbar-width: none; margin: 4px -12px 6px; }
  .nav::-webkit-scrollbar { display: none; }
  html { scroll-padding-top: 130px; }
  .info-cards { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 760px) {
  body { font-size: 18px; }
  .wrap { padding: 0 16px; }
  .nav { font-size: 17px; }
  .hero { grid-template-columns: 1fr; gap: 24px; padding: 28px 0 36px; }
  .hero-photo { width: 168px; }
  .role { font-size: 21px; }
  .affiliation { font-size: 18.5px; }
  .lead { font-size: 18.5px; }
  .contact-line { flex-direction: column; gap: 2px; }
  .contact-line .sep { display: none; }
  .info-cards, .two-col, .theme-grid { grid-template-columns: 1fr; }
  .two-col { gap: 40px; }
  .pub.has-fig { grid-template-columns: 1fr; gap: 16px; }
  .pub-fig { order: -1; }
  .pub-body { padding-left: 0; }
  .pub-num { position: static; display: block; margin-bottom: 2px; }
  .talk { grid-template-columns: 34px 1fr; gap: 2px 10px; }
  .talk-num { grid-row: 1 / span 2; text-align: left; }
  .talk-date, .talk > div { grid-column: 2; }
  h2, .section-title, .prose h2 { font-size: 30px; }
  .year { font-size: 28px; }
  .topic { font-size: 25px; }
  .topic-grid { grid-template-columns: 1fr; }
  .view-switch button { padding: 8px 16px; }
  .dated-list li { grid-template-columns: 1fr; gap: 2px; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { padding: 12px 0; border-bottom: 1px solid var(--rule); }
  .table td { padding: 0; border: 0; }
  .table .t-main { width: 100%; }
  .journal-list { columns: 1; }
}
