/* The Loot window (loot.js; docs/loot-window.md; the chips design, owner
   2026-11-21). The Room window's frame and the theme's tokens, so every
   theme draws it. Item colours are the one colour system's: an item in the
   game's `objects` type (the theme's room-object), a magic item in the
   game's `magic` type (CLR_MAGIC, the theme's magic), coins in the gold. */

#loot {
  --loot-item: var(--t-room-object, var(--parchment));
  --loot-magic: var(--t-magic, var(--magic));
  --loot-coins: var(--gilt-bright, var(--gilt));
  position: absolute;
  z-index: 4;
  display: flex;
  flex-direction: column;
  width: min(340px, calc(100vw - 16px));
  height: min(300px, calc(100vh - 40px));
  min-width: 180px;
  min-height: 90px;
  max-width: calc(100vw - 16px);
  max-height: calc(100vh - 16px);
  background: var(--ink-high);
  border: 1px solid var(--gilt);
  box-shadow: var(--shadow);
  overflow: hidden;
  resize: both;
  font-family: var(--chrome-font);
  font-size: var(--chrome-size);
  color: var(--parchment);
}
#loot[hidden] { display: none; }
#loot.front { z-index: 7; }
#loot:focus { outline: none; }
#loot > header {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 4px 2px 10px;
  color: var(--gilt);
  border-bottom: 1px solid var(--rule);
  cursor: move;
  touch-action: none;
  user-select: none;
}
#loot-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.loot-body { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; }
.loot-group { display: grid; gap: 5px; padding: 7px 10px; border-bottom: 1px solid var(--rule); }
.loot-group:last-of-type { border-bottom: 0; }
.loot-gh { display: flex; gap: 8px; align-items: baseline; min-width: 0; }
.loot-gh > b { flex: 1; min-width: 0; color: var(--parchment-bright); font-weight: 400; overflow-wrap: anywhere; }
.loot-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.loot-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  margin: 0;
  padding: 2px 10px;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: var(--ink-raised);
  color: var(--loot-item);
  font-family: var(--font);
  font-size: calc(var(--size) * 0.86);
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
}
.loot-chip .loot-nm { min-width: 0; overflow-wrap: anywhere; }
.loot-chip:hover { border-color: var(--gilt); background: var(--t-hover-fill, var(--ink-high)); }
.loot-chip:active { background: var(--t-pressed-fill, var(--ink-raised)); }
.loot-chip.magic { color: var(--loot-magic); border-color: color-mix(in srgb, var(--loot-magic) 45%, var(--rule-strong)); }
.loot-chip.magic:hover { border-color: var(--loot-magic); }
.loot-mark { font-size: 0.8em; line-height: 1; }
.loot-chip.coins { color: var(--loot-coins); }
.loot-btn {
  flex: none;
  margin: 0;
  padding: 1px 9px;
  border: 1px solid var(--rule-strong);
  border-radius: 3px;
  background: none;
  color: var(--gilt-bright, var(--gilt));
  font: inherit;
  font-size: 0.92em;
  white-space: nowrap;
  cursor: pointer;
}
.loot-btn:hover { border-color: var(--gilt); background: var(--t-hover-fill, var(--ink-raised)); }
.loot-btn.primary { background: var(--t-button-primary-bg, var(--gilt)); border-color: var(--t-button-primary-bg, var(--gilt)); color: var(--t-button-primary-text, var(--ink)); }
.loot-btn.primary:hover { filter: brightness(1.08); }
#loot button:focus-visible { outline: 2px solid var(--t-focus-ring, var(--gilt)); outline-offset: 1px; }
#loot .taking { opacity: 0.45; pointer-events: none; }
.loot-lock { flex: none; color: var(--ember); font-size: 0.85em; letter-spacing: 0.06em; text-transform: uppercase; }
.loot-empty, .loot-none { color: var(--muted); font-style: italic; }
.loot-empty { flex: none; font-size: 0.92em; }
.loot-none { margin: 0; padding: 8px 10px; }
.loot-foot { flex: none; display: flex; justify-content: flex-end; padding: 6px 10px; border-top: 1px solid var(--rule); }
.loot-foot[hidden] { display: none; }
@media (prefers-reduced-motion: no-preference) {
  .loot-chip, .loot-btn { transition: opacity 0.15s, border-color 0.12s, background-color 0.12s; }
}
#set-loot-row[hidden] { display: none; }
