/* Villager Trade (public/villager.js): a villager behind a wooden counter, a lava pool on the right */
.vt-stage { overflow: hidden; }
.vt-track { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.vt-slot { position: relative; height: 64px; border-radius: 10px; background: var(--bg2); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; gap: 8px; transition: opacity .25s, border-color .25s; }
.vt-slot .q { font: 800 20px 'JetBrains Mono', monospace; color: var(--line); }
.vt-slot img { width: 30px; height: 30px; object-fit: contain; image-rendering: pixelated; }
.vt-slot b { font-size: 13px; font-weight: 700; }
.vt-slot.up b { color: var(--green); }
.vt-slot.down b { color: var(--red); }
.vt-slot.now { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), 0 6px 20px -8px var(--gold); }
.vt-slot.burned { opacity: .45; }
.vt-slot.burned img { filter: grayscale(1) sepia(1) hue-rotate(-30deg) saturate(3) brightness(.6); }
.vt-slot.burned b { text-decoration: line-through; }
.vt-slot.taken { border-color: var(--green); box-shadow: 0 0 0 1px var(--green); }
.vt-slot.taken.down { border-color: var(--red); box-shadow: 0 0 0 1px var(--red); }
.vt-slot.unseen { opacity: .4; border-style: dashed; }

.vt-scene { position: relative; flex: 1; min-height: 380px; border-radius: 14px; overflow: hidden; isolation: isolate;
  background: linear-gradient(180deg, #2a1745 0%, #1d0f33 100%); }
/* the blacksmith's house behind the villager (public/img/villager/blacksmith-backdrop.webp) */
.vt-wall { position: absolute; inset: 0; background: #2a1d33 url(img/villager/blacksmith-backdrop.webp) 50% 62% / cover no-repeat; image-rendering: pixelated; }
.vt-villager { position: absolute; left: 40%; bottom: 14px; width: 150px; transform: translateX(-50%); z-index: 1; transition: transform .3s cubic-bezier(.3,.7,.3,1); }
.vt-villager svg { display: block; width: 100%; height: auto; filter: drop-shadow(0 8px 12px rgba(0, 0, 0, .45)); }
.vt-villager .vt-v-head { animation: vtNod 3.2s ease-in-out infinite; transform-origin: 8px 10px; transform-box: view-box; }
.vt-villager .vt-v-arms { transition: transform .3s cubic-bezier(.3,.7,.3,1); transform-box: view-box; }
.vt-villager.reach { transform: translateX(-50%) translateY(14px); }
.vt-villager.reach .vt-v-arms { transform: translateY(9px); }
/* 3D villager (public/villager3d.js): the canvas replaces the SVG and does its own bowing and turning */
.vt-villager.is3d { width: 200px; height: 330px; bottom: 24px; }
.vt-villager.is3d svg { display: none; }
.vt-villager.is3d canvas { display: block; width: 100%; height: 100%; filter: drop-shadow(0 10px 14px rgba(0, 0, 0, .45)); }
.vt-villager.is3d.reach { transform: translateX(-50%); }
@keyframes vtNod { 0%, 80%, 100% { transform: none; } 86% { transform: rotate(-4deg); } 93% { transform: rotate(3deg); } }

/* the desk (public/img/villager/desk.png): the 64px ends stay as they are, the middle repeats to any width */
.vt-counter { position: absolute; left: 0; bottom: 0; width: 74%; height: 130px; z-index: 3; box-sizing: border-box; image-rendering: pixelated;
  border-style: solid; border-width: 0 29px; border-image: url(img/villager/desk.png) 0 64 fill / 0 29px / 0 round;
  filter: drop-shadow(0 -2px 8px rgba(0, 0, 0, .45)); }
.vt-item { position: absolute; left: 40%; bottom: 128px; width: 76px; height: 76px; object-fit: contain; z-index: 2;
  transform: translate(-50%, 0); image-rendering: pixelated; filter: drop-shadow(0 6px 6px rgba(0, 0, 0, .55)); }
.vt-item[src*="/block/"] { image-rendering: auto; }
.vt-tag { position: absolute; left: calc(40% + 92px); bottom: 150px; z-index: 4; display: flex; flex-direction: column; gap: 2px; padding: 10px 14px;
  border-radius: 10px; background: #1b1131ee; border: 1px solid var(--line); box-shadow: 0 12px 30px -10px #000; min-width: 120px; }
.vt-tag-name { font-size: 12px; color: var(--muted); font-weight: 600; }
.vt-tag b { font-size: 28px; font-weight: 800; line-height: 1.1; }
.vt-tag > span.mono { display: flex; align-items: center; gap: 5px; font-weight: 700; font-size: 15px; }
.vt-tag.up { border-color: color-mix(in srgb, var(--green) 50%, transparent); }
.vt-tag.up b { color: var(--green); text-shadow: 0 0 18px rgba(54, 227, 154, .45); }
.vt-tag.down { border-color: color-mix(in srgb, var(--red) 45%, transparent); }
.vt-tag.down b { color: var(--red); }

/* lava pool with a stone rim; the lava itself is drawn on a canvas by vtLava() in villager.js */
.vt-lava { position: absolute; right: 3%; bottom: 0; width: 20%; height: 96px; z-index: 4; border-radius: 4px 4px 0 0; overflow: hidden;
  border: 8px solid #57565d; border-bottom: 0; background: #b8340a;
  box-shadow: inset 0 0 0 2px #3a393f, inset 0 6px 10px rgba(0, 0, 0, .55), 0 0 46px 8px rgba(255, 100, 20, .38);
  animation: vtHeat 3.2s ease-in-out infinite; }
.vt-lava canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; image-rendering: pixelated; }
@keyframes vtHeat { 50% { box-shadow: inset 0 0 0 2px #3a393f, inset 0 6px 10px rgba(0, 0, 0, .55), 0 0 60px 12px rgba(255, 120, 30, .5); } }
/* lava popping out of the pool (square bits, Minecraft style) and smoke puffs; moved by vtLavaPop() */
.vt-embers { position: absolute; right: 3%; bottom: 88px; width: 20%; height: 0; z-index: 4; pointer-events: none; }
.vt-embers i { position: absolute; bottom: 0; background: #f9b833; box-shadow: 0 0 6px rgba(255, 150, 40, .9); }
.vt-embers i.smoke { width: 8px; height: 8px; background: #4a4650; box-shadow: none; }
.vt-smoke { position: absolute; right: 3%; bottom: 96px; width: 20%; height: 0; z-index: 4; pointer-events: none; }
.vt-smoke i { position: absolute; bottom: 0; width: 14px; height: 14px; border-radius: 50%; background: #8a8590; opacity: 0; }
.vt-smoke i:nth-child(1) { left: 25%; } .vt-smoke i:nth-child(2) { left: 50%; } .vt-smoke i:nth-child(3) { left: 70%; }
.vt-lava.splash { animation: vtGlow .6s ease-out; }
.vt-smoke.splash i { animation: vtSmoke .9s ease-out forwards; }
.vt-smoke.splash i:nth-child(2) { animation-delay: .08s; } .vt-smoke.splash i:nth-child(3) { animation-delay: .16s; }
@keyframes vtGlow { 30% { box-shadow: inset 0 0 0 2px #3a393f, 0 0 80px 24px rgba(255, 150, 40, .75); } }
@keyframes vtSmoke { 0% { opacity: .9; transform: translateY(30px) scale(.6); } 100% { opacity: 0; transform: translateY(-60px) scale(2.4); } }

.vt-burst { position: absolute; left: 40%; bottom: 170px; width: 0; height: 0; z-index: 5; pointer-events: none; }
.vt-burst img { position: absolute; width: 22px; height: 22px; margin: -11px; image-rendering: pixelated; animation: vtBurst .9s ease-out forwards; }
.vt-burst:not(.win) img { filter: grayscale(.6) brightness(.8); }
@keyframes vtBurst { 0% { transform: rotate(var(--a)) translateX(0) scale(.4); opacity: 1; } 100% { transform: rotate(var(--a)) translateX(var(--r)) scale(1); opacity: 0; } }

.vt-pop { z-index: 6; }

/* home card */
.vt-cover { background: linear-gradient(180deg, #4923a5 0%, #3b1a8e 40%, #2b1369 70%, #1f0d48 100%); border-radius: inherit; }
.vt-cover .vtc-art { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.vtc-halo { fill: #5329b5; }
.vtc-shadow { fill: #2a0d60; opacity: .85; }
/* a still render of the 3D villager (public/models/villager.glb), so the home page doesn't load three.js */
.vt-cover .vtc-villager { position: absolute; left: 50%; top: 8%; width: 54%; transform: translateX(-50%); transform-origin: 50% 90%; filter: drop-shadow(0 6px 6px rgba(20, 5, 60, .5)); transition: transform .3s; }
.game-card:hover .vt-cover .vtc-villager { transform: translateX(-50%) rotate(-4deg) translateY(-3%); }
.vt-cover .vtc-counter { position: absolute; left: 12%; right: 12%; top: 58%; height: 13%; border-radius: 3px; background: linear-gradient(180deg, #c08a52 0 22%, #8a5a30 22%); box-shadow: 0 4px 0 #220d4f; }
.vt-cover .vtc-item { position: absolute; left: 50%; top: 42%; width: 21%; transform: translateX(-50%); image-rendering: pixelated; transition: transform .3s; }
.game-card:hover .vt-cover .vtc-item { animation: vtcHop 1.4s ease-in-out infinite; }
@keyframes vtcHop { 0%, 100% { transform: translateX(-50%); } 40% { transform: translate(-50%, -30%) rotate(-10deg); } }
.vt-cover .vtc-tag { position: absolute; left: 8%; bottom: 18.5%; display: flex; align-items: center; gap: 5px; font-size: clamp(7px, 4.2cqw, 10px); font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: #b9a8dc; }
.vt-cover .vtc-tag::before { content: ''; width: .75em; height: .75em; border-radius: 50%; background: #36e39a; }
.vt-cover .vtc-name { position: absolute; left: 8%; bottom: 6%; font-size: clamp(12px, 9.5cqw, 22px); font-weight: 900; letter-spacing: -.01em; color: #fff; white-space: nowrap; }

@media (max-width: 760px) {
  .vt-scene { min-height: 320px; }
  .vt-villager { width: 112px; bottom: 14px; }
  .vt-villager.is3d { width: 150px; height: 250px; bottom: 14px; }
  .vt-item { width: 64px; height: 64px; bottom: 108px; }
  .vt-counter { height: 110px; border-width: 0 24px; border-image-width: 0 24px; }
  .vt-tag { left: auto; right: 4%; bottom: auto; top: 12px; }
  .vt-tag b { font-size: 22px; }
  .vt-slot { height: 52px; flex-direction: column; gap: 2px; }
  .vt-slot img { width: 22px; height: 22px; }
  .vt-slot b { font-size: 10px; }
}
@media (prefers-reduced-motion: reduce) { 
  .vt-villager .vt-v-head, .vt-lava, .game-card:hover .vt-cover .vtc-item { animation: none; } }

/* Under maintenance: covers the scene while Villager Trade is switched off (VILLAGER.maintenance in server/house.js) */
.vt-maint { position: absolute; inset: 0; z-index: 7; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background: rgba(8, 6, 16, .78); backdrop-filter: blur(3px); border-radius: inherit; text-align: center; padding: 20px; }
.vt-maint[hidden] { display: none; }
.vt-maint b { font: 900 28px 'Bricolage Grotesque', sans-serif; letter-spacing: .02em; color: #ffc940; }
.vt-maint span { color: var(--muted); font-size: 14px; }
