/* ============================================================================
   Newsreader — self-hosted variable subset (latin + latin-ext, roman + italic)
   ========================================================================== */
@font-face {
  font-family: "Newsreader";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("/fonts/newsreader-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Newsreader";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("/fonts/newsreader-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Newsreader";
  font-style: italic;
  font-weight: 200 800;
  font-display: swap;
  src: url("/fonts/newsreader-italic-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Newsreader";
  font-style: italic;
  font-weight: 200 800;
  font-display: swap;
  src: url("/fonts/newsreader-italic-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ============================================================================
   Tokens
   ========================================================================== */
:root {
  --paper: #faf8f3;
  --ink: #211e1a;
  --muted: #6a6157;
  --faint: #8c8478;
  --rule: #e6dfd1;
  --accent: #b04e1f; /* rustic orange */
  --accent-soft: #f0ddd0;

  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Palatino,
    Georgia, "Times New Roman", serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Helvetica, Arial,
    sans-serif;

  --measure: 34rem; /* ~65 characters at this size */
  --gutter: 1.5rem;
  --sidenote-w: 14rem;

  /* iOS-style continuous "squircle" corner — superellipse (n=5) SVG mask */
  --squircle: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20100%20100'%20preserveAspectRatio='none'%3E%3Cpath%20d='M100.00,50.00L99.92,68.84L99.69,74.82L99.31,79.12L98.77,82.55L98.07,85.43L97.20,87.89L96.17,90.03L94.94,91.90L93.53,93.53L91.90,94.94L90.03,96.17L87.89,97.20L85.43,98.07L82.55,98.77L79.12,99.31L74.82,99.69L68.84,99.92L50.00,100.00L31.16,99.92L25.18,99.69L20.88,99.31L17.45,98.77L14.57,98.07L12.11,97.20L9.97,96.17L8.10,94.94L6.47,93.53L5.06,91.90L3.83,90.03L2.80,87.89L1.93,85.43L1.23,82.55L0.69,79.12L0.31,74.82L0.08,68.84L0.00,50.00L0.08,31.16L0.31,25.18L0.69,20.88L1.23,17.45L1.93,14.57L2.80,12.11L3.83,9.97L5.06,8.10L6.47,6.47L8.10,5.06L9.97,3.83L12.11,2.80L14.57,1.93L17.45,1.23L20.88,0.69L25.18,0.31L31.16,0.08L50.00,0.00L68.84,0.08L74.82,0.31L79.12,0.69L82.55,1.23L85.43,1.93L87.89,2.80L90.03,3.83L91.90,5.06L93.53,6.47L94.94,8.10L96.17,9.97L97.20,12.11L98.07,14.57L98.77,17.45L99.31,20.88L99.69,25.18L99.92,31.16L100.00,50.00Z'%20fill='%23000'/%3E%3C/svg%3E");
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #15130f;
    --ink: #e9e2d6;
    --muted: #a89e90;
    --faint: #837a6d;
    --rule: #322d24;
    --accent: #d4845a; /* rustic orange, lightened for dark bg */
    --accent-soft: #2e1e14;
  }
}

/* ============================================================================
   Reset / base
   ========================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 112.5%; /* 18px base */
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-weight: 400;
  line-height: 1.62;
  font-feature-settings: "kern", "liga", "onum", "pnum";
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

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

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

/* Links — the single accent does most of its work here */
a {
  color: var(--accent);
  text-decoration: none;
  text-underline-offset: 0.14em;
  text-decoration-thickness: 0.06em;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 38%, transparent);
  transition: border-color 0.15s ease, background 0.15s ease;
}
a:hover {
  border-bottom-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 9%, transparent);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 1px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--paper);
  color: var(--ink);
  padding: 0.5rem 0.85rem;
  border: 1px solid var(--rule);
  z-index: 10;
}
.skip-link:focus {
  left: 1rem;
  top: 1rem;
}

/* ============================================================================
   Frame: header, main, footer
   ========================================================================== */
.site-head,
.site-foot,
main {
  width: 100%;
  margin-inline: auto;
}

.site-head {
  max-width: calc(var(--measure) + var(--sidenote-w) + var(--gutter) * 2);
  padding: 2rem var(--gutter) 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  align-items: baseline;
  justify-content: space-between;
}

.wordmark {
  font-weight: 500;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
  color: var(--ink);
  border-bottom: none;
}
.wordmark:hover {
  background: none;
  color: var(--accent);
}

.site-nav {
  display: flex;
  gap: 1.35rem;
  font-family: var(--sans);
  font-size: 0.82rem;
  letter-spacing: 0.02em;
}
.site-nav a {
  color: var(--muted);
  border-bottom: none;
  padding-bottom: 2px;
}
.site-nav a:hover {
  color: var(--accent);
  background: none;
}
.site-nav a[aria-current="page"] {
  color: var(--ink);
  border-bottom: 1px solid var(--accent);
}

main {
  flex: 1 0 auto;
  max-width: calc(var(--measure) + var(--sidenote-w) + var(--gutter) * 2);
  padding: 3.5rem var(--gutter) 0;
}

.site-foot {
  max-width: calc(var(--measure) + var(--sidenote-w) + var(--gutter) * 2);
  margin-top: 5rem;
  padding: 1.75rem var(--gutter) 2.5rem;
  border-top: 1px solid var(--rule);
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  align-items: baseline;
  justify-content: space-between;
  font-family: var(--sans);
  font-size: 0.82rem;
}
.foot-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1.1rem;
}
.foot-links a,
.foot-meta a {
  color: var(--muted);
  border-bottom: none;
}
.foot-links a:hover,
.foot-meta a:hover {
  color: var(--accent);
  background: none;
}
.foot-meta {
  margin: 0;
}

/* ============================================================================
   Landing
   ========================================================================== */
.intro {
  max-width: 40rem;
  margin: 1rem auto 0;
  display: flex;
  align-items: center;
  gap: 2.25rem;
}
.intro-text {
  flex: 1 1 0;
  min-width: 0;
}
.intro-photo {
  flex: 0 0 auto;
}
.intro-photo img {
  display: block;
  width: 200px;
  height: 200px;
  object-fit: cover;
  object-position: center top;
  filter: grayscale(12%);
  /* iOS App Store-style continuous corners */
  -webkit-mask: var(--squircle) center / 100% 100% no-repeat;
  mask: var(--squircle) center / 100% 100% no-repeat;
}
.intro-name {
  font-weight: 400;
  font-size: clamp(2.1rem, 6vw, 2.9rem);
  line-height: 1.08;
  letter-spacing: -0.012em;
  margin: 0 0 1.1rem;
}
.intro-lede {
  font-size: 1.24rem;
  line-height: 1.55;
  color: var(--ink);
  margin: 0 0 1.6rem;
  text-wrap: pretty;
}
.intro-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.4rem;
  font-family: var(--sans);
  font-size: 0.9rem;
  margin: 0;
}
.intro-links a {
  border-bottom: none;
  color: var(--accent);
}
.intro-links a:hover {
  background: none;
  border-bottom: 1px solid var(--accent);
}

/* ---- featured writing on the landing ---- */
.featured {
  max-width: 40rem;
  margin: 4.5rem auto 0;
}
.section-label {
  font-family: var(--sans);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
  margin: 0 0 1.5rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--rule);
}
.feature-date,
.writing-date,
.feature-status,
.writing-status {
  margin: 0;
}
.feature-date,
.writing-date {
  font-family: var(--sans);
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  color: var(--faint);
  margin-bottom: 0.5rem;
}
.feature-title {
  font-weight: 500;
  font-size: 1.9rem;
  line-height: 1.16;
  letter-spacing: -0.01em;
  margin: 0 0 0.7rem;
}
.feature-title a {
  color: var(--ink);
  border-bottom: none;
}
.feature-title a:hover {
  color: var(--accent);
  background: none;
}
.feature-dek {
  font-size: 1.12rem;
  line-height: 1.5;
  color: var(--ink);
  margin: 0 0 1rem;
  text-wrap: pretty;
}
.feature-cta {
  font-family: var(--sans);
  font-size: 0.9rem;
  margin: 1.2rem 0 0;
}
.feature-cta a {
  border-bottom: none;
}

.feature-status,
.writing-status {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--muted);
  border-left: 2px solid var(--accent-soft);
  padding-left: 0.9rem;
  margin-top: 1rem;
}

.feature-empty {
  font-style: italic;
  color: var(--muted);
  margin: 0;
}

.essay-list {
  list-style: none;
  padding: 0;
  margin: 2rem 0 0;
  border-top: 1px solid var(--rule);
}
.essay-list li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: baseline;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--rule);
}
.essay-list a {
  border-bottom: none;
  color: var(--ink);
}
.essay-list a:hover {
  color: var(--accent);
  background: none;
}
.essay-list time {
  font-family: var(--sans);
  font-size: 0.76rem;
  color: var(--faint);
  white-space: nowrap;
}
.see-all {
  font-family: var(--sans);
  font-size: 0.85rem;
  margin-top: 1.5rem;
}
.see-all a {
  border-bottom: none;
}

/* ============================================================================
   Generic prose page (about, now, colophon) + writing index
   ========================================================================== */
.page {
  max-width: var(--measure);
  margin-inline: auto;
}
.page-title {
  font-weight: 400;
  font-size: clamp(1.9rem, 5vw, 2.4rem);
  letter-spacing: -0.01em;
  line-height: 1.1;
  margin: 0 0 1.8rem;
}
.page-intro {
  font-size: 1.16rem;
  color: var(--muted);
  line-height: 1.55;
  margin: 0 0 2.5rem;
  text-wrap: pretty;
}

.prose p,
.prose ul,
.prose ol {
  margin: 0 0 1.25rem;
}
.prose h2 {
  font-weight: 500;
  font-size: 1.32rem;
  letter-spacing: -0.005em;
  margin: 2.6rem 0 0.9rem;
}
.prose ul,
.prose ol {
  padding-left: 1.2rem;
}
.prose li {
  margin-bottom: 0.5rem;
}
.prose a {
  /* keep inline body links underlined for affordance */
}
.prose blockquote {
  margin: 2rem 0;
  padding: 0;
  border: none;
  font-size: 1.5rem;
  font-style: italic;
  line-height: 1.35;
  color: var(--ink);
  letter-spacing: -0.005em;
  text-wrap: balance;
}
.prose blockquote p {
  margin: 0;
}
.prose hr {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 2.5rem 0;
}

/* now page "last updated" */
.now-updated {
  font-family: var(--sans);
  font-size: 0.82rem;
  color: var(--faint);
  margin: 0 0 2rem !important;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--rule);
}
.now-updated time {
  color: var(--muted);
}
.now-updated-note {
  margin-left: 0.4em;
}

/* writing index */
.writing-index {
  list-style: none;
  counter-reset: none;
  padding: 0;
  margin: 0;
}
.writing-entry {
  padding: 2rem 0;
  border-top: 1px solid var(--rule);
}
.writing-entry:first-child {
  border-top: none;
  padding-top: 0;
}
.writing-entry-title {
  font-weight: 500;
  font-size: 1.55rem;
  line-height: 1.2;
  letter-spacing: -0.008em;
  margin: 0.3rem 0 0.6rem;
}
.writing-entry-title a {
  color: var(--ink);
  border-bottom: none;
}
.writing-entry-title a:hover {
  color: var(--accent);
  background: none;
}
.writing-dek {
  font-size: 1.05rem;
  color: var(--muted);
  margin: 0;
  line-height: 1.5;
}

/* ============================================================================
   Essay
   ========================================================================== */
.essay {
  max-width: var(--measure);
}
.essay-head {
  margin-bottom: 2.5rem;
}
.essay-kicker {
  font-family: var(--sans);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin: 0 0 1.2rem;
}
.essay-kicker a {
  color: var(--faint);
  border-bottom: none;
}
.essay-kicker a:hover {
  color: var(--accent);
  background: none;
}
.essay-title {
  font-weight: 500;
  font-size: clamp(2rem, 6vw, 2.7rem);
  line-height: 1.12;
  letter-spacing: -0.015em;
  margin: 0 0 1rem;
  text-wrap: balance;
}
.essay-dek {
  font-size: 1.22rem;
  font-style: italic;
  line-height: 1.45;
  color: var(--muted);
  margin: 0 0 1.6rem;
  text-wrap: pretty;
}
.essay-meta {
  font-family: var(--sans);
  border-top: 1px solid var(--rule);
  padding-top: 1.1rem;
}
.essay-meta time {
  font-size: 0.8rem;
  letter-spacing: 0.03em;
  color: var(--faint);
}

.essay-body {
  font-size: 1.06rem;
}
.essay-body p {
  margin: 0 0 1.3rem;
}
.essay-body h2 {
  font-weight: 500;
  font-size: 1.3rem;
  letter-spacing: -0.005em;
  margin: 2.8rem 0 1rem;
}
.essay-body hr {
  border: none;
  border-top: 1px solid var(--rule);
  width: 4rem;
  margin: 2.6rem 0;
}
.essay-body em {
  font-style: italic;
}
.essay-foot {
  margin-top: 3.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 0.9rem;
}
.essay-foot a {
  border-bottom: none;
}

/* ============================================================================
   Tufte sidenotes — float to margin on wide screens, fold inline on narrow.
   No JavaScript; the checkbox toggle only matters at narrow widths.
   ========================================================================== */
.sidenote-ref {
  font-family: var(--sans);
  font-size: 0.68em;
  font-weight: 600;
  vertical-align: super;
  line-height: 0;
  color: var(--accent);
  cursor: default;
  padding: 0 0.1em;
}
.sidenote-num {
  font-family: var(--sans);
  font-size: 0.7em;
  font-weight: 600;
  vertical-align: super;
  line-height: 0;
  color: var(--accent);
  margin-right: 0.3em;
}
/* Visually hidden but still focusable, so keyboard users can Tab to the note
   marker and toggle it with Space — no JavaScript. Hidden outright on wide
   screens, where the note is always visible in the margin. */
.sidenote-toggle {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}
.sidenote-toggle:focus-visible + .sidenote-ref {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 1px;
}
.sidenote {
  display: block;
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--muted);
}

/* Wide: park the note in the right margin, aligned to its reference line. */
@media (min-width: 60rem) {
  .sidenote-toggle {
    display: none;
  }
  .sidenote-ref {
    cursor: default;
  }
  .sidenote {
    float: right;
    clear: right;
    width: var(--sidenote-w);
    margin-right: calc(-1 * (var(--sidenote-w) + var(--gutter)));
    margin-top: 0.25rem;
    margin-bottom: 1rem;
    position: relative;
  }
}

/* Narrow: hide by default, reveal on tapping the reference number. */
@media (max-width: 59.99rem) {
  .sidenote-ref {
    cursor: pointer;
  }
  .sidenote {
    max-height: 0;
    overflow: hidden;
    margin: 0;
    opacity: 0;
    transition: opacity 0.2s ease;
  }
  .sidenote-toggle:checked ~ .sidenote {
    max-height: none;
    opacity: 1;
    margin: 0.6rem 0 1rem;
    padding-left: 0.9rem;
    border-left: 2px solid var(--accent-soft);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

/* ============================================================================
   Small screens
   ========================================================================== */
@media (max-width: 34rem) {
  html {
    font-size: 106.25%; /* 17px */
  }
  main {
    padding-top: 2.5rem;
  }
  .site-head {
    padding-top: 1.5rem;
  }
  .intro {
    gap: 1.5rem;
  }
  .intro-photo {
    display: none; /* photo is desktop-only */
  }
  .intro-name {
    margin-bottom: 0.9rem;
  }
}
