/* ============================================
   InfluenceHub – Global 44px touch target audit
   - Ensures every interactive control meets the
     WCAG 2.5.5 minimum 44x44px touch target on
     mobile (and remains comfortable on desktop).
   - Uses a conservative approach: only enforces
     min-height/min-width on controls that are
     commonly too small (icon buttons, chips,
     small links, tab buttons, close buttons).
   - Does not break existing layouts: uses
     min-height/min-width (not fixed height/width)
     and inline-flex centering so content stays
     vertically centered.
   - Dark mode, prefers-reduced-motion and
     forced-colors support.
   ============================================ */

/* ---------- Base: 44px minimum touch targets ---------- */

/* Icon-only and small buttons across the site */
.auth-modal button[aria-label],
.auth-modal [data-auth-close],
.auth-modal [data-profile-modal-close],
.auth-modal [data-profile-form-close],
.auth-modal [data-request-close],
.auth-modal [data-birthday-close],
.auth-modal [data-confirm-close],
.auth-modal [data-toggle-password],
#theme-toggle,
#menu-toggle,
#user-menu-toggle,
#catalog-search-clear,
#filters-toggle,
#active-filters-copy,
#active-filters-clear,
#empty-clear-filters,
#empty-show-all,
#saved-empty-browse,
#saved-empty-show-all,
#catalog-load-more,
#bulk-clear,
#bulk-send,
#my-profile-create,
#my-profile-edit,
#inbox-birthday-empty-cta,
#inbox-birthday-empty-secondary,
#sent-birthday-empty-cta,
#sent-birthday-empty-secondary,
#sent-birthday-empty-cta-browse,
#sent-birthday-empty-cta-show-all,
[data-birthday-order],
[data-profile-contact],
[data-favorite-toggle],
[data-save-toggle],
[data-select-card],
[data-inbox-tab],
[data-sent-filter],
[data-category-tab],
[data-category],
[data-auth-open],
[data-auth-logout],
[data-inbox-open],
[data-sent-open],
[data-auth-mode],
[data-auth-role],
[data-bulk-clear],
[data-bulk-send] {
  min-height: 44px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* Icon-only buttons need a square target */
.auth-modal button[aria-label],
.auth-modal [data-auth-close],
.auth-modal [data-profile-modal-close],
.auth-modal [data-profile-form-close],
.auth-modal [data-request-close],
.auth-modal [data-birthday-close],
.auth-modal [data-confirm-close],
.auth-modal [data-toggle-password],
#theme-toggle,
#menu-toggle,
#catalog-search-clear {
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Tab buttons (inbox, sent, category) – keep them comfortable */
[data-inbox-tab],
[data-sent-filter],
[data-category-tab] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

/* Small chips / badges that are interactive */
[data-favorite-toggle],
[data-save-toggle] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Focus-visible ring (keyboard) ---------- */

/* A single, consistent focus ring for every interactive control that
   does not already define one. Uses :where() so specificity stays low
   and existing per-component rings win. */
:where(
  button,
  [role="button"],
  a[href],
  input[type="checkbox"],
  input[type="radio"],
  summary
):focus-visible {
  outline: 2px solid #7c3aed;
  outline-offset: 2px;
}

.dark :where(
  button,
  [role="button"],
  a[href],
  input[type="checkbox"],
  input[type="radio"],
  summary
):focus-visible {
  outline-color: #c4b5fd;
}

/* ---------- Fallback for browsers without :focus-visible ---------- */

@supports not selector(:focus-visible) {
  :where(
    button,
    [role="button"],
    a[href],
    input[type="checkbox"],
    input[type="radio"],
    summary
  ):focus {
    outline: 2px solid #7c3aed;
    outline-offset: 2px;
  }

  .dark :where(
    button,
    [role="button"],
    a[href],
    input[type="checkbox"],
    input[type="radio"],
    summary
  ):focus {
    outline-color: #c4b5fd;
  }
}

/* ---------- Small screens: keep the 44px target ---------- */

@media (max-width: 480px) {
  /* Ensure stacked action buttons keep the 44px target */
  .auth-modal button,
  .auth-modal [role="button"],
  #bulk-action-bar button,
  #bulk-action-bar [role="button"] {
    min-height: 44px;
  }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  /* Global safety net: disable all transitions and animations on
     interactive controls. Component-level rules already do this, but
     this catches anything new that might be added later. */
  button,
  [role="button"],
  a[href],
  input,
  select,
  textarea,
  summary,
  [data-inbox-tab],
  [data-sent-filter],
  [data-category-tab] {
    transition-duration: 0.001ms !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }

  /* Neutralise hover/focus transforms on interactive controls */
  button:hover,
  button:focus,
  button:active,
  [role="button"]:hover,
  [role="button"]:focus,
  [role="button"]:active {
    transform: none !important;
  }
}

/* ---------- Forced colors (Windows High Contrast) ---------- */

@media (forced-colors: active) {
  /* Ensure focus is always visible in forced-colors mode */
  :where(
    button,
    [role="button"],
    a[href],
    input,
    select,
    textarea,
    summary
  ):focus-visible,
  :where(
    button,
    [role="button"],
    a[href],
    input,
    select,
    textarea,
    summary
  ):focus {
    outline: 2px solid Highlight;
    outline-offset: 2px;
    box-shadow: none;
  }

  /* Ensure disabled controls are still distinguishable */
  button:disabled,
  [aria-disabled="true"] {
    color: GrayText;
    border-color: GrayText;
  }
}
