#roles {
  --role-edge: rgb(237 219 197 / 14%);
  --role-accent: #ffb079;
  --role-curve: cubic-bezier(.22, .72, .25, 1);
}

#roles .role-tabs {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--role-count, 3), minmax(0, 1fr));
  align-items: stretch;
  background: #202123;
  border: 1px solid var(--role-edge);
  border-radius: 18px 18px 0 0;
}

#roles .role-tabs::after {
  content: "";
  position: absolute;
  inset: auto auto -1px 0;
  height: 2px;
  width: calc(100% / var(--role-count, 3));
  background: #fa9960;
  transform: translateX(calc(var(--role-index, 0) * 100%));
  transition: transform 300ms var(--role-curve);
  pointer-events: none;
}

#roles .role-tabs button {
  min-width: 0;
  min-height: 46px;
  padding: clamp(11px, 1.1vw, 20px) 4px;
  background: transparent;
  border: 0;
  border-radius: 0;
  color: #bebbb8;
  font: inherit;
  font-size: clamp(14px, 1.25vw, 22px);
  font-weight: 600;
  transition: color 180ms ease;
}

#roles .role-tabs button:hover { color: #fff; filter: none; }
#roles .role-tabs button[aria-selected="true"] { color: var(--role-accent); }
#roles :is(button, [role="tabpanel"]):focus-visible {
  outline: 2px solid var(--role-accent);
  outline-offset: -5px;
}

#roles [data-panel] {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: clamp(320px, 30vw, 520px);
  margin: 0;
  padding: clamp(28px, 4.5vw, 88px);
  border: 1px solid var(--role-edge);
  border-top-width: 0;
  border-radius: 0 0 18px 18px;
  background: radial-gradient(ellipse at 85% 80%, #41372c 0, transparent 55%), #202123;
}

#roles [data-panel]::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  background: url(imgVector12.svg) right -2vw bottom -9vw / 60% auto no-repeat;
  opacity: .28;
  pointer-events: none;
}

#roles [data-panel]::after {
  content: "";
  position: absolute;
  inset: 4% 0 0 49%;
  z-index: -1;
  background: var(--role-image) center / contain no-repeat;
  pointer-events: none;
}

#civil { --role-image: url(img23.png); }
#patrol { --role-image: url(patrol-figma.webp); }
#medic { --role-image: url(medic-figma.webp); }

#roles [data-panel] h3 {
  max-width: 50%;
  font-size: clamp(30px, 3.8vw, 76px);
  line-height: 1.03;
  letter-spacing: -.045em;
  text-wrap: balance;
}

#roles [data-panel] p {
  width: 47%;
  max-width: 39ch;
  margin-top: clamp(14px, 1.5vw, 24px);
  color: #d2ceca;
  font-size: clamp(16px, 1.3vw, 23px);
  line-height: 1.55;
}

@media (max-width: 700px) {
  #roles .role-tabs button { font-size: clamp(12px, 3.5vw, 15px); }
  #roles [data-panel] { padding: 24px 18px 8px; min-height: auto; }
  #roles [data-panel] h3, #roles [data-panel] p { width: 100%; max-width: none; }
  #roles [data-panel] p { margin-top: 10px; }
  #roles [data-panel]::after {
    position: relative;
    inset: auto;
    width: 100%;
    height: clamp(170px, 48vw, 260px);
    margin-top: 12px;
    order: 1;
    background-position: center bottom;
  }
}

@media (prefers-reduced-motion: no-preference) {
  #roles.role-changed [data-panel]:not([hidden])::after {
    animation: role-art-in 450ms var(--role-curve) both;
  }
  #roles.role-changed [data-panel]:not([hidden]) > :is(h3, p) {
    animation: role-copy-in 290ms var(--role-curve) both;
  }
  #roles.role-changed [data-panel]:not([hidden]) p { animation-delay: 45ms; }
}

@keyframes role-art-in {
  from { opacity: .15; transform: translateX(14px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes role-copy-in {
  from { opacity: .15; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  #roles .role-tabs::after, #roles .role-tabs button { transition: none; }
}
