/* ---------- the Collector's Desk ----------
   Home is a walnut desk seen from above, and every place in the game is an object on it. The desk, the felt mat and
   the mat's shadow are drawn by the table shader (stage3d.js); this layer holds the objects, in the world frame:
   --a is one art pixel (two world pixels). Objects and plates scale with the world; the HUD bars hug the screen edges.
   One look for every place: hover lifts the object one art pixel, outlines it in paper, and lights its brass plate. */
:root { --brass: #c48a2a; --brass-dk: #8a5a1c; --brass-lt: #ffd66b; --wine: #5a1420; --pillbg: rgba(35, 32, 28, 0.92); }
.desklayer { position: absolute; left: var(--ox); top: var(--oy); width: calc(var(--g) * 640); height: calc(var(--g) * 360); --a: calc(var(--g) * 2); --u: var(--g); --fu: calc(var(--g) * var(--fs)); pointer-events: none; }
#hud > .desklayer { pointer-events: none; }
.desk-ghost { z-index: 9; }
#stage[data-mode="home"] #vignette { opacity: 0; }
#vignette { transition: opacity 0.6s ease; }

.dobj { position: absolute; left: calc(var(--a) * var(--x)); top: calc(var(--a) * var(--y)); width: calc(var(--a) * var(--w)); height: calc(var(--a) * var(--h)); padding: 0; border: 0; background: none; pointer-events: auto; text-shadow: none; }
.dobj img { position: absolute; left: 0; top: 0; image-rendering: pixelated; pointer-events: none; -webkit-user-drag: none; }
.dobj img.o { width: 100%; height: 100%; transition: transform 0.12s ease; }
.dobj img.s { width: calc(100% + var(--a) * 2); height: calc(100% + var(--a) * 3); }
.dobj-hit { position: absolute; inset: 0; padding: 0; border: 0; background: none; }
.dobj:not(.locked):hover img.o, .dobj:focus-visible img.o, .dobj-hit:hover img.o, .dobj-hit:focus-visible img.o {
  transform: translateY(calc(var(--a) * -1));
  filter: drop-shadow(var(--a) 0 0 var(--paper)) drop-shadow(calc(var(--a) * -1) 0 0 var(--paper)) drop-shadow(0 var(--a) 0 var(--paper)) drop-shadow(0 calc(var(--a) * -1) 0 var(--paper)); }
.dobj:focus-visible, .dobj-hit:focus-visible { outline: none; }
.dobj.lifted img, .dobj.lifted .plate, .dobj.lifted .badge { visibility: hidden; }
.dobj.locked img.o { filter: grayscale(1) brightness(0.62); }
.dobj.locked .lock-pip { display: block; right: calc(var(--a) * -2); bottom: calc(var(--a) * 2); }
.dobj .badge { right: calc(var(--a) * -3); top: calc(var(--a) * -3); z-index: 2; }

/* a brass plate under each object names it, with its count */
.plate { position: absolute; left: 50%; top: calc(100% - var(--a) * 2); transform: translateX(-50%); z-index: 1; display: flex; align-items: baseline; gap: calc(var(--g) * 3);
  white-space: nowrap; font-family: var(--font-px); font-size: calc(var(--g) * 7.5 * var(--fs)); line-height: 1; letter-spacing: 0.04em; color: var(--ink);
  background: var(--brass); border: calc(var(--g) * 1.5) solid var(--ink); border-radius: calc(var(--g) * 1.5); padding: calc(var(--g) * 2.5) calc(var(--g) * 5) calc(var(--g) * 2);
  box-shadow: inset 0 var(--g) 0 var(--brass-lt), inset 0 calc(var(--g) * -1) 0 var(--brass-dk), 0 calc(var(--g) * 1.5) 0 rgba(35, 32, 28, 0.45); pointer-events: none; transition: transform 0.12s ease; }
.plate b { font-family: var(--font-ui); font-weight: 700; font-size: 1.05em; color: var(--wine); }
.plate b:empty { display: none; }
.dobj:not(.locked):hover .plate, .dobj:focus-visible .plate, .dobj.active .plate, .dobj.packs:hover .plate {
  background: var(--paper); box-shadow: inset 0 calc(var(--g) * -1) 0 #d8ccb0, 0 calc(var(--g) * 1.5) 0 rgba(35, 32, 28, 0.45); transform: translate(-50%, calc(var(--a) * -1)); }
.dobj.locked .plate { background: #8a8378; box-shadow: none; }
/* an object along the desk's top edge has its plate beside it (the leaderboards' scroll) */
.dobj.side .plate { left: calc(100% + var(--a) * 2); top: 50%; transform: translateY(-50%); }
.dobj.side:not(.locked):hover .plate, .dobj.side:focus-visible .plate, .dobj.side.active .plate { transform: translate(0, calc(-50% - var(--a))); }

/* the sealed packs: click the stack to open one, ALL opens every one */
.dobj.packs { pointer-events: none; }
.dobj.packs > * { pointer-events: auto; }
.dobj.packs .all { position: absolute; right: calc(100% + var(--a) * 3); top: calc(var(--a) * 9); font-size: calc(var(--g) * 8 * var(--fs)); padding: calc(var(--g) * 2) calc(var(--g) * 5);
  background: var(--green); color: var(--ink); border: calc(var(--g) * 1.5) solid var(--ink); border-radius: calc(var(--g) * 3); box-shadow: 0 calc(var(--g) * 2) 0 var(--ink); }
/* its own state names: the global .empty (style.css, a list's empty note) has a top margin that dropped the stack */
.dobj.packs.allout .all { display: none; }
.dobj.packs.nopacks img.o { filter: grayscale(0.7) brightness(0.75); opacity: 0.55; }
#openAllW.ready img.o { animation: packsReady 2.4s steps(1) infinite; }
@keyframes packsReady { 0%, 70%, 100% { translate: 0 0; } 75%, 85% { translate: 0 calc(var(--a) * -1); } }

/* the display till: a coin chip over the cabinet's register, its right edge at --x so a longer amount or a larger text
   grows it toward the cabinet rather than off the screen (on the cabinet's top corner it covered the VAULT plate: QA3).
   (set by right, not a translate: the table view and a run's sweep move the desk's pieces by translate and transform) */
.till-chip { position: absolute; right: calc(var(--a) * (320 - var(--x))); top: calc(var(--a) * var(--y)); z-index: 3; display: grid; grid-template-columns: auto auto; align-items: center; gap: calc(var(--g) * 1) calc(var(--g) * 3);
  pointer-events: auto; font-family: var(--font-ui); font-weight: 700; font-size: calc(var(--g) * 7.5 * var(--fs)); color: var(--cash); text-shadow: none;
  background: var(--pillbg); border: calc(var(--g) * 1.5) solid var(--ink); border-radius: calc(var(--g) * 4); padding: calc(var(--g) * 1.5) calc(var(--g) * 4); }
.till-chip .coin { position: static; width: calc(var(--g) * 6); height: calc(var(--g) * 6); background: url(../art/desk/coin.png) center / contain no-repeat; image-rendering: pixelated; }
.till-chip .bar { grid-column: 1 / -1; height: calc(var(--g) * 2); background: #3a3446; border-radius: var(--g); overflow: hidden; }
.till-chip .bar i { display: block; height: 100%; background: var(--cash); }
.till-chip:hover { border-color: var(--brass-lt); }
.till-chip.full { animation: tillFull 1s steps(2) infinite; }
@keyframes tillFull { 50% { border-color: var(--brass-lt); } }
body.calm #openAllW.ready img.o, body.calm .till-chip.full { animation: none; }

/* the mat: START RUN in the middle, the next goals above it, Daily and Modes below (START RUN and the modes step down a
   little as the text grows, so the goals above never reach it). Packs opened at home land on the mat; while it is
   busy, START RUN steps down to the mat's front edge. */
.mat-ui { position: absolute; left: calc(var(--a) * var(--x)); top: calc(var(--a) * var(--y)); width: calc(var(--a) * var(--w)); height: calc(var(--a) * var(--h)); pointer-events: none; }
.mat-ui > * { pointer-events: auto; }
.mat-ui .goals { position: absolute; left: calc(var(--a) * 7); right: calc(var(--a) * 7); top: calc(var(--a) * 8); max-width: none; display: flex; flex-direction: column; align-items: center; gap: calc(var(--g) * 2); pointer-events: none; }
.mat-ui .goals > * { pointer-events: auto; }
.mat-ui .goals-h { font-family: var(--font-px); font-size: calc(var(--g) * 7 * var(--fs)); color: #cfe8c8; text-shadow: none; letter-spacing: 0.08em; }
.mat-ui .goal { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: calc(var(--g) * 7.5 * var(--fs) * var(--fit, 1)); color: var(--paper); text-shadow: none;
  background: rgba(20, 34, 25, 0.55); border: calc(var(--g) * 1) solid rgba(106, 160, 112, 0.45); border-radius: calc(var(--g) * 3); padding: calc(var(--g) * 1) calc(var(--g) * 5); }
.mat-ui .goal:hover { background: rgba(35, 32, 28, 0.85); border-color: var(--brass-lt); }
.mat-ui .goal::before { color: var(--brass-lt); }
.mat-ui .cta { position: absolute; left: 50%; top: calc(var(--a) * (39 + 12 * (var(--fs) - 1))); right: auto; bottom: auto; transform: translateX(-50%); width: calc(var(--a) * 68); height: calc(var(--a) * 22); padding: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: calc(var(--g) * 2); font-family: var(--font-px); color: var(--ink); text-shadow: none;
  background: var(--brass-lt); border: calc(var(--g) * 2) solid var(--ink); border-radius: calc(var(--g) * 2); animation: none;
  box-shadow: inset 0 calc(var(--g) * 2) 0 #fff2b0, inset 0 calc(var(--g) * -2) 0 var(--brass), 0 calc(var(--g) * 3) 0 var(--ink); transition: top 0.25s ease, width 0.25s ease, height 0.25s ease; }
/* START RUN reads on one line, and the plate grows to hold it: the pixel font prints on whole font pixels, up to a third
   larger than the art's size, so at 800×600 and 1000×620 the label ran past its plate and broke in two (QA3) */
.mat-ui .cta { min-width: max-content; padding: 0 calc(var(--a) * 3); }
.mat-ui .cta .t1 { font-size: calc(var(--g) * 18); font-weight: 700; letter-spacing: 0.06em; line-height: 1; white-space: nowrap; }
.mat-ui .cta .t2 { font-family: var(--font-ui); font-size: calc(var(--g) * 7 * var(--fs)); color: #5a3a14; white-space: nowrap; }
.mat-ui .cta:hover { background: #fff2b0; }
.mat-ui .cta:active { transform: translate(-50%, calc(var(--g) * 2)); box-shadow: inset 0 calc(var(--g) * 2) 0 #fff2b0, inset 0 calc(var(--g) * -2) 0 var(--brass), 0 var(--g) 0 var(--ink); }
.mat-ui .mode-row { position: absolute; left: 50%; top: calc(var(--a) * (67 + 12 * (var(--fs) - 1))); transform: translateX(-50%); display: flex; gap: calc(var(--g) * 4); }
.mat-ui .mode-btn { flex: none; font-size: calc(var(--g) * 7.5 * var(--fs)); color: var(--paper); text-shadow: none; background: var(--pillbg); border: calc(var(--g) * 1.5) solid var(--ink); border-radius: calc(var(--g) * 3);
  box-shadow: 0 calc(var(--g) * 2) 0 var(--ink); padding: calc(var(--g) * 2) calc(var(--g) * 6); }
.mat-ui .mode-btn:hover { border-color: var(--brass-lt); }
.mat-ui .mode-btn.ready { background: #24533d; border-color: var(--green); }
.mat-ui.busy .goals, .mat-ui.busy .mode-row { display: none; }
.mat-ui.busy .cta { top: calc(100% - var(--a) * 5); width: calc(var(--a) * 44); height: calc(var(--a) * 11); }
.mat-ui.busy .cta .t1 { font-size: calc(var(--g) * 10); }
.mat-ui.busy .cta .t2 { display: none; }
/* a card on show over the mat (its showcase, or a rare finish's callout, homeui.js): START RUN steps out from under its
   words, and comes back when it has gone */
.mat-ui .cta { transition: top 0.25s ease, width 0.25s ease, height 0.25s ease, opacity 0.2s ease; }
.mat-ui.shy .cta { opacity: 0; visibility: hidden; transition: top 0.25s ease, width 0.25s ease, height 0.25s ease, opacity 0.15s ease, visibility 0s 0.15s; }
body.calm .mat-ui .cta { transition: none; }

/* the HUD on the desk: bank and rank at the top left, the Rulebook and Settings at the top right */
#hud.home #topbar, #stage[data-mode="home"] #topbar { align-items: stretch; }
#stage[data-mode="home"] #rankPill { position: relative; right: auto; top: auto; }
#sysbar { position: absolute; right: calc(var(--u) * 8); top: calc(var(--u) * 5); display: flex; gap: calc(var(--u) * 5); padding: calc(var(--u) * 1) calc(var(--u) * 6); }
#sysbar button { position: relative; background: none; border: 0; padding: calc(var(--u) * 2); border-radius: calc(var(--u) * 6); }
#sysbar button.active { background: rgba(255, 255, 255, 0.18); }
#sysbar button:hover .ico { animation: icoHop 0.45s steps(4, end); }

/* an open place takes the table (css/areas.css); the ghost is the place being left, closing where it stands */
.panel-ghost { animation: none !important; pointer-events: none; z-index: 21; }
body.calm .desk-hero, body.calm .panel-ghost { display: none; }

/* the shared look: dark pills with ink edges, paper buttons, brass for what matters */
#hud .pill { background: var(--pillbg); border: calc(var(--u) * 1.5) solid var(--ink); box-shadow: 0 calc(var(--u) * 2) 0 rgba(13, 9, 7, 0.45); }
#hud #moneyPill.run { background: #3b3322; }
#hud .widget { background: var(--pillbg); border: calc(var(--u) * 1.5) solid var(--ink); box-shadow: 0 calc(var(--u) * 2) 0 rgba(13, 9, 7, 0.45); }
