/*
 * Engineering Edge — "Ask" UI styles.
 *
 * Ported from the frozen co-design prototype (docs/ka-ui-spec.html, v2.2).
 * Two deliberate departures from the prototype file:
 *   1. All classes are namespaced `ka-*` and design tokens are scoped to
 *      `.ka-root`, so nothing collides with Semantic UI / invenio-app-rdm
 *      classes (the prototype used bare `.btn`, `.searchbox`, `.src`, …).
 *   2. Dark mode is NOT shipped (prompt §4: a KA-only dark island against a
 *      light InvenioRDM would be worse than none). The high-contrast variant
 *      (`.ka-root.hc`) IS shipped and is the accessibility toggle.
 *
 * Palette and typography are the ee theme tokens exactly as the spec froze them.
 */
@import url("../shared/grouplabel.css"); /* the "Knowledge maps" heading label */

.ka-root {
  --slate: #64748b;
  --slate-deep: #566071;
  --slate-hover: #485060;
  --orange: #f78f01;
  --orange-soft: #fdf0dd;
  --orange-ink: #9a3412; /* AA text on --orange-soft (6.50:1) and white (7.31:1) */
  --focus: #1d4ed8; /* the site-wide focus ring (6.70:1 on white) */
  --control-border: #7b8494; /* input borders, 3.77:1 on white (1.4.11) */
  --blue: #4cbeff;
  --blue-deep: #2596d1;
  --ink: #1e293b;
  /* --muted / --label / --pdf-ok darkened from the prototype's #697586 /
     #94a3b8 / #16a34a so secondary text clears WCAG AA (4.5:1) on white and
     on --bg-soft. --faint stays light — it is only used for borders and
     placeholders, never as body text. (§4 contract-checked tokens.) */
  --muted: #5c6675;
  --faint: #94a3b8;
  --label: #5f6b7a;
  --pdf-ok: #157f3c;
  --line: #e2e8f0;
  --line-soft: #eef2f6;
  --bg: #ffffff;
  --bg-soft: #f8fafc;
  --card: #ffffff;
  --ok: #16a34a;
  --serif: "Source Serif 4", Georgia, serif;
  --sans: "Inter", -apple-system, "Segoe UI", sans-serif;
}

/* High-contrast variant — the shipped a11y toggle (persisted per browser). */
.ka-root.hc {
  --ink: #000000;
  --muted: #1e293b;
  --faint: #334155;
  --orange: #b45309;
  --orange-soft: #ffedd5;
  --blue-deep: #1d4ed8;
  --ok: #15803d;
}
.ka-root.hc .ka-src,
.ka-root.hc .ka-searchbox,
.ka-root.hc .ka-refusal,
.ka-root.hc .ka-guardrail {
  border-width: 2px;
}
.ka-root.hc .ka-cite {
  border-width: 1.5px;
  font-weight: 700;
}

/* Same ring as the site-wide rule in site.overrides (3px #1d4ed8). Inside the
   slate navbar the #invenio-nav rule there paints it white instead. */
.ka-root :focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
.ka-root svg.ka-ic {
  width: 1em;
  height: 1em;
  vertical-align: -2px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── search/ask unit — lives IN the navbar on every page (v2.3) ───────── */
/* The unit is a white pill dropped into the slate navbar, filling the flex
   space between the logo and the right-hand nav items (the `.item.search-bar`
   wrapper already carries `flex:1` from menu.overrides). */
.ka-navsearch {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
}
.ka-searchbox {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  background: var(--card);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: none;
  border: 1px solid transparent;
}
.ka-searchbox input {
  flex: 1;
  border: 0;
  padding: 10px 14px;
  font-size: 14.5px;
  font-family: var(--sans);
  color: var(--ink);
  min-width: 0;
  background: transparent;
}
.ka-searchbox input::placeholder {
  color: var(--muted); /* 5.81:1 on white — the typewriter uses this too */
}
.ka-searchbox input:focus {
  outline: none;
}
/* The input's own ring is off (the box is one visual unit); the box shows a
   white ring on the slate navbar while anything inside it has focus. */
.ka-searchbox:focus-within {
  outline: 3px solid #fff;
  outline-offset: 2px;
}
.ka-btn {
  border: 0;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  padding: 0 15px;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}
.ka-btn-search {
  /* Dark-grey text AND icon (icon inherits via currentColor), matching the
     navbar's Log in link — not the old orange/white search button. */
  background: var(--bg-soft);
  color: #334155;
  border-left: 1px solid var(--line);
}
.ka-btn-search:hover {
  background: var(--line-soft);
}
/* Responsive: below 820px the button words collapse, leaving icon-only
   (magnifier / ✦). Narrower still, InvenioRDM's burger stacks the whole unit
   into the collapsed menu (a full-width second row). */
@media (max-width: 820px) {
  .ka-btn .ka-btnword {
    display: none;
  }
  .ka-btn {
    padding: 0 12px;
  }
}
.ka-btn-ask {
  background: var(--orange);
  color: var(--ink); /* dark ink on the brand orange: 6.19:1 (white was 2.36:1) */
  position: relative;
  overflow: hidden;
}
.ka-btn-ask:hover {
  background: #e07f00;
}
.ka-root.hc .ka-btn-ask:hover {
  background: #92400e;
}
.ka-spark {
  font-size: 15px;
  line-height: 1;
}
/* Shimmer (WCAG 1.4.3 + 2.2.2, 2026-11-07): the glyphs are solid ink — no
   colour in a gradient could keep ≥4.5:1 on the orange (the lightest band
   would need to be near-black) — and the sweep is a translucent white SHEEN
   behind them (::before), which only lightens the orange under the ink, so
   the label stays ≥ 6.19:1 at every point of the sweep. It runs ONCE on page
   load (4.8s, under the 5s unprompted-motion limit) and once more on
   hover/focus (a second keyframes name restarts it); never infinite. Reduced
   motion: no sheen at all. Single linear segment, both ends off-button. */
.ka-btn-ask .ka-asklabel {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  position: relative;
  z-index: 1;
  color: var(--ink);
}
.ka-btn-ask::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
      105deg,
      rgba(255, 255, 255, 0) 32%,
      rgba(255, 255, 255, 0.45) 50%,
      rgba(255, 255, 255, 0) 68%
    )
    0 0 / 260% 100%;
  animation: ka-asksweep 4.8s linear 1;
}
.ka-btn-ask:hover::before,
.ka-btn-ask:focus-visible::before {
  animation: ka-asksweep-again 4.8s linear 1;
}
@keyframes ka-asksweep {
  from {
    background-position: 250% 0; /* off-button */
  }
  to {
    background-position: -400% 0; /* one linear sweep, then off-button */
  }
}
@keyframes ka-asksweep-again {
  from {
    background-position: 250% 0;
  }
  to {
    background-position: -400% 0;
  }
}
.ka-caret {
  display: inline-block;
  width: 1px;
  height: 1.05em;
  background: var(--faint);
  vertical-align: -2px;
  margin-left: 1px;
  animation: ka-blink 1s steps(1) infinite;
}
@keyframes ka-blink {
  50% {
    opacity: 0;
  }
}
/* ── ask page layout ────────────────────────────────────── */
.ka-askwrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 14px 28px 60px;
}
/* Question row: icon + h1 + the high-contrast toggle (which no longer takes
   a row of its own). A long question wraps BESIDE the icon (the h1 is a
   flex item with min-width:0), never under it; on narrow screens the
   toggle wraps under the title. */
.ka-qrow {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 6px 10px;
}
.ka-qicon {
  flex: none;
  width: 24px;
  height: 24px;
  margin-top: 2px;
  color: var(--blue-deep);
  stroke: currentColor;
  fill: none;
  stroke-width: 2.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ka-qtitle {
  flex: 1 1 240px;
  min-width: 0;
  font-size: 23px;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -0.3px;
  margin: 0;
  text-wrap: balance;
  color: var(--ink);
  font-family: var(--sans);
}
.ka-phase {
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--muted);
  font-size: 13.5px;
  margin: 6px 0 4px;
  min-height: 34px;
}

/* ── Ask "working" loader — three orbiting stars (docs/ka-ask-loader.html) ──
   One shell (.ka-loader) holding one SVG: three four-point stars (the ✦ of
   the navbar Ask button) of different sizes circle a shared centre
   (.kl-ring rotates) while each star twinkles — scale + opacity — in turn
   (staggered animation-delay). No variants. The colour flips blue
   (--blue-deep, searching) → orange (--orange, .is-generating, faster).
   Colour is ONLY the two brand tokens, so .ka-root.hc adapts with no extra
   rules. Reduced-motion is handled in the media block below. */
.ka-loader {
  --klc: var(--blue-deep);
  --klspd: 2.4s;
  --klsize: 30px;
  width: var(--klsize);
  height: var(--klsize);
  flex: 0 0 var(--klsize);
  display: inline-block;
  vertical-align: middle;
}
.ka-loader.is-generating {
  --klc: var(--orange);
  --klspd: 1.6s;
}
.ka-loader svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  display: block;
}
.ka-loader .kl-star {
  fill: var(--klc);
  transform-box: fill-box;
  transform-origin: center;
  animation: kl-twinkle var(--klspd) ease-in-out infinite;
}
.ka-loader .kl-star.s2 {
  animation-delay: calc(var(--klspd) / -3);
}
.ka-loader .kl-star.s3 {
  animation-delay: calc(var(--klspd) / -1.5);
}
.ka-loader .kl-ring {
  transform-box: view-box;
  transform-origin: 24px 24px;
  animation: kl-orbit var(--klspd) linear infinite;
}
@keyframes kl-orbit {
  to {
    transform: rotate(360deg);
  }
}
@keyframes kl-twinkle {
  0%,
  100% {
    transform: scale(0.8);
    opacity: 0.65;
  }
  50% {
    transform: scale(1.1);
    opacity: 1;
  }
}
/* Reduced-motion fallback (applied in the @media block below). */
@keyframes kl-breath {
  0%,
  100% {
    opacity: 0.5;
  }
  50% {
    opacity: 1;
  }
}
.ka-stats {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--muted);
  margin: 12px 0 8px;
  min-height: 20px;
}
.ka-stats b {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.ka-stats .ka-sep {
  color: var(--line);
}
.ka-cols {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 42px;
  margin-top: 10px;
}
@media (max-width: 900px) {
  .ka-cols {
    grid-template-columns: 1fr;
  }
}

/* ── history ────────────────────────────────────────────── */
.ka-hx {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 14px;
  background: var(--bg-soft);
  max-width: 66ch;
}
.ka-hx summary {
  cursor: pointer;
  padding: 10px 14px;
  font-weight: 600;
  font-size: 14px;
  color: var(--muted);
  list-style: none;
  display: flex;
  gap: 8px;
  align-items: baseline;
}
.ka-hx summary::-webkit-details-marker {
  display: none;
}
.ka-hx summary::before {
  content: "Q";
  font-size: 11px;
  font-weight: 700;
  color: var(--orange);
  background: var(--orange-soft);
  border-radius: 4px;
  padding: 0 5px;
  flex: none;
}
.ka-hx[open] summary {
  border-bottom: 1px solid var(--line);
}
.ka-hx .ka-hxbody {
  padding: 12px 16px;
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.65;
  color: var(--muted);
}
.ka-hxnote {
  font-size: 11.5px;
  color: var(--label);
  margin: 0 0 10px;
}

/* ── answer + citations ─────────────────────────────────── */
.ka-answer {
  font-family: var(--serif);
  font-size: 16.5px;
  line-height: 1.72;
  max-width: 66ch;
  color: var(--ink);
}
.ka-answer p {
  margin: 0 0 1.05em;
}
/* Answer headings — the model's "## Heading" / "**Bold heading**" lines,
   rendered as h3 (the h1 is the question) by ask.js from parsed tokens. */
.ka-answer .ka-ah {
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
  margin: 1.2em 0 0.4em;
  color: var(--ink);
}
.ka-answer .ka-ah:first-child {
  margin-top: 0;
}
.ka-answer strong {
  font-weight: 600;
}
.ka-answer ul,
.ka-answer ol {
  margin: 0 0 1.05em;
  padding-left: 1.4em;
}
.ka-answer li {
  margin: 0 0 0.3em;
}
.ka-cite {
  /* Square-ish box (frozen v2.3): a centred flex box with min-width == height,
     so the shape stays consistent whether the number is 1 or 2 digits and the
     answer's line-height can't stretch it into a tall rectangle. */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-width: 17px;
  height: 17px;
  padding: 0 3px;
  line-height: 1;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  color: var(--orange-ink); /* 6.50:1 on the soft orange (was --orange, 2.10:1) */
  background: var(--orange-soft);
  border: 1px solid #f5d9ae;
  border-radius: 4px;
  margin: 0 2px;
  /* Centre the chip on the text line (was baseline-ish, which sat too low) —
     inline-flex + align-items:center handles the digit inside the box. */
  vertical-align: middle;
  cursor: pointer;
  transition: background 0.12s;
}
.ka-cite:hover,
.ka-cite.hot {
  background: var(--orange);
  color: var(--ink); /* ink on the brand orange, 6.19:1 (white was 2.36:1) */
}
/* chained chips sit flush against their sibling */
.ka-cite.chained {
  margin-left: 0;
}
.ka-nb {
  white-space: nowrap;
}

.ka-refusal {
  border: 1px solid var(--line);
  border-left: 3px solid var(--slate);
  background: var(--bg-soft);
  border-radius: 0 8px 8px 0;
  padding: 16px 20px;
  font-family: var(--sans);
  font-size: 14.5px;
  color: var(--ink);
  max-width: 60ch;
}
.ka-guardrail {
  border: 1px solid var(--line);
  border-left: 3px solid var(--orange);
  background: var(--bg-soft);
  border-radius: 0 8px 8px 0;
  padding: 16px 20px;
  font-family: var(--sans);
  font-size: 14.5px;
  color: var(--ink);
  max-width: 60ch;
}
.ka-guardrail .ka-gr-btns {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.ka-gr-btn {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 13.5px;
  cursor: pointer;
  font-weight: 500;
  color: var(--ink);
  font-family: var(--sans);
}
.ka-gr-btn.primary {
  background: var(--orange);
  border-color: var(--orange);
  /* Dark ink on brand orange (≈5.9:1) rather than white (≈2.4:1), so the
     solid primary CTA meets AA while keeping the brand colour. §4. */
  color: var(--ink);
  font-weight: 600;
}
.ka-gr-btn:hover {
  border-color: var(--faint);
}
.ka-gr-btn.primary:hover {
  background: #e07f00;
}

/* The honest, persistent failure state that REPLACES the "Searching…" spinner
   when a retrieval hangs or fails before an answer (incident 2026-09-18). Same
   calm card language as the refusal/guardrail boxes, with a slate accent (a
   neutral "try again", not an alarm) and the AA-safe orange primary CTA. */
.ka-askerror {
  border: 1px solid var(--line);
  border-left: 3px solid var(--slate);
  background: var(--bg-soft);
  border-radius: 0 8px 8px 0;
  padding: 16px 20px;
  font-family: var(--sans);
  font-size: 14.5px;
  color: var(--ink);
  max-width: 60ch;
}
.ka-askerror-msg {
  margin: 0 0 14px;
}
.ka-askerror-retry {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--orange);
  background: var(--orange);
  /* Dark ink on brand orange (≈5.9:1) — matches the guardrail primary CTA. */
  color: var(--ink);
  border-radius: 6px;
  padding: 8px 16px;
  font-family: var(--sans);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}
.ka-askerror-retry:hover {
  background: #e07f00;
}
.ka-root.hc .ka-askerror {
  border-width: 2px;
}

.ka-feedback {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
  font-size: 13px;
  color: var(--muted);
}
.ka-thumb {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
}
.ka-thumb svg.ka-ic {
  width: 16px;
  height: 16px;
}
.ka-thumb:hover {
  border-color: var(--faint);
  color: var(--ink);
}
.ka-thumb.sel-up {
  background: #e9f9ef;
  border-color: var(--ok);
  color: var(--ok);
}
.ka-thumb.sel-up svg.ka-ic {
  fill: #bbf7d0;
}
.ka-thumb.sel-dn {
  background: #fdeaea;
  border-color: #dc2626;
  color: #dc2626;
}
.ka-thumb.sel-dn svg.ka-ic {
  fill: #fecaca;
}
.ka-followup {
  display: flex;
  margin-top: 20px;
  border: 1px solid var(--control-border); /* ≥3:1 on white (1.4.11) */
  border-radius: 8px;
  overflow: hidden;
  max-width: 560px;
  background: var(--card);
}
.ka-followup:focus-within {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
.ka-followup input::placeholder {
  color: var(--muted); /* 5.81:1 on white */
}
.ka-followup input {
  flex: 1;
  border: 0;
  padding: 11px 14px;
  font-size: 14px;
  font-family: var(--sans);
  background: transparent;
  color: var(--ink);
}
.ka-followup input:focus {
  outline: none;
}
.ka-followup button {
  border: 0;
  background: var(--orange-soft);
  color: var(--orange-ink); /* the ✦ is the only content: 6.50:1 */
  font-weight: 600;
  padding: 0 16px;
  cursor: pointer;
  font-family: var(--sans);
}
.ka-retrywrap {
  margin-top: 14px;
  max-width: 60ch;
}

/* ── sources rail ───────────────────────────────────────── */
.ka-railhead {
  font-size: 11.5px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--label);
  margin: 0 0 10px;
  font-weight: 600;
  line-height: 1.2;
}
.ka-railhead.consulted {
  margin-top: 22px;
}
/* "Also consulted (N)": a closed <details> under the cited cards. The
   summary keeps the rail-heading look plus a disclosure arrow. */
.ka-consulted > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.ka-consulted > summary::-webkit-details-marker {
  display: none;
}
.ka-consulted > summary::before {
  content: "";
  width: 0;
  height: 0;
  border-left: 5px solid currentColor;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform 0.15s;
}
.ka-consulted[open] > summary::before {
  transform: rotate(90deg);
}
.ka-consulted > summary:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
.ka-consulted > div {
  margin-top: 10px;
}
.ka-src {
  display: flex;
  gap: 11px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 8px;
  background: var(--card);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.2s;
  text-align: left;
  width: 100%;
  font-family: var(--sans);
  color: var(--ink);
}
.ka-src:hover {
  border-color: var(--faint);
}
.ka-src.hot {
  border-color: var(--orange);
  box-shadow: 0 0 0 2px var(--orange-soft);
}
.ka-src.active {
  background: var(--orange-soft);
  border-color: var(--orange);
}
/* "Consulted" cards read as secondary via the soft background and the grey
   number badge — NOT via opacity, which would drag their text below AA. */
.ka-src.dim {
  background: var(--bg-soft);
}
.ka-srcnum {
  font-size: 11px;
  font-weight: 600;
  color: var(--orange);
  background: var(--orange-soft);
  border-radius: 4px;
  height: 19px;
  min-width: 19px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}
.ka-src.active .ka-srcnum {
  background: var(--orange);
  color: #fff;
}
.ka-src.dim .ka-srcnum {
  background: var(--line-soft);
  color: var(--faint);
}
.ka-srcbody {
  min-width: 0;
}
.ka-srctitle {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ka-srcmeta {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 5px;
  font-size: 11px;
  color: var(--muted);
}
.ka-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 1px 6px;
  font-weight: 500;
}
.ka-badge i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  background: var(--faint);
}
.ka-badge.b-article i {
  background: var(--blue);
}
.ka-badge.b-thesis i {
  background: var(--orange);
}
.ka-badge.b-preprint i {
  background: var(--faint);
}
.ka-pdf {
  color: var(--pdf-ok);
  font-weight: 600;
  letter-spacing: 0.03em;
}

/* ── knowledge map ──────────────────────────────────────── */
.ka-mapsec {
  margin-top: 46px;
  border-top: 1px solid var(--line);
  padding-top: 26px;
}
/* The map head is two lines: (1) the "Knowledge maps" h2 in the homepage's
   section-label style (.ee-grouplabel, static/shared/grouplabel.css — small
   uppercase AA orange + a 1px rule to the right) with "Open in Visual search"
   at the right end after the rule; (2) the view switcher on the left and the
   Map / List toggle on the right (they wrap on narrow screens). */
.ka-maphead {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ka-maptitle {
  display: flex;
  align-items: center;
  gap: 14px;
}
.ka-maptitle h2.ee-grouplabel {
  flex: 1;
  margin: 0;
  font-family: var(--sans);
}
.ka-maphead h3 {
  font-size: 16px;
  margin: 0;
  color: var(--ink);
  font-family: var(--sans);
}
.ka-maptitle-vs {
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
}
.ka-mapbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 14px;
}
/* ── map view switcher (segmented tablist; shares a line with the Map /
   List toggle, wrapping under it when narrow) ── */
.ka-mapviews {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-soft);
  padding: 2px;
  gap: 2px;
  font-family: var(--sans);
}
.ka-mapviews [role="tab"] {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}
.ka-mapviews [role="tab"]:hover {
  color: var(--ink);
}
.ka-mapviews [role="tab"][aria-selected="true"] {
  background: var(--slate);
  color: #fff;
  font-weight: 600;
}
.ka-mapviews [role="tab"]:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
.ka-root.hc .ka-mapviews [role="tab"][aria-selected="true"] {
  background: var(--ink);
}
@media (max-width: 480px) {
  /* Phone width: the three tabs don't fit on one line — wrap inside the
     group (a softer corner suits two rows) and let each stretch. */
  .ka-mapviews {
    flex-wrap: wrap;
    border-radius: 14px;
    max-width: 100%;
  }
  .ka-mapviews [role="tab"] {
    flex: 1 1 auto;
    text-align: center;
    border-radius: 10px;
  }
}
/* The map row: the map, then the inspector (~340px) on its right; under
   900px the inspector stacks below the map. The map keeps its 430px height
   and is fitted to the wider column (knowledge-map.js fitCapped). */
.ka-maprow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 24px;
  align-items: start;
  margin-top: 14px;
}
.ka-mapcol {
  min-width: 0;
}
@media (max-width: 900px) {
  .ka-maprow {
    grid-template-columns: 1fr;
  }
}
.ka-cywrap {
  position: relative;
}
/* The tabpanel is the arrow-key panning target (Map mode): its ring. */
.ka-cywrap:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  border-radius: 10px;
}
/* The canvas stage (both canvases + the zoom buttons + the note) — the note
   is positioned against it, so it stays over the canvas's bottom edge with
   the list fold-out sitting below. */
.ka-mapstage {
  position: relative;
}
.ka-canvas {
  position: relative;
}
.ka-cy {
  height: 430px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-soft);
}
.ka-cy.is-loading {
  opacity: 0.55;
  transition: opacity 0.2s;
}
/* ── Map / List + the single-pointer zoom controls (a11y part 3) ── */
.ka-mapmode {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-soft);
  padding: 2px;
  gap: 2px;
  font-family: var(--sans);
}
.ka-mapmode button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1;
  padding: 6px 12px;
  min-height: 24px;
  border-radius: 999px;
  cursor: pointer;
}
.ka-mapmode button:hover {
  color: var(--ink);
}
.ka-mapmode button[aria-pressed="true"] {
  background: var(--slate);
  color: #fff;
  font-weight: 600;
}
.ka-root.hc .ka-mapmode button[aria-pressed="true"] {
  background: var(--ink);
}
/* Zoom in / Zoom out / Fit over the canvas's top-right corner (≥ 24px). */
.ka-mapzoom {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ka-mapzoom button {
  appearance: none;
  width: 30px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--control-border);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font: 600 15px/1 var(--sans);
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(30, 41, 59, 0.08);
}
.ka-mapzoom #ka-zoom-fit {
  font-size: 11px;
}
.ka-mapzoom button:hover {
  background: var(--bg-soft);
}
/* The list alternative: a closed fold-out under the canvas (Map), the whole
   view (List: the canvas is hidden, the summary too, the list unclipped). */
.ka-maplist-d {
  margin-top: 10px;
  font-family: var(--sans);
  font-size: 13.5px;
  color: var(--ink);
}
.ka-maplist-d > summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.2;
  min-height: 24px; /* 2.5.8 target size */
  padding: 5px 0;
  box-sizing: border-box;
  width: fit-content;
}
.ka-maplist-d > summary:hover {
  color: var(--ink);
}
.ka-maplist {
  margin-top: 6px;
  max-height: 430px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 12px 14px;
}
.ka-cywrap.is-list .ka-maplist-d {
  margin-top: 0;
}
.ka-cywrap.is-list .ka-maplist-d > summary {
  display: none;
}
.ka-cywrap.is-list .ka-maplist {
  margin-top: 0;
  max-height: none;
  overflow: visible;
}
.ka-cywrap.is-list .ka-mapnote {
  position: static;
  transform: none;
  width: fit-content;
  margin: 0 auto 10px;
  pointer-events: auto;
}
.ka-ml,
.ka-ml ul,
.ka-ml ol {
  list-style: none;
  margin: 0;
  padding: 0;
}
.ka-ml > li + li {
  margin-top: 10px;
}
.ka-ml-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
}
.ka-ml-name {
  font-weight: 600;
}
.ka-ml-count,
.ka-ml-meta,
.ka-ml-rel,
.ka-ml-status,
.ka-ml-note,
.ka-ml-more {
  color: var(--muted);
  font-size: 12.5px;
}
.ka-ml-kind {
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.ka-ml-num {
  font-weight: 700;
  color: var(--orange-ink);
}
.ka-ml-link {
  color: #1c6ea3; /* AA deep blue, like the inspector's links */
  text-decoration: underline;
  text-underline-offset: 0.15em;
  /* The rows are flex, which blockifies the link: give it the 24px target
     (2.5.8) instead of the inline-text exemption it would otherwise have. */
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  min-height: 24px;
}
.ka-ml-link:hover {
  color: var(--ink);
}
.ka-ml-group > ul {
  margin: 6px 0 0 16px;
  padding-left: 10px;
  border-left: 2px solid var(--line);
}
.ka-ml-group > ul > li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  padding: 3px 4px;
  border-radius: 4px;
}
.ka-ml-more {
  font-style: italic;
}
.ka-ml-status {
  margin: 0 0 8px;
}
/* The selected node's row(s) (a canvas tap / Details). */
.ka-ml-group[aria-current="true"] > .ka-ml-row,
.ka-ml li:not(.ka-ml-group)[aria-current="true"] {
  background: var(--orange-soft);
  box-shadow: 0 0 0 4px var(--orange-soft);
  border-radius: 4px;
}
.ka-ml-details,
.ka-ml-expand {
  appearance: none;
  border: 1px solid var(--control-border);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  font: 500 12px/1 var(--sans);
  padding: 5px 10px;
  min-height: 24px;
  cursor: pointer;
}
.ka-ml-details:hover,
.ka-ml-expand:hover {
  background: var(--bg-soft);
}
.ka-ml-expand[aria-expanded="true"] {
  background: var(--slate);
  color: #fff;
  border-color: var(--slate);
}
.ka-ml-expand[aria-busy="true"] {
  opacity: 0.6;
}
.ka-root.hc .ka-ml-link {
  color: var(--blue-deep);
}
/* One-line inline note inside the map (not a toast): "not available yet",
   "ask again to refresh", "no … matched", loading. */
.ka-mapnote {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  margin: 0;
  max-width: calc(100% - 28px);
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 12.5px;
  line-height: 1.35;
  text-align: center;
  box-shadow: 0 2px 8px rgba(30, 41, 59, 0.08);
  pointer-events: none;
}
.ka-maplegend .ka-lg-cited {
  background: #fff;
  border: 1.5px solid #f78f01;
  box-sizing: border-box;
}
.ka-maplegend .ka-lg-more {
  box-sizing: border-box;
  background: #e2e8f0;
  border: 1px solid #94a3b8;
}
.ka-maplegend {
  display: flex;
  gap: 18px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
  flex-wrap: wrap;
}
.ka-maplegend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: -1px;
}

/* ── high-contrast toggle control ───────────────────────── */
.ka-a11y {
  display: flex;
  justify-content: flex-end;
  margin-left: auto;
  align-self: flex-start;
}
.ka-a11y button {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  border-radius: 6px;
  padding: 5px 11px;
  font-size: 12.5px;
  cursor: pointer;
  font-family: var(--sans);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.ka-a11y button[aria-pressed="true"] {
  border-color: var(--orange);
  color: var(--orange-ink);
  background: var(--orange-soft);
}

.ka-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  font-size: 13.5px;
  padding: 10px 18px;
  border-radius: 8px;
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
  max-width: 80vw;
  text-align: center;
  z-index: 60;
}
.ka-toast.on {
  opacity: 0.95;
}

.ka-visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

[hidden] {
  display: none !important;
}
/* Hidden #header-search-bar compatibility element in the navbar (see header.html)
   — kept in the DOM for the search-results apps, never shown. */
.ka-navsearch-compat {
  display: none !important;
}

@media (prefers-reduced-motion: reduce) {
  .ka-btn-ask::before {
    animation: none;
    background: none; /* no sheen at all; the ink label is already AA */
  }
  .ka-caret {
    animation: none;
  }
  /* The star loader holds a single calm breath — stars still, no orbit/twinkle. */
  .ka-loader * {
    animation: none !important;
  }
  .ka-loader {
    animation: kl-breath 2.4s ease-in-out infinite;
  }
}

/* ── knowledge-map inspector ("Details" panel beside the map) ─────────
   static/ka/inspector.js. The question summary before any click; a
   work / topic / note after a tap. Scrolls within the map's height on
   desktop, stacks below the map under 900px. */
.ka-inspector {
  min-width: 0;
  max-height: 430px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  padding: 14px 16px;
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink);
}
.ka-inspector:empty {
  display: none;
}
@media (max-width: 900px) {
  .ka-inspector {
    max-height: none;
  }
}
.ka-insp-kicker {
  font-size: 11px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--label);
  font-weight: 600;
  margin-bottom: 4px;
}
.ka-insp-q {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 8px;
}
.ka-insp-stats {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
}
.ka-insp-stats b {
  color: var(--ink);
}
.ka-insp-sep {
  color: var(--line);
}
.ka-insp-h {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--label);
  font-weight: 600;
  margin: 12px 0 6px;
}
.ka-insp-list,
.ka-insp-topics {
  list-style: none;
  margin: 0;
  padding: 0;
}
.ka-insp-list li,
.ka-insp-topics li {
  margin: 0 0 4px;
}
.ka-insp-pick,
.ka-insp-topic,
.ka-insp-back,
.ka-insp-show,
.ka-insp-more {
  font-family: var(--sans);
  font-size: 12.5px;
  color: var(--ink);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 4px 6px;
  cursor: pointer;
  text-align: left;
}
.ka-insp-pick {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  width: 100%;
}
.ka-insp-pick:hover,
.ka-insp-topic:hover {
  background: var(--bg-soft);
  border-color: var(--line);
}
.ka-insp-num {
  flex: none;
  font-size: 11px;
  font-weight: 600;
  color: var(--orange);
  background: var(--orange-soft);
  border-radius: 4px;
  min-width: 19px;
  height: 19px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.ka-insp-num.dim {
  color: var(--faint);
  background: var(--line-soft);
}
.ka-insp-t {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ka-insp-count {
  font-size: 11px;
  color: var(--muted);
  background: var(--line-soft);
  border-radius: 4px;
  padding: 0 5px;
  margin-left: 4px;
}
/* Inspector links/actions use the AA-safe deep blue (#1c6ea3, ≈5:1 on
   white — the shared --ee-blue-deep of the cards/homeprefs), not the brand
   --blue-deep (#2596d1, ≈3.1:1), which is reserved for headings/accents. */
.ka-insp-link {
  display: inline-block;
  margin-top: 10px;
  color: #1c6ea3;
  font-weight: 600;
  text-decoration: none;
}
.ka-insp-link:hover {
  text-decoration: underline;
}
.ka-insp-back {
  color: #1c6ea3;
  font-weight: 600;
  padding-left: 0;
  margin-bottom: 6px;
}
.ka-insp-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
}
.ka-insp-kind {
  color: var(--label);
}
.ka-insp-cite {
  font-weight: 700;
  color: var(--ink);
  background: var(--orange-soft);
  border: 1px solid var(--orange);
  border-radius: 4px;
  padding: 0 5px;
}
.ka-insp-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  margin: 6px 0 4px;
}
.ka-insp-meta {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}
.ka-inspector .ee-qi {
  margin: 8px 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-soft);
}
.ka-inspector .ee-qi-head {
  margin: 0 0 4px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--label);
  font-weight: 600;
}
.ka-inspector .ee-qi-list {
  margin: 0;
}
.ka-inspector .ee-qi-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 8px;
}
.ka-inspector .ee-qi-row dt {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin: 0;
}
.ka-inspector .ee-qi-row dd {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.ka-inspector .ee-qi-row + .ee-qi-row {
  margin-top: 4px;
}
.ka-inspector .ee-qi-value {
  font-weight: 700;
}
.ka-inspector .ee-qi-reading {
  color: var(--muted);
}
.ka-inspector .ee-qi-check {
  color: var(--pdf-ok);
  font-weight: 700;
}
.ka-insp-abs p {
  margin: 0 0 6px;
}
/* abstract snippet note (copyright) — muted on both themes (--muted darkens in .hc) */
.ka-insp-abs .ee-abstract-note {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.45;
  margin: 8px 0 0;
}
.ka-insp-abs .ee-abstract-note a {
  color: var(--blue-deep, #1c6ea3);
  text-decoration: underline;
  text-underline-offset: 0.12em;
}
.ka-insp-abs-body.is-clamped {
  display: -webkit-box;
  -webkit-line-clamp: 8;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ka-insp-more {
  color: #1c6ea3;
  font-weight: 600;
  padding-left: 0;
}
.ka-insp-chips,
.ka-insp-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.ka-insp-chip {
  display: inline-block;
  font-size: 11.5px;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: var(--bg-soft);
  text-decoration: none;
}
.ka-insp-chip:hover {
  border-color: var(--faint);
}
.ka-insp-tag-comp {
  font-weight: 600;
}
.ka-insp-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  padding: 2px 8px 2px 2px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: var(--bg-soft);
  text-decoration: none;
}
.ka-insp-tag.no-icon {
  padding-left: 8px;
}
.ka-insp-tagicon {
  width: 24px;
  height: 24px;
  display: block;
}
.ka-insp-unavail {
  color: var(--muted);
  font-style: italic;
  margin: 8px 0 0;
}
.ka-insp-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  align-items: center;
  margin-top: 6px;
}
.ka-insp-show {
  color: #1c6ea3;
  font-weight: 600;
  margin-top: 10px;
}
.ka-insp-note {
  margin: 0;
  color: var(--muted);
}
.ka-root.hc .ka-inspector {
  border-color: var(--ink);
}
