/* Theme tokens and baseline typography */
:root {
  color-scheme: light dark;
  --font-body: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino,
    "Times New Roman", Georgia, serif;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --page-max-width: 45rem;
  --header-max-width: 62rem;
  --space-2xs: 0.25rem;
  --space-xs: 0.5rem;
  --space-sm: 0.875rem;
  --space-md: 1.25rem;
  --space-lg: 2rem;
  --space-xl: 3.5rem;
  --space-2xl: 5rem;
  --radius-sm: 0.4rem;
  --border-width: 1px;
  --background: #f6f3ec;
  --surface: rgba(255, 255, 255, 0.6);
  --text: #161616;
  --muted: #555147;
  --subtle: #767061;
  --border: #d6cfbf;
  --border-strong: #9d9484;
  --link: #1d3958;
  --link-hover: #17314d;
  --focus: #8a4a00;
  --link-underline: #889bb2;
  --selection: rgba(29, 57, 88, 0.2);
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: #101113;
    --surface: rgba(28, 30, 33, 0.84);
    --text: #ede8dc;
    --muted: #c8c0b0;
    --subtle: #a79f90;
    --border: #33373b;
    --border-strong: #646a73;
    --link: #bed5f1;
    --link-hover: #d7e6fb;
    --focus: #ffd27f;
    --link-underline: #94adca;
    --selection: rgba(185, 210, 240, 0.24);
  }
}

:root[data-theme="light"] {
  color-scheme: light;
  --background: #f6f3ec;
  --surface: rgba(255, 255, 255, 0.6);
  --text: #161616;
  --muted: #555147;
  --subtle: #767061;
  --border: #d6cfbf;
  --border-strong: #9d9484;
  --link: #1d3958;
  --link-hover: #17314d;
  --focus: #8a4a00;
  --link-underline: #889bb2;
  --selection: rgba(29, 57, 88, 0.2);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --background: #101113;
  --surface: rgba(28, 30, 33, 0.84);
  --text: #ede8dc;
  --muted: #c8c0b0;
  --subtle: #a79f90;
  --border: #33373b;
  --border-strong: #646a73;
  --link: #bed5f1;
  --link-hover: #d7e6fb;
  --focus: #ffd27f;
  --link-underline: #94adca;
  --selection: rgba(185, 210, 240, 0.24);
}

html {
  scroll-behavior: smooth;
}

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

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.72;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--selection);
}

.site-shell {
  width: min(calc(100% - 2rem), var(--page-max-width));
  margin: 0 auto;
}

.site-header .site-shell,
.site-footer .site-shell {
  width: min(calc(100% - 2rem), var(--header-max-width));
}

.skip-link {
  position: absolute;
  top: var(--space-sm);
  left: var(--space-sm);
  padding: 0.65rem 0.9rem;
  border: var(--border-width) solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--background);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 0.95rem;
  text-decoration: none;
  transform: translateY(-180%);
}

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

.site-header {
  padding: 2.4rem 0 1.1rem;
  border-bottom: var(--border-width) solid var(--border);
}

.masthead {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.eyebrow {
  margin: 0 0 var(--space-2xs);
  color: var(--subtle);
  font-family: var(--font-ui);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  color: var(--text);
  font-weight: 600;
  line-height: 1.2;
}

h1 {
  font-size: clamp(2rem, 4vw, 3rem);
  letter-spacing: -0.02em;
}

.subtitle {
  max-width: 34rem;
  margin: var(--space-xs) 0 0;
  color: var(--muted);
  font-size: 1rem;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 1rem;
  padding-top: var(--space-sm);
  border-top: var(--border-width) solid var(--border);
}

.site-nav a,
a {
  color: var(--link);
  text-decoration-line: underline;
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.18em;
}

.site-nav a {
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.95rem;
  text-decoration-color: var(--border-strong);
}

a:hover {
  color: var(--link-hover);
  text-decoration-thickness: 0.12em;
}

a:focus-visible,
button:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  text-decoration: none;
}

.theme-toggle {
  flex-shrink: 0;
  padding: 0.65rem 0.9rem;
  border: var(--border-width) solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 0.92rem;
  line-height: 1;
  cursor: pointer;
}

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

main {
  padding: 4rem 0 var(--space-2xl);
}

.section + .section {
  margin-top: 5.5rem;
}

.section {
  scroll-margin-top: 1.25rem;
}

.section-heading {
  margin-bottom: var(--space-md);
}

.section-heading p,
.intro p,
.entry p,
.site-footer p {
  margin: 0;
  color: var(--muted);
}

.section-heading p,
.intro p {
  max-width: 42rem;
}

h2 {
  margin-bottom: var(--space-xs);
  font-size: clamp(1.45rem, 2.4vw, 1.85rem);
  letter-spacing: -0.01em;
}

.intro p + p {
  margin-top: var(--space-md);
}

.intro p:first-of-type {
  color: var(--text);
  font-size: 1.08rem;
}

.entry-list,
.topic-list,
.contact-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.entry-list {
  border-top: var(--border-width) solid var(--border);
}

.entry {
  padding: var(--space-md) 0;
  border-bottom: var(--border-width) solid var(--border);
}

.entry h3,
.entry h4 {
  font-size: 1.12rem;
  margin-bottom: var(--space-xs);
}

.entry h4 {
  font-size: 1.02rem;
}

.entry a {
  color: var(--text);
  text-decoration-color: var(--link-underline);
}

.entry a:hover {
  color: var(--link);
}

.entry p {
  max-width: 42rem;
  font-size: 0.98rem;
}

.essay-list .entry {
  padding: 1.1rem 0 1.25rem;
}

.essay-list .entry h3 {
  font-size: 1.24rem;
  letter-spacing: -0.01em;
}

.essay-list .entry p {
  max-width: 36rem;
}

.article-list .entry h3 {
  font-size: 1.07rem;
}

.split-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-xl);
}

.split-columns > div > h3 {
  margin-bottom: var(--space-sm);
  font-size: 0.95rem;
  color: var(--subtle);
  font-family: var(--font-ui);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.compact .entry {
  padding: var(--space-sm) 0 var(--space-md);
}

.topic-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 var(--space-lg);
  border-top: var(--border-width) solid var(--border);
}

.topic-list li {
  padding: 0.85rem 0;
  border-bottom: var(--border-width) solid var(--border);
}

.contact-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.2rem;
  padding-top: var(--space-xs);
}

.contact-list a {
  font-family: var(--font-ui);
}

.site-footer {
  padding: 1rem 0 var(--space-xl);
  border-top: var(--border-width) solid var(--border);
  color: var(--subtle);
  font-family: var(--font-ui);
  font-size: 0.92rem;
}

@media (max-width: 48rem) {
  body {
    font-size: 1rem;
  }

  .split-columns,
  .topic-list {
    grid-template-columns: 1fr;
  }

  .masthead {
    display: grid;
  }

  .theme-toggle {
    justify-self: start;
  }
}

@media (max-width: 34rem) {
  .site-header {
    padding-top: 1.15rem;
  }

  .site-shell,
  .site-header .site-shell,
  .site-footer .site-shell {
    width: min(calc(100% - 1.25rem), var(--page-max-width));
  }

  .site-nav {
    gap: 0.45rem 0.85rem;
  }
}
