/* ── Fortune Fruit Force 5 (FFF5) Screen Style ──
 *
 * Layout model
 * ------------
 * The canvas-scaler (nav.js) renders every screen at a fixed logical height
 * of 932px; only the logical width changes between devices.
 *
 * `.fff5-stage` is a box with the exact aspect ratio of the background art
 * (1024 × 1522 design px → ≈627 × 932 logical px), centred horizontally.
 * Every layer (logo / title / CTA) is positioned INSIDE the stage using
 * design-pixel coordinates converted to percentages of the stage, so the
 * layers stay glued to the artwork: they never move up/down or drift when
 * the viewport width or height changes. Narrow screens simply crop the
 * left/right edges of the stage (like `object-fit: cover`).
 *
 * To tweak a position, edit the --fff5-* variables below using the pixel
 * values from Figma (frame = background, 1024 × 1522).
 */

#screen-fff5 {
  overflow: hidden;
  height: var(--content-height, 932px) !important;
  background: #000 !important;

  /* Design frame (background art size, in design px — Figma node 5:2) */
  --fff5-frame-w: 1024;
  --fff5-frame-h: 1522;

  /* Game Logo (Figma node 6:613: x=334, y=64, w=356, h=251 → cx=512, bottom=315) */
  --fff5-logo-cx: 512;
  --fff5-logo-bottom: 315;

  /* Title (Figma node 6:468: x=183, y=574, w=657, h=315 → cx=511.5, cy=731.5) */
  --fff5-title-cx: 511.5;
  --fff5-title-cy: 731.5;

  /* CTA button (Figma node 6:506: x=189, y=1256, w=645, h=172 → cx=511.5, cy=1342) */
  --fff5-cta-cx: 511.5;
  --fff5-cta-cy: 1342;
  --fff5-cta-w: 645; /* cta-button.jpg native width */
  --fff5-cta-h: 172; /* cta-button.jpg native height */

  /* CTA label position inside cta-button (Figma node 6:563 render bounds) */
  --fff5-cta-text-left: 50.08%;
  --fff5-cta-text-top: 49.41%;
}

/* Per-language Figma variant offsets (Title 6:455 & CTA 6:563) */
#screen-fff5.fff5-lang-zh {
  --fff5-logo-cx: 511.5;
  --fff5-title-cy: 743.5; /* y=574 + 12px variant offset */
  --fff5-cta-text-left: 50.30%;
  --fff5-cta-text-top: 47.66%;
}

#screen-fff5.fff5-lang-th {
  --fff5-logo-bottom: 308; /* shifted up 7px */
  --fff5-title-cy: 717.5; /* shifted up 7px */
  --fff5-cta-text-left: 50.38%;
  --fff5-cta-text-top: 41.49%;
}

#screen-fff5.fff5-lang-id {
  --fff5-title-cy: 742.5; /* y=574 + 11px variant offset */
  --fff5-cta-text-left: 50.10%;
  --fff5-cta-text-top: 49.35%;
}

#screen-fff5.fff5-lang-ms {
  --fff5-cta-text-left: 50.10%;
  --fff5-cta-text-top: 49.35%;
}

.page-fff5 {
  position: relative;
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #000 !important;
  background-color: #000 !important;
  background-image: none !important;
}

/* Disable any black gradient overlays (inherited or pseudo) */
#screen-fff5 .page-fff5::before,
#screen-fff5 .page-fff5::after,
#screen-fff5 .page::before,
#screen-fff5 .page::after,
.page-fff5::before,
.page-fff5::after {
  display: none !important;
  content: none !important;
  background: none !important;
}

/* Stage: fixed-ratio box matching the background art */
.fff5-stage {
  position: absolute;
  top: 0;
  left: 50%;
  height: 100%;
  width: calc(var(--content-height, 932px) * 1024 / 1522);
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 2;
}

.fff5-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  user-select: none;
  -webkit-user-drag: none;
}

/* ── Shared layer rules ── */
.fff5-layer {
  position: absolute;
  display: block;
  height: auto;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

/* Localized images start hidden until the correct language asset is loaded
   (prevents a flash of the wrong language / wrong size). */
.fff5-loc {
  opacity: 0;
  transition: opacity 0.25s ease;
}

.fff5-loc.is-ready {
  opacity: 1;
}

/* ── Logo ── */
.fff5-logo {
  left: calc(var(--fff5-logo-cx) / var(--fff5-frame-w) * 100%);
  top: calc(var(--fff5-logo-bottom) / var(--fff5-frame-h) * 100%);
  width: calc(356 / 1024 * 100%); /* default = en native width; JS updates per language */
  transform: translate(-50%, -100%);
  z-index: 3;
}

/* ── Title ── */
.fff5-title {
  left: calc(var(--fff5-title-cx) / var(--fff5-frame-w) * 100%);
  top: calc(var(--fff5-title-cy) / var(--fff5-frame-h) * 100%);
  width: calc(657 / 1024 * 100%); /* default = native width; JS updates per language */
  transform: translate(-50%, -50%);
  z-index: 4;
}

/* ── CTA ── */
.fff5-cta-wrap {
  position: absolute;
  left: calc(var(--fff5-cta-cx) / var(--fff5-frame-w) * 100%);
  top: calc(var(--fff5-cta-cy) / var(--fff5-frame-h) * 100%);
  width: calc(var(--fff5-cta-w) / var(--fff5-frame-w) * 100%);
  aspect-ratio: 645 / 172;
  transform: translate(-50%, -50%);
  z-index: 5;
  pointer-events: auto;
}

.fff5-cta-btn {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  /* Scale-only animation → the button never shifts vertically */
  animation: fff5-pulse 2s infinite ease-in-out;
  transform-origin: 50% 50%;
  transition: filter 0.3s ease;
  will-change: transform;
  backface-visibility: hidden;
}

.fff5-cta-btn:hover {
  animation-play-state: paused;
  transform: scale(1.05);
  filter: brightness(1.12) drop-shadow(0 0 16px rgba(90, 255, 120, 0.55));
}

.fff5-cta-btn:active {
  animation-play-state: paused;
  transform: scale(0.95);
}

.fff5-cta-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 999px;
  clip-path: inset(1px round 999px);
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

/* Localized CTA label — positioned inside the button frame per Figma variant.
   Width is set by JS as (label native width / button native width). */
.fff5-cta-text {
  position: absolute;
  left: var(--fff5-cta-text-left, 50.08%);
  top: var(--fff5-cta-text-top, 49.41%);
  width: calc(449 / 645 * 100%);
  max-width: 86%;
  max-height: 70%;
  object-fit: contain;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

@keyframes fff5-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* ── Bottom-nav FFF5 thumbnail card & click fix ── */
.bottom-nav__card {
  user-select: none;
  -webkit-user-drag: none;
}

.bottom-nav__thumb {
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

#tab-fff5 .bottom-nav__thumb {
  object-position: center center;
}

#tab-fff5.bottom-nav__card--active {
  outline: 2px solid #ffd84a !important;
  box-shadow:
    0 0 14px rgba(255, 216, 74, 0.45),
    0 0 30px rgba(255, 216, 74, 0.2) !important;
}
