@font-face {
  font-family: "IBM Plex Serif";
  src: url("/assets/fonts/IBMPlexSerif-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Serif";
  src: url("/assets/fonts/IBMPlexSerif-Medium.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Serif";
  src: url("/assets/fonts/IBMPlexSerif-SemiBold.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}

* {
  box-sizing: border-box;
}

:root {
  color-scheme: light;
  --background: #fff;
  --text: #1f1f1f;
  --muted: #6b6b6b;
  --accent: #3d3d3d;
  --rule: #e6e6e6;
  --soft: #f3f5f9;
  --highlight: #0047ab;
  --warm: #b45309;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --serif: "IBM Plex Serif", Georgia, serif;
  color: var(--text);
  background: var(--background);
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.55;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --background: #1b1c1e;
    --text: #e8e8e8;
    --muted: #a6a6a6;
    --accent: #ddd;
    --rule: #34363a;
    --soft: #25272b;
    --highlight: #7aa7ff;
    --warm: #fbbf24;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --background: #1b1c1e;
  --text: #e8e8e8;
  --muted: #a6a6a6;
  --accent: #ddd;
  --rule: #34363a;
  --soft: #25272b;
  --highlight: #7aa7ff;
  --warm: #fbbf24;
}

body {
  margin: 0;
}

[hidden] {
  display: none !important;
}

a {
  color: var(--highlight);
  text-decoration: none;
  text-underline-offset: 3px;
}

a:hover {
  text-decoration: underline;
}

button {
  font: inherit;
}

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

/* Elements focused by in-page links (such as headings) should not show a focus box. */
[tabindex="-1"]:focus {
  outline: none;
}

h1, h2, h3 {
  margin: 0;
  font-family: var(--mono);
  font-weight: 500;
  letter-spacing: 0;
}

h1 {
  font-size: 34px;
  line-height: 1.2;
}

.skip-link {
  position: absolute;
  top: 0;
  left: 1rem;
  z-index: 10;
  padding: .5rem .75rem;
  background: var(--background);
  transform: translateY(-100%);
}

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

/* Top navigation */

.site-header {
  position: sticky;
  top: 0;
  z-index: 5;
  border-bottom: 1px solid var(--rule);
  background: var(--background);
  font-family: var(--mono);
}

.site-header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 24px;
  max-width: 900px;
  margin: 0 auto;
  padding: 12px 20px;
}

.article-page .site-header-inner, .article-page .site-main {
  max-width: 1140px;
}

.header-social {
  display: flex;
  gap: 12px;
  margin-right: auto;
}

.primary-navigation ul {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  padding: 0;
  margin: 0;
  list-style: none;
  font-size: 14px;
}

.primary-navigation a {
  color: var(--text);
}

.primary-navigation a[aria-current] {
  color: var(--highlight);
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 12px;
}

.icon-link {
  display: inline-flex;
  color: var(--highlight);
}

.icon-link svg {
  width: 20px;
  height: 20px;
}

.icon-link:hover {
  opacity: .7;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.theme-icon-sun, [data-theme="dark"] .theme-icon-moon {
  display: none;
}

[data-theme="dark"] .theme-icon-sun {
  display: block;
  filter: invert(1);
}

.site-main {
  max-width: 900px;
  margin: 0 auto;
  padding: 36px 20px 24px;
}

/* Page headers */

.page-header {
  padding-bottom: 6px;
}

.page-description {
  max-width: 640px;
  margin: 6px 0 0;
  color: var(--muted);
}

.empty-state {
  margin: 18px 0 0;
}

.return-link {
  display: inline-block;
  margin-top: 20px;
  font-family: var(--mono);
  font-size: 13px;
}

/* Homepage */

.about {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 210px;
  gap: 28px;
}

.about-title {
  margin-bottom: 18px;
}

.about-title b {
  font-weight: 600;
}

.about-text p {
  margin: 0 0 12px;
}

.reading-order {
  margin: 0 0 12px;
  padding-left: 22px;
}

.reading-order li {
  margin-bottom: 4px;
}

.about-photo img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
}

.section-heading {
  margin: 34px 0 12px;
  color: var(--warm);
  font-size: 20px;
}

.dated-list {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 14px;
}

.dated-list td {
  padding: 6px 0;
  vertical-align: top;
}

.dated-list td:first-child {
  width: 130px;
  color: var(--muted);
  white-space: nowrap;
}

/* Year and category headings */

.year-heading, .category-heading {
  margin: 24px 0 0;
  border-bottom: 1px solid var(--rule);
  color: var(--muted);
  font-weight: 400;
  text-align: right;
}

.year-heading {
  font-size: 28px;
}

.category-heading {
  margin-bottom: 12px;
  font-size: 22px;
}

/* Publications */

.publication {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 18px;
  padding: 16px 0;
}

.publication-preview {
  position: relative;
}

.publication-badge {
  position: absolute;
  top: -8px;
  left: -6px;
  padding: 2px 8px;
  border-radius: 3px;
  background: var(--highlight);
  color: var(--background);
  font-family: var(--mono);
  font-size: 11px;
}

.publication-preview img, .publication-preview svg,
.post-thumb img, .post-thumb svg {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--soft);
}

.publication-title {
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
}

.publication-author, .publication-venue {
  margin: 2px 0 0;
}

.publication-author b {
  font-weight: 400;
  text-decoration: underline;
  text-underline-offset: 3px;
}

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

.publication-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  font-family: var(--mono);
}

.publication-links button, .publication-links a {
  padding: 2px 10px;
  border: 1px solid var(--highlight);
  border-radius: 3px;
  background: none;
  color: var(--highlight);
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
}

.publication-links button:hover, .publication-links a:hover,
.publication-links button[aria-expanded="true"] {
  background: var(--highlight);
  color: var(--background);
  text-decoration: none;
}

.publication-abstract, .publication-bibtex {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-left: 3px solid var(--highlight);
  background: var(--soft);
  font-size: 14px;
}

.publication-bibtex {
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
}

/* Writing list */

.post-list {
  padding: 0;
  margin: 0;
  list-style: none;
}

.post-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 160px;
  gap: 18px;
  padding: 16px 0;
  border-bottom: 1px solid var(--rule);
}

.post-item h3 {
  margin-bottom: 6px;
  font-size: 19px;
  line-height: 1.35;
}

.post-description {
  margin: 0 0 8px;
}

.post-meta {
  margin: 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12.5px;
}

.keyword-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0;
  margin: 8px 0 0;
  list-style: none;
}

.keyword-list li {
  padding: 0 6px;
  border: 1px solid var(--rule);
  border-radius: 3px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
}

/* Generated artwork for items without an image */

.art-hot {
  fill: var(--warm);
}

.art-dim {
  fill: var(--rule);
}

/* Projects */

.project-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.project-card {
  display: block;
  overflow: hidden;
  border: 1px solid var(--rule);
  border-radius: 6px;
  color: inherit;
  transition: border-color .15s, transform .15s;
}

.project-card:hover {
  border-color: var(--highlight);
  text-decoration: none;
  transform: translateY(-2px);
}

.project-art {
  aspect-ratio: 16 / 9;
  background: var(--soft);
}

.project-art img, .project-art svg {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.project-body {
  padding: 12px 14px 14px;
}

.project-body h3 {
  margin-bottom: 6px;
  font-size: 16px;
}

.project-body p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

/* Footer and back to top */

.site-footer {
  padding: 28px 0 36px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  text-align: center;
}

.back-to-top {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 3;
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
}

.back-to-top a {
  display: inline-block;
  padding: 6px 10px;
  border: 1px solid var(--rule);
  background: var(--background);
  color: var(--text);
}

.back-to-top a:hover {
  border-color: var(--highlight);
  color: var(--highlight);
  text-decoration: none;
}

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

@media (max-width: 700px) {
  .about, .publication, .post-item, .project-grid {
    grid-template-columns: 1fr;
  }
  .about-photo:empty {
    display: none;
  }
  .about-photo {
    max-width: 160px;
  }
  .publication-preview {
    max-width: 200px;
  }
  .post-thumb {
    max-width: 220px;
  }
  .back-to-top {
    right: 16px;
    bottom: 16px;
  }
}

@media (pointer: coarse) {
  .primary-navigation a, .icon-link, .return-link, .back-to-top a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
  .icon-link, .theme-toggle {
    min-width: 44px;
    height: 44px;
    justify-content: center;
  }
}
