/* ====================================================================
 * modolab site — blog (index + articles)
 * The quiet room of the site: chalk ground, no mesh, so the writing,
 * the illustrations and the imagery carry the page. Same type system,
 * chrome and hard-square corners as the rest of the site.
 * Pages are generated by scripts/blog/build.mjs; this file is not.
 * ================================================================== */
:root {
  --ground: #F5F5F5;
  --ink: #16150f;
  --text: #2c2b25;     /* long-form body: a touch off ink, easier over length */
  --soft: #5d5a52;
  --faint: #8a877e;
  --accent: #ff5a1e;
  --line: rgba(22, 21, 15, 0.12);
  --line-strong: rgba(22, 21, 15, 0.24);
  --surface: #ffffff;
  --pad-x: clamp(20px, 4.5vw, 64px);
  --wide: 1320px;
  --measure: 640px; /* ~70 characters at the article's 17px */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
/* anchors land clear of the sticky bar (60–72px), with room to breathe */
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 100px; }
body {
  font-family: "Geist", system-ui, sans-serif;
  font-weight: 400;
  color: var(--ink);
  background: var(--ground);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
::selection { background: var(--accent); color: #fff; }
a { color: inherit; text-decoration: none; }
img, video, svg { display: block; max-width: 100%; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.icon { width: 16px; height: 16px; flex-shrink: 0; }

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 300;
  padding: 10px 14px;
  background: var(--ink);
  color: #fff;
  font: 500 12px "Geist Mono", monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.skip-link:focus { top: 12px; }
.blog-main:focus { outline: none; }

/* arrival: content settles in, as on the legal pages */
.page-in { animation: pageIn 0.7s var(--ease-out) both; }
@keyframes pageIn {
  from { opacity: 0; transform: translateY(14px); }
}

/* preview builds only: says plainly this page won't ship */
.draft-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 9px var(--pad-x);
  background: var(--ink);
  color: rgba(255, 255, 255, 0.82);
  font: 400 11px "Geist Mono", monospace;
  letter-spacing: 0.06em;
  text-align: center;
}
.draft-bar span, .status-chip {
  font: 500 10px "Geist Mono", monospace;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #fff;
  background: var(--accent);
  padding: 3px 7px;
}
/* unlisted: live, just not advertised — a hairline, not an alarm */
.status-chip--quiet {
  color: var(--soft);
  background: none;
  box-shadow: inset 0 0 0 1px var(--line-strong);
}

/* ---------- Top bar: nav left · logomark centre · CTA right ---------- */
/* stays put while the page scrolls, as on the main site: the page runs
   under it and cuts hard at the bar's edge */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 20px var(--pad-x);
  background: var(--ground);
}
.topbar nav {
  display: flex;
  gap: clamp(18px, 3vw, 40px);
  justify-self: start;
}
.topbar nav a {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  position: relative;
  padding: 4px 0;
}
/* underline sweeps in from the left, as on the main site */
.topbar nav a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -3px;
  width: 100%;
  height: 1.5px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left;
  opacity: 0.35;
  transition: transform 0.5s var(--ease-out), opacity 0.3s ease;
}
.topbar nav a:hover::after { transform: scaleX(1); }
.topbar nav a.active::after { transform: scaleX(1); opacity: 1; }
.logomark { justify-self: center; display: block; line-height: 0; }
.logomark svg { height: 26px; width: auto; }
.lm-ink { fill: #242424; }
.lm-accent { fill: var(--accent); }
.top-cta {
  justify-self: end;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 4px 0;
  border-bottom: 1.5px solid var(--line-strong);
  transition: border-color 0.3s ease;
}
.top-cta:hover { border-color: currentColor; }
.menu-burger {
  display: none;
  justify-self: end;
  color: var(--ink);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}
.menu-burger svg { width: 24px; height: 24px; }

.blog-main { flex: 1 0 auto; }

/* ---------- Shared type ---------- */
.eyebrow {
  font: 500 11px "Geist Mono", monospace;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 10px;
}
.eyebrow::before { content: ""; width: 22px; height: 1px; background: currentColor; }
.text-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: 500 11px "Geist Mono", monospace;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 4px 0;
  border-bottom: 1.5px solid var(--line-strong);
  transition: border-color 0.3s ease;
}
.text-link:hover { border-color: currentColor; }
.text-link .icon { width: 14px; height: 14px; }

/* ====================================================================
 * Index — the selection screen
 * ================================================================== */
.blog-wrap {
  max-width: var(--wide);
  margin: 0 auto;
  padding: clamp(28px, 7vh, 88px) var(--pad-x) clamp(64px, 10vh, 120px);
}
.blog-head {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding-bottom: clamp(28px, 5vh, 48px);
}
.blog-title {
  font-size: clamp(34px, 4.4vw, 62px);
  font-weight: 300;
  line-height: 1.05;
  letter-spacing: -0.035em;
  max-width: 17em;
  text-wrap: balance;
}

/* type filters: mono tabs on a hairline, between the lead and the grid */
.blog-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 28px;
  margin-bottom: clamp(28px, 5vh, 48px);
  border-bottom: 1px solid var(--line);
}
.blog-filters[hidden] { display: none; }
.blog-filters button {
  font: 500 11px "Geist Mono", monospace;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
  background: none;
  border: none;
  padding: 12px 0;
  margin-bottom: -1px;
  border-bottom: 1.5px solid transparent;
  cursor: pointer;
  transition: color 0.3s ease, border-color 0.3s ease;
}
.blog-filters button span { color: var(--faint); margin-left: 4px; }
.blog-filters button:hover { color: var(--ink); }
.blog-filters button[aria-pressed="true"] { color: var(--ink); border-color: var(--ink); }

.blog-empty {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 20px;
  padding: clamp(32px, 8vh, 80px) 0;
  border-top: 1px solid var(--line);
}
.blog-empty p { font-size: clamp(18px, 2vw, 22px); color: var(--soft); }

/* ---------- Cards ---------- */
.post-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(36px, 5vh, 56px) clamp(20px, 2.4vw, 36px);
}
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.card[hidden] { display: none; }
.card-media {
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--ground);
  outline: 1px solid var(--line);
  outline-offset: -1px;
}
.card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 1.1s var(--ease-out);
}
.card:hover .card-media img { transform: scale(1.02); }
/* no cover yet: the logomark, quiet, on white */
.card-blank {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  background: var(--surface);
}
.card-blank svg { width: 22%; height: auto; opacity: 0.14; }
.card-blank .lm-accent { opacity: 0.9; fill: var(--accent); }
.card-blank .lm-ink { fill: var(--ink); }

.card-body { display: flex; flex-direction: column; gap: 10px; }
.card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  font: 500 10.5px "Geist Mono", monospace;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
}
.card-title {
  font-size: clamp(19px, 1.6vw, 22px);
  font-weight: 400;
  line-height: 1.25;
  letter-spacing: -0.02em;
  text-wrap: balance;
}
.card-title a {
  text-decoration: underline;
  text-decoration-color: transparent;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 4px;
  transition: text-decoration-color 0.3s ease;
}
/* the title is the link; its hit area stretches over the whole card */
.card-title a::after { content: ""; position: absolute; inset: 0; }
.card:hover .card-title a { text-decoration-color: var(--line-strong); }
.card-title a:focus-visible { outline: none; }
.card:has(.card-title a:focus-visible) { outline: 2px solid var(--accent); outline-offset: 6px; }

/* the lead: newest post (or the pinned one), above the filters and
   outside the grid, so filtering never touches it */
.blog-lead { padding-bottom: clamp(36px, 5vh, 56px); }
.card.is-lead {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  align-items: center;
  gap: clamp(24px, 4vw, 64px);
}
.card.is-lead .card-body { gap: 14px; }
.card.is-lead .card-title {
  font-size: clamp(28px, 3.1vw, 44px);
  font-weight: 300;
  line-height: 1.08;
  letter-spacing: -0.03em;
}

/* ====================================================================
 * Article
 * ================================================================== */
.post { padding: clamp(24px, 6vh, 72px) var(--pad-x) 0; }
.post-head {
  max-width: 880px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
/* the way back: over the title column, or the cover's edge when it leads */
.post-top { max-width: 880px; margin: 0 auto; }
.post-top--wide { max-width: 1040px; }
.post-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: 500 11px "Geist Mono", monospace;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: clamp(8px, 3vh, 28px);
  transition: color 0.3s ease;
}
.post-back:hover { color: var(--ink); }
.post-back .icon { width: 14px; height: 14px; transition: transform 0.4s var(--ease-out); }
.post-back:hover .icon { transform: translateX(-3px); }
.post-kicker { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.post-title {
  font-size: clamp(36px, 5.2vw, 70px);
  font-weight: 300;
  line-height: 1.03;
  letter-spacing: -0.04em;
  text-wrap: balance;
}
.post-standfirst {
  font-size: clamp(18px, 1.8vw, 22px);
  line-height: 1.5;
  color: var(--soft);
  max-width: 36em;
  text-wrap: pretty;
}
/* author(s) and reading time, straight under the standfirst */
/* date · author · read time, one line under the title */
.post-byline {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 0;
  font: 400 11px "Geist Mono", monospace;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
}
.post-byline > span + span::before { content: "·"; margin: 0 10px; color: var(--faint); }
.post-byline .post-author { color: var(--ink); }

/* the cover leads the article, above the title block, at the width of
   the figures below. It's cropped 21:9 from the card's 16:9 image, so one
   image serves both and the title stays near the fold. */
.post-cover {
  max-width: 1040px;
  margin: 0 auto clamp(32px, 6vh, 64px);
}
.post-cover img {
  width: 100%;
  height: auto;
  aspect-ratio: 21 / 9;
  object-fit: cover;
  object-position: 50% 50%; /* crop evenly from every edge: the centre holds */
  outline: 1px solid var(--line);
  outline-offset: -1px;
}

/* ---------- Prose ---------- */
.prose {
  max-width: var(--measure);
  margin: clamp(40px, 7vh, 72px) auto 0;
  /* a step up from the site's 16px body for long reads, on the same 1.6
     leading, so articles read as the same system rather than a looser one */
  font-size: clamp(16px, 1.2vw, 17px);
  line-height: 1.6;
  color: var(--text);
}
.prose > * + * { margin-top: 1em; }
.prose h2 {
  font-size: clamp(25px, 2.4vw, 32px);
  font-weight: 300;
  line-height: 1.15;
  letter-spacing: -0.03em;
  color: var(--ink);
  margin-top: 2.2em;
  text-wrap: balance;
}
.prose h3 {
  font-size: 19px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.015em;
  color: var(--ink);
  margin-top: 1.9em;
}
.prose h2 + *, .prose h3 + * { margin-top: 0.6em; }
.prose strong { font-weight: 600; color: var(--ink); }
.prose a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
  transition: color 0.2s ease;
}
.prose a:hover { color: var(--accent); }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li + li { margin-top: 0.45em; }
.prose li::marker { color: var(--faint); font-family: "Geist Mono", monospace; font-size: 0.85em; }
.prose blockquote {
  border-left: 2px solid var(--accent);
  padding: 2px 0 2px 24px;
  font-size: clamp(21px, 2vw, 26px);
  font-weight: 300;
  line-height: 1.4;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.prose hr { border: 0; border-top: 1px solid var(--line-strong); margin: 2.4em 0; }
.prose code {
  font: 400 0.84em "Geist Mono", monospace;
  background: rgba(22, 21, 15, 0.06);
  padding: 2px 5px;
}
.prose pre {
  background: var(--surface);
  outline: 1px solid var(--line);
  outline-offset: -1px;
  padding: 18px 22px;
  overflow-x: auto;
  font-size: 14px;
  line-height: 1.65;
}
.prose pre code { background: none; padding: 0; font-size: inherit; }
.table-scroll { overflow-x: auto; }
.prose table { width: 100%; min-width: 480px; border-collapse: collapse; font-size: 15px; }
.prose th {
  font: 500 10.5px "Geist Mono", monospace;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: left;
  color: var(--faint);
  padding: 0 16px 10px 0;
  border-bottom: 1px solid var(--line-strong);
}
.prose td { padding: 11px 16px 11px 0; border-bottom: 1px solid var(--line); vertical-align: top; }

/* figures step out of the text column: the imagery gets the room */
.post-media {
  width: min(1040px, calc(100vw - 2 * var(--pad-x)));
  margin-left: 50%;
  transform: translateX(-50%);
}
.prose > .post-media { margin-top: 2.2em; margin-bottom: 2.2em; }
.post-media picture { display: block; }
/* a live loop (blog.js) lies over its still, so the still keeps the
   layout and the alt text and shows through until the loop is drawn */
.loop { position: relative; display: block; }
.loop iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
}
.loop.is-live iframe { opacity: 1; }
.post-media img, .post-media video {
  width: 100%;
  height: auto;
  background: var(--ground);
}
figcaption {
  max-width: var(--measure);
  margin: 14px auto 0;
  font: 400 12px "Geist Mono", monospace;
  letter-spacing: 0.02em;
  line-height: 1.6;
  color: var(--faint);
}
.post-cover figcaption { max-width: 880px; }

.post-foot {
  max-width: var(--measure);
  margin: clamp(48px, 8vh, 80px) auto 0;
}
/* no related posts after it: the post ends on the footer, so give it room */
.post:last-child { padding-bottom: clamp(64px, 10vh, 112px); }

.more-posts {
  max-width: var(--wide);
  margin: clamp(64px, 12vh, 128px) auto 0;
  padding: 0 var(--pad-x) clamp(64px, 10vh, 112px);
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* ---------- Footer: © left · legal centre · icons right ---------- */
.bottombar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  max-width: var(--wide);
  width: 100%;
  margin: 0 auto;
  padding: 26px var(--pad-x) 48px;
  border-top: 1px solid var(--line);
}
.legal {
  justify-self: start;
  font: 400 11px "Geist Mono", monospace;
  letter-spacing: 0.04em;
  color: var(--faint);
}
.legal-links { justify-self: center; display: flex; gap: clamp(14px, 2.5vw, 28px); }
.legal-links a, .menu-legal a {
  font: 400 11px "Geist Mono", monospace;
  letter-spacing: 0.04em;
  color: var(--faint);
  transition: color 0.3s ease;
}
.legal-links a:hover, .menu-legal a:hover { color: var(--ink); }
.footer-icons { display: flex; align-items: center; gap: 16px; }
.bottombar .footer-icons { justify-self: end; }
.footer-icons a { display: inline-flex; color: var(--faint); transition: color 0.3s ease; }
.footer-icons a:hover { color: var(--ink); }
.footer-icons svg { width: 17px; height: 17px; }

/* ---------- Mobile menu ---------- */
.mobile-menu {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--ground);
}
.mobile-menu[hidden] { display: none; }
.menu-inner {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 14px 20px calc(22px + env(safe-area-inset-bottom, 0px));
  animation: pageIn 0.45s var(--ease-out) both;
}
.menu-top { display: flex; align-items: center; justify-content: space-between; height: 34px; }
.menu-logomark svg { height: 22px; }
.menu-close { color: var(--ink); background: none; border: none; cursor: pointer; padding: 4px; }
.menu-close svg { width: 24px; height: 24px; }
.menu-nav { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 2px; }
.menu-nav a {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 16px 0;
  font-size: clamp(30px, 8.8vw, 46px);
  font-weight: 300;
  letter-spacing: -0.03em;
  border-bottom: 1px solid rgba(22, 21, 15, 0.1);
}
.menu-nav a span { font: 500 12px "Geist Mono", monospace; letter-spacing: 0.1em; color: var(--faint); }
.menu-nav a.active, .menu-nav a.active span { color: var(--accent); }
.menu-nav .menu-demo {
  align-items: center;
  gap: 12px;
  font-size: clamp(19px, 5.6vw, 24px);
  font-weight: 400;
  color: var(--accent);
  border-bottom: none;
  margin-top: 10px;
}
.menu-nav .menu-demo .icon { width: 20px; height: 20px; }
.menu-footer {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding-top: 20px;
  border-top: 1px solid rgba(22, 21, 15, 0.1);
}
.menu-legal { display: flex; gap: 20px; }
.menu-foot-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.menu-copyright { font: 400 10.5px "Geist Mono", monospace; letter-spacing: 0.04em; color: var(--faint); }
body.menu-open { overflow: hidden; }

/* ---------- Responsive ---------- */
@media (max-width: 1020px) {
  .post-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card.is-lead { grid-template-columns: 1fr; align-items: start; }
}
/* as on the main site: four nav links need ~920px beside the centred
   logomark, so below that the bar collapses to logomark + burger */
@media (max-width: 920px) {
  .topbar { display: flex; justify-content: space-between; }
  .topbar nav, .top-cta { display: none; }
  .menu-burger { display: inline-flex; }
  .menu-inner { padding-left: var(--pad-x); padding-right: var(--pad-x); }
}
@media (max-width: 720px) {
  .topbar { padding: 14px 20px; }
  .menu-inner { padding-left: 20px; padding-right: 20px; }
  .logomark svg { height: 22px; }
  /* footer moves into the mobile menu, as on the main site — the sticky
     bar keeps the menu a tap away from anywhere in a long read */
  .bottombar { display: none; }
  .post-grid { grid-template-columns: 1fr; }
  .blog-filters { gap: 6px 20px; }
  .prose blockquote { padding-left: 18px; }
  .draft-bar { justify-content: flex-start; text-align: left; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .page-in, .menu-inner { animation: none; }
  .card-media img, .post-back .icon, .topbar nav a::after, .loop iframe { transition: none; }
  .card:hover .card-media img { transform: none; }
}
