:root {
  color-scheme: light dark;
  --background: #ffffff;
  --text: #242421;
  --muted: #70706a;
  --border: #e8e8e4;
  --accent: #075fb8;
  --focus: #005fcc;
  --max-site: 1040px;
  --max-reading: 720px;
  --gutter: clamp(1.25rem, 4vw, 2.5rem);
  --space-xs: 0.45rem;
  --space-sm: 0.75rem;
  --space-md: 1.25rem;
  --space-lg: 2rem;
  --space-xl: clamp(3rem, 8vw, 5.75rem);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: #1b1c1a;
    --text: #e7e4de;
    --muted: #aaa59d;
    --border: #3a3833;
    --accent: #91c2f2;
    --focus: #afd6ff;
  }
}

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

html {
  background: var(--background);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 100%;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--background);
}

::selection {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}

a {
  color: inherit;
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.18em;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 4px;
}

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

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: 0.75rem;
  z-index: 2;
  transform: translateY(-160%);
  padding: 0.4rem 0.6rem;
  background: var(--background);
  border: 1px solid var(--border);
}

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

.site-header,
.site-main,
.site-footer {
  width: min(100% - (var(--gutter) * 2), var(--max-site));
  margin-inline: auto;
}

.site-header {
  padding-block: clamp(1.5rem, 4vw, 2.6rem);
}

@media (min-width: 721px) and (max-height: 820px) {
  .site-header {
    padding-block: clamp(1.25rem, 3vw, 2.2rem);
  }
}

.site-header__inner {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-md);
}

.site-title,
.site-nav a,
.writing-item a {
  text-decoration-line: underline;
  text-decoration-color: transparent;
}

.site-title {
  font-size: 0.98rem;
  font-weight: 560;
  letter-spacing: 0;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: clamp(0.85rem, 2.5vw, 1.45rem);
  font-size: 0.92rem;
}

.site-nav a {
  color: var(--muted);
}

.site-nav a[aria-current="page"] {
  color: var(--text);
  text-decoration-line: none;
  text-decoration-color: transparent;
  text-shadow:
    -0.012em 0 0 currentColor,
    0.012em 0 0 currentColor;
}

.site-nav a:hover,
.site-nav a:focus-visible {
  color: var(--text);
  text-decoration-color: currentColor;
}

.site-title:hover,
.site-title:focus-visible {
  color: var(--text);
  text-decoration-color: currentColor;
}

.intro {
  max-width: 700px;
  padding-block: clamp(2rem, 4vw, 3rem) clamp(2.35rem, 5.3vw, 4.05rem);
}

.intro h1 {
  margin: 0;
  font-size: clamp(1.45rem, 2.6vw, 2.25rem);
  line-height: 1.2;
  font-weight: 500;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.intro__topic {
  color: var(--muted);
}

.intro__about-link {
  text-decoration-color: var(--muted);
}

.intro__about-link:hover,
.intro__about-link:focus-visible {
  color: var(--accent);
  text-decoration-color: currentColor;
}

.writing-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(2.75rem, 9vw, 7rem);
  align-items: start;
}

.writing-list__header {
  margin-bottom: var(--space-lg);
}

.writing-list h2,
.section-header h1,
.article h1,
.page-content h1 {
  margin: 0;
  letter-spacing: 0;
}

.writing-list h2 {
  font-size: clamp(1rem, 1.6vw, 1.12rem);
  line-height: 1.25;
  font-weight: 610;
  overflow-wrap: anywhere;
}

.writing-list ol {
  display: grid;
  gap: clamp(1.35rem, 2.8vw, 1.8rem);
  margin: 0;
  padding: 0;
  list-style: none;
}

.writing-item {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 0.68rem;
  row-gap: 0.28rem;
}

.writing-item a {
  display: inline;
  font-size: clamp(1.04rem, 1.55vw, 1.18rem);
  line-height: 1.3;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.writing-item .topics {
  margin: 0;
}

.writing-item a:hover,
.writing-item a:focus-visible {
  color: var(--text);
  text-decoration-color: currentColor;
}

.topics {
  margin: 0.42rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.more-link {
  margin: var(--space-lg) 0 0;
  font-size: 0.92rem;
}

.more-link a,
.back-link a {
  color: var(--muted);
  text-decoration-line: underline;
  text-decoration-color: var(--muted);
}

.more-link a:hover,
.more-link a:focus-visible,
.back-link a:hover,
.back-link a:focus-visible {
  color: var(--accent);
  text-decoration-color: currentColor;
}

.site-footer {
  padding-block: clamp(3rem, 7vw, 5rem) 2.2rem;
  color: var(--muted);
  font-size: 0.88rem;
}

@media (min-width: 721px) {
  .page-home .site-footer {
    padding-block: clamp(1.9rem, 4vw, 3.25rem) 1.4rem;
  }
}

.site-footer p {
  margin: 0;
}

.site-footer a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-color: var(--muted);
}

.site-footer a:hover,
.site-footer a:focus-visible {
  color: var(--accent);
  text-decoration-color: currentColor;
}

.page-content,
.article {
  max-width: var(--max-reading);
  padding-top: clamp(2rem, 4vw, 3rem);
}

.page-content {
  font-size: clamp(1.05rem, 1.7vw, 1.15rem);
  line-height: 1.72;
  overflow-wrap: anywhere;
}

.page-content > :last-child {
  margin-bottom: 0;
}

.page-content > h3 {
  font-size: 1.12em;
}

.page-content > h4 {
  font-size: 1em;
}

.section-header {
  margin-bottom: clamp(1.75rem, 4vw, 2.75rem);
}

.section-header h1,
.page-content h1 {
  font-size: clamp(1.65rem, 3vw, 2.35rem);
  line-height: 1.18;
  font-weight: 560;
  overflow-wrap: anywhere;
}

.section-header p {
  max-width: 34rem;
  margin: 0.8rem 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.55;
}

.section-header .archive-filter-sentence {
  max-width: none;
}

.archive-filter[hidden],
[data-filter-year-group][hidden],
[data-filter-item][hidden] {
  display: none;
}

.archive-filter__option {
  display: inline-block;
  white-space: nowrap;
}

.archive-filter button {
  min-height: 1.5rem;
  padding: 0;
  border: 0;
  color: var(--muted);
  background: transparent;
  font: inherit;
  line-height: inherit;
  text-align: left;
  cursor: pointer;
}

.archive-filter__name {
  text-decoration-line: none;
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.18em;
}

.archive-filter button:focus-visible {
  color: var(--text);
  outline: 2px solid var(--focus);
  outline-offset: 0.14em;
  border-radius: 0.08rem;
}

.archive-filter button[aria-pressed="true"] {
  color: var(--text);
}

.archive-filter button[aria-pressed="true"] .archive-filter__name {
  text-decoration-line: none;
  text-shadow:
    -0.012em 0 0 currentColor,
    0.012em 0 0 currentColor;
}

.archive-filter button[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

.archive-filter__count {
  margin-left: 0.12em;
  color: var(--muted);
  font-size: 0.78em;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  text-decoration: none;
}

.archive-filter button:focus-visible .archive-filter__count,
.archive-filter button[aria-pressed="true"] .archive-filter__count {
  color: currentColor;
}

@media (hover: hover) and (pointer: fine) {
  .archive-filter button:not([disabled]):hover,
  .archive-filter button:not([disabled]):hover .archive-filter__count {
    color: var(--text);
  }
}

.archive-filter__colon,
.archive-filter__separator,
.archive-filter__terminator {
  color: var(--muted);
}

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

.article-header {
  margin-bottom: clamp(1.5rem, 3.5vw, 2.25rem);
}

.article h1 {
  font-size: clamp(1.9rem, 4.2vw, 3.2rem);
  line-height: 1.1;
  font-weight: 540;
  overflow-wrap: anywhere;
}

.article-metadata {
  margin: 0.42rem 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.article-metadata__topics {
  display: inline;
}

.article-metadata__topics + time {
  display: block;
  margin-top: 0.22rem;
}

.lead-image {
  margin: clamp(1.5rem, 3.5vw, 2.25rem) 0 0;
}

.lead-image figcaption {
  margin-top: 0.6rem;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.prose {
  font-size: clamp(1.05rem, 1.7vw, 1.15rem);
  line-height: 1.72;
  overflow-wrap: anywhere;
}

.prose > * {
  margin-block: 0;
}

.prose > * + * {
  margin-top: 1.25em;
}

.prose h2,
.prose h3,
.prose h4 {
  line-height: 1.25;
  font-weight: 610;
  margin-top: 2.2em;
}

.prose h2 {
  font-size: 1.35rem;
}

.prose h3 {
  font-size: 1.12rem;
}

.prose h4 {
  font-size: 1rem;
}

.prose a,
.page-content > p a,
.page-content > ul a,
.page-content > ol a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-color: var(--accent);
}

.prose a:hover,
.prose a:focus-visible,
.page-content > p a:hover,
.page-content > p a:focus-visible,
.page-content > ul a:hover,
.page-content > ul a:focus-visible,
.page-content > ol a:hover,
.page-content > ol a:focus-visible {
  color: var(--accent);
  text-decoration-color: currentColor;
}

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

.prose hr {
  height: 1px;
  margin-block: 2.2em;
  border: 0;
  background: var(--border);
}

.prose ul,
.page-content ul {
  padding-left: 1.25rem;
}

.prose ol,
.page-content ol {
  padding-left: 1.55rem;
}

/* Archive lists are navigation, not prose: keep their Trailing alignment flush. */
.writing-list ol {
  padding-left: 0;
}

.prose li::marker,
.page-content li::marker {
  color: var(--muted);
}

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

.prose dl {
  margin-block: 1.25em 0;
}

.prose dt {
  font-weight: 610;
}

.prose dd + dt {
  margin-top: 1em;
}

.prose dd {
  margin: 0.25rem 0 0.85rem 1.25rem;
  color: var(--muted);
}

.prose code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
}

.prose :not(pre) > code {
  padding: 0.08em 0.28em;
  border: 1px solid var(--border);
}

.prose sup {
  line-height: 0;
}

.prose sup a {
  text-decoration-thickness: 0.06em;
}

.prose pre {
  overflow-x: auto;
  overflow-wrap: normal;
  padding: 1rem;
  border: 1px solid var(--border);
}

.prose pre code {
  padding: 0;
  border: 0;
}

.prose table {
  display: block;
  width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  font-size: 0.92em;
}

.prose th,
.prose td {
  min-width: 9rem;
  padding: 0.62rem 0.75rem;
  border: 0;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.prose th {
  background: color-mix(in srgb, var(--border) 24%, transparent);
  color: var(--text);
  font-weight: 610;
}

.prose tr:last-child td {
  border-bottom: 0;
}

.prose th code,
.prose td code {
  overflow-wrap: normal;
  white-space: nowrap;
}

.prose figure {
  margin-inline: 0;
}

.prose p > img,
.prose figure img {
  width: 100%;
  height: auto;
}

.prose figcaption,
.prose .footnotes {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.5;
}

.prose figcaption {
  margin-top: 0.6rem;
}

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

.prose .reversefootnote {
  margin-left: 0.2em;
}

.prose .task-list {
  padding-left: 0;
  list-style: none;
}

.prose .task-list-item {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
}

.prose .task-list-item-checkbox {
  flex: 0 0 auto;
  margin: 0;
  accent-color: var(--accent);
  opacity: 1;
  transform: translateY(0.08em);
}

.prose .task-list-item-checkbox:disabled {
  opacity: 1;
}

.prose details {
  padding-block: 0.75rem;
  border-block: 1px solid var(--border);
}

.prose summary {
  cursor: pointer;
  font-weight: 610;
}

.prose details > * + * {
  margin-top: 0.85rem;
}

.back-link {
  margin: clamp(2.25rem, 6vw, 4rem) 0 0;
  font-size: 0.94rem;
}

.article-sequence {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 1rem 1.5rem;
  align-items: start;
  margin-top: clamp(2.5rem, 5vw, 3.5rem);
}

.compound-directional-link {
  display: block;
  min-width: 0;
  min-height: 24px;
  color: var(--muted);
  text-decoration: none;
  overflow-wrap: anywhere;
}

.compound-directional-link:hover,
.compound-directional-link:focus-visible {
  color: var(--accent);
}

.compound-directional-link--previous {
  grid-column: 1;
}

.compound-directional-link--next {
  grid-column: 3;
  text-align: right;
}

.compound-directional-link__label,
.compound-directional-link__title {
  display: block;
}

.compound-directional-link__label {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.compound-directional-link__title {
  margin-top: 0.18rem;
  color: var(--text);
  font-size: clamp(1.04rem, 1.55vw, 1.18rem);
  font-weight: 500;
  line-height: 1.3;
  text-decoration: underline;
  text-decoration-color: var(--muted);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.18em;
}

.compound-directional-link:hover .compound-directional-link__label,
.compound-directional-link:focus-visible .compound-directional-link__label,
.compound-directional-link:hover .compound-directional-link__title,
.compound-directional-link:focus-visible .compound-directional-link__title {
  color: var(--accent);
  text-decoration-color: currentColor;
}

.article-sequence__parent {
  grid-column: 2;
  justify-self: center;
  text-align: center;
}

.year-archive__group + .year-archive__group {
  margin-top: var(--space-lg);
}

.writing-list .year-archive__year {
  margin: 0 0 0.85rem;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 500;
  line-height: 1.45;
  letter-spacing: 0;
}

.empty-state {
  margin: 0;
  color: var(--muted);
}

@media (max-width: 720px) {
  .site-header__inner {
    display: grid;
    gap: 0.85rem;
  }

  .site-nav {
    justify-content: flex-start;
  }

  .intro {
    padding-block: 2rem 3rem;
  }

  .writing-grid {
    grid-template-columns: 1fr;
    gap: 3rem;
  }

  .writing-item {
    display: block;
  }

  .writing-item .topics {
    margin-top: 0.2rem;
  }

  .article-sequence {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .compound-directional-link--next {
    text-align: left;
  }

  .compound-directional-link--previous,
  .compound-directional-link--next,
  .article-sequence__parent {
    grid-column: 1;
  }

  .article-sequence__parent {
    justify-self: start;
    text-align: left;
  }

}

@media (max-height: 480px) and (orientation: landscape) {
  .site-header {
    padding-block: 1rem;
  }

  .site-header__inner {
    gap: 0.65rem;
  }

  .article {
    padding-top: 1.5rem;
  }

  .lead-image {
    margin-top: 1.5rem;
  }

  .section-header .archive-filter-sentence {
    font-size: 0.9rem;
    line-height: 1.5;
  }

  .site-footer {
    padding-block: 2.25rem 1.4rem;
    font-size: 0.82rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media print {
  :root {
    --background: #ffffff;
    --text: #000000;
    --muted: #444444;
    --border: #d6d6d6;
  }

  .site-header,
  .site-footer,
  .back-link,
  .article-sequence {
    display: none;
  }

  .site-main,
  .article,
  .page-content {
    width: 100%;
    max-width: none;
    padding: 0;
  }

  a {
    color: inherit;
  }
}
