/* Tabs — WAI-ARIA tabs pattern with refined underline styling.
 * Horizontal scroll on narrow viewports. */

.tabs {
  display: flex;
  gap: 0.125rem;
  border-bottom: 1px solid var(--pico-muted-border-color);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 0 0.125rem;
}

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

/* Override Pico's default filled-button styling — tabs are text-like, not
 * primary actions. Covers base, hover, focus, active states. */
button.tabs__tab,
button.tabs__tab:hover,
button.tabs__tab:focus,
button.tabs__tab:active,
button.tabs__tab:is([aria-selected="true"]) {
  --pico-background-color: transparent;
  --pico-border-color: transparent;
  --pico-box-shadow: none;
}

button.tabs__tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.625rem 1rem;
  background: transparent;
  border: none;
  box-shadow: none;
  color: var(--pico-muted-color);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  margin-bottom: -1px;
  border-radius: var(--pico-border-radius) var(--pico-border-radius) 0 0;
  transition:
    color 0.15s ease,
    background-color 0.15s ease;
}

/* Active underline is an ::after so transitions are smooth and it sits
 * flush with the tablist border without collapsing layout. */
button.tabs__tab::after {
  content: "";
  position: absolute;
  left: 0.75rem;
  right: 0.75rem;
  bottom: 0;
  height: 3px;
  background-color: transparent;
  border-radius: 3px 3px 0 0;
  transition: background-color 0.15s ease;
}

button.tabs__tab:hover {
  color: var(--pico-color);
  background-color: rgba(0, 0, 0, 0.04);
}

button.tabs__tab[aria-selected="true"] {
  color: var(--pico-primary-color, #1976d2);
}

button.tabs__tab[aria-selected="true"]::after {
  background-color: var(--pico-primary-color, #1976d2);
}

button.tabs__tab:focus-visible {
  outline: 2px solid var(--pico-primary-focus, #1976d2);
  outline-offset: -2px;
}

.tabs__tab-label {
  line-height: 1;
}

.tabs__badge {
  display: inline-block;
  min-width: 1.375rem;
  padding: 0 0.4375rem;
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1.375rem;
  text-align: center;
  border-radius: 999px;
  background-color: var(--pico-muted-border-color);
  color: var(--pico-muted-color);
  transition:
    background-color 0.15s ease,
    color 0.15s ease;
}

button.tabs__tab[aria-selected="true"] .tabs__badge {
  background-color: var(--pico-primary-color, #1976d2);
  color: #fff;
}

.tabs__panel[hidden] {
  display: none;
}

.tabs__panel {
  padding-top: 1rem;
}
