/* Bird Nerds — the whole stylesheet.
 *
 * One file, no build step, no framework. Written to be read: tokens first,
 * then layout, then components in the order a page uses them.
 *
 * The palette is flat white in light mode with hairline rules doing the
 * structural work, and forest green in dark mode. The accent green is for
 * links and marks only; it is too loud for a surface.
 *
 * Adding a component? Put its rules under a comment banner at the bottom and
 * use the tokens. Do not introduce a hex value outside :root.
 */

/* ── Tokens ─────────────────────────────────────────────────────────── */

:root {
  color-scheme: light dark;

  --ink:        #132800;  /* body text, brand green */
  --ink-soft:   #4a5a3e;  /* secondary text */
  --ink-faint:  #6f7d64;  /* timestamps, counts */
  --bg:         #ffffff;
  --bg-sunk:    #f7f9f5;  /* cards, code blocks */
  --line:       #e3e8de;  /* hairlines carry the structure */
  --line-soft:  #eef1ea;
  --accent:     #2f7a3a;  /* links: the deep green reads on white */
  --accent-ink: #ffffff;
  --warn-bg:    #fff6e0;
  --warn-ink:   #6b4d05;

  --wrap: 68rem;
  --prose: 40rem;

  --radius: 12px;
  --radius-sm: 999px;

  --step-0: 1rem;
  --step-1: 1.15rem;
  --step-2: 1.45rem;
  --step-3: 1.9rem;
  --step-4: clamp(2rem, 1.4rem + 2.6vw, 3.1rem);

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --font-prose: ui-serif, Georgia, "Iowan Old Style", "Times New Roman", serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink:        #eaf3e4;
    --ink-soft:   #b6c7ad;
    --ink-faint:  #8b9c83;
    --bg:         #071304;
    --bg-sunk:    #0f2109;
    --line:       #1e3614;
    --line-soft:  #16290f;
    --accent:     #5de271;  /* the bright green only works on forest */
    --accent-ink: #071304;
    --warn-bg:    #2a2205;
    --warn-ink:   #f4dfa0;
  }
}

/* ── Base ───────────────────────────────────────────────────────────── */

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: var(--step-0)/1.65 var(--font);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

h1, h2, h3, h4 { line-height: 1.2; text-wrap: balance; margin: 0 0 .5rem; }
p { margin: 0 0 1rem; }
img { max-width: 100%; height: auto; display: block; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

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

code, pre, kbd { font-family: var(--font-mono); font-size: .9em; }

.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: 1.25rem; }
main.wrap { flex: 1; padding-block: 2.5rem 4rem; }

.muted { color: var(--ink-faint); }
.dot { margin-inline: .4rem; color: var(--ink-faint); }
.eyebrow { font-size: .85rem; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: .35rem; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--accent); color: var(--accent-ink);
  padding: .6rem 1rem; border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { left: 0; }

.section-label {
  font-size: .8rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-faint); font-weight: 600;
  margin: 0 0 1rem; padding-bottom: .5rem; border-bottom: 1px solid var(--line);
}

/* ── Header ─────────────────────────────────────────────────────────── */

.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  position: sticky; top: 0; z-index: 20;
}
.header-row {
  display: flex; align-items: center; gap: 1.5rem;
  flex-wrap: wrap; padding-block: .9rem;
}
.brand {
  display: inline-flex; align-items: center; gap: .55rem;
  color: var(--ink); text-decoration: none; font-weight: 700;
  font-size: var(--step-1); letter-spacing: -.01em;
}
/* The feather mark. It is an alpha silhouette, so it is used as a mask and
 * painted with currentColor rather than shipping one bitmap per theme. The
 * @supports guard means a browser without mask support shows nothing here
 * instead of a solid green block. */
.brand-mark {
  display: block;
  width: 0.78em;
  height: 1.22em;
  flex-shrink: 0;
  color: var(--accent);
  -webkit-mask-image: var(--logo-mask); mask-image: var(--logo-mask);
  -webkit-mask-repeat: no-repeat;      mask-repeat: no-repeat;
  -webkit-mask-position: center;       mask-position: center;
  -webkit-mask-size: contain;          mask-size: contain;
}
@supports (mask-image: url("")) or (-webkit-mask-image: url("")) {
  .brand-mark { background-color: currentColor; }
}
.brand:hover .brand-name { text-decoration: underline; text-underline-offset: 3px; }

.site-nav { display: flex; align-items: center; gap: 1.15rem; margin-left: auto; flex-wrap: wrap; }
.site-nav a { color: var(--ink-soft); text-decoration: none; font-size: .95rem; }
.site-nav a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }

.nav-search input {
  font: inherit; font-size: .9rem;
  padding: .35rem .7rem; width: 9rem;
  color: var(--ink); background: var(--bg-sunk);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.nav-search input::placeholder { color: var(--ink-faint); }
.nav-search input:focus { width: 12rem; }

/* ── Hero ───────────────────────────────────────────────────────────── */

.hero { padding-block: 1rem 2.5rem; border-bottom: 1px solid var(--line); margin-bottom: 2.5rem; }
.hero-title { font-size: var(--step-4); letter-spacing: -.02em; margin-bottom: .25rem; }
.hero-tagline { font-size: var(--step-1); color: var(--ink-soft); max-width: 36rem; margin: 0; }

/* ── Featured ───────────────────────────────────────────────────────── */

.featured { margin-bottom: 3rem; }
.feature { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--bg); }
.feature-cover img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.feature-body { padding: 1.5rem; }
.feature-title { font-size: var(--step-3); letter-spacing: -.015em; }
.feature-title a { color: var(--ink); text-decoration: none; }
.feature-title a:hover { text-decoration: underline; text-underline-offset: 3px; }
.feature-summary { color: var(--ink-soft); font-size: var(--step-1); max-width: 46rem; }

/* ── Cards ──────────────────────────────────────────────────────────── */

.card-grid {
  display: grid; gap: 1.75rem;
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
}
.card { display: flex; flex-direction: column; gap: .85rem; min-width: 0; }
.card-cover img {
  width: 100%; aspect-ratio: 16 / 9; object-fit: cover;
  border-radius: var(--radius); border: 1px solid var(--line);
}
.card-body { display: flex; flex-direction: column; gap: .5rem; }
.card-meta { font-size: .82rem; color: var(--ink-faint); margin: 0; display: flex; align-items: center; flex-wrap: wrap; }
.card-title { font-size: var(--step-2); letter-spacing: -.01em; margin: 0; }
.card-title a { color: var(--ink); text-decoration: none; }
.card-title a:hover { text-decoration: underline; text-underline-offset: 3px; }
.card-summary { color: var(--ink-soft); margin: 0; font-size: .95rem; }

.pill {
  display: inline-block; margin-left: .5rem; padding: .1rem .5rem;
  border-radius: var(--radius-sm); font-size: .72rem; font-weight: 600;
  letter-spacing: .03em; text-transform: uppercase;
}
.pill-warn { background: var(--warn-bg); color: var(--warn-ink); }

.tag-pills { display: flex; flex-wrap: wrap; gap: .4rem; list-style: none; padding: 0; margin: 0; }
.tag-pills a {
  display: inline-block; padding: .15rem .6rem;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-size: .78rem; color: var(--ink-soft); text-decoration: none;
}
.tag-pills a:hover { border-color: var(--accent); color: var(--accent); }

/* ── Post ───────────────────────────────────────────────────────────── */

.post { max-width: var(--prose); margin-inline: auto; }
.post-header { margin-bottom: 2rem; }
.post-header .tag-pills { margin-bottom: .9rem; }
.post-title { font-size: var(--step-4); letter-spacing: -.025em; margin-bottom: .6rem; }
.post-summary { font-size: var(--step-1); color: var(--ink-soft); margin-bottom: 1.5rem; }
.post-meta {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding-block: 1rem; border-block: 1px solid var(--line);
}
.post-dates { margin: 0; font-size: .85rem; color: var(--ink-faint); margin-left: auto; text-align: right; }

.byline { display: inline-flex; align-items: center; gap: .6rem; color: var(--ink); text-decoration: none; font-weight: 600; font-size: .92rem; }
.byline:hover { text-decoration: underline; text-underline-offset: 3px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: var(--bg-sunk); }
.avatar-fallback {
  display: grid; place-items: center; font-weight: 700;
  color: var(--accent-ink); background: var(--accent);
}
.avatar-lg { width: 88px; height: 88px; }

.post-cover { margin: 0 0 2rem; }
.post-cover img { width: 100%; border-radius: var(--radius); border: 1px solid var(--line); }
.post-cover figcaption { font-size: .82rem; color: var(--ink-faint); margin-top: .5rem; }

.preview-banner {
  max-width: var(--prose); margin: 0 auto 2rem;
  background: var(--warn-bg); color: var(--warn-ink);
  border-radius: var(--radius); padding: .75rem 1rem; font-size: .9rem;
}

/* ── Prose (rendered markdown) ──────────────────────────────────────── */

.prose {
  font-family: var(--font-prose);
  font-size: 1.1rem;
  line-height: 1.75;
  max-width: var(--prose);
  margin-inline: auto;
}
.prose > * + * { margin-top: 1.25rem; }
.prose h2 {
  font-family: var(--font); font-size: var(--step-2); letter-spacing: -.01em;
  margin-top: 2.75rem; padding-top: .5rem;
}
.prose h3 { font-family: var(--font); font-size: var(--step-1); margin-top: 2rem; }
.prose ul, .prose ol { padding-left: 1.4rem; }
.prose li + li { margin-top: .4rem; }
.prose img { border-radius: var(--radius); border: 1px solid var(--line); }
.prose figcaption { font-family: var(--font); font-size: .85rem; color: var(--ink-faint); margin-top: .5rem; }
.prose blockquote {
  margin-inline: 0; padding: .25rem 0 .25rem 1.25rem;
  border-left: 3px solid var(--accent); color: var(--ink-soft); font-style: italic;
}
.prose hr { border: 0; border-top: 1px solid var(--line); margin-block: 2.5rem; }
.prose code { background: var(--bg-sunk); padding: .1em .35em; border-radius: 5px; }
.prose pre {
  background: var(--bg-sunk); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem; overflow-x: auto; line-height: 1.5;
}
.prose pre code { background: none; padding: 0; }
.prose table { width: 100%; border-collapse: collapse; font-family: var(--font); font-size: .95rem; display: block; overflow-x: auto; }
.prose th, .prose td { text-align: left; padding: .55rem .75rem; border-bottom: 1px solid var(--line); }
.prose th { font-weight: 600; }
.prose .footnote { font-size: .9rem; color: var(--ink-soft); }

.author-note {
  display: flex; flex-direction: column; gap: .6rem;
  margin-top: 3rem; padding: 1.25rem;
  background: var(--bg-sunk); border-radius: var(--radius); border: 1px solid var(--line);
}
.author-note p { margin: 0; font-size: .92rem; color: var(--ink-soft); }

/* ── Post navigation & related ──────────────────────────────────────── */

.post-nav {
  display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  max-width: var(--prose); margin: 3rem auto 0;
  padding-top: 1.5rem; border-top: 1px solid var(--line);
}
.post-nav-link {
  display: flex; flex-direction: column; gap: .25rem;
  padding: .9rem 1rem; border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--ink); text-decoration: none; font-weight: 600; font-size: .95rem;
}
.post-nav-link:hover { border-color: var(--accent); }
.post-nav-link .muted { font-weight: 400; font-size: .8rem; }
.post-nav-link.is-next { text-align: right; }

.related { margin-top: 4rem; }

/* ── Lists & archives ───────────────────────────────────────────────── */

.page-head { margin-bottom: 2.5rem; padding-bottom: 1.5rem; border-bottom: 1px solid var(--line); }
.page-head h1 { font-size: var(--step-4); letter-spacing: -.02em; }
.page-lede { font-size: var(--step-1); color: var(--ink-soft); max-width: 42rem; margin-bottom: .5rem; }
.author-head { display: flex; gap: 1.5rem; align-items: flex-start; flex-wrap: wrap; }

.year-group { margin-bottom: 2.5rem; }
.post-list { list-style: none; padding: 0; margin: 0; }
.post-list li {
  display: flex; gap: 1rem; align-items: baseline;
  padding-block: .7rem; border-bottom: 1px solid var(--line-soft);
}
.post-list time { flex: 0 0 4.5rem; font-size: .82rem; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.post-list a { color: var(--ink); text-decoration: none; font-weight: 500; }
.post-list a:hover { text-decoration: underline; text-underline-offset: 3px; }
.post-list .muted { margin-left: auto; font-size: .8rem; white-space: nowrap; }

.topic-grid {
  list-style: none; padding: 0; margin: 0;
  display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
}
.topic { border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; }
.topic h2 { font-size: var(--step-1); margin-bottom: .35rem; }
.topic h2 a { color: var(--ink); text-decoration: none; }
.topic h2 a:hover { color: var(--accent); }
.topic p { font-size: .9rem; color: var(--ink-soft); margin-bottom: .35rem; }
.author-card { display: flex; flex-direction: column; gap: .6rem; }

/* ── Search ─────────────────────────────────────────────────────────── */

.search-form { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1rem; }
.search-form input {
  flex: 1 1 16rem; font: inherit; padding: .6rem .9rem;
  color: var(--ink); background: var(--bg-sunk);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.search-form button {
  font: inherit; font-weight: 600; padding: .6rem 1.4rem; cursor: pointer;
  color: var(--accent-ink); background: var(--accent);
  border: 1px solid var(--accent); border-radius: var(--radius-sm);
}
.search-form button:hover { filter: brightness(1.08); }

/* ── Empty states & pagination ──────────────────────────────────────── */

.empty {
  border: 1px dashed var(--line); border-radius: var(--radius);
  padding: 2rem; text-align: center; color: var(--ink-soft);
}
.empty pre { display: inline-block; text-align: left; background: var(--bg-sunk); padding: .75rem 1rem; border-radius: 8px; }
.empty-lg { padding-block: 5rem; border: 0; }
.empty-lg h1 { font-size: var(--step-4); color: var(--ink); }

.pagination {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--line);
  font-size: .92rem;
}
.page-link { color: var(--ink); text-decoration: none; font-weight: 600; }
.page-link:hover { color: var(--accent); }
.page-link.is-off { color: var(--ink-faint); font-weight: 400; }
.page-count { color: var(--ink-faint); }

/* ── Footer ─────────────────────────────────────────────────────────── */

.site-footer { border-top: 1px solid var(--line); margin-top: auto; }
.footer-row { padding-block: 2rem 3rem; display: flex; flex-direction: column; gap: .75rem; }
.footer-blurb { color: var(--ink-soft); max-width: 34rem; margin: 0; }
.footer-nav { display: flex; flex-wrap: wrap; gap: 1rem; font-size: .9rem; }
.footer-nav a { color: var(--ink-soft); text-decoration: none; }
.footer-nav a:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.footer-legal { font-size: .82rem; color: var(--ink-faint); margin: 0; }

/* ── Narrow screens ─────────────────────────────────────────────────── */

@media (max-width: 40rem) {
  .header-row { gap: .75rem; }
  .site-nav { gap: .9rem; width: 100%; margin-left: 0; }
  .nav-search { margin-left: auto; }
  .nav-search input, .nav-search input:focus { width: 7.5rem; }
  .post-meta { flex-direction: column; align-items: flex-start; gap: .6rem; }
  .post-dates { margin-left: 0; text-align: left; }
  .prose { font-size: 1.05rem; }
  .post-nav-link.is-next { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media print {
  .site-header, .site-footer, .post-nav, .related, .pagination { display: none; }
  body { color: #000; background: #fff; }
  .prose { max-width: none; }
}
