/* ============================================================
   memo.css — standalone reader for /research (index + articles).
   These pages are hosted static routes, not part of the Vite bundle,
   so this file is self-sufficient: reset + fonts + the swarm token
   palette + a signature glow, followed by the structural rules the
   pages already use (.rx-* index, .ar-* article). Deep-space register
   so the reader reads as one site with the SWARM homepage.
   ============================================================ */

/* ---- fonts (self-hosted; CDNs are blocked on the author's network) */
@font-face { font-family: "Franklin"; src: url("/assets/fonts/libre-franklin-var.woff2") format("woff2"); font-weight: 100 900; font-display: block; }
@font-face { font-family: "PlexMono"; src: url("/assets/fonts/ibm-plex-mono-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "PlexMono"; src: url("/assets/fonts/ibm-plex-mono-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }

/* ---- swarm token palette (maps every var research.css references) */
:root {
  --paper: #06080f;             /* page ground — deep space */
  --paper-2: #0c1120;           /* raised wells: art, code, figures */
  --panel: #090e1a;             /* card / featured surfaces */
  --panel-stroke: rgba(147, 163, 192, 0.14);
  --panel-stroke-strong: rgba(150, 180, 225, 0.34);
  --ink: #eef2fb;               /* headings, strongest text */
  --ink-2: #c6d2e8;             /* running prose */
  --ink-dim: #9aa9c6;           /* footer text */
  --ink-mute: #8695b3;          /* kickers, meta, muted labels */
  --ink-faint: #586a90;         /* hairline rules, brand rule */
  --accent: #5cdcff;            /* cyan — site signature */
  --accent-tint: rgba(92, 220, 255, 0.09);
  --ff-display: "Franklin", "Helvetica Neue", Arial, sans-serif;
  --ff-body: "Franklin", "Helvetica Neue", Arial, sans-serif;
  --ff-mono: "PlexMono", ui-monospace, Menlo, monospace;
  --easing: cubic-bezier(0.22, 1, 0.36, 1);
  --r-3: 14px;
}

/* ---- reset + base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; background: var(--paper); color: var(--ink-2);
  font-family: var(--ff-body); line-height: 1.6;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
img, svg { max-width: 100%; }
a { color: inherit; text-decoration: none; }
::selection { background: rgba(92, 220, 255, 0.24); color: #fff; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--ink); color: var(--paper); padding: 10px 16px;
  font-family: var(--ff-mono); font-size: 12px; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

/* ---- signature glow — echoes the swarm's cyan/gold, no noise */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(1100px 640px at 80% -10%, rgba(92, 220, 255, 0.06), transparent 60%),
    radial-gradient(900px 620px at 8% 2%, rgba(244, 176, 99, 0.04), transparent 55%);
}

/* ============================================================
   Structural rules — the /research hub + article pages.
   Retuned to the swarm palette via the tokens above.
   ============================================================ */

/* ---- shared shell ------------------------------------------------ */
.rx-wrap { max-width: 1240px; margin: 0 auto; padding: 0 max(5vw, 28px); }

.rx-topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 18px max(5vw, 28px);
  background: linear-gradient(to bottom, color-mix(in oklab, var(--paper) 86%, transparent), transparent);
  backdrop-filter: blur(12px) saturate(105%);
  -webkit-backdrop-filter: blur(12px) saturate(105%);
  border-bottom: 1px solid var(--panel-stroke);
  font-size: 14px;
}
.rx-topbar .brand { display: inline-flex; align-items: center; gap: 12px; color: var(--ink); border: none; }
.rx-topbar .brand .mk { font-family: var(--ff-display); font-style: italic; font-size: 22px; line-height: 1; }
.rx-topbar .brand .rule { width: 20px; height: 1px; background: var(--ink-faint); display: inline-block; }
.rx-topbar .brand .nm { font-size: 13px; color: var(--ink-2); }
.rx-topbar nav { display: flex; align-items: center; gap: 24px; }
.rx-topbar nav a { color: var(--ink-2); border: none; transition: color .2s var(--easing); }
.rx-topbar nav a:hover { color: var(--accent); }
.rx-topbar nav a.cta { color: var(--ink); padding: 8px 15px; border: 1px solid var(--ink-faint); border-radius: 100px; }
.rx-topbar nav a.cta:hover { border-color: var(--accent); color: var(--accent); }

.rx-foot {
  margin-top: 120px; border-top: 1px solid var(--panel-stroke);
  padding: 40px max(5vw, 28px) 64px;
}
.rx-foot-inner { max-width: 1240px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; font-family: var(--ff-mono); font-size: 11px; color: var(--ink-dim); letter-spacing: 0.06em; }
.rx-foot-inner a { color: var(--ink-mute); border: none; }
.rx-foot-inner a:hover { color: var(--accent); }

/* ---- index hero -------------------------------------------------- */
.rx-hero { padding: 84px 0 36px; }
.rx-hero .eyebrow { font-family: var(--ff-mono); font-size: 11px; letter-spacing: 0.24em; text-transform: uppercase; color: var(--ink-mute); display: inline-flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.rx-hero .eyebrow::before { content: ""; width: 20px; height: 1px; background: var(--accent); }
.rx-hero h1 { font-family: var(--ff-display); font-weight: 400; font-size: clamp(44px, 6.4vw, 92px); line-height: 1.0; letter-spacing: -0.02em; margin: 0; color: var(--ink); text-wrap: balance; }
.rx-hero h1 em { color: var(--accent); font-style: italic; }
.rx-hero .lede { margin: 24px 0 0; max-width: 64ch; font-size: 18px; line-height: 1.6; color: var(--ink-2); }

/* ---- category filter -------------------------------------------- */
.rx-filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 40px 0 30px; border-top: 1px solid var(--panel-stroke); padding-top: 24px; }
.rx-filter {
  font-family: var(--ff-mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-mute); background: transparent; border: 1px solid var(--panel-stroke);
  padding: 7px 13px; border-radius: 100px; cursor: pointer; transition: all .18s var(--easing);
}
.rx-filter:hover { border-color: var(--panel-stroke-strong); color: var(--ink-2); }
.rx-filter.active { color: var(--paper); background: var(--ink); border-color: var(--ink); }

/* ---- featured lead ---------------------------------------------- */
.rx-featured {
  display: grid; grid-template-columns: 1.15fr 1fr; gap: 0;
  border: 1px solid var(--panel-stroke); border-radius: var(--r-3); overflow: hidden;
  background: var(--panel); margin-bottom: 22px; cursor: pointer;
  transition: border-color .25s var(--easing), transform .25s var(--easing);
}
.rx-featured:hover { border-color: var(--panel-stroke-strong); transform: translateY(-2px); }
.rx-featured .art { position: relative; min-height: 340px; background: var(--paper-2); }
.rx-featured .art > svg, .rx-card .art > svg { position: absolute; inset: 0; }
.rx-featured .meat { padding: 40px 40px 36px; display: flex; flex-direction: column; justify-content: center; }
.rx-featured .kicker { font-family: var(--ff-mono); font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent); margin-bottom: 14px; display: flex; gap: 10px; align-items: center; }
.rx-featured .kicker .fk { color: var(--ink-mute); }
.rx-featured h2 { font-family: var(--ff-display); font-weight: 400; font-size: clamp(30px, 3.4vw, 46px); line-height: 1.05; letter-spacing: -0.01em; margin: 0 0 14px; color: var(--ink); }
.rx-featured .dek { color: var(--ink-2); font-size: 16px; line-height: 1.6; margin: 0 0 22px; max-width: 52ch; }
.rx-featured .meta { font-family: var(--ff-mono); font-size: 11px; color: var(--ink-mute); letter-spacing: 0.06em; display: flex; gap: 14px; align-items: center; }
.rx-featured .go { margin-top: 22px; font-family: var(--ff-mono); font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); }

/* ---- card grid -------------------------------------------------- */
.rx-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; }
.rx-card {
  display: flex; flex-direction: column; cursor: pointer; color: var(--ink);
  border: 1px solid var(--panel-stroke); border-radius: var(--r-3); overflow: hidden;
  background: var(--panel); transition: border-color .25s var(--easing), transform .25s var(--easing);
}
.rx-card:hover { border-color: var(--panel-stroke-strong); transform: translateY(-3px); }
.rx-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.rx-card .art { position: relative; aspect-ratio: 16 / 10; background: var(--paper-2); border-bottom: 1px solid var(--panel-stroke); }
.rx-card .body { padding: 20px 20px 22px; display: flex; flex-direction: column; flex: 1; }
.rx-card .kicker { font-family: var(--ff-mono); font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent); margin-bottom: 10px; }
.rx-card h3 { font-family: var(--ff-display); font-weight: 400; font-size: 24px; line-height: 1.12; margin: 0 0 10px; color: var(--ink); }
.rx-card .dek { color: var(--ink-2); font-size: 14px; line-height: 1.55; margin: 0 0 16px; }
.rx-card .meta { margin-top: auto; font-family: var(--ff-mono); font-size: 10.5px; color: var(--ink-mute); letter-spacing: 0.06em; display: flex; gap: 12px; }
.rx-card.is-hidden { display: none; }

/* ---- article page ----------------------------------------------- */
.ar-head { padding: 64px 0 8px; max-width: 880px; margin: 0 auto; }
.ar-back { font-family: var(--ff-mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-mute); border: none; display: inline-flex; gap: 8px; margin-bottom: 30px; }
.ar-back:hover { color: var(--accent); }
.ar-kicker { font-family: var(--ff-mono); font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent); margin-bottom: 18px; }
.ar-title { font-family: var(--ff-display); font-weight: 400; font-size: clamp(38px, 5.4vw, 72px); line-height: 1.02; letter-spacing: -0.02em; margin: 0; color: var(--ink); text-wrap: balance; }
.ar-title em { color: var(--accent); font-style: italic; }
.ar-dek { margin: 22px 0 0; font-size: 20px; line-height: 1.55; color: var(--ink-2); max-width: 60ch; font-family: var(--ff-body); }
.ar-byline { margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--panel-stroke); display: flex; flex-wrap: wrap; gap: 18px; font-family: var(--ff-mono); font-size: 11.5px; color: var(--ink-mute); letter-spacing: 0.05em; }
.ar-byline b { color: var(--ink-2); font-weight: 500; }

.ar-hero-art { max-width: 1100px; margin: 40px auto 0; aspect-ratio: 21 / 9; position: relative; border: 1px solid var(--panel-stroke); border-radius: var(--r-3); overflow: hidden; background: var(--paper-2); }
.ar-hero-art > svg { position: absolute; inset: 0; }

/* article prose */
.ar-body { max-width: 720px; margin: 0 auto; padding: 56px 0 0; }
.ar-body > * { margin-left: auto; margin-right: auto; }
.ar-body p { font-size: 18px; line-height: 1.72; color: var(--ink-2); margin: 0 0 26px; }
.ar-body p > a { color: var(--accent); border-bottom: 1px solid color-mix(in oklab, var(--accent) 35%, transparent); }
.ar-body p > a:hover { border-bottom-color: var(--accent); }
.ar-body .lead-p { font-size: 21px; line-height: 1.6; color: var(--ink); }
.ar-body .lead-p::first-letter { font-family: var(--ff-display); font-style: italic; font-size: 3.4em; line-height: 0.82; float: left; padding: 6px 12px 0 0; color: var(--accent); }
.ar-body h2 { font-family: var(--ff-display); font-weight: 400; font-size: clamp(28px, 3.4vw, 38px); line-height: 1.1; letter-spacing: -0.01em; color: var(--ink); margin: 56px 0 18px; text-wrap: balance; }
.ar-body h2 em { font-style: italic; color: var(--accent); }
.ar-body h3 { font-family: var(--ff-body); font-weight: 600; font-size: 19px; letter-spacing: 0.01em; color: var(--ink); margin: 38px 0 12px; }
.ar-body ul, .ar-body ol { font-size: 18px; line-height: 1.7; color: var(--ink-2); margin: 0 0 26px; padding-left: 24px; }
.ar-body li { margin-bottom: 10px; }
.ar-body li::marker { color: var(--accent); }
.ar-body strong { color: var(--ink); font-weight: 600; }
.ar-body em { font-style: italic; }
.ar-body hr { border: none; border-top: 1px solid var(--panel-stroke); margin: 52px 0; }

/* eyebrow above an h2 (section number / label) — used sparingly */
.ar-body .sec-eyebrow { font-family: var(--ff-mono); font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-mute); margin: 56px 0 -6px; }
.ar-body .sec-eyebrow + h2 { margin-top: 10px; }

/* callout / key idea */
.ar-callout {
  border-left: 2px solid var(--accent); background: var(--accent-tint);
  padding: 22px 26px; border-radius: 0 var(--r-3) var(--r-3) 0; margin: 34px auto 34px;
}
.ar-callout p { margin: 0; font-size: 17px; line-height: 1.6; color: var(--ink); }
.ar-callout .lab { display: block; font-family: var(--ff-mono); font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent); margin-bottom: 8px; }

/* pull quote */
.ar-body blockquote {
  margin: 40px auto; padding: 0 0 0 4px; border: none;
  font-family: var(--ff-display); font-style: italic; font-size: clamp(26px, 3.2vw, 36px);
  line-height: 1.25; color: var(--ink); max-width: 720px;
}
.ar-body blockquote p { font-size: inherit; line-height: inherit; color: inherit; font-family: inherit; }

/* code */
.ar-body pre {
  background: var(--paper-2); border: 1px solid var(--panel-stroke); border-radius: var(--r-3);
  padding: 20px 22px; overflow-x: auto; margin: 30px auto; max-width: 760px;
  font-family: var(--ff-mono); font-size: 13px; line-height: 1.6; color: var(--ink-2);
}
.ar-body pre .c { color: var(--ink-mute); }
.ar-body pre .k { color: var(--accent); }
.ar-body :not(pre) > code {
  font-family: var(--ff-mono); font-size: 0.86em; background: color-mix(in oklab, var(--ink) 8%, transparent);
  border: 1px solid var(--panel-stroke); border-radius: 4px; padding: 1px 6px; color: var(--ink);
}

/* figure / diagram block (for inline cover art or schematic) */
.ar-figure { max-width: 880px; margin: 38px auto; }
.ar-figure .frame { position: relative; aspect-ratio: 16 / 9; border: 1px solid var(--panel-stroke); border-radius: var(--r-3); overflow: hidden; background: var(--paper-2); }
.ar-figure .frame > svg { position: absolute; inset: 0; }
/* diagrams with their own intrinsic height (schematics, not cover art) */
.ar-figure .frame.free { aspect-ratio: auto; padding: 22px 24px; display: block; }
.ar-figure .frame.free > svg { position: static; inset: auto; width: 100%; height: auto; display: block; }
.ar-figure figcaption { margin-top: 12px; font-family: var(--ff-mono); font-size: 11px; color: var(--ink-mute); letter-spacing: 0.04em; text-align: center; }

/* data table inside an article */
.ar-body table { width: 100%; border-collapse: collapse; margin: 32px auto; font-size: 14.5px; max-width: 760px; }
.ar-body table th, .ar-body table td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--panel-stroke); vertical-align: top; }
.ar-body table thead th { font-family: var(--ff-mono); font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-mute); border-bottom-color: var(--panel-stroke-strong); }
.ar-body table td { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.ar-body table tr:last-child td { border-bottom: none; }
.ar-body .ar-table-wrap { overflow-x: auto; margin: 32px auto; max-width: 760px; }
.ar-body .ar-table-wrap table { margin: 0; }

/* stat row inside article */
.ar-stats { display: flex; flex-wrap: wrap; gap: 36px; margin: 36px auto; max-width: 760px; padding: 26px 0; border-top: 1px solid var(--panel-stroke); border-bottom: 1px solid var(--panel-stroke); }
.ar-stat .v { font-family: var(--ff-display); font-size: 40px; line-height: 1; color: var(--accent); }
.ar-stat .l { font-family: var(--ff-mono); font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-mute); margin-top: 8px; }

/* article footer: author + next/prev */
.ar-foot { max-width: 880px; margin: 72px auto 0; padding-top: 36px; border-top: 1px solid var(--panel-stroke); }
.ar-author { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 44px; }
.ar-author .av { width: 52px; height: 52px; border-radius: 50%; overflow: hidden; flex-shrink: 0; border: 1px solid var(--panel-stroke-strong); background: var(--paper-2); }
.ar-author .av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ar-author .who .n { font-family: var(--ff-display); font-size: 22px; color: var(--ink); }
.ar-author .who .r { font-size: 14px; color: var(--ink-2); margin-top: 2px; }
.ar-author .who .links { margin-top: 10px; display: flex; gap: 16px; font-family: var(--ff-mono); font-size: 11px; }
.ar-author .who .links a { color: var(--ink-mute); border: none; }
.ar-author .who .links a:hover { color: var(--accent); }

.ar-next { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.ar-next a { display: flex; flex-direction: column; gap: 6px; padding: 20px; border: 1px solid var(--panel-stroke); border-radius: var(--r-3); color: var(--ink); transition: border-color .2s var(--easing); }
.ar-next a:hover { border-color: var(--accent); }
.ar-next .dir { font-family: var(--ff-mono); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-mute); }
.ar-next .t { font-family: var(--ff-display); font-size: 19px; line-height: 1.15; color: var(--ink); }
.ar-next a.next { text-align: right; }

/* reading progress bar */
.ar-progress { position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 60; background: transparent; pointer-events: none; }
.ar-progress .fill { height: 100%; background: var(--accent); transform-origin: 0 0; transform: scaleX(0); }

/* ---- responsive ------------------------------------------------- */
@media (max-width: 940px) {
  .rx-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* minmax(0,1fr), not bare 1fr: a bare track auto-sizes to its item's
     min-content, and the art below (aspect-ratio + min-height) has an
     intrinsic min width of 220×16/9 ≈ 391px, which blows the single
     column past the viewport and pushes the cards out of view on phones. */
  .rx-featured { grid-template-columns: minmax(0, 1fr); }
  /* width:100% makes the art fill the column and take its height from the
     aspect-ratio, instead of deriving a 391px width from min-height. */
  .rx-featured .art { width: 100%; min-height: 220px; aspect-ratio: 16/9; }
}
@media (max-width: 680px) {
  .rx-topbar nav { gap: 14px; }
  .rx-topbar .brand .nm { display: none; }
  .rx-grid { grid-template-columns: minmax(0, 1fr); }
  .rx-featured .meat { padding: 26px 22px 28px; }
  .ar-body { padding-top: 40px; }
  .ar-body p, .ar-body ul, .ar-body ol { font-size: 17px; }
  .ar-next { grid-template-columns: 1fr; }
  .ar-next a.next { text-align: left; }
  .ar-body .lead-p::first-letter { font-size: 3em; }
}


/* ============================================================
   shared site nav — identical markup + look on every page
   ============================================================ */
.mono { font-family: var(--ff-mono); }
.top {
  position: sticky; top: 0; z-index: 50; font-family: var(--ff-mono);
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 15px max(5vw, 26px);
  background: linear-gradient(to bottom, color-mix(in oklab, var(--paper) 88%, transparent), transparent);
  backdrop-filter: blur(12px) saturate(105%); -webkit-backdrop-filter: blur(12px) saturate(105%);
  border-bottom: 1px solid var(--panel-stroke);
}
.top .wordmark { font-size: 13px; letter-spacing: 0.22em; color: var(--ink); text-decoration: none; }
/* wordmark links home — at-rest back cue + hover so it reads as the way back */
.top a.wordmark { cursor: pointer; }
.top a.wordmark::before { content: "\2190"; display: inline-block; margin-right: 0.55em;
  letter-spacing: 0; color: var(--ink-mute); transition: color 0.2s, transform 0.2s; }
.top a.wordmark:hover { color: var(--accent); }
.top a.wordmark:hover::before { color: var(--accent); transform: translateX(-3px); }
.top .topnav { display: flex; gap: clamp(14px, 2vw, 28px); font-size: 12px; letter-spacing: 0.1em; }
.top .topnav a { color: var(--ink-mute); text-decoration: none; transition: color 0.2s var(--easing); }
.top .topnav a:hover, .top .topnav a[aria-current="page"] { color: var(--ink); }
@media (max-width: 620px) { .top { padding: 13px max(4vw, 16px); } .top .topnav { gap: 12px; font-size: 11px; } .top .topnav a[href="/work/"] { display: none; } }
