:root {
  --color-bg: #f5f1e8;
  --color-text: #222;
  --color-text-muted: #5a5a5a;
  --color-rule: #ddd6c7;
  --font-serif: "Newsreader", Georgia, "Times New Roman", serif;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 100%;
}

body {
  font-family: var(--font-serif);
  font-optical-sizing: auto;
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 1.1875rem;
  line-height: 1.75;
  max-width: 68ch;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  font-weight: 400;
}

p {
  margin: 0 0 1.4em;
}

h1, h2, h3 {
  font-family: var(--font-serif);
  font-optical-sizing: auto;
  font-weight: 600;
  text-wrap: balance;
  color: var(--color-text);
  margin: 1.75em 0 0.6em;
}

h1:first-child, h2:first-child, h3:first-child {
  margin-top: 0;
}

h1 {
  font-size: 3rem;
  line-height: 1.1;
  letter-spacing: -0.01em;
}

h2 {
  font-size: 2.25rem;
  line-height: 1.2;
  letter-spacing: -0.005em;
}

h3 {
  font-size: 1.5rem;
  line-height: 1.3;
}

/* Scale desktop-fixed heading sizes down for narrow viewports */
@media (max-width: 40em) {
  h1 {
    font-size: 2.125rem;
  }

  h2 {
    font-size: 1.75rem;
  }

  h3 {
    font-size: 1.3rem;
  }
}

a {
  color: var(--color-text);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}

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

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  margin-bottom: 2.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--color-rule);
}

.site-header nav a {
  margin-left: 1.25rem;
  text-decoration: none;
  font-size: 1rem;
}

.site-header nav a:first-child {
  margin-left: 0;
}

.site-title {
  font-weight: 600;
  font-size: 1.25rem;
  text-decoration: none;
  color: var(--color-text);
}

.site-footer {
  margin-top: 3.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--color-rule);
  font-size: 0.9375rem;
  color: var(--color-text-muted);
}

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

.post-list li {
  margin-bottom: 1.4em;
}

.post-list a {
  font-size: 1.25rem;
}

.post-date {
  font-size: 0.9375rem;
  color: var(--color-text-muted);
  margin: 0.15em 0 0;
}

.home-emblem {
  margin: 3.5rem 0 0;
}

.home-emblem img {
  display: block;
  width: 100%;
  max-width: 5rem;
  height: auto;
  margin: 0 auto;
}

.site-title {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.site-mark {
  width: auto;
  height: 1.75rem;
  flex: none;
}

/* Data tables (e.g. library/hospitals) — wrapper scrolls sideways on narrow screens
   instead of widening the page */
.table-wrap {
  overflow-x: auto;
  margin: 0 0 2em;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 1rem;
  line-height: 1.45;
}

.data-table th,
.data-table td {
  text-align: left;
  vertical-align: top;
  padding: 0.6em 0.75em 0.6em 0;
  border-bottom: 1px solid var(--color-rule);
}

.data-table th {
  font-weight: 600;
  border-bottom-width: 2px;
}

.data-table td:last-child {
  white-space: nowrap;
}

.fn-ref {
  font-size: 0.7em;
  line-height: 0;
  margin-left: 0.1em;
}

.fn-ref a {
  text-decoration: none;
}

.footnotes-heading {
  font-size: 1.25rem;
}

.footnotes {
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--color-text-muted);
  padding-left: 1.5em;
}

.footnotes li {
  margin-bottom: 0.6em;
}

.fn-back {
  text-decoration: none;
}

:target {
  scroll-margin-top: 1rem;
}

.footnotes li:target {
  color: var(--color-text);
}

/* Responsive 16:9 video (YouTube iframes ship with fixed 560×315) */
.video-embed {
  margin: 2.5rem 0;
}

.video-embed iframe {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  border: 0;
}
