/* ==========================================================================
   Capital Workbench — documentation theme
   Brand tokens mirror the product (templates/base.html, base.css, front-end
   style guide): navy chrome, accent blue, slateSoft surfaces, Inter type.
   ========================================================================== */

:root {
  /* CW brand tokens */
  --cw-navy: #0f172a;
  --cw-navy-2: #1e293b;
  --cw-accent: #2563eb;
  --cw-accent-strong: #1d4ed8;
  --cw-accent-soft: rgba(37, 99, 235, 0.10);
  --cw-bg: #f8fafc;          /* slateSoft page background */
  --cw-surface: #ffffff;     /* cards / article surface */
  --cw-surface-2: #f1f5f9;   /* nested panels, table head */
  --cw-border: #e2e8f0;      /* slate-200 */
  --cw-border-soft: #eef2f6;
  --cw-text: #334155;        /* slate-700 body */
  --cw-heading: #0f172a;     /* navy headings */
  --cw-muted: #64748b;       /* slate-500 */
  --cw-positive: #059669;
  --cw-caution: #d97706;
  --cw-radius: 0.75rem;      /* rounded-xl */
  --cw-radius-sm: 0.5rem;
  --cw-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 12px 28px -16px rgba(15, 23, 42, 0.18);
}

/* ---- Material palette mapping (light / "default" scheme) ---------------- */
[data-md-color-scheme="default"] {
  --md-primary-fg-color: var(--cw-navy);
  --md-primary-fg-color--light: var(--cw-navy-2);
  --md-primary-fg-color--dark: #0b1220;
  --md-primary-bg-color: #ffffff;
  --md-primary-bg-color--light: rgba(255, 255, 255, 0.72);

  --md-accent-fg-color: var(--cw-accent);
  --md-accent-fg-color--transparent: var(--cw-accent-soft);

  --md-default-bg-color: var(--cw-bg);
  --md-default-fg-color: var(--cw-text);
  --md-default-fg-color--light: var(--cw-muted);
  --md-default-fg-color--lighter: #94a3b8;

  --md-typeset-color: var(--cw-text);
  --md-typeset-a-color: var(--cw-accent);
  --md-code-bg-color: #f5f7fa;
  --md-code-fg-color: #1f2937;
  --md-footer-bg-color: var(--cw-navy);
  --md-footer-bg-color--dark: #0b1220;
}

/* ---- Dark ("slate") scheme --------------------------------------------- */
[data-md-color-scheme="slate"] {
  --md-primary-fg-color: #0b1220;
  --md-primary-fg-color--light: var(--cw-navy-2);
  --md-primary-fg-color--dark: #070b14;
  --md-primary-bg-color: #f8fafc;
  --md-primary-bg-color--light: rgba(248, 250, 252, 0.72);

  --md-accent-fg-color: #60a5fa;
  --md-accent-fg-color--transparent: rgba(96, 165, 250, 0.12);

  --md-default-bg-color: #0b1120;
  --md-default-fg-color: #cbd5e1;
  --md-typeset-color: #cbd5e1;
  --md-typeset-a-color: #60a5fa;
  --md-code-bg-color: #111a2e;

  --cw-bg: #0b1120;
  --cw-surface: #0f1a30;
  --cw-surface-2: #13203a;
  --cw-border: #1e293b;
  --cw-border-soft: #1b2638;
  --cw-heading: #f1f5f9;
  --cw-text: #cbd5e1;
  --cw-muted: #94a3b8;
  --cw-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 14px 30px -18px rgba(0, 0, 0, 0.6);
}

/* ==========================================================================
   Typography
   ========================================================================== */
body,
.md-typeset {
  font-feature-settings: "kern", "liga", "cv11";
}

.md-typeset {
  font-size: 0.78rem;
  line-height: 1.72;
  color: var(--cw-text);
}

.md-typeset h1,
.md-typeset h2,
.md-typeset h3,
.md-typeset h4 {
  color: var(--cw-heading);
  font-weight: 700;
  letter-spacing: -0.012em;
}

.md-typeset h1 {
  font-size: 1.78rem;
  font-weight: 700;
  margin-bottom: 0.4em;
}

.md-typeset h2 {
  font-size: 1.28rem;
  margin-top: 2.2em;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--cw-border);
}

.md-typeset h3 {
  font-size: 1.02rem;
  margin-top: 1.6em;
}

.md-typeset h2 + h3 {
  margin-top: 1em;
}

/* Tighter, brand-tinted code */
.md-typeset code {
  border-radius: 0.3rem;
  font-size: 0.84em;
}

/* Links: solid accent, underline on hover only */
.md-typeset a {
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 120ms ease, border-color 120ms ease;
}
.md-typeset a:hover {
  color: var(--cw-accent-strong);
  border-bottom-color: currentColor;
}

/* ==========================================================================
   Header / navigation chrome
   ========================================================================== */
.md-header {
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.06), 0 4px 18px -12px rgba(15, 23, 42, 0.5);
}

.md-header__title {
  font-weight: 600;
  letter-spacing: 0.01em;
}

.md-header__topic .md-ellipsis {
  font-weight: 600;
}

/* Sticky tabs read like a product top-nav */
.md-tabs {
  background: var(--md-primary-fg-color--dark);
}
.md-tabs__link {
  opacity: 0.78;
  font-weight: 500;
  font-size: 0.72rem;
}
.md-tabs__link:hover,
.md-tabs__link--active {
  opacity: 1;
}
.md-tabs__item--active .md-tabs__link {
  font-weight: 600;
}

/* Push the last top-level nav entry ("Return to CW") to the right edge */
.md-tabs__list {
  width: 100%;
}
.md-tabs__item:last-child {
  margin-left: auto;
}
.md-tabs__item:last-child .md-tabs__link {
  opacity: 1;
  font-weight: 600;
}
.md-tabs__item:last-child .md-tabs__link::after {
  content: " \2197"; /* ↗ */
  font-weight: 400;
}

/* Search bar: rounded, product-like */
.md-search__form {
  border-radius: 0.6rem;
  background: rgba(255, 255, 255, 0.12);
}
.md-search__form:hover {
  background: rgba(255, 255, 255, 0.2);
}
[data-md-toggle="search"]:checked ~ .md-header .md-search__form {
  border-radius: 0.6rem;
}

/* Active sidebar links in CW accent */
.md-nav__link--active,
.md-nav__item .md-nav__link--active {
  color: var(--cw-accent);
  font-weight: 600;
}
.md-nav__link:hover {
  color: var(--cw-accent);
}

/* Section labels in the sidebar: small-caps, muted (matches app) */
.md-nav__item--section > .md-nav__link,
label.md-nav__title {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--cw-muted);
}

/* TOC active marker */
.md-nav__link--active {
  border-left: none;
}

/* ==========================================================================
   Content surface — article as a dashboard card on a soft background
   ========================================================================== */
.md-main {
  background: var(--cw-bg);
}

.md-content {
  background: var(--cw-surface);
  border: 1px solid var(--cw-border);
  border-radius: var(--cw-radius);
  box-shadow: var(--cw-shadow);
  margin: 1.2rem 0.6rem;
}

@media screen and (min-width: 76.25em) {
  .md-content {
    margin: 1.4rem 1.1rem;
  }
}

.md-content__inner {
  padding: 0 1.4rem 1.6rem;
  margin-top: 0;
}
.md-content__inner::before {
  height: 1.2rem;
}

/* The per-page "Audience · Version · Updated" line (rendered from _italic_) */
.md-content__inner > p:first-of-type em:only-child {
  display: inline-block;
  font-style: normal;
  font-size: 0.66rem;
  letter-spacing: 0.04em;
  color: var(--cw-muted);
  background: var(--cw-surface-2);
  border: 1px solid var(--cw-border);
  border-radius: 999px;
  padding: 0.18rem 0.7rem;
}

/* ==========================================================================
   Tables — institutional, readable, tabular numerals
   ========================================================================== */
.md-typeset__table {
  width: 100%;
}
.md-typeset table:not([class]) {
  border: 1px solid var(--cw-border);
  border-radius: var(--cw-radius-sm);
  overflow: hidden;
  font-size: 0.74rem;
  box-shadow: none;
}
.md-typeset table:not([class]) th {
  background: var(--cw-surface-2);
  color: var(--cw-heading);
  font-weight: 700;
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--cw-border);
  padding: 0.6rem 0.9rem;
  white-space: nowrap;
}
.md-typeset table:not([class]) td {
  padding: 0.55rem 0.9rem;
  border-top: 1px solid var(--cw-border-soft);
  vertical-align: top;
}
/* Zebra striping */
.md-typeset table:not([class]) tbody tr:nth-child(even) {
  background: rgba(148, 163, 184, 0.06);
}
.md-typeset table:not([class]) tbody tr:hover {
  background: var(--cw-accent-soft);
}
/* Tabular numerals + right-align numeric columns */
.md-typeset table:not([class]) td[align="right"],
.md-typeset table:not([class]) th[align="right"] {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}
/* Sortable header affordance */
.md-typeset table:not([class]) th[role="columnheader"] {
  cursor: pointer;
}

/* ==========================================================================
   Admonitions — CW product-card callouts
   ========================================================================== */
.md-typeset .admonition,
.md-typeset details {
  border-radius: var(--cw-radius-sm);
  border-width: 1px;
  border-left-width: 3px;
  box-shadow: none;
  font-size: 0.74rem;
}
.md-typeset .admonition-title,
.md-typeset summary {
  font-weight: 700;
  letter-spacing: 0.01em;
}

/* Custom CW callout types (use:  !!! cw-insight "Insight")
   --------------------------------------------------------- */
:root {
  --md-admonition-icon--cw-insight: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="currentColor" d="M12 2a7 7 0 0 0-4 12.74V17a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1v-2.26A7 7 0 0 0 12 2m-3 19a1 1 0 0 0 1 1h4a1 1 0 0 0 1-1v-1H9z"/></svg>');
  --md-admonition-icon--cw-limitation: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="currentColor" d="M12 2 1 21h22zm0 4 7.5 13h-15zM11 10v4h2v-4zm0 6v2h2v-2z"/></svg>');
  --md-admonition-icon--cw-source: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="currentColor" d="M4 4h16v4H4zm0 6h16v4H4zm0 6h10v4H4z"/></svg>');
  --md-admonition-icon--cw-analyst: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="currentColor" d="M3 13h4v8H3zm7-6h4v14h-4zm7-4h4v18h-4z"/></svg>');
}

/* Insight — accent blue */
.md-typeset .admonition.cw-insight,
.md-typeset details.cw-insight {
  border-color: var(--cw-accent);
}
.md-typeset .cw-insight > .admonition-title,
.md-typeset .cw-insight > summary {
  background: var(--cw-accent-soft);
}
.md-typeset .cw-insight > .admonition-title::before,
.md-typeset .cw-insight > summary::before {
  background-color: var(--cw-accent);
  -webkit-mask-image: var(--md-admonition-icon--cw-insight);
          mask-image: var(--md-admonition-icon--cw-insight);
}

/* Limitation — caution amber */
.md-typeset .admonition.cw-limitation,
.md-typeset details.cw-limitation {
  border-color: var(--cw-caution);
}
.md-typeset .cw-limitation > .admonition-title,
.md-typeset .cw-limitation > summary {
  background: rgba(217, 119, 6, 0.10);
}
.md-typeset .cw-limitation > .admonition-title::before,
.md-typeset .cw-limitation > summary::before {
  background-color: var(--cw-caution);
  -webkit-mask-image: var(--md-admonition-icon--cw-limitation);
          mask-image: var(--md-admonition-icon--cw-limitation);
}

/* Data source — slate/navy */
.md-typeset .admonition.cw-source,
.md-typeset details.cw-source {
  border-color: #94a3b8;
}
.md-typeset .cw-source > .admonition-title,
.md-typeset .cw-source > summary {
  background: var(--cw-surface-2);
}
.md-typeset .cw-source > .admonition-title::before,
.md-typeset .cw-source > summary::before {
  background-color: #475569;
  -webkit-mask-image: var(--md-admonition-icon--cw-source);
          mask-image: var(--md-admonition-icon--cw-source);
}

/* Analyst note — positive emerald */
.md-typeset .admonition.cw-analyst,
.md-typeset details.cw-analyst {
  border-color: var(--cw-positive);
}
.md-typeset .cw-analyst > .admonition-title,
.md-typeset .cw-analyst > summary {
  background: rgba(5, 150, 105, 0.10);
}
.md-typeset .cw-analyst > .admonition-title::before,
.md-typeset .cw-analyst > summary::before {
  background-color: var(--cw-positive);
  -webkit-mask-image: var(--md-admonition-icon--cw-analyst);
          mask-image: var(--md-admonition-icon--cw-analyst);
}

/* ==========================================================================
   Grid cards (homepage)
   ========================================================================== */
.md-typeset .grid.cards > ul > li,
.md-typeset .grid > .card {
  border: 1px solid var(--cw-border);
  border-radius: var(--cw-radius);
  background: var(--cw-surface);
  box-shadow: var(--cw-shadow);
  padding: 1rem 1.1rem;
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}
.md-typeset .grid.cards > ul > li:hover,
.md-typeset .grid > .card:hover {
  transform: translateY(-2px);
  border-color: var(--cw-accent);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.06), 0 18px 36px -20px rgba(37, 99, 235, 0.45);
}
.md-typeset .grid.cards > ul > li > p:first-child > strong {
  color: var(--cw-heading);
  font-size: 0.92rem;
}

/* ==========================================================================
   Hero (homepage banner)
   ========================================================================== */
.cw-hero {
  margin: 0 0 1.6rem;
  padding: 1.6rem 1.7rem;
  border-radius: var(--cw-radius);
  border: 1px solid var(--cw-border);
  background:
    radial-gradient(120% 140% at 100% 0%, rgba(37, 99, 235, 0.14), transparent 55%),
    linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  color: #e2e8f0;
}
.cw-hero h1,
.md-typeset .cw-hero h1 {
  color: #ffffff;
  margin: 0 0 0.4rem;
  font-size: 1.7rem;
}
.cw-hero p {
  color: #cbd5e1;
  max-width: 46rem;
  margin: 0;
}
.cw-hero .cw-eyebrow {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: #93c5fd;
  margin-bottom: 0.55rem;
}

/* ==========================================================================
   Footer
   ========================================================================== */
.md-footer-meta {
  background: var(--md-footer-bg-color--dark);
}

/* Buttons (.md-button) tuned to CW accent */
.md-typeset .md-button {
  border-radius: var(--cw-radius-sm);
  border-width: 1px;
  font-weight: 600;
}
.md-typeset .md-button--primary {
  background: var(--cw-accent);
  border-color: var(--cw-accent);
  color: #fff;
}
.md-typeset .md-button--primary:hover {
  background: var(--cw-accent-strong);
  border-color: var(--cw-accent-strong);
}

/* Images / screenshots */
.md-typeset img {
  border-radius: var(--cw-radius-sm);
}
.md-typeset figure img,
.md-typeset img.cw-shot {
  border: 1px solid var(--cw-border);
  box-shadow: var(--cw-shadow);
}
.md-typeset figcaption {
  color: var(--cw-muted);
  font-size: 0.7rem;
}
