/* Image picker modal — reads as an in-game inventory screen: a stone panel of
   recessed slots over a dimmed world. */

.asset-picker {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.asset-picker[hidden] {
  display: none;
}

body.has-open-picker {
  overflow: hidden;
}

.asset-picker__panel {
  width: 100%;
  max-width: 720px;
  max-height: min(78vh, 640px);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.asset-picker__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.asset-picker__title {
  margin: 0;
  font-size: 1.05rem;
}

.asset-picker__close {
  min-width: 40px;
  min-height: 40px;
  background: #9d9d9d;
  border: 2px solid var(--mc-outline);
  box-shadow: var(--bevel-raised);
  color: #1c1f22;
  font-family: var(--font-ui);
  font-weight: 700;
  cursor: pointer;
  flex: 0 0 auto;
}

.asset-picker__close:hover {
  background: #adadad;
}

.asset-picker__close:active {
  box-shadow: var(--bevel-inset);
}

.asset-picker__search {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 2px solid var(--mc-outline);
  box-shadow: var(--bevel-inset);
  background: var(--mc-slot);
  color: #23262a;
  font-size: 1rem;
  font-family: inherit;
}

.asset-picker__filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.asset-picker__filters[hidden] {
  display: none;
}

.asset-picker__chip {
  min-height: 34px;
  padding: 0 11px;
  font-size: 0.78rem;
}

/* The slot grid scrolls inside the panel so the header and search stay put. */
.asset-picker__grid {
  list-style: none;
  margin: 0;
  padding: 8px;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 120px;
  border: 2px solid var(--mc-outline);
  box-shadow: var(--bevel-inset);
  background: #b6b6b6;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 6px;
}

.asset-picker__item {
  margin: 0;
}

.asset-picker__tile {
  width: 100%;
  min-height: 92px;
  padding: 8px 4px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  background: #c6c6c6;
  border: 2px solid var(--mc-outline);
  box-shadow: var(--bevel-raised);
  cursor: pointer;
  color: #23262a;
  font-family: inherit;
}

.asset-picker__tile:hover {
  background: #d6d6d6;
}

.asset-picker__tile:active {
  box-shadow: var(--bevel-inset);
}

.asset-picker__tile.is-selected {
  background: var(--color-primary);
  box-shadow: var(--bevel-inset);
  color: #fff;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.45);
}

/* Minecraft artwork is pixel art — keep the hard edges when scaling. */
.asset-picker__image {
  width: 40px;
  height: 40px;
  object-fit: contain;
  image-rendering: pixelated;
  flex: 0 0 auto;
}

.asset-picker__fallback {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  background: #8f8f8f;
  border: 2px solid rgba(0, 0, 0, 0.35);
  font-family: var(--font-pixel);
  font-size: 0.82rem;
  font-weight: 700;
  color: #2b2f34;
  flex: 0 0 auto;
}

.asset-picker__name {
  font-size: 0.7rem;
  line-height: 1.3;
  text-align: center;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
}

.asset-picker__empty {
  margin: 0;
  padding: 10px 2px;
  font-size: 0.9rem;
  color: var(--color-text-muted);
  text-align: center;
}

.asset-picker__empty[hidden] {
  display: none;
}

.asset-picker__hint {
  margin: 0;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

@media (max-width: 480px) {
  .asset-picker {
    padding: 10px;
  }

  .asset-picker__panel {
    max-height: 88vh;
    padding: 14px;
  }

  .asset-picker__grid {
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  }

  /* Sharing the row leaves ~160px for the input, which is not enough to read a
     long identifier like minecraft:polished_blackstone_bricks. */
  .asset-field {
    flex-wrap: wrap;
  }

  .field .asset-field input {
    flex: 1 1 100%;
  }
}

/* The input plus its "choose from images" button */

.asset-field {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

/* Specific enough to beat the `width: 100%` that components.css puts on every
   text input inside `.field` — here the input shares the row with a button. */
.field .asset-field input {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
}

.asset-field__open {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #9d9d9d;
  border: 2px solid var(--mc-outline);
  box-shadow: var(--bevel-raised);
  color: #1c1f22;
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 0.82rem;
  white-space: nowrap;
  cursor: pointer;
}

.asset-field__open:hover {
  background: #adadad;
}

.asset-field__open:active {
  box-shadow: var(--bevel-inset);
}

.asset-field__open-icon {
  display: inline-grid;
  grid-template-columns: repeat(2, 5px);
  gap: 2px;
}

.asset-field__open-icon span {
  width: 5px;
  height: 5px;
  background: #2b2f34;
}
