:root {
  color-scheme: light;
  --bg: #f5f0e6;
  --bg-soft: #f9f5ee;
  --text: #1f1b17;
  --muted: #5d544b;
  --accent: #765640;
  --line: rgba(31, 27, 23, 0.14);
  --line-strong: rgba(31, 27, 23, 0.26);
  --header-bg: rgba(245, 240, 230, 0.86);
  --header-line: rgba(31, 27, 23, 0.08);
  --selection-bg: rgba(118, 86, 64, 0.18);
  --body-wash: rgba(255, 255, 255, 0.55);
  --body-glow: rgba(118, 86, 64, 0.08);
  --detail-link-line: rgba(31, 27, 23, 0.22);
  --tag-dot: rgba(118, 86, 64, 0.7);
  --toggle-bg: rgba(31, 27, 23, 0.04);
  --toggle-bg-hover: rgba(31, 27, 23, 0.08);
  --max-width: 1040px;
  --header-height: 72px;
  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", serif;
  --sans: "Instrument Sans", "Avenir Next", "Segoe UI", sans-serif;
  --copy-size: 1rem;
  --meta-size: 0.9rem;
  --micro-size: 0.78rem;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #15110f;
  --bg-soft: #211a16;
  --text: #f4efe7;
  --muted: #bcb0a2;
  --accent: #d7a46f;
  --line: rgba(244, 239, 231, 0.15);
  --line-strong: rgba(244, 239, 231, 0.3);
  --header-bg: rgba(21, 17, 15, 0.86);
  --header-line: rgba(244, 239, 231, 0.1);
  --selection-bg: rgba(215, 164, 111, 0.26);
  --body-wash: rgba(255, 246, 232, 0.055);
  --body-glow: rgba(215, 164, 111, 0.11);
  --detail-link-line: rgba(244, 239, 231, 0.24);
  --tag-dot: rgba(215, 164, 111, 0.78);
  --toggle-bg: rgba(244, 239, 231, 0.07);
  --toggle-bg-hover: rgba(244, 239, 231, 0.12);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --bg: #15110f;
    --bg-soft: #211a16;
    --text: #f4efe7;
    --muted: #bcb0a2;
    --accent: #d7a46f;
    --line: rgba(244, 239, 231, 0.15);
    --line-strong: rgba(244, 239, 231, 0.3);
    --header-bg: rgba(21, 17, 15, 0.86);
    --header-line: rgba(244, 239, 231, 0.1);
    --selection-bg: rgba(215, 164, 111, 0.26);
    --body-wash: rgba(255, 246, 232, 0.055);
    --body-glow: rgba(215, 164, 111, 0.11);
    --detail-link-line: rgba(244, 239, 231, 0.24);
    --tag-dot: rgba(215, 164, 111, 0.78);
    --toggle-bg: rgba(244, 239, 231, 0.07);
    --toggle-bg-hover: rgba(244, 239, 231, 0.12);
  }
}

* {
  box-sizing: border-box;
}

html {
  scroll-padding-top: calc(var(--header-height) + 28px);
}

body {
  margin: 0;
  background:
    linear-gradient(to bottom, var(--body-wash), transparent 16rem),
    radial-gradient(circle at top left, var(--body-glow), transparent 24rem),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: var(--copy-size);
  line-height: 1.68;
  text-rendering: optimizeLegibility;
}

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

a {
  color: inherit;
  text-decoration: none;
}

p,
li,
dd,
dt,
span,
a {
  font-size: var(--copy-size);
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.03;
}

h1 {
  max-width: 14ch;
  font-size: clamp(2.15rem, 4.1vw, 3.35rem);
}

h2 {
  font-size: clamp(1.32rem, 2.1vw, 1.78rem);
}

h3 {
  font-size: clamp(1.12rem, 1.55vw, 1.35rem);
}

.site-header,
.page-shell,
.site-footer {
  padding-inline: clamp(1.25rem, 3vw, 2rem);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: var(--header-height);
  backdrop-filter: blur(16px);
  background: var(--header-bg);
  border-bottom: 1px solid var(--header-line);
}

.site-header-inner {
  max-width: calc(var(--max-width) + 4rem);
  min-height: var(--header-height);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  font-size: var(--meta-size);
  font-weight: 600;
  letter-spacing: 0.03em;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  overflow-x: auto;
  scrollbar-width: none;
}

.site-nav::-webkit-scrollbar {
  display: none;
}

.site-nav a,
.brand {
  position: relative;
}

.site-nav a {
  color: var(--muted);
  font-size: var(--meta-size);
  transition: color 180ms ease;
}

.site-nav a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -0.32rem;
  height: 1px;
  transform: scaleX(0);
  transform-origin: left;
  background: currentColor;
  transition: transform 180ms ease;
}

.site-nav a:hover,
.site-nav a.is-active,
.site-nav a[data-active="true"] {
  color: var(--text);
}

.site-nav a:hover::after,
.site-nav a.is-active::after,
.site-nav a[data-active="true"]::after {
  transform: scaleX(1);
}

.theme-toggle {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 2.35rem;
  height: 2.35rem;
  margin-left: 0.1rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--toggle-bg);
  color: var(--text);
  cursor: pointer;
  transition:
    background-color 180ms ease,
    border-color 180ms ease,
    transform 180ms ease;
}

.theme-toggle:hover {
  background: var(--toggle-bg-hover);
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

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

.theme-toggle svg {
  width: 1rem;
  height: 1rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.theme-toggle .theme-icon-light,
[data-theme="dark"] .theme-toggle .theme-icon-dark {
  display: none;
}

[data-theme="dark"] .theme-toggle .theme-icon-light {
  display: block;
}

.menu-toggle {
  display: none;
  place-items: center;
  width: 2.35rem;
  height: 2.35rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--toggle-bg);
  color: var(--text);
  cursor: pointer;
  transition:
    background-color 180ms ease,
    border-color 180ms ease,
    transform 180ms ease;
}

.menu-toggle:hover {
  background: var(--toggle-bg-hover);
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.menu-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.menu-toggle span {
  grid-area: 1 / 1;
  width: 0.95rem;
  height: 1.5px;
  border-radius: 999px;
  background: currentColor;
  transition:
    transform 180ms ease,
    opacity 180ms ease;
}

.menu-toggle span:nth-child(1) {
  transform: translateY(-0.32rem);
}

.menu-toggle span:nth-child(3) {
  transform: translateY(0.32rem);
}

.menu-toggle[aria-expanded="true"] span:nth-child(1) {
  transform: rotate(45deg);
}

.menu-toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}

.menu-toggle[aria-expanded="true"] span:nth-child(3) {
  transform: rotate(-45deg);
}

.page-shell,
.site-footer {
  max-width: calc(var(--max-width) + 4rem);
  margin: 0 auto;
}

.page-shell {
  padding-top: 1rem;
  padding-bottom: 4rem;
}

.home-shell {
  padding-top: 1.6rem;
}

.page-section {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 1.35rem 2.75rem;
  padding: 1.8rem 0;
  border-top: 1px solid var(--line);
}

.page-section:first-child {
  border-top: 0;
  padding-top: 1.1rem;
}

.intro-section {
  padding-top: 1.25rem;
}

.section-label p {
  position: sticky;
  top: calc(var(--header-height) + 1.6rem);
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: var(--micro-size);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

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

.intro-copy,
.section-intro,
.entry-body p,
.entry-meta p,
.entry-meta span,
.site-footer p,
.site-footer a,
.note-list li,
.intro-details dd,
.intro-details dt {
  color: var(--muted);
}

.intro-copy,
.section-intro {
  max-width: 40rem;
  font-size: 1.05rem;
}

.intro-copy + .intro-copy {
  margin-top: 1rem;
}

.intro-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.1rem 2rem;
  margin: 1.8rem 0 0;
  padding: 1.2rem 0 0;
  border-top: 1px solid var(--line);
}

.intro-details dt {
  margin: 0 0 0.3rem;
  font-size: var(--micro-size);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.intro-details dd {
  margin: 0;
  max-width: 24rem;
}

.intro-details a {
  border-bottom: 1px solid var(--detail-link-line);
}

.note-list {
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}

.note-list li {
  max-width: 42rem;
  padding: 0.8rem 0;
  border-top: 1px solid var(--line);
}

.note-list li:last-child {
  border-bottom: 1px solid var(--line);
}

.entry-list {
  display: grid;
}

.entry {
  display: grid;
  grid-template-columns: minmax(150px, 0.24fr) minmax(0, 1fr);
  gap: 1rem 1.75rem;
  padding: 1.15rem 0;
  border-top: 1px solid var(--line);
  transition: transform 180ms ease;
}

.entry:first-child {
  padding-top: 0;
  border-top: 0;
}

.entry:hover {
  transform: translateX(4px);
}

.entry-meta p,
.entry-meta span {
  margin: 0;
  font-size: var(--meta-size);
}

.entry-meta span {
  display: block;
  margin-top: 0.18rem;
}

.entry-subtitle {
  margin: 0.15rem 0 0;
}

.entry-body p {
  max-width: 42rem;
  margin: 0.55rem 0 0;
}

.entry-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 1rem;
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}

.entry-tags li {
  position: relative;
  padding-left: 0.8rem;
  color: var(--muted);
  font-size: var(--meta-size);
}

.entry-tags li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.72rem;
  width: 0.26rem;
  height: 0.26rem;
  border-radius: 50%;
  background: var(--tag-dot);
}

.site-footer {
  padding-top: 1.35rem;
  padding-bottom: 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-top: 1px solid var(--line);
}

.site-footer p,
.site-footer a {
  margin: 0;
  font-size: var(--meta-size);
}

.site-footer div {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.reveal {
  opacity: 1;
  transform: none;
}

.has-motion .reveal {
  animation: reveal-in 540ms ease both;
  animation-delay: var(--reveal-delay, 0ms);
}

@keyframes reveal-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

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

@media (prefers-reduced-motion: reduce) {
  .site-nav a,
  .site-nav a::after,
  .theme-toggle,
  .entry,
  .reveal {
    transition: none;
  }

  .has-motion .reveal {
    animation: none;
  }
}

@media (max-width: 900px) {
  :root {
    --header-height: 64px;
  }

  .site-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .site-header-inner {
    display: grid;
    grid-template-columns: minmax(2.35rem, 1fr) auto minmax(2.35rem, 1fr);
    align-items: center;
    gap: 0.75rem;
  }

  .brand {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .site-nav {
    justify-self: center;
  }

  .theme-toggle {
    justify-self: end;
    margin-left: 0;
  }

  .menu-toggle {
    justify-self: end;
  }

  .page-section,
  .entry {
    grid-template-columns: 1fr;
  }

  .section-label p {
    position: static;
    margin-top: 0;
  }
}

@media (max-width: 430px) {
  .site-header-inner {
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 0.55rem;
  }

  .brand {
    color: var(--text);
    min-width: 0;
  }

  .site-nav {
    position: absolute;
    top: calc(100% + 0.35rem);
    right: 1rem;
    display: grid;
    gap: 0;
    min-width: 8.6rem;
    padding: 0.25rem;
    overflow: visible;
    border: 1px solid var(--line);
    border-radius: 0.85rem;
    background: var(--bg-soft);
    box-shadow: 0 18px 48px var(--shadow);
    opacity: 0;
    pointer-events: none;
    transform: translateY(-0.35rem);
    transition:
      opacity 180ms ease,
      transform 180ms ease;
  }

  .site-nav[data-open="true"] {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
  }

  .site-nav a {
    padding: 0.48rem 0.65rem;
    color: var(--text);
    border-radius: 0.55rem;
    font-size: var(--meta-size);
    line-height: 1.2;
  }

  .site-nav a:hover,
  .site-nav a.is-active,
  .site-nav a[data-active="true"] {
    background: var(--toggle-bg-hover);
  }

  .site-nav a::after {
    display: none;
  }

  .menu-toggle {
    display: inline-grid;
  }
}

@media (max-width: 680px) {
  h1 {
    max-width: 100%;
  }

  .intro-details {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .site-nav {
    gap: 0.8rem;
  }

  .page-shell,
  .site-footer,
  .site-header {
    padding-inline: 1rem;
  }
}
