/* Blog engine stylesheet.
 *
 * Two concerns: (1) the rendered post body — every selector prefixed .bp- ,
 * every colour taken from the marketing site's theme variables so dark mode
 * works with no second sheet and nothing collides with the !important
 * .text-primary / .bg-primary utilities in marketing_layout.html; (2) the
 * /blog listing + post page chrome, prefixed .blog- .
 *
 * Linked only from marketing_blog_*.html and admin_blog_edit.html.
 */

/* ========================================================================
   1. RENDERED POST BODY  (.bp-)
   ======================================================================== */
.bp-body {
  font-size: 1.075rem;
  line-height: 1.75;
  color: var(--text-primary);
  max-width: 44rem;
}
.bp-body > * + * { margin-top: 1.5rem; }

.bp-p { margin: 0; }
.bp-body a { color: var(--accent-primary); text-decoration: underline; text-underline-offset: 2px; }
.bp-body a:hover { color: var(--accent-primary-dark, var(--accent-primary)); }

.bp-h2, .bp-h3, .bp-h4 {
  position: relative;
  color: var(--text-primary);
  line-height: 1.25;
  scroll-margin-top: 6rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 2.75rem 0 0 !important;
}
.bp-h2 { font-size: 1.7rem; }
.bp-h3 { font-size: 1.32rem; margin-top: 2.25rem !important; }
.bp-h4 { font-size: 1.1rem; margin-top: 1.75rem !important; }
/* The rendered heading's anchor link is literally the text "#" (baked into
   body_html at save time in services/blog/render.py -- changing that would only
   affect posts saved AFTER a deploy, not the ones already published). Swapping it
   for an icon purely in CSS -- hide the "#" glyph, draw a Font Awesome icon via
   ::before -- applies to every post immediately, old and new, with no backfill. */
.bp-anchor {
  position: absolute; left: -1.85rem; top: 0.05em;
  width: 1.6rem; height: 1.6rem; display: inline-flex; align-items: center; justify-content: center;
  opacity: 0; text-decoration: none; color: var(--text-muted); border-radius: 7px;
  font-size: 0; /* hides the "#" text node -- the icon is the only visible content */
  transition: opacity .12s, background .12s, color .12s;
}
.bp-anchor::before {
  font-family: "Font Awesome 6 Free"; font-weight: 900; content: "\f0c1"; /* fa-link */
  font-size: 0.82rem;
}
.bp-h2:hover .bp-anchor, .bp-h3:hover .bp-anchor, .bp-h4:hover .bp-anchor,
.bp-anchor:focus-visible { opacity: 1; }
.bp-anchor:hover, .bp-anchor:focus-visible { color: var(--accent-primary); background: var(--bg-secondary); }
.bp-anchor.is-copied { opacity: 1; color: #10b981; }
.bp-anchor.is-copied::before { content: "\f00c"; } /* fa-check, shown briefly after a successful copy */

.bp-ul, .bp-ol { margin: 0; padding-left: 1.5rem; }
.bp-ul li, .bp-ol li { margin: 0.4rem 0; }
.bp-ul { list-style: disc; }
.bp-ol { list-style: decimal; }

/* Longhand, not `margin: 2rem 0` -- the shorthand also sets left/right to 0
   !important, which silently won over --wide/--full's margin-left: 50%
   centering trick regardless of its higher class-selector specificity
   (!important short-circuits normal specificity/source-order resolution).
   That's what was pulling wide images off-center: only the transform half
   of the centering pair (translateX(-50%)) was applying, the margin half
   was being zeroed out here. */
.bp-figure { margin-top: 2rem !important; margin-bottom: 2rem !important; }
.bp-figure--inset { max-width: 100%; }
/* `width`, not `max-width` -- a block box with width:auto and an explicit
   margin-left resolves its OWN width to (container - margin-left), i.e.
   exactly 50% of the container here, and max-width can only shrink that
   further, never grow it back out to the intended 52rem/100vw. That made
   every "wide"/"full" image (and the CTA callout below) render at half
   its container's width instead of bleeding past it. Giving the box an
   explicit width breaks that auto-margin coupling, matching the CSS bleed
   technique this was always meant to be. Confirmed via a headless-browser
   computed-style check: 352px (wrong, exactly half of a 704px column) vs
   815px (right, min(52rem, 100vw-2rem) at that viewport) before/after. */
.bp-figure--wide { width: min(52rem, 100vw - 2rem); margin-left: 50%; transform: translateX(-50%); }
.bp-figure--full { width: 100vw; margin-left: 50%; transform: translateX(-50%); }
.bp-img {
  width: 100%; height: auto; display: block;
  border-radius: 12px; border: 1px solid var(--card-border);
  background: var(--bg-secondary);
}
.bp-caption {
  margin-top: 0.6rem; font-size: 0.9rem; color: var(--text-muted);
  text-align: center; line-height: 1.5;
}

.bp-quote {
  margin: 2rem 0 !important; padding: 0.25rem 0 0.25rem 1.25rem;
  border-left: 3px solid var(--accent-primary);
}
.bp-quote p { margin: 0; font-size: 1.2rem; line-height: 1.6; color: var(--text-primary); font-style: italic; }
.bp-cite {
  display: block; margin-top: 0.6rem; font-style: normal;
  font-size: 0.9rem; color: var(--text-muted);
}
.bp-cite::before { content: "— "; }

.bp-callout {
  margin: 2rem 0 !important; padding: 1.25rem 1.4rem; border-radius: 12px;
  border: 1px solid var(--card-border); background: var(--card-bg);
  box-shadow: var(--shadow-light);
}
.bp-callout--note { border-left: 3px solid var(--text-muted); }
.bp-callout--tip { border-left: 3px solid var(--success-emerald, #10b981); }
.bp-callout--warning { border-left: 3px solid #f59e0b; }
.bp-callout__title { margin: 0 0 0.35rem; font-weight: 700; color: var(--text-primary); }
.bp-callout__body { margin: 0; color: var(--text-secondary); }
.bp-callout__cta {
  display: inline-block; margin-top: 0.9rem; padding: 0.55rem 1.1rem;
  background: var(--accent-primary); color: #fff !important; border-radius: 8px;
  font-weight: 600; text-decoration: none !important; font-size: 0.95rem;
}
.bp-callout__cta:hover { background: var(--accent-primary-dark, var(--accent-primary)); }

/* The CTA variant is deliberately the loudest thing in the body — a full-bleed
   colour banner, not another bordered card, so a "book a demo" moment reads
   as a moment rather than a footnote. Breaks out to the same width as a wide
   image so it doesn't get lost in the 44rem reading column. */
.bp-callout--cta {
  border: 0; text-align: center; padding: 2.25rem 2rem;
  /* width, not max-width -- same auto-margin bug as .bp-figure--wide above:
     this was rendering at half the reading column's width, the opposite of
     the "so it doesn't get lost in the 44rem reading column" comment's intent. */
  width: min(52rem, 100vw - 2rem); margin-left: 50% !important; transform: translateX(-50%);
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary, var(--accent-primary-dark, var(--accent-primary))));
  box-shadow: var(--shadow-heavy);
}
.bp-callout--cta .bp-callout__title {
  color: #fff; font-size: 1.35rem; font-weight: 800; letter-spacing: -0.01em; margin-bottom: 0.5rem;
}
.bp-callout--cta .bp-callout__body { color: rgba(255,255,255,0.92); font-size: 1.02rem; max-width: 34rem; margin: 0 auto; }
.bp-callout--cta .bp-callout__cta {
  background: #fff; color: var(--accent-primary-dark, var(--accent-primary)) !important;
  margin-top: 1.25rem; padding: 0.7rem 1.6rem; font-size: 1rem;
}
.bp-callout--cta .bp-callout__cta:hover { background: #fff; opacity: 0.92; }
@media (max-width: 640px) {
  .bp-callout--cta { margin-left: 0 !important; transform: none; max-width: 100%; padding: 1.75rem 1.25rem; }
}

/* Post-level CTA row, rendered right under the byline — "Call To Action
   Buttons Under Title" from the blog layout brief. Deliberately lighter
   weight than the in-body CTA banner: one compact button, no colour block. */
.blog-intro-cta { margin-top: 1.1rem; }
.blog-intro-cta a {
  display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.55rem 1.2rem;
  background: var(--accent-primary); color: #fff; border-radius: 8px;
  font-weight: 600; font-size: 0.92rem; text-decoration: none;
}
.blog-intro-cta a:hover { background: var(--accent-primary-dark, var(--accent-primary)); }

.bp-pre {
  margin: 1.75rem 0 !important; padding: 1rem 1.1rem; border-radius: 10px;
  background: var(--bg-secondary); border: 1px solid var(--card-border);
  overflow-x: auto; font-size: 0.9rem; line-height: 1.6;
}
.bp-code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; color: var(--text-primary); white-space: pre; }

.bp-hr { margin: 2.5rem 0 !important; border: 0; border-top: 1px solid var(--border-color); }

.bp-table-wrap { margin: 1.75rem 0 !important; overflow-x: auto; }
.bp-table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.bp-table th, .bp-table td { padding: 0.55rem 0.8rem; border: 1px solid var(--card-border); text-align: left; vertical-align: top; }
.bp-table thead th { background: var(--bg-secondary); font-weight: 600; color: var(--text-primary); }
.bp-table tbody tr:nth-child(even) { background: var(--bg-secondary); }

/* KaTeX renders into these on page load (see marketing_blog_post.html) --
   sized/spaced to match the rest of .bp-body until it does. */
.bp-equation { color: var(--text-primary); }
.bp-equation--block { display: block; margin: 1.75rem 0 !important; overflow-x: auto; text-align: center; }
.bp-equation--inline { display: inline-block; }

/* video facade — poster with a play button, iframe swapped in on click */
.bp-video-wrap { position: relative; width: 100%; overflow: hidden; border-radius: 12px; border: 1px solid var(--card-border); background: #000; }
.bp-video, .bp-video-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.bp-video-facade {
  position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer;
  border: 0; padding: 0; background-size: cover; background-position: center;
  display: flex; align-items: center; justify-content: center;
}
.bp-video-facade::after { content: ""; position: absolute; inset: 0; background: rgba(0,0,0,0.25); transition: background .15s; }
.bp-video-facade:hover::after { background: rgba(0,0,0,0.1); }
.bp-video-play {
  position: relative; z-index: 1; width: 68px; height: 48px; border-radius: 12px;
  background: rgba(0,0,0,0.65); color: #fff; font-size: 1.4rem;
  display: flex; align-items: center; justify-content: center;
}
.bp-video-facade:hover .bp-video-play { background: var(--accent-primary); }

@media (max-width: 640px) {
  /* transform is fully off here, so there's no bleed-centering trick left to
     conflict with -- margin:auto safely centers a narrower image (one with
     an inline max-width from the "Max width" slider) the same way inset
     already does, instead of leaving it flush against the left edge. */
  .bp-figure--wide, .bp-figure--full { margin-left: auto; margin-right: auto; transform: none; max-width: 100%; }
}

@media (min-width: 1100px) {
  /* Above 1100px .blog-post-layout switches to a 12rem-sidebar + 3rem-gap
     grid (see .blog-toc below) and .bp-body stops being centered on the
     page -- it's just the grid's second column. The margin-left:50% /
     translateX(-50%) breakout above centers on .bp-body's OWN box, so once
     .bp-body is offset right by the sidebar+gap, "wide"/"full" images and
     the CTA callout overshoot left past .bp-body's own edge and land on top
     of the sticky TOC. There's no room to bleed wider than the article
     column here without covering the sidebar, so cap it to 100% instead. */
  .bp-figure--wide, .bp-figure--full, .bp-callout--cta {
    width: 100%; margin-left: 0 !important; transform: none;
  }
}

/* ========================================================================
   2. /blog LISTING + POST CHROME  (.blog-)
   ======================================================================== */
.blog-wrap { max-width: 68rem; margin: 0 auto; }

.blog-head { text-align: center; margin-bottom: 2.5rem; }
.blog-head h1 { font-size: clamp(2rem, 5vw, 2.8rem); font-weight: 800; letter-spacing: -0.02em; color: var(--text-primary); margin: 0 0 0.75rem; }
.blog-head p { color: var(--text-secondary); font-size: 1.1rem; max-width: 38rem; margin: 0 auto; }

.blog-search {
  position: relative; max-width: 28rem; margin: 1.5rem auto 0;
  display: flex; align-items: center;
}
.blog-search i.fa-magnifying-glass { position: absolute; left: 1rem; color: var(--text-muted); font-size: 0.9rem; pointer-events: none; }
.blog-search input {
  width: 100%; padding: 0.75rem 2.5rem; border-radius: 30px;
  border: 1px solid var(--card-border); background: var(--card-bg); color: var(--text-primary);
  font-size: 0.95rem; outline: none;
}
.blog-search input:focus { border-color: var(--accent-primary); }
.blog-search-clear {
  position: absolute; right: 0.9rem; color: var(--text-muted); text-decoration: none;
  width: 20px; height: 20px; display: flex; align-items: center; justify-content: center;
}
.blog-search-clear:hover { color: var(--accent-primary); }

.blog-cats { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; margin: 2rem 0; }
.blog-cat {
  padding: 0.4rem 0.9rem; border-radius: 20px; font-size: 0.9rem; font-weight: 500;
  text-decoration: none; color: var(--text-secondary);
  border: 1px solid var(--card-border); background: var(--card-bg);
}
.blog-cat:hover { color: var(--accent-primary); border-color: var(--accent-primary); }
.blog-cat.is-active { background: var(--accent-primary); color: #fff; border-color: var(--accent-primary); }

.blog-featured {
  display: grid; grid-template-columns: 1.1fr 1fr; gap: 0; margin-bottom: 2.5rem;
  border: 1px solid var(--card-border); border-radius: 16px; overflow: hidden;
  background: var(--card-bg); box-shadow: var(--shadow-light); text-decoration: none;
}
.blog-featured img { width: 100%; height: 100%; min-height: 260px; object-fit: cover; }
.blog-featured .blog-featured-body { padding: 2rem; display: flex; flex-direction: column; justify-content: center; }
.blog-eyebrow { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent-primary); }
.blog-featured h2 { font-size: 1.6rem; font-weight: 750; color: var(--text-primary); margin: 0.5rem 0; letter-spacing: -0.01em; }
.blog-featured p { color: var(--text-secondary); margin: 0 0 0.75rem; }
.blog-meta { font-size: 0.85rem; color: var(--text-muted); }

.blog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 1.5rem; }
.blog-card {
  display: flex; flex-direction: column; text-decoration: none;
  border: 1px solid var(--card-border); border-radius: 14px; overflow: hidden;
  background: var(--card-bg); transition: transform .15s, box-shadow .15s;
}
.blog-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-heavy); }
.blog-card-img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: var(--bg-secondary); }
.blog-card-body { padding: 1.1rem 1.2rem 1.3rem; display: flex; flex-direction: column; gap: 0.4rem; flex: 1; }
.blog-card-body h3 { font-size: 1.12rem; font-weight: 700; color: var(--text-primary); margin: 0; line-height: 1.3; letter-spacing: -0.01em; }
.blog-card-body p { font-size: 0.92rem; color: var(--text-secondary); margin: 0; flex: 1; }

.blog-pager { display: flex; justify-content: center; gap: 1rem; margin: 3rem 0 1rem; }
.blog-pager a { color: var(--accent-primary); text-decoration: none; font-weight: 600; }
.blog-pager span { color: var(--text-muted); }

.blog-empty { text-align: center; color: var(--text-muted); padding: 3rem 1rem; }

.blog-endcta {
  margin: 3.5rem 0 1rem; padding: 2rem; text-align: center; border-radius: 16px;
  border: 1px solid var(--card-border); background: var(--card-bg);
}
.blog-endcta p { font-size: 1.15rem; font-weight: 600; color: var(--text-primary); margin: 0 0 1rem; }
.blog-endcta a {
  display: inline-block; padding: 0.65rem 1.4rem; background: var(--accent-primary);
  color: #fff; border-radius: 8px; font-weight: 600; text-decoration: none;
}

/* ---- post page ---- */
.blog-post-head { max-width: 44rem; margin: 0 auto 2rem; }
.blog-breadcrumb { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 1rem; }
.blog-breadcrumb a { color: var(--text-secondary); text-decoration: none; }
.blog-breadcrumb a:hover { color: var(--accent-primary); }
.blog-post-head h1 { font-size: clamp(1.9rem, 4.5vw, 2.7rem); font-weight: 800; line-height: 1.15; letter-spacing: -0.02em; color: var(--text-primary); margin: 0 0 0.75rem; }
.blog-subtitle { font-size: 1.2rem; color: var(--text-secondary); line-height: 1.5; margin: 0 0 1.5rem; }
.blog-byline { display: flex; align-items: center; gap: 0.75rem; font-size: 0.9rem; color: var(--text-muted); }
.blog-byline img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.blog-byline b { color: var(--text-secondary); font-weight: 600; }

/* aspect-ratio lives on the figure, not the img -- the inline script next to
   this figure in marketing_blog_post.html positions the img absolutely
   (explicit px width/height/left/top, reproducing the admin cropper's exact
   crop math) so it no longer participates in layout and can't size its own
   parent. overflow/radius/border are on the figure too, for the same reason
   a zoomed-in img shouldn't carry its own clipped/rounded edges. */
.blog-hero { position: relative; max-width: 52rem; aspect-ratio: 16 / 9; margin: 0 auto 2.5rem; overflow: hidden; border-radius: 16px; border: 1px solid var(--card-border); }
.blog-hero img { width: 100%; height: 100%; object-fit: cover; display: block; }

.blog-post-layout { display: grid; grid-template-columns: 1fr; gap: 2rem; max-width: 44rem; margin: 0 auto; }
/* Grid items default to min-width:auto, so a wide table/code block's min-content width
   stretched the whole column past a phone's viewport and .bp-table-wrap never got to scroll. */
.blog-post-layout > * { min-width: 0; }
@media (min-width: 1100px) {
  .blog-post-layout { grid-template-columns: 12rem 1fr; max-width: 58rem; gap: 3rem; margin-left: auto; margin-right: auto; }
  .blog-toc { position: sticky; top: 6rem; align-self: start; }
}
.blog-toc { font-size: 0.9rem; }
.blog-toc-title { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); margin-bottom: 0.75rem; font-weight: 700; }
.blog-toc a { display: block; color: var(--text-secondary); text-decoration: none; padding: 0.25rem 0; border-left: 2px solid var(--border-color); padding-left: 0.75rem; }
.blog-toc a.lvl-3 { padding-left: 1.5rem; }
.blog-toc a:hover, .blog-toc a.is-current { color: var(--accent-primary); border-left-color: var(--accent-primary); }
.blog-toc-toggle { display: none; }
@media (max-width: 1099px) {
  .blog-toc-toggle { display: block; width: 100%; text-align: left; background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 8px; padding: 0.6rem 0.9rem; color: var(--text-secondary); font-weight: 600; cursor: pointer; }
  .blog-toc nav { display: none; margin-top: 0.75rem; }
  .blog-toc.is-open nav { display: block; }
}

.blog-tags { max-width: 44rem; margin: 2.5rem auto 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.blog-tag { font-size: 0.85rem; color: var(--text-secondary); text-decoration: none; padding: 0.3rem 0.7rem; border: 1px solid var(--card-border); border-radius: 20px; }
.blog-tag:hover { color: var(--accent-primary); border-color: var(--accent-primary); }

.blog-author-card {
  max-width: 44rem; margin: 2.5rem auto 0; display: flex; gap: 1rem; align-items: flex-start;
  padding: 1.5rem; border: 1px solid var(--card-border); border-radius: 14px; background: var(--card-bg);
}
.blog-author-card img { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.blog-author-card b { display: block; color: var(--text-primary); font-size: 1.05rem; }
.blog-author-card span { color: var(--text-muted); font-size: 0.9rem; }
.blog-author-card p { color: var(--text-secondary); margin: 0.5rem 0 0; font-size: 0.95rem; }
.blog-author-card-body { flex: 1; min-width: 0; }
.blog-author-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem; }
.blog-author-social {
  flex-shrink: 0; width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--card-border); color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center; text-decoration: none;
}
.blog-author-social:hover { color: #fff; background: var(--accent-primary); border-color: var(--accent-primary); }

.blog-related { max-width: 58rem; margin: 3.5rem auto 0; }
.blog-related h2 { font-size: 1.3rem; font-weight: 700; color: var(--text-primary); margin: 0 0 1.25rem; text-align: center; }

.blog-preview-bar {
  position: sticky; top: 0; z-index: 50; background: #f59e0b; color: #1a1a2e;
  text-align: center; padding: 0.5rem; font-size: 0.85rem; font-weight: 600;
}

@media (max-width: 720px) {
  .blog-featured { grid-template-columns: 1fr; }
  .blog-featured img { min-height: 200px; }
}

@media (prefers-reduced-motion: reduce) {
  .blog-card, .blog-card:hover { transition: none; transform: none; }
}
