/* Games lab map hub (docs/games-lab-v2-contract.md, WP5): the approved map
   prototype between the site header and footer. Every colour is a --lm-*
   custom property set by map.js (game art lives in JS, never here) or a
   theme token. Radii only from 0, 8, 10, 12, 16 and 999. */

.lab-map {
  position: relative;
  padding-top: var(--header-h);
  background: var(--lm-side-m);
  color: var(--lm-ink);
  font-family: var(--font-body);
  overflow-x: clip;
}
@media (min-width: 441px) { .lab-map { background: var(--lm-side); } }
.lab-map *, .lab-map *::before, .lab-map *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
.lab-map button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
.lab-map h1.visually-hidden { margin: 0; }

/* the bar: stars, streak, collection, sound; sticky under the site header */
.lm-bar {
  position: sticky; top: var(--header-h); z-index: 30; height: 54px;
  background: var(--lm-bar);
  -webkit-backdrop-filter: blur(14px) saturate(1.4); backdrop-filter: blur(14px) saturate(1.4);
  box-shadow: var(--lm-bar-sh);
}
.lm-bar-in { width: min(100%, 440px); height: 54px; margin: 0 auto; display: flex; align-items: center; gap: 6px; padding: 0 10px 0 12px; }
.lm-stat {
  display: flex; align-items: center; gap: 6px; height: 40px; padding: 0 8px; border-radius: 12px;
  font-family: var(--font-display); font-weight: 800; font-size: 18px; letter-spacing: -.01em;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.lm-stat svg { display: block; }
.lm-streak svg { width: 22px; height: 26px; }
.lm-streak .fl { transform-box: fill-box; transform-origin: 50% 100%; animation: lm-flick 1.6s ease-in-out infinite; }
.lm-streak .fl2 { animation-duration: 1.1s; animation-delay: -.4s; }
.lm-stars svg { width: 24px; height: 24px; }
.lm-stat b { display: inline-block; min-width: 1ch; font-weight: 800; }
.lab-map .bump { animation: lm-bump .36s cubic-bezier(.3,1.6,.5,1); }
.lm-spacer { flex: 1; }
.lm-ibtn { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; transition: transform .15s, background .2s; }
.lm-ibtn:active { transform: scale(.9); background: var(--lm-press); }
.lm-ibtn:focus-visible { outline: 2px solid var(--lm-teal); outline-offset: 2px; }
.lm-ibtn svg { width: 26px; height: 26px; display: block; }
.lab-map .lm-mut { display: none; }
.lab-map.is-muted .lm-snd { display: none; }
.lab-map.is-muted .lm-mut { display: inline; }

/* the map */
.lm-stage { position: relative; }
.lm-map {
  position: relative; width: min(100%, 440px); margin: 0 auto; overflow: hidden;
  box-shadow: var(--lm-map-sh);
}
.lm-layer { position: absolute; left: 0; top: 0; width: 100%; height: 100%; }
.lm-far { z-index: 1; overflow: hidden; }
.lm-land { z-index: 2; }
.lm-decor { z-index: 3; }
.lm-road { z-index: 4; display: block; overflow: visible; }
.lm-amb { z-index: 5; pointer-events: none; }
.lm-near { z-index: 6; pointer-events: none; }
.lm-ui { z-index: 8; pointer-events: none; }
.lm-wamb { pointer-events: none; }
.lm-wsvg { position: absolute; left: 0; width: 100%; display: block; overflow: visible; }
.lab-map .fw { position: absolute; left: 0; width: 100%; overflow: hidden;
  -webkit-mask-image: linear-gradient(transparent, #000 160px, #000 calc(100% - 160px), transparent);
  mask-image: linear-gradient(transparent, #000 160px, #000 calc(100% - 160px), transparent); }
.lab-map .fi { position: absolute; left: 0; width: 100%; will-change: transform; }
.lab-map .fi > svg { position: absolute; left: 0; top: 0; width: 100%; height: 100%; display: block; }
.lab-map .o { position: absolute; transform: translate(-50%, -100%); pointer-events: none; }
.lab-map .o > svg { display: block; width: 100%; height: auto; overflow: visible; }
.lab-map .o.free { transform: none; }
.lab-map .nc { position: absolute; will-change: transform; }
.lab-map .nc > svg { display: block; width: 100%; height: auto; }

/* the one line under the first node */
.lm-note {
  position: absolute; z-index: 7; width: max-content; max-width: 72%; text-wrap: balance; margin: 0; transform: translateX(-50%);
  padding: 7px 12px 8px; border-radius: 12px;
  background: var(--lm-note-bg); border: 1.5px solid var(--lm-note-line); box-shadow: var(--lm-note-sh);
  font-size: 13px; line-height: 1.45; font-weight: 500; text-align: center; color: var(--lm-note);
  pointer-events: none;
}

/* ambient motion */
.lab-map .a-bob { transform-origin: 50% 80%; animation: lm-bob 3.4s ease-in-out infinite; }
.lab-map .a-bob2 { animation: lm-bob2 2.8s ease-in-out infinite; }
.lab-map .a-sway { transform-origin: 50% 100%; animation: lm-sway 2.8s ease-in-out infinite; }
.lab-map .a-drift { animation: lm-drift 16s ease-in-out infinite alternate; }
.lab-map .a-drift2 { animation: lm-drift 24s ease-in-out infinite alternate-reverse; }
.lab-map .a-spin { animation: lm-spin 9s linear infinite; transform-origin: 50% 50%; }
.lab-map .a-wave { animation: lm-wave 3.2s ease-in-out infinite alternate; }
.lab-map .a-glint { animation: lm-glint 3s ease-in-out infinite; }
.lab-map .a-fly { animation: lm-fly 26s linear infinite; }
.lab-map .a-flyr { animation: lm-flyr 30s linear infinite; }
.lab-map .a-fish { animation: lm-fish 14s ease-in-out infinite alternate; }
.lab-map .a-glow { animation: lm-glow 2.6s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.lab-map .wing { transform-box: fill-box; transform-origin: 50% 100%; animation: lm-flap .5s ease-in-out infinite alternate; }
.lab-map .fall line { animation: lm-fallw .7s linear infinite; }
.lab-map .fall line:nth-child(2) { animation-duration: .9s; }
.lab-map .fall line:nth-child(3) { animation-duration: .6s; }
.lab-map .puff { transform-box: fill-box; transform-origin: center; animation: lm-puff 4.2s ease-out infinite; opacity: 0; }
.lab-map .puff:nth-child(2) { animation-delay: 1.4s; }
.lab-map .puff:nth-child(3) { animation-delay: 2.8s; }
.lab-map .flag { transform-box: fill-box; transform-origin: 0 50%; animation: lm-flagw 1.6s ease-in-out infinite alternate; }
.lab-map .flake { position: absolute; width: 5px; height: 5px; border-radius: 999px; background: var(--lm-white); box-shadow: var(--lm-flake-sh); animation: lm-snow 9s linear infinite; opacity: 0; }
.lab-map .mist { position: absolute; border-radius: 999px; background: var(--lm-mist); animation: lm-drift 11s ease-in-out infinite alternate; }

/* nodes */
.lab-map .node { cursor: pointer; outline: none; }
.lab-map .node .nb { transform-box: view-box; transform-origin: 0 12px; transition: transform .14s ease; }
.lab-map .node.press .nb { transform: scale(.93); }
.lab-map .node:focus-visible .nb { filter: var(--lm-focus); }
.lab-map .pulse { transform-box: fill-box; transform-origin: center; animation: lm-pulse 1.9s ease-out infinite; }
.lab-map .pulse.p2 { animation-delay: .95s; }
.lab-map .shake { animation: lm-shake .46s cubic-bezier(.36,.07,.19,.97); }
.lab-map .twinkle { transform-box: fill-box; transform-origin: center; animation: lm-twinkle 2.2s ease-in-out infinite; }
.lab-map .lm-trav { cursor: pointer; }
.lab-map .trav-idle { transform-box: view-box; transform-origin: 0 0; animation: lm-breathe 2.6s ease-in-out infinite; }
.lab-map .eyes { transform-box: fill-box; transform-origin: center; animation: lm-blink 4.6s infinite; }
.lab-map .scarf { transform-box: fill-box; transform-origin: 0 0; animation: lm-scarf 1.4s ease-in-out infinite alternate; }

/* level card, rising from its node */
.lm-card { position: absolute; width: 232px; pointer-events: auto; z-index: 8; }
.lm-card-in {
  position: relative; background: var(--lm-white); border-radius: 16px; padding: 14px;
  box-shadow: var(--lm-card-sh);
  transform-origin: var(--tx) calc(100% + 14px); animation: lm-rise .5s cubic-bezier(.18,1.4,.42,1) both;
}
.lm-card.below .lm-card-in { transform-origin: var(--tx) -14px; }
.lm-card.out .lm-card-in { animation: lm-sink .2s ease-in both; }
.lm-tip { position: absolute; width: 20px; height: 20px; background: var(--lm-white); border-radius: 0; transform: rotate(45deg); left: calc(var(--tx) - 10px); bottom: -8px; }
.lm-card.below .lm-tip { top: -8px; bottom: auto; }
.lm-card-top { display: flex; align-items: center; gap: 12px; }
.lm-card-icon { width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; box-shadow: var(--lm-icon-sh); flex: none; }
.lm-card-icon svg { width: 40px; height: 40px; display: block; }
.lm-card-lvl { font-family: var(--font-display); font-weight: 800; font-size: 23px; letter-spacing: -.02em; line-height: 1.05; }
.lm-card-game { font-size: 13px; font-weight: 600; color: var(--lm-muted); margin-top: 3px; }
.lm-card-stars { display: flex; justify-content: center; gap: 8px; margin: 12px 0; }
.lm-card-stars svg { width: 34px; height: 34px; display: block; animation: lm-spop .5s cubic-bezier(.2,1.6,.4,1) both; }
.lm-card-stars svg:nth-child(2) { animation-delay: .07s; transform: translateY(-4px); }
.lm-card-stars svg:nth-child(3) { animation-delay: .14s; }
.lm-play {
  display: flex; align-items: center; justify-content: center; gap: 9px; height: 52px; border-radius: 16px;
  background: var(--lm-teal); color: var(--lm-white); text-decoration: none; font-weight: 700; font-size: 17px;
  box-shadow: var(--lm-play-sh); transition: transform .08s, box-shadow .08s;
}
.lm-play:hover { color: var(--lm-white); text-decoration: none; }
.lm-play:active { transform: translateY(4px); box-shadow: var(--lm-play-sh2); }
.lm-play:focus-visible { outline: 2px solid var(--lm-teal-d); outline-offset: 3px; }
.lm-play svg { width: 16px; height: 16px; }

/* celebration overlay */
.lm-fx { position: fixed; inset: 0; pointer-events: none; z-index: 140; }
.lm-glow {
  position: fixed; left: 50%; top: 42%; width: 520px; height: 520px; margin: -260px 0 0 -260px; border-radius: 999px;
  background: var(--lm-glow);
  -webkit-mask: radial-gradient(closest-side, #000 18%, transparent 72%); mask: radial-gradient(closest-side, #000 18%, transparent 72%);
  opacity: 0; transform: scale(.4); pointer-events: none; z-index: 139;
  transition: opacity .35s, transform .6s cubic-bezier(.2,1.2,.4,1);
}
.lm-glow.on { opacity: 1; transform: scale(1); animation: lm-rays 9s linear infinite; }
.lm-wash { position: fixed; inset: 0; background: var(--lm-wash); opacity: 0; pointer-events: none; z-index: 138; transition: opacity .35s; }
.lm-wash.on { opacity: 1; }
.lab-map .fstar { position: fixed; left: 0; top: 0; width: 70px; height: 70px; margin: -35px 0 0 -35px; will-change: transform; }
.lab-map .fstar svg { width: 100%; height: 100%; display: block; filter: var(--lm-fstar-sh); }
.lab-map .spark { position: fixed; width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 999px; background: var(--lm-spark); box-shadow: var(--lm-spark-sh); animation: lm-sparkf .6s ease-out forwards; }

/* collection sheet */
.lm-scrim { position: fixed; inset: 0; background: var(--lm-scrim); opacity: 0; pointer-events: none; transition: opacity .28s; z-index: 150; }
.lm-scrim.on { opacity: 1; pointer-events: auto; }
.lm-sheet {
  position: fixed; left: 50%; bottom: 0; width: min(100%, 440px); transform: translate(-50%, 105%);
  transition: transform .46s cubic-bezier(.2,1.12,.35,1); z-index: 151; background: var(--lm-white);
  border-radius: 16px 16px 0 0; padding: 10px 18px calc(22px + env(safe-area-inset-bottom)); box-shadow: var(--lm-sheet-sh);
  visibility: hidden;
}
.lm-sheet.on { transform: translate(-50%, 0); visibility: visible; }
.lm-grab { width: 44px; height: 5px; border-radius: 999px; background: var(--lm-grab); margin: 0 auto 12px; }
.lm-sh-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.lm-sh-head h2 { margin: 0; font-family: var(--font-display); font-weight: 800; font-size: 22px; letter-spacing: -.02em; color: var(--lm-ink); }
.lm-sh-count { font-size: 14px; color: var(--lm-muted); font-weight: 600; }
.lm-sh-head .lm-ibtn { margin-left: auto; }
.lm-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.lm-item {
  aspect-ratio: 1 / .92; border-radius: 16px; background: var(--lm-item); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px; box-shadow: var(--lm-item-sh);
}
.lm-item svg { width: 50%; height: auto; display: block; }
.lm-item.got { background: var(--lm-item-got); box-shadow: var(--lm-item-got-sh); }
.lm-item.miss svg { filter: brightness(0) opacity(.13); }
.lm-item small { font-size: 12px; font-weight: 600; color: var(--lm-item-name); min-height: 15px; }
.lm-sheet.on .lm-item { animation: lm-tilein .4s cubic-bezier(.2,1.4,.4,1) both; }

@keyframes lm-flick { 0%, 100% { transform: scale(1, 1); } 50% { transform: scale(.92, 1.08); } }
@keyframes lm-bump { 0% { transform: scale(1); } 40% { transform: scale(1.32); } 100% { transform: scale(1); } }
@keyframes lm-bob { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-6%) rotate(2.5deg); } }
@keyframes lm-bob2 { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-9%); } }
@keyframes lm-sway { 0%, 100% { transform: rotate(-7deg); } 50% { transform: rotate(7deg); } }
@keyframes lm-drift { from { transform: translateX(-12%); } to { transform: translateX(12%); } }
@keyframes lm-spin { to { transform: rotate(360deg); } }
@keyframes lm-wave { from { transform: translateX(-10%); opacity: .35; } to { transform: translateX(12%); opacity: .95; } }
@keyframes lm-glint { 0%, 100% { opacity: 0; transform: scale(.4); } 50% { opacity: 1; transform: scale(1); } }
@keyframes lm-fly { 0% { transform: translate(-200%, 0); } 25% { transform: translate(300%, -60%); } 50% { transform: translate(800%, 20%); } 75% { transform: translate(1300%, -40%); } 100% { transform: translate(1800%, 0); } }
@keyframes lm-flyr { 0% { transform: translate(1800%, 0) scaleX(-1); } 50% { transform: translate(800%, -70%) scaleX(-1); } 100% { transform: translate(-200%, 10%) scaleX(-1); } }
@keyframes lm-fish { from { transform: translate(-30%, 0) rotate(-6deg); } to { transform: translate(130%, 20%) rotate(6deg); } }
@keyframes lm-glow { 0%, 100% { opacity: .55; transform: scale(.85); } 50% { opacity: 1; transform: scale(1.15); } }
@keyframes lm-flap { from { transform: scaleY(1); } to { transform: scaleY(-.35); } }
@keyframes lm-fallw { to { stroke-dashoffset: -28; } }
@keyframes lm-puff { 0% { opacity: 0; transform: translate(0, 0) scale(.5); } 15% { opacity: .85; } 100% { opacity: 0; transform: translate(10px, -34px) scale(1.9); } }
@keyframes lm-flagw { from { transform: skewY(-6deg) scaleX(.94); } to { transform: skewY(5deg) scaleX(1.04); } }
@keyframes lm-snow { 0% { transform: translate(0, 0); opacity: 0; } 12% { opacity: .95; } 100% { transform: translate(18px, 170px); opacity: 0; } }
@keyframes lm-pulse { 0% { transform: scale(.9); opacity: .85; } 100% { transform: scale(1.55); opacity: 0; } }
@keyframes lm-shake { 10%, 90% { transform: translateX(-1.5px); } 20%, 80% { transform: translateX(3px); } 30%, 50%, 70% { transform: translateX(-5px); } 40%, 60% { transform: translateX(5px); } }
@keyframes lm-twinkle { 0%, 100% { opacity: .2; transform: scale(.5); } 50% { opacity: 1; transform: scale(1.1); } }
@keyframes lm-breathe { 0%, 100% { transform: scale(1, 1); } 50% { transform: scale(1.035, .965); } }
@keyframes lm-blink { 0%, 93%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
@keyframes lm-scarf { from { transform: rotate(-8deg); } to { transform: rotate(10deg); } }
@keyframes lm-rise { 0% { opacity: 0; transform: translateY(18px) scale(.3); } 60% { opacity: 1; } 100% { opacity: 1; transform: none; } }
@keyframes lm-sink { to { opacity: 0; transform: translateY(10px) scale(.7); } }
@keyframes lm-spop { 0% { opacity: 0; transform: scale(0) rotate(-40deg); } 100% { opacity: 1; } }
@keyframes lm-rays { to { transform: scale(1) rotate(360deg); } }
@keyframes lm-sparkf { 0% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(.2) translateY(14px); } }
@keyframes lm-tilein { 0% { opacity: 0; transform: translateY(16px) scale(.85); } 100% { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .lab-map *, .lab-map *::before, .lab-map *::after { animation: none !important; transition: none !important; }
  .lab-map .flake, .lab-map .puff { display: none; }
}
