html {
  --rocm-docs-selector-border-radius: 2px;
  --rocm-docs-selector-accent-color: var(--pst-color-primary);
  --rocm-docs-selector-bg-color: var(--pst-color-on-background);
  --rocm-docs-selector-fg-color: var(--pst-color-text-base);
  --rocm-docs-selector-selected-fg-color: var(--pst-color-primary-text);
  --rocm-docs-selector-group-heading-bg-color: var(--pst-color-surface);
  --rocm-docs-selector-option-hover-color: var(--pst-color-link-hover);
  --rocm-docs-selector-option-selected-color: var(--pst-color-primary);
  --rocm-docs-selector-tile-padding: 0.25rem 0.75rem;
  --rocm-docs-selector-tile-gap: 0.5rem;
}

html[data-theme="light"] {
  --rocm-docs-selector-border-color: var(--pst-gray-400);
  --rocm-docs-selector-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --rocm-docs-selector-shadow-hover: 0 2px 8px rgba(0, 0, 0, 0.15);
}

html[data-theme="dark"] {
  --rocm-docs-selector-border-color: var(--pst-color-border);
  --rocm-docs-selector-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  --rocm-docs-selector-shadow-hover: 0 2px 8px rgba(0, 0, 0, 0.4);
}

/* Avoid odd sizing interactions with Bootstrap width utilities */
.rocm-docs-selector-group,
.rocm-docs-selector-group * {
  box-sizing: border-box;
}

/* Hide selectors during initialization to prevent FOUC */
.rocm-docs-selector-group:not(.rocm-docs-selector-initialized) {
  visibility: hidden;
}

.rocm-docs-selector-group.rocm-docs-selector-initialized {
  visibility: visible;
}

@supports selector(.x:has(.y)) {
  .rocm-docs-selector-group:has(
      .rocm-docs-selector-option:hover,
      .ts-control:hover,
      .ts-dropdown:hover
    )
    .rocm-docs-selector-group-heading {
    border-right-color: var(--rocm-docs-selector-option-hover-color);
  }
}

/* Selector group heading box */
.rocm-docs-selector-group-heading {
  background-color: var(--rocm-docs-selector-group-heading-bg-color);
  padding: var(--rocm-docs-selector-tile-padding) !important;
  font-weight: 600;
  border-right: solid 3px var(--rocm-docs-selector-accent-color);
  border-radius: var(--rocm-docs-selector-border-radius);
  transition: border-color 0.25s ease;
  box-shadow: var(--rocm-docs-selector-shadow);
}

/* Selector group heading text */
.rocm-docs-selector-group-heading > span {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

/* Selector option */
.rocm-docs-selector-option {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;

  background-color: var(--rocm-docs-selector-bg-color);
  padding: var(--rocm-docs-selector-tile-padding) !important;
  border: solid 2px var(--rocm-docs-selector-border-color);
  border-radius: var(--rocm-docs-selector-border-radius);
  box-shadow: var(--rocm-docs-selector-shadow);

  cursor: pointer;
  user-select: none;

  transition:
    background-color 0.2s ease,
    color 0.2s ease,
    transform 0.2s ease,
    box-shadow 0.2s ease,
    border-color 0.2s ease;
}

/* Hover (not disabled) */
.rocm-docs-selector-option:hover:not(.rocm-docs-disabled) {
  background-color: var(--rocm-docs-selector-option-hover-color);
  color: var(--rocm-docs-selector-selected-fg-color);
  transform: translateY(-2px);
  box-shadow: var(--rocm-docs-selector-shadow-hover);
}

/* Keep it above neighbors if it gets an outline/box-shadow */
.rocm-docs-selector-option:focus:not(.rocm-docs-disabled) {
  position: relative;
  z-index: 1;
}

/* Selected */
.rocm-docs-selector-option.rocm-docs-selected {
  background-color: var(--rocm-docs-selector-option-selected-color);
  color: var(--rocm-docs-selector-selected-fg-color);
}

/* Prevent hover lift on selected (keeps it steady) */
.rocm-docs-selector-option.rocm-docs-selected:hover {
  transform: none;
}

/* Disabled */
.rocm-docs-selector-option.rocm-docs-disabled {
  background-color: var(--rocm-docs-selector-border-color);
  color: var(--rocm-docs-selector-selected-fg-color);
  cursor: not-allowed;
  pointer-events: none;
  opacity: 0.75;
}

/* Hidden state */
.rocm-docs-hidden {
  display: none;
}


/* Put selected option summary in secondary page-level TOC on a new line */
.rocm-docs-selector-toc2-item .nav-link span {
  display: block;
  padding-left: 1rem;
}

@media (max-width: 768px) {
  .rocm-docs-selector-group {
    row-gap: var(--rocm-docs-selector-tile-gap);
  }
}

@media (max-width: 576px) {
  .rocm-docs-selector-option {
    flex: 0 0 100%;
    max-width: 100%;
  }
}

@media (max-width: 440px) {
  .rocm-docs-selector-group-heading {
    flex: 0 0 100%;
    max-width: 100%;

    /* When stacked, puth the accent on the bottom */
    border-right: 0;
    border-bottom: solid 3px var(--rocm-docs-selector-accent-color);
  }

  .rocm-docs-selector-group.row .row {
    flex: 0 0 100%;
    max-width: 100%;
  }

  .rocm-docs-selector-option {
    flex: 0 0 100%;
    max-width: 100%;
  }
}

/* Motion reduction */
@media (prefers-reduced-motion: reduce) {
  .rocm-docs-selector-group.rocm-docs-selector-initialized {
    animation: none;
  }

  .rocm-docs-selector-option {
    transition: none;
  }

  .rocm-docs-selector-option:hover:not(.rocm-docs-disabled) {
    transform: none;
  }
}

/* Tom Select */
.ts-dropdown {
  border: solid 2px var(--rocm-docs-selector-border-color);
}

.ts-dropdown-content {
  background-color: var(--rocm-docs-selector-bg-color);
  color: var(--rocm-docs-selector-fg-color);
  border: solid 1px var(--rocm-docs-selector-border-color);
}

/* Taller dropdown (more items before scroll) */
.ts-dropdown .ts-dropdown-content {
  max-height: 420px;
}

.page-toc .ts-dropdown-content .option {
  font-size: 0.88rem;
  padding-top: 0.33rem;
  padding-bottom: 0.33rem;
}

.ts-dropdown-content .option:hover {
  background-color: var(--rocm-docs-selector-option-hover-color);
  color: var(--rocm-docs-selector-selected-fg-color);
}

.ts-dropdown-content div[aria-selected="true"] {
  background-color: var(--rocm-docs-selector-group-heading-bg-color);
  color: var(--rocm-docs-selector-fg-color);
}

.dropdown-input-wrap {
  background-color: var(--rocm-docs-selector-bg-color);
  border: solid 2px var(--rocm-docs-selector-border-color);
}

.ts-dropdown-input {
  background-color: var(--rocm-docs-selector-bg-color);
  color: var(--rocm-docs-selector-fg-color);
}

.ts-wrapper {
  background-color: var(--rocm-docs-selector-option-selected-color);
  border: solid 2px var(--rocm-docs-selector-border-color);
  border-radius: var(--rocm-docs-selector-border-radius);
}

.ts-wrapper:hover {
  background-color: var(--rocm-docs-selector-option-hover-color);
}

.ts-wrapper .item {
  color: var(--rocm-docs-selector-selected-fg-color);
}

.page-toc .ts-wrapper {
  background-color: var(--rocm-docs-selector-bg-color);
}

.page-toc .ts-wrapper .item {
    color: var(--rocm-docs-selector-fg-color);
  font-size: 0.88rem !important;
}

.sidebar-secondary-item {
  width: 100%;
}

.bd-sidebar-secondary {
  height: 100%;
}
