/*
 * floating-boxes.css
 * Fixed promotional/info boxes shown on selected screens.
 *
 * Controlled from config/texts.php -> floatingBoxes.
 *
 * Requirements:
 * - fixed to viewport, independent from scroll
 * - highest visual layer above all game UI
 * - one box per screen
 * - close button in top-right corner
 * - type1: 40% image / 60% text
 * - type2: image only
 * - type3: text only
 * - top: slide-down
 * - center: zoom-in
 * - bottom: slide-up
 */

.floating-box-host {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  pointer-events: none;
  overflow: hidden;
}

.floating-box-host.is-empty {
  display: none;
}

.floating-box-wrap {
  position: fixed;
  left: 50%;
  z-index: 2147483001;
  width: min(92vw, 520px);
  max-width: calc(100vw - 24px);
  pointer-events: auto;
}

.floating-box-wrap[data-position="top"] {
  top: calc(var(--safe-top, 0px) + 14px);
  transform: translate3d(-50%, 0, 0);
}

.floating-box-wrap[data-position="center"] {
  top: 50%;
  transform: translate3d(-50%, -50%, 0);
}

.floating-box-wrap[data-position="bottom"] {
  bottom: calc(var(--safe-bottom, 0px) + 14px);
  transform: translate3d(-50%, 0, 0);
}

.floating-box {
  position: relative;
  display: block;
  width: 100%;
  max-width: 100%;
  min-height: 0;
  color: #fff4df;
  text-decoration: none;
  border: 1px solid rgba(255, 218, 155, 0.34);
  border-radius: 18px;
  background:
    radial-gradient(circle at 15% 0%, rgba(255, 218, 155, 0.12), transparent 34%),
    linear-gradient(180deg, rgba(21, 9, 8, 0.94), rgba(7, 3, 3, 0.91));
  box-shadow:
    0 20px 54px rgba(0, 0, 0, 0.48),
    0 0 34px rgba(255, 168, 83, 0.13),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  -webkit-backdrop-filter: blur(14px) saturate(1.05);
  backdrop-filter: blur(14px) saturate(1.05);
  overflow: hidden;
  isolation: isolate;
}

.floating-box::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.05), transparent 24%, transparent 76%, rgba(255, 218, 155, 0.06)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent 42%);
  opacity: 0.92;
}

.floating-box:hover,
.floating-box:focus-visible {
  color: #fff8ea;
  border-color: rgba(255, 218, 155, 0.54);
  box-shadow:
    0 24px 62px rgba(0, 0, 0, 0.52),
    0 0 42px rgba(255, 176, 92, 0.19),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.floating-box:focus-visible {
  outline: 3px solid rgba(255, 218, 155, 0.38);
  outline-offset: 4px;
}

.floating-box.is-not-clickable {
  cursor: default;
}

.floating-box-content {
  position: relative;
  z-index: 1;
}

.floating-box[data-type="type1"] .floating-box-content {
  display: grid;
  grid-template-columns: minmax(0, 40%) minmax(0, 60%);
  align-items: center;
  gap: 0;
}

.floating-box[data-type="type2"] .floating-box-content,
.floating-box[data-type="type3"] .floating-box-content {
  display: grid;
  grid-template-columns: 1fr;
}

.floating-box-image-slot {
  min-width: 0;
  height: 100%;
  display: grid;
  align-items: center;
  justify-items: center;
  padding: 10px;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 218, 155, 0.10), transparent 68%),
    rgba(255, 255, 255, 0.025);
}

.floating-box[data-type="type1"] .floating-box-image-slot {
  border-right: 1px solid rgba(255, 218, 155, 0.18);
}

.floating-box[data-type="type2"] .floating-box-image-slot {
  padding: 0;
  background: transparent;
}

.floating-box-image {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

.floating-box[data-type="type1"] .floating-box-image {
  max-height: 118px;
}

.floating-box[data-type="type2"] .floating-box-image {
  width: 100%;
  max-height: min(36vh, 260px);
  object-fit: cover;
}

.floating-box-text-slot {
  min-width: 0;
  padding: clamp(14px, 3.6vw, 20px) clamp(16px, 4vw, 24px);
  font-size: clamp(0.94rem, 2.7vw, 1.08rem);
  line-height: 1.32;
  text-align: left;
}

.floating-box[data-type="type3"] .floating-box-text-slot {
  text-align: center;
  padding: clamp(18px, 4.8vw, 26px) clamp(18px, 5vw, 30px);
}

.floating-box-text-slot p {
  margin: 0;
}

.floating-box-text-slot p + p {
  margin-top: 0.55em;
}

.floating-box-text-slot strong {
  color: rgba(255, 221, 164, 0.98);
  font-weight: 700;
}

.floating-box-close {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 4;
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255, 218, 155, 0.28);
  border-radius: 999px;
  background: rgba(6, 2, 2, 0.66);
  color: rgba(255, 244, 223, 0.92);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 19px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  box-shadow:
    0 8px 18px rgba(0, 0, 0, 0.34),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transition:
    transform var(--duration-base) var(--ease-bounce-soft),
    background var(--duration-base) var(--ease-standard),
    border-color var(--duration-base) var(--ease-standard),
    color var(--duration-base) var(--ease-standard);
}

.floating-box-close:hover,
.floating-box-close:focus-visible {
  transform: scale(1.07);
  background: rgba(28, 8, 7, 0.9);
  color: #fff7e8;
  border-color: rgba(255, 218, 155, 0.52);
}

.floating-box-close:focus-visible {
  outline: 2px solid rgba(255, 218, 155, 0.4);
  outline-offset: 2px;
}

.floating-box-wrap.is-entering[data-animation="slide-down"] {
  animation: floatingBoxSlideDown 420ms var(--ease-bounce-soft) both;
}

.floating-box-wrap.is-entering[data-animation="slide-up"] {
  animation: floatingBoxSlideUp 420ms var(--ease-bounce-soft) both;
}

.floating-box-wrap.is-entering[data-animation="zoom-in"] {
  animation: floatingBoxZoomIn 360ms var(--ease-bounce-soft) both;
}

.floating-box-wrap.is-exiting[data-position="top"] {
  animation: floatingBoxExitTop 220ms var(--ease-standard) both;
}

.floating-box-wrap.is-exiting[data-position="center"] {
  animation: floatingBoxExitCenter 200ms var(--ease-standard) both;
}

.floating-box-wrap.is-exiting[data-position="bottom"] {
  animation: floatingBoxExitBottom 220ms var(--ease-standard) both;
}

@keyframes floatingBoxSlideDown {
  0% {
    opacity: 0;
    transform: translate3d(-50%, -36px, 0) scale(0.98);
  }

  100% {
    opacity: 1;
    transform: translate3d(-50%, 0, 0) scale(1);
  }
}

@keyframes floatingBoxSlideUp {
  0% {
    opacity: 0;
    transform: translate3d(-50%, 36px, 0) scale(0.98);
  }

  100% {
    opacity: 1;
    transform: translate3d(-50%, 0, 0) scale(1);
  }
}

@keyframes floatingBoxZoomIn {
  0% {
    opacity: 0;
    transform: translate3d(-50%, -50%, 0) scale(0.88);
  }

  100% {
    opacity: 1;
    transform: translate3d(-50%, -50%, 0) scale(1);
  }
}

@keyframes floatingBoxExitTop {
  0% {
    opacity: 1;
    transform: translate3d(-50%, 0, 0) scale(1);
  }

  100% {
    opacity: 0;
    transform: translate3d(-50%, -26px, 0) scale(0.98);
  }
}

@keyframes floatingBoxExitBottom {
  0% {
    opacity: 1;
    transform: translate3d(-50%, 0, 0) scale(1);
  }

  100% {
    opacity: 0;
    transform: translate3d(-50%, 26px, 0) scale(0.98);
  }
}

@keyframes floatingBoxExitCenter {
  0% {
    opacity: 1;
    transform: translate3d(-50%, -50%, 0) scale(1);
  }

  100% {
    opacity: 0;
    transform: translate3d(-50%, -50%, 0) scale(0.92);
  }
}

@media (max-width: 520px) {
  .floating-box-wrap {
    width: min(94vw, 460px);
    max-width: calc(100vw - 18px);
  }

  .floating-box-wrap[data-position="top"] {
    top: calc(var(--safe-top, 0px) + 9px);
  }

  .floating-box-wrap[data-position="bottom"] {
    bottom: calc(var(--safe-bottom, 0px) + 9px);
  }

  .floating-box {
    border-radius: 16px;
  }

  .floating-box[data-type="type1"] .floating-box-content {
    grid-template-columns: minmax(0, 40%) minmax(0, 60%);
  }

  .floating-box-image-slot {
    padding: 8px;
  }

  .floating-box[data-type="type1"] .floating-box-image {
    max-height: 94px;
  }

  .floating-box[data-type="type2"] .floating-box-image {
    max-height: min(30vh, 210px);
  }

  .floating-box-text-slot {
    padding: 13px 16px;
    font-size: clamp(0.86rem, 3.45vw, 0.98rem);
    line-height: 1.24;
  }

  .floating-box[data-type="type3"] .floating-box-text-slot {
    padding: 17px 18px;
  }

  .floating-box-close {
    top: 5px;
    right: 5px;
    width: 28px;
    height: 28px;
    font-size: 18px;
  }
}

@media (max-width: 360px) {
  .floating-box-wrap {
    width: min(95vw, 340px);
  }

  .floating-box[data-type="type1"] .floating-box-content {
    grid-template-columns: minmax(0, 38%) minmax(0, 62%);
  }

  .floating-box-image-slot {
    padding: 7px;
  }

  .floating-box[data-type="type1"] .floating-box-image {
    max-height: 82px;
  }

  .floating-box-text-slot {
    padding: 12px 14px;
    font-size: 0.86rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .floating-box-wrap,
  .floating-box-wrap.is-entering,
  .floating-box-wrap.is-exiting {
    animation: none !important;
  }

  .floating-box-logo-link,
  .floating-box,
  .floating-box-close {
    transition: none !important;
  }
}
