/* ============================================
   InfluenceHub – Saved profiles tab a11y
   - Visible :focus-visible ring for #tab-saved
     (the "Įsimintieji" catalog tab) so keyboard
     users can see which tab is focused.
   - 44px minimum touch target (WCAG 2.5.5) for
     mobile users on the tab and its count badge.
   - Dark mode, prefers-reduced-motion and
     forced-colors support.
   ============================================ */

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

#tab-saved {
  /* WCAG 2.5.5 – minimum 44x44px touch target for mobile users */
  min-height: 44px;
  min-width: 44px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
}

/* The count badge is a small counter inside the tab – keep it visually
   compact but guarantee a tappable area for users who tap directly on
   the badge. */
#saved-count {
  min-height: 1.375rem;
  min-width: 1.375rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

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

/* High-contrast, always-visible ring for keyboard users. The ring is
   drawn with both an outline and a box-shadow halo so it stays visible
   against the light tab background and the dark-mode surface. */
#tab-saved:focus-visible {
  outline: 2px solid #7c3aed;
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.25);
}

/* The tab uses a white fill in light mode – add a violet inner ring so
   the outline stays visible against the white surface. */
#tab-saved:focus-visible {
  outline: 2px solid #7c3aed;
  outline-offset: 2px;
  box-shadow:
    0 0 0 2px #ffffff,
    0 0 0 6px rgba(124, 58, 237, 0.35);
}

/* The active tab uses a dark slate fill in light mode – add a white
   inner ring so the violet outline stays visible against the dark fill. */
#tab-saved.tab-active:focus-visible {
  outline: 2px solid #7c3aed;
  outline-offset: 2px;
  box-shadow:
    0 0 0 2px #ffffff,
    0 0 0 6px rgba(124, 58, 237, 0.35);
}

/* The count badge sits inside the tab – give it its own ring so keyboard
   users can see it when it is focused directly (e.g. via tab order). */
#saved-count:focus-visible {
  outline: 2px solid #7c3aed;
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.25);
}

/* ---------- Dark mode ---------- */

.dark #tab-saved:focus-visible {
  outline-color: #c4b5fd;
  box-shadow:
    0 0 0 2px #0f172a,
    0 0 0 6px rgba(196, 181, 253, 0.45);
}

.dark #tab-saved.tab-active:focus-visible {
  outline-color: #c4b5fd;
  box-shadow:
    0 0 0 2px #0f172a,
    0 0 0 6px rgba(196, 181, 253, 0.45);
}

.dark #saved-count:focus-visible {
  outline-color: #c4b5fd;
  box-shadow: 0 0 0 4px rgba(196, 181, 253, 0.35);
}

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

@supports not selector(:focus-visible) {
  #tab-saved:focus {
    outline: 2px solid #7c3aed;
    outline-offset: 2px;
    box-shadow:
      0 0 0 2px #ffffff,
      0 0 0 6px rgba(124, 58, 237, 0.35);
  }

  #saved-count:focus {
    outline: 2px solid #7c3aed;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.25);
  }

  .dark #tab-saved:focus {
    outline-color: #c4b5fd;
    box-shadow:
      0 0 0 2px #0f172a,
      0 0 0 6px rgba(196, 181, 253, 0.45);
  }

  .dark #saved-count:focus {
    outline-color: #c4b5fd;
    box-shadow: 0 0 0 4px rgba(196, 181, 253, 0.35);
  }
}

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

@media (max-width: 480px) {
  #tab-saved {
    min-height: 44px;
    min-width: 44px;
  }
}

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

@media (prefers-reduced-motion: reduce) {
  #tab-saved,
  #saved-count {
    transition: none !important;
    animation: none !important;
    transform: none !important;
  }

  /* Neutralise any hover/focus transform so no motion is perceived */
  #tab-saved:hover,
  #tab-saved:focus,
  #tab-saved:active,
  #saved-count:hover,
  #saved-count:focus,
  #saved-count:active {
    transform: none !important;
    transition: none !important;
  }

  /* Keep the focus ring visible but static (no animated halo) */
  #tab-saved:focus-visible {
    box-shadow:
      0 0 0 2px #ffffff,
      0 0 0 6px rgba(124, 58, 237, 0.35) !important;
  }

  .dark #tab-saved:focus-visible {
    box-shadow:
      0 0 0 2px #0f172a,
      0 0 0 6px rgba(196, 181, 253, 0.45) !important;
  }

  #saved-count:focus-visible {
    box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.25) !important;
  }

  .dark #saved-count:focus-visible {
    box-shadow: 0 0 0 4px rgba(196, 181, 253, 0.35) !important;
  }
}

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

@media (forced-colors: active) {
  #tab-saved {
    border: 1px solid CanvasText;
    color: CanvasText;
    background: Canvas;
  }

  #tab-saved:hover {
    background: Highlight;
    color: HighlightText;
  }

  #tab-saved.tab-active {
    background: Highlight;
    color: HighlightText;
    border-color: Highlight;
  }

  #tab-saved:focus-visible,
  #tab-saved:focus {
    outline: 2px solid Highlight;
    outline-offset: 2px;
    box-shadow: none;
    background: Highlight;
    color: HighlightText;
  }

  #saved-count {
    background: Highlight;
    color: HighlightText;
    border: 1px solid HighlightText;
  }

  #saved-count:focus-visible,
  #saved-count:focus {
    outline: 2px solid Highlight;
    outline-offset: 2px;
    box-shadow: none;
  }
}
