/* petewilcock.com
   One stylesheet, no framework, no webfont. The old theme shipped ~110KB of CSS
   across five Autoptimize bundles plus a FontAwesome family for content that
   never changes. */

:root {
  --bg: #fbfbfa;
  --surface: #ffffff;
  --fg: #16191c;
  --muted: #6a7078;
  --faint: #949aa2;
  --rule: #e4e6e4;
  --link: #1a5f4a;
  --link-hover: #0f4434;
  --accent: #1a5f4a;
  --code-bg: #f2f3f1;
  --measure: 40rem;
  --wrap: 62rem;
}

/* Dark tokens are declared twice on purpose: once behind the OS preference for
   the un-stamped default state, and once behind the explicit stamp so the
   toggle wins in both directions. Components only ever read the tokens. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131517;
    --surface: #191c1f;
    --fg: #e7e9e7;
    --muted: #9aa1a6;
    --faint: #757c82;
    --rule: #292d31;
    --link: #6ec4a3;
    --link-hover: #96d8bf;
    --accent: #6ec4a3;
    --code-bg: #1d2124;
  }
}
:root[data-theme="dark"] {
  --bg: #131517;
  --surface: #191c1f;
  --fg: #e7e9e7;
  --muted: #9aa1a6;
  --faint: #757c82;
  --rule: #292d31;
  --link: #6ec4a3;
  --link-hover: #96d8bf;
  --accent: #6ec4a3;
  --code-bg: #1d2124;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 17px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 1.5rem; }

a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--link-hover); }
img { max-width: 100%; height: auto; }

.skip { position: absolute; left: -9999px; }
.skip:focus {
  left: 1rem; top: 1rem; z-index: 10; background: var(--surface);
  padding: .5rem .75rem; border: 2px solid var(--accent);
}
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px;
}

/* ---------------------------------------------------------------- header */

.site-header { padding: 1.75rem 0 1.5rem; margin-bottom: 2.25rem; }
.site-header .wrap {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1.5rem; flex-wrap: wrap;
}

/* Wordmark: a monospace monogram tile against a proportional name, so the
   technical half of the subject shows up in the identity rather than in an
   illustration. */
.brand { display: inline-flex; align-items: center; gap: .7rem; text-decoration: none; }
.brand-mark {
  flex: none; width: 2.1rem; height: 2.1rem; border-radius: 6px;
  background: var(--accent); color: var(--bg);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .82rem; font-weight: 600; letter-spacing: -.03em;
  display: grid; place-items: center;
  transition: transform .2s ease;
}
.brand:hover .brand-mark { transform: rotate(-4deg); }
.brand-words { display: flex; flex-direction: column; line-height: 1.25; }
.brand-name {
  font-size: 1.02rem; color: var(--fg); letter-spacing: -.015em; font-weight: 400;
}
.brand-name b { font-weight: 650; }
.brand-tagline { color: var(--faint); font-size: .76rem; }

.site-nav { display: flex; align-items: center; gap: 1.15rem; }
.site-nav a {
  font-size: .88rem; color: var(--muted); text-decoration: none;
  padding-bottom: 2px; border-bottom: 1px solid transparent;
}
.site-nav a:hover { color: var(--fg); border-bottom-color: var(--accent); }
.site-nav a[aria-current="page"] { color: var(--fg); border-bottom-color: var(--accent); }

.theme-toggle {
  display: grid; place-items: center; width: 2rem; height: 2rem;
  padding: 0; border: 1px solid var(--rule); border-radius: 6px;
  background: transparent; color: var(--muted); cursor: pointer;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
/* Every rule below is scoped to .theme-toggle so it outranks the base
   `.theme-toggle svg` declaration - a bare `.icon-moon` loses to it and both
   icons render at once. */
.theme-toggle svg { display: none; }
.theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: block; }
}

main { padding-bottom: 4rem; }

/* --------------------------------------------------------------- listing */

.post-list { display: flex; flex-direction: column; gap: 2.25rem; }

.card { display: grid; grid-template-columns: 200px 1fr; gap: 1.4rem; align-items: start; }
.card:not(:first-child) { padding-top: 2.25rem; border-top: 1px solid var(--rule); }
.card > .card-text:only-child { grid-column: 1 / -1; }

.card-media {
  display: block; overflow: hidden; border-radius: 4px;
  background: var(--code-bg); aspect-ratio: 16 / 9;
}
.card-media img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transition: transform .35s ease;
}
.card-media:hover img { transform: scale(1.03); }

.card-meta {
  color: var(--faint); font-size: .78rem; margin: 0 0 .3rem;
  letter-spacing: .01em;
}
.card-meta a { color: var(--faint); text-decoration: none; }
.card-meta a:hover { color: var(--accent); text-decoration: underline; }
.card-cats::before { content: "·"; margin: 0 .4rem; }

.card-title { font-size: 1.2rem; line-height: 1.3; margin: 0 0 .4rem; letter-spacing: -.012em; }
.card-title a { color: inherit; text-decoration: none; }
.card-title a:hover { color: var(--accent); }
.card-excerpt { margin: 0; color: var(--muted); font-size: .95rem; }

/* The most recent post leads the page, as it did in the original theme. */
.card-lead { grid-template-columns: 1fr; gap: 1.1rem; }
.card-lead .card-media { aspect-ratio: 21 / 9; border-radius: 5px; }
.card-lead .card-title { font-size: 1.95rem; line-height: 1.18; letter-spacing: -.025em; }
.card-lead .card-excerpt { font-size: 1.02rem; max-width: var(--measure); }
.card-lead + .card { padding-top: 2.25rem; border-top: 1px solid var(--rule); }

.pagination {
  display: flex; align-items: center; gap: 1rem; font-size: .88rem;
}
.pagination-bottom {
  margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--rule);
}
.pagination-top {
  margin-bottom: 2rem; padding-bottom: 1rem; border-bottom: 1px solid var(--rule);
}
.page-link.is-disabled { color: var(--rule); }
.page-of { color: var(--faint); font-variant-numeric: tabular-nums; }
.page-link { text-decoration: none; }
.page-link:hover { text-decoration: underline; }
.page-next { margin-left: auto; }

/* --------------------------------------------------------------- archive */

.archive-header { margin-bottom: 2.5rem; }
.archive-eyebrow {
  font-size: .72rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--accent); font-weight: 600; margin: 0 0 .4rem;
}
.archive-title { font-size: 1.85rem; line-height: 1.2; margin: 0; letter-spacing: -.025em; }
.archive-count { color: var(--faint); font-size: .88rem; margin: .35rem 0 0; }
.empty { color: var(--muted); }

.notfound { padding: 3rem 0 5rem; max-width: var(--measure); }
.button {
  display: inline-block; margin-top: .75rem; padding: .55rem 1.1rem;
  background: var(--accent); color: var(--bg); border-radius: 4px;
  text-decoration: none; font-size: .92rem; font-weight: 500;
}
.button:hover { color: var(--bg); opacity: .88; }

/* ----------------------------------------------------------------- entry */

.entry { max-width: var(--measure); }
.entry-header { margin-bottom: 1.75rem; }
.entry-eyebrow {
  font-size: .72rem; letter-spacing: .12em; text-transform: uppercase;
  font-weight: 600; margin: 0 0 .5rem;
}
.entry-eyebrow a { color: var(--accent); text-decoration: none; }
.entry-eyebrow a:hover { text-decoration: underline; }
.entry-eyebrow .sep { color: var(--rule); }

.entry-title { font-size: 2.15rem; line-height: 1.16; margin: 0 0 .6rem; letter-spacing: -.028em; }
.entry-meta { color: var(--faint); font-size: .87rem; margin: 0; }
.entry-meta a { color: var(--muted); }
.entry-meta time::before { content: "·"; margin: 0 .45rem; }

.entry-hero {
  margin: 0 0 2rem; border-radius: 5px; overflow: hidden; background: var(--code-bg);
}
.entry-hero img { width: 100%; display: block; }

.entry-body > *:first-child { margin-top: 0; }
.entry-body p, .entry-body ul, .entry-body ol, .entry-body blockquote { margin: 0 0 1.3rem; }
.entry-body h2 {
  font-size: 1.32rem; margin: 2.4rem 0 .75rem; letter-spacing: -.015em; line-height: 1.3;
}
.entry-body h3 { font-size: 1.1rem; margin: 1.9rem 0 .6rem; }
.entry-body ul, .entry-body ol { padding-left: 1.4rem; }
.entry-body li { margin-bottom: .4rem; }
.entry-body img { display: block; margin: 1.75rem 0; border-radius: 4px; }
.entry-body blockquote {
  border-left: 2px solid var(--accent); padding-left: 1.1rem;
  color: var(--muted); font-style: italic;
}

.entry-body pre, .entry-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .85em;
}
.entry-body code {
  background: var(--code-bg); padding: .13em .38em; border-radius: 3px;
}
.entry-body pre {
  background: var(--code-bg); padding: 1rem 1.1rem; border-radius: 5px;
  overflow-x: auto; margin: 0 0 1.3rem; line-height: 1.5;
  border: 1px solid var(--rule);
}
.entry-body pre code { background: none; padding: 0; }

.entry-body table {
  border-collapse: collapse; width: 100%; margin: 0 0 1.3rem; font-size: .92em;
}
.entry-body th, .entry-body td {
  border: 1px solid var(--rule); padding: .5rem .65rem; text-align: left;
}
.entry-body { overflow-wrap: break-word; }

.entry-footer { margin-top: 2.5rem; }
.entry-terms { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0; }
.entry-terms a {
  padding: .18rem .6rem; border: 1px solid var(--rule); border-radius: 999px;
  text-decoration: none; font-size: .8rem; color: var(--muted);
}
.entry-terms a:hover { border-color: var(--accent); color: var(--accent); }

.post-nav {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1px; background: var(--rule);
  border: 1px solid var(--rule); border-radius: 5px; overflow: hidden;
  margin-top: 3.5rem;
}
.post-nav-item {
  background: var(--surface); padding: 1rem 1.15rem; text-decoration: none;
  display: block;
}
.post-nav-item:hover { background: var(--code-bg); }
.post-nav-dir {
  display: block; font-size: .7rem; text-transform: uppercase;
  letter-spacing: .1em; color: var(--faint); margin-bottom: .25rem;
}
.post-nav-title { color: var(--fg); font-size: .95rem; line-height: 1.35; }
.post-nav-older { text-align: right; }

/* ---------------------------------------------------------------- footer */

.site-footer {
  border-top: 1px solid var(--rule); padding: 2.5rem 0 3rem;
  background: var(--surface);
}
.footer-cols {
  display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 1fr); gap: 2.5rem;
}
.footer-heading {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .12em;
  color: var(--faint); font-weight: 600; margin: 0 0 .8rem;
}
.footer-terms {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-wrap: wrap; gap: .4rem 1.5rem;
}
.footer-terms a { font-size: .9rem; text-decoration: none; color: var(--muted); }
.footer-terms a:hover { color: var(--accent); text-decoration: underline; }
.footer-terms .count {
  font-size: .72rem; color: var(--faint); font-variant-numeric: tabular-nums;
}
.colophon {
  margin: 2.5rem 0 0; padding-top: 1.25rem; border-top: 1px solid var(--rule);
  color: var(--faint); font-size: .82rem;
}

/* ------------------------------------------------------------ responsive */

@media (max-width: 46rem) {
  .card { grid-template-columns: 120px 1fr; gap: 1rem; }
  .card-lead { grid-template-columns: 1fr; }
  .card-lead .card-title { font-size: 1.55rem; }
  .card-title { font-size: 1.02rem; }
  .card-excerpt { display: none; }
  .card-lead .card-excerpt { display: block; }
  .entry-title { font-size: 1.65rem; }
  .archive-title { font-size: 1.45rem; }
  .footer-cols { grid-template-columns: 1fr; gap: 1.75rem; }
  .post-nav-older { text-align: left; }
  body { font-size: 16px; }
}

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

/* -------------------------------------------------------- archive index */

.index-list { list-style: none; padding: 0; margin: 0; }
.index-item {
  display: grid; grid-template-columns: 7.5rem 1fr; gap: 1rem;
  padding: .7rem 0; border-bottom: 1px solid var(--rule); align-items: baseline;
}
.index-item time {
  color: var(--faint); font-size: .82rem; font-variant-numeric: tabular-nums;
}
.index-item a { text-decoration: none; color: var(--fg); }
.index-item a:hover { color: var(--accent); text-decoration: underline; }

@media (max-width: 34rem) {
  .index-item { grid-template-columns: 1fr; gap: .15rem; }
}

/* ------------------------------------------------------------ breadcrumb */

.breadcrumb { font-size: .8rem; color: var(--faint); margin-bottom: 1.25rem; }
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); text-decoration: underline; }
.breadcrumb .sep { margin: 0 .4rem; color: var(--rule); }

.entry-readtime::before { content: "·"; margin: 0 .45rem; }

/* --------------------------------------------------------------- related */

.section-heading {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .12em;
  color: var(--faint); font-weight: 600; margin: 0 0 1rem;
}
.related { margin-top: 3.5rem; padding-top: 1.75rem; border-top: 1px solid var(--rule); }
.related-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 1.5rem;
}
.related-item { display: flex; flex-direction: column; gap: .5rem; text-decoration: none; }
.related-media {
  display: block; overflow: hidden; border-radius: 4px;
  background: var(--code-bg); aspect-ratio: 16 / 9;
}
.related-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.related-title { color: var(--fg); font-size: .95rem; line-height: 1.35; }
.related-item:hover .related-title { color: var(--accent); }
.related-date { color: var(--faint); font-size: .78rem; }
