/* Tabs
   A tabbed panel that works without JavaScript. Hidden radios (one group via a
   shared name) drive which label is active and which panel shows. Supports up
   to five tabs. Colour and type come from tokens.css.

   Structure: radios first, then .dp-tablist (labels), then .dp-tabpanels
   (panels). Match each label's `for` to a radio id, and keep label and panel
   order in step. */

.dp-tabs {
  display: block;
}

.dp-tab-radio {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.dp-tablist {
  display: flex;
  flex-wrap: wrap;
  gap: var(--dp-space-1);
  border-bottom: 1px solid var(--dp-border);
}

.dp-tab {
  display: inline-flex;
  align-items: center;
  gap: var(--dp-space-2);
  padding: var(--dp-space-3) var(--dp-space-4);
  font-weight: var(--dp-weight-bold);
  font-size: var(--dp-text-sm);
  color: var(--dp-text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--dp-transition), border-color var(--dp-transition);
}

.dp-tab:hover {
  color: var(--dp-navy);
}

.dp-tabpanels {
  padding-top: var(--dp-space-5);
}

.dp-tabpanel {
  display: none;
  color: var(--dp-text-muted);
}

/* Show the panel whose index matches the checked radio */
.dp-tab-radio:nth-of-type(1):checked ~ .dp-tabpanels .dp-tabpanel:nth-child(1),
.dp-tab-radio:nth-of-type(2):checked ~ .dp-tabpanels .dp-tabpanel:nth-child(2),
.dp-tab-radio:nth-of-type(3):checked ~ .dp-tabpanels .dp-tabpanel:nth-child(3),
.dp-tab-radio:nth-of-type(4):checked ~ .dp-tabpanels .dp-tabpanel:nth-child(4),
.dp-tab-radio:nth-of-type(5):checked ~ .dp-tabpanels .dp-tabpanel:nth-child(5) {
  display: block;
}

/* Mark the matching label active */
.dp-tab-radio:nth-of-type(1):checked ~ .dp-tablist .dp-tab:nth-child(1),
.dp-tab-radio:nth-of-type(2):checked ~ .dp-tablist .dp-tab:nth-child(2),
.dp-tab-radio:nth-of-type(3):checked ~ .dp-tablist .dp-tab:nth-child(3),
.dp-tab-radio:nth-of-type(4):checked ~ .dp-tablist .dp-tab:nth-child(4),
.dp-tab-radio:nth-of-type(5):checked ~ .dp-tablist .dp-tab:nth-child(5) {
  color: var(--dp-navy);
  border-bottom-color: var(--dp-blue-700);
}

/* Keyboard focus ring on the matching label */
.dp-tab-radio:nth-of-type(1):focus-visible ~ .dp-tablist .dp-tab:nth-child(1),
.dp-tab-radio:nth-of-type(2):focus-visible ~ .dp-tablist .dp-tab:nth-child(2),
.dp-tab-radio:nth-of-type(3):focus-visible ~ .dp-tablist .dp-tab:nth-child(3),
.dp-tab-radio:nth-of-type(4):focus-visible ~ .dp-tablist .dp-tab:nth-child(4),
.dp-tab-radio:nth-of-type(5):focus-visible ~ .dp-tablist .dp-tab:nth-child(5) {
  outline: none;
  box-shadow: var(--dp-shadow-focus);
  border-radius: var(--dp-radius-xs) var(--dp-radius-xs) 0 0;
}
