/* ═══════════════════════════════════════════════════════════
   knowledge.css — the article layer
   ═══════════════════════════════════════════════════════════
   Loaded AFTER dragon-os.css, which stays untouched as the shared
   design language. Everything here is scoped to the knowledgebase:
   reading typography for the doc pages, plus a couple of local
   overrides. Uses the dragon-os tokens only — no new colours.

   Note: dragon-os.css defines --font-reading ('Inter') but never
   uses it. This is the layer it was waiting for.
   ═══════════════════════════════════════════════════════════ */

/* ── Local override: the card button's " //" suffix ──────────
   dragon-os.css appends content:" //" to every .dl-card-btn. That
   reads as a spec-sheet flourish on a product card, but on a READ
   button it looks like a truncated comment. Off inside the KB only. */
.dl-card-btn::after { content: none; }

/* The hero's second line is the page's real <h1>; kill UA margins
   so it sits exactly where the old <span> did. */
.dl-hero-line-2 { margin: 0; }


/* ══════════════════════════ THE ARTICLE ══════════════════════════ */

/* One shared measure for the article and its Related panel.
   Deliberately a length, not `ch`: the two blocks inherit different
   fonts, so `ch` resolves differently in each and they stop aligning.
   640px at 17px Inter lands ~72 characters — inside the 60-75 range
   where the eye reliably finds the next line on the return sweep. */
:root { --kb-measure: 640px; }

.dl-doc {
  max-width: var(--kb-measure);
  margin: 0 auto;
  padding: 8px 0 24px;
  font-family: var(--font-reading);
  font-size: 17px;
  line-height: 1.75;
  color: var(--text-secondary);
  -webkit-font-smoothing: antialiased;
}

/* Lede — the first paragraph carries the plain-language summary,
   so it gets size and full-strength colour. */
.dl-doc > p:first-child {
  font-size: 20px;
  line-height: 1.6;
  color: var(--text-primary);
  margin: 0 0 2em;
  padding-bottom: 1.4em;
  border-bottom: 1px solid var(--dragon-border);
}

.dl-doc p { margin: 0 0 1.35em; }

/* ── Headings ── */
.dl-doc h2 {
  font-family: var(--font-header);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-primary);
  margin: 2.6em 0 1em;
  padding-top: 1.2em;
  border-top: 1px solid var(--dragon-border-subtle);
  position: relative;
}
.dl-doc h2::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 0;
  width: 44px;
  height: 2px;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
}
.dl-doc h2:first-child { margin-top: 0; border-top: 0; padding-top: 0; }
.dl-doc h2:first-child::before { display: none; }

.dl-doc h3 {
  font-family: var(--font-body);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-primary);
  margin: 2em 0 0.7em;
}

.dl-doc h4 {
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 1.6em 0 0.6em;
}

/* ── Inline ──
   The drafts lead many paragraphs with a bolded product or route
   name ("**DFX Speed** is a processing module"). Lifting bold to
   full-strength colour makes those scan like the labels they are. */
.dl-doc strong { color: var(--text-primary); font-weight: 600; }
.dl-doc em { color: var(--text-secondary); font-style: italic; }

.dl-doc a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-dim);
  transition: border-color 0.2s ease, color 0.2s ease;
}
.dl-doc a:hover { color: var(--text-primary); border-bottom-color: var(--accent); }

.dl-doc code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  color: var(--text-primary);
  background: var(--accent-dim);
  border: 1px solid var(--dragon-border);
  border-radius: 4px;
  padding: 0.12em 0.42em;
  word-break: break-word;
}

.dl-doc pre.dl-code {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  background: var(--dragon-surface);
  border: 1px solid var(--dragon-border);
  border-left: 2px solid var(--accent);
  border-radius: 8px;
  padding: 16px 18px;
  margin: 0 0 1.5em;
  overflow-x: auto;
}
.dl-doc pre.dl-code code {
  background: none;
  border: 0;
  padding: 0;
  color: var(--text-secondary);
  font-size: inherit;
}

/* ── Lists ── */
.dl-doc ul, .dl-doc ol { margin: 0 0 1.5em; padding-left: 0; }
.dl-doc li { margin-bottom: 0.6em; }

.dl-doc ul { list-style: none; }
.dl-doc ul > li { position: relative; padding-left: 1.5em; }
.dl-doc ul > li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.68em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent-glow);
}

.dl-doc ol { list-style: none; counter-reset: dl-step; }
.dl-doc ol > li { position: relative; padding-left: 2em; counter-increment: dl-step; }
.dl-doc ol > li::before {
  content: counter(dl-step, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 0.1em;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 0.05em;
}

/* ── Blockquote ── */
.dl-doc blockquote {
  margin: 0 0 1.5em;
  padding: 2px 0 2px 20px;
  border-left: 2px solid var(--accent);
  color: var(--text-dim);
  font-style: italic;
}

.dl-doc hr {
  border: 0;
  border-top: 1px solid var(--dragon-border-subtle);
  margin: 2.4em 0;
}


/* ══════════════════════ RELATED (doc footer) ══════════════════════
   Every doc closes with its own "Related" list. Pulled out of the
   prose flow and set as a panel so the article ends deliberately
   instead of trailing off into more links. */
.dl-doc-related {
  max-width: var(--kb-measure);
  margin: 0 auto 8px;
  padding: 22px 26px;
  background: var(--dragon-surface);
  border: 1px solid var(--dragon-border);
  border-radius: 12px;
}
.dl-doc-related h2 {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 0 0 14px;
}
.dl-doc-related ul { list-style: none; margin: 0; padding: 0; }
.dl-doc-related li { margin: 0; border-top: 1px solid var(--dragon-border-subtle); }
.dl-doc-related li:first-child { border-top: 0; }
.dl-doc-related a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 0;
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.2s ease, padding-left 0.2s ease;
}
.dl-doc-related a::before {
  content: "→";
  color: var(--accent);
  font-size: 13px;
  opacity: 0.55;
  transition: opacity 0.2s ease;
}
.dl-doc-related a:hover { color: var(--text-primary); padding-left: 5px; }
.dl-doc-related a:hover::before { opacity: 1; }


/* ═══════════════════════ FLUID HERO TITLES ═══════════════════════
   These were inline `style="font-size: 42px"` on the <h1>, which no
   media query could reach. At 375px "PROGRAMMING AND DEVELOPMENT"
   measured 413px wide — 38px past the viewport, clipped by the hero.
   Now one fluid ramp per page tier, so the title fits every screen
   from 320px up without a breakpoint staircase. */
.kb-hero-h1 {
  overflow-wrap: break-word;
  word-break: break-word;
  hyphens: auto;
  max-width: 100%;
}
.kb-hero-h1[data-tier="hub"]      { font-size: clamp(30px, 7.6vw, 52px); }
.kb-hero-h1[data-tier="category"] { font-size: clamp(24px, 6.4vw, 42px); }
.kb-hero-h1[data-tier="doc"]      { font-size: clamp(23px, 5.6vw, 38px); }


/* ══════════════════════ READING INSTRUMENTS ══════════════════════
   The doc page's amp layer: progress LED, hero meta, section numbers,
   the "on this page" rail, and prev/next patrol. All generated at
   build time; the only runtime is ~15 lines of inline scroll wiring. */

/* Smooth anchor travel — guarded for motion-sensitive readers. */
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}
.dl-doc h2 { scroll-margin-top: 96px; }

/* ── Progress LED — a live wire across the top of the page ── */
.kb-progress {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), #8b5cf6);
  box-shadow: 0 0 12px var(--accent-glow);
  transform: scaleX(0);
  transform-origin: 0 50%;
  z-index: 1000;
  pointer-events: none;
}

/* ── Hero meta strip — the article's vitals under the title ── */
.kb-hero-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 20px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.kb-hero-meta .kb-meta-sep { color: var(--accent); opacity: 0.6; }

/* ── Section numbers — the muster-roll on every h2 ── */
.kb-h2-num {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-right: 14px;
  text-shadow: 0 0 8px var(--accent-glow);
}

/* ── Doc layout grid — article centered, rail standing watch left ── */
.kb-doc-layout {
  display: grid;
  grid-template-columns: minmax(0, var(--kb-measure));
  justify-content: center;
}
.kb-toc { display: none; }

@media (min-width: 1160px) {
  .kb-doc-layout.has-toc {
    grid-template-columns: 210px minmax(0, var(--kb-measure)) 210px;
    gap: 44px;
  }
  .kb-doc-layout.has-toc .kb-toc {
    display: block;
    align-self: start;
    position: sticky;
    top: 110px;
  }
}

.kb-toc-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 6px 0 14px;
}
.kb-toc ul { list-style: none; margin: 0; padding: 0; }
.kb-toc li { margin: 0; }
.kb-toc a {
  position: relative;
  display: block;
  padding: 7px 0 7px 16px;
  border-left: 1px solid var(--dragon-border-subtle);
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.kb-toc a:hover { color: var(--text-secondary); }
.kb-toc a.active {
  color: var(--text-primary);
  border-left-color: var(--accent);
}
.kb-toc a.active::before {
  content: "";
  position: absolute;
  left: -2.5px;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}

/* ── Prev / next patrol — the corridor to the neighbours ── */
.kb-doc-nav {
  max-width: var(--kb-measure);
  margin: 0 auto 8px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.kb-doc-nav a {
  display: block;
  padding: 18px 20px;
  background: var(--dragon-surface);
  border: 1px solid var(--dragon-border);
  border-radius: 12px;
  text-decoration: none;
  transition: border-color 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
}
.kb-doc-nav a:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--accent-glow);
}
.kb-doc-nav a.kb-next { text-align: right; }
.kb-doc-nav .kb-nav-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.kb-doc-nav .kb-nav-title {
  display: block;
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
  transition: color 0.25s ease;
}
.kb-doc-nav a:hover .kb-nav-title { color: var(--text-primary); }

@media (max-width: 560px) {
  .kb-doc-nav { grid-template-columns: 1fr; }
  .kb-doc-nav a.kb-next { text-align: left; }
}

/* ── Arrival — the article settles into place ── */
@media (prefers-reduced-motion: no-preference) {
  .dl-doc, .kb-toc, .kb-doc-nav, .dl-doc-related {
    animation: kb-settle 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
  }
  @keyframes kb-settle {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
  }
}


/* ══════════════════════════ RESPONSIVE ══════════════════════════
   Measured on a 375x812 handset against the real pages, not guessed.
   The TOC rail is desktop-only (>=1160px) and already absent here. */

/* ── Tablet / small laptop: reclaim the gutters ── */
@media (max-width: 900px) {
  .dl-hero { min-height: 0 !important; padding: 34px 20px !important; }
  .kb-hero-meta { margin-top: 16px; }
}

/* ── Phone ── */
@media (max-width: 640px) {
  .dl-doc { font-size: 16px; line-height: 1.7; }
  .dl-doc > p:first-child { font-size: 18px; padding-bottom: 1.2em; margin-bottom: 1.6em; }
  .dl-doc h2 { font-size: 13px; letter-spacing: 0.12em; margin: 2.2em 0 0.8em; }
  .dl-doc h3 { font-size: 17px; }
  .dl-doc h2 .kb-h2-num { margin-right: 10px; }
  .dl-doc-related { padding: 18px 20px; border-radius: 10px; }

  /* Long paths/endpoints inside code must scroll, never widen the page. */
  .dl-doc pre.dl-code { padding: 13px 14px; font-size: 12.5px; }

  /* The meta strip's wide tracking is what breaks it first on narrow screens. */
  .kb-hero-meta {
    flex-wrap: wrap;
    gap: 8px;
    font-size: 9px;
    letter-spacing: 0.24em;
    padding: 0 8px;
  }

  /* Anchor offset shrinks with the header. */
  .dl-doc h2 { scroll-margin-top: 72px; }
}

/* ── Small phone (320-375px): the tightest real target ── */
@media (max-width: 400px) {
  .dl-hero { padding: 28px 16px !important; }
  .dl-section { padding-left: 16px !important; padding-right: 16px !important; }
  .dl-doc-related { padding: 16px 16px; }
  .kb-doc-nav a { padding: 15px 16px; }
  .dl-doc ul > li { padding-left: 1.25em; }
  .dl-doc ol > li { padding-left: 1.75em; }
}

/* ── Landscape phone: don't let a tall hero eat the whole screen ── */
@media (max-height: 480px) and (orientation: landscape) {
  .dl-hero { min-height: 0 !important; padding: 24px 20px !important; }
}

/* Long, unbroken tokens (paths, endpoints) must not push the page wide. */
.dl-doc { overflow-wrap: break-word; }
