:root {
  color-scheme: dark;
  --bg: #090d0b;
  --bg-soft: #101711;
  --ink: #f7f0df;
  --muted: #b9af99;
  --faint: rgba(247, 240, 223, 0.12);
  --line: rgba(247, 240, 223, 0.2);
  --accent: #ff6842;
  --accent-ink: #11140f;
  --green: #9bbf84;
  --blue: #7fb1bd;
  --header-bg: rgba(9, 13, 11, 0.76);
  --body-wash: linear-gradient(180deg, rgba(9, 13, 11, 0.98), rgba(9, 13, 11, 1));
  --grid-x: repeating-linear-gradient(90deg, rgba(247, 240, 223, 0.032) 0 1px, transparent 1px 80px);
  --grid-y: repeating-linear-gradient(180deg, rgba(247, 240, 223, 0.025) 0 1px, transparent 1px 80px);
  --scanline: rgba(247, 240, 223, 0.08);
  --warm-trace: rgba(255, 104, 66, 0.1);
  --texture-opacity: 0.13;
  --texture-blend: screen;
  --hero-wash-a: rgba(9, 13, 11, 0.95);
  --hero-wash-b: rgba(9, 13, 11, 0.7);
  --hero-wash-c: rgba(9, 13, 11, 0.22);
  --hero-wash-d: rgba(9, 13, 11, 0.86);
  --canvas-line: 247, 240, 223;
  --canvas-node: 247, 240, 223;
  --canvas-hot: 255, 104, 66;
  --theme-mark: #f7f0df;
  --theme-glow: rgba(255, 104, 66, 0.42);
  --max: 1180px;
  --gutter: 20px;
  --header-height: 72px;
  --scroll-depth: 0;
  --serif: Georgia, "Times New Roman", serif;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f5efe4;
  --bg-soft: #e9dfcf;
  --ink: #171b16;
  --muted: #636b60;
  --faint: rgba(23, 27, 22, 0.11);
  --line: rgba(23, 27, 22, 0.2);
  --accent: #b84327;
  --accent-ink: #fffaf1;
  --green: #497956;
  --blue: #3c7180;
  --header-bg: rgba(245, 239, 228, 0.82);
  --body-wash: linear-gradient(180deg, rgba(245, 239, 228, 0.98), rgba(238, 229, 216, 1));
  --grid-x: repeating-linear-gradient(90deg, rgba(23, 27, 22, 0.04) 0 1px, transparent 1px 80px);
  --grid-y: repeating-linear-gradient(180deg, rgba(23, 27, 22, 0.035) 0 1px, transparent 1px 80px);
  --scanline: rgba(23, 27, 22, 0.055);
  --warm-trace: rgba(184, 67, 39, 0.06);
  --texture-opacity: 0.18;
  --texture-blend: multiply;
  --hero-wash-a: rgba(245, 239, 228, 0.97);
  --hero-wash-b: rgba(245, 239, 228, 0.76);
  --hero-wash-c: rgba(245, 239, 228, 0.24);
  --hero-wash-d: rgba(238, 229, 216, 0.88);
  --canvas-line: 23, 27, 22;
  --canvas-node: 23, 27, 22;
  --canvas-hot: 184, 67, 39;
  --theme-mark: #171b16;
  --theme-glow: rgba(60, 113, 128, 0.26);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--body-wash), var(--grid-x), var(--grid-y);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.55;
  letter-spacing: 0;
  overflow-x: hidden;
  transition: background 180ms ease, color 180ms ease;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  content: "";
  opacity: var(--texture-opacity);
  background-image:
    repeating-linear-gradient(0deg, transparent 0 2px, var(--scanline) 2px 3px),
    linear-gradient(90deg, transparent, var(--warm-trace), transparent);
  mix-blend-mode: var(--texture-blend);
}

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

button {
  font: inherit;
}

img,
svg,
canvas {
  display: block;
  max-width: 100%;
}

::selection {
  background: var(--accent);
  color: var(--accent-ink);
}

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

.skip-link {
  position: fixed;
  left: 16px;
  top: 16px;
  z-index: 20;
  transform: translateY(-140%);
  background: var(--ink);
  color: var(--bg);
  padding: 10px 14px;
}

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

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 12;
  min-height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px var(--gutter);
  background: var(--header-bg);
  border-bottom: 1px solid var(--faint);
  backdrop-filter: blur(18px);
  transition: background 180ms ease, border-color 180ms ease;
}

.wordmark {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  font-weight: 780;
  line-height: 1;
}

.wordmark span:last-child {
  color: var(--muted);
  font-weight: 520;
}

.header-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  min-width: 0;
}

.site-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

.site-nav a {
  position: relative;
  padding: 8px 10px;
  color: var(--muted);
  font-size: 0.92rem;
  transition: color 160ms ease;
}

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

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

.site-nav a:hover::after,
.site-nav a:focus-visible::after {
  transform: scaleX(1);
}

.theme-toggle {
  position: relative;
  flex: 0 0 auto;
  width: 38px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.theme-toggle::before,
.theme-toggle::after {
  position: absolute;
  content: "";
  transition: transform 180ms ease, opacity 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.theme-toggle::before {
  left: 11px;
  top: 8px;
  width: 14px;
  height: 14px;
  border: 1px solid currentColor;
  border-radius: 50%;
  background: var(--theme-mark);
  box-shadow: 0 0 18px var(--theme-glow);
}

.theme-toggle::after {
  left: 8px;
  right: 8px;
  bottom: 8px;
  height: 1px;
  background: var(--accent);
  transform: rotate(-18deg);
  transform-origin: center;
}

:root[data-theme="dark"] .theme-toggle::before {
  background: var(--ink);
  box-shadow: inset 5px -4px 0 var(--bg), 0 0 18px var(--theme-glow);
}

:root[data-theme="light"] .theme-toggle::before {
  transform: translateX(3px);
}

:root[data-theme="light"] .theme-toggle::after {
  transform: rotate(18deg);
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
  border-color: var(--accent);
  background: var(--faint);
}

.hero {
  position: relative;
  min-height: 88svh;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  isolation: isolate;
}

#signal-field {
  position: absolute;
  inset: 0;
  z-index: -2;
  width: 100%;
  height: 100%;
}

.hero-wash {
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(90deg, var(--hero-wash-a) 0%, var(--hero-wash-b) 44%, var(--hero-wash-c) 100%),
    linear-gradient(180deg, transparent 0%, var(--hero-wash-d) 100%);
}

.hero-copy {
  width: min(100%, 980px);
  padding: 128px var(--gutter) 76px;
  transform: translateY(calc(var(--scroll-depth) * -18px));
}

.section-label {
  margin: 0 0 18px;
  color: var(--accent);
  font-size: 0.88rem;
  font-weight: 720;
  line-height: 1.2;
}

.hero h1 {
  margin: 0;
  max-width: 10ch;
  font-family: var(--serif);
  font-size: 4.25rem;
  font-weight: 500;
  line-height: 0.9;
  letter-spacing: 0;
}

.hero h1 span {
  display: block;
}

.hero-lede {
  max-width: 620px;
  margin: 28px 0 0;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.35rem;
  line-height: 1.35;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
  margin-top: 34px;
}

.signal-link,
.plain-link,
.text-link,
.back-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-weight: 760;
}

.signal-link {
  position: relative;
  padding: 0 18px 0 0;
  color: var(--ink);
}

.signal-link::before {
  width: 34px;
  height: 2px;
  margin-right: 12px;
  content: "";
  background: var(--accent);
  transition: width 180ms ease;
}

.signal-link:hover::before,
.signal-link:focus-visible::before {
  width: 52px;
}

.plain-link,
.text-link,
.back-link {
  color: var(--muted);
  transition: color 160ms ease;
}

.plain-link:hover,
.plain-link:focus-visible,
.text-link:hover,
.text-link:focus-visible,
.back-link:hover,
.back-link:focus-visible {
  color: var(--ink);
}

.hero-index {
  position: absolute;
  right: var(--gutter);
  bottom: 24px;
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 0.84rem;
  text-align: right;
  transform: translateY(calc(var(--scroll-depth) * 16px));
}

.page-section,
.page-shell {
  width: min(100% - (var(--gutter) * 2), var(--max));
  margin-inline: auto;
}

.page-section {
  padding: 72px 0;
}

.section-ruled {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.section-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}

.section-copy {
  max-width: 760px;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h2 {
  max-width: 780px;
  margin: 0;
  font-family: var(--serif);
  font-size: 2.2rem;
  font-weight: 500;
  line-height: 1.06;
  letter-spacing: 0;
}

.section-copy p,
.page-heading p,
.about-note p {
  max-width: 720px;
  margin: 20px 0 0;
  color: var(--muted);
  font-size: 1.02rem;
}

.writing-list,
.project-list {
  margin-top: 28px;
  border-top: 1px solid var(--line);
}

.writing-row,
.project-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 22px 0;
  border-bottom: 1px solid var(--line);
  transition: color 160ms ease, transform 180ms ease, border-color 180ms ease;
}

.writing-row:hover,
.writing-row:focus-visible,
.project-row:hover,
.project-row:focus-visible {
  color: var(--green);
  border-bottom-color: var(--green);
  transform: translateX(6px);
}

.writing-row time,
.project-state {
  color: var(--muted);
  font-size: 0.88rem;
}

.writing-row strong,
.project-row strong {
  display: block;
  color: var(--ink);
  font-size: 1.08rem;
  line-height: 1.25;
}

.writing-row em,
.project-row em {
  display: block;
  max-width: 720px;
  margin-top: 5px;
  color: var(--muted);
  font-style: normal;
}

.text-link {
  margin-top: 22px;
}

.text-link::after,
.back-link::before {
  color: var(--accent);
}

.text-link::after {
  margin-left: 10px;
  content: "->";
}

.back-link::before {
  margin-right: 10px;
  content: "<-";
}

.page-shell {
  padding-top: 132px;
  padding-bottom: 88px;
}

.page-heading {
  max-width: 850px;
  margin-bottom: 54px;
}

.page-heading h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 3.2rem;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0;
}

.writing-list-large,
.project-list-large {
  margin-top: 0;
}

.about-shell {
  max-width: 900px;
}

.about-note {
  padding-top: 28px;
  border-top: 1px solid var(--line);
}

.article-shell {
  max-width: 860px;
}

.essay-header {
  padding-bottom: 34px;
  border-bottom: 1px solid var(--line);
}

.essay-header time {
  color: var(--accent);
  font-size: 0.94rem;
  font-weight: 720;
}

.essay-header h1 {
  margin: 16px 0 0;
  font-family: var(--serif);
  font-size: 3.4rem;
  font-weight: 500;
  line-height: 1.02;
  letter-spacing: 0;
}

.essay-header p {
  max-width: 660px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 1.08rem;
}

.essay-body {
  padding-top: 34px;
  font-family: var(--serif);
  font-size: 1.22rem;
  line-height: 1.75;
}

.essay-body p {
  margin: 0 0 1.25em;
}

.site-footer {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 34px var(--gutter);
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.site-footer strong,
.site-footer span {
  display: block;
}

.site-footer strong {
  color: var(--ink);
}

.footer-links {
  display: flex;
  gap: 18px;
}

.footer-links a {
  color: var(--muted);
}

.footer-links a:hover,
.footer-links a:focus-visible {
  color: var(--ink);
}

@keyframes hero-enter {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hero .section-label,
.hero h1,
.hero-lede,
.hero-actions {
  animation: hero-enter 680ms ease both;
}

.hero h1 {
  animation-delay: 80ms;
}

.hero-lede {
  animation-delay: 150ms;
}

.hero-actions {
  animation-delay: 220ms;
}

@media (min-width: 520px) {
  :root {
    --gutter: 28px;
  }

  .hero h1 {
    font-size: 5.7rem;
  }

  .hero-lede {
    font-size: 1.55rem;
  }

  .writing-row,
  .project-row {
    grid-template-columns: 160px minmax(0, 1fr);
    gap: 28px;
  }

  .site-footer {
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-between;
  }
}

@media (min-width: 840px) {
  :root {
    --gutter: 40px;
  }

  .hero-copy {
    padding-top: 146px;
  }

  .hero h1 {
    font-size: 8.4rem;
  }

  .section-grid {
    grid-template-columns: 190px minmax(0, 1fr);
    gap: 48px;
  }

  h2 {
    font-size: 3rem;
  }

  .page-heading h1 {
    font-size: 4.6rem;
  }

  .essay-header h1 {
    font-size: 4.4rem;
  }
}

@media (min-width: 1180px) {
  :root {
    --gutter: 56px;
  }

  .hero h1 {
    font-size: 10.2rem;
  }
}

@media (max-width: 620px) {
  .site-header {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: flex-start;
    min-height: 88px;
  }

  .wordmark {
    display: grid;
    gap: 1px;
  }

  .header-controls {
    flex-wrap: wrap;
    gap: 6px 10px;
  }

  .site-nav {
    flex-wrap: wrap;
    gap: 0;
  }

  .site-nav a {
    padding: 6px 6px;
    font-size: 0.86rem;
  }

  .theme-toggle {
    width: 34px;
    height: 31px;
  }

  .hero {
    min-height: 84svh;
  }

  .hero-copy {
    padding-top: 118px;
    padding-bottom: 64px;
  }

  .hero-index {
    display: none;
  }

  .page-heading h1 {
    font-size: 2.7rem;
  }

  .essay-header h1 {
    font-size: 2.7rem;
  }
}

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

  .hero-copy,
  .hero-index {
    transform: none;
  }
}
