/* ═══════════════════════════════════════════════════════════════
   LUMENFORM WORLD — the little world layered over the studio
   Floor deck · lift cable · riding lift cage · cogs · BATHO-01
   (mascot core carried over from mascot-v19, extended for v20)
   ═══════════════════════════════════════════════════════════════ */

/* ── Floor deck (bottom platform) ──────────────────────────────── */
#lf-floor {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 24px;
  z-index: 8990;
  pointer-events: none;
  background: repeating-linear-gradient(
    90deg,
    #1d1d1d 0px, #1d1d1d 38px,
    #2c2c2c 38px, #2c2c2c 40px
  );
  box-shadow: inset 0 4px 8px rgba(0, 0, 0, 0.5), 0 -2px 0 rgba(204, 0, 0, 0.8);
}

#lf-floor::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0; right: 0;
  height: 4px;
  transform: translateY(-50%);
  background: repeating-linear-gradient(
    90deg,
    transparent 0px, transparent 18px,
    rgba(220, 20, 20, 0.5) 18px, rgba(220, 20, 20, 0.5) 20px
  );
}

/* hazard chevrons under the lift shaft */
#lf-floor::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 72px;
  background: repeating-linear-gradient(
    -45deg,
    rgba(204, 0, 0, 0.5) 0 8px,
    rgba(20, 20, 20, 0.9) 8px 16px
  );
  opacity: 0.6;
}

/* ── Lift cable ────────────────────────────────────────────────── */
.lf-cable {
  position: fixed;
  top: 0;
  bottom: 24px;
  left: 30px;
  width: 4px;
  z-index: 8985;
  pointer-events: none;
  background: repeating-linear-gradient(
    180deg,
    #b5b5b5 0px,  #b5b5b5 5px,
    #666    5px,  #666    8px,
    #a0a0a0 8px,  #a0a0a0 10px,
    #666    10px, #666    14px
  );
  opacity: 1;
}

/* secondary guide rail */
.lf-cable::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 26px;
  width: 2px;
  background: repeating-linear-gradient(180deg, #5a5a5a 0 6px, #383838 6px 12px);
  opacity: 0.9;
}

/* ── Counterweight (moves opposite the lift) ───────────────────── */
#lf-counterweight {
  position: fixed;
  left: 53px;
  width: 12px;
  height: 30px;
  z-index: 8986;
  pointer-events: none;
  background: linear-gradient(180deg, #4d4d4d, #262626);
  border: 1px solid #5e5e5e;
  border-radius: 3px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.6);
}

#lf-counterweight::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 2px;
  right: 2px;
  height: 3px;
  transform: translateY(-50%);
  background: #cc0000;
  opacity: 0.7;
  border-radius: 1px;
}

/* ── Lift cage ─────────────────────────────────────────────────── */
#lf-lift {
  position: fixed;
  left: 8px;
  width: 48px;
  height: 58px;
  z-index: 8995;
  cursor: pointer;
  pointer-events: auto;
}

.lf-lift-cabin {
  position: absolute;
  inset: 0;
  border: 2px solid #6e6e6e;
  border-radius: 6px 6px 4px 4px;
  background: linear-gradient(180deg, rgba(44, 44, 44, 0.6), rgba(22, 22, 22, 0.6));
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(245, 245, 245, 0.14);
}

/* cage bars */
.lf-lift-cabin::before {
  content: '';
  position: absolute;
  inset: 6px 5px;
  background: repeating-linear-gradient(90deg, rgba(170, 170, 170, 0.55) 0 2px, transparent 2px 9px);
  border-radius: 2px;
}

/* roof beam + hanger */
.lf-lift-cabin::after {
  content: '';
  position: absolute;
  top: -9px;
  left: 50%;
  transform: translateX(-50%);
  width: 14px;
  height: 9px;
  background: #555;
  border-radius: 3px 3px 0 0;
  border: 1px solid #6a6a6a;
}

.lf-lift-lamp {
  position: absolute;
  top: 4px;
  right: 5px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #cc0000;
  box-shadow: 0 0 8px rgba(255, 34, 34, 0.9);
  animation: lf-lamp 2.2s ease-in-out infinite;
}

@keyframes lf-lamp {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.35; }
}

#lf-lift.is-moving .lf-lift-lamp {
  background: #ff9900;
  box-shadow: 0 0 10px rgba(255, 153, 0, 0.9);
  animation-duration: 0.4s;
}

#lf-lift .lf-lift-label {
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'VT323', monospace;
  font-size: 11px;
  letter-spacing: 0.16em;
  color: #8a8a8a;
  background: rgba(10, 10, 10, 0.8);
  padding: 0 5px;
  border-radius: 3px;
  pointer-events: none;
  white-space: nowrap;
}

#lf-lift:hover .lf-lift-cabin { border-color: #cc0000; }

/* ── Level HUD (bottom-left, sits on the floor deck) ───────────── */
#lf-hud {
  position: fixed;
  left: 78px;
  bottom: 34px;
  z-index: 8991;
  pointer-events: none;
  font-family: 'VT323', monospace;
  color: #9b9b9b;
  font-size: 16px;
  letter-spacing: 0.2em;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(10, 10, 10, 0.7);
  border: 1px solid rgba(245, 245, 245, 0.1);
  border-radius: 999px;
  padding: 4px 14px;
  backdrop-filter: blur(6px);
}

#lf-hud .lf-hud-level { color: #ff2222; }

#lf-hud .lf-hud-depth { color: #6b6b6b; }

@media (max-width: 700px) {
  #lf-hud { display: none; }
}

/* ═══════════════════════════════════════════════════════════════
   BATHO-01 — the spaceman
   ═══════════════════════════════════════════════════════════════ */

#site-mascot {
  position: fixed;
  top: 0;
  left: 50px;
  width: 56px;
  height: 80px;
  transform: scale(0.5);
  transform-origin: top left;
  z-index: 9999;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

#site-mascot.state-drag { cursor: grabbing; }

#site-mascot:hover .mascot-head { animation: mascot-nod 0.4s ease; }

/* ── Helmet ── */
.mascot-head {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  overflow: hidden;
  margin: 0 auto;
  position: relative;
  z-index: 2;
  border: 4px solid #b0b8c1;
  box-shadow:
    0 0 0 2px #78868f,
    0 0 0 4px #d0d8e0,
    inset 0 2px 8px rgba(255, 255, 255, 0.3),
    0 4px 12px rgba(0, 0, 0, 0.5);
  background: #c8dff5;
}

.mascot-head img {
  width: 100%;
  height: 100%;
  margin: 0;
  object-fit: cover;
  object-position: center 15%;
  display: block;
  filter: contrast(1.05) saturate(1.1);
  transform: scaleX(-1);
  pointer-events: none;
}

.mascot-head::after {
  content: '';
  position: absolute;
  top: 6px;
  left: 8px;
  width: 18px;
  height: 12px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  transform: rotate(-25deg);
  pointer-events: none;
}

.mascot-head::before {
  content: '';
  position: absolute;
  bottom: -6px;
  left: -6px;
  right: -6px;
  height: 10px;
  background: linear-gradient(180deg, #c8cdd2 0%, #8f9aa3 100%);
  border-radius: 0 0 30px 30px;
  z-index: 3;
  border: 1px solid #6a7880;
}

/* ── Body ── */
.mascot-body { margin-top: 2px; position: relative; }

.mascot-torso {
  width: 40px;
  height: 30px;
  background: linear-gradient(160deg, #f0f2f5 0%, #d8dde3 60%, #c5ccd4 100%);
  border: 2.5px solid #8f9aa3;
  border-radius: 10px 10px 5px 5px;
  margin: 0 auto;
  position: relative;
  box-shadow:
    inset 2px 2px 6px rgba(255, 255, 255, 0.8),
    inset -2px -2px 4px rgba(0, 0, 0, 0.1),
    0 2px 4px rgba(0, 0, 0, 0.25);
}

.mascot-torso::before {
  content: '';
  position: absolute;
  top: 7px;
  left: 50%;
  transform: translateX(-50%);
  width: 16px;
  height: 14px;
  background: linear-gradient(180deg, #cc0000 0%, #990000 100%);
  border-radius: 3px;
  border: 1.5px solid #660000;
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.2);
}

.mascot-torso::after {
  content: '';
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 6px;
  height: 2px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 1px;
  box-shadow: 0 3px 0 rgba(255, 255, 255, 0.5);
}

.mascot-arm {
  position: absolute;
  top: 2px;
  width: 11px;
  height: 22px;
  background: linear-gradient(180deg, #e8ecf0 0%, #c8cdd2 100%);
  border: 2px solid #8f9aa3;
  border-radius: 5px 5px 7px 7px;
  box-shadow: inset 1px 1px 3px rgba(255, 255, 255, 0.6);
}

.mascot-arm.left  { left: -12px; transform-origin: top center; }
.mascot-arm.right { right: -12px; transform-origin: top center; }

.mascot-arm.left::after,
.mascot-arm.right::after {
  content: '';
  position: absolute;
  bottom: -5px;
  left: -1px;
  width: 11px;
  height: 7px;
  background: #cc0000;
  border: 1.5px solid #880000;
  border-radius: 3px 3px 5px 5px;
}

.mascot-waist {
  width: 36px;
  height: 7px;
  background: linear-gradient(180deg, #9aa3aa 0%, #6a7880 100%);
  border: 1.5px solid #556068;
  border-radius: 3px;
  margin: 0 auto;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.mascot-legs {
  display: flex;
  justify-content: center;
  gap: 5px;
  margin-top: 2px;
}

.mascot-leg {
  width: 14px;
  height: 22px;
  background: linear-gradient(180deg, #dde2e8 0%, #c0c7cf 100%);
  border: 2px solid #8f9aa3;
  border-radius: 4px 4px 2px 2px;
  position: relative;
  transform-origin: top center;
  box-shadow: inset 1px 0 3px rgba(255, 255, 255, 0.5);
}

.mascot-leg::before {
  content: '';
  position: absolute;
  top: 50%;
  left: -2px;
  right: -2px;
  height: 5px;
  background: linear-gradient(180deg, #a0aab3 0%, #788088 100%);
  border: 1px solid #6a7880;
  transform: translateY(-50%);
  border-radius: 2px;
}

.mascot-leg::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: -4px;
  width: 20px;
  height: 10px;
  background: linear-gradient(180deg, #e8ecf0 0%, #b8bfc8 100%);
  border: 2px solid #8f9aa3;
  border-radius: 4px 6px 6px 3px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* ── Jetpack ── */
.mascot-jetpack {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 28px;
  z-index: 0;
  pointer-events: none;
}

.jpack {
  width: 8px;
  height: 14px;
  background: linear-gradient(180deg, #aaa 0%, #ccc 40%, #777 100%);
  border-radius: 3px 3px 2px 2px;
  border: 1px solid #444;
  position: relative;
  box-shadow: 0 0 3px rgba(255, 150, 0, 0);
  transition: box-shadow 0.2s;
}

.jflame {
  position: absolute;
  bottom: -18px;
  left: 50%;
  width: 8px;
  height: 20px;
  transform: translateX(-50%);
  border-radius: 50% 50% 40% 40%;
  opacity: 0;
  background: linear-gradient(180deg,
    #fff 0%, #ffe066 15%, #ff9900 45%, #ff4400 75%, transparent 100%);
  pointer-events: none;
}

#site-mascot.state-jetpack .jpack { box-shadow: 0 0 6px rgba(255, 150, 0, 0.7); }

#site-mascot.state-jetpack .jflame {
  opacity: 1;
  animation: jflicker 0.1s ease-in-out infinite alternate;
}

#site-mascot.state-jetpack .jpack-l .jflame { animation-delay: 0.05s; }

@keyframes jflicker {
  from { transform: translateX(-50%) scaleY(0.85) scaleX(0.9); opacity: 0.85; }
  to   { transform: translateX(-50%) scaleY(1.2)  scaleX(1.1); opacity: 1; }
}

/* ── Parachute (deploys when you drop him) ── */
.mascot-chute {
  position: absolute;
  top: -46px;
  left: 50%;
  transform: translateX(-50%) scale(0);
  transform-origin: bottom center;
  width: 74px;
  height: 40px;
  pointer-events: none;
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s;
  z-index: 1;
}

.mascot-chute::before {
  content: '';
  position: absolute;
  inset: 0 0 12px;
  border-radius: 50% 50% 14% 14% / 90% 90% 10% 10%;
  background:
    repeating-linear-gradient(90deg, #cc0000 0 12px, #f5f5f5 12px 24px);
  border: 2px solid #7a0000;
  box-shadow: inset 0 -6px 10px rgba(0, 0, 0, 0.3);
}

.mascot-chute::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -12px;
  width: 46px;
  height: 26px;
  transform: translateX(-50%);
  background:
    linear-gradient(75deg, transparent 49%, rgba(220, 220, 220, 0.8) 49% 51%, transparent 51%),
    linear-gradient(105deg, transparent 49%, rgba(220, 220, 220, 0.8) 49% 51%, transparent 51%),
    linear-gradient(90deg, transparent 49%, rgba(220, 220, 220, 0.8) 49% 51%, transparent 51%);
}

#site-mascot.state-chute .mascot-chute {
  opacity: 1;
  transform: translateX(-50%) scale(1);
  animation: chute-sway 1.6s ease-in-out infinite;
}

@keyframes chute-sway {
  0%, 100% { transform: translateX(-50%) scale(1) rotate(-5deg); }
  50%      { transform: translateX(-50%) scale(1) rotate(5deg); }
}

/* ═══ Mascot animations ════════════════════════════════════════── */

@keyframes mascot-float {
  0%, 100% { transform: scale(0.5) translateY(0) rotate(-0.5deg); }
  33%       { transform: scale(0.5) translateY(-3px) rotate(0.5deg); }
  66%       { transform: scale(0.5) translateY(-1px) rotate(-0.3deg); }
}
@keyframes mascot-float-left {
  0%, 100% { transform: scale(0.5) scaleX(-1) translateY(0) rotate(0.5deg); }
  33%       { transform: scale(0.5) scaleX(-1) translateY(-3px) rotate(-0.5deg); }
  66%       { transform: scale(0.5) scaleX(-1) translateY(-1px) rotate(0.3deg); }
}

@keyframes mascot-walk {
  0%, 100% { transform: scale(0.5) translateY(0) rotate(-1deg); }
  50%       { transform: scale(0.5) translateY(-2px) rotate(1deg); }
}
@keyframes mascot-walk-left {
  0%, 100% { transform: scale(0.5) scaleX(-1) translateY(0) rotate(1deg); }
  50%       { transform: scale(0.5) scaleX(-1) translateY(-2px) rotate(-1deg); }
}

@keyframes mascot-leg-left {
  0%, 100% { transform: rotate(0deg); }
  25%       { transform: rotate(-22deg); }
  75%       { transform: rotate(18deg); }
}

@keyframes mascot-leg-right {
  0%, 100% { transform: rotate(0deg); }
  25%       { transform: rotate(18deg); }
  75%       { transform: rotate(-22deg); }
}

@keyframes mascot-arm-wave {
  0%, 100% { transform: rotate(0deg); }
  25%       { transform: rotate(-50deg); }
  75%       { transform: rotate(-10deg); }
}

@keyframes mascot-wave {
  0%, 100% { transform: rotate(0deg); }
  20%       { transform: rotate(14deg); }
  40%       { transform: rotate(-10deg); }
  60%       { transform: rotate(12deg); }
  80%       { transform: rotate(-7deg); }
}

@keyframes mascot-nod {
  0%, 100% { transform: rotate(0deg) translateY(0); }
  30%       { transform: rotate(8deg) translateY(2px); }
  60%       { transform: rotate(-5deg) translateY(-1px); }
}

/* dangle while dragged / parachuting */
@keyframes mascot-dangle {
  0%, 100% { transform: rotate(-14deg); }
  50%      { transform: rotate(14deg); }
}

/* ═══ Mascot states ════════════════════════════════════════════── */

#site-mascot.state-idle { animation: mascot-float 2.5s ease-in-out infinite; }
#site-mascot.facing-left.state-idle { animation: mascot-float-left 2.5s ease-in-out infinite; }

#site-mascot.state-idle .mascot-leg.left,
#site-mascot.state-idle .mascot-leg.right { animation: none; transform: rotate(0deg); }

#site-mascot.state-idle .mascot-arm.right { animation: mascot-arm-wave 2.5s ease-in-out infinite; }

#site-mascot.state-walk { animation: mascot-walk 0.5s ease-in-out infinite; }
#site-mascot.facing-left.state-walk { animation: mascot-walk-left 0.5s ease-in-out infinite; }

#site-mascot.state-walk .mascot-leg.left { animation: mascot-leg-left 0.5s ease-in-out infinite; }
#site-mascot.state-walk .mascot-leg.right { animation: mascot-leg-right 0.5s ease-in-out infinite; }

#site-mascot.state-wave .mascot-head { animation: mascot-wave 0.6s ease-in-out 2; }
#site-mascot.state-wave .mascot-arm.right { animation: mascot-arm-wave 0.6s ease-in-out 2; }

#site-mascot.facing-left { transform: scale(0.5) scaleX(-1); }

/* riding the lift — hold the bars, gentle bob */
#site-mascot.state-lift { animation: mascot-float 1.2s ease-in-out infinite; }
#site-mascot.facing-left.state-lift { animation: mascot-float-left 1.2s ease-in-out infinite; }
#site-mascot.state-lift .mascot-arm.left,
#site-mascot.state-lift .mascot-arm.right { transform: rotate(-160deg); transition: transform 0.3s; }

/* dragged by the user — limbs dangle */
#site-mascot.state-drag .mascot-leg.left { animation: mascot-dangle 0.9s ease-in-out infinite; }
#site-mascot.state-drag .mascot-leg.right { animation: mascot-dangle 0.9s ease-in-out infinite 0.45s; }
#site-mascot.state-drag .mascot-arm.left { animation: mascot-dangle 1.1s ease-in-out infinite 0.2s; }
#site-mascot.state-drag .mascot-arm.right { animation: mascot-dangle 1.1s ease-in-out infinite 0.7s; }

/* parachuting — legs together, slight sway handled by chute */
#site-mascot.state-chute .mascot-leg.left,
#site-mascot.state-chute .mascot-leg.right { animation: mascot-dangle 1.6s ease-in-out infinite; }
#site-mascot.state-chute .mascot-arm.left,
#site-mascot.state-chute .mascot-arm.right { transform: rotate(-150deg); transition: transform 0.3s; }

/* bracing while the user scrolls fast — leans into the wind */
#site-mascot.state-brace { animation: none; transform: scale(0.5) rotate(7deg) !important; }
#site-mascot.facing-left.state-brace { transform: scale(0.5) scaleX(-1) rotate(-7deg) !important; }

/* grapple aim */
#site-mascot.state-grapple-aim { animation: mascot-grapple-aim 0.4s ease forwards !important; }
#site-mascot.facing-left.state-grapple-aim { animation: mascot-grapple-aim-left 0.4s ease forwards !important; }

@keyframes mascot-grapple-aim {
  0%   { transform: scale(0.5) rotate(0deg); }
  50%  { transform: scale(0.5) rotate(-8deg) translateY(-4px); }
  100% { transform: scale(0.5) rotate(-5deg) translateY(-3px); }
}
@keyframes mascot-grapple-aim-left {
  0%   { transform: scale(0.5) scaleX(-1) rotate(0deg); }
  50%  { transform: scale(0.5) scaleX(-1) rotate(8deg) translateY(-4px); }
  100% { transform: scale(0.5) scaleX(-1) rotate(5deg) translateY(-3px); }
}

#site-mascot.state-grapple-aim .mascot-arm.right {
  transform: rotate(-120deg) !important;
  transition: transform 0.3s ease;
}

/* ── Speech bubble ─────────────────────────────────────────────── */
.mascot-bubble {
  position: absolute;
  bottom: 120px;
  left: 0;
  background: #f5f5f5;
  border: 3px solid #1a1a1a;
  border-radius: 16px;
  padding: 12px 16px;
  font-family: 'Space Grotesk', Arial, sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: #111;
  box-shadow: 4px 4px 0 #1a1a1a, 0 0 0 1px rgba(204, 0, 0, 0.0);
  pointer-events: none;
  opacity: 0;
  transform: translateY(8px) scale(0.9);
  transition: opacity 0.25s, transform 0.25s;
  z-index: 10000;
  max-width: 280px;
  white-space: normal;
  line-height: 1.4;
}

.mascot-bubble::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 20px;
  border: 5px solid transparent;
  border-top-color: #1a1a1a;
}

.mascot-bubble.visible { opacity: 1; transform: translateY(0) scale(1); }

#site-mascot.facing-left .mascot-bubble { transform: scaleX(-1) translateY(8px) scale(0.9); }
#site-mascot.facing-left .mascot-bubble.visible { transform: scaleX(-1) translateY(0) scale(1); }

/* ═══ Small screens — the world shrinks but stays alive ════════── */
@media (max-width: 700px) {
  .lf-cable::after { display: none; }
  #lf-counterweight { display: none; }
  #lf-lift .lf-lift-label { display: none; }
  #lf-floor::after { width: 44px; }
}

/* ═══ Reduced motion — park the machinery ══════════════════════── */
@media (prefers-reduced-motion: reduce) {
  #site-mascot, #site-mascot.facing-left { animation: none !important; }
  .lf-lift-lamp, .mascot-chute { animation: none !important; }
}
