/* ═════════════════════════════ THE BASEMENT (floor B) ═════════════════════════════
   The shared fb-* frame lives in workshop.css. Room: 1200 × 600 (phones: 400 × 700). */

.floor-basement {
  --fb-wall: #17161F;
  background:
    radial-gradient(40% 50% at 18% 70%, rgba(255, 120, 40, .16), transparent 70%),
    radial-gradient(30% 40% at 34% 30%, rgba(255, 210, 120, .10), transparent 70%),
    linear-gradient(180deg, #14131C, #1B1A25 60%, #1E1C26);
}
.floor-basement::before { /* the warm light from the open vault */
  content: ''; position: absolute; inset: 0; z-index: 1; pointer-events: none; opacity: 0; transition: opacity 1.4s ease;
  background: radial-gradient(38% 60% at 78% 78%, rgba(255, 196, 110, .26), transparent 70%);
}
.floor-basement.is-vault-open::before { opacity: 1; }
.bm-back {
  background:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, .35) 0 4px, transparent 4px 46px),
    repeating-linear-gradient(90deg, transparent 0 92px, rgba(0, 0, 0, .28) 92px 96px),
    linear-gradient(180deg, #1F1D29, #242230);
}
.bm-pipes-back { top: 132px; left: 0; width: 100%; height: 80px; opacity: .85; }
.bm-arch { width: clamp(120px, 14vw, 230px); left: max(12px, 2vw); bottom: calc(140px + 12%); opacity: .7; }
.bm-web { position: absolute; }
.bm-web-l { width: 110px; left: 0; top: 140px; }
@media (max-width: 1399px) { .bm-web-l { display: none; } }
@media (max-width: 760px) { .bm-arch { display: none; } }

.bm-front .bm-web-r { right: 0; top: 110px; width: clamp(90px, 7vw, 130px); }
@media (max-width: 1479px) { .bm-front .bm-web-r { display: none; } }
.bm-front .bm-pipe-f { left: -2%; bottom: 60px; width: 38%; height: 70px; opacity: .95; }
@media (max-width: 1100px) { .bm-front .bm-pipe-f { display: none; } }

.bm-ground {
  background:
    linear-gradient(180deg, #4A4757 0 5px, transparent 5px),
    repeating-linear-gradient(90deg, transparent 0 116px, rgba(13, 17, 32, .9) 116px 120px),
    repeating-linear-gradient(0deg, transparent 0 26px, rgba(13, 17, 32, .6) 26px 29px),
    linear-gradient(180deg, #3A3846, #2B2935);
}

/* positions: desktop room 1200 × 600 */
.bm-boiler { --x: 8;   --y: 126; --w: 270; }
.bm-sign   { --x: 300; --y: 50;  --w: 150; }
.bm-bulb   { --x: 470; --y: 12;  --w: 50; z-index: 4; pointer-events: none; }
.bm-count  { --x: 548; --y: 262; --w: 176; }
.bm-unit   { --x: 330; --y: 256; --w: 200; z-index: 5; }
.bm-crates { --x: 564; --y: 412; --w: 150; }
.bm-drip   { --x: 700; --y: 190; --w: 52; pointer-events: none; }
.bm-doodle { --x: 580; --y: 96;  --w: 92; }
.bm-mouse  { --x: 284; --y: 508; --w: 44; }
.bm-door   { --x: 744; --y: 54;  --w: 430; z-index: 3; }
.bm-plaque { --x: 849; --y: 4;   --w: 220; z-index: 4; }

/* boiler */
.bm-boiler svg { transform-origin: 50% 100%; }
.bm-boiler:hover svg { transform: scale(1.01, .99); transition: transform .3s var(--spring); }
.bm-boiler.is-bang svg { animation: br-rumble .08s linear 6; }
.bm-fire { animation: bm-fire 1.6s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 100%; }
@keyframes bm-fire { 0%, 100% { transform: scale(1, 1); opacity: 1; } 33% { transform: scale(1.04, .9); opacity: .88; } 66% { transform: scale(.97, 1.08); opacity: .95; } }
.bm-gauge { transform-box: view-box; transform-origin: 135px 118px; animation: bm-gauge 3s ease-in-out infinite; }
@keyframes bm-gauge { 0%, 100% { transform: rotate(-30deg); } 50% { transform: rotate(40deg); } }
.bm-boiler.is-bang .bm-gauge { animation: none; transform: rotate(75deg); }
.bm-vp { opacity: 0; transform-box: fill-box; transform-origin: center; animation: ws-puff 3.4s ease-out infinite; }
.bm-vp.p2 { animation-delay: -1.7s; }

/* the bulb */
.bm-bulb svg { transform-origin: 50% 0; animation: bm-swing 4.5s ease-in-out infinite; }
@keyframes bm-swing { 0%, 100% { transform: rotate(4deg); } 50% { transform: rotate(-4deg); } }
.bm-bulb-glow { animation: bm-hum 5s ease-in-out infinite; }
@keyframes bm-hum { 0%, 100% { opacity: .85; } 50% { opacity: 1; } }

/* the drip */
.bm-drop { transform-box: view-box; animation: bm-drop 2.6s cubic-bezier(.55, 0, 1, .45) infinite; }
@keyframes bm-drop { 0%, 30% { transform: translateY(0) scale(.4); opacity: 0; } 40% { transform: translateY(0) scale(1); opacity: 1; } 96% { transform: translateY(412px); opacity: 1; } 100% { transform: translateY(418px); opacity: 0; } }
.bm-ripple { transform-box: fill-box; transform-origin: center; animation: bm-ripple 2.6s ease-out infinite; }
@keyframes bm-ripple { 0%, 94% { transform: scale(.2); opacity: 0; } 96% { opacity: 1; } 100% { transform: scale(2.4); opacity: 0; } }

/* the mouse hole */
.bm-eyes { animation: bm-blink 4.6s steps(1) infinite; transform-box: fill-box; transform-origin: center; }
@keyframes bm-blink { 0%, 92%, 100% { transform: scaleY(1); } 94% { transform: scaleY(.1); } }
.bm-mouse.is-gone .bm-eyes { opacity: 0; animation: none; transition: opacity .1s; }

/* ── DO NOT PRESS ── */
.bm-count {
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding: .5em .7em; text-align: center; gap: .1em;
  font: 600 max(12.5px, calc(15 * var(--u)))/1.15 var(--font-display); color: var(--cream);
  background: #232A40; border: calc(4 * var(--u)) solid var(--outline); border-radius: calc(12 * var(--u));
  box-shadow: inset 0 0 0 calc(2.5 * var(--u)) var(--brass), 0 calc(5 * var(--u)) 0 rgba(0, 0, 0, .35);
}
.bm-count b { color: var(--molten); font-variant-numeric: tabular-nums; }
.bm-count.is-bump b { display: inline-block; animation: squash .45s var(--spring); }
.bm-unit { transition: translate .28s var(--spring); }
.bm-unit > .bm-ped { width: 100%; height: auto; overflow: visible; }
.bm-press { position: absolute; left: 25%; top: 10.4%; width: 50%; z-index: 1; }
.bm-press svg { display: block; width: 100%; height: auto; overflow: visible; transform-origin: 50% 90%; transition: transform .12s ease-out; }
.bm-press:hover svg { transform: scale(1.03, .97); }
.bm-press:active svg, .bm-press.is-down svg { transform: scaleY(.62); }
.bm-press:focus-visible { outline: 3px solid var(--molten); outline-offset: 6px; border-radius: 50%; }
.bm-lid {
  position: absolute; left: 10%; top: .4%; width: 80%; z-index: 2;
  transform-origin: 50% 6%; transform: perspective(420px) rotateX(0deg); transition: transform .55s var(--spring);
}
.bm-lid svg { display: block; width: 100%; height: auto; overflow: visible; }
.bm-lid:hover { transform: perspective(420px) rotateX(-14deg); }
.bm-unit.is-open .bm-lid { transform: perspective(420px) rotateX(-128deg); }
.bm-unit.is-open .bm-lid:hover { transform: perspective(420px) rotateX(-122deg); }
.bm-lid:focus-visible { outline: 3px solid var(--molten); outline-offset: 4px; border-radius: 18px; }
.bm-unit:not(.is-open) .bm-press { pointer-events: none; }
.bm-legs { opacity: 0; transition: opacity .15s; }
.bm-unit.is-running .bm-legs { opacity: 1; animation: bm-legs .18s steps(2) infinite; }
@keyframes bm-legs { 50% { transform: translateY(-3px); } }
.bm-unit.is-running .bm-ped, .bm-unit.is-running .bm-press, .bm-unit.is-running .bm-lid { animation: bm-hop .36s ease-in-out infinite; }
@keyframes bm-hop { 50% { translate: 0 -6px; } }
.bm-trophy { opacity: 0; transform-box: fill-box; transform-origin: center; }
.bm-unit.is-gold .bm-trophy { opacity: 1; animation: bm-trophy 2.4s ease-in-out infinite; }
@keyframes bm-trophy { 50% { transform: rotate(-12deg) scale(1.1); } }
.bm-unit.is-gold .bm-rim { fill: #FFD76A; }
.bm-unit.is-gold .bm-rim-face { fill: #C99A2E; }
.bm-unit.is-gold .bm-ped { filter: drop-shadow(0 0 10px rgba(255, 215, 106, .55)); }

/* the outcomes */
.bm-cloud { position: absolute; z-index: 9; left: 50%; top: -34%; width: 76%; transform: translateX(-50%); pointer-events: none; animation: bm-cloud-in .5s var(--spring) both; }
.bm-cloud.out { animation: bm-cloud-out .6s ease-in both; }
.bm-cloud svg { width: 100%; height: auto; overflow: visible; display: block; }
.bm-cloud .bm-rain path { animation: bm-rain .5s linear infinite; }
.bm-cloud .bm-rain path:nth-child(2n) { animation-delay: -.25s; }
.bm-cloud .bm-rain path:nth-child(3n) { animation-delay: -.12s; }
@keyframes bm-rain { from { transform: translateY(-6px); opacity: 0; } 30% { opacity: 1; } to { transform: translateY(46px); opacity: 0; } }
@keyframes bm-cloud-in { from { transform: translateX(-50%) scale(.3); opacity: 0; } to { transform: translateX(-50%) scale(1); opacity: 1; } }
@keyframes bm-cloud-out { to { transform: translateX(-50%) translateY(-30px); opacity: 0; } }
.bm-float {
  position: absolute; z-index: 9; left: 50%; top: -10%; margin: 0; transform: translateX(-50%); pointer-events: none; white-space: nowrap;
  font: 700 max(20px, calc(34 * var(--u)))/1 var(--font-display); color: var(--cream);
  text-shadow: 0 3px 0 var(--outline), 3px 0 0 var(--outline), -3px 0 0 var(--outline), 0 -3px 0 var(--outline);
  animation: bm-float 2.4s ease-out both;
}
@keyframes bm-float { 0% { transform: translateX(-50%) scale(.4) rotate(-8deg); opacity: 0; } 15% { transform: translateX(-50%) scale(1.1) rotate(4deg); opacity: 1; } 30% { transform: translateX(-50%) scale(1) rotate(-3deg); } 80% { opacity: 1; } 100% { transform: translateX(-50%) translateY(40px) rotate(-10deg); opacity: 0; } }

/* ── THE VAULT DOOR ── */
.bm-door { transition: transform .3s var(--spring); }
.bm-door > .bm-frame { width: 100%; height: auto; overflow: visible; }
.bm-door:focus-visible { outline: 3px solid var(--molten); outline-offset: 6px; border-radius: 48% 48% 14px 14px / 40% 40% 14px 14px; }
.bm-leaf-wrap {
  position: absolute; left: 9.302%; top: 8.163%; width: 81.395%; height: 91.837%; display: block;
  transform-origin: 0 50%; transform: perspective(1400px) rotateY(0deg);
  transition: transform 1.7s cubic-bezier(.55, 0, .25, 1), filter 1.7s;
}
.bm-leaf { display: block; width: 100%; height: 100%; overflow: visible; }
.bm-door.is-rattle .bm-leaf-wrap { animation: bm-rattle .42s linear; }
@keyframes bm-rattle { 15% { transform: perspective(1400px) translateX(-4px) rotate(-.6deg); } 35% { transform: perspective(1400px) translateX(5px) rotate(.5deg); } 55% { transform: perspective(1400px) translateX(-4px); } 75% { transform: perspective(1400px) translateX(3px); } }
.bm-door.is-open .bm-leaf-wrap { transform: perspective(1400px) rotateY(-106deg); filter: brightness(.6); }
.bm-light { opacity: 0; transition: opacity 1.2s ease .3s; }
.bm-door.is-open .bm-light { opacity: 1; }
.bm-rays { transform-box: view-box; transform-origin: 215px 250px; animation: bm-rays 12s linear infinite; }
@keyframes bm-rays { 0%, 100% { transform: rotate(-6deg); opacity: .35; } 50% { transform: rotate(6deg); opacity: .55; } }
.bm-door:not(.is-open):hover .bm-leaf-wrap { transform: perspective(1400px) rotateY(-3deg); }
.bm-bolts-door { transform-box: view-box; transition: transform .35s var(--spring); }
.bm-door.is-unbolted .bm-bolts-door { transform: translateX(-38px); }
.bm-star .bm-st-a { fill: #F1E4C2; stroke: #E2CFA0; stroke-width: 1; stroke-linejoin: round; }
.bm-star .bm-st-b { fill: #2B241A; stroke: #E2CFA0; stroke-width: 1; stroke-linejoin: round; }
.bm-star .bm-st-a.bm-st-minor { fill: #CDB98C; }
.bm-eng { stroke-width: 1.2; }
.bm-keyhole { transition: fill .3s; }
.bm-door:hover .bm-keyhole { fill: #2A1C08; }
.bm-key {
  position: absolute; left: 50%; top: 51.55%; width: 26%; height: auto; overflow: visible;
  transform: translate(-50%, -50%) scale(0) rotate(-40deg); opacity: 0; transition: transform .5s var(--spring), opacity .2s;
}
.bm-door.is-keyed .bm-key { transform: translate(-50%, -50%) scale(1) rotate(0deg); opacity: 1; }
.bm-door.is-turned .bm-key { transform: translate(-50%, -50%) scale(1) rotate(90deg); transition-duration: .45s; }
.bm-door.is-half .bm-key { transform: translate(-50%, -50%) scale(1) rotate(42deg); transition-duration: .3s; }
.bm-door.is-clunk .bm-key { animation: bm-clunk .35s ease-out; }
@keyframes bm-clunk { 30% { translate: 0 3px; } 60% { translate: 0 -1px; } }

/* the lamps around the keyhole (one per Spark the lock wants) and the counter plate */
.bm-lamp-bulb { fill: #2B241A; stroke: #C8A15A; stroke-width: 1.2; transition: fill .4s, stroke .4s; }
.bm-lamp-halo { fill: #FFC23D; opacity: 0; transition: opacity .4s; }
.bm-lamp.on .bm-lamp-bulb { fill: #FFE08A; stroke: #FFF3DF; }
.bm-lamp.on .bm-lamp-halo { opacity: .3; }
.bm-lamp.is-new .bm-lamp-halo { animation: bm-lamp-new 1.2s ease-out; }
@keyframes bm-lamp-new { 0% { opacity: .9; } 100% { opacity: .3; } }
.bm-lamps.is-flicker .bm-lamp.on { animation: bm-flicker .9s steps(1) 1; }
.bm-lamps.is-flicker .bm-lamp:not(.on) .bm-lamp-halo { animation: bm-want .9s ease-in-out 1; }
@keyframes bm-flicker { 0%, 100% { opacity: 1; } 22% { opacity: .25; } 40% { opacity: 1; } 62% { opacity: .35; } 80% { opacity: 1; } }
@keyframes bm-want { 0%, 100% { opacity: 0; } 50% { opacity: .22; } }
.bm-plate-n { font-variant-numeric: tabular-nums; }
.bm-door.is-ready .bm-plate rect:first-child { fill: #E3C27E; }
.bm-door.is-ready .bm-keyhole { fill: #3A2708; }
.bm-door.is-ready:not(.is-open) .bm-leaf { filter: drop-shadow(0 0 10px rgba(255, 194, 61, .35)); }
.bm-door.is-open .bm-key { opacity: 1; }
.bm-spill {
  position: absolute; z-index: 1; bottom: 0; left: calc(784 / var(--rw) * 100%); width: calc(350 / var(--rw) * 100%); height: calc(var(--gh) / var(--rh) * 100% + 4px);
  background: linear-gradient(180deg, rgba(255, 214, 140, .75), rgba(255, 160, 60, .12));
  clip-path: polygon(4% 0, 96% 0, 128% 100%, -28% 100%); opacity: 0; transition: opacity 1.2s ease .5s; pointer-events: none;
}
.floor-basement.is-vault-open .bm-spill { opacity: 1; }
.bm-plaque {
  display: flex; flex-direction: column; align-items: center; justify-content: center; margin: 0; padding: .32em .6em .38em; gap: .12em; text-align: center;
  background: linear-gradient(180deg, #E3C27E, #C8A15A 55%, #A9823E); color: #2A1C08;
  border: calc(3.5 * var(--u)) solid var(--outline); border-radius: calc(6 * var(--u));
  box-shadow: inset 0 0 0 calc(2 * var(--u)) rgba(255, 243, 223, .5), 0 calc(4 * var(--u)) 0 rgba(0, 0, 0, .4);
  font: italic 700 max(12px, calc(17 * var(--u)))/1.05 Georgia, 'Times New Roman', serif; letter-spacing: .04em; white-space: nowrap;
}
.bm-plaque small { font: italic 400 max(10.5px, calc(12.5 * var(--u)))/1.1 Georgia, 'Times New Roman', serif; letter-spacing: .02em; color: #3A2710; }
.bm-plaque small b { font-weight: 700; }
.bm-plaque.is-glint { animation: bm-glint .9s ease-out; }
@keyframes bm-glint { 0% { filter: brightness(1); transform: rotate(0); } 25% { filter: brightness(1.5); transform: rotate(-3deg); } 60% { transform: rotate(2deg); } 100% { filter: brightness(1); transform: rotate(0); } }

/* the vault card (in the cabinet) */
.bm-card { padding: clamp(22px, 4vw, 40px); text-align: center; background: radial-gradient(70% 60% at 50% 0%, rgba(255, 200, 120, .16), transparent 70%); }
.bm-card svg { width: 110px; height: 110px; margin: 0 auto 14px; display: block; }
.bm-card .lede { margin: 0 auto .6em; max-width: 34ch; color: var(--cream); font: 600 var(--step-1)/1.3 var(--font-display); }
.bm-card .warn { margin: 0 auto 1.4em; color: #FFB27A; font-weight: 800; }
.bm-card .row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

@media (max-width: 760px) { .floor-basement .fb-head { padding-right: 58px; } }

/* ── the Basement on phones and small tablets: room 400 × 620 ── */
@media (max-width: 1020px) {
  .bm-room { --rh: 620; --gh: 70; }
  .bm-door   { --x: 150; --y: 274; --w: 246; }
  .bm-plaque { --x: 166; --y: 212; --w: 214; }
  .bm-unit   { --x: 4;   --y: 336; --w: 150; }
  .bm-count  { --x: 0;   --y: 244; --w: 150; padding: .4em .5em; }
  .bm-sign   { --x: 16;  --y: 30;  --w: 150; }
  .bm-bulb   { --x: 344; --y: 0;   --w: 44; }
  .bm-bulb svg { animation: none; }
  .bm-doodle { --x: 262; --y: 88;  --w: 92; }
  .bm-spill  { left: calc(173 / 400 * 100%); width: calc(200 / 400 * 100%); }
  .bm-boiler, .bm-crates, .bm-drip, .bm-mouse { display: none; }
}
.bm-card-status { margin: 1em 0 0; min-height: 1.3em; color: var(--fg-muted); font-weight: 700; }
.bm-card .btn[aria-busy="true"] { cursor: progress; filter: saturate(.7); }
