/* ============================================================
   Inventory editor — used by the public editor and the console.
   Slots are square, pixel icons render crisp, and nothing relies
   on colour alone: changed slots also get an outline marker.
   ============================================================ */

.inv [hidden], .inv[hidden] { display: none !important; }

.inv {
  --slot: 46px;
  --slot-gap: 4px;
  --slot-bg: #f5f3f8;
  --slot-line: #d9d3e2;
  position: relative;
  display: grid;
  gap: 14px;
}

.inv__toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.inv__toolbar-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.inv__hint { margin: 0; color: var(--ink-3); font-size: 0.8rem; }
.inv__pending { font-family: var(--mono); font-size: 0.78rem; color: var(--ink-3); padding: 0 4px; }
.inv__pending.is-dirty { color: var(--amber); }
.inv__stamp { font-size: 0.75rem; color: var(--ink-3); }
.inv__empty { color: var(--ink-3); margin: 12px 0; }
.inv__fine { color: var(--ink-3); font-size: 0.8rem; margin: 6px 0; }

.inv__notice {
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  padding: 8px 12px;
  font-size: 0.88rem;
  background: var(--surface);
}
.inv__notice--error { border-color: rgba(190, 63, 57, 0.5); color: var(--danger); }
.inv__notice--ok { border-color: rgba(116, 54, 201, 0.4); color: var(--lime); }

.inv__layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 400px);
  gap: 14px;
  align-items: start;
}
.inv__main { display: grid; gap: 14px; min-width: 0; }

.inv-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  min-width: 0;
}
.inv-panel__title, .inv-panel h3 { margin: 0 0 12px; font-size: 1rem; font-family: var(--mono); letter-spacing: 0; }

.inv-tabs, .inv-seg {
  display: inline-flex;
  gap: 2px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  margin-bottom: 14px;
}
.inv-tabs button, .inv-seg button {
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 0.85rem;
  padding: 5px 14px;
  border-radius: 999px;
  cursor: pointer;
}
.inv-tabs button.is-on, .inv-seg button.is-on { background: var(--surface-2); color: var(--ink); font-weight: 600; }

/* ---------------------------------------------------------------- slots */

.inv-slot {
  position: relative;
  width: var(--slot);
  height: var(--slot);
  display: inline-grid;
  place-items: center;
  padding: 0;
  background: var(--slot-bg);
  border: 1px solid var(--slot-line);
  border-radius: 3px;
  color: var(--ink-3);
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(38, 24, 57, 0.04);
}
.inv-slot:hover { border-color: var(--violet); }
.inv-slot:focus-visible { outline: 2px solid var(--lime); outline-offset: 1px; }
.inv-slot img { width: 32px; height: 32px; image-rendering: pixelated; object-fit: cover; object-position: top; pointer-events: none; }
.inv-slot.is-filled { background: #f0edf5; }
.inv-slot.is-changed { border-color: var(--amber); box-shadow: inset 0 0 0 1px var(--amber); }
.inv-slot.is-changed::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 6px;
  height: 6px;
  background: var(--amber);
  border-radius: 1px;
}
.inv-slot.is-custom::after {
  content: "+";
  position: absolute;
  top: 0;
  right: 3px;
  font-size: 0.7rem;
  color: var(--info);
  font-weight: 700;
}
.inv-slot.is-enchanted img { animation: inv-glint 2.8s ease-in-out infinite; }
@keyframes inv-glint {
  0%, 100% { filter: drop-shadow(0 0 0 rgba(116, 54, 201, 0)); }
  50% { filter: drop-shadow(0 0 4px rgba(116, 54, 201, 0.9)) brightness(1.15); }
}
@media (prefers-reduced-motion: reduce) { .inv-slot.is-enchanted img { animation: none; filter: drop-shadow(0 0 3px rgba(116, 54, 201, 0.8)); } }
.inv-slot__label { font-size: 0.56rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
.inv-slot__count {
  position: absolute;
  right: 3px;
  bottom: 1px;
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 700;
  color: #ffffff;
  text-shadow: -1px -1px 0 #302637, 1px -1px 0 #302637, -1px 1px 0 #302637, 1px 1px 0 #302637;
  pointer-events: none;
}
.inv-slot__bar { position: absolute; left: 6px; right: 6px; bottom: 4px; height: 3px; background: #000; }
.inv-slot__bar span { display: block; height: 100%; }
.inv-slot--static { cursor: default; }
.inv-slot--static:hover { border-color: var(--slot-line); }

.inv-grid { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: var(--slot-gap); width: calc(9 * var(--slot) + 8 * var(--slot-gap)); max-width: 100%; }
.inv-grid .inv-slot { width: 100%; height: auto; aspect-ratio: 1; }
.inv-grid--hotbar { margin-top: 12px; }

.inv-top {
  display: grid;
  grid-template-columns: var(--slot) 92px var(--slot) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
}
.inv-armor { display: grid; gap: var(--slot-gap); }
.inv-figure {
  height: calc(var(--slot) * 4 + var(--slot-gap) * 3);
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 4px;
  background: var(--bg);
}
.inv-figure__svg { height: 84%; width: auto; image-rendering: pixelated; }
.inv-offhand { align-self: end; }
.inv-craft { display: flex; align-items: center; gap: 12px; align-self: start; margin-left: 18px; }
.inv-craft__grid { display: grid; grid-template-columns: repeat(2, var(--slot)); gap: var(--slot-gap); }
.inv-craft__arrow { color: var(--ink-3); font-size: 1.3rem; }

/* ---------------------------------------------------------------- catalogue */

.inv-catalogue { position: sticky; top: 16px; display: grid; gap: 12px; }
.inv-catalogue__head, .inv-export__head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.inv-catalogue__head h3, .inv-export__head h3 { margin: 0; font-family: var(--sans); font-size: 1.05rem; }
.inv-catalogue__count { font-family: var(--mono); font-size: 0.78rem; color: var(--lime); }
.inv-catalogue__selected { margin: 0; font-size: 0.84rem; color: var(--ink-2); }
.inv-catalogue__selected b { color: var(--violet); font-weight: 600; font-family: var(--mono); font-size: 0.8rem; }
.inv-search .input { width: 100%; }
.inv-chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.inv-chips button {
  flex: none;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink-2);
  font: inherit;
  font-size: 0.8rem;
  border-radius: 999px;
  padding: 4px 12px;
  cursor: pointer;
}
.inv-chips button.is-on { background: var(--lime); color: var(--lime-ink); border-color: var(--lime); font-weight: 600; }
.inv-items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 4px;
  max-height: 520px;
  overflow-y: auto;
  padding-right: 2px;
}
.inv-item {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  padding: 0;
  background: var(--slot-bg);
  border: 1px solid var(--slot-line);
  border-radius: 3px;
  cursor: pointer;
}
.inv-item:hover { border-color: var(--violet); }
.inv-item:focus-visible { outline: 2px solid var(--lime); outline-offset: 1px; }
.inv-item.is-selected { border-color: var(--lime); box-shadow: inset 0 0 0 1px var(--lime); }
.inv-item img { width: 32px; height: 32px; image-rendering: pixelated; object-fit: cover; object-position: top; pointer-events: none; }
.inv-textures { border-top: 1px solid var(--line-soft); padding-top: 10px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inv-textures p { margin: 0; font-size: 0.78rem; color: var(--ink-3); flex-basis: 100%; }
.inv-file { cursor: pointer; }
.inv-link { background: none; border: 0; color: var(--lime); font: inherit; cursor: pointer; padding: 0; text-decoration: underline; }

/* ---------------------------------------------------------------- export */

.inv-export { display: grid; gap: 12px; }
.inv-export .inv-seg { margin: 0; justify-self: start; }
.inv-export__code { max-height: 220px; overflow: auto; font-size: 0.78rem; margin: 0; }
.inv-export__row { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------------------------------------------------------------- floating */

.inv__held {
  position: sticky;
  bottom: 12px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--surface-2);
  border: 1px solid var(--lime);
  border-radius: var(--radius-s);
  box-shadow: 0 12px 30px rgba(38, 24, 57, 0.10);
  font-size: 0.88rem;
}
.inv__held img { image-rendering: pixelated; }

.inv-pop {
  position: absolute;
  z-index: 20;
  width: 272px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  box-shadow: 0 18px 40px rgba(38, 24, 57, 0.12);
  padding: 14px;
  display: grid;
  gap: 10px;
}
.inv-pop__head { display: flex; gap: 10px; align-items: center; }
.inv-pop__head img { image-rendering: pixelated; background: var(--slot-bg); border: 1px solid var(--slot-line); padding: 2px; border-radius: 3px; }
.inv-pop__head b { display: block; }
.inv-pop__head code { font-size: 0.72rem; }
.inv-pop__range { display: grid; gap: 4px; font-size: 0.84rem; color: var(--ink-2); }
.inv-pop__range span { display: flex; justify-content: space-between; }
.inv-pop__range b { color: var(--amber); font-family: var(--mono); }
.inv-pop__range input { width: 100%; accent-color: var(--lime); }
.inv-pop__actions { display: flex; flex-wrap: wrap; gap: 6px; }

.inv-sheet {
  position: fixed;
  inset: 0;
  z-index: 220;
  display: grid;
  place-items: center;
  background: rgba(32, 23, 46, 0.36);
  padding: 16px;
}
.inv-sheet__card {
  width: min(520px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.inv-sheet__head { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.inv-sheet__head h3 { margin: 0; flex: 1; font-size: 1rem; }
.inv-sheet__head img { image-rendering: pixelated; }
.inv-sheet__body { padding: 16px 18px; display: grid; gap: 12px; }
.inv-sheet__body textarea { width: 100%; resize: vertical; font-family: var(--sans); }
.inv-sheet__foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }
.inv-enchants { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.inv-enchants li { display: grid; grid-template-columns: 1fr 80px auto; gap: 8px; align-items: center; }
.inv-enchant-add { display: grid; grid-template-columns: 1fr 80px auto; gap: 8px; }

/* ---------------------------------------------------------------- responsive */

@media (max-width: 1080px) {
  .inv__layout { grid-template-columns: minmax(0, 1fr); }
  .inv-catalogue { position: static; }
}
@media (max-width: 620px) {
  .inv { --slot: calc((100vw - 32px - 36px - 8 * 3px) / 9); --slot-gap: 3px; }
  .inv-panel { padding: 12px; }
  .inv-slot img { width: 70%; height: 70%; }
  .inv-top { grid-template-columns: var(--slot) 1fr var(--slot); }
  .inv-craft { grid-column: 1 / -1; margin-left: 0; }
}

/* ---------------------------------------------------------------- public tool page */

/* Minecraft text is drawn from the original bitmap glyphs at an integer scale.
   Only the game preview uses this treatment; the surrounding app stays light. */
.inv-tooltip {
  position: fixed;
  z-index: 1000;
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 24px);
  pointer-events: none;
  overflow: hidden;
  padding: 2px;
}
.mc-tooltip {
  position: relative;
  isolation: isolate;
  width: max-content;
  max-width: 100%;
  padding: 24px;
  color: #fff;
  font-family: var(--mono);
  font-size: 16px;
  line-height: 18px;
  text-align: left;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  image-rendering: pixelated;
}
.mc-tooltip::before, .mc-tooltip::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  image-rendering: pixelated;
  border-style: solid;
  border-color: transparent;
}
.mc-tooltip::before {
  border-width: 18px;
  border-image: url("../minecraft/1.21.11/gui/tooltip/background.png") 9 fill / 18px / 0 stretch;
}
.mc-tooltip::after {
  border-width: 20px;
  border-image: url("../minecraft/1.21.11/gui/tooltip/frame.png") 10 fill / 20px / 0 stretch;
}
.mc-tooltip__line { position: relative; min-height: 18px; line-height: 18px; }
.mc-text { display: inline-block; max-width: 100%; vertical-align: top; }
.mc-text__canvas { display: block; image-rendering: pixelated; }
.mc-tooltip__line canvas { display: block; max-width: 100%; image-rendering: pixelated; }
.mc-tooltip__name:not(:last-child) { margin-bottom: 4px; }
.mc-tooltip--hidden-item { font-size: 12px; color: #aaa; padding: 14px; }
.inv-preview { display: grid; gap: 10px; min-width: 0; }
.inv-preview__label { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px; font-size: .75rem; color: var(--ink-3); }
.inv-preview__label span:first-child { color: var(--violet); font-weight: 700; }
.inv-preview__scene {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  min-height: 110px;
  min-width: 0;
  padding: 18px 12px;
  background: #c6c6c6;
  border: 2px solid #171717;
  box-shadow: inset 2px 2px #fff, inset -2px -2px #555;
}
.inv-preview__scene > img {
  flex: 0 0 48px;
  box-sizing: content-box;
  margin-top: 8px;
  padding: 4px;
  image-rendering: pixelated;
  background: #8b8b8b;
  border: 2px solid;
  border-color: #373737 #fff #fff #373737;
}
[data-inv-preview], [data-inv-stack-preview] { min-width: 0; max-width: 100%; }
.inv-preview__scene [data-inv-preview] { flex: 1; }
.inv-preview .inv__fine { margin: 0 0 4px; }
.inv-pop { width: min(306px, calc(100vw - 40px)); }
.inv-sheet__card { width: min(600px, 100%); }

@media (max-width: 480px) {
  .inv-preview__scene { gap: 6px; padding: 12px 6px; }
  .inv-preview__scene > img { flex-basis: 32px; width: 32px; height: 32px; }
  .inv-preview__label span:last-child { display: none; }
}

.tool { padding: 46px 0 56px; }
.tool__wrap { max-width: 1440px; }
.tool__head { margin-bottom: 22px; max-width: 760px; }
.tool__head h1 { margin: 4px 0 8px; font-size: clamp(1.8rem, 3vw, 2.4rem); }
.tool__head p { color: var(--ink-2); margin: 0; }
.tool__actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 22px 0 14px; }
.tool__head .tool__explanation { font-size: 0.85rem; padding-left: 12px; border-left: 3px solid var(--gold); color: var(--ink-3); }
.tool__editor:focus { outline: none; }
.tool__fine { color: var(--ink-3); font-size: 0.78rem; margin-top: 22px; }

@media (max-width: 480px) {
  .tool__actions .btn { width: 100%; }
  .tool { padding-top: 28px; }
}
