/* ============================================================
   BRAWIN HQ — Knowledge / Pillar Guide
   Extends the shared design system (styles.css). Every value here
   is derived from existing tokens so dark/light, accent colour and
   motion settings keep working with zero extra wiring.
   ============================================================ */

/* ---------- reading-progress bar (fixed, top) ---------- */
.reading-progress {
  position: fixed; top: 0; left: 0; right: 0; z-index: 101;
  height: 2px; background: transparent; pointer-events: none;
}
.reading-progress span {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 12px var(--accent-glow);
  transition: width .1s linear;
}
@media (prefers-reduced-motion: reduce) {
  .reading-progress span { transition: none; }
}

/* ---------- breadcrumb ---------- */
.crumb {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  font-family: var(--font-mono); font-size: 12.5px; letter-spacing: 0.04em;
  color: var(--text-3);
}
.crumb a { color: var(--text-2); transition: color .2s; }
.crumb a:hover { color: var(--accent); }
.crumb .sep { color: var(--text-3); }
.crumb span[aria-current] { color: var(--text); }

/* ---------- guide hero meta strip ---------- */
.guide-hero { padding-top: clamp(120px, 15vw, 168px); }
.guide-title {
  font-size: clamp(2.4rem, 5.4vw, 4.4rem);
  max-width: 20ch;
}
.guide-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 22px;
  font-family: var(--font-mono); font-size: 12.5px; letter-spacing: 0.05em;
  color: var(--text-2);
}
.guide-meta .gm { display: inline-flex; align-items: center; gap: 8px; }
.guide-meta .gm svg { width: 15px; height: 15px; stroke: var(--accent); opacity: .9; }
.guide-meta .gm-sep { width: 4px; height: 4px; border-radius: 50%; background: var(--text-3); }
.guide-author-inline { display: inline-flex; align-items: center; gap: 9px; }
.guide-author-inline .ga-mark {
  width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center;
  background: linear-gradient(140deg, var(--accent-2), var(--accent));
  color: #fff; font-family: var(--font-mono); font-weight: 600; font-size: 10px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.3);
}

/* ---------- the two-column reading layout ----------
   Widen the reading track so component grids (framework, cards, related,
   comparison table) fill the space instead of leaving big empty margins on
   laptops/desktops. Prose inside still self-limits to ~74ch for readability. */
.guide-layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: clamp(28px, 4vw, 72px);
  align-items: start;
}
@media (max-width: 980px) {
  .guide-layout { grid-template-columns: 1fr; gap: 0; }
}

/* ---------- sticky table of contents (desktop) ---------- */
.toc {
  position: sticky; top: 96px;
  max-height: calc(100vh - 120px); overflow-y: auto;
  padding: 22px 20px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--card-grad);
  box-shadow: inset 0 1px 0 var(--card-hi);
  scrollbar-width: thin; scrollbar-color: var(--border-2) transparent;
}
.toc::-webkit-scrollbar { width: 6px; }
.toc::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 100px; }
.toc-title {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--text-3); margin-bottom: 16px; font-weight: 500;
}
.toc ol { list-style: none; counter-reset: toc; display: flex; flex-direction: column; gap: 2px; }
.toc li { counter-increment: toc; }
.toc a {
  display: flex; gap: 11px; align-items: baseline;
  padding: 8px 10px; border-radius: 10px;
  font-size: 13.5px; line-height: 1.4; color: var(--text-2);
  border-left: 2px solid transparent; transition: color .2s, background .2s, border-color .2s;
}
.toc a::before {
  content: counter(toc, decimal-leading-zero);
  font-family: var(--font-mono); font-size: 11px; color: var(--text-3);
  flex-shrink: 0; transition: color .2s;
}
.toc a:hover { color: var(--text); background: var(--card-hover); }
.toc a.is-active {
  color: var(--text); background: var(--accent-soft);
  border-left-color: var(--accent);
}
.toc a.is-active::before { color: var(--accent); }

/* mobile ToC: collapsible <details> */
.toc-mobile {
  margin-bottom: 8px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--card-grad); box-shadow: inset 0 1px 0 var(--card-hi); overflow: hidden;
}
.toc-mobile > summary {
  list-style: none; cursor: pointer; padding: 18px 20px;
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 500; font-size: 15px;
}
.toc-mobile > summary::-webkit-details-marker { display: none; }
.toc-mobile > summary .chev { transition: transform .3s var(--ease); color: var(--text-3); }
.toc-mobile[open] > summary .chev { transform: rotate(180deg); }
.toc-mobile .toc-title { display: none; }
.toc-mobile .toc { position: static; max-height: none; border: none; box-shadow: none; background: transparent; padding: 0 12px 16px; }
@media (min-width: 981px) { .toc-mobile { display: none; } }
@media (max-width: 980px) { .toc-desktop { display: none; } }

/* ---------- prose (long-form editorial body) ----------
   The reading COLUMN fills the available grid track (so cards, tables and
   the framework/related grids use the full width and the page doesn't look
   empty on laptops/desktops). Only the running PROSE is capped to a
   comfortable ~72ch measure — long text lines hurt readability, wide
   component grids do not. */
.guide-body { max-width: none; min-width: 0; }
.guide-body .prose,
.guide-body > .toc-mobile { max-width: 74ch; }
.guide-body .prose { font-size: clamp(1.02rem, 1.15vw, 1.14rem); line-height: 1.72; color: var(--text); }
.guide-body .prose p { color: var(--text-2); margin: 0 0 20px; text-wrap: pretty; }
.guide-body .prose p strong { color: var(--text); font-weight: 600; }
.guide-body .prose a:not(.btn):not(.link-arrow) {
  color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px;
  text-underline-offset: 3px; text-decoration-color: var(--accent-line); transition: text-decoration-color .2s;
}
.guide-body .prose a:not(.btn):not(.link-arrow):hover { text-decoration-color: var(--accent); }
.guide-body .prose ul, .guide-body .prose ol { margin: 0 0 22px; padding-left: 0; list-style: none; display: flex; flex-direction: column; gap: 12px; }
.guide-body .prose ul li { position: relative; padding-left: 26px; color: var(--text-2); }
.guide-body .prose ul li::before {
  content: ""; position: absolute; left: 4px; top: 11px;
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
}
.guide-body .prose ol { counter-reset: pl; }
.guide-body .prose ol li { position: relative; padding-left: 34px; color: var(--text-2); counter-increment: pl; }
.guide-body .prose ol li::before {
  content: counter(pl); position: absolute; left: 0; top: 1px;
  width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center;
  font-family: var(--font-mono); font-size: 11px; color: var(--accent);
  background: var(--accent-soft); border: 1px solid var(--accent-line);
}

/* section rhythm inside the guide */
.guide-section { scroll-margin-top: 92px; padding: clamp(30px, 4vw, 52px) 0; }
.guide-section + .guide-section { border-top: 1px solid var(--border); }
.guide-section > .section-head { margin-bottom: clamp(20px, 2.6vw, 32px); }
.guide-section .h2 { max-width: 24ch; }
.guide-lead-in { font-size: clamp(1.05rem, 1.4vw, 1.2rem); color: var(--text-2); max-width: 68ch; line-height: 1.6; margin-bottom: 8px; }

/* pull quote / callout inside prose */
.callout {
  border: 1px solid var(--border-2); border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm); background: var(--bg-2);
  padding: 20px 22px; margin: 26px 0;
}
.callout .callout-k {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 8px;
}
.callout p { margin: 0 !important; color: var(--text-2); }

/* ---------- comparison table ---------- */
.cmp-scroll { overflow-x: auto; margin: 8px 0 4px; border-radius: var(--radius); border: 1px solid var(--border); -webkit-overflow-scrolling: touch; }
.cmp {
  width: 100%; border-collapse: collapse; min-width: 640px;
  background: var(--card-grad); font-size: 14.5px;
}
.cmp caption { text-align: left; padding: 16px 18px; color: var(--text-3); font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.05em; }
.cmp th, .cmp td { padding: 15px 18px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
.cmp thead th {
  font-family: var(--font-mono); font-size: 11.5px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-2); font-weight: 500; background: var(--surface-2);
  position: sticky; top: 0;
}
.cmp thead th:first-child { color: var(--accent); }
.cmp tbody th {
  font-weight: 600; color: var(--text); width: 22%;
}
.cmp tbody td { color: var(--text-2); }
.cmp tbody tr:last-child th, .cmp tbody tr:last-child td { border-bottom: none; }
.cmp tbody tr:hover td, .cmp tbody tr:hover th { background: var(--card-hover); }

/* ---------- framework diagram (SVG-lite, CSS built) ---------- */
.framework { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin: 6px 0 4px; }
/* 7-step framework: flow into as many columns as fit (min ~200px each), so it
   fills the widened reading column cleanly instead of leaving gaps. */
.framework--seven { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
/* 10-step framework: same flow-to-fit behaviour, slightly tighter min so the
   larger set arranges cleanly across the wide column. */
.framework--ten { grid-template-columns: repeat(auto-fit, minmax(185px, 1fr)); }
@media (max-width: 880px) { .framework { grid-template-columns: 1fr 1fr; } }
@media (max-width: 460px) { .framework { grid-template-columns: 1fr; } }
.fw-step { position: relative; }
.fw-step .card { height: 100%; padding: 22px 20px; }
.fw-step .fw-n {
  font-family: var(--font-mono); font-size: 12px; color: var(--accent);
  border: 1px solid var(--accent-line); background: var(--accent-soft);
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; margin-bottom: 14px;
}
.fw-step h3 { font-size: 1.05rem; line-height: 1.2; margin-bottom: 8px; }
.fw-step p { font-size: 13.5px; color: var(--text-2); line-height: 1.5; }

/* ---------- process stepper (vertical, reuses timeline feel) ---------- */
.process { display: flex; flex-direction: column; gap: 2px; position: relative; }
.proc-item {
  display: grid; grid-template-columns: 54px 1fr; gap: 20px;
  padding: 22px 0; border-bottom: 1px solid var(--border); position: relative;
}
.proc-item:last-child { border-bottom: none; }
.proc-n {
  font-family: var(--font-mono); font-size: 13px; color: var(--accent);
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
  border: 1px solid var(--accent-line); background: var(--accent-soft);
  box-shadow: inset 0 1px 0 var(--card-hi);
}
.proc-body h3 { font-size: 1.18rem; margin-bottom: 6px; }
.proc-body p { color: var(--text-2); margin: 0; line-height: 1.6; }
.proc-body .proc-eg {
  margin-top: 10px; font-size: 13.5px; color: var(--text-2);
  border-left: 2px solid var(--accent-line); padding-left: 12px;
}
.proc-body .proc-eg b { color: var(--accent); font-weight: 500; font-family: var(--font-mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; display: block; margin-bottom: 3px; }

/* ---------- mistakes grid ---------- */
.mistakes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
@media (max-width: 760px) { .mistakes { grid-template-columns: 1fr; } }
.mistake { display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: start; }
.mistake .mk-n { font-family: var(--font-mono); font-size: 13px; color: var(--text-3); padding-top: 2px; }
.mistake h3 { font-size: 1.05rem; margin-bottom: 6px; }
.mistake p { font-size: 14px; color: var(--text-2); margin: 0; line-height: 1.55; }

/* ---------- takeaway cards ---------- */
.takeaways { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 880px) { .takeaways { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .takeaways { grid-template-columns: 1fr; } }
.takeaway .tk-i {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; margin-bottom: 14px;
  background: var(--accent-soft); border: 1px solid var(--accent-line);
}
.takeaway .tk-i svg { width: 18px; height: 18px; stroke: var(--accent); }
.takeaway h3 { font-size: 1.02rem; margin-bottom: 7px; }
.takeaway p { font-size: 13.5px; color: var(--text-2); margin: 0; line-height: 1.55; }

/* ---------- FAQ accordion ---------- */
.faq { display: flex; flex-direction: column; gap: 10px; }
.faq-item {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--card-grad); box-shadow: inset 0 1px 0 var(--card-hi);
  transition: border-color .3s, background .3s;
}
.faq-item[open] { border-color: var(--border-2); }
.faq-item > summary {
  list-style: none; cursor: pointer; padding: 20px 22px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  font-size: 1.02rem; font-weight: 500; color: var(--text); line-height: 1.4;
}
.faq-item > summary::-webkit-details-marker { display: none; }
.faq-item > summary .faq-plus {
  position: relative; flex-shrink: 0; width: 20px; height: 20px;
}
.faq-item > summary .faq-plus::before,
.faq-item > summary .faq-plus::after {
  content: ""; position: absolute; background: var(--accent); border-radius: 2px;
  left: 50%; top: 50%; transition: transform .3s var(--ease);
}
.faq-item > summary .faq-plus::before { width: 12px; height: 2px; transform: translate(-50%, -50%); }
.faq-item > summary .faq-plus::after { width: 2px; height: 12px; transform: translate(-50%, -50%); }
.faq-item[open] > summary .faq-plus::after { transform: translate(-50%, -50%) rotate(90deg); opacity: 0; }
.faq-answer { padding: 0 22px 22px; color: var(--text-2); line-height: 1.68; }
.faq-answer p { margin: 0 0 12px; }
.faq-answer p:last-child { margin-bottom: 0; }

/* ---------- related supporting-page cards ---------- */
.related-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
/* 5-item related grid: flow to fit (min ~200px), filling the wider column. */
.related-grid--five { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
@media (max-width: 980px) { .related-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) { .related-grid { grid-template-columns: 1fr; } }
.rel-card { display: flex; flex-direction: column; min-height: 168px; }
.rel-card .rel-k { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.1em; color: var(--text-3); text-transform: uppercase; margin-bottom: 12px; }
.rel-card h3 { font-size: 1.06rem; line-height: 1.25; margin-bottom: 8px; }
.rel-card p { font-size: 13px; color: var(--text-2); margin: 0 0 auto; line-height: 1.5; }
.rel-card .post-go { margin-top: 16px; }
.rel-soon { align-self: flex-start; margin-top: 14px; }

/* ---------- author bio ---------- */
.author-card { display: grid; grid-template-columns: auto 1fr; gap: 26px; align-items: start; }
@media (max-width: 620px) { .author-card { grid-template-columns: 1fr; } }
.author-portrait {
  width: 96px; height: 96px; border-radius: 20px; overflow: hidden;
  border: 1px solid var(--border-2); box-shadow: inset 0 1px 0 var(--card-hi);
}
.author-portrait img { width: 100%; height: 100%; object-fit: cover; }
.author-body h3 { font-size: 1.3rem; margin-bottom: 4px; }
.author-body .author-role { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.06em; color: var(--accent); margin-bottom: 14px; }
.author-body p { color: var(--text-2); margin: 0 0 16px; line-height: 1.62; }

/* generic "coming soon" pill */
.soon { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); border: 1px solid var(--border-2); border-radius: 100px; padding: 4px 10px; display: inline-flex; align-items: center; gap: 6px; }
.soon::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--text-3); }

/* ---------- hero readable container ---------- */
.narrow-guide { max-width: 860px; }

/* ============================================================
   MOBILE OPTIMISATION (≤ 600px)
   The guide was tuned for desktop/tablet; this block fixes the
   phone layout. Root cause of horizontal overflow: .guide-body is
   a grid item, and grid items default to min-width:auto, so the
   640px-min comparison table refused to let the column shrink.
   min-width:0 lets the track shrink and the table scroll inside
   its own container instead of pushing the whole page wide.
   ============================================================ */

/* 1) Let the reading column shrink on every viewport (fixes overflow) */
.guide-layout { min-width: 0; }
.guide-body { min-width: 0; }
.guide-body .prose,
.guide-section,
.section-head { min-width: 0; }

/* keep any oversized media/tables inside their own scroll box, never the page */
.cmp-scroll { max-width: 100%; }
.guide-body img, .guide-body svg, .guide-body pre { max-width: 100%; }

@media (max-width: 600px) {

  /* hero: tighter top gap, smaller title, comfortable lead */
  .guide-hero { padding-top: clamp(96px, 26vw, 120px); }
  .guide-title { font-size: clamp(1.85rem, 8.5vw, 2.5rem); line-height: 1.08; max-width: none; }
  .guide-hero .lead { font-size: 1.02rem; }
  .narrow-guide { max-width: 100%; }

  /* meta strip: let it wrap to two rows without cramping */
  .guide-meta { gap: 8px 14px; font-size: 12px; }
  .guide-meta .gm-sep { display: none; }        /* dots look odd when wrapped */

  /* section rhythm: less vertical padding so the page isn't endless */
  .guide-section { padding: 26px 0; scroll-margin-top: 80px; }
  .guide-section .h2 { max-width: none; }
  .section-head { margin-bottom: 18px; }
  .guide-lead-in { font-size: 1rem; }

  /* prose: size for thumb-reading */
  .guide-body .prose { font-size: 1.02rem; line-height: 1.7; }
  .guide-body .prose p { margin-bottom: 18px; }
  .callout { padding: 18px; margin: 22px 0; }

  /* comparison table: readable on a phone, scrolls inside its box.
     Shrink the forced min-width and tighten cells so less scrolling
     is needed, and hint that it scrolls. */
  .cmp { min-width: 520px; font-size: 13.5px; }
  .cmp th, .cmp td { padding: 12px 13px; }
  .cmp tbody th { width: 26%; }
  .cmp-scroll { position: relative; }
  .cmp-scroll::after {
    content: "→ scroll"; position: absolute; top: 10px; right: 10px;
    font-family: var(--font-mono); font-size: 10px; letter-spacing: .08em;
    color: var(--text-3); background: var(--surface-2); border: 1px solid var(--border);
    padding: 3px 8px; border-radius: 100px; pointer-events: none; opacity: .9;
  }

  /* framework: single column, full-width cards (2-up was cramped) */
  .framework { grid-template-columns: 1fr; gap: 10px; }
  .fw-step .card { padding: 18px 18px; }
  .fw-step .fw-n { margin-bottom: 10px; }

  /* process stepper: smaller number gutter, tighter rows */
  .proc-item { grid-template-columns: 40px 1fr; gap: 14px; padding: 18px 0; }
  .proc-n { width: 36px; height: 36px; border-radius: 10px; font-size: 12px; }
  .proc-body h3 { font-size: 1.08rem; }
  .proc-body p { font-size: 14.5px; }
  .proc-body .proc-eg { font-size: 13px; }

  /* mistakes: already single-col under 760; tighten the number gutter */
  .mistake { grid-template-columns: auto 1fr; gap: 12px; }
  .mistake h3 { font-size: 1rem; }

  /* takeaways: single column full-width */
  .takeaways { grid-template-columns: 1fr; }

  /* FAQ: comfortable tap targets */
  .faq-item > summary { padding: 16px 18px; font-size: .98rem; gap: 12px; }
  .faq-answer { padding: 0 18px 18px; }

  /* supporting cards: one per row, shorter min height */
  .related-grid { grid-template-columns: 1fr; }
  .rel-card { min-height: 0; }

  /* author: stack portrait above text, center nothing (keeps it tidy) */
  .author-card { grid-template-columns: 1fr; gap: 18px; }
  .author-portrait { width: 76px; height: 76px; }
  .author-body .btn { flex: 1 1 auto; justify-content: center; }

  /* sticky ToC (mobile collapsible): full width, comfy tap targets */
  .toc-mobile > summary { padding: 16px 18px; font-size: .98rem; }
  .toc-mobile .toc a { padding: 10px; font-size: 14px; }

  /* reading-progress a touch thicker so it's visible on small screens */
  .reading-progress { height: 3px; }
}

/* very small phones (≤ 380px): shave a bit more */
@media (max-width: 380px) {
  .container { padding-inline: 16px; }
  .guide-title { font-size: clamp(1.7rem, 9vw, 2.1rem); }
  .cmp { min-width: 460px; }
}
