/* =========================================================================
   Queryable — Blog stylesheet
   Tokens, base, shared components and header/footer mirror the homepage
   (index.html) so the blog is pixel-consistent. Blog/article-specific
   styles live in the last two blocks. Driven entirely by CSS custom
   properties — see DESIGN_SYSTEM.md.
   ========================================================================= */

/* ---------- Tokens ---------- */
:root {
  --font-serif: 'Instrument Serif', ui-serif, Georgia, serif;
  --font-sans: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}
:root[data-theme="dark"] {
  --bg-primary: #0a0a0a;
  --bg-secondary: #141414;
  --bg-tertiary: #1c1c1c;
  --fg-primary: #f5f5f4;
  --fg-secondary: #a8a29e;
  --fg-tertiary: #78716c;
  --border: #2a2a2a;
  --border-soft: #1f1f1f;
  --accent: #3f46ff;
  --accent-hover: #5a60ff;
  --selection-bg: #3f46ff;
  --selection-fg: #ffffff;
}
:root[data-theme="light"] {
  --bg-primary: #ffffff;
  --bg-secondary: #fafaf9;
  --bg-tertiary: #f5f5f4;
  --fg-primary: #0a0a0a;
  --fg-secondary: #57534e;
  --fg-tertiary: #78716c;
  --border: #e7e5e4;
  --border-soft: #f5f5f4;
  --accent: #3f46ff;
  --accent-hover: #2a31d9;
  --selection-bg: #3f46ff;
  --selection-fg: #ffffff;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg-primary);
  color: var(--fg-primary);
  font-family: var(--font-sans);
  font-feature-settings: 'ss01', 'cv11';
  font-size: 1rem;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { letter-spacing: -0.02em; line-height: 1.05; font-weight: 400; }
p { hyphens: auto; line-height: 1.55; max-width: 72ch; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
::selection { background: var(--selection-bg); color: var(--selection-fg); }
:focus { outline: none; }
:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; border-radius: 2px; }

.serif { font-family: var(--font-serif); letter-spacing: -0.01em; font-feature-settings: 'ss01'; }
.mono { font-family: var(--font-mono); font-feature-settings: 'ss01', 'zero'; }

.serif-display::before, .serif-display::after { content: ''; display: block; height: 0; }
.serif-display::before { margin-top: -0.18em; }
.serif-display::after { margin-bottom: -0.18em; }

.container-app {
  max-width: 1280px;
  margin-inline: auto;
  padding-inline: clamp(1.5rem, 4vw, 3rem);
}

.skip-link {
  position: fixed; top: 0; left: 0;
  padding: 0.75rem 1rem;
  background: var(--accent); color: #fff; font-weight: 500;
  transform: translateY(-120%);
  transition: transform 200ms ease;
  z-index: 100;
}
.skip-link:focus-visible { transform: translateY(0); }

/* ---------- Shared components ---------- */
.surface {
  background: var(--bg-secondary);
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  overflow: hidden;
  transition: border-color 200ms ease, background 200ms ease;
}
.surface:hover { border-color: var(--border); }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  font-family: var(--font-sans);
  font-weight: 500; font-size: 0.9375rem; line-height: 1;
  border-radius: 9999px;
  white-space: nowrap; cursor: pointer;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease;
}
.btn-primary { background: var(--accent); color: #fff; border: 1px solid var(--accent); }
.btn-primary:hover, .btn-primary:focus-visible { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { background: transparent; color: var(--fg-primary); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg-secondary); border-color: var(--fg-tertiary); }
.btn-text { background: transparent; color: var(--fg-primary); padding: 0.5rem 0.75rem; border: 1px solid transparent; }
.btn-text:hover { background: var(--bg-secondary); }
.btn-lg { padding: 0.8125rem 1.375rem; font-size: 1rem; }

.cat-chip {
  display: inline-flex;
  padding: 0.25rem 0.55rem;
  border-radius: 9999px;
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--accent);
  border: 1px solid color-mix(in oklab, var(--accent) 40%, transparent);
  background: color-mix(in oklab, var(--accent) 10%, transparent);
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--fg-tertiary);
}
.eyebrow-accent { color: var(--accent); }

.arrow-link {
  display: inline-flex; align-items: center; gap: 0.4rem;
  color: var(--fg-secondary); font-weight: 500; font-size: 0.9375rem;
}
.arrow-link .arrow { display: inline-block; transition: transform 150ms ease; }
.arrow-link:hover .arrow, .arrow-link:focus-visible .arrow { transform: translateX(0.2em); }
.arrow-link:hover { color: var(--fg-primary); }

.callout {
  position: relative;
  border-radius: 16px;
  padding: 1.5rem 1.75rem;
  border: 1px solid var(--border-soft);
  background: linear-gradient(180deg, color-mix(in oklab, var(--accent) 8%, var(--bg-secondary)) 0%, var(--bg-secondary) 100%);
}
.callout-rail {
  position: absolute; left: 0; top: 1.5rem; bottom: 1.5rem;
  width: 3px; border-radius: 0 999px 999px 0;
  background: var(--accent);
}

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in oklab, var(--bg-primary) 82%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-soft);
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 64px; gap: 1rem;
}
.brand { display: inline-flex; align-items: center; gap: 0.625rem; font-weight: 600; font-size: 1.0625rem; letter-spacing: -0.01em; }
.logo-mark { width: 22px; height: 22px; flex: none; display: block; }
:root[data-theme="light"] .logo-mark { filter: invert(1); }
.nav-links { display: none; align-items: center; gap: 0.25rem; }
.nav-links a {
  padding: 0.5rem 0.75rem; border-radius: 9999px;
  font-size: 0.9063rem; color: var(--fg-secondary);
  transition: color 150ms ease, background 150ms ease;
}
.nav-links a:hover { color: var(--fg-primary); background: var(--bg-secondary); }
.nav-links a[aria-current="page"] { color: var(--fg-primary); }
.header-actions { display: flex; align-items: center; gap: 0.5rem; }
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 9999px;
  background: transparent; border: 1px solid var(--border);
  color: var(--fg-secondary); cursor: pointer;
  transition: color 150ms ease, border-color 150ms ease, background 150ms ease;
}
.theme-toggle:hover { color: var(--fg-primary); background: var(--bg-secondary); border-color: var(--fg-tertiary); }
:root[data-theme="dark"] .icon-sun { display: block; }
:root[data-theme="dark"] .icon-moon { display: none; }
:root[data-theme="light"] .icon-sun { display: none; }
:root[data-theme="light"] .icon-moon { display: block; }
@media (min-width: 62em) {
  .nav-links { display: flex; }
}

/* ---------- Pre-footer (giant wordmark) ---------- */
.pre-footer {
  position: relative; overflow: hidden;
  padding: 5rem 0 2.5rem;
}
@media (min-width: 48em) { .pre-footer { padding: 7rem 0 4rem; } }
.pre-footer-word {
  font-size: clamp(4rem, 20vw, 18rem);
  line-height: 0.9;
  letter-spacing: -0.04em;
  color: var(--fg-primary);
  user-select: none;
  white-space: nowrap;
}

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border-soft); padding-top: 1.5rem; padding-bottom: 2.5rem; }
.footer-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2rem;
  padding-top: 3rem;
}
@media (min-width: 48em) { .footer-grid { grid-template-columns: repeat(4, 1fr); gap: 2.5rem; } }
@media (min-width: 62em) { .footer-grid { grid-template-columns: repeat(5, 1fr); } }
.footer-brand { grid-column: span 2; }
.footer-brand p {
  margin-top: 1rem;
  font-size: 0.875rem; line-height: 1.6;
  color: var(--fg-secondary);
  max-width: 20rem;
}
.footer-col .eyebrow { margin-bottom: 1rem; }
.footer-col ul { list-style: none; display: flex; flex-direction: column; gap: 0.625rem; }
.footer-col a {
  font-size: 0.875rem; color: var(--fg-secondary);
  transition: color 150ms ease;
}
.footer-col a:hover { color: var(--fg-primary); }
.footer-bottom {
  margin-top: 3.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-soft);
  text-align: center;
  font-size: 0.75rem;
  color: var(--fg-tertiary);
}
.footer-bottom a { text-decoration: underline; text-underline-offset: 2px; transition: color 150ms ease; }
.footer-bottom a:hover { color: var(--fg-primary); }
.footer-contact-links { display: flex; gap: 0.625rem; margin-top: 1.25rem; }
.footer-contact-links a {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.25rem; height: 2.25rem; border-radius: 50%;
  border: 1px solid var(--border-soft);
  color: var(--fg-secondary);
  transition: color 150ms ease, border-color 150ms ease;
}
.footer-contact-links a:hover { color: var(--fg-primary); border-color: var(--fg-secondary); }

/* ---------- Reveal ---------- */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity 400ms cubic-bezier(0.16, 1, 0.3, 1), transform 400ms cubic-bezier(0.16, 1, 0.3, 1); }
.reveal.revealed { opacity: 1; transform: none; }

/* =========================================================================
   Blog index
   ========================================================================= */
.blog-hero {
  position: relative;
  border-bottom: 1px solid var(--border-soft);
  padding-block: clamp(3rem, 6vw, 5rem) clamp(2.5rem, 5vw, 3.5rem);
}
.blog-hero .eyebrow { margin-bottom: 1rem; }
.blog-hero h1 {
  font-family: var(--font-serif);
  font-size: clamp(2.5rem, 6vw, 4.5rem);
  margin-bottom: 1.25rem;
}
.blog-hero h1 em { font-style: italic; color: var(--accent); }
.blog-hero p {
  font-size: 1.125rem; color: var(--fg-secondary);
  max-width: 38rem;
}

.post-list { padding-block: clamp(3rem, 6vw, 4.5rem); }
.post-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}
@media (min-width: 48em) { .post-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 62em) { .post-grid { grid-template-columns: repeat(3, 1fr); } }

.post-card {
  display: flex;
  flex-direction: column;
  padding: 1.625rem 1.5rem 1.5rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  transition: border-color 200ms ease, transform 200ms ease;
}
.post-card:hover { border-color: var(--border); transform: translateY(-2px); }
.post-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.post-card .cat-chip { align-self: flex-start; margin-bottom: 1rem; }
.post-card h2 {
  font-family: var(--font-serif);
  font-size: 1.625rem;
  line-height: 1.1;
  margin-bottom: 0.625rem;
}
.post-card p {
  font-size: 0.9375rem;
  color: var(--fg-secondary);
  line-height: 1.55;
}
.post-meta {
  margin-top: auto;
  padding-top: 1.25rem;
  display: flex; align-items: center; gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 11.5px; color: var(--fg-tertiary);
}
.post-meta .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--fg-tertiary); }
.post-card .read-on {
  margin-top: 1rem;
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-size: 0.875rem; font-weight: 500;
  color: var(--accent);
}
.post-card .read-on .arrow { transition: transform 150ms ease; }
.post-card:hover .read-on .arrow { transform: translateX(0.2em); }

/* =========================================================================
   Article
   ========================================================================= */
.article { padding-block: clamp(2.5rem, 5vw, 3.5rem) clamp(3rem, 6vw, 4.5rem); }
.article-wrap { max-width: 44rem; margin-inline: auto; }

.back-link {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 12px; letter-spacing: 0.04em;
  color: var(--fg-tertiary);
  margin-bottom: 2rem;
  transition: color 150ms ease;
}
.back-link .arrow { transition: transform 150ms ease; }
.back-link:hover { color: var(--fg-primary); }
.back-link:hover .arrow { transform: translateX(-0.2em); }

.article-head { margin-bottom: clamp(2rem, 4vw, 2.75rem); }
.article-head .cat-chip { margin-bottom: 1.25rem; }
.article-title {
  font-family: var(--font-serif);
  font-size: clamp(2.25rem, 5vw, 3.5rem);
  margin-bottom: 1.25rem;
}
.article-title em { font-style: italic; color: var(--accent); }
.article-lead {
  font-size: 1.25rem;
  line-height: 1.5;
  color: var(--fg-secondary);
  margin-bottom: 1.75rem;
}
.article-byline {
  display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 12.5px; color: var(--fg-tertiary);
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-soft);
}
.article-byline .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--fg-tertiary); }
.article-byline .author { color: var(--fg-secondary); }

/* Prose */
.prose { color: var(--fg-secondary); }
.prose > * + * { margin-top: 1.375rem; }
.prose p { font-size: 1.0625rem; line-height: 1.7; max-width: none; }
.prose h2 {
  font-family: var(--font-serif);
  font-size: clamp(1.75rem, 3.5vw, 2.25rem);
  color: var(--fg-primary);
  margin-top: 2.75rem;
  line-height: 1.1;
}
.prose h3 {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  color: var(--fg-primary);
  margin-top: 2rem;
}
.prose strong { color: var(--fg-primary); font-weight: 600; }
.prose em { font-style: italic; }
/* Scope link styling to real prose text — not UI components (.btn, cards)
   that may also live inside .prose. */
.prose p a, .prose li a, .prose h2 a, .prose h3 a, .prose blockquote a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
  transition: color 150ms ease;
}
.prose p a:hover, .prose li a:hover, .prose h2 a:hover,
.prose h3 a:hover, .prose blockquote a:hover { color: var(--accent-hover); }
.prose ul, .prose ol { padding-left: 1.25rem; }
.prose li { font-size: 1.0625rem; line-height: 1.65; margin-top: 0.5rem; }
.prose li::marker { color: var(--fg-tertiary); }
.prose ul li::marker { color: var(--accent); }
.prose blockquote {
  margin-top: 2rem;
  padding: 1.5rem 1.75rem;
  position: relative;
  border-radius: 16px;
  border: 1px solid var(--border-soft);
  background: linear-gradient(180deg, color-mix(in oklab, var(--accent) 8%, var(--bg-secondary)) 0%, var(--bg-secondary) 100%);
  font-family: var(--font-serif);
  font-size: 1.5rem;
  line-height: 1.35;
  color: var(--fg-primary);
}
.prose blockquote p { font-size: inherit; line-height: inherit; max-width: none; }
.prose hr { border: none; border-top: 1px solid var(--border-soft); margin-block: 2.5rem; }
.prose code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  padding: 0.15em 0.4em;
  border-radius: 6px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-soft);
  color: var(--fg-primary);
}
.prose .lead { font-size: 1.1875rem; color: var(--fg-primary); }

/* Key-takeaways box */
.takeaways {
  margin-top: 2.5rem;
  padding: 1.5rem 1.75rem;
  border-radius: 16px;
  border: 1px solid var(--border-soft);
  background: var(--bg-secondary);
}
.takeaways .eyebrow { margin-bottom: 1rem; }
.takeaways ul { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 0.75rem; }
.takeaways li {
  display: flex; gap: 0.75rem; align-items: flex-start;
  font-size: 0.9688rem; line-height: 1.55; color: var(--fg-secondary); margin: 0;
}
.takeaways li .tick { color: var(--accent); flex: none; margin-top: 2px; }

/* End-of-article CTA */
.article-cta {
  margin-top: clamp(3rem, 6vw, 4rem);
  text-align: center;
  padding: clamp(2.5rem, 5vw, 3.5rem) clamp(1.5rem, 4vw, 3rem);
  border-radius: 20px;
  border: 1px solid var(--border-soft);
  background: linear-gradient(180deg, color-mix(in oklab, var(--accent) 9%, var(--bg-secondary)) 0%, var(--bg-secondary) 100%);
}
.article-cta h2 { font-family: var(--font-serif); font-size: clamp(1.875rem, 4vw, 2.75rem); margin-bottom: 0.875rem; }
.article-cta p { color: var(--fg-secondary); font-size: 1.0625rem; margin: 0 auto 1.75rem; }
.article-cta .ctas { display: flex; flex-wrap: wrap; gap: 0.75rem; justify-content: center; }

/* Related posts */
.related { margin-top: clamp(3rem, 6vw, 4rem); }
.related .eyebrow { margin-bottom: 1.25rem; }
.related-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 40em) { .related-grid { grid-template-columns: repeat(2, 1fr); } }
.related-card {
  display: flex; flex-direction: column;
  padding: 1.25rem 1.375rem;
  border-radius: 14px;
  border: 1px solid var(--border-soft);
  background: var(--bg-secondary);
  transition: border-color 200ms ease, transform 200ms ease;
}
.related-card:hover { border-color: var(--border); transform: translateY(-2px); }
.related-card .cat-chip { align-self: flex-start; margin-bottom: 0.75rem; }
.related-card h3 { font-family: var(--font-serif); font-size: 1.25rem; color: var(--fg-primary); line-height: 1.15; }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .reveal { opacity: 1; transform: none; }
}
