:root {
  color-scheme: light;
  --paper: #f7f4ed;
  --ink: #25221f;
  --ink-soft: #514c46;
  --muted: #746d65;
  --rule: #d7d0c6;
  --accent: #8b432b;
  --accent-hover: #672f1e;
  --focus: #a94c2d;
  --status-progress: #8b432b;
  --status-maintained: #45644f;
  --status-paused: #735a25;
  --status-completed: #466274;
  --status-retired: #706a63;
  --sans: "Atkinson Hyperlegible", system-ui, sans-serif;
  --serif: "Newsreader", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --shell: 1040px;
  --measure: 68ch;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --paper: #191817;
  --ink: #eee9e1;
  --ink-soft: #c8c0b6;
  --muted: #9d948a;
  --rule: #45403a;
  --accent: #dfa080;
  --accent-hover: #f0b99d;
  --focus: #e8a281;
  --status-progress: #dfa080;
  --status-maintained: #92bea0;
  --status-paused: #d1b47b;
  --status-completed: #91b8c9;
  --status-retired: #aaa39b;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --paper: #191817;
    --ink: #eee9e1;
    --ink-soft: #c8c0b6;
    --muted: #9d948a;
    --rule: #45403a;
    --accent: #dfa080;
    --accent-hover: #f0b99d;
    --focus: #e8a281;
    --status-progress: #dfa080;
    --status-maintained: #92bea0;
    --status-paused: #d1b47b;
    --status-completed: #91b8c9;
    --status-retired: #aaa39b;
  }
}

html[data-readable="true"] {
  --sans: "OpenDyslexic", "Atkinson Hyperlegible", sans-serif;
  --serif: "OpenDyslexic", "Atkinson Hyperlegible", sans-serif;
  --mono: "OpenDyslexic", "Atkinson Hyperlegible", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.55;
  text-rendering: optimizeLegibility;
}

::selection {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

a:hover {
  color: var(--accent-hover);
}

button {
  font: inherit;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 10;
  top: 0;
  left: 1rem;
  padding: 0.55rem 0.75rem;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--mono);
  font-size: 0.75rem;
  transform: translateY(-120%);
}

.skip-link:focus {
  transform: translateY(0);
}

.site-shell {
  width: min(100%, var(--shell));
  min-height: 100vh;
  margin: 0 auto;
  padding: 0 clamp(1.4rem, 4vw, 3rem);
}

main {
  min-height: 62vh;
}

.site-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 2rem;
  padding: 1.6rem 0 1.25rem;
  border-bottom: 1px solid var(--rule);
}

.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 0.4rem;
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}

.brand-name {
  font-size: 1.08rem;
  letter-spacing: -0.015em;
}

.space-mark {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 400;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  font-size: 0.85rem;
}

.site-nav a {
  color: var(--muted);
  text-decoration: none;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
  color: var(--ink);
}

.site-nav a[aria-current="page"] {
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 0.35em;
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  padding: 1.5rem 0 2.5rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.68rem;
}

.site-footer p {
  margin: 0;
}

.site-footer a {
  color: var(--muted);
}

.display-controls {
  display: flex;
  gap: 0.8rem;
}

.display-controls button {
  padding: 0;
  border: 0;
  border-bottom: 1px dotted var(--muted);
  background: transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.68rem;
  cursor: pointer;
}

.display-controls button:hover,
.display-controls button[aria-pressed="true"] {
  border-bottom-color: var(--accent);
  color: var(--ink);
}

h1,
h2,
h3,
p {
  overflow-wrap: break-word;
}

h1,
h2,
h3 {
  margin-top: 0;
  color: var(--ink);
  font-family: var(--serif);
}

.lede {
  color: var(--ink);
  font-size: clamp(1.3rem, 2.2vw, 1.55rem);
  line-height: 1.38;
}

.hero {
  padding: clamp(3.5rem, 7vw, 5rem) 0 clamp(3.2rem, 6vw, 4.5rem);
}

.project-kind,
.project-meta,
.teaching-meta,
.project-byline,
.profile-list dt,
.project-details dt,
.artifact-links li span {
  font-family: var(--mono);
}

.hero h1 {
  margin: 0;
  font-size: clamp(2.8rem, 6vw, 4.25rem);
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1;
}

.role-line {
  margin: 0.9rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.hero-copy {
  margin-top: 1.8rem;
}

.hero-copy .lede {
  margin: 0;
}

.hero-copy > p:not(.lede, .hero-links) {
  margin: 1.1rem 0 0;
  color: var(--ink-soft);
}

.hero-links {
  margin: 1.25rem 0 0;
  font-size: 0.9rem;
}

.section-block {
  padding: clamp(2.8rem, 6vw, 4rem) 0;
  border-top: 1px solid var(--rule);
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 1.6rem;
}

.section-heading h2 {
  margin: 0;
  font-size: clamp(1.6rem, 3vw, 2rem);
  letter-spacing: -0.01em;
}

.section-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.section-tail {
  margin: 1.3rem 0 0;
  font-size: 0.9rem;
}

.project-list {
  border-top: 1px solid var(--rule);
}

.project-card {
  display: grid;
  grid-template-columns: 11rem minmax(0, 1fr);
  gap: clamp(1.5rem, 4vw, 3rem);
  padding: 1.7rem 0;
  border-bottom: 1px solid var(--rule);
}

.project-meta {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding-top: 0.15rem;
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.4;
}

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

.status--in-progress { --status-color: var(--status-progress); }
.status--maintained { --status-color: var(--status-maintained); }
.status--paused { --status-color: var(--status-paused); }
.status--completed { --status-color: var(--status-completed); }
.status--retired { --status-color: var(--status-retired); }

.project-copy h3 {
  margin: 0;
  font-size: 1.3rem;
  letter-spacing: -0.015em;
  line-height: 1.2;
}

.project-copy h3 a {
  color: var(--ink);
  text-decoration: none;
}

.project-copy h3 a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.project-copy p {
  margin: 0.55rem 0 0;
  color: var(--ink-soft);
  font-size: 1.04rem;
  line-height: 1.48;
}

.teaching-preview {
}

.teaching-meta {
  margin: 0 0 0.4rem;
  color: var(--muted);
  font-size: 0.68rem;
}

.teaching-preview h3,
.teaching-card h3 {
  margin: 0;
  font-size: 1.3rem;
}

.teaching-preview > p:not(.teaching-meta),
.teaching-card > p:not(.teaching-meta) {
  margin: 0.55rem 0 0.9rem;
  color: var(--ink-soft);
  font-size: 1.04rem;
}

.teaching-preview > a {
  font-size: 0.9rem;
}

.page-hero {
  padding: clamp(3.5rem, 7vw, 5rem) 0 clamp(2.8rem, 5vw, 3.8rem);
}

.page-hero h1 {
  margin: 0;
  font-size: clamp(2.6rem, 5vw, 3.6rem);
  letter-spacing: -0.035em;
  line-height: 1;
}

.page-hero .lede {
  margin: 1.2rem 0 0;
}

.project-groups .project-group:first-child,
.teaching-list {
  border-top: 1px solid var(--rule);
}

.project-groups .project-group:first-child {
  margin-top: 0;
}

.project-group .section-heading {
  margin-bottom: 1rem;
}

.project-page {
}

.project-hero {
  padding: clamp(3.5rem, 7vw, 5rem) 0 clamp(2.8rem, 5vw, 3.8rem);
  border-bottom: 1px solid var(--rule);
}

.project-kind {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.7rem;
}

.project-hero h1 {
  margin: 0;
  font-size: clamp(2.6rem, 5vw, 3.7rem);
  letter-spacing: -0.035em;
  line-height: 1;
}

.project-subtitle {
  margin: 1.4rem 0 0;
  color: var(--ink-soft);
  font-size: clamp(1.25rem, 2.3vw, 1.5rem);
  font-style: italic;
  line-height: 1.4;
}

.project-byline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 1.8rem 0 0;
  color: var(--muted);
  font-size: 0.68rem;
}

.project-prose {
  padding: clamp(3rem, 6vw, 4.5rem) 0;
}

.project-prose section {
  margin: 0 0 3.4rem;
}

.project-prose h2 {
  margin: 0 0 0.8rem;
  font-size: 1.55rem;
  letter-spacing: -0.02em;
}

.project-prose section > p {
  margin: 0 0 1rem;
  color: var(--ink-soft);
  font-size: 1.12rem;
  line-height: 1.58;
}

.project-details dl,
.profile-list {
  margin: 0;
  border-top: 1px solid var(--rule);
}

.project-details dl > div,
.profile-list > div {
  display: grid;
  grid-template-columns: 9rem minmax(0, 1fr);
  gap: 1.5rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--rule);
}

.project-details dt,
.profile-list dt {
  color: var(--muted);
  font-size: 0.67rem;
}

.project-details dd,
.profile-list dd {
  margin: 0;
  color: var(--ink-soft);
}

.artifact-links ul,
.related-links {
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--rule);
  list-style: none;
}

.artifact-links li,
.related-links li {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--rule);
}

.artifact-links li span {
  margin-left: 0.5rem;
  color: var(--muted);
  font-size: 0.65rem;
}

.teaching-card {
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--rule);
}

.teaching-card h3 a {
  color: var(--ink);
  text-decoration: none;
}

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

.about-copy {
  padding: 0 0 clamp(3rem, 6vw, 4.5rem);
}

.about-copy p {
  margin: 0 0 1.2rem;
  color: var(--ink-soft);
  font-size: 1.12rem;
  line-height: 1.58;
}

.about-copy p:first-child {
  color: var(--ink);
  font-size: 1.3rem;
}

.profile-block {
}

.not-found {
  padding: clamp(6rem, 14vw, 10rem) 0;
}

.not-found h1 {
  margin: 0;
  font-size: clamp(2.8rem, 6vw, 4.2rem);
  letter-spacing: -0.04em;
}

.not-found p {
  margin: 1rem 0 1.5rem;
  color: var(--ink-soft);
  font-size: 1.15rem;
}

@media (max-width: 700px) {
  .site-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.9rem;
  }

  .site-nav {
    gap: 1rem;
  }

  .hero {
    padding-top: 4rem;
  }

  .project-card {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.65rem;
  }

  .project-meta {
    align-items: baseline;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.45rem 0.8rem;
  }

}

@media (max-width: 480px) {
  body {
    font-size: 16px;
  }

  .site-shell {
    padding-right: 1.1rem;
    padding-left: 1.1rem;
  }

  .site-nav {
    width: 100%;
    justify-content: space-between;
    gap: 0.5rem;
  }

  .section-heading,
  .site-footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.6rem;
  }

  .project-details dl > div,
  .profile-list > div {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.3rem;
  }

  .project-byline {
    align-items: flex-start;
    flex-direction: column;
  }

  .project-byline > span[aria-hidden="true"] {
    display: none;
  }
}

html[data-readable="true"] body {
  line-height: 1.7;
}

html[data-readable="true"] .hero h1,
html[data-readable="true"] .page-hero h1,
html[data-readable="true"] .project-hero h1,
html[data-readable="true"] .not-found h1,
html[data-readable="true"] .brand-name,
html[data-readable="true"] .section-heading h2,
html[data-readable="true"] .project-copy h3,
html[data-readable="true"] .project-prose h2 {
  letter-spacing: 0;
}

html[data-readable="true"] .hero h1,
html[data-readable="true"] .page-hero h1,
html[data-readable="true"] .project-hero h1,
html[data-readable="true"] .not-found h1 {
  line-height: 1.18;
}

html[data-readable="true"] .lede,
html[data-readable="true"] .project-copy p,
html[data-readable="true"] .teaching-preview > p:not(.teaching-meta),
html[data-readable="true"] .teaching-card > p:not(.teaching-meta),
html[data-readable="true"] .experience-card > p:not(.teaching-meta),
html[data-readable="true"] .project-subtitle,
html[data-readable="true"] .project-prose section > p,
html[data-readable="true"] .about-copy p,
html[data-readable="true"] .not-found p {
  line-height: 1.7;
}

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

@media print {
  :root,
  html[data-theme="dark"] {
    --paper: #fff;
    --ink: #000;
    --ink-soft: #222;
    --muted: #444;
    --rule: #aaa;
    --accent: #000;
    --accent-hover: #000;
    --status-progress: #000;
    --status-maintained: #000;
    --status-paused: #000;
    --status-completed: #000;
    --status-retired: #000;
  }

  @page {
    margin: 1.7cm;
  }

  body {
    background: #fff;
    color: #000;
    font-size: 10.5pt;
  }

  .site-shell {
    width: auto;
    padding: 0;
  }

  .site-nav,
  .display-controls,
  .site-footer {
    display: none;
  }

  .hero,
  .page-hero,
  .project-hero {
    padding: 2rem 0;
  }

  a {
    color: #000;
  }
}

/* Back navigation on subpages. The link floats in the hero's breathing room:
   it takes a modest top margin and the hero that follows drops its large
   top padding, so the two never stack into a dead zone. */
.back-link {
  margin: 1.6rem 0 0;
  font-family: var(--mono);
  font-size: 0.78rem;
}

.back-link + .page-hero,
.back-link + .project-page .project-hero {
  padding-top: clamp(1.2rem, 2.5vw, 1.8rem);
}

.back-link a {
  color: var(--muted);
  text-decoration: none;
}

.back-link a:hover,
.back-link a:focus-visible {
  color: var(--accent);
}

/* Experience entries */
.experience-card + .experience-card {
  margin-top: 1.6rem;
}

.experience-card > p:not(.teaching-meta) {
  margin: 0.55rem 0 0;
  color: var(--ink-soft);
  line-height: 1.55;
}

/* Typst-authored prose fragments */
.project-subtitle p {
  margin: 0;
}

.eqn {
  margin: 1.1rem 0;
  overflow-x: auto;
}
