/* CMS Cloud KB — site styling layered on CMS Design System tokens. */

:root {
  --kb-sidebar-w: 16rem;
  --kb-toc-w: 14rem;
  --kb-maxw: 90rem;
  --kb-ink: var(--color-base, #262626);
  --kb-navy: var(--color-primary-darkest, #07124d);
  --kb-navy-2: var(--color-primary-darker, #09196b);
  --kb-blue: var(--color-primary, #0d2499);
  --cms-blue: #015390;            /* official CMS brand blue (Graphic Standards) */
  --kb-line: var(--color-border, #d9d9d9);
  --kb-muted: #5a5a5a;
  --kb-bg-soft: #f4f6fb;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body.ds-base {
  margin: 0;
  color: var(--kb-ink);
  background: #fff;
  font-family: var(--font-family-body), system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--kb-blue); }

/* The CMS DS sets a global `a:visited` color (specificity 0,1,1); these keep our
   chrome/link colors stable after a page has been visited. */
.kb-masthead a, .kb-masthead a:visited, .kb-brand, .kb-brand:visited,
.kb-masthead__okf, .kb-masthead__okf:visited,
.kb-footer a, .kb-footer a:visited { color: #fff; }
.kb-card, .kb-card:visited { color: var(--kb-ink); }
.kb-doclist__link, .kb-doclist__link:visited { color: var(--kb-navy); }
.kb-breadcrumb a, .kb-breadcrumb a:visited { color: var(--kb-blue); }
.kb-toc a, .kb-toc a:visited { color: var(--kb-muted); }
.kb-masthead .kb-search__hit, .kb-masthead .kb-search__hit:visited,
.kb-search__hit, .kb-search__hit:visited,
.kb-search-card, .kb-search-card:visited { color: var(--kb-ink); }
.kb-nav .ds-c-vertical-nav__label, .kb-nav .ds-c-vertical-nav__label:visited { color: var(--kb-ink); }
.kb-content a:visited { color: var(--kb-blue); }

.ds-l-container { max-width: var(--kb-maxw); }

/* ---------- Masthead ---------- */
.kb-masthead {
  position: sticky; top: 0; z-index: 50;
  background: var(--kb-navy);
  color: #fff;
  border-bottom: 3px solid var(--kb-blue);
}
.kb-masthead__inner {
  display: flex; align-items: center; gap: 1.25rem;
  padding: 0.65rem 1.5rem; min-height: 4rem;
}
.kb-brand { display: flex; align-items: center; gap: 0.75rem; color: #fff; text-decoration: none; flex: 0 0 auto; }
.kb-brand__logo { display: block; height: 1.85rem; width: auto; flex: 0 0 auto; }
.kb-brand__text {
  display: flex; flex-direction: column; line-height: 1.15;
  padding-left: 0.85rem; margin-left: 0.1rem;
  border-left: 1px solid rgba(255,255,255,0.28);
}
.kb-brand__title { font-weight: 700; font-size: 1.05rem; font-family: var(--font-family-heading), sans-serif; }
.kb-brand__sub { font-size: 0.7rem; opacity: 0.8; }
.kb-masthead__okf {
  flex: 0 0 auto; color: #fff; text-decoration: none;
  border: 1px solid rgba(255,255,255,0.45); border-radius: 4px;
  padding: 0.4rem 0.75rem; font-size: 0.85rem; font-weight: 600;
}
.kb-masthead__okf:hover { background: rgba(255,255,255,0.12); }

/* ---------- Header search ---------- */
.kb-search { position: relative; flex: 1 1 auto; max-width: 34rem; margin: 0 auto; }
.kb-search__input {
  width: 100%; border: 1px solid transparent; border-radius: 6px;
  padding: 0.55rem 0.9rem; font-size: 0.95rem; background: #fff; color: var(--kb-ink);
}
.kb-search__input:focus { outline: 3px solid var(--cms-blue); outline-offset: 1px; }
.kb-search__results {
  position: absolute; top: calc(100% + 0.4rem); left: 0; right: 0;
  background: #fff; color: var(--kb-ink);
  border: 1px solid var(--kb-line); border-radius: 8px;
  box-shadow: 0 12px 32px rgba(7,18,77,0.18);
  max-height: 70vh; overflow: auto; z-index: 60;
}
.kb-search__hit { display: block; padding: 0.6rem 0.9rem; text-decoration: none; color: var(--kb-ink); border-bottom: 1px solid #eef0f6; }
.kb-search__hit:last-child { border-bottom: 0; }
.kb-search__hit:hover, .kb-search__hit.is-active { background: var(--kb-bg-soft); }
.kb-search__hit b { color: var(--kb-blue); }
.kb-search__hit-title { font-weight: 600; display: block; color: var(--kb-navy); }
.kb-search__hit-meta { font-size: 0.75rem; color: var(--kb-muted); }
.kb-search__empty { padding: 0.8rem 0.9rem; color: var(--kb-muted); }

/* ---------- Shell / layout ---------- */
.kb-shell {
  display: grid;
  grid-template-columns: var(--kb-sidebar-w) minmax(0, 1fr);
  gap: 2.5rem;
  padding: 2rem 1.5rem 4rem;
  align-items: start;
}
.kb-main { min-width: 0; }

/* ---------- Sidebar nav ---------- */
.kb-sidebar { position: sticky; top: 5.25rem; max-height: calc(100vh - 6.5rem); overflow-y: auto; padding-right: 0.5rem; }
.kb-sidebar__title {
  text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.72rem;
  font-weight: 700; color: var(--kb-muted); margin: 0 0 0.5rem 0.25rem;
}
.kb-sidebar__title--sub { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--kb-line); }
.kb-nav { list-style: none; margin: 0; padding: 0; }
.kb-nav .ds-c-vertical-nav__label { display: flex; gap: 0.5rem; align-items: baseline; font-size: 0.9rem; }
.kb-nav-num { font-variant-numeric: tabular-nums; color: var(--kb-muted); font-size: 0.78rem; font-weight: 600; }
.kb-nav-section.is-active > .ds-c-vertical-nav__label { color: var(--kb-blue); font-weight: 700; }
.kb-nav-section.is-active { border-left: 3px solid var(--kb-blue); background: var(--kb-bg-soft); border-radius: 0 6px 6px 0; }
.kb-nav .ds-c-vertical-nav__subnav .ds-c-vertical-nav__label { font-size: 0.84rem; padding-left: 1.75rem; }
.ds-c-vertical-nav__label--current { color: var(--kb-blue) !important; font-weight: 700; background: rgba(13,36,153,0.08); border-radius: 4px; }

/* ---------- Hero (home) ---------- */
.kb-hero {
  background: linear-gradient(135deg, var(--kb-navy) 0%, var(--kb-blue) 100%);
  color: #fff; border-radius: 14px; padding: 2.75rem 2.5rem; margin-bottom: 2.5rem;
}
.kb-hero__eyebrow { text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.75rem; opacity: 0.85; margin: 0 0 0.5rem; }
.kb-hero__title { font-family: var(--font-family-heading), sans-serif; font-size: clamp(1.8rem, 4vw, 2.75rem); margin: 0 0 0.75rem; line-height: 1.1; }
.kb-hero__lede { font-size: 1.1rem; max-width: 48rem; opacity: 0.95; margin: 0 0 0.75rem; }
.kb-hero__stats { font-size: 0.9rem; opacity: 0.85; margin: 0 0 1.5rem; }
.kb-hero__actions { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.kb-hero__cta.ds-c-button { background: #fff; color: var(--kb-navy); border-color: #fff; }
.kb-hero .ds-c-button--ghost { color: #fff; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.7); }

.kb-section-h { font-family: var(--font-family-heading), sans-serif; font-size: 1.4rem; margin: 0 0 1.25rem; }

/* ---------- Card grid (home) ---------- */
.kb-card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 1rem; }
.kb-card {
  display: flex; flex-direction: column; gap: 0.4rem;
  border: 1px solid var(--kb-line); border-radius: 10px; padding: 1.1rem 1.2rem;
  text-decoration: none; color: var(--kb-ink); background: #fff;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.kb-card:hover { border-color: var(--kb-blue); box-shadow: 0 8px 22px rgba(7,18,77,0.1); transform: translateY(-2px); }
.kb-card__num { font-size: 0.72rem; font-weight: 700; color: var(--kb-blue); letter-spacing: 0.05em; }
.kb-card__title { font-weight: 700; font-size: 1.02rem; font-family: var(--font-family-heading), sans-serif; }
.kb-card__desc { font-size: 0.85rem; color: var(--kb-muted); flex: 1; }
.kb-card__meta { font-size: 0.75rem; color: var(--kb-blue); font-weight: 600; }

/* ---------- Breadcrumb / page head ---------- */
.kb-breadcrumb { font-size: 0.82rem; color: var(--kb-muted); margin-bottom: 1rem; }
.kb-breadcrumb a { color: var(--kb-blue); text-decoration: none; }
.kb-breadcrumb a:hover { text-decoration: underline; }
.kb-page-head { margin-bottom: 1.5rem; }
.kb-page-head h1 { font-family: var(--font-family-heading), sans-serif; font-size: clamp(1.5rem, 3vw, 2.1rem); line-height: 1.15; margin: 0.35rem 0 0.5rem; }
.kb-page-head__eyebrow { text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.72rem; font-weight: 700; color: var(--kb-blue); margin: 0; }
.kb-page-head__lede { font-size: 1.08rem; color: #333; max-width: 52rem; margin: 0.25rem 0; }
.kb-page-head__meta { font-size: 0.8rem; color: var(--kb-muted); margin: 0.5rem 0 0; }
.kb-page-head__badges { display: flex; gap: 0.4rem; margin-bottom: 0.25rem; }
.kb-badge { text-transform: lowercase; font-variant: small-caps; letter-spacing: 0.02em; }

/* ---------- Doc list (section page) ---------- */
.kb-doclist { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.6rem; }
.kb-doclist__item { border: 1px solid var(--kb-line); border-radius: 10px; padding: 1rem 1.15rem; }
.kb-doclist__item:hover { border-color: var(--kb-blue); }
.kb-doclist__link { font-weight: 700; font-size: 1.05rem; text-decoration: none; color: var(--kb-navy); margin-right: 0.5rem; }
.kb-doclist__link:hover { color: var(--kb-blue); text-decoration: underline; }
.kb-doclist__desc { margin: 0.4rem 0 0; color: var(--kb-muted); font-size: 0.9rem; }

/* ---------- Doc article + TOC ---------- */
.kb-doc-layout { display: grid; grid-template-columns: minmax(0,1fr) var(--kb-toc-w); gap: 2.5rem; align-items: start; }
.kb-article { min-width: 0; }
.kb-toc { position: sticky; top: 5.25rem; font-size: 0.85rem; border-left: 2px solid var(--kb-line); padding-left: 1rem; }
.kb-toc__title { text-transform: uppercase; letter-spacing: 0.07em; font-size: 0.7rem; font-weight: 700; color: var(--kb-muted); margin: 0 0 0.5rem; }
.kb-toc ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.35rem; }
.kb-toc a { color: var(--kb-muted); text-decoration: none; }
.kb-toc a:hover, .kb-toc a.is-active { color: var(--kb-blue); }

/* ---------- Content typography ---------- */
.kb-content { font-size: 1rem; line-height: 1.7; color: #1f1f1f; max-width: 52rem; }
.kb-content > *:first-child { margin-top: 0; }
.kb-content h2 { font-family: var(--font-family-heading), sans-serif; font-size: 1.5rem; margin: 2.25rem 0 0.75rem; padding-top: 0.5rem; border-top: 1px solid #eef0f6; }
.kb-content h3 { font-family: var(--font-family-heading), sans-serif; font-size: 1.2rem; margin: 1.75rem 0 0.5rem; }
.kb-content h4 { font-size: 1.02rem; margin: 1.35rem 0 0.4rem; }
.kb-content p { margin: 0.75rem 0; }
.kb-content ul, .kb-content ol { padding-left: 1.4rem; margin: 0.75rem 0; }
.kb-content li { margin: 0.3rem 0; }
.kb-content a { color: var(--kb-blue); }
.kb-content code { background: var(--kb-bg-soft); padding: 0.12em 0.4em; border-radius: 4px; font-size: 0.88em; font-family: var(--font-family-monospace), Menlo, Consolas, monospace; }
.kb-content pre { background: #0d1733; color: #e8ecff; padding: 1rem 1.15rem; border-radius: 10px; overflow-x: auto; font-size: 0.85rem; line-height: 1.55; }
.kb-content pre code { background: transparent; padding: 0; color: inherit; }
/* Mermaid render targets: not code blocks. Hide the raw source until mermaid swaps in the SVG. */
.kb-content pre.kb-mermaid { background: #fff; color: inherit; margin: 1.5rem 0; padding: 1.5rem; border: 1px solid var(--kb-line); border-radius: 12px; box-shadow: 0 4px 18px rgba(7,18,77,0.06); text-align: center; line-height: normal; overflow-x: auto; }
.kb-content pre.kb-mermaid:not([data-processed]) { visibility: hidden; }
.kb-content pre.kb-mermaid svg { max-width: 100%; height: auto; }
.kb-content blockquote { margin: 1rem 0; padding: 0.5rem 1rem; border-left: 4px solid var(--kb-blue); background: var(--kb-bg-soft); color: #333; border-radius: 0 6px 6px 0; }
.kb-content img { max-width: 100%; height: auto; border-radius: 6px; }
.kb-heading { position: relative; }
.kb-anchor { position: absolute; left: -1.1rem; opacity: 0; text-decoration: none; color: var(--kb-line); font-weight: 400; }
.kb-heading:hover .kb-anchor { opacity: 1; }
.kb-extlink::after { content: "↗"; font-size: 0.75em; margin-left: 0.15em; opacity: 0.6; }

/* Tables */
.kb-table-scroll { overflow-x: auto; margin: 1.25rem 0; }
.kb-content table { font-size: 0.9rem; }

/* Tags */
.kb-tags { margin-top: 2rem; display: flex; flex-wrap: wrap; gap: 0.4rem; padding-top: 1rem; border-top: 1px solid #eef0f6; }
.kb-tag { font-size: 0.75rem; background: var(--kb-bg-soft); color: var(--kb-navy-2); padding: 0.2rem 0.6rem; border-radius: 999px; border: 1px solid #e2e6f2; }

/* ---------- Search page ---------- */
.kb-search--page { max-width: none; margin: 0 0 1.5rem; }
.kb-search--page .kb-search__input { border: 1px solid var(--kb-line); }
.kb-search-page-results { display: grid; gap: 0.75rem; }
.kb-search-card { border: 1px solid var(--kb-line); border-radius: 10px; padding: 1rem 1.15rem; text-decoration: none; color: var(--kb-ink); display: block; }
.kb-search-card:hover { border-color: var(--kb-blue); }
.kb-search-card h3 { margin: 0 0 0.25rem; font-size: 1.05rem; color: var(--kb-navy); }
.kb-search-card p { margin: 0.25rem 0 0; color: var(--kb-muted); font-size: 0.88rem; }
.kb-search-card b { color: var(--kb-blue); }

/* ---------- OKF score ---------- */
.kb-score { display: flex; align-items: center; gap: 2rem; flex-wrap: wrap; background: var(--kb-bg-soft); border: 1px solid var(--kb-line); border-radius: 12px; padding: 1.5rem 2rem; margin: 1.5rem 0; }
.kb-score__big { font-size: 3rem; font-weight: 800; color: var(--kb-navy); font-family: var(--font-family-heading), sans-serif; }
.kb-score__big span { font-size: 1.2rem; color: var(--kb-muted); font-weight: 600; }
.kb-score__dims { display: flex; gap: 1.5rem; }
.kb-score__dims div { display: flex; flex-direction: column; }
.kb-score__dims span { font-size: 0.75rem; color: var(--kb-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.kb-score__dims strong { font-size: 1.5rem; color: var(--kb-blue); }

/* ---------- Footer ---------- */
.kb-footer { background: var(--kb-navy); color: #cdd5f3; margin-top: 4rem; padding: 2.5rem 1.5rem; }
.kb-footer a { color: #fff; text-decoration: none; }
.kb-footer a:hover { text-decoration: underline; }
.kb-footer__grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 2rem; }
.kb-footer__title { font-weight: 700; font-size: 1.1rem; color: #fff; margin: 0 0 0.5rem; font-family: var(--font-family-heading), sans-serif; }
.kb-footer__muted { font-size: 0.85rem; opacity: 0.8; margin: 0; max-width: 30rem; }
.kb-footer__h { text-transform: uppercase; letter-spacing: 0.07em; font-size: 0.72rem; color: #9fb0e8; margin: 0 0 0.6rem; }
.kb-footer__links { display: flex; flex-direction: column; gap: 0.4rem; font-size: 0.9rem; }
.kb-footer__colophon { margin: 2rem 0 0; padding-top: 1.5rem; border-top: 1px solid rgba(255,255,255,0.15); font-size: 0.82rem; opacity: 0.8; }
.kb-footer__colophon a { text-decoration: underline; }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .kb-shell { grid-template-columns: 1fr; }
  .kb-sidebar { position: static; max-height: none; order: 2; border-top: 1px solid var(--kb-line); margin-top: 2rem; padding-top: 1.5rem; }
  .kb-doc-layout { grid-template-columns: 1fr; }
  .kb-toc { display: none; }
}
@media (max-width: 768px) {
  .kb-masthead__inner { flex-wrap: wrap; min-height: 0; gap: 0.75rem; }
  .kb-search { order: 3; flex-basis: 100%; max-width: none; margin: 0; }
  .kb-footer__grid { grid-template-columns: 1fr; }
}
