/*
 * Tab styling for Event Analytics.
 *
 * Mantine's default tab indicator is a 2px bottom border in the primary colour.
 * Against the dark theme's low-contrast surface that border was almost invisible,
 * so the selected tab read the same as the unselected ones. This gives the active
 * tab a filled pill instead — a shape change, not just a colour change, so it is
 * legible in both schemes and without relying on colour perception.
 */
/*
 * One source for the selected colour, in both schemes.
 *
 * Hover and selected were each written out with their own `light-dark()`,
 * which meant the hover was only *about* the right colour rather than derived
 * from it, and a `light-dark()` nested inside `color-mix()` is not resolved
 * consistently across browsers — in dark mode it could land on the wrong base
 * or none at all. The pill colour is now a variable per scheme, and every
 * other state is mixed from that variable, so they cannot drift.
 */
.tab {
  --tab-active-bg: var(--mantine-color-dark-8);
  --tab-active-fg: var(--mantine-color-white);

  border: none;
  border-radius: var(--mantine-radius-md);
  font-weight: 600;
  color: var(--mantine-color-gray-7);
  transition:
    background-color 140ms ease,
    color 140ms ease;
}

/*
 * Dark mode inverts the pill: a near-white surface with near-black text.
 *
 * Scoped by the attribute Mantine sets on <html>, rather than `light-dark()`,
 * so the value is a plain colour that `color-mix()` below can rely on.
 */
:global([data-mantine-color-scheme="dark"]) .tab {
  --tab-active-bg: var(--mantine-color-dark-0);
  --tab-active-fg: var(--mantine-color-dark-9);

  color: var(--mantine-color-dark-1);
}

/*
 * Hovering an unselected tab previews the pill at a quarter weight.
 *
 * Literally the selected colour, diluted — so the hover reads as "this is what
 * you would select" in either scheme, and can never be mistaken for the
 * selection itself.
 */
.tab:hover {
  background-color: color-mix(in srgb, var(--tab-active-bg) 25%, transparent);
}

.tab[data-active] {
  background-color: var(--tab-active-bg);
  /* Inverted against the pill, so contrast holds whichever scheme is active. */
  color: var(--tab-active-fg);
}

/*
 * The selected tab lightens slightly under the pointer — enough to answer it,
 * not enough to read as a different state. Mixed from the same variable, so
 * both schemes lighten by the same amount rather than by hand-picked shades
 * that happened to differ.
 */
.tab[data-active]:hover {
  background-color: color-mix(in srgb, var(--tab-active-bg) 85%, transparent);
  color: var(--tab-active-fg);
}

/* The pills carry the emphasis; the rule under them would only add noise. */
.tabList {
  border-bottom: none;
  gap: 6px;

  /*
   * Scrolls sideways rather than wrapping.
   *
   * Three tabs with icons do not fit a 390px screen. Wrapping put one tab on
   * its own row under the other two, which reads as a second, unrelated
   * control; scrolling keeps them as one strip. The scrollbar itself is hidden
   * — the partially visible third tab is the affordance.
   */
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabList::-webkit-scrollbar {
  display: none;
}

.tabList > * {
  flex-shrink: 0;
}
