/* ═══════════════════════════════════════════
   PalmGift Scanner – Camera Scanner Page
   Background: #fee000 yellow theme
════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --yellow:     #fee000;
  --yellow-dk:  #e6c800;
  --yellow-lt:  #fff8b0;
  --orange:     #fee000;
  --amber:      #E69500;
  --brown:      #3a2000;
  --black:      #1a1000;
  --white:      #FFFFFF;
  --font:       -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html, body { height: 100%; overflow: hidden; }

.scanner-body {
  font-family: var(--font);
  background: var(--yellow);   /* ← yellow instead of black */
  color: var(--black);
  position: relative;
  width: 100vw;
  height: 100dvh;
}

/* ── Camera feed – fills viewport ── */
#cameraFeed {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
}

/* ── Scanner overlay ── */
.scanner-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}

/* Soft yellow tint over camera (not dark black vignette) */
.scanner-overlay::before {
  content: '';
  position: fixed;
  inset: 0;
  background: rgba(254, 224, 0, 0.08);
  z-index: -1;
}

/* ── Top bar – solid yellow strip ── */
.scanner-topbar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  pointer-events: all;
  background: linear-gradient(to bottom, rgba(254,224,0,0.96) 60%, rgba(254,224,0,0));
}

.back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  background: rgba(0,0,0,0.12);
  border: 1px solid rgba(0,0,0,0.15);
  border-radius: 50%;
  color: var(--black);
  text-decoration: none;
  transition: background 0.2s;
}
.back-btn svg { width: 20px; height: 20px; stroke: var(--black); }
.back-btn:hover { background: rgba(0,0,0,0.22); }

.scanner-logo {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Logo has dark text — visible on yellow, no special filter */
.scanner-logo-img {
  height: 34px;
  width: auto;
  object-fit: contain;
}

/* ── Scanner frame ── */
.scanner-frame {
  position: relative;
  width: min(75vw, 280px);
  height: min(75vw, 280px);
  margin: auto;
  transform: translateY(-40px);
}

/* Four glowing corner brackets — dark on yellow */
.corner {
  position: absolute;
  width: 36px; height: 36px;
  border-color: var(--brown);
  border-style: solid;
  border-width: 0;
  border-radius: 4px;
  animation: cornerPulse 2s ease-in-out infinite;
}

.corner-tl { top: 0; left: 0;  border-top-width: 4px; border-left-width: 4px; }
.corner-tr { top: 0; right: 0; border-top-width: 4px; border-right-width: 4px; }
.corner-bl { bottom: 0; left: 0;  border-bottom-width: 4px; border-left-width: 4px; }
.corner-br { bottom: 0; right: 0; border-bottom-width: 4px; border-right-width: 4px; }

@keyframes cornerPulse {
  0%, 100% { border-color: var(--brown);  box-shadow: 0 0 0   rgba(0,0,0,0); }
  50%       { border-color: var(--orange); box-shadow: 0 0 14px rgba(255,140,0,0.7); }
}

/* Moving scan line — amber/orange on yellow */
.scan-line {
  position: absolute;
  left: 4px; right: 4px;
  height: 3px;
  background: linear-gradient(90deg,
    transparent, var(--orange), rgba(255,140,0,0.9), var(--orange), transparent);
  box-shadow: 0 0 10px 3px rgba(255,140,0,0.55);
  border-radius: 2px;
  animation: scanMove 2.4s ease-in-out infinite;
}

@keyframes scanMove {
  0%   { top: 4px;   opacity: 0.2; }
  10%  { opacity: 1; }
  90%  { opacity: 1; }
  100% { top: calc(100% - 7px); opacity: 0.2; }
}

/* X-ray pulse rings — dark on yellow */
.xray-ring {
  position: absolute;
  inset: -20px;
  border: 2px solid rgba(0,0,0,0.1);
  border-radius: 8px;
  animation: xrayPulse 3s ease-in-out infinite;
}
.xray-ring-2 { inset: -40px; animation-delay: -1.5s; }

@keyframes xrayPulse {
  0%, 100% { opacity: 0.1; transform: scale(1); }
  50%       { opacity: 0.35; transform: scale(1.04); }
}

/* ── Instruction pill — white card on yellow ── */
.scanner-instruction {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.88);
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 30px;
  padding: 10px 20px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--black);
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  margin-bottom: 0.8rem;
  pointer-events: none;
}
.instruction-icon { font-size: 20px; }

/* ── Scanner particles (darker dots on yellow) ── */
.scanner-particles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

.sp {
  position: absolute;
  width: 5px; height: 5px;
  background: var(--orange);
  border-radius: 50%;
  opacity: 0;
  animation: spFloat var(--dur, 5s) ease-in-out infinite;
  animation-delay: var(--d, 0s);
}

@keyframes spFloat {
  0%   { opacity: 0;   transform: translateY(100vh); }
  20%  { opacity: 0.7; }
  80%  { opacity: 0.4; }
  100% { opacity: 0;   transform: translateY(-50px); }
}

/* ── Capture button — dark circle on yellow ── */
.scanner-bottom {
  position: fixed;
  bottom: 4rem;
  left: 0; right: 0;
  display: flex;
  justify-content: center;
  pointer-events: all;
  z-index: 20;
}

.capture-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 90px; height: 90px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  background: transparent;
  padding: 0;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

/* Dark button so it pops against yellow bg */
.capture-btn-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 80px; height: 80px;
  border-radius: 50%;
  background: #fee000;
  box-shadow: 0 4px 24px rgba(0,0,0,0.35);
  transition: transform 0.15s, box-shadow 0.15s;
  gap: 2px;
}

.capture-btn:active .capture-btn-inner {
  transform: scale(0.93);
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.capture-icon  { font-size: 22px; line-height: 1; }
.capture-label { font-size: 10px; font-weight: 800; color: #000000; letter-spacing: 1px; }

/* Pulse ring — orange on yellow */
.capture-pulse {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 3px solid rgb(247 255 0 / 50%);
  animation: capturePulse 2s ease-in-out infinite;
}

@keyframes capturePulse {
  0%   { transform: scale(1);   opacity: 0.8; }
  50%  { transform: scale(1.1); opacity: 0.3; }
  100% { transform: scale(1);   opacity: 0.8; }
}

/* ── Camera permission card — white on yellow ── */
.camera-permission-panel {
  position: fixed;
  inset: 0;
  z-index: 35;
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  padding: 20px;
  background: rgba(254,224,0,0.6);
  backdrop-filter: blur(4px);
}

.camera-permission-panel.active { display: flex; }

.camera-permission-card {
  width: min(92vw, 360px);
  background: var(--white);
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 20px;
  padding: 24px 20px;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,0.18);
  pointer-events: all;
}

.camera-permission-title {
  font-size: 17px;
  font-weight: 800;
  margin-bottom: 8px;
  color: var(--black);
}

.camera-permission-text {
  font-size: 13px;
  line-height: 1.5;
  color: rgba(30,20,0,0.7);
  margin-bottom: 16px;
}

.camera-permission-btn {
  border: none;
  border-radius: 999px;
  padding: 12px 28px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.4px;
  color: var(--black);
  background: var(--yellow);
  box-shadow: 0 4px 16px rgba(200,160,0,0.4);
  cursor: pointer;
  transition: transform 0.15s;
}
.camera-permission-btn:active { transform: scale(0.96); }

/* ── AI Loading overlay — yellow bg ── */
.ai-loading {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(254,224,0,0.93);
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
}
.ai-loading.active { display: flex; }

.ai-loading-card {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.ai-spinner {
  position: relative;
  width: 90px; height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-spinner-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 4px solid transparent;
  border-top-color: var(--brown);
  animation: spin 1s linear infinite;
}

.ai-spinner-ring-2 {
  inset: 10px;
  border-top-color: var(--orange);
  animation-duration: 0.7s;
  animation-direction: reverse;
}

.ai-spinner-icon {
  font-size: 30px;
  animation: spinPop 1.5s ease-in-out infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

@keyframes spinPop {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.15); }
}

.ai-loading-text {
  font-size: 22px;
  font-weight: 800;
  color: var(--black);
}
.ai-loading-sub {
  font-size: 14px;
  color: rgba(30,20,0,0.6);
}

/* ── Toast — dark on yellow ── */
.toast {
  position: fixed;
  bottom: 130px;
  left: 50%;
  transform: translateX(-50%) translateY(30px);
  background: rgba(10,8,0,0.9);
  border: 1px solid rgba(255,140,0,0.4);
  border-radius: 30px;
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 600;
  color: var(--white);
  z-index: 60;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Success State — yellow bg ── */
.success-state {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  background: rgba(254,224,0,0.88);
  backdrop-filter: blur(4px);
}
.success-state.active { display: flex; }

#confettiCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 41;
}

.gift-float-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  z-index: 45;
  animation: giftFloat 2.4s ease-in-out infinite;
}

@keyframes giftFloat {
  0%, 100% { transform: translateY(0)    rotate(-2deg); }
  50%       { transform: translateY(-20px) rotate(2deg); }
}

.gift-glow-ring {
  position: absolute;
  width: 140px; height: 140px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,140,0,0.3), transparent 70%);
  animation: glowPulse 2s ease-in-out infinite;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
}

@keyframes glowPulse {
  0%, 100% { transform: translate(-50%,-50%) scale(1);   opacity: 0.5; }
  50%       { transform: translate(-50%,-50%) scale(1.2); opacity: 1;   }
}

.gift-emoji-wrap {
  width: 110px; height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  filter: drop-shadow(0 6px 20px rgba(0,0,0,0.2));
}

.gift-emoji {
  font-size: 80px;
  animation: giftShake 3s ease-in-out infinite;
}

@keyframes giftShake {
  0%, 100% { transform: rotate(0deg); }
  25%       { transform: rotate(-5deg); }
  75%       { transform: rotate(5deg); }
}

.gift-tap-hint {
  margin-top: 10px;
  background: var(--black);
  color: var(--yellow);
  font-size: 13px;
  font-weight: 700;
  padding: 7px 18px;
  border-radius: 20px;
  animation: blink 1.4s ease-in-out infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

.success-msg {
  font-size: clamp(15px, 4vw, 18px);
  font-weight: 800;
  color: var(--black);
  text-align: center;
  padding: 0 20px;
  z-index: 45;
}

/* ── Gift Modal — white card on yellow overlay ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(254,224,0,0.92);
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(10px);
}
.modal-overlay.active { display: flex; }

.modal-card {
  background: var(--white);
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 28px;
  padding: 48px 40px;
  text-align: center;
  max-width: 340px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.18);
  animation: modalPop 0.4s cubic-bezier(0.34,1.56,0.64,1) both;
}

@keyframes modalPop {
  from { opacity: 0; transform: scale(0.6); }
  to   { opacity: 1; transform: scale(1); }
}

.modal-gift-anim {
  font-size: 70px;
  margin-bottom: 20px;
  position: relative;
}

.modal-gift-closed { animation: giftBounce 0.6s ease-in-out infinite alternate; }
.modal-gift-open   { display: none; font-size: 80px; }

@keyframes giftBounce {
  from { transform: translateY(0)   scale(1); }
  to   { transform: translateY(-8px) scale(1.05); }
}

.modal-spinner {
  display: none;
  justify-content: center;
  margin-bottom: 20px;
}
.modal-spinner.active { display: flex; }

.modal-ring {
  width: 50px; height: 50px;
  border: 4px solid transparent;
  border-top-color: var(--brown);
  border-right-color: var(--orange);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.modal-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--black);
  margin-bottom: 8px;
}

.modal-sub {
  font-size: 15px;
  color: rgba(30,20,0,0.55);
}

/* ════════════════════════════════════════
   REWARD IFRAME OVERLAY
   Fullscreen slide-up panel, #fee000 bar
════════════════════════════════════════ */
.iframe-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  background: var(--white);
  transform: translateY(100%);            /* hidden off-screen below */
  transition: transform 0.42s cubic-bezier(0.32, 0.72, 0, 1);
}

.iframe-overlay.active {
  transform: translateY(0);              /* slides up into view */
}

/* Yellow topbar strip */
.iframe-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--yellow);
  flex-shrink: 0;
  min-height: 58px;
}

.iframe-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,0.1);
  cursor: pointer;
  color: var(--black);
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
}
.iframe-close-btn svg { width: 18px; height: 18px; }
.iframe-close-btn:hover { background: rgba(0,0,0,0.2); }

.iframe-topbar-label {
  font-size: 15px;
  font-weight: 800;
  color: var(--black);
  letter-spacing: 0.3px;
}

/* Spinner shown until iframe loads */
.iframe-loader {
  position: absolute;
  inset: 58px 0 0;          /* below topbar */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: var(--white);
  z-index: 1;
  pointer-events: none;
}

.iframe-loader.hidden { display: none; }

.iframe-loader-ring {
  width: 48px; height: 48px;
  border: 4px solid rgba(0,0,0,0.1);
  border-top-color: var(--brown);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.iframe-loader p {
  font-size: 14px;
  color: rgba(30,20,0,0.55);
  font-weight: 600;
}

/* The actual iframe – fills remainder */
#rewardIframe {
  flex: 1;
  width: 100%;
  border: none;
  display: block;
  position: relative;
  z-index: 2;
}

/* ── Responsive ── */
@media (max-width: 380px) {
  .scanner-frame { width: 68vw; height: 68vw; }
  .capture-btn  { width: 76px; height: 76px; }
  .capture-btn-inner { width: 68px; height: 68px; }
}
