/*
  Residion docs — light monochrome design system.
  Tokens: content-source/brand-tokens.md
  Emphasis by inversion. No accent hue. Status without colour.
  Layout / type / spacing are first-class — not a Material palette swap.
*/

:root,
[data-md-color-scheme="residion"],
[data-md-color-scheme="default"] {
  /* ── Brand colour tokens ───────────────────────────────────────── */
  --res-shell: #ffffff;
  --res-ink: #1a1a1a;
  --res-secondary: #6e6e6e;
  --res-tertiary: #bfbfbf;
  --res-hairline: #dadada;
  --res-tint: #f4f4f4;

  /* ── Type scale ────────────────────────────────────────────────── */
  --res-font-sans: "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --res-font-mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;

  --res-text-xs: 0.75rem;    /* 12px — captions, meta */
  --res-text-sm: 0.875rem;   /* 14px — nav, secondary */
  --res-text-base: 1.0625rem;/* 17px — body reading size */
  --res-text-lg: 1.25rem;    /* 20px — h3 / lead */
  --res-text-xl: 1.5rem;     /* 24px — h2 */
  --res-text-2xl: 2rem;      /* 32px — page h1 */
  --res-text-3xl: 2.75rem;   /* 44px — landing hero */

  --res-leading-tight: 1.2;
  --res-leading-snug: 1.35;
  --res-leading-body: 1.65;

  --res-tracking-tight: -0.02em;
  --res-tracking-display: -0.03em;

  /* ── Spacing scale (4px base) ──────────────────────────────────── */
  --res-space-1: 0.25rem;  /*  4 */
  --res-space-2: 0.5rem;   /*  8 */
  --res-space-3: 0.75rem;  /* 12 */
  --res-space-4: 1rem;     /* 16 */
  --res-space-5: 1.5rem;   /* 24 */
  --res-space-6: 2rem;     /* 32 */
  --res-space-7: 3rem;     /* 48 */
  --res-space-8: 4rem;     /* 64 */
  --res-space-9: 5rem;     /* 80 */

  --res-measure: 72ch;
  --res-content-max: 52rem;
  --res-header-height: 3.5rem;
  --res-search-max: 22rem;

  /* ── Material colour mappings (monochrome only) ────────────────── */
  --md-primary-fg-color: var(--res-ink);
  --md-primary-fg-color--light: #333333;
  --md-primary-fg-color--dark: #000000;
  --md-primary-bg-color: var(--res-shell);
  --md-primary-bg-color--light: var(--res-tint);

  --md-accent-fg-color: var(--res-ink);
  --md-accent-fg-color--transparent: rgba(26, 26, 26, 0.06);
  --md-accent-bg-color: var(--res-shell);

  --md-default-fg-color: var(--res-ink);
  --md-default-fg-color--light: var(--res-secondary);
  --md-default-fg-color--lighter: var(--res-tertiary);
  --md-default-fg-color--lightest: var(--res-hairline);
  --md-default-bg-color: var(--res-shell);
  --md-default-bg-color--light: var(--res-tint);
  --md-default-bg-color--lighter: var(--res-tint);
  --md-default-bg-color--lightest: var(--res-shell);

  --md-code-fg-color: var(--res-ink);
  --md-code-bg-color: var(--res-tint);

  --md-typeset-a-color: var(--res-ink);
  --md-typeset-color: var(--res-ink);
  --md-typeset-table-color: var(--res-hairline);
  --md-typeset-table-color--light: transparent;

  --md-footer-fg-color: var(--res-ink);
  --md-footer-fg-color--light: var(--res-secondary);
  --md-footer-fg-color--lighter: var(--res-tertiary);
  --md-footer-bg-color: var(--res-shell);
  --md-footer-bg-color--dark: var(--res-shell);

  --md-shadow-z1: none;
  --md-shadow-z2: none;
  --md-shadow-z3: none;

  --md-typeset-font-size: var(--res-text-base);
}

/* ═══════════════════════════════════════════════════════════════════
   Base
   ═══════════════════════════════════════════════════════════════════ */

html {
  font-size: 16px;
}

body {
  background: var(--res-shell);
  color: var(--res-ink);
  font-family: var(--res-font-sans);
  -webkit-font-smoothing: antialiased;
}

.md-typeset {
  font-family: var(--res-font-sans);
  font-size: var(--res-text-base);
  line-height: var(--res-leading-body);
  color: var(--res-ink);
}

.md-typeset > :first-child {
  margin-top: 0;
}

/* Content measure — long pages stay readable */
.md-content__inner {
  max-width: var(--res-content-max);
  margin-top: var(--res-space-6);
  margin-bottom: var(--res-space-8);
}

.md-typeset p,
.md-typeset li,
.md-typeset dd {
  max-width: var(--res-measure);
}

.md-grid {
  max-width: 72rem;
}

/* ── Heading ramp ────────────────────────────────────────────────── */

.md-typeset h1,
.md-typeset h2,
.md-typeset h3,
.md-typeset h4 {
  font-family: var(--res-font-sans);
  font-weight: 600;
  letter-spacing: var(--res-tracking-tight);
  color: var(--res-ink);
  line-height: var(--res-leading-tight);
}

.md-typeset h1 {
  font-size: var(--res-text-2xl);
  letter-spacing: var(--res-tracking-display);
  margin: 0 0 var(--res-space-5);
  font-weight: 650;
}

.md-typeset h2 {
  font-size: var(--res-text-xl);
  border-bottom: 1px solid var(--res-hairline);
  padding-bottom: var(--res-space-3);
  margin-top: var(--res-space-7);
  margin-bottom: var(--res-space-5);
}

.md-typeset h3 {
  font-size: var(--res-text-lg);
  margin-top: var(--res-space-6);
  margin-bottom: var(--res-space-3);
}

.md-typeset h4 {
  font-size: var(--res-text-base);
  margin-top: var(--res-space-5);
  margin-bottom: var(--res-space-2);
}

.md-typeset p,
.md-typeset li {
  color: var(--res-ink);
}

.md-typeset p + p {
  margin-top: var(--res-space-4);
}

.md-typeset .md-caption,
.md-typeset small {
  color: var(--res-secondary);
  font-size: var(--res-text-sm);
}

/* Links: ink + underline — never a brand blue */
.md-typeset a {
  color: var(--res-ink);
  text-decoration: underline;
  text-underline-offset: 0.18em;
  text-decoration-thickness: 1px;
}

.md-typeset a:hover {
  color: #000000;
  text-decoration-thickness: 2px;
}

/* ═══════════════════════════════════════════════════════════════════
   Header — minimal chrome, search as primary affordance
   Material's black primary paints the header #14151A via palette CSS;
   we force shell chrome here (higher specificity + !important) so the
   product reads light-monochrome, not a dark Material bar.
   ═══════════════════════════════════════════════════════════════════ */

[data-md-color-scheme="residion"] .md-header,
[data-md-color-scheme="default"] .md-header,
[data-md-color-primary="black"] .md-header,
.md-header,
.md-header--shadow,
.md-header--lifted {
  background-color: var(--res-shell) !important;
  background-image: none !important;
  color: var(--res-ink) !important;
  border-bottom: 1px solid var(--res-hairline);
  box-shadow: none !important;
  height: auto;
}

.md-header__inner {
  height: var(--res-header-height);
  padding-inline: var(--res-space-4);
}

.md-header__title,
.md-header__button,
.md-header .md-logo,
.md-header .md-source,
.md-header__topic,
.md-header__button.md-icon {
  color: var(--res-ink) !important;
}

.md-header .md-header__button:hover {
  opacity: 1;
  background-color: var(--res-tint);
}

.md-header .md-logo {
  margin: 0;
  padding: 0;
}

.md-header .md-logo svg {
  width: 1.35rem;
  height: 1.35rem;
  fill: currentColor;
}

.md-header__title {
  font-size: var(--res-text-sm);
  font-weight: 600;
  letter-spacing: var(--res-tracking-tight);
  margin-left: var(--res-space-2);
}

/* Version selector — quiet chip */
.md-version {
  margin-left: var(--res-space-3);
}

.md-version__current,
.md-version__link {
  color: var(--res-ink) !important;
  font-size: var(--res-text-xs);
  font-weight: 500;
}

.md-header__option .md-header__button {
  color: var(--res-ink) !important;
  opacity: 1;
}

/* Tabs — product-level bar, hairline separated (same light chrome) */
[data-md-color-scheme="residion"] .md-tabs,
[data-md-color-scheme="default"] .md-tabs,
[data-md-color-primary="black"] .md-tabs,
.md-tabs {
  background-color: var(--res-shell) !important;
  background-image: none !important;
  color: var(--res-ink) !important;
  border-bottom: 1px solid var(--res-hairline);
  box-shadow: none !important;
}

.md-tabs__link {
  font-size: var(--res-text-sm);
  font-weight: 500;
  opacity: 1 !important;
  color: var(--res-secondary) !important;
  margin-top: 0;
}

.md-tabs__link--active,
.md-tabs__item--active .md-tabs__link,
.md-tabs__link:hover,
.md-tabs__link:focus {
  color: var(--res-ink) !important;
}

.md-tabs__item--active {
  border-bottom: 2px solid var(--res-ink);
}

/* ── Search — primary affordance ─────────────────────────────────── */

.md-search__form {
  background: var(--res-tint);
  border: 1px solid var(--res-hairline);
  border-radius: 0;
  box-shadow: none;
}

.md-search__input {
  background: transparent;
  color: var(--res-ink);
  font-family: var(--res-font-sans);
  font-size: var(--res-text-sm);
}

.md-search__input + .md-search__icon,
.md-search__input::placeholder {
  color: var(--res-secondary);
}

.md-search__output {
  background: var(--res-shell);
  color: var(--res-ink);
  border: 1px solid var(--res-hairline);
  border-top: none;
  box-shadow: none;
}

.md-search-result__meta {
  color: var(--res-secondary);
  background: var(--res-tint);
  font-size: var(--res-text-xs);
}

.md-search-result__link:hover,
.md-search-result__more > summary:hover {
  background: var(--res-tint);
}

/* Desktop: always-visible search field in the header */
@media screen and (min-width: 60em) {
  .md-header__inner {
    gap: var(--res-space-4);
  }

  .md-header .md-search {
    position: relative;
    width: var(--res-search-max);
    max-width: var(--res-search-max);
    padding: 0;
    transition: none;
  }

  .md-header .md-search__inner {
    width: 100%;
  }

  .md-header .md-search__form {
    height: 2.25rem;
  }

  .md-header .md-search__output {
    top: calc(100% + 1px);
    width: 100%;
  }

  /* Hide the icon-only toggle; the field itself is the affordance */
  .md-header > .md-header__inner > label.md-header__button[for="__search"] {
    display: none;
  }
}

/* ═══════════════════════════════════════════════════════════════════
   Sidebar — grouped / collapsible (no force-expand)
   ═══════════════════════════════════════════════════════════════════ */

.md-nav {
  font-size: var(--res-text-sm);
  line-height: var(--res-leading-snug);
}

.md-nav__title {
  color: var(--res-ink);
  font-weight: 600;
  font-size: var(--res-text-sm);
}

.md-nav__item--section > .md-nav__link {
  color: var(--res-ink);
  font-weight: 600;
  font-size: var(--res-text-sm);
  letter-spacing: var(--res-tracking-tight);
}

.md-nav__link {
  color: var(--res-secondary);
  margin-top: 0.15em;
}

.md-nav__link--active,
.md-nav__link:focus,
.md-nav__link:hover {
  color: var(--res-ink);
}

.md-nav__link--active:not(.md-nav__container) {
  font-weight: 600;
  color: var(--res-ink);
}

.md-sidebar {
  padding-top: var(--res-space-4);
}

.md-sidebar--primary .md-sidebar__scrollwrap {
  border-right: 1px solid var(--res-hairline);
}

.md-sidebar--secondary .md-sidebar__scrollwrap {
  border-left: 1px solid transparent;
}

.md-nav--secondary .md-nav__title {
  background: transparent;
  box-shadow: none;
  border-bottom: 1px solid var(--res-hairline);
  color: var(--res-secondary);
  font-size: var(--res-text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

/* ═══════════════════════════════════════════════════════════════════
   Cards — workhorse component (Material .grid.cards + Residion skin)
   ═══════════════════════════════════════════════════════════════════ */

.md-typeset .grid {
  grid-gap: var(--res-space-5);
  margin: var(--res-space-5) 0 var(--res-space-6);
}

.md-typeset .grid.cards > :is(ul, ol) > li,
.md-typeset .grid > .card,
.md-typeset .card {
  border: 1px solid var(--res-hairline);
  border-radius: 0;
  background: var(--res-shell);
  box-shadow: none;
  padding: var(--res-space-5);
  transition: background 120ms ease, border-color 120ms ease;
}

.md-typeset .grid.cards > :is(ul, ol) > li:hover,
.md-typeset .grid > .card:hover,
.md-typeset .card:hover {
  box-shadow: none;
  border-color: var(--res-ink);
  background: var(--res-shell);
}

.md-typeset .grid.cards > :is(ul, ol) > li > hr,
.md-typeset .grid > .card > hr,
.md-typeset .card > hr {
  margin: var(--res-space-3) 0;
  border: none;
  border-top: 1px solid var(--res-hairline);
}

.md-typeset .grid.cards > :is(ul, ol) > li > :first-child,
.md-typeset .card > :first-child {
  margin-top: 0;
}

.md-typeset .grid.cards > :is(ul, ol) > li > :last-child,
.md-typeset .card > :last-child {
  margin-bottom: 0;
}

.md-typeset .grid.cards > :is(ul, ol) > li p,
.md-typeset .card p {
  color: var(--res-secondary);
  font-size: var(--res-text-sm);
  line-height: var(--res-leading-body);
  max-width: none;
}

.md-typeset .grid.cards > :is(ul, ol) > li strong,
.md-typeset .card strong {
  color: var(--res-ink);
  font-size: var(--res-text-base);
  font-weight: 600;
  letter-spacing: var(--res-tracking-tight);
}

.md-typeset .grid.cards > :is(ul, ol) > li a,
.md-typeset .card a {
  text-decoration: none;
  border-bottom: 1px solid var(--res-ink);
  font-weight: 500;
  font-size: var(--res-text-sm);
}

.md-typeset .grid.cards > :is(ul, ol) > li a:hover,
.md-typeset .card a:hover {
  text-decoration: none;
  border-bottom-width: 2px;
}

/* Capability cards — denser list of what you can do today */
.md-typeset .grid.cards.res-capabilities > :is(ul, ol) > li {
  padding: var(--res-space-4) var(--res-space-5);
}

.md-typeset .grid.cards.res-capabilities > :is(ul, ol) > li p {
  margin: 0;
  color: var(--res-ink);
  font-size: var(--res-text-sm);
}

/* Gap card — keep "What still needs Residion" visually prominent */
.md-typeset .grid.cards > :is(ul, ol) > li.res-card--gap,
.md-typeset .card.res-card--gap {
  background: var(--res-ink);
  border-color: var(--res-ink);
  color: var(--res-shell);
}

.md-typeset .grid.cards > :is(ul, ol) > li.res-card--gap:hover,
.md-typeset .card.res-card--gap:hover {
  background: #000000;
  border-color: #000000;
}

.md-typeset .grid.cards > :is(ul, ol) > li.res-card--gap strong,
.md-typeset .grid.cards > :is(ul, ol) > li.res-card--gap p,
.md-typeset .card.res-card--gap strong,
.md-typeset .card.res-card--gap p {
  color: var(--res-shell);
}

.md-typeset .grid.cards > :is(ul, ol) > li.res-card--gap > hr,
.md-typeset .card.res-card--gap > hr {
  border-top-color: rgba(255, 255, 255, 0.25);
}

.md-typeset .grid.cards > :is(ul, ol) > li.res-card--gap a,
.md-typeset .card.res-card--gap a {
  color: var(--res-shell);
  border-bottom-color: var(--res-shell);
}

/* ═══════════════════════════════════════════════════════════════════
   Landing hero
   ═══════════════════════════════════════════════════════════════════ */

.res-hero {
  margin: 0 0 var(--res-space-7);
  padding: 0;
  max-width: none;
}

.res-hero h1 {
  font-size: var(--res-text-3xl);
  letter-spacing: var(--res-tracking-display);
  line-height: var(--res-leading-tight);
  margin: 0 0 var(--res-space-4);
  font-weight: 650;
}

.res-hero .res-hero__lede {
  font-size: var(--res-text-lg);
  line-height: var(--res-leading-snug);
  color: var(--res-ink);
  max-width: 42rem;
  margin: 0 0 var(--res-space-5);
}

.res-hero .res-invert {
  margin: 0;
  max-width: 42rem;
}

/* Landing: roomier content column when sidebars hidden */
.md-main__inner:has(.res-hero) {
  margin-top: var(--res-space-6);
}

article .res-hero + h2,
.md-typeset .res-hero + h2 {
  margin-top: var(--res-space-7);
}

/* ═══════════════════════════════════════════════════════════════════
   Callouts — hairline boxes, ink labels, no coloured panels
   ═══════════════════════════════════════════════════════════════════ */

.md-typeset .admonition,
.md-typeset details {
  border: 1px solid var(--res-hairline);
  border-left: 1px solid var(--res-hairline);
  border-radius: 0;
  background: var(--res-shell);
  box-shadow: none;
  color: var(--res-ink);
  margin: var(--res-space-5) 0;
  font-size: var(--res-text-sm);
}

.md-typeset .admonition > .admonition-title,
.md-typeset details > summary {
  background: var(--res-tint);
  border-bottom: 1px solid var(--res-hairline);
  color: var(--res-ink);
  font-weight: 600;
  font-size: var(--res-text-sm);
}

.md-typeset .admonition > .admonition-title::before,
.md-typeset details > summary::before {
  background-color: var(--res-ink) !important;
  opacity: 0.85;
}

.md-typeset .admonition.note,
.md-typeset .admonition.info,
.md-typeset .admonition.tip,
.md-typeset .admonition.warning,
.md-typeset .admonition.danger,
.md-typeset .admonition.caution,
.md-typeset .admonition.failure,
.md-typeset .admonition.success,
.md-typeset details.note,
.md-typeset details.warning {
  border-color: var(--res-hairline);
}

/* Inversion block — emphasis without colour */
.res-invert {
  background: var(--res-ink);
  color: var(--res-shell);
  padding: var(--res-space-4) var(--res-space-5);
  margin: var(--res-space-5) 0;
}

.res-invert a,
.res-invert strong {
  color: var(--res-shell);
}

/* Status without colour */
.res-status {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
}

.res-status::before {
  content: "";
  width: 0.55em;
  height: 0.55em;
  border: 1.5px solid var(--res-ink);
  border-radius: 50%;
  flex-shrink: 0;
}

.res-status--active::before,
.res-status--healthy::before {
  background: var(--res-ink);
}

.res-status--inactive::before,
.res-status--degraded::before {
  background: transparent;
}

/* ═══════════════════════════════════════════════════════════════════
   Tables — lighter rules, more padding, no zebra by default
   ═══════════════════════════════════════════════════════════════════ */

.md-typeset table:not([class]) {
  border: 1px solid var(--res-hairline);
  box-shadow: none;
  font-size: var(--res-text-sm);
  display: table;
  width: 100%;
}

.md-typeset table:not([class]) th {
  background: var(--res-tint);
  color: var(--res-ink);
  border-bottom: 1px solid var(--res-hairline);
  font-weight: 600;
  padding: var(--res-space-3) var(--res-space-4);
}

.md-typeset table:not([class]) td {
  border-top: 1px solid var(--res-hairline);
  padding: var(--res-space-3) var(--res-space-4);
  vertical-align: top;
}

.md-typeset table:not([class]) tr:nth-child(even) {
  background: transparent;
}

/* ═══════════════════════════════════════════════════════════════════
   Code — Tint background, monospace, no language-switcher furniture
   ═══════════════════════════════════════════════════════════════════ */

.md-typeset code {
  background: var(--res-tint);
  color: var(--res-ink);
  border: 1px solid var(--res-hairline);
  border-radius: 0;
  padding: 0.1em 0.35em;
  font-family: var(--res-font-mono);
  font-size: 0.88em;
}

.md-typeset pre > code {
  border: none;
  background: transparent;
  font-size: 0.875em;
  line-height: 1.55;
}

.md-typeset .highlight,
.md-typeset pre {
  background: var(--res-tint);
  border: 1px solid var(--res-hairline);
  border-radius: 0;
  box-shadow: none;
}

.md-typeset .highlight code {
  border: none;
}

/* ═══════════════════════════════════════════════════════════════════
   Footer — quiet, hairline-separated
   ═══════════════════════════════════════════════════════════════════ */

.md-footer {
  background: var(--res-shell);
  color: var(--res-ink);
  border-top: 1px solid var(--res-hairline);
}

.md-footer-meta {
  background: var(--res-shell);
  border-top: none;
  color: var(--res-secondary);
}

.md-footer-meta__inner {
  padding: var(--res-space-5) var(--res-space-4);
}

.md-copyright,
.md-copyright__highlight {
  color: var(--res-secondary);
  font-size: var(--res-text-xs);
}

.md-footer__link {
  color: var(--res-ink);
}

.md-footer__title {
  font-size: var(--res-text-sm);
}

.md-footer__direction {
  color: var(--res-secondary);
  font-size: var(--res-text-xs);
}

/* ═══════════════════════════════════════════════════════════════════
   Buttons / misc
   ═══════════════════════════════════════════════════════════════════ */

.md-button {
  border-radius: 0;
  box-shadow: none;
  font-weight: 500;
}

.md-button--primary {
  background: var(--res-ink);
  color: var(--res-shell);
  border: 1px solid var(--res-ink);
}

.md-button--primary:hover {
  background: #000000;
  color: var(--res-shell);
}

.md-typeset .md-button {
  color: var(--res-ink);
  border: 1px solid var(--res-ink);
  text-decoration: none;
}

.res-muted {
  color: var(--res-secondary);
}

.res-caveat {
  border-top: 1px solid var(--res-hairline);
  margin-top: var(--res-space-5);
  padding-top: var(--res-space-4);
  color: var(--res-ink);
  font-size: var(--res-text-sm);
  max-width: var(--res-measure);
}

hr {
  border: none;
  border-top: 1px solid var(--res-hairline);
  margin: var(--res-space-6) 0;
}

/* Top-of-page affordance */
.md-top {
  border: 1px solid var(--res-hairline);
  border-radius: 0;
  box-shadow: none;
  background: var(--res-shell);
  color: var(--res-ink);
}
