/*!
 * Joystats hero stat: one fixed-size slot that cycles through four stats
 * (platform library count / total hours / genre hours / achievement).
 *
 * Fonts: Nine By Five NBP by Nate Halley (CC BY-SA 3.0, fontspace.com/nine-by-five-nbp-font-f15597)
 *        Press Start 2P by CodeMan38 (SIL OFL 1.1)
 * Both are bundled in /fonts. Keep the credits if you redistribute.
 *
 * THEMING: set any of the --joystats-* variables (below) on .js-stat or any ancestor.
 * Platforms are told apart by SHAPE ONLY; every color comes from these tokens.
 */

@font-face { font-family: "Nine By Five"; src: url("fonts/NineByFiveNbp.ttf") format("truetype"); font-display: block; }
@font-face { font-family: "Press Start 2P"; src: url("fonts/press-start-2p-latin-400-normal.woff2") format("woff2"); font-display: block; }

.js-stat {
  --js-slot:    var(--joystats-slot, var(--ink-1, #121824)); /* slot background */
  --js-card:    var(--joystats-card, var(--ink-2, #212938)); /* chips, counter cells, icon badge, meter track */
  --js-panel:   var(--joystats-panel, var(--ink-3, #2a3040)); /* cartridge / console bodies */
  --js-edge:    var(--joystats-edge, var(--ink-4, #3a4358)); /* body outlines, spine, icon badge border */
  --js-fg:      var(--joystats-fg, var(--tx, #e8edf7)); /* primary text */
  --js-white:   var(--joystats-title, #ffffff); /* achievement title */
  --js-muted:   var(--joystats-muted, var(--tx-dim, #8b96ab)); /* secondary text */
  --js-accent:  var(--joystats-accent, var(--cy, #2fe6ff)); /* cyan: label fill, counters, clickable words, game name */
  --js-accent2: var(--joystats-accent2, var(--pk, #ff5fd2)); /* pink: rarity, xbox bar, left joy-con */
  --js-gold:    var(--joystats-gold, var(--yl, #ffcf4a)); /* cartridge pins, right joy-con, achievement badge border */
  --js-ink:     var(--joystats-ink, #05222b); /* text on accent-colored label */
  --js-font:     var(--joystats-font,     "Nine By Five", "Courier New", monospace);
  --js-font-num: var(--joystats-font-num, "Press Start 2P", "Nine By Five", "Courier New", monospace);

  box-sizing: border-box; font-family: var(--js-font); font-size: 22px; line-height: 1.2; color: var(--js-fg);
  text-transform: none; letter-spacing: normal; text-align: left; font-weight: 400;
}
.js-stat *, .js-stat *::before, .js-stat *::after { box-sizing: border-box; }
/* neutralise theme button styles (WordPress themes style <button> aggressively) */
.js-stat :where(button) { appearance: none; -webkit-appearance: none; margin: 0; padding: 0; border: 0; border-radius: 0; background: none; box-shadow: none; font: inherit; color: inherit; text-transform: none; letter-spacing: normal; text-decoration: none; text-shadow: none; cursor: pointer; min-height: 0; min-width: 0; width: auto; height: auto; line-height: inherit; }
.js-stat :where(button):focus-visible { outline: 2px solid var(--js-accent); outline-offset: 2px; }

/* ---------- The slot: fixed footprint (162px tall, 330-400px wide) ---------- */
.js-stat { width: 100%; max-width: 400px; min-height: 162px; flex: 0 1 400px; min-width: 0; border-radius: 4px; background: var(--js-slot); padding: 10px 16px 12px; display: grid; grid-template-rows: 24px auto; gap: 8px; overflow: visible; }
.js-s-val { display: flex; align-items: center; justify-content: center; min-width: 0; overflow: hidden; }

/* view: library, one shape per platform (shape only, colors come from theme tokens) */
.js-m { position: relative; background: var(--js-panel); }
.js-lab { background: var(--js-accent); color: var(--js-ink); box-shadow: inset 0 0 0 2px rgba(255,255,255,.4); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-width: 0; position: relative; }
.js-n { display: flex; align-items: center; justify-content: center; font-family: var(--js-font-num); font-weight: 400; line-height: .9; white-space: nowrap; }
.js-t { font-size: 22px; line-height: 1; white-space: nowrap; color: var(--js-ink); }
.js-pick { background: var(--js-card); padding: 1px 6px 2px; line-height: 1; vertical-align: baseline; }
.js-pick { margin: 0 1px 0 3px; }
.js-ach .js-sub .js-pick { margin-left: -6px; }
.js-lab .js-pick { color: var(--js-fg); background: var(--js-ink); }
.js-lab .js-pick { margin: 0 1px 0 0; }
.js-pick { animation: js-pulse 2.4s ease-in-out infinite; }
.js-lab .js-pick { animation-name: js-pulse-lab; }
.js-pick:hover { animation: none; box-shadow: 0 0 0 2px color-mix(in srgb, var(--js-accent) 80%, transparent); }
.js-lab .js-pick:hover { box-shadow: 0 0 0 2px rgba(255,255,255,.7); }
@keyframes js-pulse { 0%, 100% { box-shadow: 0 0 0 2px color-mix(in srgb, var(--js-accent) 0%, transparent); } 50% { box-shadow: 0 0 0 2px color-mix(in srgb, var(--js-accent) 60%, transparent); } }
@keyframes js-pulse-lab { 0%, 100% { box-shadow: 0 0 0 0 rgba(255,255,255,0); } 50% { box-shadow: 0 0 0 2px rgba(255,255,255,.6); } }
@media (prefers-reduced-motion: reduce) { .js-pick { animation: none; } }
.js-pins { width: 6px; height: 8px; margin-left: 10px; background: var(--js-gold); }

.js-m-cart { width: 210px; height: 108px; display: grid; grid-template-rows: 1fr 8px; gap: 6px; padding: 6px 6px 7px; box-shadow: inset 0 0 0 2px var(--js-edge); clip-path: polygon(0 0,calc(100% - 18px) 0,100% 18px,100% 100%,0 100%); }
.js-m-cart .js-lab { gap: 9px; }
.js-m-cart .js-pins { box-shadow: 12px 0 var(--js-gold), 24px 0 var(--js-gold), 36px 0 var(--js-gold), 48px 0 var(--js-gold), 60px 0 var(--js-gold), 72px 0 var(--js-gold), 84px 0 var(--js-gold), 96px 0 var(--js-gold), 108px 0 var(--js-gold), 120px 0 var(--js-gold), 132px 0 var(--js-gold), 144px 0 var(--js-gold), 156px 0 var(--js-gold); }

.js-m-floppy { width: 220px; height: 108px; clip-path: polygon(0 0,calc(100% - 14px) 0,100% 14px,100% 100%,0 100%); }
.js-m-floppy .js-shutter { position: absolute; top: 0; left: 28px; width: 80px; height: 34px; background: var(--js-muted); }
.js-m-floppy .js-shutter::after { content: ""; position: absolute; top: 6px; right: 8px; width: 10px; height: 22px; background: var(--js-panel); }
.js-m-floppy .js-lab { position: absolute; left: 10px; right: 10px; bottom: 0; height: 72px; gap: 4px; box-shadow: none; }

.js-m-switch { width: 286px; height: 108px; display: flex; gap: 4px; background: none; }
.js-m-switch .js-jc { width: 30px; height: 100%; background: var(--js-edge); position: relative; flex: none; }
.js-m-switch .js-jc.js-l { clip-path: polygon(10px 0,100% 0,100% 100%,10px 100%,0 calc(100% - 10px),0 10px); }
.js-m-switch .js-jc.js-r { clip-path: polygon(0 0,calc(100% - 10px) 0,100% 10px,100% calc(100% - 10px),calc(100% - 10px) 100%,0 100%); }
.js-m-switch .js-jc i { position: absolute; display: block; }
.js-m-switch .js-jc.js-l { background: var(--js-accent2); }
.js-m-switch .js-jc.js-r { background: var(--js-gold); }
.js-m-switch .js-jc .js-s { width: 12px; height: 12px; background: var(--js-slot); }
.js-m-switch .js-jc .js-b { width: 6px; height: 6px; background: var(--js-slot); }
.js-m-switch .js-jc.js-l .js-s { left: 10px; top: 16px; }
.js-m-switch .js-jc.js-l .js-b { left: 13px; bottom: 16px; }
.js-m-switch .js-jc.js-r .js-b { left: 10px; top: 16px; }
.js-m-switch .js-jc.js-r .js-b + .js-b { top: 28px; }
.js-m-switch .js-jc.js-r .js-s { left: 9px; bottom: 16px; }
.js-m-switch .js-scr { flex: 1; min-width: 0; background: var(--js-panel); box-shadow: inset 0 0 0 2px var(--js-edge); padding: 8px; display: grid; }

.js-m-case { width: 246px; height: 108px; box-shadow: inset 0 0 0 2px var(--js-edge); }
.js-m-case .js-spine { position: absolute; left: 0; top: 0; bottom: 0; width: 24px; background: var(--js-edge); display: grid; align-content: center; justify-items: center; gap: 8px; }
.js-m-case .js-spine i { width: 10px; height: 4px; background: var(--js-slot); display: block; }
.js-m-case .js-cover { position: absolute; left: 32px; right: 8px; top: 8px; bottom: 8px; display: grid; grid-template-rows: 8px 1fr; gap: 4px; }
.js-m-case .js-cover b { background: var(--js-accent2); display: block; }

.js-m-ps { width: 298px; height: 108px; position: relative; background: none; }
.js-m-ps .js-disc { position: absolute; right: 0; top: 8px; display: block; shape-rendering: crispEdges; }
.js-m-ps .js-disc .js-d1 { fill: var(--js-muted); }
.js-m-ps .js-disc .js-d2 { fill: var(--js-edge); }
.js-m-ps .js-sleeve { position: absolute; left: 0; top: 0; width: 266px; height: 108px; background: var(--js-panel); box-shadow: inset 0 0 0 2px var(--js-edge); padding: 10px; display: grid; }
.js-m-ps .js-lab { gap: 10px; }

/* view: hours counters */
.js-counter { --js-h: 42px; display: flex; align-items: flex-end; gap: 4px; }
.js-cell { width: 30px; height: var(--js-h); display: grid; place-items: center; background: var(--js-card); color: var(--js-accent); font-family: var(--js-font-num); font-weight: 400; font-size: 20px; line-height: 1; overflow: hidden; }
.js-cell.js-roll { display: block; }
.js-cell.js-blank { background: var(--js-card); opacity: .5; }
.js-dot { width: 6px; height: 6px; background: var(--mg); margin-bottom: 4px; flex: none; }
.js-strip { display: flex; flex-direction: column; transform: translateY(calc(-1 * var(--js-h))); animation: js-roll .7s cubic-bezier(.2,.7,.2,1) both; animation-delay: calc(var(--js-i) * 70ms); }
.js-strip span { height: var(--js-h); display: grid; place-items: center; }
@keyframes js-roll { from { transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { .js-strip { animation: none; } }
.js-hrs { display: flex; align-items: flex-start; justify-content: center; gap: 12px; width: 100%; min-width: 0; }
.js-badge { flex: none; }
.js-hrs .js-stack { align-items: flex-start; min-width: 0; }
.js-hrs .js-sub { white-space: normal; line-height: 1.05; }
.js-hrs .js-sub .js-pick { margin-left: 0; display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: baseline; }
.js-stack { display: flex; flex-direction: column; align-items: center; gap: 9px; }
.js-sub { font-size: 22px; line-height: 1; white-space: nowrap; color: var(--js-muted); }
.js-ach .js-name { font-size: 24px; line-height: 1; color: var(--js-white); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; text-transform: none; }
.js-ach .js-name span { color: var(--js-muted); }
.js-ach .js-name .js-t1 { color: var(--js-gold); }
.js-ach .js-name a.js-game { text-decoration: none; }
.js-ach .js-name.js-split { display: block; }
.js-ach .js-name.js-split .js-t1, .js-ach .js-name.js-split .js-game { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.js-ach .js-name.js-split .js-dash { display: none; }
.js-ach .js-name .js-game { color: var(--js-accent); }
.js-ach .js-sub { margin-bottom: 3px; }
.js-pick { border: 0; font: inherit; color: var(--js-accent); }

/* view: achievement */
.js-ach { display: grid; grid-template-columns: auto minmax(0,auto); justify-content: center; gap: 14px; align-items: center; width: 100%; }
/* The badge paints nothing: the icon floats with no background. */
.js-badge { width: 48px; height: 48px; display: grid; place-items: center; background: none; border: none; }
.js-ach .js-rar { font-size: 22px; display: flex; align-items: center; gap: 8px; color: var(--js-muted); line-height: 1; margin-top: 4px; white-space: nowrap; }
.js-pct { font-family: var(--js-font-num); font-weight: 400; font-size: 12px; color: var(--js-accent2); white-space: nowrap; flex: none; }
.js-meter { flex: none; width: 88px; height: 8px; background: var(--js-card); position: relative; min-width: 24px; }
.js-meter::before { content: ""; position: absolute; inset: 0; width: var(--js-p, 6%); background: var(--js-accent2); }


/* ---------- icon badge: drop your own <img>/<svg> inside (26px in hours badge, 33px in achievement) ---------- */
.js-badge > img, .js-badge > svg { display: block; max-width: 100%; max-height: 100%; image-rendering: pixelated; shape-rendering: crispEdges; }
.js-hrs .js-badge > img, .js-hrs .js-badge > svg { width: 26px; height: 26px; }
.js-ach .js-badge > img, .js-ach .js-badge > svg { width: 33px; height: 33px; }
/* The dashed placeholder survives only when no icon markup and no
   JoyStats fallback image could be built (no base URL and no caller
   icon); the JS default is the JoyStats icon, not the dashed box. */
.js-ph { display: block; width: 18px; height: 18px; border: 2px dashed var(--js-muted); }
.js-ach .js-name .js-t1 { color: var(--js-white); }

/* No border on hero stat (user request). */
.js-stat { border: none !important; outline: none !important; box-shadow: none !important; }

/* No dark container. */
.js-stat { background: none !important; }

/* Hero stat badge: no box, larger icon. */
.js-badge {
	background: none !important;
	border: none !important;
	width: auto !important;
	height: auto !important;
	padding: 0 !important;
}
.js-badge img {
	width: 40px !important;
	height: 40px !important;
}

/* Hero stat: fixed width, no jumping. */
.js-stat {
	width: 400px !important;
	min-width: 400px !important;
	max-width: 400px !important;
	flex: 0 0 400px !important;
}
