/* Корпоратив (party.js): кнопка в углу сцены, реквизит кабинета, манеры танца,
   травмы и следы. Манеры и травмы — data-motion на герое; office.css на время
   любого data-motion снимает анимацию состояния с фигуры, поэтому здесь
   каждая манера задаёт свою. Все keyframes держат scaleX(--office-facing),
   как в office.css, иначе герой развернулся бы лицом не туда.

   Спрайты нарисованы в полуоборот со светотенью (PPO-303), поэтому фигуру
   не зеркалят внутри keyframes, не сплющивают ребром и не наклоняют целиком
   дальше пары градусов — иначе она читается как картонная ростовая фигура.
   Движение манеры — это кадры (party.js подбирает walk/talk/sleep), а здесь
   только подпрыгивание, лёгкий сквош и падения — плавно, без steps(2):
   двухкадровые скачки читались как мерцание. Префикс .office-page даёт
   вес 0,3,0 поверх правила состояния walk из office.css. */

/* ── кнопка PARTY в углу сцены ── */
/* Док нулевой высоты сразу за .office-frame в колонке .office-stage: кнопка
   висит в правом нижнем углу рамки поверх мира, не масштабируется вместе с
   .office-world и не прокручивается с ним. */
.office-party-dock {
  position: relative;
  z-index: 2;
  flex: none;
  height: 0;
}
.office-party-button {
  position: absolute;
  right: 16px;
  bottom: 16px;
  width: 46px;
  height: 40px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  pointer-events: auto;
}
.office-party-button-plate {
  position: absolute;
  inset: 0;
  background: #f4f0e6;
  border: 2px solid #3b2f2a;
  box-shadow: 3px 3px 0 #3b2f2a;
}
.office-party-button-knob {
  position: absolute;
  left: 50%;
  top: 6px;
  width: 18px;
  height: 18px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ff8a8a, #d61f3c 60%, #8f0f24);
  border: 2px solid #3b2f2a;
  transition: transform 120ms var(--ease-out), box-shadow 300ms;
}
.office-party-button-sign {
  position: absolute;
  left: 50%;
  bottom: 3px;
  transform: translateX(-50%);
  font: 700 7px/1 var(--font-mono);
  letter-spacing: 0.08em;
  color: #3b2f2a;
  white-space: nowrap;
}
.office-party-button:hover .office-party-button-knob { box-shadow: 0 0 10px 3px rgba(214, 31, 60, 0.6); }
.office-party-button:active .office-party-button-knob { transform: translateX(-50%) scale(0.85); }
.office-party-button:focus-visible { outline: 2px solid var(--d-rose); outline-offset: 2px; }
.office-party-button[disabled] { cursor: default; opacity: 0.55; }
/* Выключатель нажат: корпоратив идёт, кнопка мигает, повторное нажатие всё гасит. */
.office-party-button[aria-pressed="true"] .office-party-button-knob { animation: office-party-knob 0.87s steps(2, end) infinite; }
@keyframes office-party-knob { 50% { filter: brightness(1.6); } }
.office-page.is-building .office-party-button { display: none; }

/* статус в подвале */
.office-party-status { color: var(--d-rose); font-weight: 600; }
.office-party-status:empty { display: none; }
.office-stage { position: relative; }

/* ── реквизит кабинета ── */
.office-party-tint,
.office-party-spot,
.office-party-ball,
.office-party-fx {
  position: absolute;
  pointer-events: none;
}
.office-party-tint { inset: 0; overflow: hidden; }

/* Пятна прожекторов: мягкие овалы с плавным спадом, дрейфуют по полу.
   Квадратных краёв нет — у каждого пятна своя рамка с запасом и размытие. */
.office-party-pool {
  position: absolute;
  width: 240px;
  height: 120px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  mix-blend-mode: multiply;
  opacity: 0.85;
  filter: blur(7px);
  background: radial-gradient(closest-side, var(--c, #ff7ab8) 0%, color-mix(in srgb, var(--c, #ff7ab8) 55%, #fff) 45%, rgba(255, 255, 255, 0) 100%);
  animation: office-party-pool var(--t, 3s) ease-in-out var(--d, 0s) infinite alternate;
}
@keyframes office-party-pool {
  to { transform: translate(calc(-50% + var(--mx, 60px)), calc(-50% + var(--my, 30px))) scale(1.15); }
}
/* Свет по полу пульсирует плавно: жёсткий строб steps(2) мерцал всей сценой. */
.office-page.is-party .office-room-floor { animation: office-party-strobe 0.87s ease-in-out infinite; }
@keyframes office-party-strobe { 50% { filter: brightness(0.82) saturate(1.3); } }

.office-party-spot {
  width: 36px;
  height: 18px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  opacity: 0.9;
  mix-blend-mode: screen;
  filter: blur(2px);
  background: radial-gradient(closest-side, #fff 0%, var(--c, #fff) 40%, rgba(255, 255, 255, 0) 100%);
  animation: office-party-spot var(--t, 1.7s) ease-in-out var(--d, 0s) infinite alternate;
}
@keyframes office-party-spot {
  from { transform: translate(-50%, -50%); }
  to { transform: translate(calc(-50% + var(--mx, 60px)), calc(-50% + var(--my, 30px))); }
}

.office-party-ball {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  transform: translateX(-50%);
  background:
    radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.95) 0 4px, transparent 9px),
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.25) 0 1px, transparent 1px 5px),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.35) 0 1px, transparent 1px 5px),
    radial-gradient(circle at 50% 50%, #e9ecff 0, #9aa3c9 60%, #4b5278 100%);
  box-shadow: 0 0 18px 4px rgba(200, 210, 255, 0.35);
  animation: office-party-descend 1.4s cubic-bezier(0.2, 0.8, 0.3, 1.25) 1 both, office-party-sway 2.2s ease-in-out 1.4s infinite;
  transition: opacity 400ms;
}
.office-party-ball::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -96px;
  width: 2px;
  height: 96px;
  background: #6b7399;
  transform: translateX(-50%);
}
.office-party-ball::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.28) 0 2px, transparent 2px 7px);
  animation: office-party-mirrors 1.2s linear infinite;
}
@keyframes office-party-descend { from { transform: translate(-50%, -190px); } to { transform: translate(-50%, 0); } }
@keyframes office-party-mirrors { to { background-position: 28px 0; } }
@keyframes office-party-sway {
  0%, 100% { transform: translateX(-50%) rotate(-5deg); }
  50% { transform: translateX(-50%) rotate(5deg); }
}
.office-party-ball.is-fallen { animation: office-party-fall 700ms cubic-bezier(0.4, 0, 0.8, 1) 1 forwards; }
.office-party-ball.is-fallen::before { display: none; }
@keyframes office-party-fall { to { transform: translate(-50%, var(--fall, 200px)) rotate(200deg); } }

/* ── части героя ── */
.office-party-part { position: absolute; pointer-events: none; display: none; }
.office-party-bottle {
  width: 10px;
  height: 22px;
  left: 60px;
  bottom: 50px;
  transform-origin: 50% 90%;
  image-rendering: pixelated;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='22' shape-rendering='crispEdges'%3E%3Crect x='3' y='0' width='4' height='2' fill='%23c7a95b'/%3E%3Crect x='3' y='2' width='4' height='6' fill='%232f7a4b'/%3E%3Crect x='1' y='8' width='8' height='14' fill='%232f7a4b'/%3E%3Crect x='2' y='12' width='6' height='5' fill='%23f2e6c8'/%3E%3Crect x='2' y='9' width='1' height='11' fill='%2367b283'/%3E%3C/svg%3E") no-repeat;
}
.office-agent.has-bottle .office-party-bottle { display: block; }
.office-agent[data-facing="left"] .office-party-bottle { left: 26px; }
.office-agent[data-motion="drink"] .office-party-bottle { animation: office-party-tilt 900ms ease-in-out 1; }
@keyframes office-party-tilt { 40%, 70% { transform: rotate(-70deg) translate(-4px, -10px); } }
.office-agent.is-ko .office-party-bottle { display: none; }

.office-party-stars {
  left: 50%;
  top: 6px;
  width: 44px;
  height: 16px;
  transform: translateX(-50%);
  font: 700 11px var(--font-mono);
  color: #f5c542;
  white-space: nowrap;
}
.office-party-stars span { position: absolute; top: 0; left: 50%; animation: office-party-orbit 1.1s linear infinite; }
.office-party-stars span:nth-child(2) { animation-delay: -0.37s; }
.office-party-stars span:nth-child(3) { animation-delay: -0.73s; }
@keyframes office-party-orbit {
  0% { transform: translateX(-22px) scale(0.7); opacity: 0.5; }
  25% { transform: translate(0, -5px) scale(1.1); opacity: 1; }
  50% { transform: translateX(22px) scale(0.7); opacity: 0.5; }
  75% { transform: translate(0, 5px) scale(0.6); opacity: 0.3; }
  100% { transform: translateX(-22px) scale(0.7); opacity: 0.5; }
}
.office-agent.is-ko .office-party-stars { display: block; }

.office-party-plaster {
  width: 10px;
  height: 4px;
  left: 44px;
  bottom: 106px;
  background: #f6b8c1;
  border: 1px solid #d98899;
  transform: rotate(-30deg);
}
.office-party-plaster::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 4px;
  height: 2px;
  background: #fde7ea;
}
.office-agent.has-plaster .office-party-plaster { display: block; }

.office-party-drip {
  width: 3px;
  height: 6px;
  left: 52px;
  bottom: 98px;
  background: #b3122b;
  animation: office-party-drip 700ms linear infinite;
}
@keyframes office-party-drip { to { transform: translateY(70px); opacity: 0; } }
.office-agent.is-bleeding .office-party-drip { display: block; }

.office-party-fire {
  left: 50%;
  bottom: 118px;
  width: 24px;
  height: 30px;
  transform: translateX(-50%);
  image-rendering: pixelated;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='30' shape-rendering='crispEdges'%3E%3Crect x='8' y='10' width='8' height='20' fill='%23ff5a1f'/%3E%3Crect x='4' y='16' width='4' height='14' fill='%23ff5a1f'/%3E%3Crect x='16' y='14' width='4' height='16' fill='%23ff5a1f'/%3E%3Crect x='10' y='2' width='4' height='8' fill='%23ffb12b'/%3E%3Crect x='10' y='18' width='4' height='12' fill='%23ffe25a'/%3E%3Crect x='6' y='22' width='2' height='8' fill='%23ffb12b'/%3E%3Crect x='16' y='20' width='2' height='10' fill='%23ffb12b'/%3E%3C/svg%3E") no-repeat;
  animation: office-party-flicker 120ms steps(2) infinite;
}
@keyframes office-party-flicker { 50% { transform: translateX(-50%) scale(1.15, 0.9); } }
.office-agent.is-burning .office-party-fire { display: block; }
.office-agent.is-burning .office-agent-figure { filter: brightness(1.1) sepia(0.4) saturate(2); }
.office-agent.is-ko .office-agent-shadow { transform: translateX(-50%) scaleX(1.6); }

/* ── манеры танца и травмы ── */
.office-page .office-agent[data-motion="dance"] .office-agent-figure { animation: office-party-dance 435ms ease-in-out var(--office-motion-delay, 0ms) infinite; }
.office-page .office-agent[data-motion="dance-b"] .office-agent-figure { animation: office-party-dance-b 435ms ease-in-out var(--office-motion-delay, 0ms) infinite; }
.office-page .office-agent[data-motion="jump"] .office-agent-figure { animation: office-party-jump 420ms cubic-bezier(0.3, 0, 0.2, 1) var(--office-motion-delay, 0ms) infinite; }
.office-page .office-agent[data-motion="drink"] .office-agent-figure { animation: office-party-drink 900ms ease-in-out 1; }
.office-page .office-agent[data-motion="throw"] .office-agent-figure { animation: office-party-throw 500ms ease-out 1; }
.office-page .office-agent[data-motion="hit"] .office-agent-figure { animation: office-party-hit 600ms ease-out 1; }
.office-page .office-agent[data-motion="ko"] .office-agent-figure { animation: office-party-ko 500ms cubic-bezier(0.3, 1.6, 0.6, 1) 1 forwards; }
.office-page .office-agent[data-motion="getup"] .office-agent-figure { animation: office-party-getup 600ms var(--ease-out) 1; }
.office-page .office-agent[data-motion="flat"] .office-agent-figure { animation: office-party-flat 320ms cubic-bezier(0.5, 0, 1, 1) 1 forwards; }
.office-page .office-agent[data-motion="unflat"] .office-agent-figure { animation: office-party-unflat 500ms cubic-bezier(0.3, 1.6, 0.6, 1) 1; }
.office-page .office-agent[data-motion="zap"] .office-agent-figure { animation: office-party-zap 90ms steps(1) infinite; }
.office-page .office-agent[data-motion="slip"] .office-agent-figure { animation: office-party-slip 600ms cubic-bezier(0.2, 0.8, 0.4, 1.4) 1 forwards; }
.office-page .office-agent[data-motion="panic"] .office-agent-figure { animation: office-party-panic 160ms ease-in-out infinite alternate; }
.office-page .office-agent[data-motion="jump"] .office-agent-shadow { animation: office-party-shadow-jump 420ms cubic-bezier(0.3, 0, 0.2, 1) var(--office-motion-delay, 0ms) infinite; }

@keyframes office-party-dance {
  0% { transform: translateY(0) scaleX(var(--office-facing, 1)); }
  50% { transform: translateY(-9px) scale(0.97, 1.03) scaleX(var(--office-facing, 1)); }
}
@keyframes office-party-dance-b {
  0%, 100% { transform: translateX(-3px) rotate(-3deg) scaleX(var(--office-facing, 1)); }
  50% { transform: translateX(3px) translateY(-4px) rotate(3deg) scaleX(var(--office-facing, 1)); }
}
@keyframes office-party-jump {
  0%, 100% { transform: translateY(0) scale(1.06, 0.94) scaleX(var(--office-facing, 1)); }
  50% { transform: translateY(-18px) scale(0.94, 1.06) scaleX(var(--office-facing, 1)); }
}
@keyframes office-party-shadow-jump { 50% { transform: translateX(-50%) scale(0.7); opacity: 0.6; } }
@keyframes office-party-drink {
  0%, 100% { transform: scaleX(var(--office-facing, 1)); }
  40%, 70% { transform: rotate(calc(var(--office-facing, 1) * -3deg)) translateY(-2px) scaleX(var(--office-facing, 1)); }
}
@keyframes office-party-throw {
  0% { transform: rotate(calc(var(--office-facing, 1) * 4deg)) scaleX(var(--office-facing, 1)); }
  60% { transform: rotate(calc(var(--office-facing, 1) * -5deg)) translateX(calc(var(--office-facing, 1) * 6px)) scaleX(var(--office-facing, 1)); }
  100% { transform: scaleX(var(--office-facing, 1)); }
}
@keyframes office-party-hit {
  0% { transform: translate(calc(var(--office-facing, 1) * -8px), 0) rotate(calc(var(--office-facing, 1) * 5deg)) scaleX(var(--office-facing, 1)); }
  40% { transform: translate(calc(var(--office-facing, 1) * 4px), -2px) rotate(calc(var(--office-facing, 1) * -3deg)) scaleX(var(--office-facing, 1)); }
  100% { transform: scaleX(var(--office-facing, 1)); }
}
@keyframes office-party-ko {
  0% { transform: rotate(0) scaleX(var(--office-facing, 1)); }
  30% { transform: translateY(-14px) rotate(calc(var(--office-facing, 1) * -40deg)) scaleX(var(--office-facing, 1)); }
  100% { transform: translate(calc(var(--office-facing, 1) * -30px), 8px) rotate(calc(var(--office-facing, 1) * -90deg)) scaleX(var(--office-facing, 1)); }
}
@keyframes office-party-getup {
  0% { transform: translate(calc(var(--office-facing, 1) * -30px), 8px) rotate(calc(var(--office-facing, 1) * -90deg)) scaleX(var(--office-facing, 1)); }
  60% { transform: translateY(-6px) rotate(calc(var(--office-facing, 1) * 6deg)) scaleX(var(--office-facing, 1)); }
  100% { transform: scaleX(var(--office-facing, 1)); }
}
@keyframes office-party-flat { to { transform: scale(1.5, 0.12) scaleX(var(--office-facing, 1)); } }
@keyframes office-party-unflat {
  0% { transform: scale(1.5, 0.12) scaleX(var(--office-facing, 1)); }
  60% { transform: scale(0.85, 1.2) scaleX(var(--office-facing, 1)); }
  100% { transform: scaleX(var(--office-facing, 1)); }
}
@keyframes office-party-zap {
  0% { filter: invert(1) contrast(3); transform: translate(-3px, 0) scaleX(var(--office-facing, 1)); }
  50% { filter: none; transform: translate(3px, -2px) scaleX(var(--office-facing, 1)); }
}
@keyframes office-party-slip {
  0% { transform: scaleX(var(--office-facing, 1)); }
  35% { transform: translateY(-16px) rotate(calc(var(--office-facing, 1) * 30deg)) scaleX(var(--office-facing, 1)); }
  100% { transform: translate(calc(var(--office-facing, 1) * 20px), 10px) rotate(calc(var(--office-facing, 1) * 95deg)) scaleX(var(--office-facing, 1)); }
}
@keyframes office-party-panic {
  0% { transform: translateY(-6px) rotate(-3deg) scaleX(var(--office-facing, 1)); }
  100% { transform: translateY(0) rotate(3deg) scaleX(var(--office-facing, 1)); }
}

/* ── следы и эффекты ── */
.office-party-flying {
  width: 10px;
  height: 22px;
  transform: translate(-50%, -50%);
  image-rendering: pixelated;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='22' shape-rendering='crispEdges'%3E%3Crect x='3' y='0' width='4' height='2' fill='%23c7a95b'/%3E%3Crect x='3' y='2' width='4' height='6' fill='%232f7a4b'/%3E%3Crect x='1' y='8' width='8' height='14' fill='%232f7a4b'/%3E%3Crect x='2' y='12' width='6' height='5' fill='%23f2e6c8'/%3E%3Crect x='2' y='9' width='1' height='11' fill='%2367b283'/%3E%3C/svg%3E") no-repeat;
}
.office-party-shard { width: 4px; height: 4px; background: #67b283; }
.office-party-shard.is-pale { background: #cfe9d9; }
.office-party-spark { width: 3px; height: 3px; background: #ffe25a; }
.office-party-puddle {
  width: 18px;
  height: 6px;
  border-radius: 50%;
  background: rgba(103, 178, 131, 0.45);
  transform: translate(-50%, -50%);
  animation: office-party-puddle 3s ease-out forwards;
}
@keyframes office-party-puddle { to { opacity: 0; transform: translate(-50%, -50%) scale(1.4); } }
.office-party-blood {
  width: 28px;
  height: 14px;
  image-rendering: pixelated;
  transition: opacity 1.2s;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='14' shape-rendering='crispEdges'%3E%3Crect x='6' y='4' width='16' height='6' fill='%23b3122b'/%3E%3Crect x='2' y='6' width='6' height='4' fill='%23b3122b'/%3E%3Crect x='20' y='2' width='6' height='4' fill='%23b3122b'/%3E%3Crect x='10' y='10' width='6' height='3' fill='%23b3122b'/%3E%3Crect x='24' y='9' width='3' height='3' fill='%23b3122b'/%3E%3Crect x='0' y='2' width='3' height='2' fill='%23b3122b'/%3E%3Crect x='8' y='5' width='6' height='2' fill='%23e0203f'/%3E%3C/svg%3E") no-repeat;
}
.office-party-blood.is-fading { opacity: 0; }
.office-party-smoke {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(120, 120, 130, 0.7);
  animation: office-party-smoke 1.2s ease-out forwards;
}
@keyframes office-party-smoke { to { transform: translate(var(--dx, 0), -50px) scale(2.4); opacity: 0; } }
.office-party-confetti {
  width: 4px;
  height: 4px;
  animation: office-party-confetti linear forwards;
}
@keyframes office-party-confetti { to { transform: translate(var(--dx, 0), 400px) rotate(540deg); opacity: 0.2; } }
.office-party-note {
  font: 700 13px var(--font-mono);
  color: #f472a6;
  animation: office-party-note 1.4s ease-out forwards;
}
@keyframes office-party-note { to { transform: translate(var(--dx, 8px), -60px) rotate(20deg); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .office-party-pool,
  .office-party-spot,
  .office-party-ball,
  .office-party-ball::after,
  .office-party-confetti,
  .office-party-note,
  .office-party-button-knob,
  .office-page.is-party .office-room-floor { animation: none !important; }
}
