:root {
  color-scheme: light dark;
  --bg: #f4f1ea;
  --surface: #ebe5da;
  --text: #171717;
  --muted: #68645d;
  --line: #d8d2c7;
  --accent: #8c2f39;
  --accent-soft: #ead5d5;
  --serif: Georgia, "Times New Roman", serif;
  --sans: Arial, Helvetica, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151513;
    --surface: #201f1c;
    --text: #f4f1ea;
    --muted: #aaa59b;
    --line: #37342f;
    --accent: #df8d95;
    --accent-soft: #462e31;
  }
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--serif);
  text-rendering: optimizeLegibility;
}

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

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

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

a:focus-visible,
summary:focus-visible {
  border-radius: 2px;
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

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

.skip-link {
  position: fixed;
  z-index: 10;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.6rem 0.8rem;
  transform: translateY(-200%);
  background: var(--text);
  color: var(--bg);
  font-family: var(--sans);
}

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

.eyebrow,
.article-kicker,
.writing-type,
.article-meta,
.site-nav,
.site-footer,
.toc,
.home-links {
  font-family: var(--sans);
}

.eyebrow,
.article-kicker,
.writing-type {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

/* Home */

.home {
  display: grid;
  place-items: center;
  padding: 2rem;
}

.home-main {
  width: min(100%, 42rem);
}

.home .eyebrow {
  margin: 0 0 1.25rem;
}

.home h1 {
  margin: 0;
  font-size: clamp(3.2rem, 12vw, 7rem);
  font-weight: 400;
  line-height: 0.92;
  letter-spacing: -0.055em;
}

.home-intro {
  max-width: 35rem;
  margin: 2rem 0 0;
  color: var(--muted);
  font-size: clamp(1.1rem, 2.5vw, 1.35rem);
  line-height: 1.55;
}

.home-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem 1.5rem;
  align-items: center;
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  font-size: 0.9rem;
}

.home-links a:first-child {
  font-weight: 700;
}

.home-links a span {
  display: inline-block;
  margin-left: 0.25rem;
  transition: transform 150ms ease;
}

.home-links a:hover span {
  transform: translateX(0.2rem);
}

/* Shared page chrome */

.shell {
  width: min(calc(100% - 3rem), 72rem);
  margin-inline: auto;
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 2rem;
  padding-block: 1.5rem;
  border-bottom: 1px solid var(--line);
}

.wordmark {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.site-nav {
  display: flex;
  gap: 1.25rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.site-nav a[aria-current="page"] {
  color: var(--text);
  text-decoration-color: var(--accent);
}

.page-main {
  padding-block: clamp(4rem, 10vw, 8rem);
}

.page-intro {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(14rem, 1fr);
  gap: 3rem;
  align-items: end;
  margin-bottom: clamp(4rem, 9vw, 7rem);
}

.page-title,
.article-title {
  margin: 0;
  font-weight: 400;
  letter-spacing: -0.05em;
}

.page-title {
  font-size: clamp(4rem, 11vw, 8.5rem);
  line-height: 0.86;
}

.page-description {
  margin: 0 0 0.35rem;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.6;
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  margin-top: 6rem;
  padding-block: 1.5rem 2.5rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.8rem;
}

/* Writings index */

.writing-list {
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line);
  list-style: none;
}

.writing-link {
  display: grid;
  grid-template-columns: 3.5rem minmax(0, 1fr) auto;
  gap: 1.5rem;
  align-items: start;
  padding-block: 2.25rem;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
}

.writing-number {
  padding-top: 0.25rem;
  color: var(--accent);
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 700;
}

.writing-title {
  display: block;
  margin: 0.35rem 0 0.6rem;
  font-size: clamp(1.7rem, 4vw, 2.8rem);
  font-weight: 400;
  letter-spacing: -0.035em;
  line-height: 1.05;
}

.writing-summary {
  display: block;
  max-width: 42rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.55;
}

.writing-arrow {
  padding-top: 0.15rem;
  font-size: 1.5rem;
  transition: transform 150ms ease;
}

.writing-link:hover .writing-arrow {
  transform: translateX(0.3rem);
}

/* Articles */

.article-main {
  padding-top: clamp(3.5rem, 9vw, 7rem);
}

.article-header {
  max-width: 62rem;
}

.article-kicker {
  margin: 0 0 1.25rem;
}

.article-title {
  max-width: 60rem;
  font-size: clamp(3.2rem, 9vw, 7.25rem);
  line-height: 0.93;
}

.article-deck {
  max-width: 43rem;
  margin: 2rem 0 0;
  color: var(--muted);
  font-size: clamp(1.15rem, 2.4vw, 1.45rem);
  line-height: 1.55;
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.25rem;
  margin: 2.25rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.article-meta span + span::before {
  content: "/";
  margin-right: 1.25rem;
  color: var(--line);
}

.article-rule {
  margin-block: clamp(3rem, 7vw, 5rem);
  border: 0;
  border-top: 1px solid var(--line);
}

.article-back {
  display: inline-block;
  margin-top: 5rem;
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 700;
}

/* Poem */

.poem-page .article-header {
  max-width: 54rem;
}

.poem {
  width: min(100%, 45rem);
  font-size: clamp(1.06rem, 2.1vw, 1.28rem);
  line-height: 1.72;
  overflow-wrap: break-word;
}

.poem p {
  margin: 0 0 2.4rem;
}

.poem p:first-child::first-letter {
  color: var(--accent);
  font-size: 2.8em;
  line-height: 0.75;
}

/* Thesis */

.thesis-header {
  max-width: 66rem;
}

.thesis-header .article-title {
  max-width: 64rem;
}

.thesis-layout {
  display: grid;
  grid-template-columns: 15rem minmax(0, 46rem);
  gap: clamp(2.5rem, 6vw, 6rem);
  align-items: start;
}

.toc {
  position: sticky;
  top: 1.5rem;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.toc summary {
  margin-bottom: 1rem;
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.12em;
  list-style: none;
  text-transform: uppercase;
}

.toc summary::-webkit-details-marker {
  display: none;
}

.toc ol {
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line);
  list-style: none;
}

.toc li {
  border-bottom: 1px solid var(--line);
}

.toc a {
  display: block;
  padding: 0.6rem 0;
  text-decoration: none;
}

.thesis-body {
  min-width: 0;
  font-size: 1.02rem;
  line-height: 1.78;
}

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

.thesis-body h1,
.thesis-body h2,
.thesis-body h3,
.thesis-body h4 {
  scroll-margin-top: 2rem;
  font-weight: 400;
  letter-spacing: -0.025em;
  line-height: 1.14;
}

.thesis-body h1 {
  margin: 5.5rem 0 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
  font-size: clamp(2.25rem, 5vw, 3.6rem);
}

.thesis-body h2 {
  margin: 3.8rem 0 1.15rem;
  font-size: clamp(1.65rem, 3.5vw, 2.35rem);
}

.thesis-body h3 {
  margin: 2.8rem 0 0.9rem;
  color: var(--accent);
  font-size: clamp(1.3rem, 2.6vw, 1.65rem);
}

.thesis-body h4 {
  margin: 2.4rem 0 0.8rem;
  font-size: 1.15rem;
  font-style: italic;
}

.thesis-body p {
  margin: 0 0 1.35rem;
}

.thesis-body ul {
  margin-block: 1.5rem;
  padding-left: 1.25rem;
}

.thesis-body li {
  margin-bottom: 0.55rem;
  padding-left: 0.35rem;
}

.thesis-body em {
  color: color-mix(in srgb, var(--text) 84%, var(--accent));
}

.thesis-body img {
  display: block;
  max-height: 48rem;
  margin: 2rem auto;
  border: 1px solid var(--line);
  background: #fff;
  object-fit: contain;
}

.thesis-body a {
  overflow-wrap: anywhere;
}

.references p {
  padding-left: 1.5rem;
  text-indent: -1.5rem;
  font-size: 0.92rem;
}

@media (max-width: 48rem) {
  .shell {
    width: min(calc(100% - 2rem), 72rem);
  }

  .site-header {
    padding-block: 1.1rem;
  }

  .site-nav {
    gap: 0.8rem;
  }

  .page-intro {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .writing-link {
    grid-template-columns: 2rem minmax(0, 1fr);
    gap: 1rem;
  }

  .writing-arrow {
    display: none;
  }

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

  .toc {
    position: static;
    padding: 1rem;
    border: 1px solid var(--line);
    background: var(--surface);
  }

  .toc summary {
    margin: 0;
  }

  .toc[open] summary {
    margin-bottom: 1rem;
  }

  .article-meta span + span::before {
    margin-right: 0.6rem;
  }

  .article-meta {
    gap: 0.5rem 0.6rem;
  }

  .article-title {
    font-size: clamp(2.8rem, 12vw, 4rem);
    overflow-wrap: anywhere;
  }

  .site-footer {
    flex-direction: column;
  }
}

@media (max-width: 28rem) {
  .home {
    padding: 1.25rem;
  }

  .site-nav a:last-child {
    display: none;
  }

  .poem {
    font-size: 1rem;
    line-height: 1.65;
  }
}

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

  .home-links a span,
  .writing-arrow {
    transition: none;
  }
}

@media print {
  :root {
    color-scheme: light;
    --bg: #fff;
    --text: #000;
    --muted: #444;
    --line: #aaa;
    --accent: #000;
  }

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

  .shell {
    width: 100%;
  }

  .thesis-layout {
    display: block;
  }

  .thesis-body a {
    text-decoration: none;
  }
}
