.ui-image-list {
  --ui-image-list-size: 100px;
  position: relative;
}

.ui-image-list__strip {
  display: flex;
  gap: 8px;
  margin: 0;
  padding: 4px;
  list-style: none;
  overflow-x: auto;
  overflow-y: hidden;
  color: var(--ui-text, #d6d6d6);
  user-select: none;
  scrollbar-width: thin;
}

.ui-image-list__item {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: calc(var(--ui-image-list-size) + 8px);
  padding: 3px;
  border: 1px solid transparent;
  border-radius: 3px;
  cursor: pointer;
}

.ui-image-list__item:hover {
  background: var(--ui-image-list-hover, #2e2e2e);
}

.ui-image-list__item.is-selected {
  border-color: var(--ui-image-list-selected-border, #d6d6d66f);
  background: var(--ui-image-list-selected, #2e2e2e);
}

/* Square box; the image is fitted inside and keeps its aspect. */
.ui-image-list__thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--ui-image-list-size);
  height: var(--ui-image-list-size);
  background: var(--ui-image-list-placeholder, #161616);
}

.ui-image-list__thumb img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  opacity: 0;
  transition: opacity .15s;
}

.ui-image-list__thumb.is-loaded img {
  opacity: 1;
}

.ui-image-list__thumb.is-failed img {
  display: none;
}

/* Label: the start shrinks with an ellipsis, the end stays visible. */
.ui-image-list__label {
  display: flex;
  justify-content: center;
  min-width: 0;
  font-size: 11px;
  line-height: 15px;
  white-space: nowrap;
}

.ui-image-list__start {
  overflow: hidden;
  text-overflow: ellipsis;
}

.ui-image-list__end {
  flex: none;
}

/* Keyboard focus: a line inside the item, the list stays in place. */
.ui-image-list__item:focus {
  outline: none;
}

.ui-image-list__item:focus-visible {
  outline: 1px solid var(--ui-focus, #3d7fd9);
  outline-offset: 1px;
}

/*
 * Arrows on the edges, over the strip, as high as an item: border 2px, padding 6px, thumbnail, gap 4px, label 15px.
 * A shade at the edge keeps the arrow visible on light images.
 */
.ui-image-list__arrow {
  position: absolute;
  top: 4px;
  width: 16px;
  height: calc(var(--ui-image-list-size) + 27px);
  padding: 0;
  background: linear-gradient(to right, var(--ui-image-list-arrow-fade, #1e1e1ecc), transparent);
  border: 0;
  opacity: 0;
  pointer-events: none;
  cursor: pointer;
  transition: opacity .15s;
}

.ui-image-list__arrow::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--ui-image-list-arrow, #d6d6d699);
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 28'%3E%3Cpath d='M11 1v26L1 14z'/%3E%3C/svg%3E") center / 12px 28px no-repeat;
}

.ui-image-list__arrow.is-prev {
  left: 0;
}

.ui-image-list__arrow.is-next {
  right: 0;
  background: linear-gradient(to left, var(--ui-image-list-arrow-fade, #1e1e1ecc), transparent);
}

.ui-image-list__arrow.is-next::before {
  transform: scaleX(-1);
}

/* Shown while the mouse is over the list, on the sides with an image to move to. */
.ui-image-list.can-prev:hover .ui-image-list__arrow.is-prev,
.ui-image-list.can-next:hover .ui-image-list__arrow.is-next {
  opacity: 1;
  pointer-events: auto;
}
