/* Blog post reading layout (Nov 2026).
   Every post shares one shell: breadcrumb div, header div (h1), then
   <article class="px-4 pb-20"><div class="container-site mx-auto max-w-3xl blog-body">.
   Rules key off that shell with :has(), so no post needs its markup changed.
   blog-post.js adds the table of contents, progress bar and table wrappers. */

body:has(.blog-body) {
  --bp-ink: #0f172a;
  --bp-body: #2b3445;
  --bp-mute: #64748b;
  --bp-line: #e5e8ef;
  --bp-soft: #f6f7fb;
  --bp-brand: #1c3ef2;
  --bp-brand-soft: #eef1fe;
  --bp-amber: #f59e0b;
  --bp-col: 720px;
  background: #ffffff;
}

/* One reading column for the header, the body and everything under it */
body:has(.blog-body) .container-site.max-w-3xl { max-width: var(--bp-col) !important; margin-left: auto; margin-right: auto; }
body:has(.blog-body) div.pt-24:has(+ div h1) > .container-site { max-width: var(--bp-col); }

/* Header */
body:has(.blog-body) h1 {
  font-family: var(--font-display, "Bricolage Grotesque", system-ui, sans-serif);
  font-size: clamp(2rem, 4.4vw, 3rem) !important;
  line-height: 1.12 !important;
  letter-spacing: -0.025em;
  color: var(--bp-ink);
  text-wrap: balance;
}
body:has(.blog-body) div.px-4.pb-8:has(h1) > .container-site { border-bottom: 1px solid var(--bp-line); padding-bottom: 1.75rem; margin-bottom: 2.5rem; }
body:has(.blog-body) div.px-4.pb-8:has(h1) .mb-8 { margin-bottom: 0; }

/* Body type: ~68 characters a line, generous leading */
.blog-body { font-size: 1.1875rem; line-height: 1.75; color: var(--bp-body); font-feature-settings: "kern", "liga"; }
.blog-body > * + * { margin-top: 0; }
.blog-body p { margin: 0 0 1.35em; }
.blog-body > p:first-child { font-size: 1.3125rem; line-height: 1.6; color: var(--bp-ink); }
.blog-body > p:first-child strong { font-weight: 600; }
.blog-body strong { color: var(--bp-ink); font-weight: 650; }
.blog-body a { color: var(--bp-brand); text-decoration: underline; text-decoration-color: rgba(28, 62, 242, .3); text-underline-offset: 3px; text-decoration-thickness: 1.5px; }
.blog-body a:hover { text-decoration-color: var(--bp-brand); }

.blog-body h2 {
  font-family: var(--font-display, "Bricolage Grotesque", system-ui, sans-serif);
  font-size: clamp(1.55rem, 2.6vw, 1.95rem);
  line-height: 1.22;
  letter-spacing: -0.02em;
  font-weight: 750;
  color: var(--bp-ink);
  margin: 2.6em 0 .7em;
  scroll-margin-top: 96px;
  text-wrap: balance;
}
.blog-body h3 {
  font-size: 1.3rem;
  line-height: 1.35;
  font-weight: 700;
  color: var(--bp-ink);
  margin: 2em 0 .5em;
  scroll-margin-top: 96px;
}
.blog-body h4 { font-size: 1.1rem; font-weight: 700; color: var(--bp-ink); margin: 1.6em 0 .4em; }

/* Lists */
.blog-body ul, .blog-body ol { margin: 0 0 1.5em; padding-left: 1.4em; }
.blog-body ul { list-style: none; padding-left: 1.5em; }
.blog-body ul > li { position: relative; }
.blog-body ul > li::before { content: ""; position: absolute; left: -1.1em; top: .72em; width: 7px; height: 7px; border-radius: 2px; background: var(--bp-brand); }
.blog-body ol { list-style: decimal; }
.blog-body ol > li::marker { color: var(--bp-brand); font-weight: 700; }
.blog-body li { margin: 0 0 .6em; padding-left: .2em; }
.blog-body li > p { margin-bottom: .4em; }

/* Callouts: blockquote is a soft card; "Key takeaways" gets the brand treatment */
.blog-body blockquote {
  margin: 2em 0;
  padding: 1.4em 1.6em;
  background: var(--bp-soft);
  border: 1px solid var(--bp-line);
  border-left: 4px solid var(--bp-brand);
  border-radius: 14px;
  color: var(--bp-body);
  font-size: 1.0625rem;
}
.blog-body blockquote > :last-child { margin-bottom: 0; }
.blog-body blockquote.bp-takeaways {
  background: var(--bp-brand-soft);
  border: 1px solid #d9e0fd;
  border-left: 1px solid #d9e0fd;
  padding: 1.6em 1.7em 1.2em;
}
.blog-body blockquote.bp-takeaways > p:first-child {
  font-family: var(--font-label, "Geist Mono", ui-monospace, monospace);
  font-size: .75rem; letter-spacing: .14em; text-transform: uppercase;
  color: var(--bp-brand); margin-bottom: .9em;
}
.blog-body blockquote.bp-takeaways > p:first-child strong { color: var(--bp-brand); font-weight: 600; }
.blog-body blockquote.bp-takeaways li { margin-bottom: .55em; }

/* Tables: bordered card, scrolls on its own on small screens */
.blog-body .bp-table { margin: 2em 0; border: 1px solid var(--bp-line); border-radius: 14px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.blog-body .bp-table table { margin: 0 !important; display: table !important; min-width: 100%; font-size: .95rem; }
.blog-body table { font-variant-numeric: tabular-nums; }
.blog-body thead { background: var(--bp-soft) !important; }
.blog-body th { font-size: .8125rem; text-transform: none; color: var(--bp-ink) !important; }
.blog-body td, .blog-body th { padding: .8rem 1rem !important; }
.blog-body td:first-child { font-weight: 600; color: var(--bp-ink); }

/* Figures and images */
.blog-body img { max-width: 100%; height: auto; border-radius: 14px; }
.blog-body figure, .blog-body .aq-fig { margin: 2.2em 0; }
.blog-body figure img { display: block; width: 100%; border: 1px solid var(--bp-line); border-radius: 14px; margin: 0; background: #fff; }
.blog-body figcaption { margin-top: .7em; font-size: .9rem; line-height: 1.55; color: var(--bp-mute); }
.blog-body figcaption a { color: inherit; }

/* Code and rules */
.blog-body code { font-family: var(--font-label, ui-monospace, monospace); font-size: .88em; background: var(--bp-soft); border: 1px solid var(--bp-line); border-radius: 6px; padding: .1em .35em; }
.blog-body hr { border: 0; border-top: 1px solid var(--bp-line); margin: 2.5em 0; }

/* Related reading */
.blog-body .aq-related { background: var(--bp-soft) !important; border: 1px solid var(--bp-line) !important; border-radius: 16px !important; }
.blog-body .aq-related h2 { margin-top: 0; font-size: 1.25rem; }
.blog-body .aq-related ul { margin-bottom: 0; }

/* Table of contents: left rail on wide screens, hidden elsewhere */
.bp-toc { display: none; }
@media (min-width: 1240px) {
  body:has(.blog-body) article.px-4:has(.bp-toc) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--bp-col) minmax(0, 1fr);
    column-gap: 56px;
    align-items: start;
  }
  body:has(.blog-body) article.px-4:has(.bp-toc) > .blog-body { grid-column: 2; grid-row: 1; width: 100%; max-width: none !important; margin: 0; }
  body:has(.blog-body) article.px-4:has(.bp-toc) > :not(.blog-body):not(.bp-toc) { grid-column: 2; }
  .bp-toc {
    display: block; grid-column: 1; grid-row: 1; justify-self: end;
    width: 240px; position: sticky; top: 104px;
    max-height: calc(100vh - 140px); overflow-y: auto;
    font-size: .875rem; line-height: 1.45;
  }
  .bp-toc p { font-family: var(--font-label, ui-monospace, monospace); font-size: .7rem; letter-spacing: .14em; text-transform: uppercase; color: var(--bp-mute); margin: 0 0 .8em; }
  .bp-toc ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--bp-line); }
  .bp-toc a { display: block; padding: .38em 0 .38em 1em; margin-left: -1px; border-left: 2px solid transparent; color: var(--bp-mute); text-decoration: none; }
  .bp-toc a:hover { color: var(--bp-ink); }
  .bp-toc a[aria-current="true"] { color: var(--bp-brand); border-left-color: var(--bp-brand); font-weight: 600; }
}

/* Reading progress */
.bp-progress { position: fixed; top: 0; left: 0; height: 4px; width: 100%; transform-origin: 0 50%; transform: scaleX(0); background: var(--bp-brand); z-index: 70; pointer-events: none; }

/* Phones */
@media (max-width: 640px) {
  .blog-body { font-size: 1.0625rem; line-height: 1.72; }
  .blog-body > p:first-child { font-size: 1.15rem; }
  .blog-body blockquote { padding: 1.15em 1.2em; margin: 1.6em 0; }
  .blog-body h2 { margin-top: 2.1em; }
  .blog-body ul { padding-left: 1.3em; }
}

@media (prefers-reduced-motion: reduce) { .bp-toc a { transition: none; } }

/* Solid menu bar so body text never shows through it while reading */
body:has(.blog-body) #main-nav { background: #ffffff !important; backdrop-filter: none; box-shadow: 0 1px 0 var(--bp-line); }
body:has(.blog-body) div.px-4.pb-8:has(h1) .text-gray-500 { flex-wrap: wrap; row-gap: 4px; }
body:has(.blog-body) div.px-4.pb-8:has(h1) .text-gray-500 > span { white-space: nowrap; }
@media (max-width: 640px) {
  body:has(.blog-body) div.px-4.pb-8:has(h1) > .container-site { margin-bottom: 1.5rem; padding-bottom: 1.25rem; }
  body:has(.blog-body) div.px-4.pb-8:has(h1) { padding-bottom: 0 !important; }
}
