/*
 * The API reference's look (docs/V2_DOCS_PLAN.md §4.3): Scalar's theme variables set from the portal's --hud-*
 * tokens, so the reference follows both themes with the rest of the site. Scalar puts light-mode or dark-mode on
 * <body> (js/reference.js keeps it matching the portal's theme) and sets its own colors there; "body." outranks
 * those, and the --hud-* tokens already hold the theme showing. Scalar also marks some parts dark-mode whatever the
 * theme (the request examples); they take the tokens too, so in the light theme they're light, like the guides' code.
 */
body.light-mode, body.dark-mode, body .light-mode, body .dark-mode {
  /* The portal's sticky top bar sits over Scalar's page; its sticky sidebar and headers start below it. */
  --scalar-custom-header-height: var(--topbar);

  --scalar-font: var(--hud-f-body);
  --scalar-font-code: var(--hud-f-mono);

  --scalar-background-1: var(--hud-void);
  --scalar-background-2: var(--hud-deck);
  --scalar-background-3: var(--hud-deck-2);
  --scalar-background-4: var(--hud-hull);
  --scalar-background-card: var(--hud-deck);
  --scalar-background-accent: rgb(var(--hud-signal-rgb) / .12);
  --scalar-color-1: var(--hud-text-hi);
  --scalar-color-2: var(--hud-text-mid);
  --scalar-color-3: var(--hud-text-low);
  --scalar-color-accent: var(--hud-signal);
  --scalar-border-color: var(--hud-hull);
  --scalar-link-color: var(--hud-signal);
  --scalar-link-color-hover: var(--hud-text-hi);
  --scalar-focus-color: var(--hud-text-hi);

  --scalar-color-green: var(--hud-ok);
  --scalar-color-red: var(--hud-alert);
  --scalar-color-yellow: var(--hud-warn);
  --scalar-color-orange: var(--hud-warn);
  --scalar-color-blue: var(--hud-signal);
  --scalar-color-danger: var(--hud-alert);
  --scalar-color-alert: var(--hud-warn);
  --scalar-background-danger: rgb(var(--hud-alert-rgb) / .12);

  --scalar-button-1: var(--hud-signal);
  --scalar-button-1-hover: var(--hud-text-hi);
  --scalar-button-1-color: var(--hud-on-signal);

  --scalar-sidebar-background-1: var(--hud-void);
  --scalar-sidebar-color-1: var(--hud-text-hi);
  --scalar-sidebar-color-2: var(--hud-text-mid);
  --scalar-sidebar-color-active: var(--hud-signal);
  --scalar-sidebar-border-color: var(--hud-hull);
  --scalar-sidebar-item-hover-background: var(--hud-deck);
  --scalar-sidebar-item-hover-color: var(--hud-text-hi);
  --scalar-sidebar-item-active-background: rgb(var(--hud-signal-rgb) / .12);
  --scalar-sidebar-search-background: var(--hud-deck);
  --scalar-sidebar-search-border-color: var(--hud-hull);
  --scalar-sidebar-search-color: var(--hud-text-low);

  --scalar-scrollbar-color: var(--hud-hull);
  --scalar-scrollbar-color-active: var(--hud-hull-hi);

  /* Flat, like the portal: popovers get a hull outline instead of a drop shadow. */
  --scalar-shadow-1: none;
  --scalar-shadow-2: 0 0 0 1px var(--hud-hull);

  /* Square corners, like the portal's frames. */
  --scalar-radius: 0;
  --scalar-radius-md: 0;
  --scalar-radius-lg: 0;
  --scalar-radius-xl: 0;
  --scalar-radius-2xl: 0;
  --scalar-radius-3xl: 0;
}

/* In the light theme, Scalar's always-dark parts are light through and through: its own rule forces them dark
   (color-scheme, its light-dark() switch) with !important inside a cascade layer, which beats any unlayered
   !important. For !important the first-declared layer wins, and this sheet loads before Scalar injects its own. */
@layer portal-reference-overrides {
  body.light-mode .dark-mode {
    --lightningcss-light: initial !important;
    --lightningcss-dark: !important;
    color-scheme: light !important;
  }
}
body.light-mode .dark-mode {
  --scalar-lifted-brightness: 1;
  --scalar-backdrop-brightness: 1;
}

/* No hexagon edge art here: Scalar's sidebar and examples run to the page edges. */
body::before, body::after { content: none; }

/* The page under the top bar is Scalar's. */
.reference { flex: 1 0 auto; width: 100%; position: relative; z-index: 1; }
.reference h1, .reference h2, .reference h3 { font-family: var(--hud-f-display); }
.reference-noscript { max-width: var(--hud-shell-max); margin: 0 auto; padding: 48px var(--hud-gutter); }
