/* Шторка пазла на /generate */
.po-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(15, 23, 42, .55);
  opacity: 0;
  transition: opacity .2s ease;
}
.po-backdrop.is-open { opacity: 1; }
.po-sheet {
  width: 100%;
  max-width: 460px;
  max-height: 92dvh;
  overflow-y: auto;
  box-sizing: border-box;
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  border-radius: 20px 20px 0 0;
  background: #fff;
  text-align: center;
  transform: translateY(100%);
  transition: transform .28s cubic-bezier(.2, .8, .2, 1);
}
.po-backdrop.is-open .po-sheet { transform: translateY(0); }
/* Телефон: кнопки выше нижней панели браузера */
@media (max-width: 767px) and (min-height: 500px) {
  .po-sheet {
    padding-bottom: calc(18px + 7vh + env(safe-area-inset-bottom));
    padding-bottom: calc(18px + 7dvh + env(safe-area-inset-bottom));
  }
}
@media (min-width: 768px) {
  .po-backdrop { align-items: center; }
  .po-sheet { border-radius: 20px; transform: translateY(24px) scale(.98); }
  .po-backdrop.is-open .po-sheet { transform: none; }
}
.po-added {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 14px 5px 7px;
  border-radius: 18px;
  background: #e9f8ee;
  text-align: left;
  font-size: clamp(13.5px, 4vw, 15.5px);
  line-height: 1.2;
  font-weight: 700;
  color: #137a3a;
}
/* Зелёная печать: появляется с лёгким пружинением, затем рисуется галочка */
.po-check { width: 26px; height: 26px; flex: 0 0 auto; }
.po-check__seal {
  fill: #16a34a;
  transform-box: fill-box;
  transform-origin: center;
  animation: po-seal-in .42s cubic-bezier(.34, 1.56, .64, 1) .08s both;
}
.po-check__tick {
  fill: none;
  stroke: #fff;
  stroke-width: 2.3;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 13;
  stroke-dashoffset: 13;
  animation: po-draw .26s ease-out .38s forwards;
}
@keyframes po-seal-in { from { opacity: 0; transform: scale(.45) rotate(-30deg); } to { opacity: 1; transform: none; } }
@keyframes po-draw { to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) {
  .po-check__seal { animation: none; }
  .po-check__tick { animation: none; stroke-dashoffset: 0; }
}
.po-title {
  text-wrap: balance;
  margin: 10px 0 12px;
  font-size: 19px;
  line-height: 1.25;
  font-weight: 700;
  color: #111827;
}
/* Сцена. Все координаты взяты из макета 1671×941, поэтому она одинакова на любой ширине */
.po-scene {
  position: relative;
  width: 100%;
  /* Невысокий экран: сцена уменьшается целиком, чтобы кнопки остались видны */
  width: min(100%, max(195px, calc((85vh - 276px) * 1.776)));
  width: min(100%, max(195px, calc((85dvh - 276px) * 1.776)));
  aspect-ratio: 1671 / 941;
  margin: 0 auto 12px;
  border-radius: 14px;
  overflow: hidden;
  isolation: isolate;
  background: #dcae74;
  container-type: inline-size;
}
@supports not (aspect-ratio: 1) {
  .po-scene { width: 100%; height: 0; padding-top: 56.31%; }
}
.po-scene__bg {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  display: block;
}
/* Пазл: центр (655.5, 481.9), сторона 738, поворот -4.5° */
.po-puzzle {
  position: absolute;
  left: 17.146%;
  top: 11.998%;
  width: 44.165%;
  height: 78.427%;
  transform: rotate(-4.5deg);
}
.po-puzzle__contact,
.po-puzzle__lift,
.po-puzzle__art {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  border-radius: 1%;
}
/* Тень лежащего пазла и тень поднятого: при появлении одна сменяет другую */
.po-puzzle__contact {
  box-shadow: -.25px .2px 1.8px rgba(38, 24, 14, .92);
  box-shadow: -.072cqw .06cqw .5cqw rgba(38, 24, 14, .92);
}
.po-puzzle__lift {
  opacity: 0;
  box-shadow: -3px 6px 12px rgba(38, 24, 14, .58);
  box-shadow: -1cqw 2.2cqw 3.6cqw rgba(38, 24, 14, .58);
}
.po-puzzle__art {
  overflow: hidden;
  background: #e9e2d6;
}
.po-puzzle__art img {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  display: block;
}
/* Картинка 205×205 мм, рез 200×200: показываем только то, что останется после реза */
.po-puzzle__cover { object-fit: cover; transform: scale(1.025); }
.po-puzzle__gleam {
  position: absolute;
  left: 0;
  top: -30%;
  width: 42%;
  height: 160%;
  opacity: 0;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, .42) 50%, rgba(255, 255, 255, 0));
}
/* Число деталей на свободном месте стола, между пазлом и зайцем. Размер считается от ширины сцены */
.po-scene__pieces {
  position: absolute;
  left: 73.9%;
  top: 74.5%;
  width: 21%;
  transform: translate(-50%, -50%);
  text-align: center;
  line-height: 1.05;
  font-weight: 800;
  color: #2b1a0e;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .28);
  font-size: 11px;
  font-size: max(9px, 3.5cqw);
}
.po-scene__pieces b {
  display: block;
  font-weight: 800;
  letter-spacing: -.02em;
  font-size: 30px;
  font-size: 9.2cqw;
}
/* Коробка и её тень: слой 1760×1031, сдвинут на 90 вверх. Целиком один слой, чтобы потом можно было анимировать */
.po-box {
  position: absolute;
  left: 0;
  top: -9.564%;
  width: 105.326%;
  height: 109.564%;
  pointer-events: none;
}
.po-box svg {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
}
.po-box__img {
  position: absolute;
  left: 61.932%;
  top: 7.953%;
  width: 33.466%;
  height: 45.393%;
  display: block;
}
.po-price { margin: 18px 0 20px; display: flex; align-items: baseline; justify-content: center; gap: 8px; }
.po-price b { font-size: 26px; color: #d02a2a; }
.po-price__old { font-size: 16px; color: #9ca3af; }
.po-actions { display: flex; align-items: stretch; gap: 10px; }
.po-btn {
  min-height: 50px;
  padding: 10px 12px;
  border: 0;
  border-radius: 12px;
  font-size: 15px;
  line-height: 1.2;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.po-btn:disabled { opacity: .6; cursor: default; }
.po-btn--no { flex: 2 1 0; background: #f1f3f6; color: #374151; }
.po-btn--yes { flex: 3 1 0; font-size: 16px; font-weight: 700; background: #16a34a; color: #fff; }

/* Появление сцены: готовый пазл ложится на стол, по нему проходит блик, справа выезжает коробка с тенью.
   Классы живут только на время анимации, конечный кадр совпадает с обычным видом сцены. */
.po-scene.is-waiting .po-puzzle,
.po-scene.is-waiting .po-scene__pieces,
.po-scene.is-waiting .po-box { visibility: hidden; }

.po-scene.is-playing .po-puzzle { animation: po-puzzle-land .78s cubic-bezier(.3, .7, .2, 1) .14s both; }
.po-scene.is-playing .po-puzzle__lift { animation: po-puzzle-lift .78s ease-out .14s both; }
.po-scene.is-playing .po-puzzle__contact { animation: po-puzzle-contact .78s linear .14s both; }
.po-scene.is-playing .po-puzzle__gleam { animation: po-gleam .78s cubic-bezier(.4, 0, .3, 1) .68s both; }
.po-scene.is-playing .po-scene__pieces { animation: po-pieces-in .5s ease-out .6s both; }
.po-scene.is-playing .po-box {
  transform-origin: 80.7% 27.2%;
  animation: po-box-in .9s cubic-bezier(.16, 1, .3, 1) .46s both;
}

@keyframes po-puzzle-land {
  0% { opacity: 0; transform: translate(1%, -6%) rotate(-11deg) scale(1.14); }
  16% { opacity: 1; }
  76% { opacity: 1; transform: translate(0, 0) rotate(-4.15deg) scale(.994); }
  100% { opacity: 1; transform: translate(0, 0) rotate(-4.5deg) scale(1); }
}
/* Тень подтягивается к пазлу, а не отъезжает от него: внутри своего блока тень не рисуется, и иначе у края будет просвет */
@keyframes po-puzzle-lift {
  0% { opacity: 0; transform: translate(0, 0); }
  16% { opacity: 1; }
  80%, 100% { opacity: 0; transform: translate(2%, -4.4%); }
}
@keyframes po-puzzle-contact {
  0%, 62% { opacity: 0; }
  88%, 100% { opacity: 1; }
}
@keyframes po-gleam {
  0% { opacity: 0; transform: translateX(-130%) skewX(-18deg); }
  18% { opacity: 1; }
  82% { opacity: 1; }
  100% { opacity: 0; transform: translateX(330%) skewX(-18deg); }
}
@keyframes po-pieces-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes po-box-in {
  0% { transform: translateX(62%) rotate(6deg); }
  74% { transform: translateX(.3%) rotate(-.5deg); }
  100% { transform: translateX(0) rotate(0); }
}
