/* Hallmark · shape: long document, rail + measure · genre: editorial · theme: brand (biplus-design v3.5) · redesign: full
 * paper: var(--surface) · accent: var(--y) · display: UTM Avo · body: Manrope · hero: split, head left, cover right · nav: kept · footer: kept · signature: the outline rail that opens only the section being read, and the "Đang đọc" bar on phones
 * axes: white/avo/gold · posture: split · contrast: pass · fold: pass · v2.0.0 */
/* Hallmark · pre-emit critique: P2 H2 E2 S2 R2 V2 · weakest: R, posts without a cover drop to one column so the hero stays honest */
/* Hallmark · waive 44c · hero ends at 555px on 1440x900 and the article text starts at 600px · a reading page starts reading in the first screen */
/* Hallmark · waive 79 · the space under the hero holds the first paragraphs of the article · a reading page fills its first screen with the article itself, not with a bigger hero */
/* Hallmark · finish-review: subagent, recapture (render cap) then hero fixes: top air, gold limited to the active outline entry, phone bar off outside the article, 1:1 split for the cover */
/* Reading pages (single posts, docs). Tokens from biplus-tokens.css; markup in single.php and template-parts/biplus-reading.php. */

html:has(body.biplus-article), body.biplus-article { overflow-x: clip; }
body.biplus-article { background: var(--surface); }
.biplus-article .site-content > .ast-container { max-width: none; padding: 0; display: block; }
body.biplus-article #content > .ast-container, body.biplus-article article.bp-post.bp-post { padding-left: 0 !important; padding-right: 0 !important; } /* Astra gutters */
.biplus-article :is(a, button, summary):focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: var(--r-chip); }

/* Reading progress: thin gold line under the header */
.bp-progress { position: fixed; inset: 0 0 auto; height: 3px; z-index: 101; pointer-events: none; }
.admin-bar .bp-progress { top: 32px; }
.bp-progress__bar { display: block; height: 100%; background: var(--y); transform: scaleX(0); transform-origin: 0 50%; }

/* ---------- Hero: head left, cover right; one column without a cover ---------- */
.bp-hero { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-8); align-items: center; padding-top: var(--sp-6); padding-bottom: var(--sp-8); }
.bp-hero.has-cover { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.bp-hero__text { display: grid; gap: var(--sp-5); justify-items: start; min-width: 0; }
.bp-crumbs { display: flex; flex-wrap: wrap; gap: var(--sp-2); font-family: var(--font-body); font-size: 14px; font-weight: 500; color: var(--gray); }
.bp-crumbs { align-items: center; }
.bp-crumbs a { display: inline-block; min-height: 24px; line-height: 24px; color: var(--gray-mid); text-decoration: none; } /* 24px tap target */
.bp-crumbs a:hover { color: var(--ink); text-decoration: underline; text-decoration-color: var(--y-deep); }
.bp-hero__title {
  margin: 0; max-width: 22ch; font-family: var(--font-heading); font-size: clamp(34px, 2.6vw + 14px, 52px); line-height: 1.1;
  font-weight: 800; letter-spacing: -1px; color: var(--ink); text-wrap: balance; overflow-wrap: break-word; min-width: 0;
}
.bp-hero__lead { margin: 0; max-width: 60ch; font-family: var(--font-body); font-size: 19px; line-height: 1.6; font-weight: 500; color: var(--gray-mid); text-wrap: pretty; }
.bp-meta, .bp-chips, .bp-tags { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; font-family: var(--font-body); }
.bp-meta { font-size: 15px; font-weight: 500; color: var(--gray-mid); row-gap: var(--sp-2); }
.bp-meta li + li { margin-left: var(--sp-3); padding-left: var(--sp-3); border-left: 1px solid var(--line-soft); }
.bp-meta li:first-child { font-weight: 700; color: var(--ink); }
.bp-chips, .bp-tags { gap: var(--sp-2); }
.bp-chip, .bp-tags a {
  display: inline-block; font-size: 14px; font-weight: 700; color: var(--ink); background: var(--y-pale);
  border-radius: var(--r-pill); padding: var(--sp-1) var(--sp-3); text-decoration: none;
}
.bp-chip:hover, .bp-tags a:hover { background: var(--y-soft); color: var(--ink); }
.bp-hero__cover { margin: 0; }
.bp-hero__cover img { display: block; width: 100%; height: auto; aspect-ratio: 16 / 10; object-fit: cover; border-radius: var(--r-hero); box-shadow: var(--shadow-body); }

/* ---------- Rail + measure ---------- */
.bp-read { display: grid; grid-template-columns: minmax(0, 720px); justify-content: start; gap: var(--sp-9); padding-top: var(--sp-6); padding-bottom: var(--sp-9); border-top: 1px solid var(--line-soft); }
.bp-read.has-toc { grid-template-columns: 280px minmax(0, 720px); justify-content: start; gap: var(--sp-8); }
.bp-rail__inner { position: sticky; top: 100px; max-height: calc(100vh - 124px); overflow: auto; overscroll-behavior: contain; padding-right: var(--sp-2); }
.admin-bar .bp-rail__inner { top: 132px; }
.bp-toc { font-family: var(--font-body); }
.bp-toc__title { margin: 0 0 var(--sp-3); font-size: 15px; font-weight: 800; color: var(--ink); }
.bp-toc ol { list-style: none; margin: 0; padding: 0; }
.bp-toc a {
  display: block; padding: var(--sp-2) var(--sp-3); border-radius: var(--r-chip); font-size: 15px; line-height: 1.4; font-weight: 500;
  color: var(--gray-mid); text-decoration: none; transition: background-color .15s, color .15s;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; /* one line per entry; full heading in the title attribute */
}
.bp-toc a:hover { color: var(--ink); background: var(--subtle); }
.bp-toc a:active { background: var(--y-soft); }
.bp-toc__sub { margin: 0 0 var(--sp-2) var(--sp-3) !important; }
.bp-toc__sub a { font-size: 14px; padding-top: var(--sp-1); padding-bottom: var(--sp-1); }
/* Collapse from the first paint whenever scripts run (the script adds .bp-js only at the end of the page) */
@media (scripting: enabled) { .bp-toc__item:not(.is-open) > .bp-toc__sub { display: none; } }
.bp-toc a[aria-current="true"] { color: var(--ink); font-weight: 700; background: var(--y-pale); }
/* "Về đầu trang": a small ink disc with the same chevron as the floating back-to-top button, then the label */
.bp-rail__top {
  display: flex; align-items: center; gap: var(--sp-3); margin-top: var(--sp-4); padding: var(--sp-4) var(--sp-3) var(--sp-2);
  border-top: 1px solid var(--line-soft); font-family: var(--font-body); font-size: 14px; font-weight: 700; color: var(--gray-mid); text-decoration: none;
}
.bp-rail__top-icon {
  flex: 0 0 28px; width: 28px; height: 28px; border-radius: var(--r-pill); display: inline-flex; align-items: center; justify-content: center;
  background: var(--ink); color: var(--text-light); transition: transform .15s, background-color .15s;
}
.bp-rail__top:hover { color: var(--ink); }
.bp-rail__top:hover .bp-rail__top-icon { background: var(--dark); transform: translateY(-2px); }
.bp-rail a.bp-rail__top:focus-visible { color: var(--ink); outline: 2px solid var(--ink); outline-offset: 2px; border-radius: var(--r-chip); }
@media (prefers-reduced-motion: reduce) { .bp-rail__top-icon { transition: none; } .bp-rail__top:hover .bp-rail__top-icon { transform: none; } }
.bp-now { display: none; }

/* ---------- Prose ---------- */
.bp-prose { font-family: var(--font-body); font-size: 18px; line-height: 1.75; font-weight: 500; color: var(--fg-1); min-width: 0; }
.bp-prose p, .bp-prose li { text-align: left !important; text-wrap: pretty; } /* old posts carry inline justify */
.bp-prose p { margin: 0 0 var(--sp-5); max-width: 68ch; }
.bp-prose :is(h2, h3, h4) { color: var(--ink); scroll-margin-top: 112px; text-wrap: balance; overflow-wrap: break-word; position: relative; }
.bp-prose h2 { font-family: var(--font-heading); font-size: 30px; line-height: 1.25; font-weight: 800; letter-spacing: -0.5px; margin: var(--sp-9) 0 var(--sp-4); }
.bp-prose h3 { font-family: var(--font-body); font-size: 21px; line-height: 1.4; font-weight: 800; margin: var(--sp-8) 0 var(--sp-3); }
.bp-prose h4 { font-family: var(--font-body); font-size: 18px; font-weight: 800; margin: var(--sp-7) 0 var(--sp-2); }
.bp-prose > :first-child { margin-top: 0; }
.bp-prose a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--gray-mid); text-decoration-thickness: 1px; text-underline-offset: 3px; }
.bp-prose a:hover { background: var(--y-pale); }
.bp-prose :is(strong, b) { font-weight: 800; color: var(--ink); }
.bp-prose :is(ul, ol) { margin: 0 0 var(--sp-5); padding-left: var(--sp-6); max-width: 68ch; }
.bp-prose li { margin-bottom: var(--sp-2); }
.bp-prose li::marker { color: var(--gray-mid); font-weight: 800; }
.bp-prose img { max-width: 100%; height: auto; border-radius: var(--r-card); }
.bp-prose figure { margin: var(--sp-7) 0; }
.bp-prose :is(figcaption, .wp-caption-text) { font-size: 14px; color: var(--gray); margin-top: var(--sp-2); }
.bp-prose blockquote { margin: var(--sp-7) 0; padding: var(--sp-5) var(--sp-6); background: var(--subtle); border: 0; border-radius: var(--r-outer); font-size: 19px; font-weight: 700; color: var(--ink); }
.bp-prose blockquote p:last-child { margin-bottom: 0; }
.bp-prose :is(table, tr, td, th) { height: auto !important; } /* old editor rows carry inline heights that clip a block table */
.bp-prose table { display: block; width: 100%; overflow-x: auto; border-collapse: collapse; margin: var(--sp-7) 0; font-size: 15px; line-height: 1.5; }
.bp-prose :is(th, td) { min-width: 140px; border-bottom: 1px solid var(--line-soft); padding: var(--sp-3) var(--sp-4); text-align: left; vertical-align: top; }
.bp-prose :is(th, td) > :is(p, ul, ol) { margin: 0; max-width: none; }
.bp-prose table:not(:has(thead)) tr:first-child :is(th, td), .bp-prose thead :is(th, td) { background: var(--subtle); color: var(--ink); font-weight: 800; }
.bp-prose code { font-size: .9em; background: var(--subtle); border-radius: var(--r-chip); padding: 0 var(--sp-1); }
.bp-prose pre { background: var(--dark); color: var(--text-light); border-radius: var(--r-card); padding: var(--sp-5); overflow-x: auto; font-size: 14px; }
.bp-prose pre code { background: none; padding: 0; }
.bp-prose hr { border: 0; border-top: 1px solid var(--line-soft); margin: var(--sp-8) 0; }
.bp-prose iframe { max-width: 100%; border-radius: var(--r-card); }

/* ---------- Under the article: tags, share ---------- */
.bp-read__foot { margin-top: var(--sp-8); padding-top: var(--sp-6); border-top: 1px solid var(--line-soft); display: grid; gap: var(--sp-5); font-family: var(--font-body); }
.bp-share { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-3); min-width: 0; }
.bp-share__label { margin: 0; font-size: 15px; font-weight: 800; color: var(--ink); }
.bp-share__row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); }
.bp-share__nets { list-style: none; margin: 0; padding: 0; display: flex; gap: var(--sp-2); }
.bp-share__net {
  width: 44px; height: 44px; border-radius: var(--r-pill); display: inline-grid; place-items: center; color: var(--ink);
  background: var(--subtle); box-shadow: inset 0 0 0 1px var(--line-soft); text-decoration: none; transition: background-color .15s, color .15s;
}
.bp-share__net svg { width: 18px; height: 18px; fill: currentColor; }
.bp-share__net:hover { background: var(--ink); color: var(--surface); }
.bp-share__copy {
  flex: 1 1 280px; max-width: 460px; min-width: 0; display: flex; align-items: center; gap: var(--sp-2); min-height: 44px; box-sizing: border-box;
  padding: 4px 4px 4px var(--sp-4); border-radius: var(--r-pill); background: var(--subtle); box-shadow: inset 0 0 0 1px var(--line-soft);
}
.bp-share__url { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; color: var(--gray); }
.bp-share__copybtn {
  flex: none; display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 var(--sp-4); border: 0; border-radius: var(--r-pill);
  background: var(--ink); color: var(--surface); font-family: var(--font-body); font-size: 14px; font-weight: 700; cursor: pointer; transition: background-color .15s;
}
.bp-share__copybtn:hover { background: var(--dark); }
.bp-share__copybtn svg { width: 16px; height: 16px; }
.bp-share__copybtn .bp-i-check, .bp-share__copybtn.is-copied .bp-i-link { display: none; }
.bp-share__copybtn.is-copied .bp-i-check { display: block; }
.bp-share__copybtn.is-copied { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 2px var(--ok); }
.bp-share__copybtn.is-copied svg { color: var(--ok); }
.bp-share__net:focus-visible, .bp-share__copybtn:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { .bp-share__net, .bp-share__copybtn { transition: none; } }

/* ---------- CTA and related ---------- */
.bp-post-cta {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-5); flex-wrap: wrap;
  max-width: 1200px; margin: 0 auto var(--sp-9); padding: var(--sp-7) !important; box-sizing: border-box;
  background: var(--dark); color: var(--line-soft); border-radius: var(--r-hero); font-family: var(--font-body);
}
.bp-post-cta p { margin: 0; }
.bp-post-cta__title { font-family: var(--font-heading); font-size: 26px; line-height: 1.25; font-weight: 800; color: var(--text-light); margin-bottom: var(--sp-1) !important; }
.bp-related { background: var(--subtle); padding: var(--sp-9) 0; }
.bp-related h2.wp-block-heading { margin: 0 0 var(--sp-6); }

/* ---------- Tablet and phone: the rail becomes the "Đang đọc" bar ---------- */
@media (max-width: 1080px) {
  .bp-read.has-toc { grid-template-columns: minmax(0, 720px); justify-content: center; }
  .bp-rail { display: none; }
  .bp-now { display: block; position: fixed; left: var(--sp-4); right: var(--sp-4); bottom: var(--sp-4); z-index: 99; max-width: 560px; margin: 0 auto; font-family: var(--font-body); }
  .bp-now summary {
    list-style: none; cursor: pointer; display: flex; align-items: center; gap: var(--sp-3); min-height: 48px; padding: 0 var(--sp-5);
    background: var(--dark); color: var(--text-light); border-radius: var(--r-pill); box-shadow: var(--shadow-hero); font-size: 15px;
  }
  .bp-now summary::-webkit-details-marker { display: none; }
  .bp-now { transition: opacity .2s, transform .2s, visibility .2s; }
  .bp-now.is-off { opacity: 0; visibility: hidden; transform: translateY(var(--sp-4)); } /* set by script outside the article body */
  .bp-now__label { font-weight: 800; flex: none; }
  .bp-now__current { font-weight: 500; color: var(--line-soft); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; min-width: 0; }
  .bp-now__current:not(:empty) { border-left: 1px solid var(--gray-mid); padding-left: var(--sp-3); }
  .bp-now__panel { position: absolute; left: 0; right: 0; bottom: calc(100% + var(--sp-2)); max-height: 60vh; overflow: auto; overscroll-behavior: contain; background: var(--surface); border-radius: var(--r-outer); box-shadow: var(--shadow-hero); padding: var(--sp-5); }
  .bp-hero.has-cover { grid-template-columns: minmax(0, 1fr); }
  .bp-hero__cover { max-width: 720px; }
}
@media (max-width: 781px) {
  .bp-hero { padding-top: var(--sp-6); padding-bottom: var(--sp-6); gap: var(--sp-6); }
  .bp-hero, .bp-read { padding-left: var(--sp-4); padding-right: var(--sp-4); }
  .bp-prose { font-size: 17px; }
  .bp-prose h2 { font-size: 25px; }
  .bp-post-cta { margin: 0 var(--sp-4) var(--sp-8); padding: var(--sp-5) !important; }
  .admin-bar .bp-progress { top: 46px; }
}
@media (prefers-reduced-motion: reduce) { .biplus-article *, .biplus-article *::before, .biplus-article *::after { transition-duration: 0.01ms !important; scroll-behavior: auto !important; } }
