/* ============================================================
   BIG BENIS GAME — попапы (универсальная рамка + сюжетные сцены)
   Параметры подложки — из overlay.json набора; слайсы — nine-slice.json
   ============================================================ */

.popup-backdrop {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: calc(var(--safe-top) + 2vh) 5% calc(var(--safe-bottom) + 2vh);
  background: rgba(2, 7, 14, 0.78);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}
.popup-backdrop.is-open { opacity: 1; pointer-events: auto; }

.popup {
  position: relative;
  width: min(86%, 400px);
  max-height: 100%;
  overflow: hidden;
  scrollbar-width: none;
  border: solid transparent;
  border-width: clamp(16px, 4.6vw, 24px);
  border-image: url("../assets/popup/modal-frame.webp") 82 82 88 82 fill / clamp(16px, 4.6vw, 24px) stretch;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(6px, 1.1vh, 11px);
  padding: 1% 3% 2%;
  text-align: center;
  transform: translateY(14px) scale(0.94);
  transition: transform 240ms cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.popup-backdrop.is-open .popup { transform: none; }
.popup::-webkit-scrollbar { display: none; }

/* сюжетная сцена целиком (по ширине, без обрезки); нижняя треть
   растворяется маской, и на неё ложатся заголовок, текст и кнопки */
.popup-scene {
  position: relative;
  display: block;
  width: 100%;
  height: auto;
  margin-bottom: -34%;
  object-fit: contain;
  -webkit-mask-image: linear-gradient(180deg, #000 52%, transparent 82%);
  mask-image: linear-gradient(180deg, #000 52%, transparent 82%);
  z-index: 0;
}
.popup > :not(.popup-scene) { position: relative; z-index: 2; }
.popup-title {
  margin: 0;
  font: 400 clamp(19px, 5.4vw, 28px)/1.1 var(--font-display);
  color: #f3eee4;
  letter-spacing: 0.04em;
  text-shadow: 0 3px 0 #2a3140, 0 6px 10px #000;
}
.popup-value {
  font: 400 clamp(34px, 10vw, 52px)/1 var(--font-display);
  color: var(--gold-2);
  text-shadow: 0 4px 0 #7c4a00, 0 8px 14px #000;
}
.popup-value--bad { color: var(--red); text-shadow: 0 4px 0 #5c1510, 0 8px 14px #000; }
.popup-text {
  margin: 0;
  font: 700 clamp(11px, 3vw, 15px)/1.4 var(--font-body);
  color: #abb4c5;
}
.popup-text mark { color: var(--green); background: none; }
.popup-text em { color: var(--red); font-style: normal; }

/* --- чипы-факты --- */
.popup-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: clamp(5px, 1.4vw, 10px); }
.popup-chip {
  display: flex;
  align-items: center;
  gap: clamp(4px, 1.2vw, 8px);
  min-height: clamp(30px, 4.4vh, 40px);
  border: solid transparent;
  border-width: 8px 10px 9px 10px;
  border-image: url("../assets/popup/info-chip-dark.webp") 58 70 65 70 fill / 8px 10px 9px 10px stretch;
  padding: 0 clamp(4px, 1.4vw, 10px);
  font: 400 clamp(10px, 2.8vw, 14px)/1 var(--font-display);
  color: #d9deea;
  letter-spacing: 0.03em;
  text-shadow: 0 2px 3px #000;
}
.popup-chip img { height: 1.3em; width: auto; }

/* --- календарь ежедневных наград --- */
.popup-days {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: clamp(3px, 1vw, 7px);
}
.popup-day {
  aspect-ratio: 327 / 574;
  border: solid transparent;
  border-width: 7px;
  border-image: url("../assets/popup/daily-card-normal.webp") 44 46 48 46 fill / 7px stretch;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 4% 2%;
  font: 400 clamp(8px, 2.2vw, 12px)/1 var(--font-display);
  color: #b9c0cf;
  text-shadow: 0 1px 2px #000;
}
.popup-day--claimed { border-image-source: url("../assets/popup/daily-card-claimed.webp"); color: #7f8a9e; }
.popup-day--current { border-image-source: url("../assets/popup/daily-card-current.webp"); color: #ffe9b0; }
.popup-day--rare { border-image-source: url("../assets/popup/daily-card-rare.webp"); color: #e7d1ff; }
.popup-day img { width: 72%; max-width: 34px; height: auto; filter: drop-shadow(0 2px 2px #000); }
.popup-day b { font-weight: 400; }

/* --- кнопки --- */
.popup-actions { width: 100%; display: flex; flex-direction: column; gap: clamp(6px, 1vh, 10px); }
.popup-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(6px, 1.8vw, 10px);
  min-height: clamp(44px, 6.4vh, 56px);
  border: solid transparent;
  border-width: 13px 18px 15px 18px;
  border-image: url("../assets/popup/button-primary-gold.webp") 52 72 60 72 fill / 13px 18px 15px 18px stretch;
  font: 400 clamp(15px, 4.2vw, 22px)/1 var(--font-display);
  color: #fff;
  letter-spacing: 0.04em;
  text-shadow: 0 3px 3px #754000;
  cursor: pointer;
}
.popup-btn img { height: 1.2em; width: auto; }
.popup-btn:active { transform: translateY(2px); }
.popup-btn--dark {
  border-image-source: url("../assets/popup/button-secondary-dark.webp");
  color: #d9deea;
  text-shadow: 0 2px 3px #000;
}

@media (prefers-reduced-motion: reduce) {
  .popup-backdrop, .popup { transition: none; }
}
