:root {
  color-scheme: light;
  --paper: #f7f4ed;
  --ink: #161616;
  --muted: #616161;
  --rule: rgba(22, 22, 22, 0.18);
  --rule-strong: rgba(22, 22, 22, 0.32);
  --accent: #7e2f2f;
  --surface: #fffdf8;
  --shadow: 0 1rem 2.2rem rgba(0, 0, 0, 0.09);
  --focus-ring: rgba(22, 22, 22, 0.32);
  --max: 72rem;
  --measure: 42rem;
  --wide-measure: 48rem;
  --font: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --mono: "SFMono-Regular", "SF Mono", "Menlo", monospace;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #111315;
  --ink: #f1ece1;
  --muted: #aea79b;
  --rule: rgba(241, 236, 225, 0.16);
  --rule-strong: rgba(241, 236, 225, 0.28);
  --accent: #d8a08a;
  --surface: #1a1d20;
  --shadow: 0 1rem 2.6rem rgba(0, 0, 0, 0.38);
  --focus-ring: rgba(241, 236, 225, 0.36);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --paper: #111315;
    --ink: #f1ece1;
    --muted: #aea79b;
    --rule: rgba(241, 236, 225, 0.16);
    --rule-strong: rgba(241, 236, 225, 0.28);
    --accent: #d8a08a;
    --surface: #1a1d20;
    --shadow: 0 1rem 2.6rem rgba(0, 0, 0, 0.38);
    --focus-ring: rgba(241, 236, 225, 0.36);
  }
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.75;
  text-rendering: optimizeLegibility;
  transition: background-color 180ms ease, color 180ms ease;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color 180ms ease;
}

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

.site-header,
.site-footer,
.front-page,
.home-notes,
.latest-strip,
.archive-strip,
.page-shell,
.report-shell {
  width: min(calc(100% - 2rem), var(--max));
  margin: 0 auto;
}

.site-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0 0.8rem;
}

.wordmark,
.site-nav,
.kicker,
.section-label,
.latest-date,
.archive-list span,
.site-footer {
  font-family: var(--font);
}

.wordmark {
  display: block;
  font-size: 1.08rem;
  letter-spacing: 0.06em;
  line-height: 1.08;
  text-transform: uppercase;
}

.theme-toggle {
  appearance: none;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  display: grid;
  flex: 0 0 auto;
  height: 2.6rem;
  margin-left: auto;
  padding: 0;
  place-items: center;
  position: relative;
  width: 2.6rem;
  transition:
    background-color 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease,
    color 180ms ease,
    transform 180ms ease;
}

.theme-toggle:hover {
  border-color: var(--rule-strong);
  color: var(--accent);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.theme-icon {
  fill: none;
  height: 1.1rem;
  pointer-events: none;
  position: absolute;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
  transition: opacity 180ms ease, transform 180ms ease;
  width: 1.1rem;
}

.theme-icon-sun {
  opacity: 0;
  transform: scale(0.72) rotate(-24deg);
}

:root[data-theme="dark"] .theme-icon-sun {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

:root[data-theme="dark"] .theme-icon-moon {
  opacity: 0;
  transform: scale(0.72) rotate(18deg);
}

.sr-only {
  border: 0;
  clip: rect(0, 0, 0, 0);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

.site-nav {
  display: flex;
  gap: 1rem;
  font-size: 0.92rem;
}

.site-nav a,
.lede-links a,
.section-head a,
.archive-list a,
.prose a {
  position: relative;
}

.site-nav a::after,
.lede-links a::after,
.section-head a::after,
.archive-list a::after,
.prose a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -0.08em;
  width: 100%;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 180ms ease;
}

.site-nav a:hover::after,
.lede-links a:hover::after,
.section-head a:hover::after,
.archive-list a:hover::after,
.prose a:hover::after {
  transform: scaleX(1);
}

.front-page {
  padding: 2rem 0 2.8rem;
}

.front-lede {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(18rem, 0.92fr);
  gap: 1.6rem;
  align-items: end;
}

.front-copy {
  width: min(100%, var(--wide-measure));
}

.kicker,
.section-label,
.latest-date,
.archive-list span,
.site-footer,
.report-meta dt {
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.front-copy h1,
.report-head h1,
.page-head h1 {
  font-weight: 400;
  line-height: 0.96;
  letter-spacing: -0.04em;
  margin: 0;
}

.front-copy h1 {
  font-size: clamp(2.8rem, 5.3vw, 4.4rem);
  margin-top: 0.6rem;
  max-width: 11ch;
}

.front-summary,
.page-intro {
  width: min(100%, 28rem);
  font-size: 1rem;
  color: var(--muted);
  margin: 0.9rem 0 0;
}

.lede-report {
  padding: 1.1rem 0 0;
  border-top: 1px solid var(--ink);
}

.lede-date {
  margin: 0.25rem 0 0;
  font-family: var(--font);
  font-size: 0.9rem;
  color: var(--muted);
}

.lede-report h2 {
  margin: 0.5rem 0 0;
  font-size: clamp(2rem, 3.4vw, 3.2rem);
  font-weight: 400;
  line-height: 1.02;
}

.lede-summary {
  margin: 0.8rem 0 0;
  font-size: 1rem;
  color: var(--ink);
}

.lede-excerpt {
  margin: 0.8rem 0 0;
  color: var(--muted);
  font-size: 0.97rem;
}

.lede-links {
  display: flex;
  gap: 1.2rem;
  flex-wrap: wrap;
  margin-top: 1.1rem;
  font-family: var(--font);
}

.latest-strip,
.archive-strip,
.page-shell,
.article-index-shell,
.report-shell {
  border-top: 1px solid var(--rule);
  padding: 1.4rem 0 2.8rem;
}

.latest-grid,
.section-head {
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(0, 1.2fr) minmax(14rem, 0.8fr);
  align-items: start;
}

.latest-grid h2,
.archive-list a,
.page-head h1,
.report-head h1 {
  font-size: clamp(1.8rem, 3vw, 3rem);
}

.latest-grid h2 {
  margin: 0.3rem 0 0;
  font-weight: 400;
  line-height: 1.05;
}

.latest-summary {
  max-width: 24rem;
  margin: 0;
  color: var(--muted);
}

.archive-list {
  list-style: none;
  padding: 0;
  margin: 1.4rem 0 0;
}

.archive-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(14rem, 22rem) 4rem;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--rule);
  align-items: start;
}

.archive-list li > div {
  display: grid;
  gap: 0.25rem;
}

.archive-list p {
  margin: 0;
  color: var(--muted);
}

.archive-read {
  font-family: var(--font);
  font-size: 0.92rem;
  white-space: nowrap;
}

.article-index-shell {
  padding: 1rem 0 2.8rem;
}

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

.article-index li {
  display: block;
  padding: 1rem 0;
}

.article-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.45rem;
}

.article-date {
  font-family: var(--font);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.article-author {
  font-size: 0.8rem;
  color: var(--muted);
}

.article-author::before {
  content: "·";
  margin-right: 0.45rem;
  color: var(--rule-strong);
}

.article-main {
  min-width: 0;
}

.article-title {
  display: inline-block;
  font-size: clamp(1.5rem, 2.3vw, 2.2rem);
  line-height: 1.06;
  font-weight: 400;
}

.article-summary {
  margin: 0.45rem 0 0;
  max-width: 42rem;
  color: var(--muted);
}

.page-head,
.report-head {
  width: min(100%, var(--measure));
}

.report-meta-row {
  display: flex;
  align-items: center;
  gap: 0.62rem;
  flex-wrap: wrap;
  margin-top: 0.72rem;
}

.report-published {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.report-author {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.report-author::before {
  content: "·";
  margin-right: 0.62rem;
  color: var(--rule-strong);
}

.report-dek {
  margin: 0.7rem 0 0;
  max-width: 34rem;
  color: var(--muted);
}

.report-body,
.page-body {
  width: min(100%, var(--measure));
  margin-top: 2.4rem;
}

.prose > :first-child {
  margin-top: 0;
}

.prose h2,
.prose h3 {
  font-family: var(--font);
  font-size: 1rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 2.6rem;
}

.prose p,
.prose li,
.prose blockquote {
  font-size: 1.12rem;
}

.prose :not(pre) > code {
  background: color-mix(in srgb, var(--surface) 76%, transparent);
  border-bottom: 1px solid var(--rule);
  border-radius: 0.3rem;
  color: inherit;
  font-family: inherit;
  font-size: 0.94em;
  letter-spacing: 0.01em;
  padding: 0.04em 0.24em 0.08em;
}

.prose ul,
.prose ol {
  padding-left: 1.2rem;
}

.prose blockquote {
  margin: 1.5rem 0;
  padding-left: 1rem;
  border-left: 2px solid var(--rule);
  color: var(--muted);
}

.prose hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 2rem 0;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font);
  font-size: 0.95rem;
}

.prose th,
.prose td {
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  vertical-align: top;
}

.prose sup {
  font-family: var(--font);
  line-height: 0;
}

.prose .footnotes {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
}

.prose .footnotes ol {
  padding-left: 1rem;
}

.prose .footnote-popover-anchor sup {
  line-height: 0;
  font-size: 1em;
  vertical-align: baseline;
}

.prose a.footnote {
  display: inline;
  margin-left: 0.08em;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.72rem;
  line-height: 1;
  vertical-align: baseline;
  font-variant-numeric: tabular-nums;
  text-decoration: none;
  text-indent: 0;
  overflow: visible;
  white-space: normal;
  width: auto;
  height: auto;
  box-shadow: none;
  border-radius: 0;
}

.prose a.footnote::after {
  content: none;
}

.prose a.footnote:hover,
.prose a.footnote:focus-visible,
.prose .footnote-popover-anchor.is-open a.footnote {
  color: var(--ink);
}

.prose a.footnote:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.prose .footnote-popover-anchor {
  position: relative;
  display: inline-flex;
  line-height: 0;
  vertical-align: super;
}

.prose .footnote-popover {
  --footnote-popover-gap: 0.26rem;
  --footnote-popover-arrow-outer: 0.26rem;
  --footnote-popover-arrow-inner: 0.22rem;
  --footnote-trigger-height: 0.72rem;
  position: absolute;
  left: 50%;
  top: calc(var(--footnote-trigger-height) + var(--footnote-popover-gap));
  transform: translateX(-50%) translateY(-0.08rem);
  width: min(28rem, calc(100vw - 2rem));
  min-width: 15rem;
  padding: 0.6rem 0.9rem 0.8rem;
  border: 1px solid var(--rule);
  border-radius: 0.9rem;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 120ms ease, transform 120ms ease;
  z-index: 30;
  font-size: 0.98rem;
  line-height: 1.55;
}

.prose .footnote-popover p:last-child {
  margin-bottom: 0;
}

.prose .footnote-popover > :first-child {
  margin-top: 0;
}

.prose .footnote-popover .reversefootnote {
  display: none;
}

.prose .footnote-popover::before,
.prose .footnote-popover::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.prose .footnote-popover::before {
  top: calc(-1 * var(--footnote-popover-arrow-outer));
  border-width: 0 0.42rem var(--footnote-popover-arrow-outer) 0.42rem;
  border-style: solid;
  border-color: transparent transparent var(--rule) transparent;
}

.prose .footnote-popover::after {
  top: calc(-1 * var(--footnote-popover-arrow-inner));
  border-width: 0 0.38rem var(--footnote-popover-arrow-inner) 0.38rem;
  border-style: solid;
  border-color: transparent transparent var(--surface) transparent;
}

.prose .footnote-popover-anchor.is-open .footnote-popover {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.site-footer {
  padding: 0 0 2rem;
}

.reveal-1,
.reveal-2,
.reveal-3,
.reveal-4 {
  opacity: 0;
  transform: translateY(10px);
  animation: rise 520ms ease forwards;
}

.reveal-2 {
  animation-delay: 90ms;
}

.reveal-3 {
  animation-delay: 180ms;
}

.reveal-4 {
  animation-delay: 270ms;
}

@keyframes rise {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

  .reveal-1,
  .reveal-2,
  .reveal-3,
  .reveal-4 {
    animation: none;
    opacity: 1;
    transform: none;
  }

  .site-nav a::after,
  .lede-links a::after,
  .section-head a::after,
  .archive-list a::after,
  .prose a::after,
  body,
  a,
  .theme-toggle,
  .theme-icon,
  .prose .footnote-popover {
    transition: none;
  }
}

@media (max-width: 820px) {
  .front-lede,
  .latest-grid,
  .section-head,
  .archive-list li {
    grid-template-columns: 1fr;
  }

  .front-page {
    padding-top: 1.2rem;
  }

  .front-copy h1 {
    max-width: none;
  }

  .archive-list li {
    gap: 0.35rem;
  }

  .article-index li {
    grid-template-columns: 1fr;
    gap: 0.3rem;
  }

  .archive-list span,
  .archive-read {
    margin-top: 0.2rem;
  }

  .prose p,
  .prose li,
  .prose blockquote {
    font-size: 1.02rem;
  }

  .prose .footnote-popover {
    position: fixed;
    left: 1rem;
    right: 1rem;
    top: auto;
    bottom: 1rem;
    width: auto;
    min-width: 0;
    max-width: none;
    transform: translateY(0.5rem);
  }

  .prose .footnote-popover::before,
  .prose .footnote-popover::after {
    display: none;
  }

  .prose .footnote-popover-anchor.is-open .footnote-popover {
    transform: translateY(0);
  }
}
