/* The blog's stylesheet, served by the API at /blog/blog.css.
 *
 * ── Keep in step with apps/web/src/styles/base.css ─────────────────────────
 * The token VALUES below are copied from that file's @theme and dark-theme
 * blocks. They are duplicated rather than imported because these pages are
 * rendered by the Rust service, not by Vite, so there is no Tailwind build to
 * pull the real tokens through. base.css carries a comment pointing back here.
 * If a colour, the type stack or the rhythm changes there, change it here too;
 * nothing automated will catch the drift, and a post in last season's palette
 * is the symptom.
 *
 * Scope is deliberately small: this styles a nav, a footer, an index and an
 * article. Anything more elaborate belongs in the app, not in a second CSS
 * file maintained by hand.
 */

@font-face {
  font-family: "Archivo";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/archivo-latin-400-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Archivo";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/archivo-latin-600-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Archivo";
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url("/fonts/archivo-latin-800-normal.woff2") format("woff2");
}

:root {
  --color-bg: #faf7fb;
  --color-surface: #f0eaf4;
  --color-ink: #3a3346;
  --color-accent: #7c5cd6;
  --color-accent-200: #e2d9f8;
  --color-accent-600: #6f4ecb;
  --color-accent-700: #5b3fae;

  --font-sans: "Archivo", system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "SFMono-Regular", Menlo, Consolas, monospace;

  --divider: color-mix(in srgb, var(--color-ink) 40%, transparent);
  --divider-soft: color-mix(in srgb, var(--color-ink) 22%, transparent);
  --ink-70: color-mix(in srgb, var(--color-ink) 70%, transparent);
  --ink-60: color-mix(in srgb, var(--color-ink) 60%, transparent);

  /* The 28px leading unit and its half-step, as on every other page. */
  --leading: 28px;
  --half: 14px;
  --edge: clamp(20px, 5vw, 72px);
  --measure: 58ch;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --color-bg: #221d19;
  --color-surface: #2b2520;
  --color-ink: #ece4d6;
  --color-accent: #e07f5c;
  --color-accent-200: #4c2b1e;
  --color-accent-600: #cf7550;
  --color-accent-700: #e39a77;
}

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

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--color-bg);
  color: var(--color-ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-sans);
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: -0.015em;
  margin: 0;
}

a {
  color: var(--color-accent);
  text-underline-offset: 3px;
}

:focus {
  outline: none;
}
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

::selection {
  background: color-mix(in srgb, var(--color-accent) 30%, transparent);
}

/* ── nav ─────────────────────────────────────────────────────────────────── */
/* Same 1200px text axis and 2px seam as SiteNav.css. */
.l-nav {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px max(var(--edge), calc((100% - 1200px) / 2 + var(--edge)));
  border-bottom: 2px solid var(--divider);
}
.l-nav .brand {
  font-weight: 800;
  font-size: 20px;
  margin-right: auto;
}
.l-nav a {
  text-decoration: none;
  font-size: 14px;
  white-space: nowrap;
}
.l-nav a:not(.btn-primary) {
  color: inherit;
}
.l-nav a:not(.btn-primary):hover {
  color: var(--color-accent);
}
.l-nav .nav-links {
  display: flex;
  gap: 16px;
}
.btn-primary {
  background: var(--color-accent);
  color: var(--color-bg);
  font-weight: 800;
  font-size: 14px;
  padding: 8px 14px;
  text-decoration: none;
}
.btn-primary:hover {
  background: var(--color-accent-600);
}
.theme-toggle {
  background: transparent;
  border: 0;
  color: var(--color-ink);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 6px;
}

/* Below 760px the label row overflows; collapse to brand + toggle + CTA,
   exactly as SiteNav does. The footer is then the path to these pages. */
@media (max-width: 760px) {
  .l-nav .nav-links {
    display: none;
  }
}

@media (pointer: coarse) {
  .l-nav a,
  .site-footer a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
  }
}

/* ── page frame ──────────────────────────────────────────────────────────── */
.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: calc(2 * var(--leading)) var(--edge);
}

.rule2 {
  height: 2px;
  border: 0;
  margin: var(--leading) 0;
  background: var(--divider);
}

.kicker {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--color-accent-700);
  margin: 0 0 var(--half);
}
.kicker a {
  color: inherit;
}

.display {
  font-size: clamp(32px, 4.2vw, 52px);
  line-height: 1.08;
  letter-spacing: -0.02em;
  margin-left: -0.03em;
  max-width: 20ch;
}

.sub {
  font-size: 17px;
  line-height: var(--leading);
  max-width: var(--measure);
  margin: var(--leading) 0 0;
  color: var(--ink-70);
}

.meta {
  font-size: 13px;
  color: var(--ink-60);
  margin: var(--half) 0 0;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-note {
  margin: var(--leading) 0 0;
  font-size: 14px;
}

.tag {
  display: inline-block;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
  padding: 2px 8px;
  border: 1px solid var(--divider-soft);
  color: var(--ink-70);
  text-decoration: none;
}
a.tag:hover {
  color: var(--color-accent);
  border-color: var(--color-accent);
}

/* ── index ───────────────────────────────────────────────────────────────── */
.post-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.post-item {
  padding: var(--leading) 0;
  border-bottom: 1px solid var(--divider-soft);
}
.post-item:first-child {
  padding-top: 0;
}
.post-item h2 {
  font-size: 24px;
}
.post-item h2 a {
  color: inherit;
  text-decoration: none;
}
.post-item h2 a:hover {
  color: var(--color-accent);
}
.post-item .blurb {
  margin: var(--half) 0 0;
  max-width: var(--measure);
  color: var(--ink-70);
}
.empty {
  color: var(--ink-60);
}

/* ── article ─────────────────────────────────────────────────────────────── */
/* Text sits on the 58ch measure; code and tables are allowed to run wider,
   because a pin table or an 84-column Rust line squeezed into a text column is
   unreadable.
 *
 * The cap therefore lives on the text elements, NOT on `.prose` itself. Capping
 * the container instead makes `max-width: 100%` on a <pre> resolve to the
 * measure, which silently undoes the wider allowance and puts every code block
 * behind a horizontal scrollbar. */
.prose {
  max-width: 90ch;
  font-size: 16px;
  line-height: var(--leading);
}
.prose > p,
.prose > ul,
.prose > ol,
.prose > blockquote,
.prose > h2,
.prose > h3 {
  max-width: var(--measure);
}
.prose > * {
  margin: var(--leading) 0 0;
}
.prose > :first-child {
  margin-top: 0;
}
.prose h2 {
  font-size: 26px;
  margin-top: calc(2 * var(--leading));
}
.prose h3 {
  font-size: 19px;
  margin-top: calc(1.5 * var(--leading));
}
.prose ul,
.prose ol {
  padding-left: 22px;
}
.prose li {
  margin-top: var(--half);
}
.prose strong {
  font-weight: 600;
}
.prose blockquote {
  margin-left: 0;
  padding-left: var(--half);
  border-left: 2px solid var(--divider);
  color: var(--ink-70);
}
.prose hr {
  height: 1px;
  border: 0;
  background: var(--divider-soft);
}

/* Permalink anchors: present for anyone who wants to link a step, invisible
   until the heading is hovered or the link itself is focused. */
.prose .anchor {
  margin-left: 8px;
  text-decoration: none;
  color: var(--ink-60);
  opacity: 0;
  font-weight: 400;
}
.prose h2:hover .anchor,
.prose h3:hover .anchor,
.prose .anchor:focus-visible {
  opacity: 1;
}

.prose code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--color-surface);
  padding: 1px 5px;
}
.prose pre {
  /* Wider than the measure by design; still scrolls rather than pushing the
     page sideways when a line runs past even this. */
  max-width: 100%;
  background: var(--color-surface);
  border: 1px solid var(--divider-soft);
  padding: var(--half);
  overflow-x: auto;
}
.prose pre code {
  background: transparent;
  padding: 0;
  font-size: 13px;
  line-height: 22px;
}

/* Tables scroll inside their own box rather than pushing the page sideways. */
.prose table {
  display: block;
  overflow-x: auto;
  max-width: 100%;
  width: fit-content;
  border-collapse: collapse;
  font-size: 14px;
}
.prose th,
.prose td {
  border: 1px solid var(--divider-soft);
  padding: 6px 10px;
  text-align: left;
}
.prose th {
  font-weight: 600;
  background: var(--color-surface);
}
/* Zebra striping, not a width cap: dense rows need the horizontal guide. */
.prose tbody tr:nth-child(even) {
  background: color-mix(in srgb, var(--color-ink) 4%, transparent);
}

.prose img {
  display: block;
  max-width: 100%;
}

.post-foot {
  max-width: var(--measure);
  font-size: 15px;
  color: var(--ink-70);
}

/* ── footer ──────────────────────────────────────────────────────────────── */
.site-footer {
  max-width: 1200px;
  margin: 0 auto;
  padding: calc(2 * var(--leading)) var(--edge);
  font-size: 13px;
  line-height: var(--leading);
  color: var(--ink-70);
}
.site-footer .footer-links {
  margin-left: var(--half);
}
.site-footer .footer-links a {
  color: var(--ink-70);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.site-footer .footer-links a:hover {
  color: var(--color-ink);
}
