/* rex-sigma.css — образ «Сигма» (rex-sigma.js): кадры-эмоции .rexsg-f поверх
   Рекса того же размера; и праздник выигранной партии (rex-party.js):
   хлопушка, конфетти, трещины с пешками на стекле экрана. */

.rexsg-f { display: none; }

/* Игра (#rex-pic) — как кадры «Шесть-Семь» (rex-67.css). */
#rex-pic.is-sg > .rex-art { visibility: hidden; }
#rex-pic.is-sg > .rexsg-f {
  display: block; position: absolute; left: 0; right: 0; bottom: 0; margin: 0 auto; width: 100%; height: auto; aspect-ratio: 1;
  transform-origin: 50% 100%; -webkit-user-drag: none; user-select: none; pointer-events: none;
}
#rex-pic.rex-lvl-pawn > .rexsg-f { width: 75%; }
#rex-pic.rex-lvl-knight > .rexsg-f { width: 81%; }
#rex-pic.rex-lvl-officer > .rexsg-f { width: 86%; }
#rex-pic.rex-lvl-rook > .rexsg-f { width: 91%; }
#rex-pic.rex-lvl-queen > .rexsg-f { width: 96%; }

/* Угол (dino.js). */
.dr.is-sg .dr-flip { position: relative; }
.dr.is-sg .dr-flip > .dr-art { visibility: hidden; }
.dr.is-sg .dr-flip > .rexsg-f {
  display: block; position: absolute; inset: 0; width: 100%; height: 100%; max-width: none;
  transform-origin: 50% 92%; -webkit-user-drag: none; user-select: none; pointer-events: none;
}

#rex-pic.is-sg.is-sg-hop > .rexsg-f, .dr.is-sg.is-sg-hop .rexsg-f { animation: rexsg-hop .6s cubic-bezier(.3, .7, .4, 1) 2; }
#rex-pic.is-sg.is-sg-laugh > .rexsg-f, .dr.is-sg.is-sg-laugh .rexsg-f { animation: rexsg-laugh .18s ease-in-out 7; }
@keyframes rexsg-hop {
  0%, 100% { transform: translateY(0) scale(1, 1); }
  15% { transform: translateY(0) scale(1.04, .94); }
  50% { transform: translateY(-10%) scale(.97, 1.04); }
  85% { transform: translateY(0) scale(1.03, .96); }
}
@keyframes rexsg-laugh {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-1.5%); }
}

/* Витрина /test4/: кнопка пробы праздника. */
.rexsg-try { position: fixed; left: 12px; bottom: calc(76px + env(safe-area-inset-bottom, 0px)); z-index: 60; box-shadow: 0 4px 14px rgba(0, 0, 0, .25); }
.rexsg-try[hidden] { display: none; }

/* ---------------------------------------------------------- праздник */

.rex-party {
  position: fixed; inset: 0; z-index: 2147483000; overflow: hidden; cursor: pointer;
  background: radial-gradient(120% 90% at 80% 100%, rgba(20, 12, 4, .38), rgba(20, 12, 4, .18) 60%, rgba(0, 0, 0, .1));
  opacity: 0; transition: opacity .25s ease-out;
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.rex-party.is-in { opacity: 1; }
.rex-party.is-out { opacity: 0; transition-duration: .55s; }
.rp-sky, .rp-glass { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.rp-sky { z-index: 3; }
.rp-glass { z-index: 1; }

/* Рекс выезжает справа снизу и стоит до конца. */
.rp-rex {
  position: absolute; z-index: 2; right: max(-2vw, -12px); bottom: 0;
  width: min(54vh, 72vw, 480px); height: auto; aspect-ratio: 1;
  transform: translateX(110%); transition: transform .45s cubic-bezier(.2, .9, .3, 1.15);
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, .35)); pointer-events: none; -webkit-user-drag: none;
}
.rex-party.is-in .rp-rex { transform: translateX(0); }
.rex-party.is-out .rp-rex { transform: translateX(110%); transition-duration: .5s; transition-timing-function: ease-in; }

/* Попадание: стекло вдавлено, пешка влетает из глубины и впечатывается. */
.rp-hit { position: absolute; width: 0; height: 0; }
/* max-width: none — общий svg { max-width: 100% } от нулевой ширины точки
   сжимал трещины в Chrome в ноль. */
.rp-hit > svg { position: absolute; left: 0; top: 0; max-width: none; max-height: none; transform: translate(-50%, -50%) rotate(var(--rot, 0deg)); overflow: visible; }
.rp-crack-glow { fill: none; stroke: rgba(255, 255, 255, .22); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.rp-crack-shadow { fill: none; stroke: rgba(0, 0, 0, .34); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; transform: translate(1.3px, 1.8px); }
.rp-crack { fill: none; stroke: rgba(255, 255, 255, .95); stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
.rp-chip { fill: rgba(235, 245, 255, .28); stroke: rgba(255, 255, 255, .7); stroke-width: 1; }
.rp-crack-glow, .rp-crack-shadow, .rp-crack { stroke-dasharray: 600; stroke-dashoffset: 600; animation: rp-crack .22s ease-out forwards; }
.rp-pawn { transform-box: fill-box; }
.rp-pawn-body { stroke: #5b3f06; stroke-width: 2; filter: drop-shadow(2px 4px 2px rgba(0, 0, 0, .45)); }
.rp-pawn-shine { fill: none; stroke: rgba(255, 255, 255, .9); stroke-width: 3.5; stroke-linecap: round; }
.rp-hit > svg { animation: rp-slam .2s cubic-bezier(.2, .8, .3, 1.2) both; }
@keyframes rp-crack { to { stroke-dashoffset: 0; } }
@keyframes rp-slam {
  from { opacity: 0; transform: translate(-50%, -50%) rotate(var(--rot, 0deg)) scale(2.6); }
  60% { opacity: 1; transform: translate(-50%, -50%) rotate(var(--rot, 0deg)) scale(.92); }
  to { opacity: 1; transform: translate(-50%, -50%) rotate(var(--rot, 0deg)) scale(1); }
}
/* Осыпается: падает вниз, крутясь. */
.rp-hit.is-fall { animation: rp-fall 1.1s cubic-bezier(.5, 0, .9, .6) forwards; }
@keyframes rp-fall {
  from { transform: translate(0, 0) rotate(0); opacity: 1; }
  to { transform: translate(var(--fall-x, 0), 110vh) rotate(var(--fall-r, 20deg)); opacity: .2; }
}

@media (prefers-reduced-motion: reduce) {
  .rexsg-f { animation: none !important; }
  .rex-party { display: none; }
}
