:root {
  /* Fonts already installed on the visitor's machine: no external request, no
     font files to ship, no swap-in layout shift. Resolves to SF Pro on Apple,
     Segoe UI Variable on Windows, Roboto on Android. */
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;

  /* The primary carries titles, links and every interaction state;
     the secondary is confined to the icon plates and the venue badges. */
  --primary: #d11a1a;
  --primary-hover: #ab1515;
  --primary-soft: #fcf1f1;
  --primary-line: #f2bfbf;
  --accent: #c2410c;
  --accent-hover: #9c340a;
  --accent-soft: #fdf1ea;
  --bg: #faf9f7;
  --surface: #ffffff;
  --text: #292524;
  --text-strong: #1c1917;
  --text-soft: #57534e;
  --muted: #78716c;
  --line: #e7e5e4;
  --line-soft: #f5f4f2;
  --radius: 0.25rem;
  --radius-sm: 0.1875rem;
  --nav-h: 4rem;
  --measure: 68ch;
  --page: 68rem;
  --gap: clamp(1rem, 2.5vw, 1.5rem);
  /* One transition for every interactive surface that tints on hover */
  --tint: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

/* ---------- Reset ---------- */

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

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

/* Every element inherits the sans face and its size from here, so no rule below
   repeats font-family. */
body {
  margin: 0;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: clamp(1rem, 0.97rem + 0.15vw, 1.0625rem);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--primary-line);
  color: var(--primary-hover);
}

img {
  max-width: 100%;
  height: auto;
}

/* ---------- Typography ---------- */

h1,
h2,
h3 {
  color: var(--text-strong);
  line-height: 1.2;
  margin: 0;
  letter-spacing: -0.015em;
}

h1 {
  font-size: clamp(2.125rem, 1.5rem + 2.6vw, 3rem);
  font-weight: 700;
}

h2 {
  font-size: clamp(1.5rem, 1.2rem + 1.1vw, 1.875rem);
  font-weight: 700;
}

h3 {
  font-size: 1.125rem;
  font-weight: 600;
}

p {
  margin: 0;
}

a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

a:hover {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 2px;
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* ---------- Layout ---------- */

.wrap {
  width: 100%;
  max-width: var(--page);
  margin-inline: auto;
  padding-inline: clamp(1rem, 4vw, 2rem);
}

main.wrap {
  padding-top: calc(var(--nav-h) + clamp(2rem, 5vw, 3.5rem));
  padding-bottom: clamp(3rem, 6vw, 4.5rem);
}

section {
  margin-bottom: clamp(3rem, 6vw, 4.5rem);
  scroll-margin-top: calc(var(--nav-h) + 1.5rem);
}

section:last-of-type {
  margin-bottom: 0;
}

/* Main titles carry the primary accent, as the section headings do in the CV.
   The icon inherits it through currentColor. */
.section-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: clamp(1.25rem, 3vw, 2rem);
  color: var(--primary);
}

.prose {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: var(--measure);
  color: var(--text-soft);
}

.lead {
  font-size: clamp(1.0625rem, 1rem + 0.35vw, 1.1875rem);
}

hr.rule {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 0 0 clamp(3rem, 6vw, 4.5rem);
}

/* ---------- Icons ---------- */

.icon {
  width: 1.25rem;
  height: 1.25rem;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  flex: none;
}

.icon-sm {
  width: 1rem;
  height: 1rem;
}

.icon-lg {
  width: 1.5rem;
  height: 1.5rem;
}

/* ---------- Navigation ---------- */

.nav {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 50;
  background: rgb(255 255 255 / 0.72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--nav-h);
  gap: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.125rem;
  font-weight: 400;
  color: var(--text-strong);
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.brand-last {
  font-weight: 600;
}

.brand-mark {
  width: 1.375rem;
  height: 1.375rem;
  flex: none;
}

.brand:hover {
  color: var(--primary);
  text-decoration: none;
}

.nav-links {
  display: flex;
  align-items: baseline;
  gap: clamp(1rem, 2vw, 1.5rem);
  font-size: 0.9375rem;
  font-weight: 500;
}

.nav-links a {
  position: relative;
  color: var(--text);
  transition: color 0.2s ease;
}

.nav-links a:hover {
  color: var(--primary);
  text-decoration: none;
}

.nav-links a::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -5px;
  width: 0;
  height: 2px;
  background: var(--primary);
  transition: width 0.25s ease;
}

.nav-links a:hover::after {
  width: 100%;
}

.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.nav-toggle:hover {
  background: var(--line-soft);
  color: var(--primary);
}

/* Populated from .nav-links by main.js */
.nav-mobile {
  display: none;
  border-top: 1px solid var(--line);
  padding: 0.5rem clamp(1rem, 4vw, 2rem) 0.75rem;
}

.nav-mobile.open {
  display: block;
}

.nav-mobile a {
  display: block;
  padding: 0.625rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-weight: 500;
}

.nav-mobile a:hover {
  background: var(--primary-soft);
  color: var(--primary);
  text-decoration: none;
}

@media (max-width: 62rem) {
  .nav-links {
    display: none;
  }

  .nav-toggle {
    display: inline-flex;
  }
}

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

/* The h1 is the tagline itself: quiet type, since the name is in the bar. */
.hero .tagline {
  font-size: clamp(1rem, 0.9rem + 0.5vw, 1.25rem);
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 1.5rem;
}

/* ---------- Cards & grids ---------- */

.grid {
  display: grid;
  gap: var(--gap);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
}

.grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
}

.grid-top {
  align-items: start;
}

/* Exactly two columns from tablet up: keeps 4-card sections balanced (2x2)
   instead of leaving an orphan card on a second row. */
.grid-pair {
  grid-template-columns: 1fr;
}

@media (min-width: 48rem) {
  .grid-pair {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* A card that takes the whole row: the S3 entry leads the software list. */
.card-wide {
  grid-column: 1 / -1;
}

/* A plain card is a container, not a control, so it gets no hover state.
   Hover feedback is reserved for links, chips and buttons. */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(1.25rem, 3vw, 1.75rem);
}

/* Whole-card links (Software, Teaching): the card is the control, so it takes
   the same hover feedback as an entry in the link list. */
a.card {
  display: block;
  color: inherit;
  font-weight: inherit;
  transition: var(--tint);
}

a.card:hover {
  border-color: var(--primary-line);
  background: var(--primary-soft);
  text-decoration: none;
}

a.card:hover h3 {
  color: var(--primary-hover);
}

/* Invert the icon plate so it stays legible against the tinted card */
a.card:hover .card-icon {
  background: var(--surface);
}

.card h3 {
  margin-bottom: 0.625rem;
}

.card p {
  color: var(--text-soft);
  font-size: 0.9375rem;
}

.card > p + p {
  margin-top: 1rem;
}

/* The accent plate, shared with the lecture numbers on the course pages */
.card-icon,
.lectures > li::before {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
}

.card-icon {
  width: 2.75rem;
  height: 2.75rem;
  margin-bottom: 1rem;
}

/* A plate holds either a stroked icon or a math glyph, so both are drawn in the
   same 1.625rem box: at the default .icon size the line art read a fifth
   smaller than the glyph on the card beside it. */
.card-icon .icon {
  width: 1.625rem;
  height: 1.625rem;
}

/* Math glyph (e.g. the double turnstile) used in place of a stroked icon.
   The UI sans has no U+22A8, so fall back through math/serif faces that do. */
.glyph {
  font-family: 'STIX Two Math', 'Cambria Math', 'Latin Modern Math', 'DejaVu Serif', 'Times New Roman', serif;
  font-size: 1.625rem;
  font-weight: 600;
  line-height: 1;
}

/* Software cards use the tool's name in place of an icon, set in the monospace
   face: these are commands you type. Not small caps — the mixed case in nuXmv,
   NuSMV and pySMT is part of the name and small caps would flatten it. */
.card-icon.name {
  width: auto;
  min-width: 2.75rem;
  height: 2.375rem;
  padding: 0 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.9375rem;
  font-weight: 600;
  white-space: nowrap;
}

/* The name plate is the card's visible title, so the heading text that would
   repeat it is exposed to assistive tech only. */
.sr-name {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ---------- Chips & link list ---------- */

/* A chip and a link-list entry are the same object at two sizes: an outlined
   surface that tints on hover. */
.chip,
.link-list a {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
  transition: var(--tint);
}

.chip {
  gap: 0.4rem;
  padding: 0.35rem 0.7rem;
  font-size: 0.8125rem;
}

button.chip {
  font-family: inherit;
  cursor: pointer;
}

.link-list a {
  flex: 1;
  gap: 0.625rem;
  padding: 0.75rem 1rem;
}

/* Four states share one look: a hovered chip or link entry, the Abstract toggle
   while its panel is open, and the Abstract toggle of a hovered publication
   card — that card's click drives the toggle, so it previews the control it
   will operate. */
.chip:hover,
.chip-active,
.pub:hover button.chip,
.link-list a:hover {
  background: var(--primary-soft);
  border-color: var(--primary-line);
  color: var(--primary-hover);
}

.chip:hover,
.link-list a:hover {
  text-decoration: none;
}

/* Unless the pointer is on one of the card's links, which does something else */
.pub:has(a:hover) button.chip:not(.chip-active) {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

/* A chip row that closes a section rather than a card */
.chips-loose {
  margin-top: 1.5rem;
}

.link-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
}

.link-list li {
  display: flex;
}

.link-list .icon {
  color: var(--muted);
}

.link-list a:hover .icon {
  color: var(--primary);
}

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

.pub-list {
  display: flex;
  flex-direction: column;
  gap: clamp(1.75rem, 4vw, 2.5rem);
}

.pub-year {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.pub-year::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

.pub-items {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* The whole card toggles its abstract, so it earns hover feedback. Border only:
   the tinted fill is reserved for cards that navigate somewhere. */
.pub {
  display: flex;
  gap: 1.25rem;
  cursor: pointer;
  transition: var(--tint);
}

.pub:hover {
  border-color: var(--primary-line);
}

/* One treatment for every venue type: the label already says which it is, so
   colour would only repeat it. */
.badge {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  flex: none;
  padding: 0.25rem 0.7rem;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.pub-body {
  flex: 1;
  min-width: 0;
}

.pub-authors {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.pub-title {
  margin-bottom: 0.4rem;
  line-height: 1.35;
}

.pub-venue {
  font-size: 0.875rem;
  font-style: italic;
  color: var(--muted);
}

.pub .chips {
  margin-top: 0.875rem;
}

@media (max-width: 40rem) {
  .pub {
    flex-direction: column;
    gap: 0.75rem;
  }
}

.pub-abstract {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line-soft);
  font-size: 0.9375rem;
  color: var(--text-soft);
  max-width: var(--measure);
}

.pub-abstract sub {
  font-size: 0.72em;
}

/* ---------- Committees ---------- */

.service-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  font-size: 0.9375rem;
}

.service-list li {
  display: grid;
  grid-template-columns: 9.5rem 1fr;
  gap: 0.5rem 1rem;
  align-items: baseline;
  color: var(--text-soft);
}

.service-list strong {
  color: var(--text-strong);
}

.service-years {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--primary);
  white-space: nowrap;
}

@media (max-width: 34rem) {
  .service-list li {
    grid-template-columns: 1fr;
    gap: 0.15rem;
  }
}

/* ---------- Education ---------- */

.timeline {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.timeline .card {
  display: grid;
  grid-template-columns: minmax(9rem, 12rem) 1fr;
  gap: clamp(1rem, 3vw, 2rem);
  align-items: start;
}

.timeline .prose {
  margin-top: 0.5rem;
}

.timeline-when {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--primary);
}

.timeline-where {
  font-size: 0.875rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

@media (max-width: 48rem) {
  .timeline .card {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
}

/* ---------- Course pages ---------- */

.page-head {
  margin-bottom: clamp(1.5rem, 4vw, 2.25rem);
}

/* The title sits closer to its description, where the page head has one */
.page-head .section-title:has(+ .prose) {
  margin-bottom: 1rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.875rem;
  color: var(--muted);
  margin-bottom: 1rem;
}

.back-link:hover {
  color: var(--primary);
  text-decoration: none;
}

.lectures {
  list-style: none;
  counter-reset: lecture;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.lectures > li {
  counter-increment: lecture;
  display: grid;
  grid-template-columns: 2.25rem 1fr;
  gap: 1rem;
  align-items: start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(1rem, 2.5vw, 1.25rem);
}

.lectures > li::before {
  content: counter(lecture);
  width: 2.25rem;
  height: 2.25rem;
  font-size: 0.875rem;
  font-weight: 700;
}

.lecture-title {
  font-weight: 600;
  color: var(--text-strong);
}

.lecture-date {
  font-size: 0.8125rem;
  color: var(--muted);
  font-weight: 400;
  margin-left: 0.5rem;
  white-space: nowrap;
}

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

footer {
  background: var(--text-strong);
  color: #a8a29e;
  padding: clamp(2.5rem, 5vw, 3rem) 0;
  text-align: center;
  font-size: 0.9375rem;
}

footer a {
  color: inherit;
}

footer a:hover {
  color: #fff;
  text-decoration: none;
}

footer .footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.5rem;
  margin-top: 1rem;
}

/* ---------- Wide screens ---------- */

@media (min-width: 90rem) {
  :root {
    --page: 76rem;
  }
}

/* ---------- Motion ---------- */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
