@font-face {
  font-family: "Literata";
  src: url("/assets/fonts/literata-variable.woff2") format("woff2");
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
}

@font-face {
  font-family: "Literata";
  src: url("/assets/fonts/literata-italic-variable.woff2") format("woff2");
  font-style: italic;
  font-weight: 200 900;
  font-display: swap;
}

/* Palette derived from the homepage cover: sage-teal ink wash, terracotta figure. */
:root {
  color-scheme: light;
  --measure: 40rem;
  --color-primary: #212620;
  --color-text: #212620;
  --color-subtext: #5d675b;
  --color-border: #c8d1c0;
  --color-code-bg: #e3e8d9;
  --color-bg: #eef1e8;
  --color-hover: #41686d;
  --color-focus: #212620;
  --color-accent: #a5513f;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --color-primary: #e9ece1;
    --color-text: #e9ece1;
    --color-subtext: #a4ad9d;
    --color-border: #4b544a;
    --color-code-bg: #262c24;
    --color-bg: #1b201a;
    --color-hover: #93bcc0;
    --color-focus: #e9ece1;
    --color-accent: #c9836b;
  }
}

[data-theme="dark"] {
  color-scheme: dark;
  --color-primary: #e9ece1;
  --color-text: #e9ece1;
  --color-subtext: #a4ad9d;
  --color-border: #4b544a;
  --color-code-bg: #262c24;
  --color-bg: #1b201a;
  --color-hover: #93bcc0;
  --color-focus: #e9ece1;
  --color-accent: #c9836b;
}

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

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

body {
  min-height: 100vh;
  margin: 0;
  color: var(--color-text);
  background: var(--color-bg);
  font-family: "Literata", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-size: 1.1875rem;
  font-optical-sizing: auto;
  font-synthesis: none;
  line-height: 1.65;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

::selection {
  color: var(--color-text);
  background: var(--color-border);
}

h1, h2, h3, h4, h5, h6 {
  color: var(--color-primary);
  font-weight: 600;
  line-height: 1.2;
}

h1 { font-size: 2.5rem; }
h2 { margin: 2.5em 0 0.5em; font-size: 1.9rem; }
h3 { margin: 1.75em 0 0.7em; font-size: 1.45rem; }
h4 { margin: 1.5em 0 0.5em; font-size: 1.1875rem; }
p { margin: 0 0 1em; }

a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-color: var(--color-border);
  text-decoration-thickness: 0.06em;
  text-underline-offset: 0.16em;
}

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

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 3px;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

iframe { max-width: 100%; }

hr {
  width: 100%;
  margin: 2.5rem 0;
  border: 0;
  border-top: 1px solid var(--color-border);
}

time { color: var(--color-subtext); }

code,
pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

code {
  padding: 0.08em 0.25em;
  border-radius: 0.18em;
  background: var(--color-code-bg);
  font-size: 0.82em;
}

pre {
  margin: 1.75em 0;
  padding: 0.75rem 1rem;
  overflow: auto;
  border-radius: 0.2rem;
  background: var(--color-code-bg);
  font-size: 0.78em;
  line-height: 1.55;
}

pre code {
  padding: 0;
  background: transparent;
  font-size: inherit;
}

blockquote {
  margin: 2.5rem 0;
  padding: 0.25rem 0 0.25rem 1.5rem;
  border-left: 2px solid var(--color-border);
  color: var(--color-text);
  font-size: 0.92em;
  line-height: 1.5;
}

blockquote > :last-child { margin-bottom: 0; }
ul, ol { padding-left: 1.6em; }
li { margin-bottom: 0.35em; }

nav {
  margin-bottom: 1.5rem;
  background: var(--color-bg);
}

.nav-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: var(--measure);
  margin: 0 auto;
  padding: 1.9rem 0 0.75rem;
}

.nav-container > a {
  color: var(--color-primary);
  font-size: 1.25rem;
  font-weight: 400;
  text-decoration: none;
}

main { padding: 0 1.25rem 6rem; }

main > article,
.home-wrapper,
.page-body {
  max-width: var(--measure);
  margin-right: auto;
  margin-left: auto;
}

footer {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 0 2rem;
  color: var(--color-subtext);
  font-size: 0.9rem;
}

#theme-toggle {
  display: grid;
  width: 2rem;
  height: 2rem;
  flex: 0 0 auto;
  padding: 0;
  border: 0;
  background: none;
  color: var(--color-subtext);
  cursor: pointer;
  place-items: center;
}

#theme-toggle::before {
  width: 1rem;
  height: 1rem;
  border: 1px solid currentColor;
  border-radius: 50%;
  background: linear-gradient(90deg, currentColor 50%, transparent 50%);
  content: "";
}

[data-theme="dark"] #theme-toggle::before {
  background: linear-gradient(270deg, currentColor 50%, transparent 50%);
}

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

.home-wrapper { padding-top: 0.5rem; }

.home-cover {
  width: min(100%, 34rem);
  margin: 0 auto 1.25rem;
}

.social-links {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin: 0 0 3rem;
  padding: 0;
  color: var(--color-subtext);
  font-size: 0.9rem;
  list-style: none;
}

.year-divider {
  margin: 3rem 0 1.5rem;
  color: var(--color-accent);
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.note-entry { margin-bottom: 2rem; }

.note-entry h3 {
  margin: 0 0 0.25rem;
  font-size: 1.3rem;
  font-weight: 600;
  line-height: 1.25;
}

.note-entry .note-description {
  margin: 0 0 0.25rem;
  color: var(--color-subtext);
  font-size: 1rem;
  line-height: 1.45;
}

.note-entry time {
  display: block;
  font-size: 0.85rem;
  line-height: 1.4;
}

.note-header { margin: 2rem 0 3rem; }

.note-header h1 {
  margin: 0 0 0.1em;
  font-size: clamp(2.8rem, 5vw, 3.6rem);
  font-weight: 700;
  line-height: 1.1;
}

.note-header .note-description {
  margin: 0;
  color: var(--color-text);
  font-size: 1.3rem;
  line-height: 1.45;
}

.note-date {
  display: block;
  margin-top: 0.5rem;
  font-size: 1rem;
  line-height: 1.5;
}

.article-body h2,
.article-body h3,
.article-body h4 { scroll-margin-top: 6rem; }
.article-body img { margin: 2.5rem auto; }

.article-body .footnotes {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
  color: var(--color-subtext);
  font-size: 0.85em;
  line-height: 1.5;
}

.article-body .footnotes > hr { display: none; }

.article-body sup {
  font-size: 0.68em;
  line-height: 0;
}

.not-found { padding-top: 2rem; }

/* Breakpoint stays a literal (custom properties don't work in media queries):
   keep it roughly --measure + 6rem of side-margin slack. */
@media (max-width: 46rem) {
  nav {
    position: sticky;
    z-index: 10;
    top: 0;
    margin-bottom: 1.25rem;
  }

  .nav-container { padding: 1rem 1.25rem 0.75rem; }

  main {
    padding-right: 1.25rem;
    padding-bottom: 4.5rem;
    padding-left: 1.25rem;
  }

  footer {
    padding-right: 1.25rem;
    padding-left: 1.25rem;
  }

  .home-cover { width: 100%; }
  .note-header { margin-top: 1.25rem; }
  .note-header h1 { font-size: 2.8rem; }

  blockquote {
    margin: 2rem 0;
    padding-left: 1.1em;
    font-size: 0.88em;
  }
}
