/* ==========================================================================
   Nayel Bettache — site stylesheet
   One stylesheet for the homepage and the course pages.
   Typeface: STIX Two Text, the face of scientific publishing.
   ========================================================================== */

:root {
  --paper: #ffffff;
  --ink: #1c1e24;
  --muted: #5b606d;
  --faint: #868b98;
  --rule: #e3e5ea;
  --tint: #f5f6f9;
  --accent: #27479a;
  --accent-strong: #19306e;
  --accent-tint: #eef1fa;
  --alert: #a1281c;

  --font: "STIX Two Text", "STIX Two", "Times New Roman", Times, serif;
  --width: 62rem;
  --gutter: 1.25rem;
  --label-col: 12rem;
  --col-gap: 3rem;
  --bar-h: 3.5rem;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #15171c;
    --ink: #e7e8ec;
    --muted: #a6abb7;
    --faint: #7f8492;
    --rule: #2a2e37;
    --tint: #1b1e25;
    --accent: #9fb5f2;
    --accent-strong: #c6d3f8;
    --accent-tint: #1e2640;
    --alert: #f0907f;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #15171c;
  --ink: #e7e8ec;
  --muted: #a6abb7;
  --faint: #7f8492;
  --rule: #2a2e37;
  --tint: #1b1e25;
  --accent: #9fb5f2;
  --accent-strong: #c6d3f8;
  --accent-tint: #1e2640;
  --alert: #f0907f;
  color-scheme: dark;
}

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

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--bar-h) + 1rem);
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.6;
  font-variant-numeric: lining-nums;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

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

p { margin: 0 0 0.85em; }
p:last-child { margin-bottom: 0; }

h1, h2, h3 {
  font-weight: 600;
  line-height: 1.25;
  margin: 0;
  text-wrap: balance;
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent);
}
a:hover { color: var(--accent-strong); text-decoration-color: currentColor; }

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

em { font-style: italic; }
strong { font-weight: 600; }

.skip-link {
  position: absolute;
  left: -999px;
  top: 0.5rem;
  background: var(--paper);
  padding: 0.4rem 0.8rem;
  z-index: 50;
}
.skip-link:focus { left: 0.5rem; }

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  -webkit-backdrop-filter: saturate(140%) blur(8px);
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--rule);
}

.topbar-inner {
  max-width: var(--width);
  margin: 0 auto;
  padding: 0 var(--gutter);
  min-height: var(--bar-h);
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.brand {
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  font-size: 1.0625rem;
  white-space: nowrap;
}
.brand:hover { color: var(--accent); }

.sections {
  margin-left: auto;
  display: flex;
  gap: 1.15rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.sections::-webkit-scrollbar { display: none; }

.sections a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9375rem;
  white-space: nowrap;
  padding: 0.25rem 0;
  border-bottom: 1px solid transparent;
}
.sections a:hover { color: var(--ink); }
.sections a[aria-current="true"] {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

/* ---------- Page grid ---------- */

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

/* A row: a heading in the left column, content in the right. */
.row {
  display: grid;
  grid-template-columns: var(--label-col) minmax(0, 1fr);
  column-gap: var(--col-gap);
  padding: 2.75rem 0;
  border-top: 1px solid var(--rule);
}
.row:first-child { border-top: 0; }

.row > h2 {
  font-size: 1.125rem;
  color: var(--ink);
  position: sticky;
  top: calc(var(--bar-h) + 1.25rem);
  align-self: start;
  padding-top: 0.1rem;
}
.row > h2 .sub {
  display: block;
  font-weight: 400;
  font-style: italic;
  color: var(--muted);
  font-size: 0.9375rem;
  margin-top: 0.15rem;
}

.body > * + * { margin-top: 1rem; }
.body > h3 + * { margin-top: 0.6rem; }
.body > * + h3 { margin-top: 2rem; }

.body h3 {
  font-size: 1.0625rem;
  font-style: italic;
  font-weight: 600;
}
.body h3 a { color: inherit; }
.body h3 a:hover { color: var(--accent); }

.prose { max-width: 40em; }

.note {
  color: var(--muted);
  font-style: italic;
}

/* ---------- Intro (homepage header) ---------- */

.intro {
  display: grid;
  grid-template-columns: var(--label-col) minmax(0, 1fr);
  column-gap: var(--col-gap);
  padding: 3.5rem 0 3rem;
  align-items: start;
}

.portrait {
  width: 100%;
  max-width: 11rem;
  height: auto;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 0.75rem;
  background: var(--tint);
}

.intro h1 {
  font-size: clamp(2rem, 1.4rem + 2.2vw, 2.75rem);
  letter-spacing: -0.012em;
  line-height: 1.1;
}

.intro .role {
  font-size: 1.1875rem;
  margin: 0.6rem 0 0;
}
.intro .affil {
  color: var(--muted);
  margin: 0.1rem 0 0;
}

.facts {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 0.2rem 1rem;
  margin: 1.25rem 0 0;
}
.facts dt { color: var(--muted); font-style: italic; }
.facts dd { margin: 0; }

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 1.25rem;
  margin-top: 1.5rem;
}

.profiles {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.1rem;
  list-style: none;
  margin: 0;
  padding: 0;
}
.profiles a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--ink);
  text-decoration: none;
}
.profiles a:hover { color: var(--accent); }
.profiles svg {
  width: 1rem;
  height: 1rem;
  fill: currentColor;
  flex: none;
}

.button {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.95rem;
  border: 1px solid var(--accent);
  border-radius: 0.375rem;
  color: var(--accent);
  background: transparent;
  text-decoration: none;
  font-size: 0.9375rem;
  line-height: 1.3;
  white-space: nowrap;
}
.button:hover {
  background: var(--accent-tint);
  color: var(--accent-strong);
}
.button.primary {
  background: var(--accent);
  color: var(--paper);
}
.button.primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: var(--paper);
}
.button svg { width: 0.95rem; height: 0.95rem; fill: currentColor; }

/* ---------- Course shortcuts (homepage) ---------- */

.course-links {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  list-style: none;
  margin: 0;
  padding: 0;
}
.course-links a {
  display: block;
  height: 100%;
  padding: 0.8rem 1rem;
  border: 1px solid var(--rule);
  border-radius: 0.5rem;
  color: var(--ink);
  text-decoration: none;
}
.course-links a:hover {
  border-color: var(--accent);
  background: var(--accent-tint);
}
.course-links .title { display: block; font-weight: 600; line-height: 1.3; }
.course-links .code { display: block; color: var(--muted); font-size: 0.9375rem; margin-top: 0.15rem; }

/* ---------- Entries: CV-style rows with a date column ---------- */

.entries {
  list-style: none;
  margin: 0;
  padding: 0;
}
.entries > li + li { margin-top: 1.1rem; }

.entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 1.5rem;
}
.entry .what { font-weight: 600; }
.entry .what a,
.pubs .title {
  color: var(--ink);
  text-decoration-color: color-mix(in srgb, var(--accent) 55%, transparent);
}
.entry .what a:hover,
.pubs .title:hover { color: var(--accent); text-decoration-color: currentColor; }
.entry .when {
  color: var(--muted);
  white-space: nowrap;
  text-align: right;
  font-variant-numeric: tabular-nums lining-nums;
}
.entry .detail {
  grid-column: 1 / -1;
  color: var(--muted);
}
.entry .detail a { color: var(--accent); }

/* Publications */
.pubs { list-style: none; margin: 0; padding: 0; }
.pubs > li + li { margin-top: 1.25rem; }
.pubs .title { font-weight: 600; }
.pubs .authors,
.pubs .venue { display: block; color: var(--muted); }
.pubs .venue em { color: var(--ink); }

/* Plain bulleted lists */
.bullets {
  margin: 0;
  padding-left: 1.15rem;
}
.bullets li + li { margin-top: 0.4rem; }
.bullets li::marker { color: var(--faint); }

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

.course-head {
  display: grid;
  grid-template-columns: var(--label-col) minmax(0, 1fr);
  column-gap: var(--col-gap);
  padding: 3.5rem 0 3rem;
  align-items: start;
}
.course-head .portrait { max-width: 7.5rem; }
.course-head h1 {
  font-size: clamp(1.9rem, 1.4rem + 2vw, 2.6rem);
  letter-spacing: -0.012em;
  line-height: 1.12;
}
.course-head .code {
  font-size: 1.1875rem;
  margin: 0.55rem 0 0;
}
.course-head .term { color: var(--muted); margin: 0.1rem 0 0; }
.course-head .profiles { margin-top: 1rem; }

.callout {
  border-left: 2px solid var(--accent);
  background: var(--tint);
  padding: 0.85rem 1.1rem;
  border-radius: 0 0.375rem 0.375rem 0;
  color: var(--muted);
}
.callout strong { color: var(--ink); }

.hours {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 0.5rem 1.5rem;
  margin: 0;
}
.hours dt { font-weight: 600; }
.hours dd { margin: 0; color: var(--muted); }
.hours dd a { color: var(--accent); }

/* Weekly schedule */
.callout + .weeks { margin-top: 1.75rem; }
.weeks {
  list-style: none;
  margin: 0;
  padding: 0;
}
.week {
  display: grid;
  grid-template-columns: 5.25rem minmax(0, 1fr);
  column-gap: 1.25rem;
  padding: 1.1rem 0;
  border-top: 1px solid var(--rule);
}
.week:first-child { border-top: 0; padding-top: 0.25rem; }
.week .when { color: var(--muted); font-variant-numeric: tabular-nums lining-nums; }
.week .when b { display: block; color: var(--ink); font-weight: 600; }
.week h3 {
  font-size: 1.0625rem;
  font-style: normal;
  margin-bottom: 0.35rem;
}

.week.highlight {
  grid-template-columns: minmax(0, 1fr);
  background: var(--accent-tint);
  border-top-color: transparent;
  border-radius: 0.5rem;
  padding: 1.1rem 1.25rem;
  margin: 0.75rem 0 0;
}

/* Resource lines inside a week: a label, then links */
.res {
  display: grid;
  grid-template-columns: 6.5rem minmax(0, 1fr);
  gap: 0.25rem 0.75rem;
}
.res .k { color: var(--muted); font-style: italic; }
.res .v a { display: inline-block; margin-right: 0.85rem; }
.res .v a:last-child { margin-right: 0; }
.res .full { grid-column: 1 / -1; }
.res .aside { color: var(--muted); font-style: italic; }

.due { font-style: italic; color: var(--muted); font-size: 0.9375rem; }
.due.urgent { color: var(--alert); }

.muted { color: var(--muted); }

ol.objectives {
  margin: 0;
  padding-left: 1.5rem;
}
ol.objectives li + li { margin-top: 0.35rem; }
ol.objectives li::marker { color: var(--muted); font-variant-numeric: tabular-nums; }

.books { list-style: none; margin: 0; padding: 0; }
.books li + li { margin-top: 0.6rem; }
.books .note { display: block; }

.grading h3 { font-style: normal; }

/* Stacked label/value pairs (prerequisites, lecture times) */
.stack { margin: 0; }
.stack dt { font-weight: 600; }
.stack dd { margin: 0.1rem 0 0; }
.stack dd + dt { margin-top: 1rem; }

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

.footer {
  border-top: 1px solid var(--rule);
  margin-top: 1rem;
}
.footer .page {
  padding-top: 1.75rem;
  padding-bottom: 2.5rem;
  color: var(--faint);
  font-size: 0.9375rem;
}

/* ---------- Responsive ---------- */

@media (max-width: 52rem) {
  :root { --label-col: 9.5rem; --col-gap: 2rem; }
}

@media (max-width: 44rem) {
  :root { --bar-h: 5.75rem; }

  .topbar-inner {
    flex-wrap: wrap;
    gap: 0;
    padding-top: 0.6rem;
  }
  .brand { width: 100%; }
  .sections {
    margin: 0 calc(var(--gutter) * -1);
    padding: 0.35rem var(--gutter) 0.6rem;
    width: calc(100% + var(--gutter) * 2);
    gap: 1.1rem;
  }

  .row,
  .intro,
  .course-head {
    grid-template-columns: minmax(0, 1fr);
  }
  .row { padding: 2.25rem 0; }
  .row > h2 {
    position: static;
    margin-bottom: 1rem;
    font-size: 1.25rem;
  }
  .row > h2 .sub { display: inline; margin-left: 0.35rem; }

  .intro { padding: 2.25rem 0 1.5rem; }
  .intro .portrait { max-width: 7rem; margin-bottom: 1.25rem; }
  .course-head { padding: 2.25rem 0 1.5rem; }
  .course-head .portrait { max-width: 5rem; margin-bottom: 1.1rem; }

  .course-links { grid-template-columns: minmax(0, 1fr); }

  .entry { grid-template-columns: minmax(0, 1fr); }
  .entry .when { text-align: left; grid-row: 3; white-space: normal; font-size: 0.9375rem; }

  .hours { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .hours dd { margin-bottom: 0.6rem; }

  .week { grid-template-columns: minmax(0, 1fr); }
  .week .when { margin-bottom: 0.15rem; }
  .week .when b { display: inline; margin-right: 0.4rem; }
  .week.highlight { padding: 1rem; }

  .res { grid-template-columns: 5.5rem minmax(0, 1fr); gap: 0.3rem 0.6rem; }
  .res .k { font-size: 0.9375rem; padding-top: 0.05rem; }
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

@media print {
  .topbar, .skip-link { display: none; }
  .row > h2 { position: static; }
  a { color: inherit; text-decoration: none; }
}
