/* ═══════════════════════════════════════════════════════════════
   krackedtools.dev — shared blog-post shell.
   Same design system as index.html (handoff-3 mono editorial):
   Fira Code lowercase headings, bracket links, flat 1px-bordered
   sections, white on #131118, 760px column. No cards, no radius.
   Loaded by every page under posts/; behavior lives in post.js.
   ═══════════════════════════════════════════════════════════════ */

/* Webfonts — same packages the portfolio loads (pinned CDN).
   Fira Code comes from Google Fonts via a <link> in each post. */
@font-face {
  font-family: "Geist Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(https://cdn.jsdelivr.net/npm/@fontsource-variable/geist@5/files/geist-latin-wght-normal.woff2) format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Hack";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(https://cdn.jsdelivr.net/npm/hack-font@3/build/web/fonts/hack-regular.woff2) format("woff2");
}

:root {
  --font-sans: "Geist Variable", ui-sans-serif, system-ui, sans-serif,
    "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
  --font-mono: "Fira Code", "Hack", ui-monospace, "SFMono-Regular", "Menlo",
    "Monaco", "Consolas", "Liberation Mono", "Courier New", monospace;
  --font-display: var(--font-mono);
  --font-serif: var(--font-mono); /* posts no longer use a serif voice */

  /* mirrors index.html */
  --bg: #131118;
  --bg-base-1: oklch(0.213 0.0098 305);
  --bg-base-2: oklch(0.252 0.0112 305);
  --bg-subtle: oklch(1 0 0 / 0.06);
  --text-primary: #ffffff;
  --text-secondary: oklch(0.83 0.008 305);
  --text-tertiary: oklch(0.62 0.014 305);
  --border-neutral: oklch(0.312 0.014 305);
  --border-soft: oklch(0.27 0.012 305);
  --orange-9: #ff570a;   /* --accent-upcoming on the front page */
  --orange-11: #ffa057;
  --orange-12: #ffe0c2;
  --orange-3: #331e0b;

  --text-sm: 0.75rem;    --text-sm-lh: 1rem;
  --text-base: 0.875rem; --text-base-lh: 1.25rem;

  --radius: 0px;
  --radius-md: 0px;
  --radius-lg: 0px;
  --shadow-xs: none;
  --ease: cubic-bezier(0.19, 1, 0.22, 1);

  /* Compatibility aliases — the posts' inline styles were written against
     the old editorial variable names; map them onto the dark tokens. */
  --sans: var(--font-sans);
  --serif: var(--font-serif);
  --mono: var(--font-mono);
  --paper: var(--bg);
  --paper-2: var(--bg-base-1);
  --paper-3: var(--bg-base-2);
  --ink: var(--text-primary);
  --ink-2: var(--text-secondary);
  --ink-3: var(--text-tertiary);
  --ink-4: oklch(0.42 0.014 305);
  --rule: var(--border-neutral);
  --rule-soft: var(--border-soft);
  --accent: var(--orange-9);
  --accent-ink: var(--orange-11);
  --accent-soft: var(--orange-3);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--text-base-lh);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: inherit; }
::selection { background: oklch(0.9 0.005 55); color: oklch(0.177 0.0084 305); }

/* ---------- Reading progress ---------- */
.progress {
  position: fixed; top: 0; left: 0;
  height: 2px; width: 0%;
  background: var(--orange-9);
  z-index: 200;
  transition: width .1s linear;
}

/* ---------- Top nav — front-page vocabulary: mono brand block +
   bracket links ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in oklch, #131118 88%, transparent);
  backdrop-filter: saturate(160%) blur(8px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s ease;
}
.nav.scrolled { border-color: var(--border-neutral); }
.nav-inner {
  max-width: 760px; margin: 0 auto;
  padding: 24px 24px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand {
  font-family: var(--font-mono);
  font-size: 13px; font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--text-primary);
  text-decoration: none;
  display: flex; align-items: center; gap: 9px;
  transition: opacity 150ms var(--ease);
}
.brand:hover { opacity: 0.7; }
.brand-mark, .brand svg { width: 16px; height: 16px; color: var(--text-primary); }
.nav-links { display: flex; gap: 20px; flex-wrap: wrap; }
.nav-links a {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-primary);
  text-decoration: none;
  transition: opacity 150ms var(--ease);
}
.nav-links a::before { content: "[ "; }
.nav-links a::after  { content: " ]"; }
.nav-links a:hover { opacity: 0.7; }

/* ---------- Hero — mono headline over a calm rain band ---------- */
.hero-band { position: relative; }
#hero-rain {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0.5;
  -webkit-mask-image: linear-gradient(to bottom, black 30%, transparent 96%);
  mask-image: linear-gradient(to bottom, black 30%, transparent 96%);
}
.wrap { max-width: 760px; margin: 0 auto; padding: 0 24px; }
.hero { position: relative; padding: 72px 0 8px; }
.kicker {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: 24px;
}
.kicker::before { content: "[ "; }
.kicker::after  { content: " ]"; }
.hero-title {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 38px;
  line-height: 1.15;
  font-weight: 600;
  letter-spacing: -0.03em;
  text-transform: lowercase;
  color: var(--text-primary);
  text-wrap: balance;
}
.hero-title em {
  font-style: normal;
  font-weight: 600;
  color: var(--orange-9);
}
.meta-dek {
  margin: 20px 0 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.7;
  color: var(--text-primary);
  max-width: 520px;
  font-weight: 400;
  text-wrap: pretty;
}
.meta-line {
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--border-neutral);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}
.hero-art {
  display: block;
  width: 100%;
  height: auto;
  margin-top: 36px;
  border: 1px solid var(--border-neutral);
}

/* ---------- Body: contents block + article, one 760px column ---------- */
.body {
  display: block;
  max-width: 760px;
  margin: 0 auto;
  padding: 48px 24px 120px;
}
.toc {
  position: static;
  margin-bottom: 56px;
  font-family: var(--font-mono);
  font-size: 12px;
}
.toc-label {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-tertiary);
  margin-bottom: 12px;
}
.toc-label::before { content: "[ "; }
.toc-label::after  { content: " ]"; }
.toc ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--border-neutral); }
.toc li a {
  display: block;
  padding: 6px 14px;
  color: var(--text-tertiary);
  text-decoration: none;
  line-height: 1.4;
  border-left: 2px solid transparent;
  margin-left: -1px;
  transition: color 150ms var(--ease);
}
.toc li a:hover { color: var(--text-primary); }
.toc li.active a { color: var(--text-primary); border-left-color: var(--orange-9); }

.article {
  max-width: 620px;
  font-size: var(--text-base);
  line-height: 1.7;
  color: var(--text-primary);
}
.article > p { margin: 0 0 1.5em; font-weight: 400; text-wrap: pretty; }
.article h2 {
  font-family: var(--font-mono);
  font-size: 24px;
  line-height: 1.15;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  text-transform: lowercase;
  border-top: 1px solid var(--border-neutral);
  padding-top: 36px;
  margin: 3em 0 1em;
}
.article h2:first-child { margin-top: 0; border-top: none; padding-top: 0; }
.article h3 {
  font-family: var(--font-mono);
  font-size: 16px;
  line-height: 1.3;
  font-weight: 600;
  color: var(--text-primary);
  text-transform: lowercase;
  margin: 2.2em 0 0.6em;
  letter-spacing: -0.01em;
}
.article strong { color: var(--text-primary); font-weight: 600; }
.article p.lede { color: var(--text-primary); font-weight: 500; }
.article a {
  color: var(--text-primary);
  text-decoration: underline;
  text-decoration-color: color-mix(in oklch, #ffffff 40%, transparent);
  text-underline-offset: 3px;
  transition: opacity 150ms var(--ease), text-decoration-color .15s;
}
.article a:hover { opacity: 0.7; text-decoration-color: #ffffff; }
.article ul, .article ol { padding-left: 22px; margin: 0 0 1.5em; }
.article li { margin-bottom: 0.5em; }
.article em { font-style: italic; }

/* ---------- Callout — flat, front-page bordered recipe ---------- */
.callout {
  margin: 2em 0;
  padding: 4px 0 4px 22px;
  background: none;
  border-left: 2px solid var(--orange-9);
  border-radius: 0;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-style: italic;
  font-size: 15px;
  line-height: 1.7;
}
.callout .attrib {
  display: block; margin-top: 12px;
  font-family: var(--font-mono);
  font-style: normal;
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

/* ---------- Figure — flat bordered section, no card ---------- */
.figure {
  margin: 2.6em -32px;
  background: none;
  border: 1px solid var(--border-neutral);
  border-radius: 0;
  box-shadow: none;
  padding: 26px 28px 22px;
}
.figure .figure-title {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  text-align: center;
  text-transform: lowercase;
  letter-spacing: -0.01em;
  margin: 4px 0 22px;
}
.figure-caption {
  font-family: var(--font-mono);
  font-size: 10.5px;
  line-height: 1.6;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-top: 16px;
}
/* Images always scale to their container, never overflow it —
   also guards readers on a stale cached stylesheet. */
.article img, .figure img, .hero-art { max-width: 100%; }
.figure img { display: block; width: 100%; height: auto; }
.figure.flush { padding: 0; overflow: hidden; }
.figure.flush .figure-caption {
  margin-top: 0;
  padding: 12px 16px;
  border-top: 1px solid var(--border-soft);
}

/* ---------- Code block ---------- */
.code-block {
  position: relative;
  margin: 2em 0;
  background: oklch(0.16 0.008 305);
  color: #EFEDE6;
  border: 1px solid var(--border-neutral);
  border-radius: 0;
  box-shadow: none;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.6;
  overflow: hidden;
}
.code-block .copy-btn {
  position: absolute;
  top: 8px; right: 10px;
  z-index: 2;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 0;
  cursor: pointer;
  transition: color .15s, background .15s, border-color .15s;
}
.code-block .copy-btn:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.10);
  border-color: rgba(255,255,255,0.20);
}
.code-block .copy-btn.copied {
  color: #3dd68c;
  border-color: rgba(61,214,140,0.45);
  background: rgba(61,214,140,0.10);
}
.code-block .copy-btn svg { width: 12px; height: 12px; }
.code-head {
  display: flex; justify-content: flex-start; align-items: center; gap: 14px;
  padding: 10px 16px;
  padding-right: 92px;
  background: var(--bg-base-1);
  border-bottom: 1px solid var(--border-soft);
  color: var(--text-tertiary);
  font-size: 11px;
  font-family: var(--font-mono);
}
.code-head .dots { display: flex; gap: 6px; }
.code-head .dots span {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--border-neutral);
}
.code-body { padding: 18px 20px; overflow-x: auto; white-space: pre; }
.tk-key { color: #E89B6C; }
.tk-str { color: #9AC489; }
.tk-fn  { color: #BEA8DC; }
.tk-cm  { color: #6D6A60; font-style: italic; }
.tk-num { color: #E8C971; }
.tk-p   { color: #B3B0A6; }

/* ---------- Data table ---------- */
.table-wrap { margin: 2em 0; overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-sans);
  font-size: var(--text-base);
}
.data-table thead th {
  text-align: left;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-primary);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-neutral);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.data-table tbody td {
  padding: 14px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text-primary);
  vertical-align: top;
}
.data-table tbody td:first-child { font-weight: 500; }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ---------- Lite YouTube facade ---------- */
.lite-yt { position: relative; display: block; width: 100%; aspect-ratio: 16/9; padding: 0; margin: 0; border: 0; cursor: pointer; background: #0d0b11; overflow: hidden; border-radius: 0; }
.lite-yt-thumb { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0.92; }
.lite-yt-shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,0.10), rgba(0,0,0,0.42)); transition: background .2s ease; }
.lite-yt-btn { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 84px; height: 60px; border-radius: 14px; background: rgba(10,9,13,0.78); display: flex; align-items: center; justify-content: center; transition: background .15s ease, transform .15s ease; }
.lite-yt:hover .lite-yt-btn, .lite-yt:focus-visible .lite-yt-btn { background: #CC0000; transform: translate(-50%, -50%) scale(1.04); }
.lite-yt:hover .lite-yt-shade { background: linear-gradient(180deg, rgba(0,0,0,0.0), rgba(0,0,0,0.32)); }
.lite-yt:focus-visible { outline: 2px solid var(--orange-9); outline-offset: 2px; }

/* ---------- Embedded tweet ---------- */
.tweet-embed {
  margin: 2.4em 0 0;
  display: flex;
  justify-content: center;
  min-height: 120px;
}
.tweet-embed blockquote.twitter-tweet {
  margin: 0;
  padding: 16px 20px;
  border-left: 2px solid var(--border-neutral);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--text-tertiary);
}

/* ---------- Footer — front-page vocabulary ---------- */
.foot {
  border-top: 1px solid var(--border-neutral);
  max-width: 760px;
  margin: 0 auto;
  padding: 36px 24px 48px;
  display: flex; align-items: center; justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-primary);
}
.foot a { text-decoration: none; color: var(--text-primary); transition: opacity 150ms var(--ease); }
.foot a:hover { opacity: 0.7; }
.foot .glyph { font-family: var(--font-mono); }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .hero { padding-top: 48px; }
  .hero-title { font-size: 30px; }
  .body { padding: 36px 20px 80px; }
  .wrap, .nav-inner, .foot { padding-left: 20px; padding-right: 20px; }
  .figure { margin-left: -14px; margin-right: -14px; }
  .nav-links { gap: 12px; }
}

/* ---------- Accessibility ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important; scroll-behavior: auto !important;
  }
}
:focus-visible { outline: 2px solid var(--orange-9); outline-offset: 2px; border-radius: 0; }
