/* Item library for /give — the two-column shell, the sprite grid and the preview.
 *
 * Every selector is prefixed with #tool-root, because css/tool-theme.css loads after this
 * file and re-skins whatever it finds with #tool-root-scoped rules. A plain class rule
 * loses to it; that is documented in CLAUDE.md and the schematic viewer already paid for
 * forgetting it once.
 */

/* The widget's own 720px cap has to go, or the two columns have nowhere to live. */
#tool-root .gcg { max-width: none; }

#tool-root .gcg-shell {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

/* One column below the width where two would each be too narrow to read. The library goes
 * SECOND on a phone: the generated command and the tabs are what someone came for, and a
 * 1,609-item grid above them would push the whole tool below the fold. */
@media (max-width: 900px) {
  #tool-root .gcg-shell { grid-template-columns: 1fr; }
  #tool-root .gcg-lib { order: 2; max-height: 460px; }
}

/* ---------- library column ---------- */
#tool-root .gcg-lib {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex; flex-direction: column;
  /* Sticky so the grid stays reachable while the tab panels scroll past it. 100vh minus
   * the site's own top padding keeps the header visible. */
  position: sticky; top: 16px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}
#tool-root .gcg-lib-head {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface);
  padding: 12px 12px 10px;
  border-bottom: 1px solid var(--line);
}
#tool-root .gcg-lib-title {
  margin: 0 0 8px; font-size: 11.5px; font-weight: 700;
  letter-spacing: 1.7px; text-transform: uppercase; color: var(--fg-dim);
}
#tool-root .gcg-lib-search { width: 100%; }
#tool-root .gcg-lib-count { margin: 8px 0 0; font-size: 11.5px; color: var(--fg-dim); }

#tool-root .gcg-lib-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 5px; padding: 8px;
}
#tool-root .gcg-lib-empty { padding: 18px 12px; color: var(--fg-muted); font-size: 13px; }
#tool-root .gcg-lib-more { height: 1px; }

#tool-root .gcg-lib-item {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 8px 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  /* Buttons default to centre-ish; names are two words as often as one, so pin the sprite
   * to the top and let the label wrap under it rather than pushing the sprite around. */
  justify-content: flex-start;
  transition: border-color 120ms, background 120ms;
}
#tool-root .gcg-lib-item:hover { border-color: var(--line-strong); background: var(--surface-3); }
#tool-root .gcg-lib-item.is-on {
  border-color: var(--grass);
  background: color-mix(in srgb, var(--grass) 14%, var(--surface-2));
}
#tool-root .gcg-lib-name {
  font-size: 10.5px; line-height: 1.25; text-align: center;
  color: var(--fg-muted);
  /* Two lines then ellipsis: "Waxed Oxidized Cut Copper Stairs" would otherwise set the
   * row height for every tile beside it. */
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
#tool-root .gcg-lib-item.is-on .gcg-lib-name { color: var(--fg); }

/* ---------- sprites ----------
 *
 * One 640x656 sheet, addressed by background-position. `image-rendering: pixelated` is not
 * optional: these are 16px textures and any smoothing turns them to mush — the same rule
 * tool-theme.css already applies to 16px art elsewhere.
 *
 * Scaling up uses a transform rather than background-size, because scaling the background
 * would scale the POSITION too and every cell would point at the wrong sprite.
 */
#tool-root .gcg-lib-sprite {
  width: 16px; height: 16px; flex: none; display: block;
  background-image: var(--atlas);
  background-repeat: no-repeat;
  image-rendering: pixelated;
  transform: scale(2);
  transform-origin: center;
  margin: 8px 0;
}
#tool-root .gcg-lib-sprite-lg { transform: scale(2.5); margin: 12px 10px; }

/* ---------- selected-item preview ---------- */
#tool-root .gcg-lib-preview {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 14px; margin-bottom: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
#tool-root .gcg-lib-preview[hidden] { display: none !important; }
#tool-root .gcg-lib-preview-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
#tool-root .gcg-lib-preview-meta strong { font-size: 15px; }
#tool-root .gcg-lib-preview-meta code { font-size: 12px; color: var(--fg-muted); background: none; border: 0; padding: 0; }

/* ---------- version + snapshots ----------
 * The control minecraftmaps puts on this tool. It sits in the library head, above the
 * search box, because the version decides WHICH items the search is searching. */
#tool-root .gcg-lib-version {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}
#tool-root .gcg-lib-vlabel {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-muted);
}
#tool-root .gcg-lib-vselect { flex: 0 1 auto; min-width: 9ch; }
/* aria-pressed is the state, so style from it rather than a class the script also has to
   keep in step — one source of truth for "snapshots are showing". */
#tool-root .gcg-lib-snap {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
#tool-root .gcg-lib-snap[aria-pressed="true"] {
  border-color: var(--grass);
  color: var(--grass);
}
