/* ---------- Fonts ---------- */

/* Geist and Geist Mono (SIL Open Font License), self-hosted. Each file is a variable font
   covering every weight; the latin-ext files only download when a page uses those characters. */
@font-face {
  font-family: "Geist";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/assets/fonts/geist-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: "Geist";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/assets/fonts/geist-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-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Geist Mono";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/assets/fonts/geist-mono-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: "Geist Mono";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/assets/fonts/geist-mono-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-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------- Theme tokens ---------- */

:root {
  --bg: #ffffff;
  --fg: #0a0a0a;
  --muted: #5c5c5c;
  --line: #e3e3e3;
  --soft: #f6f6f6;

  --font-sans: "Geist", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, monospace;
  --gutter-left: max(24px, env(safe-area-inset-left, 0px));
  --gutter-right: max(24px, env(safe-area-inset-right, 0px));

  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0a0a0a;
  --fg: #fafafa;
  --muted: #a3a3a3;
  --line: #2a2a2a;
  --soft: #141414;

  color-scheme: dark;
}

/* Without JavaScript there is no data-theme attribute, so follow the OS. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #0a0a0a;
    --fg: #fafafa;
    --muted: #a3a3a3;
    --line: #2a2a2a;
    --soft: #141414;

    color-scheme: dark;
  }
}

/* ---------- Base ---------- */

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

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.6;
}

main {
  flex: 1;
}

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

a:hover {
  opacity: 0.6;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

button:hover {
  opacity: 0.75;
}

:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
}

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

/* Read by screen readers, not shown on screen. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding-left: var(--gutter-left);
  padding-right: var(--gutter-right);
}

/* Theme-dependent content: the toggle shows the current theme. */
:root:not([data-theme="dark"]) .when-dark,
:root[data-theme="dark"] .when-light {
  display: none;
}

html:not(.js) .js-only {
  display: none;
}

/* ---------- Header & footer ---------- */

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

.site-header .container {
  padding-block: 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.logo {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 28px;
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.6;
}

.site-nav a[aria-current] {
  text-decoration: underline;
  text-underline-offset: 6px;
}

.pill-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 13px;
}

.pill-btn--wide {
  padding: 0 16px;
}

.site-footer {
  border-top: 1px solid var(--line);
}

.site-footer .container {
  padding-block: 28px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
}

/* ---------- Shared pieces ---------- */

.prompt {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--muted);
}

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

.section__inner {
  padding-block: 96px;
  display: flex;
  flex-wrap: wrap;
  gap: 32px 48px;
}

.section--last .section__inner {
  padding-block: 96px 112px;
}

.section-label {
  flex: 1 1 160px;
  margin: 0;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 400;
  color: var(--muted);
}

.section-body {
  flex: 999 1 560px;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.row-between {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px 24px;
}

.text-link {
  align-self: flex-start;
  margin-top: 28px;
  font-family: var(--font-mono);
  font-size: 14px;
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* Titled code window: home /stack and fenced code in posts */
.code-window {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.code-window__bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--soft);
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
}

.code-window__scroll {
  overflow-x: auto;
}

.code-window pre {
  margin: 0;
  padding: 20px;
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.75;
}

.code-window code {
  font-family: inherit;
}

.code-window--stack {
  display: block;
}

.code-window--stack pre {
  line-height: 2;
  font-variant-numeric: tabular-nums;
}

.token.comment,
.token.prolog {
  color: var(--muted);
}

/* ---------- Home ---------- */

.hero {
  padding-block: 128px 112px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.hero h1 {
  margin: 0;
  font-size: clamp(44px, 7vw, 84px);
  font-weight: 500;
  line-height: 1.02;
  letter-spacing: -0.045em;
  text-wrap: balance;
}

.lede {
  margin: 0;
  max-width: 640px;
  font-size: 22px;
  line-height: 1.5;
  color: var(--muted);
  text-wrap: pretty;
}

.meta-row {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
}

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--fg);
}

.status::before {
  content: "";
  width: 8px;
  height: 8px;
  background: var(--fg);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding-top: 12px;
}

.btn {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 0 22px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 15px;
}

.btn--primary {
  border: 0;
  background: var(--fg);
  color: var(--bg);
  font-weight: 500;
}

.work {
  gap: 56px;
}

.company {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.company h3 {
  margin: 0;
  font-size: 26px;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.company p {
  margin: 0;
  color: var(--muted);
}

.dates {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.project {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding-top: 40px;
  border-top: 1px solid var(--line);
}

.project h4 {
  margin: 0;
  font-size: 21px;
  font-weight: 500;
  letter-spacing: -0.015em;
}

.project > p {
  margin: 0;
  max-width: 640px;
  color: var(--muted);
}

.badge {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
}

.badge--solid {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}

.stats {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 24px;
  padding-top: 8px;
}

.stats div {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stats dt {
  order: 2;
  font-size: 14px;
  color: var(--muted);
}

.stats dd {
  order: 1;
  margin: 0;
  font-family: var(--font-mono);
  font-size: 36px;
  font-weight: 500;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.post-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 24px;
  padding-block: 20px;
  border-bottom: 1px solid var(--line);
}

.post-row__date {
  flex: 0 0 96px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.post-row__title {
  flex: 1 1 320px;
  min-width: 0;
  font-size: 19px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.post-row__arrow {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
}

.about {
  gap: 40px;
}

.about__intro {
  margin: 0;
  max-width: 640px;
  font-size: 21px;
  line-height: 1.55;
  text-wrap: pretty;
}

.facts {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px 48px;
}

.facts div {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.facts dt {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
}

.facts dd {
  margin: 0;
}

.contact {
  gap: 24px;
}

.contact__lede {
  margin: 0;
  font-size: 21px;
  color: var(--muted);
}

.contact__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px 20px;
}

.contact__email {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: clamp(22px, 3.4vw, 36px);
  font-weight: 500;
  letter-spacing: -0.025em;
}

/* ---------- Writing index ---------- */

.page-intro {
  padding-block: 112px 64px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.page-intro h1 {
  margin: 0;
  font-size: clamp(44px, 6vw, 72px);
  font-weight: 500;
  line-height: 1.02;
  letter-spacing: -0.045em;
}

.page-intro__lede {
  margin: 0;
  max-width: 600px;
  font-size: 20px;
  color: var(--muted);
}

.archive {
  padding-block: 0 128px;
  display: flex;
  flex-direction: column;
  gap: 56px;
}

.year {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 48px;
}

.year__label {
  padding-top: 22px;
  font-variant-numeric: tabular-nums;
}

.year__posts {
  flex: 999 1 560px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--line);
}

.post-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-block: 20px;
  border-bottom: 1px solid var(--line);
}

.post-card__head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 4px 24px;
}

.post-card__title {
  min-width: 0;
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.015em;
}

.post-card__meta {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.post-card__summary {
  max-width: 640px;
  color: var(--muted);
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}

.tag {
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
}

.feed-link {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--muted);
}

.feed-link a {
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* ---------- Post ---------- */

.page-post {
  font-size: 18px;
  line-height: 1.7;
}

.post-main {
  padding-left: var(--gutter-left);
  padding-right: var(--gutter-right);
}

.post {
  max-width: 680px;
  margin: 0 auto;
  padding-block: 96px 112px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.back-link {
  align-self: flex-start;
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--muted);
}

.post-header {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--line);
}

.post-meta {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.post-header h1 {
  margin: 0;
  font-size: clamp(36px, 5vw, 52px);
  font-weight: 500;
  line-height: 1.08;
  letter-spacing: -0.04em;
  text-wrap: balance;
}

.post-lede {
  margin: 0;
  font-size: 21px;
  line-height: 1.55;
  color: var(--muted);
  text-wrap: pretty;
}

.prose {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.prose > * {
  margin: 0;
}

.prose h2 {
  margin: 24px 0 0;
  font-size: 26px;
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.prose h3 {
  margin: 16px 0 0;
  font-size: 21px;
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: -0.015em;
}

.prose a {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.prose ul,
.prose ol {
  padding-left: 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.prose blockquote {
  margin: 8px 0;
  padding: 4px 0 4px 20px;
  border-left: 2px solid var(--fg);
  font-size: 20px;
  line-height: 1.55;
}

.prose blockquote p {
  margin: 0;
}

.prose :not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  padding: 2px 6px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 4px;
}

.prose figure {
  margin: 8px 0;
}

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

.post-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 16px;
  margin-top: 40px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}

.post-nav a {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.post-nav__next {
  margin-left: auto;
  text-align: right;
}

.post-nav__dir {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
}

.post-nav__title {
  font-weight: 500;
}
