/* ==========================================================================
   machtei.com, styles
   Colors and fonts are set once here, at the top. Change them in this block.
   ========================================================================== */

:root {
  --bg: #FAF8F3;          /* warm white */
  --fg: #161616;
  --mute: #555555;
  --line: #E5E1D8;
  --soft: #F1EEE6;
  --acc: #2F5D50;          /* accent: links, paper and course titles, current section */
  --chip-on: #161616;
  --chip-on-fg: #FFFFFF;

  --font-name: 'Source Serif 4', Georgia, serif;
  --font-body: 'Source Serif 4', Georgia, serif;
  --font-ui: Inter, system-ui, sans-serif;
  --font-code: 'JetBrains Mono', ui-monospace, monospace;

  /* status tags: background / text */
  --st-pub-bg: #E3F0EA;  --st-pub-fg: #1F4E3D;
  --st-rev-bg: #FBEEDC;  --st-rev-fg: #6B3A00;
  --st-ch-bg:  #F1E6F4;  --st-ch-fg:  #5A2D6B;
  --st-wp-bg:  #EEEEEE;  --st-wp-fg:  #444444;
}

[data-theme="dark"] {
  --bg: #17181A;
  --fg: #ECEAE6;
  --mute: #A8A8A8;
  --line: #33363A;
  --soft: #222427;
  --acc: #9FCFBE;
  --chip-on: #ECEAE6;
  --chip-on-fg: #17181A;
  --st-pub-bg: #1E3A30;  --st-pub-fg: #A8D8C4;
  --st-rev-bg: #3D2C14;  --st-rev-fg: #F0C994;
  --st-ch-bg:  #36243D;  --st-ch-fg:  #DDB8EA;
  --st-wp-bg:  #2A2C30;  --st-wp-fg:  #C8C8C8;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.6;
  transition: background-color .3s, color .3s;
}
a { color: var(--acc); text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px; }
button { font: inherit; cursor: pointer; }
p { margin: 0 0 16px; }
.wrap { max-width: 1080px; margin: 0 auto; padding-left: 32px; padding-right: 32px; }
.ui { font-family: var(--font-ui); font-size: 14px; }
.code { font-family: var(--font-code); font-size: .9em; }
.small { font-size: 12px; }
.links { display: flex; flex-wrap: wrap; gap: 18px; margin: 0; }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 10; background: var(--bg); transition: background-color .3s; }
.bar {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px 32px;
  padding-top: 30px; padding-bottom: 22px; border-bottom: 1px solid transparent;
  transition: padding .25s ease-out, border-color .25s;
}
.brand { min-width: 0; }
.name {
  display: block; font-family: var(--font-name); font-weight: 600; font-size: 40px; line-height: 1.15;
  letter-spacing: -0.02em; color: var(--fg); text-decoration: none; transition: font-size .25s ease-out;
}
.sub {
  margin: 4px 0 0; font-size: 15px; font-style: italic; color: var(--mute);
  max-height: 32px; overflow: hidden; transition: max-height .25s ease-out, opacity .2s;
}
body.compact .bar { padding-top: 10px; padding-bottom: 10px; border-bottom-color: var(--line); }
body.compact .name { font-size: 19px; }
body.compact .sub { max-height: 0; opacity: 0; }

.tools { display: flex; align-items: center; gap: 22px; max-width: 100%; }
nav { display: flex; gap: 22px; font-family: var(--font-ui); font-size: 14px; font-weight: 500; overflow-x: auto; padding: 6px 4px; }

.nav {
  position: relative; display: inline-block; color: var(--fg); text-decoration: none; white-space: nowrap;
  transform-origin: center bottom; transition: transform .2s ease-out, color .2s;
}
.nav::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -4px; height: 1.5px; background: var(--acc);
  transform: scaleX(0); transform-origin: left; transition: transform .22s ease-out;
}
.nav:hover, .nav:focus-visible, .nav.on { color: var(--acc); }
.nav:hover, .nav:focus-visible { transform: scale(1.06); }
.nav.on, .nav.on:hover, .nav.on:focus-visible { transform: scale(1.1); font-weight: 600; }
.nav:hover::after, .nav:focus-visible::after, .nav.on::after { transform: scaleX(1); }

.theme-toggle {
  width: 36px; height: 36px; flex: none; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 50%; background: transparent; color: var(--fg);
}
.icon-sun { display: none; }
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }

/* ---------- home ---------- */
.home { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 24px 48px; padding: 44px 0 8px; }
.intro { flex: 1 1 520px; max-width: 740px; min-width: 0; }
.lede { font-size: 1.3em; line-height: 1.5; }
.photo { width: 180px; height: 180px; object-fit: cover; border-radius: 6px; flex: none; }

/* ---------- sections ---------- */
section { scroll-margin-top: 64px; }
.sec { padding-top: 56px; }
.secbody { max-width: 780px; }
.sh { margin: 0 0 18px; font-family: var(--font-ui); font-size: 13px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; }

/* ---------- research ---------- */
.filters { font-size: 13px; display: flex; flex-direction: column; gap: 10px; padding: 16px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.filter-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.filter-label { width: 64px; color: var(--mute); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 32px; padding: 0 12px; border-radius: 16px; border: 1px solid var(--line); background: transparent; color: var(--fg); transition: background-color .15s, color .15s, border-color .15s; }
.chip:hover { border-color: var(--fg); }
.chip[aria-pressed="true"] { background: var(--chip-on); border-color: var(--chip-on); color: var(--chip-on-fg); }

.papers { list-style: none; margin: 0; padding: 0; }
.paper { padding: 20px 0; border-bottom: 1px solid var(--line); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; font-family: var(--font-ui); font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; }
.tag { padding: 2px 8px; border-radius: 3px; border: 1px solid var(--line); color: var(--mute); }
.status { border: 0; }
.st-journal-article, .st-published, .st-forthcoming { background: var(--st-pub-bg); color: var(--st-pub-fg); }
.st-under-review { background: var(--st-rev-bg); color: var(--st-rev-fg); }
.st-book-chapter { background: var(--st-ch-bg); color: var(--st-ch-fg); }
.st-working-paper { background: var(--st-wp-bg); color: var(--st-wp-fg); }

.paper-title { margin: 0 0 2px; font-size: 1.12em; line-height: 1.35; }
.paper-title button {
  padding: 0; border: 0; background: none; text-align: left; color: var(--acc);
  font-family: var(--font-body); font-weight: 600; line-height: inherit;
}
.paper-title button:hover { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.byline { margin: 0 0 10px; font-size: .9em; color: var(--mute); }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-family: var(--font-ui); font-size: 13px; }
.btn { min-height: 36px; padding: 0 14px; border: 1px solid var(--line); border-radius: 4px; background: transparent; color: var(--fg); }
.btn:hover { border-color: var(--fg); }
.actions a { display: inline-flex; align-items: center; min-height: 36px; padding: 0 6px; }
.summary { margin: 14px 0 0; padding: 14px 18px; background: var(--soft); border-radius: 4px; font-size: .9em; }
.no-match { margin: 24px 0; font-style: italic; color: var(--mute); }
.text-button { border: 0; background: none; padding: 0; color: var(--acc); text-decoration: underline; }

/* ---------- teaching ---------- */
.group { margin: 0 0 10px; font-style: italic; color: var(--mute); }
.course { margin-bottom: 20px; }
.course p { margin: 0 0 4px; }
.course-title, .course-name { font-weight: 600; color: var(--acc); }
.course-title span { font-weight: 400; color: var(--mute); }
.course .links { font-size: 13px; gap: 16px; }
.group:not(:first-child) { margin-top: 28px; }
.ta { margin: 0; padding-left: 22px; }

/* ---------- footer ---------- */
.footer { margin-top: 64px; padding: 16px 0 56px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--mute); }

/* ---------- phones ---------- */
@media (max-width: 640px) {
  .wrap { padding-left: 20px; padding-right: 20px; }
  body { font-size: 17px; }
  .name { font-size: 32px; }
  .sub { max-height: 60px; }
  .bar { gap: 8px 12px; }
  .brand { max-height: 140px; transition: max-height .25s ease-out, opacity .2s; }
  .tools { width: 100%; flex-wrap: nowrap; gap: 12px; }
  /* one swipeable row of links; a soft fade on the right shows there is more */
  nav {
    flex: 1 1 auto; min-width: 0; gap: 18px; padding: 8px 10px 8px 4px;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(to right, #000 82%, transparent);
            mask-image: linear-gradient(to right, #000 82%, transparent);
  }
  nav::-webkit-scrollbar { display: none; }
  nav.at-end { -webkit-mask-image: none; mask-image: none; }
  /* when scrolled, the bar becomes a single line of links */
  body.compact .brand { max-height: 0; opacity: 0; overflow: hidden; }
  body.compact .bar { padding-top: 4px; padding-bottom: 4px; }
  section { scroll-margin-top: 56px; }
  .photo { width: 120px; height: 120px; order: -1; }
}

/* ---------- type weights (variable Source Serif) ---------- */
body { font-weight: 350; }
.name { font-variation-settings: 'opsz' 60; letter-spacing: -0.01em; }
.lede { font-size: 1.15em; line-height: 1.5; font-weight: 350; }
.paper-title button, .course-title, .course-name { font-weight: 500; }
.course-title span { font-weight: 350; }
strong, b { font-weight: 600; }

/* floating day/dark switch */
.fab { position: fixed; right: 20px; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); z-index: 40;
  width: 48px; height: 48px; background: var(--bg); border-color: var(--line);
  box-shadow: 0 2px 10px rgba(0,0,0,.10); transition: transform .25s ease-out, box-shadow .2s, background-color .3s; }
.fab:hover, .fab:focus-visible { transform: scale(1.06); box-shadow: 0 4px 16px rgba(0,0,0,.16); }
[data-theme="dark"] .fab { box-shadow: 0 2px 12px rgba(0,0,0,.5); }
.fab svg { width: 18px; height: 18px; }
/* phones: drop "Home" from the bar (tapping your name or scrolling up does the same), so all links fit */
@media (max-width: 640px) {
  .nav[data-section="home"] { display: none; }
  nav { gap: 16px; }
}

/* name inside the phone link row (only when the bar is thin) */
.nav-name { display: none; }
@media (max-width: 640px) {
  .home { padding-top: 8px; gap: 16px; }
  .photo { width: 104px; height: 104px; border-radius: 6px; }
  body.compact .nav-name {
    display: inline-block; flex: none; font-family: 'Source Serif 4', Georgia, serif; font-weight: 600;
    font-size: 16px; color: var(--fg); text-decoration: none; white-space: nowrap; align-self: center;
  }
  /* soft fades on whichever side has more to swipe to */
  nav { -webkit-mask-image: linear-gradient(to right, transparent 0, #000 28px, #000 calc(100% - 40px), transparent);
                mask-image: linear-gradient(to right, transparent 0, #000 28px, #000 calc(100% - 40px), transparent); }
  nav.at-start { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 40px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 40px), transparent); }
  nav.at-end { -webkit-mask-image: linear-gradient(to right, transparent 0, #000 28px); mask-image: linear-gradient(to right, transparent 0, #000 28px); }
  nav.at-start.at-end { -webkit-mask-image: none; mask-image: none; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
  .nav:hover, .nav:focus-visible { transform: none; }
}

.name-h { margin: 0; font-size: inherit; font-weight: inherit; line-height: inherit; }
