/* Tabs that slide (shared/tabs.js): the white pill under the tab that's picked, and each tab's page coming and going
   under them. Global, unscoped - the leaderboard's tabs (board.css) and the account's (theme.css) are both made with it,
   and say how they look otherwise themselves. */

/* The tabs: a row of buttons, all as wide as each other (a grid of equal columns, --tabs of them with --tabs-gap
   between, 3px in from the edge of the grey track), with the pill under them. Their words are grey, but dark on the
   pill's tab - and on the one nearest it as it's swiped along. */
/* (Of no weight, so a box's own rules come first - the account's tabs stick, rather than sit, for instance) */
:where(.tabs) {
  position: relative;
  isolation: isolate;
}
.tabs > [data-tab] {
  position: relative;
  z-index: 1;
  background: none;
  transition: color 0.2s ease, scale 0.2s cubic-bezier(0.3, 1.4, 0.5, 1);
}
.tabs > [data-tab].is-lit { color: var(--ink); }

.tabs-pill {
  position: absolute;
  z-index: 0;
  top: 3px;
  bottom: 3px;
  left: 3px;
  width: calc((100% - 6px - (var(--tabs, 2) - 1) * var(--tabs-gap, 2px)) / var(--tabs, 2));
  border-radius: 9px;
  background: var(--tab-pill);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 1px rgba(0, 0, 0, 0.04);
  /* At rest, under the tab picked (--at: its place, from 0) - wherever that is as the box changes size */
  transform: translateX(calc(var(--at, 0) * (100% + var(--tabs-gap, 2px))));
  transition: scale 0.2s cubic-bezier(0.3, 1.4, 0.5, 1);
  pointer-events: none;
}
/* Pressed - or held, to be slid along the tabs - it shrinks a little, as on an iPhone, and springs back as it's let go */
.tabs.is-holding > .tabs-pill,
.tabs:has(> [aria-selected="true"]:is(:active, .is-pressed)) > .tabs-pill {
  scale: 0.95;
  transition-duration: 0.12s;
}

/* A count in a tab, beside its name (the leaderboard's: how many are on each board). The name stays in the middle of
   its tab and the count hangs off its end, so a count coming, or changing, moves nothing. In the tab:
   <span class="tabs-label">Name<span class="tabs-count">87</span></span> */
.tabs-label {
  position: relative;
  display: inline-block;
}
.tabs-count {
  position: absolute;
  left: 100%;
  top: 50%;
  translate: 0 -50%;
  margin-left: 6px;
  min-width: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--tab-count);
  color: var(--ink-muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 18px;
  letter-spacing: 0;
  text-align: center;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  transition: background 0.2s ease, color 0.2s ease;
}
.tabs-count:empty { display: none; }
.tabs > [data-tab].is-lit .tabs-count { background: var(--tab-count-lit); color: var(--ink); }

/* Where the pages are: what comes and goes is cut off at its edges */
.tabs-stage { position: relative; }
.tabs-stage.is-moving {
  overflow: hidden;
  overflow: clip;
}
.tabs-page.is-moving { will-change: transform; }
/* Not the tab's page: there, but not seen (tabs.js keeps it from being tapped, focused or read out too). Hidden or
   shown at once: with Reduce Motion on, theme.css gives every transition a moment, which would have a page put away
   seen for a frame more. */
.tabs-page { transition-property: none; }
.tabs-page.tabs-away { visibility: hidden; }

/* The leaderboard's: each page fills the stage, all in the same place, each scrolling itself */
.tabs-stack {
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  overflow: hidden;
  overflow: clip;
}
.tabs-stack > .tabs-page { grid-area: 1 / 1; }

/* The account's: the page showing is in the stage's flow and gives it its height; any other is over it, at its top
   (as far in from the stage's edges as the page in the flow is, --tabs-inset) - and one put away isn't there at all,
   or the card could be scrolled down past the end of a short page as far as a tall one goes */
.tabs-flow > .tabs-page:not(.tabs-base) {
  position: absolute;
  top: 0;
  left: var(--tabs-inset, 0px);
  right: var(--tabs-inset, 0px);
}
.tabs-flow > .tabs-page.tabs-away { display: none; }

/* Tabs.swap's box - the account's calendar, a month at a time: what's on its way off is over what's coming on */
.tabs-swap {
  position: relative;
  overflow: hidden;
  overflow: clip;
}
.tabs-swap > .tabs-swap-out {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
}
