/* Tokens. Light by default, dark from the system setting or the theme button. */
:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --border: #d9dce3;
  --text: #1b1d26;
  --text-secondary: #4a4f5e;
  --text-muted: #646978;
  --accent: #a3530a;
  --font-body: "Literata", Georgia, serif;
  --font-head: "Schibsted Grotesk", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1d26;
    --surface: #232631;
    --border: #363a48;
    --text: #eceef3;
    --text-secondary: #b9bdca;
    --text-muted: #9499a8;
    --accent: #ffb86c;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #1b1d26;
  --surface: #232631;
  --border: #363a48;
  --text: #eceef3;
  --text-secondary: #b9bdca;
  --text-muted: #9499a8;
  --accent: #ffb86c;
  color-scheme: dark;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 17px/1.6 var(--font-body);
}

h1, h2, h3 {
  margin: 0;
  font-family: var(--font-head);
  font-weight: 700;
  text-wrap: balance;
}

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

/* Post images have transparent backgrounds and dark marks, so they need a light ground in both themes. */
.prose img { background: #ffffff; }

a {
  color: var(--accent);
  text-underline-offset: 3px;
}

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

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

.skip-link {
  position: absolute;
  left: -999px;
  top: 12px;
  z-index: 10;
  padding: 8px 12px;
  background: var(--surface);
}

.skip-link:focus { left: 12px; }

/* Page frame */
.site {
  display: flex;
  flex-direction: column;
  gap: 64px;
  width: 100%;
  max-width: calc(720px + 48px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 0 24px 56px;
}

.site-home { max-width: calc(920px + 48px); }
.site-wide { max-width: calc(1040px + 48px); }

main {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 64px;
  min-width: 0;
}

/* Header */
.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 20px;
  padding-top: 20px;
  font: 500 15px/1.3 var(--font-head);
}

.mark {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-right: auto;
  color: var(--text);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.07em;
  text-decoration: none;
}

.mark span { color: var(--accent); }

.site-header nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 20px;
}

.site-header nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--text-secondary);
  text-decoration: none;
}

.site-header nav a:hover { color: var(--text); text-decoration: underline; }

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

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
}

.theme-toggle:hover { color: var(--text); }

/* Hero */
.hero {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding-top: 32px;
}

.hero h1 {
  font-size: clamp(48px, 9vw, 92px);
  line-height: 0.98;
  letter-spacing: -0.035em;
}

.hero-page h1 { font-size: clamp(44px, 8vw, 80px); }

.intro {
  max-width: 34em;
  font-size: clamp(20px, 2.4vw, 24px);
  line-height: 1.42;
}

.secondary { color: var(--text-secondary); }
.about {
  max-width: 38em;
  color: var(--text-secondary);
  font-size: 19px;
  font-optical-sizing: none;
  line-height: 1.5;
}

/* Home sections */
.row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 32px;
}

.row-label {
  flex: 1 1 130px;
  color: var(--text-muted);
  font: 500 13px/1.8 var(--font-mono);
  letter-spacing: 0.03em;
}

.row-body {
  display: flex;
  flex: 999 1 520px;
  flex-direction: column;
  align-items: flex-start;
  gap: 18px;
  min-width: 0;
}

.entries {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.entries li {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.entries a:first-child {
  font: 700 18px/1.3 var(--font-head);
}

.entries span {
  max-width: 40em;
  color: var(--text-secondary);
}

.plain {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.selected span { color: var(--text-muted); }

.more,
.more-links {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

.more { color: var(--text-secondary); }
.more-links { gap: 20px; margin-top: -10px; }
.row-body > .more { margin-top: -10px; }

.career {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  margin: 0;
}

.career div {
  display: flex;
  flex-wrap: wrap;
  gap: 0 20px;
}

.career dt {
  flex: 0 0 150px;
  font-weight: 600;
}

.career dd {
  flex: 1 1 280px;
  min-width: 0;
  margin: 0;
  color: var(--text-secondary);
}

.numbers {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 28px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.numbers-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 20px;
}

.numbers-head h2 { font-size: 22px; line-height: 1.2; }

.numbers-head a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

.numbers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 18px 24px;
}

.numbers-grid div {
  display: flex;
  flex-direction: column;
}

.numbers-grid strong {
  font: 700 44px/1.05 var(--font-head);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.numbers-grid span {
  color: var(--text-secondary);
  font-size: 15px;
}

/* Footer */
.site-footer {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

/* Year in Review */
.ledger-section,
.recaps-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ledger-section h2,
.recaps-section h2 {
  font-size: 24px;
  line-height: 1.2;
}

.table-scroll {
  overflow-x: auto;
  border-block: 1px solid var(--border);
}

.ledger {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: 15px;
  line-height: 1.3;
}

.ledger th,
.ledger td {
  padding: 11px 12px;
  text-align: left;
  white-space: nowrap;
}

.ledger th:first-child { padding-left: 0; }
.ledger tbody th { font-weight: 600; }
.ledger tbody tr { border-top: 1px solid var(--border); }

.ledger thead th {
  color: var(--text-muted);
  font: 500 13px/1.3 var(--font-mono);
}

.ledger .num {
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.ledger td.num { color: var(--text-secondary); font-size: 14px; }
.ledger td.latest { color: var(--text); font-weight: 500; }
.ledger td.empty { color: var(--text-muted); }
.ledger .trend { padding: 6px 0 6px 16px; }
.ledger svg { display: block; overflow: visible; }
.spark-line { stroke: var(--text-secondary); }
.spark-end { fill: var(--accent); stroke: var(--bg); }

.note {
  color: var(--text-muted);
  font: 400 13px/1.5 var(--font-mono);
}

.recaps-section { gap: 24px; }

.recaps {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 40px 36px;
}

.recap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  scroll-margin-top: 16px;
}

.recap h3 {
  color: var(--accent);
  font-size: 40px;
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.recap p {
  color: var(--text-secondary);
  font-size: 16px;
  line-height: 1.45;
}

.recap ul {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin: 4px 0 0;
  padding: 0;
  font-size: 15.5px;
  line-height: 1.45;
  list-style: none;
}

/* Inner pages and posts */
.prose { min-width: 0; }
.prose > * { margin-block: 0 1.1em; }
.prose > :last-child { margin-bottom: 0; }

.prose h1 {
  margin-top: 16px;
  font-size: clamp(36px, 6vw, 52px);
  line-height: 1.05;
  letter-spacing: -0.025em;
}

.prose h2 {
  margin-top: 1.8em;
  font-size: 28px;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.prose h3 {
  margin-top: 1.5em;
  font-size: 21px;
  line-height: 1.25;
}

.prose li + li { margin-top: 0.3em; }
.prose strong { font-weight: 600; }

.prose code {
  font: 400 0.86em var(--font-mono);
  overflow-wrap: anywhere;
}

.prose pre {
  overflow-x: auto;
  padding: 14px 16px;
  font: 400 14px/1.55 var(--font-mono);
}

.prose pre code {
  font: inherit;
  overflow-wrap: normal;
}

.prose .highlight { margin-block: 0 1.1em; }
.prose .highlight pre { margin: 0; }

.prose pre:not(.chroma) {
  background: var(--surface);
  border: 1px solid var(--border);
}

/* Work, Projects and Talks: a name on the first line, details below it. */
.page ul {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 0;
  list-style: none;
}

.page li { margin: 0; color: var(--text-secondary); }

.page li > a:first-child,
.page li > strong:first-child {
  font: 700 18px/1.5 var(--font-head);
}

.page li > strong:first-child { color: var(--text); }

.post-header { margin-bottom: 2em; }
.post-header h1 { margin-bottom: 12px; }

.post-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0;
  list-style: none;
}

.post-list li {
  display: flex;
  flex-wrap: wrap;
  gap: 0 20px;
  margin: 0;
}

.post-list time {
  flex: 0 0 80px;
  color: var(--text-muted);
  font: 400 14px/1.8 var(--font-mono);
}

.post-list a { flex: 1 1 280px; min-width: 0; }

@media (max-width: 560px) {
  body { font-size: 16px; }
  .site { padding-inline: 16px; gap: 48px; }
  .site-header { flex-wrap: nowrap; gap: 8px; }
  .site-header nav { flex-wrap: nowrap; gap: 0 14px; white-space: nowrap; }
  .theme-toggle { flex: none; }
  main { gap: 48px; }
  .hero { padding-top: 16px; }
  .about { font-size: 18px; }
  .numbers { padding: 20px; }
}
