/*
 * SN Knowledge Base v11 — additions only.
 *
 * Everything reusable (header, role-switcher, search, sidebar, card grid,
 * modal shell, pending list, fullscreen/app-mode) is already in
 * knowledge-base.css and js/kb-v11.js uses those classes as-is — nothing
 * here duplicates them.
 *
 * Two things are genuinely new to v11 and have no existing equivalent:
 * the release picker (the old widget had no release concept) and the
 * entry detail drawer's content blocks (the old widget only highlighted
 * related cards in place; it never drilled into one entry). Both are
 * built only from the --dl-kb-* tokens defined in knowledge-base.css
 * (verified: lines 17-64 light theme, 86-117 dark theme) — no hardcoded
 * hex values, per AGENTS.md section 3.
 */

/* ---------- full-bleed breakout ----------
 * 2026-11-22, root cause confirmed live via DevTools (getComputedStyle on
 * dadalab.com/poc-copy/, not guessed): this was never a narrow-ancestor
 * problem. The actual parent, .entry-content, computed out to 2500px wide
 * on a 2848px viewport — already nearly full width. The real constraint was
 * WordPress's own block-theme layout CSS: every direct child of a
 * `.wp-block-post-content-is-layout-constrained` container gets
 * `max-width: 645px` unless it carries an alignwide/alignfull class.
 * Confirmed directly: getComputedStyle(wrap).maxWidth === "645px" even
 * with an inline `width` set to something far larger — max-width always
 * wins over width, however the width is set, inline included. That's why
 * two earlier attempts both failed silently: a pure-CSS left:50%/-50vw trick
 * (shoved the widget off-screen, since it assumed a centered narrow
 * ancestor that doesn't exist), then a JS-measured runtime negative-margin
 * version (applied an inline width, which the max-width clamp overrode
 * right back down to 645px every time). Neither touched the thing actually
 * constraining it. Both are gone now; js/kb-v11.js no longer has an
 * applyBreakout() at all.
 *
 * Fix: cancel WordPress's per-child max-width directly on the wrapper.
 * .dl-page (already used elsewhere in style.css) then re-caps and centers
 * the result at the site's existing --dl-wide-w (1340px), same as any
 * other wide content block on the site — reusing the component rather than
 * inventing a new one, per AGENTS.md section 3.
 *
 * Wrap the widget as: <div class="dl-kb-breakout"><div class="dl-page">
 * <div id="kb-app"></div></div></div>
 */
.dl-kb-breakout { max-width: none; width: 100%; }

/* ---------- release picker ---------- */

.dl-kb .release-picker {
  display: flex;
  align-items: center;
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--dl-kb-border);
  border-radius: var(--dl-kb-radius);
  background: var(--dl-kb-bg);
  color: var(--dl-kb-text-secondary);
  font-family: var(--dl-kb-mono);
  font-size: 11px;
  cursor: pointer;
  transition: var(--dl-kb-transition);
}
.dl-kb .release-picker:hover { border-color: var(--dl-kb-border-strong); color: var(--dl-kb-text-primary); }
.dl-kb .release-picker:focus-visible { outline: 2px solid var(--dl-kb-sn-green-dark); outline-offset: 2px; }

@media (max-width: 640px) {
  .dl-kb .release-picker { min-height: 44px; }
}

/* ---------- entry detail drawer ---------- */
/* Reuses .modal/.modal-close/.modal-sub/.approve-btn from knowledge-base.css
   as the shell; only the content blocks below are new. */

.dl-kb .dl-kb-detail-desc {
  font-size: 13px;
  color: var(--dl-kb-text-secondary);
  line-height: 1.5;
  margin-bottom: 16px;
}

.dl-kb .dl-kb-detail-block { margin-bottom: 16px; }
.dl-kb .dl-kb-detail-block:last-of-type { margin-bottom: 20px; }

.dl-kb .dl-kb-detail-block h3 {
  font-size: 11px;
  font-family: var(--dl-kb-mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--dl-kb-text-muted);
  margin-bottom: 6px;
}

.dl-kb .dl-kb-detail-block p {
  font-size: 13px;
  color: var(--dl-kb-text-primary);
  line-height: 1.5;
}

.dl-kb .dl-kb-detail-block ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dl-kb .dl-kb-detail-block li {
  font-size: 13px;
  color: var(--dl-kb-text-primary);
  padding: 8px 10px;
  background: var(--dl-kb-bg);
  border-radius: var(--dl-kb-radius);
}

.dl-kb .dl-kb-detail-source {
  font-size: 11px;
  font-family: var(--dl-kb-mono);
  color: var(--dl-kb-text-muted);
  margin-bottom: 8px;
}
.dl-kb .dl-kb-detail-source a { color: var(--dl-kb-sn-green-dark); text-decoration: none; }
.dl-kb .dl-kb-detail-source a:hover { text-decoration: underline; }

.dl-kb .dl-kb-detail-approval {
  font-size: 12px;
  font-family: var(--dl-kb-mono);
  color: var(--dl-kb-text-secondary);
  margin-bottom: 8px;
}

/* 2026-11-22: the "Review this entry" button sat right under whatever text
 * block happened to precede it (Source, Approval area, Decision), inheriting
 * only that block's 8px margin-bottom — reads as crowded, the button needs
 * to feel like its own distinct action, not a continuation of the metadata
 * above it. 20px matches the existing rhythm value this file already uses
 * for a detail-block's closing margin (line 83), not a new number.
 */
.dl-kb .dl-kb-detail .approve-btn { margin-top: 20px; }

/* ---------- Proposed link relocated into the sidebar ----------
 * 2026-11-22: moved out of the header into the sidebar, under the category
 * rows, per David's call — it was easy to miss as a small text link sitting
 * between the role switcher and the release picker. Still the same
 * #dl-kb-pending-btn element and .btn-tertiary styling from
 * knowledge-base.css; this only adds the spacing/divider needed now that
 * it's a sidebar row instead of a header item. JS hides it entirely when
 * there's nothing Proposed, not just for Guest — see renderPendingModal().
 */
.dl-kb-sidebar #dl-kb-pending-btn {
  margin-top: 8px;
  padding: 8px 10px;
  border-top: 1px solid var(--dl-kb-border);
}

@media (max-width: 860px) {
  /* Sidebar is a horizontal scrolling row at this width (see
     knowledge-base.css); a top divider reads wrong turned sideways, so swap
     it for a left divider and drop the stacked spacing. */
  .dl-kb-sidebar #dl-kb-pending-btn {
    margin-top: 0;
    padding: 8px 10px 8px 14px;
    border-top: none;
    border-left: 1px solid var(--dl-kb-border);
    flex-shrink: 0;
  }
}

/* card footer additions: maturity label sits beside the stability pill / pending chip */

.dl-kb .footer-left { display: flex; align-items: center; gap: 10px; }

.dl-kb .maturity-label {
  font-size: 10px;
  font-family: var(--dl-kb-mono);
  color: var(--dl-kb-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

@media (prefers-reduced-motion: reduce) {
  .dl-kb .release-picker { transition: none; }
}

/* ======================================================================
 * 2026-11-23 header/visual redesign (David's call).
 *
 * Everything below is scoped to #dl-kb-v11 so none of it reaches the
 * shared .dl-kb rules in knowledge-base.css that the still-live v9 widget
 * at /poc/ depends on. v11 gets its own fixed dark/white scheme (no
 * light/dark toggle), sourced from David's own ServiceNow screenshots,
 * pixel-sampled rather than guessed or taken from Figma:
 *   #57d245  button green   — f7dd5d4c-image.png ("Sign in with your
 *                              ServiceNow ID"), confirmed independently in
 *                              fc138b4f-image.png and 65df31e2-image.png
 *   #02273a  dark navy chrome — 673b6f7d-image.png ("Hi Jim" MyNow dashboard)
 *   #fefefe  white card/field  — 673b6f7d-image.png (same screen)
 *   #1b1b1b  dark ink text     — f7dd5d4c-image.png
 * WCAG: #1b1b1b on #57d245 ≈ 8.79:1 (computed by hand, sRGB-linearized),
 * well past AA's 4.5:1 — see the role-btn.active rule below.
 * On-dark muted text reuses #a9c4d1, the existing dark-theme
 * --dl-kb-text-secondary value already in knowledge-base.css (line ~91,
 * Impeccable-audited 2026-10-26 against a very close navy) rather than
 * inventing a new muted tone.
 * ====================================================================== */

#dl-kb-v11 {
  --dl-kb-bg: #02273a;
  --dl-kb-surface: #fefefe;
  --dl-kb-border: #0e3954;
  --dl-kb-border-strong: #12405c;
  --dl-kb-text-primary: #1b1b1b;
  --dl-kb-text-secondary: #4a4a4a;
  --dl-kb-text-muted: #6b6b6b;
  --dl-kb-input-border: #868073;
  --dl-kb-ink: #57d245;
  --dl-kb-ink-text: #1b1b1b;
  --dl-kb-sn-green: #57d245;
  --dl-kb-sn-green-dark: #2f8a1f; /* darkened for AA text/icon use on white; the pure
     sample green is a fill color, not a text-safe one against --dl-kb-surface */
  --dl-kb-sn-green-tint: #eaf7e6;
  /* On-dark text — for the handful of elements (header, footer, role switcher,
     search eyebrow, filters/expand buttons) that sit directly on --dl-kb-bg
     rather than on a white card or modal. --dl-kb-text-* above stay dark;
     they serve the cards and modals, which are most of this widget's text. */
  --dl-kb-ondark-text: #fefefe;
  --dl-kb-ondark-muted: #a9c4d1;
}

/* ---------- header: dark chrome, bare wordmark ---------- */
/* Header used --dl-kb-surface (white) in the shared rule; v11 wants the
   same dark chrome as the rest of the shell, white cards floating on top
   of it — David's "Hi Jim" reference. */
#dl-kb-v11 .dl-kb-header { background: var(--dl-kb-bg); border-bottom-color: var(--dl-kb-border); }
#dl-kb-v11 .logo { gap: 8px; }
#dl-kb-v11 .logo-mark {
  font-family: var(--dl-kb-mono);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--dl-kb-ondark-text);
}
#dl-kb-v11 .logo-text { color: var(--dl-kb-ondark-muted); font-weight: 500; }

/* ---------- role switcher: primary (selected) / secondary (unselected) ----------
 * David's reference: the Cancel/Done pair — one solid-green primary action,
 * everything else a white secondary with a visible border. Applied to the
 * three role buttons: whichever is selected gets the primary treatment, the
 * other two get the secondary one. No segmented-control grouping bg needed
 * now that each button carries its own fill. Also shorter (David: "too
 * tall") — 6px vertical padding instead of relying on the switcher's own box.
 */
#dl-kb-v11 .role-switcher { background: none; border: none; gap: 6px; }
#dl-kb-v11 .role-btn {
  padding: 6px 13px;
  border-radius: var(--dl-kb-radius);
  background: var(--dl-kb-surface);
  color: var(--dl-kb-text-primary);
  border: 1.5px solid var(--dl-kb-sn-green-dark);
}
#dl-kb-v11 .role-btn:hover { background: var(--dl-kb-sn-green-tint); }
#dl-kb-v11 .role-btn.active {
  background: var(--dl-kb-ink);
  color: var(--dl-kb-ink-text);
  border-color: var(--dl-kb-ink);
}
#dl-kb-v11 .role-btn.active:hover { background: var(--dl-kb-ink); opacity: 0.9; }

/* ---------- header action buttons on dark chrome ---------- */
/* .dl-kb-fullscreen-btn already uses --dl-kb-surface/--dl-kb-text-secondary,
   which are now white/dark — it renders correctly as a light pill on the
   dark header with no override needed. filtersButton() carries that same
   class (see js/kb-v11.js) so it gets identical chrome for free. */
#dl-kb-v11 .filters-icon { font-size: 13px; line-height: 1; }

/* ---------- search: bigger, gently glowing icon, prompt-style eyebrow ---------- */
#dl-kb-v11 .search-eyebrow { color: var(--dl-kb-ondark-muted); font-weight: 500; letter-spacing: 0.02em; text-transform: none; font-family: var(--dl-kb-sans); font-size: 15px; }
#dl-kb-v11 .search-icon {
  font-size: 19px;
  left: 14px;
  color: var(--dl-kb-sn-green-dark);
  animation: dl-kb-v11-glow 2.6s ease-in-out infinite;
}
#dl-kb-v11 .dl-kb-search-input { padding-left: 46px; }
@keyframes dl-kb-v11-glow {
  0%, 100% { filter: drop-shadow(0 0 1px rgba(87, 210, 69, 0.35)); }
  50% { filter: drop-shadow(0 0 5px rgba(87, 210, 69, 0.8)); }
}
@media (prefers-reduced-motion: reduce) {
  #dl-kb-v11 .search-icon { animation: none; filter: drop-shadow(0 0 3px rgba(87, 210, 69, 0.5)); }
}

/* ---------- layout: no sidebar column, three-column card grid ----------
 * The shared .dl-kb-layout rule reserves a 200px first column for the
 * sidebar <nav> that v11 no longer renders (replaced by the All-filters
 * overlay below) — without this override that column would sit empty.
 * Three columns instead of two, per David's call, now that the freed
 * sidebar width is available for cards.
 */
#dl-kb-v11 .dl-kb-layout { display: block; }
/* results-header text sits directly on --dl-kb-bg (dark), not on a card —
 * same on-dark case as the header/footer. Caught in the first screenshot
 * pass: both tokens it used by default are dark ink, nearly invisible on
 * navy. */
#dl-kb-v11 .results-count { color: var(--dl-kb-ondark-muted); }
#dl-kb-v11 .results-count span { color: var(--dl-kb-ondark-text); }
#dl-kb-v11 .no-results { color: var(--dl-kb-ondark-muted); }

/* .dl-kb-detail-block li (entry detail "Relationships" list, and the new
 * version popup's changelog) uses --dl-kb-bg as its fill — fine when that
 * token was a light neutral, illegible now that it's dark navy and the
 * list sits inside a white modal. Caught visually in the version-popup
 * screenshot. Reuses the existing pale-green tint already used for
 * highlighted rows elsewhere (cat-row hover, is-related cards) rather
 * than a new value. */
#dl-kb-v11 .dl-kb-detail-block li { background: var(--dl-kb-sn-green-tint); }
#dl-kb-v11 .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 960px) { #dl-kb-v11 .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { #dl-kb-v11 .grid { grid-template-columns: 1fr; } }

/* ---------- All-filters overlay (replaces the sidebar) ----------
 * Category rows and the release picker keep their existing .cat-row /
 * .release-picker rules verbatim; this only adjusts the few that assumed
 * a dark-bg hover/fill context when they're now inside the white modal.
 */
#dl-kb-v11 .dl-kb-filters .filters-block { margin-bottom: 20px; }
#dl-kb-v11 .dl-kb-filters .filters-block:last-of-type { margin-bottom: 0; }
#dl-kb-v11 .dl-kb-filters .filters-block h3 {
  font-size: 11px;
  font-family: var(--dl-kb-mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--dl-kb-text-muted);
  margin-bottom: 8px;
}
#dl-kb-v11 .filters-cats { display: flex; flex-direction: column; gap: 1px; }
#dl-kb-v11 .dl-kb-filters .cat-row:hover { background: var(--dl-kb-sn-green-tint); }
#dl-kb-v11 .dl-kb-filters .release-picker { background: var(--dl-kb-surface); }
#dl-kb-v11 .dl-kb-filters #dl-kb-pending-btn { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--dl-kb-border); }

/* ---------- footer: version-history trigger replaces the static tagline ---------- */
#dl-kb-v11 .dl-kb-footer { border-top-color: var(--dl-kb-border); color: var(--dl-kb-ondark-muted); }
#dl-kb-v11 .dl-kb-footer .version-link { font-size: 11px; font-family: var(--dl-kb-mono); color: var(--dl-kb-ondark-muted); }
#dl-kb-v11 .dl-kb-footer .version-link:hover { color: var(--dl-kb-ondark-text); }

/* ---------- expand to full browser width, in place (not true fullscreen) ----------
 * David's call: the old native-Fullscreen "Fullscreen" button covered the
 * whole monitor, hiding the rest of the page. fullscreenBtn() in
 * js/kb-v11.js now just toggles this class on the .dl-page ancestor
 * (the same wrap the breakout fix above already escapes to 100%) instead
 * of calling requestFullscreen() — the widget widens in its normal place
 * in the page flow, nothing else is covered.
 */
.dl-page.is-kb-wide { max-width: none; }
