/* ============================================================================
   Remediate — Windows High Contrast / forced-colors support
   Loaded last on every surface (marketing, demo, county host page, app,
   admin, viewer, 404). The honor-system theme is intentionally replaced by
   system colors: no authored text color survives forced-colors mode, so
   contrast is always CanvasText / LinkText / ButtonText / FieldText.
   ========================================================================== */

@media (forced-colors: active) {
  html {
    background: Canvas;
    color-scheme: light dark;
  }

  body {
    background: Canvas !important;
    color: CanvasText !important;
  }

  /* Decorative gradients, glows, blurs and shadows add nothing in HCM. */
  *,
  *::before,
  *::after {
    background-image: none !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }

  /* Every piece of text defaults to the system text color. */
  body,
  body * {
    color: CanvasText !important;
    border-color: currentColor;
  }

  /* Links keep the system link color, including nested spans/svgs. */
  a,
  a *,
  a:visited,
  a:visited * {
    color: LinkText !important;
  }

  a {
    text-decoration: underline !important;
  }

  /* Buttons, switches and toggles. */
  button,
  button *,
  [role='button'],
  [role='button'] *,
  [role='switch'],
  [role='switch'] *,
  [role='tab'],
  [role='tab'] *,
  .btn,
  .btn *,
  input[type='submit'],
  input[type='button'],
  input[type='reset'] {
    background-color: ButtonFace !important;
    color: ButtonText !important;
    border: 1px solid ButtonText !important;
    forced-color-adjust: none;
  }

  /* Form fields. */
  input:not([type='submit']):not([type='button']):not([type='reset']):not([type='checkbox']):not([type='radio']):not([type='range']),
  textarea,
  select {
    background-color: Field !important;
    color: FieldText !important;
    border: 1px solid FieldText !important;
  }

  input::placeholder,
  textarea::placeholder {
    color: GrayText !important;
    opacity: 1;
  }

  input[type='checkbox'],
  input[type='radio'],
  input[type='range'],
  progress,
  meter {
    accent-color: Highlight;
  }

  :disabled,
  [aria-disabled='true'],
  .is-disabled {
    color: GrayText !important;
    border-color: GrayText !important;
  }

  /* Surfaces that paint over photography or gradients become plain Canvas so
     CanvasText stays readable. */
  header,
  footer,
  nav,
  main,
  aside,
  section,
  article,
  dialog,
  [role='dialog'],
  [role='region'],
  .panel,
  .card,
  .hero,
  .band,
  .masthead,
  .utility-bar,
  .sidebar,
  .doc-controls,
  .public-nav,
  .app-shell,
  .app-sidebar,
  .county-footer {
    background-color: Canvas !important;
  }

  /* Separate regions without relying on color. */
  header,
  footer,
  nav,
  aside,
  dialog,
  [role='dialog'],
  .panel,
  .card {
    border: 1px solid CanvasText !important;
  }

  /* Focus must remain visible in every surface. */
  :focus-visible,
  a:focus-visible,
  button:focus-visible,
  input:focus-visible,
  select:focus-visible,
  textarea:focus-visible,
  [tabindex]:focus-visible {
    outline: 3px solid Highlight !important;
    outline-offset: 2px !important;
  }

  ::selection {
    background: Highlight !important;
    color: HighlightText !important;
  }

  /* Modal backdrops: keep the dialog distinguishable. */
  dialog::backdrop {
    background: Canvas !important;
    opacity: 0.92;
  }

  /* Integration code card: explicit system colors so tokens stay legible. */
  .code-card,
  .code-head,
  .code-block,
  .code-block code,
  .code-tabs button {
    background: Canvas !important;
    color: CanvasText !important;
    border-color: CanvasText !important;
    forced-color-adjust: none;
  }
  .code-copy,
  .code-copy span,
  .code-status {
    background: Canvas !important;
    color: ButtonText !important;
    border-color: ButtonText !important;
    forced-color-adjust: none;
  }
  .tok-com { color: GrayText !important; }
  .tok-tag,
  .tok-attr,
  .tok-str,
  .tok-key,
  .tok-fn,
  .tok-num { color: CanvasText !important; }

  /* Images and PDF canvases keep their content; only the chrome is themed. */
  img,
  canvas,
  video,
  iframe {
    forced-color-adjust: none;
  }
}
