/*
 * Integration code samples (js/codetabs.js): a switch as wide as the window, whose dark thumb
 * slides to the chosen sample, above one dark window in which the samples slide sideways. Without the script every
 * sample is a window of its own, one under another. Tokens come from styles.css.
 */

.codetabs {
  --codetabs-ease: cubic-bezier(0.22, 1, 0.36, 1);
  min-width: 0;
  max-width: 100%;
}

/* ------------------------------------------------------------------ switch */

.codetabs-bar {
  position: relative;
  display: flex;
  margin-bottom: 16px;
  padding: 4px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  scrollbar-width: none;
}

.codetabs-bar::-webkit-scrollbar {
  display: none;
}

.codetabs-bar[hidden] {
  display: none;
}

/* the script sets its width and position from the active tab */
.codetabs-thumb {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 0;
  width: 0;
  border-radius: 999px;
  background: var(--ink);
  pointer-events: none;
  transition:
    transform 0.45s var(--codetabs-ease),
    width 0.45s var(--codetabs-ease);
}

.codetabs-thumb.is-static {
  transition: none;
}

.codetabs-tab {
  position: relative;
  flex: 1 1 0;
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 650;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.25s ease;
}

.codetabs-tab:hover {
  color: var(--ink);
}

.codetabs-tab[aria-selected="true"] {
  color: #ffffff;
}

/* the bar scrolls on the narrowest screens, so the ring stays inside its 4px padding */
.codetabs-tab:focus-visible {
  outline-width: 2px;
  outline-offset: 1px;
  border-radius: 999px;
}

/* ----------------------------------------------------------------- windows */

.codetabs-stage {
  display: grid;
  gap: 16px;
}

.codetabs-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--dark);
  color: var(--on-dark);
}

.codetabs-panel[hidden] {
  display: none;
}

/* With the script the samples share one window: stacked in one grid cell, so the tallest sets
   its height and switching never moves the page. A hidden sample keeps its place unseen. */
.codetabs[data-ready] .codetabs-stage {
  gap: 0;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--dark);
}

.codetabs[data-ready] .codetabs-panel {
  grid-area: 1 / 1;
  border-radius: 0;
  background: none;
}

.codetabs[data-ready] .codetabs-panel[hidden] {
  display: flex;
  visibility: hidden;
}

.codetabs-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  padding: 8px 10px 8px 20px;
  border-bottom: 1px solid #2f2f39;
}

.codetabs-title {
  min-width: 0;
  color: var(--on-dark-muted);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.3;
}

.codetabs-copy {
  flex: none;
  min-height: 36px;
  padding: 0 16px;
  border: 1.5px solid #4a4a56;
  border-radius: 100px;
  background: transparent;
  color: #fff;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 650;
  cursor: pointer;
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease;
}

/* copying needs the script */
.codetabs:not([data-ready]) .codetabs-copy {
  display: none;
}

.codetabs-copy:hover {
  background: #2a2a33;
}

.codetabs-copy[data-copied] {
  border-color: #a7e3b7;
  color: #a7e3b7;
}

.codetabs-panel :focus-visible {
  outline-color: #ffffff;
}

.codetabs-pre {
  flex: 1;
  margin: 0;
  padding: 18px 20px 20px;
  overflow: auto;
  color: var(--on-dark);
  font-family: var(--mono);
  font-size: 0.8125rem;
  line-height: 1.6;
  white-space: pre;
  tab-size: 2;
}

.codetabs-pre:focus-visible {
  outline-offset: -3px;
  border-radius: 0 0 var(--radius) var(--radius);
}

/* syntax colours (same palette as the .code block of the page) */
.codetabs .tag,
.codetabs .k {
  color: #ff9a62;
}

.codetabs .attr {
  color: #c7c7d1;
}

.codetabs .value,
.codetabs .s {
  color: #a7e3b7;
}

.codetabs .f {
  color: #9cc7ff;
}

.codetabs .c {
  color: #8d8d9a;
}

.codetabs-status {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 640px) {
  .codetabs-tab {
    padding: 0 8px;
    font-size: 0.875rem;
  }

  .codetabs-pre {
    padding: 16px;
    font-size: 0.78125rem;
  }

  .codetabs-head {
    padding-left: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .codetabs-thumb,
  .codetabs-tab {
    transition: none;
  }
}

/* the left column keeps its place next to the window */
.split:has(.codetabs) {
  align-items: start;
}
