/* ShabuBox — learnings.css
 *
 * Long-form article typography for /learnings. Loaded ONLY on the series index
 * and the article pages (via {{CSS_EXTRA}}), and content-hashed at build like
 * tokens.css / site.css so it can ride the `immutable` rule in _headers.
 *
 * Every color resolves through tokens.css variables, so light/dark theming is
 * whatever the rest of the site already does — no new scheme, no media query.
 */

/* ── Shared page furniture ── */
.lr-wrap { padding: 64px 0 24px; }
.lr-narrow { width: 100%; max-width: 760px; margin: 0 auto; padding: 0 28px; }

.lr-back {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.04em;
  color: var(--fg-faint); text-decoration: none;
  transition: color var(--dur-fast);
}
.lr-back:hover { color: var(--accent); }

/* ── Series index ── */
.lr-index-head { padding: 72px 0 12px; }
.lr-index-title {
  margin: 14px 0 0;
  font-family: var(--font-display);
  font-size: clamp(32px, 4.6vw, 46px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.04;
  color: var(--fg);
  text-wrap: balance;
}
.lr-index-intro {
  margin: 20px 0 0;
  max-width: 62ch;
  font-size: 17px;
  line-height: 1.62;
  color: var(--fg-muted);
  text-wrap: pretty;
}
.lr-index-intro + .lr-index-intro { margin-top: 14px; }

.lr-list { margin: 44px 0 0; padding: 0 0 96px; list-style: none; display: grid; gap: 12px; }
.lr-card {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 18px;
  align-items: start;
  padding: 22px 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: inherit;
  transition: all var(--dur-base) var(--ease-primary);
}
.lr-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}
.lr-num {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--accent);
  padding-top: 3px;
}
.lr-card-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--fg);
  text-wrap: balance;
}
.lr-card-sum {
  margin: 8px 0 0;
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--fg-muted);
  text-wrap: pretty;
}

/* ── Article ── */
.lr-article-head { padding: 56px 0 0; }
.lr-eyebrow {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-mono); font-size: 12px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--fg-faint);
  margin-top: 18px;
}
.lr-eyebrow a { color: var(--fg-faint); text-decoration: none; }
.lr-eyebrow a:hover { color: var(--accent); }
.lr-eyebrow .sep { opacity: 0.45; }
.lr-title {
  margin: 16px 0 0;
  font-family: var(--font-display);
  font-size: clamp(30px, 4.4vw, 42px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.06;
  color: var(--fg);
  text-wrap: balance;
}
.lr-rule { margin: 34px 0 0; border: 0; border-top: 1px solid var(--border); }

/* The measure. ~66ch of body text at 17.5px is the readable target; the
 * container caps at 760px so code blocks and tables share the same column. */
.lr-body {
  max-width: 68ch;
  padding: 8px 0 8px;
  font-size: 17.5px;
  line-height: 1.72;
  color: var(--fg);
}
.lr-body p { margin: 0 0 24px; font-size: inherit; line-height: inherit; text-wrap: pretty; }
.lr-body > :first-child { margin-top: 0; }

.lr-body .md-h2 {
  position: relative;
  margin: 52px 0 18px;
  font-family: var(--font-display);
  font-size: 25px;
  font-weight: 700;
  letter-spacing: -0.022em;
  line-height: 1.22;
  color: var(--fg);
  scroll-margin-top: 88px;
  text-wrap: balance;
}
.lr-body .md-h3 {
  margin: 38px 0 14px;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--fg);
  scroll-margin-top: 88px;
}
.md-anchor {
  position: absolute;
  left: -0.85em;
  color: var(--accent);
  opacity: 0;
  text-decoration: none;
  font-weight: 400;
  transition: opacity var(--dur-fast);
}
.lr-body .md-h2:hover .md-anchor { opacity: 0.55; }
@media (max-width: 820px) { .md-anchor { display: none; } }

.lr-body a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.lr-body a:hover { color: var(--accent-hover); }
.lr-body em { font-style: italic; }
.lr-body strong { font-weight: 650; }

.md-list { margin: 0 0 24px; padding-left: 1.3em; }
.md-list li { margin: 0 0 8px; }
.md-rule { margin: 40px 0; border: 0; border-top: 1px solid var(--border); }

.md-quote {
  margin: 0 0 24px;
  padding: 2px 0 2px 20px;
  border-left: 3px solid var(--accent);
  color: var(--fg-muted);
}
.md-quote p { margin: 0; font-style: italic; }

/* ── Inline code ── */
.md-code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--bg-quaternary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1px 5px;
  white-space: nowrap;
}

/* ── Code blocks (highlighted at BUILD time — no client JS) ── */
.md-codeblock {
  position: relative;
  margin: 0 0 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
/* Own header row rather than an absolute badge — the code beneath scrolls
 * horizontally, so an overlay label would sit on top of moving text. */
.md-code-lang {
  display: block;
  padding: 6px 14px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  text-align: right;
  color: var(--fg-faint);
  background: var(--bg-quaternary);
  border-bottom: 1px solid var(--border);
}
.md-pre {
  margin: 0;
  padding: 18px 20px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.62;
  tab-size: 2;
  color: var(--fg);
}
.md-pre code { font: inherit; white-space: pre; }

.tk-com  { color: var(--fg-faint); font-style: italic; }
.tk-str  { color: var(--tier-memories-fg); }
.tk-key  { color: var(--tier-wiki-fg); }
.tk-kw   { color: var(--tier-design-fg); font-weight: 600; }
.tk-typ  { color: var(--tier-wiki-fg); }
.tk-num  { color: var(--tier-tasks-fg); }
.tk-fn   { color: var(--accent); }
.tk-attr { color: var(--warning); }
.tk-punc { color: var(--fg-faint); }

/* ── Tables (wrapper scrolls; the page never does) ── */
.md-tablewrap {
  margin: 0 0 28px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
  -webkit-overflow-scrolling: touch;
}
.md-table {
  width: 100%;
  min-width: 480px;
  border-collapse: collapse;
  font-size: 13.5px;
  line-height: 1.5;
}
.md-table th,
.md-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  white-space: nowrap;
}
.md-table th {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--fg-faint);
  background: var(--bg-quaternary);
}
.md-table tbody tr:last-child td { border-bottom: none; }
.md-table tbody tr:hover td { background: var(--bg-quaternary); }
.md-table td .md-code { background: transparent; border: none; padding: 0; }

/* ── Prev / next ── */
.lr-pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 48px 0 0;
  padding: 0 0 96px;
}
.lr-pager-link {
  display: block;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: inherit;
  transition: all var(--dur-base) var(--ease-primary);
}
.lr-pager-link:hover { transform: translateY(-2px); border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.lr-pager-link.is-next { text-align: right; grid-column: 2; }
.lr-pager-dir {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--fg-faint);
  margin-bottom: 7px;
}
.lr-pager-title {
  display: block;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.015em;
  color: var(--fg);
  line-height: 1.3;
}

@media (max-width: 700px) {
  .lr-narrow { padding: 0 20px; }
  .lr-wrap, .lr-article-head { padding-top: 40px; }
  .lr-index-head { padding-top: 48px; }
  .lr-body { font-size: 16.5px; line-height: 1.68; }
  .lr-body .md-h2 { font-size: 22px; margin-top: 40px; }
  .lr-pager { grid-template-columns: 1fr; }
  .lr-pager-link.is-next { grid-column: 1; text-align: left; }
  .lr-card { grid-template-columns: 34px 1fr; gap: 12px; padding: 18px 18px; }
  .md-pre { font-size: 12px; padding: 16px 14px; }
}
