@layer base {
  /* Base UI portals popups to the body; isolating the app root keeps them above any z-index inside it. */
  #app {
    isolation: isolate;
  }

  .svg-icon {
    width: var(--icon-size, 1em);
    height: var(--icon-size, 1em);
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
  }
}

@layer components {
  .dropdown-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    text-align: left;
  }

  .dropdown-value {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Popup of a Base UI Select or Combobox; its Positioner places it and provides the anchor variables.
     The popup keeps its frame and only its list scrolls, as in the Base UI docs. */
  .dropdown-menu {
    position: relative;
    display: flex;
    flex-direction: column;
    max-width: var(--available-width);
    max-height: min(20rem, var(--available-height));
  }

  /* Base UI measures item offsets against the list, so it must be their offset parent. */
  .dropdown-list {
    position: relative;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scroll-padding-block: 1rem;
  }

  /* Base UI positions the Select scroll arrows absolutely over the list edges. */
  .dropdown-scroll-arrow {
    display: flex;
    height: 1rem;
    align-items: center;
    justify-content: center;
    inset-inline: 0.25rem;
    z-index: 1;
    background: inherit;
    cursor: default;
  }

  .dropdown-scroll-arrow[data-direction="up"] {
    top: 0.25rem;
  }

  .dropdown-scroll-arrow[data-direction="down"] {
    bottom: 0.25rem;
  }

  /* Long labels wrap inside the row, so the list only scrolls vertically. */
  .dropdown-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    overflow-wrap: anywhere;
  }

  /* One thin scrollbar for regions that scroll inside popups and dialogs. Blink ignores the WebKit pseudo-elements
     once scrollbar-width or scrollbar-color is set and then still draws arrow buttons, so the standard properties
     only apply where the pseudo-elements are unsupported (Firefox). */
  .dropdown-list,
  .dialog-body,
  .answer-region {
    @supports not selector(::-webkit-scrollbar) {
      scrollbar-width: thin;
      scrollbar-color: var(--color-scrollbar) transparent;
    }

    &::-webkit-scrollbar {
      width: 6px;
      height: 6px;
    }

    &::-webkit-scrollbar-thumb {
      border-radius: 3px;
      background: var(--color-scrollbar);
    }

    &::-webkit-scrollbar-track,
    &::-webkit-scrollbar-corner {
      background: transparent;
    }
  }
}
