/**
 * Blog styles.
 *
 * Served as a static file by nginx and linked from the server-rendered blog
 * pages. Self-contained: the SSR blog does not load the SPA bundle, so tokens
 * are declared here rather than imported.
 */

:root {
  --bg: #fefdf8;
  --surface: #ffffff;
  --surface-alt: #f7f5ec;
  --text: #111111;
  --text-muted: #5c5c5c;
  --border: #e8e4d6;
  --brand: #ffd700;
  --brand-deep: #b8860b;
  --on-brand: #111111;
  --r: 12px;
  --font: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-logo: 'Pixelify Sans', var(--font);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0f0f0f;
    --surface: #1a1a1a;
    --surface-alt: #242424;
    --text: #f5f5f5;
    --text-muted: #a3a3a3;
    --border: #2e2e2e;
  }
}

:root[data-theme='dark'] {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --surface-alt: #242424;
  --text: #f5f5f5;
  --text-muted: #a3a3a3;
  --border: #2e2e2e;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}

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

a {
  color: inherit;
}

/* ── layout ────────────────────────────────────────────────────────────── */

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 40px 24px 0;
}

.page-head {
  margin-bottom: 34px;
}

.page-head h1 {
  font-size: clamp(30px, 5vw, 42px);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 0 0 8px;
}

.page-head p {
  color: var(--text-muted);
  margin: 0 0 20px;
  font-size: 17px;
}

.search {
  display: flex;
  gap: 8px;
  max-width: 420px;
}

.search input {
  flex: 1;
  font: inherit;
  font-size: 14.5px;
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

.search button {
  font: inherit;
  font-weight: 650;
  font-size: 14px;
  padding: 10px 18px;
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  color: var(--on-brand);
  cursor: pointer;
}

.result-count {
  color: var(--text-muted);
  font-size: 14px;
  margin: 0 0 18px;
}

/* ── cards ─────────────────────────────────────────────────────────────── */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  transition: border-color 0.15s, transform 0.15s;
}

.card:hover {
  border-color: var(--brand);
  transform: translateY(-2px);
}

.card a {
  display: block;
  padding: 20px;
  text-decoration: none;
}

.card h2 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 8px;
  line-height: 1.35;
}

.card p {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0 0 12px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card__meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.tag {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
  text-transform: capitalize;
}

/* ── topics ────────────────────────────────────────────────────────────── */

.topics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 0 auto 34px;
  max-width: 900px;
}

.topic {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  text-transform: capitalize;
  transition: border-color 0.15s, background 0.15s;
}

.topic:hover {
  border-color: var(--brand);
}

.topic span {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--surface-alt);
  border-radius: 999px;
  padding: 1px 7px;
}

.topic--on {
  background: var(--brand);
  border-color: var(--brand);
  color: #14110a;
}

.topic--on span {
  background: rgba(0, 0, 0, 0.16);
  color: #14110a;
}

/* ── pagination ────────────────────────────────────────────────────────── */

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 48px auto 0;
  font-size: 14px;
}

.pager__nums {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pager__n,
.pager__step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font-weight: 650;
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
}

.pager__n:hover,
.pager__step:hover {
  border-color: var(--brand);
}

.pager__n--on,
.pager__n--on:hover {
  background: var(--brand);
  border-color: var(--brand);
  color: #14110a;
}

/* Rendered as a span, not a link — nothing to navigate to. */
.pager__step--off {
  opacity: 0.4;
  cursor: default;
}

.pager__step--off:hover {
  border-color: var(--border);
}

.pager__gap {
  padding: 0 4px;
  color: var(--text-muted);
}

.pager__count {
  margin: 12px 0 0;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

@media (max-width: 560px) {
  /* Numbers stay; the word labels are what overflow first. */
  .pager__step {
    font-size: 0;
    padding: 0;
    min-width: 38px;
  }

  .pager__step::after {
    font-size: 15px;
  }

  .pager__step[rel='prev']::after,
  .pager__step--off:first-child::after {
    content: '←';
  }

  .pager__step[rel='next']::after,
  .pager__step--off:last-child::after {
    content: '→';
  }
}

/* ── article ───────────────────────────────────────────────────────────── */

.article {
  max-width: 760px;
  margin-left: auto;
  margin-right: auto;
}

.crumbs {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 22px;
}

.crumbs a {
  text-decoration: none;
  text-transform: capitalize;
}

.crumbs a:hover {
  text-decoration: underline;
}

.crumbs span {
  margin: 0 6px;
  opacity: 0.5;
}

.article-head h1 {
  font-size: clamp(28px, 4.5vw, 40px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin: 0 0 12px;
}

.article-meta {
  display: flex;
  gap: 14px;
  font-size: 13.5px;
  color: var(--text-muted);
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 30px;
}

.draft-note {
  background: #fef3c7;
  color: #92400e;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  display: inline-block;
  margin: 0 0 14px;
}

/* Article body. ~68ch measure keeps lines comfortably readable. */
.prose {
  font-size: 17px;
  line-height: 1.75;
}

.prose > * {
  max-width: 68ch;
}

.prose h2 {
  font-size: 25px;
  font-weight: 750;
  letter-spacing: -0.02em;
  margin: 40px 0 14px;
  scroll-margin-top: 20px;
}

.prose h3 {
  font-size: 20px;
  font-weight: 700;
  margin: 30px 0 10px;
}

.prose p {
  margin: 0 0 20px;
}

.prose ul,
.prose ol {
  margin: 0 0 20px;
  padding-left: 24px;
}

.prose li {
  margin-bottom: 8px;
}

.prose a {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--brand);
  text-decoration-thickness: 2px;
  text-underline-offset: 2px;
}

.prose img {
  border-radius: var(--r);
  margin: 26px 0;
}

.prose blockquote {
  border-left: 3px solid var(--brand);
  padding-left: 18px;
  margin: 26px 0;
  color: var(--text-muted);
  font-style: italic;
}

.prose code {
  background: var(--surface-alt);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
  font-family: ui-monospace, monospace;
}

.prose pre {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px;
  overflow-x: auto;
  margin: 26px 0;
}

.prose pre code {
  background: none;
  padding: 0;
}

.prose hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 36px 0;
}

/* Wide tables scroll inside their own container rather than the page. */
.table-scroll {
  overflow-x: auto;
  margin: 26px 0;
  max-width: 100%;
}

.prose table {
  border-collapse: collapse;
  font-size: 14.5px;
  min-width: 100%;
}

.prose th,
.prose td {
  border: 1px solid var(--border);
  padding: 9px 13px;
  text-align: left;
}

.prose th {
  background: var(--surface-alt);
  font-weight: 700;
}

/* ── conversion ────────────────────────────────────────────────────────── */

.cta-box {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand);
  border-radius: var(--r);
  padding: 26px;
  /* Vertical only — `margin: Xpx 0` would override .wrap's `0 auto` and push
     the box flush left. */
  margin-top: 46px;
  margin-bottom: 46px;
}

.cta-box h2 {
  font-size: 20px;
  font-weight: 750;
  margin: 0 0 8px;
}

.cta-box p {
  color: var(--text-muted);
  margin: 0 0 16px;
  font-size: 15px;
}

.related {
  margin-top: 56px;
  padding-top: 34px;
  border-top: 1px solid var(--border);
}

.related h2 {
  font-size: 20px;
  font-weight: 750;
  margin: 0 0 18px;
  text-transform: capitalize;
}

.empty {
  text-align: center;
  padding: 70px 24px;
}

.empty h1,
.empty h2 {
  font-size: 26px;
  margin: 0 0 10px;
}

.empty p {
  color: var(--text-muted);
  margin: 0 0 18px;
}

@media (max-width: 640px) {
  .wrap {
    padding: 28px 18px 0;
  }
  .prose {
    font-size: 16px;
  }
}

/* ── card cover images ─────────────────────────────────────────────────── */

.card a {
  padding: 0;
}

.card__img {
  aspect-ratio: 16 / 9;
  background: var(--surface-alt);
  overflow: hidden;
  border-radius: var(--r) var(--r) 0 0;
}

.card__img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s;
}

.card:hover .card__img img {
  transform: scale(1.03);
}

.card__body {
  padding: 18px 20px 20px;
}

/* ── tools from an article ─────────────────────────────────────────────── */
/* The blog carries real authority and was spending nearly all of it on other
   blog posts. This is the link into the pages that need it. */

.article-tools {
  max-width: 760px;
  margin: 48px auto 0;
}

.article-tools h2 {
  font-size: 22px;
  font-weight: 750;
  letter-spacing: -0.02em;
  margin: 0 0 18px;
}

.article-tools .tgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
}

.article-tools .tcard {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  text-decoration: none;
  transition: transform 0.15s, border-color 0.15s;
}

.article-tools .tcard:hover {
  transform: translateY(-2px);
  border-color: var(--brand);
}

.article-tools .tcard__img {
  aspect-ratio: 16 / 10;
  background: var(--surface-alt);
  overflow: hidden;
}

.article-tools .tcard__img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.article-tools .tcard__body {
  padding: 12px 14px 14px;
}

.article-tools .tcard__body h3 {
  font-size: 14.5px;
  font-weight: 700;
  margin: 0 0 4px;
}

.article-tools .tcard__body p {
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text-muted);
  margin: 0;
}
