/* Shared automatic appearance. Light mode uses each page's original fallback
   colors. Semantic tokens also cover dynamically inserted quote UI. Screen-only
   rules keep printed purchasing documents on their existing light palette. */
:root { color-scheme: light; }

@media screen and (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --theme-surface: #111c29;
    --theme-soft: #192737;
    --theme-ink: #edf3fa;
    --theme-muted: #b0bfd0;
    --theme-line: #43556b;
    --theme-link: #8ac5ff;
    --theme-accent-surface: #173653;
    --theme-success: #92e2b4;
    --theme-success-surface: #15372b;
    --theme-warning: #ffd28a;
    --theme-warning-surface: #3e301b;
    --theme-danger: #ffb1b9;
    --theme-danger-surface: #41232c;
    --theme-glass: rgba(17, 28, 41, .96);
    --theme-glass-soft: rgba(25, 39, 55, .96);
    --theme-line-alpha: rgba(176, 191, 208, .25);
    --cx-canvas: var(--theme-soft);
    --cx-surface: var(--theme-surface);
    --cx-slate-100: var(--theme-soft);
    --cx-slate-200: var(--theme-line);
    --cx-slate-500: var(--theme-muted);
    --cx-slate-700: var(--theme-muted);
    --bs-body-color: var(--theme-ink);
    --bs-body-color-rgb: 237, 243, 250;
    --bs-body-bg: var(--theme-surface);
    --bs-body-bg-rgb: 17, 28, 41;
    --bs-emphasis-color: #fff;
    --bs-emphasis-color-rgb: 255, 255, 255;
    --bs-secondary-color: var(--theme-muted);
    --bs-secondary-color-rgb: 176, 191, 208;
    --bs-secondary-bg: var(--theme-soft);
    --bs-secondary-bg-rgb: 25, 39, 55;
    --bs-tertiary-bg: #1c2d40;
    --bs-tertiary-bg-rgb: 28, 45, 64;
    --bs-border-color: var(--theme-line);
    --bs-border-color-translucent: rgba(176, 191, 208, .25);
    --bs-link-color: var(--theme-link);
    --bs-link-color-rgb: 138, 197, 255;
    --bs-link-hover-color: #b9ddff;
    --bs-link-hover-color-rgb: 185, 221, 255;
    --focus-ring: 0 0 0 3px rgba(138, 197, 255, .35);
  }

  body { background: var(--theme-surface); color: var(--theme-ink); }
  :where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
    outline-color: var(--theme-link);
  }

  /* Keep white labels on Ahner blue actions, and brighten outline actions. */
  .btn-primary { color: #fff; }
  .btn-outline-primary, .btn-outline-secondary {
    --bs-btn-color: var(--theme-link);
    --bs-btn-border-color: #659acb;
    --bs-btn-hover-color: #fff;
    --bs-btn-active-color: #fff;
  }
  .btn-outline-secondary {
    --bs-btn-hover-bg: #24415e;
    --bs-btn-active-bg: #24415e;
  }
  .btn-link { --bs-btn-color: var(--theme-link); --bs-btn-hover-color: #b9ddff; }
  .form-control, .form-select, .input-group-text {
    color: var(--theme-ink);
    background-color: var(--theme-surface);
    border-color: var(--theme-line);
  }
  .form-control:focus, .form-select:focus {
    color: var(--theme-ink);
    background-color: var(--theme-surface);
    border-color: var(--theme-link);
  }
  .form-control::placeholder { color: var(--theme-muted); opacity: 1; }
  .form-control:disabled, .form-select:disabled { background-color: var(--theme-soft); }
  .form-check-input:not(:checked) { background-color: var(--theme-soft); border-color: #7991ab; }
  .form-control:-webkit-autofill {
    -webkit-text-fill-color: var(--theme-ink);
    -webkit-box-shadow: 0 0 0 1000px var(--theme-surface) inset;
  }
  .dropdown-menu, .modal-content, .accordion-item, .list-group-item {
    --bs-dropdown-bg: var(--theme-surface);
    --bs-dropdown-color: var(--theme-ink);
    --bs-dropdown-link-color: var(--theme-ink);
    --bs-dropdown-link-hover-color: #fff;
    --bs-dropdown-link-hover-bg: var(--theme-soft);
    --bs-dropdown-link-active-bg: #0068cf;
    color: var(--theme-ink);
    background-color: var(--theme-surface);
    border-color: var(--theme-line);
  }
  .table {
    --bs-table-color: var(--theme-ink);
    --bs-table-bg: var(--theme-surface);
    --bs-table-border-color: var(--theme-line);
    --bs-table-striped-color: var(--theme-ink);
    --bs-table-striped-bg: var(--theme-soft);
    --bs-table-hover-color: var(--theme-ink);
    --bs-table-hover-bg: #22364c;
  }

  /* Translucent light surfaces and artwork need explicit treatments. */
  .customer-account-button { background: var(--theme-soft); border-color: var(--theme-line); }
  .apple-nav .navbar-toggler { background-color: var(--theme-soft); border-color: #7991ab; }
  .apple-nav .navbar-toggler-icon { filter: none; }
  .nav-logo, .footer-logo { background: #fff; border-radius: 4px; }
  .glass-surface { background: var(--theme-surface); border-color: var(--theme-line); }

  /* These sections intentionally have light text on dark brand backgrounds.
     Their backgrounds must not inherit the foreground ink token. */
  .public-cta, .fab-cta, .fab-table thead th, .industry-cta {
    background: #0b2744;
  }
  .public-cta h2, .public-cta p, .fab-cta h2, .fab-cta p, .industry-cta h2, .industry-cta p {
    color: #edf3fa;
  }
  .public-content .public-button--light, .fab-button--light, .industry-button--light {
    color: var(--theme-ink);
    border-color: var(--theme-line);
  }
  /* Technical drawings retain their original paper and line colors. */
  .editorial-featured-image, .editorial-row-image, .editorial-figure img {
    background: #f3f6f8;
    color-scheme: light;
  }
}

@media print {
  :root { color-scheme: light; }
}
