@font-face {
  font-family: 'Monocraft';
  src: url('https://cdn.jsdelivr.net/gh/IdreesInc/Monocraft@main/dist/Monocraft-ttf/Monocraft.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

* { box-sizing: border-box; }

/* Shared hover tooltip (docs/util/tooltip.js); replaces native title= on recipe slots. */
.hovertip {
  position: fixed;
  display: none;
  pointer-events: none;
  z-index: 1000;
  font-family: 'Monocraft', monospace;
  font-size: 0.78em;
  background: #2a2a2a;
  color: #e0e0e0;
  border: 1px solid #4ecca3;
  border-radius: 6px;
  padding: 4px 8px;
  max-width: 280px;
  white-space: normal;
  line-height: 1.3;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

body {
  font-family: 'Monocraft', monospace;
  font-size: 18px;
  background: #1a1a1a;
  color: #e0e0e0;
  margin: 0;
  padding: 20px;
}

a { color: #55FF55; }

h1 {
  text-align: center;
  color: #fff;
  margin-bottom: 4px;
}

.subtitle {
  text-align: center;
  color: #888;
  margin: 0 auto 20px;
  font-size: 0.85em;
}

/* ── Controls ──────────────────────────────────────────────────────────── */
.controls {
  max-width: 1400px;   /* match .item-grid so the search bar spans the grid width */
  margin: 0 auto 16px;
}

#search-input {
  width: 100%;
  padding: 12px 16px;
  font-family: 'Monocraft', monospace;
  font-size: 1em;
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  border-radius: 8px;
  color: #e0e0e0;
}
#search-input::placeholder { color: #666; }
#search-input:focus { outline: none; border-color: #4ecca3; }

.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  justify-content: center;
}
.pill {
  font-family: 'Monocraft', monospace;
  font-size: 0.8em;
  padding: 6px 12px;
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  border-radius: 999px;
  color: #cfcfcf;
  cursor: pointer;
}
.pill:hover { border-color: #4ecca3; }
.pill.active { background: #4ecca3; color: #102; border-color: #4ecca3; }

.counter {
  text-align: center;
  color: #888;
  font-size: 0.8em;
  margin: 10px 0 18px;
}

/* ── Item grid ─────────────────────────────────────────────────────────── */
.item-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
  max-width: 1400px;
  margin: 0 auto;
}
/* #items-container is a plain wrapper holding one titled section per namespace. */
#items-container > section:first-child .section-title { margin-top: 14px; }

.item-card {
  background: #2a2a2a;
  border-radius: 12px;
  padding: 16px;
  border: 1px solid #3a3a3a;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.item-header {
  display: flex;
  align-items: center;
  gap: 14px;
}
.item-icon {
  width: 64px;
  height: 64px;
  flex: 0 0 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  image-rendering: pixelated;
}
.item-icon img { image-rendering: pixelated; max-width: 100%; max-height: 100%; }
/* Vanilla material icons render at native 16/32px; fill the box so they're not tiny next to head
   icons. 64px box → integer upscale (16×4, 32×2), so they stay crisp. */
.item-icon .mat-img, .detail-icon .mat-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}
.item-icon .placeholder { color: #555; font-size: 0.7em; text-align: center; }
.item-icon.glint { filter: drop-shadow(0 0 4px #b46cff); }

.item-title { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.item-name { font-size: 1.05em; }
.item-id { color: #666; font-size: 0.8em; }

.item-lore { color: #aaa; font-size: 0.82em; line-height: 1.5; }
.item-lore .line { white-space: pre-wrap; }

.note-line { color: #bbb; font-size: 0.9em; line-height: 1.6; white-space: pre-wrap; }
.note-line + .note-line { margin-top: 6px; }
.note-link { text-decoration: underline; }

/* ── Recipes ───────────────────────────────────────────────────────────── */
/* margin-top:auto pins the recipe block to the card bottom; grid rows stretch cards to equal
   height, so recipes line up across a row regardless of lore length. */
.recipes { display: flex; flex-direction: column; gap: 10px; margin-top: auto; }
.recipe {
  background: #222;
  border: 1px solid #353535;
  border-radius: 8px;
  padding: 10px;
}
.recipe-type { color: #4ecca3; font-size: 0.82em; margin-bottom: 8px; text-transform: uppercase; }
.recipe-body { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.recipe-arrow { color: #888; font-size: 1.3em; }

.craft-grid { display: grid; gap: 3px; }
.craft-grid.cols-1 { grid-template-columns: repeat(1, 1fr); }
.craft-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.craft-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }

.slot {
  width: 36px;
  height: 36px;
  background: #1c1c1c;
  border: 1px solid #383838;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.slot.empty { background: #181818; border-style: dashed; }
.slot.result { width: 44px; height: 44px; border-color: #4ecca3; }
.slot img { image-rendering: pixelated; width: 100%; height: 100%; object-fit: contain; }
.slot .slot-label {
  font-size: 11px;
  line-height: 1.05;
  text-align: center;
  color: #cfcfcf;
  padding: 1px;
  word-break: break-word;
}
.slot .amount {
  position: absolute;
  right: 1px;
  bottom: 0;
  font-size: 11px;
  color: #fff;
  text-shadow: 1px 1px 0 #000;
}
.slot.tag { border-color: #5a7; }
.shapeless-list { display: flex; gap: 4px; flex-wrap: wrap; }

.no-recipe { color: #666; font-size: 0.88em; font-style: italic; margin-top: auto; }

/* ── Millstone / processing-machine section ────────────────────────────── */
.section-title {
  max-width: 1400px;
  margin: 40px auto 14px;
  color: #fff;
  border-bottom: 1px solid #3a3a3a;
  padding-bottom: 8px;
}
.grind-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  max-width: 1400px;
  margin: 0 auto;
}
.grind-row {
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  border-radius: 8px;
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}
/* Machine recipes: input(s) (+ glass bottle, …) → output(s); each side wraps. */
.machine-io { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
/* "Obtained from" reverse links: which machine produces this item. */
.produced-by { margin-bottom: 12px; }
.produced-by-label { color: #4ecca3; font-size: 0.85em; margin-bottom: 6px; }
a.produced-by-machine { color: #55FF55; text-decoration: none; }
a.produced-by-machine:hover { text-decoration: underline; }
.slot .chance {
  position: absolute;
  left: 1px;
  bottom: 0;
  font-size: 10px;
  color: #9fd;
  text-shadow: 1px 1px 0 #000;
}

#error {
  background: #5c1a1a;
  color: #ff8080;
  padding: 15px;
  border-radius: 8px;
  max-width: 1400px;
  margin: 0 auto 20px;
  display: none;
}

/* ── Cards as links ────────────────────────────────────────────────────── */
a.item-card { text-decoration: none; color: inherit; cursor: pointer; transition: border-color 0.1s; }
a.item-card:hover { border-color: #4ecca3; }
a.slot { text-decoration: none; color: inherit; }
.state-badge {
  display: inline-block;
  background: #333;
  color: #4ecca3;
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 0.92em;
  margin-left: 4px;
}
.counter.inline { display: inline; margin: 0; font-size: 0.6em; color: #888; }

/* ── Vertical slabs section (compact grid) ─────────────────────────────── */
.slab-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
  max-width: 1400px;
  margin: 0 auto;
}
.slab-grid .item-card { padding: 12px; }
.slab-grid .item-lore, .slab-grid .recipes { display: none; }

/* ── Detail page ───────────────────────────────────────────────────────── */
.detail-wrap { max-width: 1200px; margin: 0 auto; }
.back-link {
  display: inline-block;
  color: #55FF55;
  text-decoration: none;
  margin-bottom: 20px;
  font-size: 0.85em;
}
.back-link:hover { text-decoration: underline; }
.detail-header { display: flex; align-items: center; gap: 20px; margin-bottom: 16px; }
.detail-icon {
  width: 96px;
  height: 96px;
  flex: 0 0 96px;
  display: flex;
  align-items: center;
  justify-content: center;
  image-rendering: pixelated;
}
.detail-icon img { image-rendering: pixelated; max-width: 100%; max-height: 100%; }
.detail-icon .placeholder { color: #555; }
.detail-icon.glint { filter: drop-shadow(0 0 6px #b46cff); }
.detail-name { margin: 0 0 4px; color: #fff; }
.detail-section { margin-top: 24px; }
.detail-section .section-title { margin-top: 0; }

/* 3D viewers (detail page): one centered row on desktop. 3 panels (In hand + 2 Placed) =
   3×(320+22) + 2×16 = 1058px, fits the 1200 column once the viewport is ≥~1121px; below that
   the media query stacks them. */
.viewers { display: flex; flex-wrap: nowrap; justify-content: center; gap: 16px; margin: 18px 0 4px; }
.viewer {
  background: #222;
  border: 1px solid #353535;
  border-radius: 10px;
  padding: 10px;
}
.viewer-label { color: #4ecca3; font-size: 0.82em; text-transform: uppercase; margin-bottom: 6px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.variant-select {
  font-family: 'Monocraft', monospace;
  font-size: 0.85em;
  background: #1c1c1c;
  color: #e0e0e0;
  border: 1px solid #3a3a3a;
  border-radius: 4px;
  padding: 2px 6px;
  margin-left: 6px;
  text-transform: none;
}
.viewer-canvas {
  width: min(320px, 86vw);
  height: min(320px, 86vw);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
}
.viewer-canvas:active { cursor: grabbing; }
.viewer-canvas canvas { display: block; }
.viewer-canvas .flat-item {
  image-rendering: pixelated;
  width: 128px;
  height: 128px;
  object-fit: contain;
}
.viewer-fail { color: #666; font-size: 0.8em; }
/* Stack the viewers once 3 panels no longer fit one row (~1121px); the canvas min(320px,86vw)
   then handles small-phone shrink on its own. */
@media (max-width: 1120px) { .viewers { flex-direction: column; align-items: center; } }

/* States / variants */
.variant-group { margin-bottom: 18px; }
.variant-group-title { color: #4ecca3; font-size: 0.78em; text-transform: uppercase; margin-bottom: 8px; }
.variant-row { display: flex; flex-wrap: wrap; gap: 12px; }
.variant { width: 64px; text-align: center; }
.variant-icon {
  width: 64px;
  height: 64px;
  background: #1c1c1c;
  border: 1px solid #383838;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  image-rendering: pixelated;
  overflow: hidden;
}
.variant-icon img { image-rendering: pixelated; max-width: 100%; max-height: 100%; }
.variant-icon .slot-label { font-size: 11px; color: #cfcfcf; padding: 2px; word-break: break-word; }
.variant-label { font-size: 0.82em; color: #aaa; margin-top: 4px; word-break: break-word; }

.transitions { margin-top: 14px; }
.transition { font-size: 0.85em; color: #ccc; padding: 3px 0; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.trans-state { background: #2a2a2a; border: 1px solid #3a3a3a; border-radius: 4px; padding: 1px 8px; }
.trans-trigger { color: #888; font-size: 0.85em; }
.trans-arrow { color: #4ecca3; }

/* ── Minecraft color codes ─────────────────────────────────────────────── */
.mc-0 { color: #000000; } .mc-1 { color: #0000AA; } .mc-2 { color: #00AA00; }
.mc-3 { color: #00AAAA; } .mc-4 { color: #AA0000; } .mc-5 { color: #AA00AA; }
.mc-6 { color: #FFAA00; } .mc-7 { color: #AAAAAA; } .mc-8 { color: #555555; }
.mc-9 { color: #5555FF; } .mc-a { color: #55FF55; } .mc-b { color: #55FFFF; }
.mc-c { color: #FF5555; } .mc-d { color: #FF55FF; } .mc-e { color: #FFFF55; }
.mc-f { color: #FFFFFF; }
.mc-l { font-weight: bold; } .mc-o { font-style: italic; }
.mc-n { text-decoration: underline; } .mc-m { text-decoration: line-through; }

/* ── Showcases page ─────────────────────────────────────────────────────── */
/* List of all showcases: a responsive grid (≈440px min track → 3 cols @1440, 2 @1024, 1 mobile). */
#showcases {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(440px, 1fr));
  gap: 20px;
  max-width: 1400px;
  margin: 0 auto;
}
.showcase {
  background: #222;
  border: 1px solid #353535;
  border-radius: 10px;
  padding: 16px;
}
.showcase h2 { color: #4ecca3; margin: 0 0 4px; }
.showcase-blurb { color: #bbb; margin: 0 0 12px; line-height: 1.5; }
.showcase-canvas {
  width: 100%;
  height: min(65vh, 640px);   /* ~1.5× the old 420px area; renderScene autoframes to refit */
  background: #1c1c1c;
  border-radius: 8px;
  border: 1px solid #3a3a3a;
  cursor: grab;
}
.showcase-canvas:active { cursor: grabbing; }
.showcase-canvas canvas { display: block; }
.showcase h2 a.showcase-title-link { color: inherit; text-decoration: none; }
.showcase h2 a.showcase-title-link:hover { color: #6fe0bd; text-decoration: underline; }
.details-link {
  display: inline-block;
  margin-top: 12px;
  color: #4ecca3;
  text-decoration: none;
  font-size: 0.9em;
}
.details-link:hover { text-decoration: underline; }

/* ── Showcase detail page ───────────────────────────────────────────────── */
.showcase-description {
  color: #ccc;
  line-height: 1.65;
  margin: 16px 0 22px;
  max-width: 900px;
}
/* Grid (not fixed-width flex): the old 140px card clipped its 176px-wide thumbs. 184px min track
   fits placed-thumb (96) + hand (48) + gap (8) + padding (24). */
.blocks-used {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(184px, 1fr));
  gap: 16px;
}
.block-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px;
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.1s;
}
a.block-card:hover { border-color: #4ecca3; }
.block-card-thumbs { display: flex; align-items: flex-end; gap: 8px; }
.block-thumb {
  width: 96px;
  height: 96px;
  background: #1c1c1c;
  border: 1px solid #383838;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  image-rendering: pixelated;
}
.block-thumb--hand { width: 48px; height: 48px; }
.block-thumb img { image-rendering: pixelated; max-width: 100%; max-height: 100%; }
.block-thumb .placed-thumb { width: 100%; height: 100%; }
.block-card-name { font-size: 0.9em; text-align: center; word-break: break-word; }
.block-card-id { font-size: 0.72em; color: #888; text-align: center; word-break: break-all; }

/* ── Catalog placed-thumbnail (static 3D preview on animated cards) ──────── */
.card-3d { display: flex; justify-content: center; margin: 2px 0; }
.placed-thumb {
  width: 150px;
  height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
/* Explicit fill (not bare max-*) so the lazy-loaded PNG reserves its box and never load-shifts.
   The .block-thumb .placed-thumb override above keeps showcase thumbnails at their own size. */
.placed-thumb-img { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; }

/* ── Item page: "Used in showcases" backlinks (machine screenshot + name) ── */
.used-in-showcases {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}
.showcase-backlink {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px;
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.1s;
}
.showcase-backlink:hover { border-color: #4ecca3; }
.showcase-thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #1c1c1c;
  border: 1px solid #383838;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.showcase-backlink-name { font-size: 0.92em; text-align: center; color: #55FF55; word-break: break-word; }
