/* ════════════════════════════════════════════════════════════════════════
   DS Tabs primitive (DS sub-step 2 — primitive 7)
   New namespace: .ds-tabs / .ds-tab. Consolidates 4 existing tab systems
   (.tab-bar/.tab-item, .settings-tabs/.settings-tab, .sl-tabs/.sl-tab,
   .view-tab) — each migrates template-by-template in the migration
   sub-phase. Consumes tokens.css. No JS (URL-driven active state).

   Variants:
     default              — underline tabs (anchor link + border-bottom on active)
     .ds-tabs--pill       — pill/chip filter tabs (background fill on active)
     .ds-tabs--scroll     — horizontal scroll + hidden scrollbar for overflow

   Per-tab modifiers:
     .ds-tab--active                — applied to current tab (URL-driven)
     .ds-tab--accent-{red,amber,green,grey}  — semantic color (matches Card)
     .ds-tab-count                  — inline count badge child

   A11y: :focus-visible ring on .ds-tab (matches Button/Input/Card precedent).
   ARIA roles (role="tablist" / role="tab" / aria-selected) left to consumer
   for proper tabpanel pattern — this primitive styles the visual layer.
   ════════════════════════════════════════════════════════════════════════ */

.ds-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  gap: 0;
  margin-bottom: var(--sp-6);
}

.ds-tab {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-5);
  font-family: inherit;
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--gray-500);
  text-decoration: none;
  border: none;
  background: transparent;
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;          /* overlap container border */
  transition: color var(--dur) var(--ease),
              border-color var(--dur) var(--ease),
              background var(--dur) var(--ease);
}

.ds-tab:hover { color: var(--accent); }

.ds-tab--active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.ds-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  border-radius: var(--radius-sm);
}

/* ── Pill variant — filter chips, no underline ──────────── */
.ds-tabs--pill {
  border-bottom: none;
  gap: var(--sp-2);
  flex-wrap: wrap;
}
.ds-tabs--pill .ds-tab {
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--card);
  margin-bottom: 0;
}
.ds-tabs--pill .ds-tab:hover { background: var(--accent-bg); border-color: var(--accent-soft); color: var(--accent); }
.ds-tabs--pill .ds-tab--active {
  background: var(--accent);
  color: var(--cf-on-accent);
  border-color: var(--accent);
}
.ds-tabs--pill .ds-tab--active:hover { background: var(--accent-soft); border-color: var(--accent-soft); color: var(--cf-on-accent); }

/* ── Scroll overflow ────────────────────────────────────── */
.ds-tabs--scroll {
  overflow-x: auto;
  flex-wrap: nowrap;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.ds-tabs--scroll::-webkit-scrollbar { display: none; }

/* ── Count badge (inline child of .ds-tab) ──────────────── */
.ds-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  padding: 0 6px;
  height: 18px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--muted);
  background: var(--gray-100);
  line-height: 1;
}
.ds-tab--active .ds-tab-count { background: var(--accent-bg); color: var(--accent); }
.ds-tabs--pill .ds-tab--active .ds-tab-count {
  background: color-mix(in srgb, var(--cf-on-accent) 25%, transparent);
  color: var(--cf-on-accent);
}

/* ── Semantic accents — work on BOTH variants ───────────── */
/* Pill variant: accent fills the pill background when active. */
.ds-tabs--pill .ds-tab--accent-red.ds-tab--active    { background: var(--error);   border-color: var(--error); }
.ds-tabs--pill .ds-tab--accent-amber.ds-tab--active  { background: var(--warning); border-color: var(--warning); }
.ds-tabs--pill .ds-tab--accent-orange.ds-tab--active { background: var(--orange);  border-color: var(--orange); }
.ds-tabs--pill .ds-tab--accent-green.ds-tab--active  { background: var(--success); border-color: var(--success); }
.ds-tabs--pill .ds-tab--accent-grey.ds-tab--active   { background: var(--gray-500); border-color: var(--gray-500); }
.ds-tabs--pill .ds-tab--accent-red:not(.ds-tab--active)    { border-color: var(--error);   color: var(--error); }
.ds-tabs--pill .ds-tab--accent-amber:not(.ds-tab--active)  { border-color: var(--warning); color: var(--warning); }
.ds-tabs--pill .ds-tab--accent-orange:not(.ds-tab--active) { border-color: var(--orange);  color: var(--orange); }
.ds-tabs--pill .ds-tab--accent-green:not(.ds-tab--active)  { border-color: var(--success); color: var(--success); }
.ds-tabs--pill .ds-tab--accent-grey:not(.ds-tab--active)   { border-color: var(--gray-400); color: var(--muted); }

/* Underline variant: accent tints :hover text + active count badge bg
   (underline border stays accent regardless — matches sl-tab precedent). */
.ds-tabs:not(.ds-tabs--pill) .ds-tab--accent-red:hover    { color: var(--error); }
.ds-tabs:not(.ds-tabs--pill) .ds-tab--accent-amber:hover  { color: var(--warning); }
.ds-tabs:not(.ds-tabs--pill) .ds-tab--accent-orange:hover { color: var(--orange); }
.ds-tabs:not(.ds-tabs--pill) .ds-tab--accent-green:hover  { color: var(--success); }
.ds-tabs:not(.ds-tabs--pill) .ds-tab--accent-grey:hover   { color: var(--muted); }

.ds-tabs:not(.ds-tabs--pill) .ds-tab--accent-red.ds-tab--active .ds-tab-count    { background: var(--error);   color: var(--cf-on-accent); }
.ds-tabs:not(.ds-tabs--pill) .ds-tab--accent-amber.ds-tab--active .ds-tab-count  { background: var(--warning); color: var(--cf-on-accent); }
.ds-tabs:not(.ds-tabs--pill) .ds-tab--accent-orange.ds-tab--active .ds-tab-count { background: var(--orange);  color: var(--cf-on-accent); }
.ds-tabs:not(.ds-tabs--pill) .ds-tab--accent-green.ds-tab--active .ds-tab-count  { background: var(--success); color: var(--cf-on-accent); }
.ds-tabs:not(.ds-tabs--pill) .ds-tab--accent-grey.ds-tab--active .ds-tab-count   { background: var(--gray-500); color: var(--cf-on-accent); }
