/* Load last, after r11-interior.css. Only cards explicitly owned by the
   existing selection scripts receive these states. #culture is excluded. */

body .r11-selectable:is([data-select-card],[data-card-toggle]):not(#culture):not(#culture *) {
  --r11-card-active: #0068b7;
  --dbt-interaction-active: #0068b7;
  --card-blue: #0068b7;
}

/* A pointer/focus preview is temporary; it does not write selected state. */
body .r11-selectable:is([data-select-card],[data-card-toggle]):is(:hover,:focus-visible,.dbt-expand-active):not(#culture):not(#culture *) {
  --r11-card-active: #0b75bf;
  background: var(--r11-card-active) !important;
  border-color: var(--r11-card-active) !important;
  color: #fff !important;
  --dbt-local-ink: #fff;
  --dbti-ink: #fff;
  --card-number: #fff;
  --card-active: 0;
}

/* Selected wins over preview and survives pointerleave/focusout. Matching the
   native state also avoids a one-frame flash before the observer runs. */
body .r11-selectable:is([data-select-card],[data-card-toggle]):is(.r11-selected,[aria-pressed="true"]):not(#culture):not(#culture *) {
  --r11-card-active: #0068b7;
  background: #0068b7 !important;
  border-color: #0068b7 !important;
  color: #fff !important;
  --dbt-local-ink: #fff;
  --dbti-ink: #fff;
  --card-number: #fff;
  --card-active: 0;
}

/* Only the chosen card's local copy is recolored; no surrounding heading or
   separate navigation link inherits a selected state. !important beats the
   legacy component rules and ordinary inline color declarations. */
body .r11-selectable:is([data-select-card],[data-card-toggle]):is(:hover,:focus-visible,.dbt-expand-active,.r11-selected,[aria-pressed="true"]):not(#culture):not(#culture *)
  :is(h3,h4,p,small,strong,em,figcaption,.mp-item-title,.mp-copy,.mp-card-copy,.mp-number,.fsvc-value-number,.refine-system-name,.dbt-card-summary,[data-dbt-summary],[data-dbti-title],.refine-icon,.mp-symbol,.motion-svg,.fsvc-benefit-icon,.story-resource-icon,.dbti-host,.dbti-art):not(#culture):not(#culture *) {
  color: #fff !important;
  --dbti-ink: #fff;
  --dbti-line: #ffffff66;
}

/* Change icon assets only. Photographs in the same card keep their color. */
body .r11-selectable:is([data-select-card],[data-card-toggle]):is(:hover,:focus-visible,.dbt-expand-active,.r11-selected,[aria-pressed="true"]):not(#culture):not(#culture *)
  :is(img[data-motion-icon],.refine-icon img,.story-resource-icon img,.fsvc-benefit-icon img):not(#culture):not(#culture *) {
  filter: brightness(0) invert(1) !important;
}

/* The old challenge-card pseudo layer uses a cyan gradient. Keep it from
   covering the new solid state while retaining the authored geometry. */
body .r11-selectable.mp-card:is(:hover,:focus-visible,.dbt-expand-active,.r11-selected,[aria-pressed="true"]):not(#culture):not(#culture *)::before {
  background: var(--r11-card-active) !important;
  opacity: 0 !important;
}

body .r11-selectable:is([data-select-card],[data-card-toggle]):focus-visible:not(#culture):not(#culture *) {
  outline: 3px solid #ee9548 !important;
  outline-offset: 3px;
}
