/* ==========================================================================
   Tokens
   ========================================================================== */

:root {
  --paper: #faf9f6;
  --ink: #1b1a17;
  --muted: #6b6b64;
  --rule: #e6e3dc;
  --accent: #8a3324;

  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --measure: 38rem;
  --gutter: clamp(1.25rem, 6vw, 5rem);
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0e0d0b;
    --ink: #e9e7e1;
    --muted: #8f8d85;
    --rule: #232220;
    --accent: #d08066;
  }
}

/* ==========================================================================
   Reset & base
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.15rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.wrap {
  max-width: calc(var(--measure) + var(--gutter) * 2);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* ==========================================================================
   Header & nav
   ========================================================================== */

.site-header {
  border-bottom: 1px solid var(--rule);
}

.site-header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  padding-top: 2rem;
  padding-bottom: 1.5rem;
}

.site-title {
  font-family: var(--mono);
  font-size: 1rem;
  color: var(--ink);
  text-decoration: none;
}

.site-title .crumb {
  color: var(--muted);
}

.site-header-right {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 1.25rem;
}

.site-nav,
.lang-filter {
  display: flex;
  gap: 1rem;
  font-family: var(--mono);
  font-size: 0.9rem;
}

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

.site-nav a:hover,
.site-nav a.active,
.lang-filter a:hover,
.lang-filter a.active {
  color: var(--ink);
}

.lang-filter {
  gap: 0.5rem;
}

.lang-filter a::after {
  content: "";
}

.lang-filter a:not(:last-child)::after {
  content: "/";
  margin-left: 0.5rem;
  color: var(--rule);
}

/* ==========================================================================
   Footer
   ========================================================================== */

.site-footer {
  border-top: 1px solid var(--rule);
  margin-top: 2rem;
}

.site-footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 1rem;
  max-width: 56rem;
  padding: 1.5rem var(--gutter);
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--muted);
}

.footer-lead {
  color: var(--ink);
}

.footer-links {
  display: flex;
}

.footer-links a {
  color: var(--muted);
  text-decoration: none;
}

.footer-links a:not(:last-child)::after {
  content: "\00b7";
  margin: 0 0.6em;
  color: var(--rule);
}

.footer-links a:hover {
  color: var(--ink);
}

/* ==========================================================================
   Prose
   ========================================================================== */

.content {
  padding-top: 3rem;
  padding-bottom: 1.5rem;
}

.page > *:first-child,
.post > *:first-child,
.paper > *:first-child {
  margin-top: 0;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.25;
  margin: 2em 0 0.5em;
}

h1 { font-size: 1.9rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }
h4, h5, h6 { font-size: 1rem; }

p, ul, ol, dl, blockquote, table, pre, figure {
  margin: 0 0 1.3em;
}

ul, ol {
  padding-left: 1.4em;
}

li + li {
  margin-top: 0.35em;
}

a {
  color: var(--ink);
  text-decoration-line: underline;
  text-decoration-color: var(--rule);
  text-underline-offset: 3px;
}

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

strong {
  font-weight: 700;
}

hr {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 2.5em 0;
}

abbr[title] {
  border-bottom: 1px dotted var(--muted);
  cursor: help;
}

blockquote {
  margin-left: 0;
  padding-left: 1.1em;
  border-left: 2px solid var(--rule);
  color: var(--muted);
  font-style: italic;
}

blockquote p:last-child {
  margin-bottom: 0;
}

img {
  max-width: 100%;
}

.image {
  text-align: center;
  font-size: 0.85em;
  font-style: italic;
}

.image figcaption {
  color: var(--muted);
  margin-top: 0.5em;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95em;
}

th, td {
  text-align: left;
  padding: 0.5em 0.75em;
  border-bottom: 1px solid var(--rule);
}

th {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 0.85em;
}

code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--rule);
  padding: 0.15em 0.35em;
  border-radius: 3px;
}

pre {
  overflow-x: auto;
  padding: 1em 1.2em;
  background: var(--rule);
  border-radius: 4px;
  margin-bottom: 1.3em;
}

pre code {
  background: none;
  padding: 0;
  font-size: 0.85em;
}

.section-label {
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.05em;
  text-transform: lowercase;
  border: none;
  margin: 2.2em 0 1em;
}

.roles {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  margin: 0 0 1.3em;
}

.role {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.role strong {
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 600;
}

.role strong a {
  color: var(--ink);
  text-decoration: none;
}

.role strong a:hover {
  text-decoration-line: underline;
  text-decoration-color: var(--accent);
}

.role span {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--muted);
}

.role .now {
  font-weight: 500;
  font-size: 0.7rem;
  color: var(--accent);
  letter-spacing: 0.03em;
  text-transform: lowercase;
}

/* ==========================================================================
   Home timeline
   ========================================================================== */

.timeline-year {
  margin-bottom: 2.5rem;
}

.timeline-year-label {
  font-family: var(--mono);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.05em;
  margin: 0 0 0.9rem;
  border: none;
}

.timeline-year-items {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.timeline-item {
  display: flex;
  align-items: baseline;
  gap: 1rem;
}

.timeline-more {
  margin-top: 1.3em;
}

.timeline-more a {
  font-family: var(--mono);
  font-size: 0.85rem;
}

.timeline-date {
  flex: 0 0 auto;
  width: 4.5em;
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--muted);
}

.timeline-title {
  font-family: var(--serif);
}

/* ==========================================================================
   Post
   ========================================================================== */

.post-header {
  margin-bottom: 2rem;
}

.post-title {
  margin: 0 0 0.4em;
}

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

.related {
  margin-top: 3.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--rule);
}

.related-title {
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.05em;
  margin: 0 0 1em;
}

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

.related-date {
  font-family: var(--mono);
  font-size: 0.8em;
  color: var(--muted);
}

.toc {
  display: none;
}

@media (min-width: 87.5rem) {
  .toc.has-items {
    display: block;
    position: fixed;
    top: 9rem;
    right: 3rem;
    width: 12rem;
    max-height: 70vh;
    overflow-y: auto;
    padding-left: 1rem;
    border-left: 1px solid var(--rule);
  }
}

.toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55em;
}

.toc a {
  display: block;
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--muted);
  text-decoration: none;
}

.toc .toc-h3 {
  padding-left: 0.9em;
}

.toc a:hover,
.toc a.active {
  color: var(--ink);
}

/* ==========================================================================
   Paper
   ========================================================================== */

.paper-header {
  margin-bottom: 2rem;
}

.paper-title {
  margin: 0 0 0.4em;
}

.paper-meta {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--muted);
  font-style: normal;
  margin: 0 0 0.6em;
}

.paper-pdf {
  margin: 0;
}

.paper-footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
}

.paper-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-family: var(--mono);
  font-size: 0.9rem;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 640px) {
  body {
    font-size: 1.05rem;
  }

  .site-header-inner {
    padding-top: 1.5rem;
  }

  .timeline-item {
    flex-direction: column;
    gap: 0.15rem;
  }

  .timeline-date {
    width: auto;
  }
}
