/* =========================================================================
   ECIDS accessibility layer — WCAG 2.1 AA per the Utah Design System
   Accessibility Checklist:
   https://designsystem.utah.gov/guidelinesStandards/accessibilityChecklistTesting

   Loaded LAST in <head> (after the component stylesheets and the inline
   <style> blocks) so these rules take precedence.
   ========================================================================= */

/* ---- Screen-reader-only text (UDS "visually-hidden" utility) ---------- */
.visually-hidden:not(:focus):not(:active) {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* ---- Skip link: first focusable element on every page ------------------ */
.ecids-skip-link {
  position: absolute;
  top: -100px;
  left: 8px;
  z-index: 10000;
  padding: 10px 16px;
  background: var(--brand-primary);
  color: #fff;
  font-weight: 700;
  text-decoration: underline;
  border-radius: 4px;
}
.ecids-skip-link:focus {
  top: 8px;
  outline: 3px solid var(--brand-accent-gold);
  outline-offset: 2px;
}

/* ---- Visible focus indicator (>= 3:1 against adjacent colours) --------- */
:focus-visible {
  outline: 3px solid var(--brand-secondary) !important;
  outline-offset: 2px;
}
/* On dark surfaces a teal ring would not reach 3:1, so use white there. */
.utds-official-website__banner :focus-visible,
.utds-official-website-popup__wrapper :focus-visible,
.footer :focus-visible {
  outline-color: #fff !important;
}
/* Programmatic focus targets (main landmark, modal titles, error summaries)
   are not interactive controls and need no ring. */
#main-content:focus,
.modal:focus,
.modal-title:focus,
:is(h1, h2, h3, h4)[tabindex="-1"]:focus,
.alert[tabindex="-1"]:focus,
.success-title:focus {
  outline: none !important;
}

/* ---- Form controls: 3:1 boundary contrast + clear focus state ---------- */
.form-control,
.form-select,
.selectize-input,
.selectize-control.single .selectize-input,
.input-daterange .form-control,
#ecids-term-table_wrapper .dataTables_filter input,
.search input[type="text"] {
  border-color: #6b7280 !important;
}
.form-check-input {
  border-color: #6b7280;
}
.form-check-input:checked {
  background-color: var(--brand-primary);
  border-color: var(--brand-primary);
}
.form-control:focus,
.form-select:focus,
.selectize-input.focus,
.form-check-input:focus,
.search input[type="text"]:focus {
  border-color: var(--brand-secondary) !important;
  box-shadow: 0 0 0 3px rgba(22, 88, 87, 0.35);
}

/* Required-field mark (visible asterisk; hidden "(required)" text follows) */
.required-mark {
  color: var(--brand-accent-red);
  font-weight: 700;
}
/* Visible helper text that replaces title-attribute tooltips */
.ecids-field-hint {
  display: block;
  color: #4b5563;
  margin-top: 4px;
  font-size: 0.875rem;
}
/* Report warnings previously styled color:Red (4.0:1) */
.ecids-warning-text {
  color: var(--brand-accent-red);
}
/* Labels that exist only for assistive technology take no layout space */
.shiny-input-container > label.control-label:has(> .visually-hidden:only-child) {
  position: absolute;
  margin: 0;
}
.shiny-input-container > label.shiny-label-null:empty {
  display: none;
}

/* ---- Links -------------------------------------------------------------- */
/* Non-navigation footer links must be identifiable by more than colour */
.footer .footer-contact-line a,
.footer .footer-disclaimer a,
.footer .footer-hotline a,
.footer .footer-legal a,
.footer .footer-col .footer-agency-information__menu a[target="_blank"] {
  text-decoration: underline;
}
/* Visual "opens in a new tab" indicator (hidden text added in Python) */
.ecids-ext-link::after {
  content: "\2197";
  display: inline-block;
  font-size: 0.8em;
  margin-left: 0.3em;
  vertical-align: text-top;
  text-decoration: none;
}
/* Icon-only links: 24 x 24 px minimum target size */
.ecids-icon-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  min-height: 24px;
  padding: 4px;
}

/* ---- Headings that keep the look of the element they replaced --------- */
.card-header .ecids-card-heading {
  font-family: var(--brand-body-font);
  font-size: 1rem;
  font-weight: 600;
  line-height: inherit;
  color: inherit;
  margin: 0;
}
.ecids-modal-title {
  font-family: var(--brand-body-font);
  font-size: 1.25rem;
  font-weight: 500;
  line-height: 1.5;
  margin: -1rem -1rem 1rem;
  padding: 1rem;
  border-bottom: 1px solid #dee2e6;
}
.footer h2.footer__section-title {
  font-family: var(--brand-body-font);
  font-weight: 700;
  font-size: 18px;
  color: inherit;
}
/* Trend report titles / report sub-headings rendered as h2/h3 with BS size classes */
h2.h4, h2.h5, h3.h4, h3.h5 {
  font-family: var(--brand-body-font);
}

/* ---- Tables / charts ---------------------------------------------------- */
.ecids-scroll-region {
  overflow-x: auto;
  /* Containing block for the visually-hidden (absolutely positioned) cell
     text, so it is clipped with the table instead of widening the page. */
  position: relative;
}
.ecids-figure {
  margin: 0;
}
/* Plotly's logo button is an icon-only link to plotly.com that opens a new tab */
.js-plotly-plot .modebar-btn--logo {
  display: none !important;
}

/* ---- Official-website banner button: keep a 24px target ---------------- */
.utds-official-website__button {
  min-height: 24px;
}
/* Text links: vertical padding enlarges the hit area to >= 24px without
   changing the text layout (UDS: interactive elements 24 x 24 px). */
main a:not(.btn):not(.ecids-icon-link):not(.nav-link),
.footer a {
  padding-top: 2px;
  padding-bottom: 2px;
}

/* ---- Reduced motion ----------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
