/* =========================================================
   FONTS
   ========================================================= */
@font-face {
  font-family: 'Koulen';
  src: url('fonts/Koulen.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap; /* show fallback font immediately, swap in Koulen once loaded, rather than a blank flash */
}

/* =========================================================
   CSS VARIABLES
   ========================================================= */
:root {
  /* Fonts */
  /* Koulen is a bold Khmer display face — used for headline, titles, and
     button labels. It only contains Khmer + basic punctuation glyphs, so
     it is never applied to body/caption text, which stays on the system
     sans-serif fallback below (placeholder until a body font is chosen). */
  --font-display: 'Koulen', 'Khmer OS Battambang', sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Khmer OS', 'Helvetica Neue', Arial, sans-serif;

  /* Colors */
  --color-bg-deep: #0a0a14;
  --color-bg-mid: #12101f;
  --color-bg-edge: #1a1030;

  --color-accent-1: #a855f7;   /* violet */
  --color-accent-2: #ec4899;   /* pink */
  --color-accent-3: #facc15;   /* gold */
  --color-accent-4: #38bdf8;   /* sky */

  --color-text-primary: #f5f3ff;
  --color-text-secondary: rgba(245, 243, 255, 0.72);
  --color-text-muted: rgba(245, 243, 255, 0.5);

  --color-glass-bg: rgba(255, 255, 255, 0.06);
  --color-glass-border: rgba(255, 255, 255, 0.14);
  --color-glass-bg-strong: rgba(255, 255, 255, 0.09);

  --color-btn-text: #1a0b2e;

  /* Gradients */
  --gradient-bg: radial-gradient(circle at 20% 20%, var(--color-bg-edge) 0%, transparent 55%),
                  radial-gradient(circle at 85% 15%, rgba(56, 189, 248, 0.12) 0%, transparent 45%),
                  radial-gradient(circle at 80% 85%, rgba(236, 72, 153, 0.14) 0%, transparent 50%),
                  linear-gradient(160deg, var(--color-bg-deep) 0%, var(--color-bg-mid) 55%, var(--color-bg-deep) 100%);

  --gradient-accent: linear-gradient(135deg, var(--color-accent-3) 0%, var(--color-accent-2) 55%, var(--color-accent-1) 100%);
  --gradient-icon: linear-gradient(135deg, var(--color-accent-4) 0%, var(--color-accent-1) 100%);

  /* Spacing */
  --space-xs: 0.5rem;
  --space-sm: 0.875rem;
  --space-md: 1.25rem;
  --space-lg: 2rem;
  --space-xl: 3rem;

  /* Radii */
  --radius-sm: 12px;
  --radius-md: 20px;
  --radius-lg: 28px;
  --radius-full: 999px;

  /* Shadows / glows */
  --glow-accent: 0 0 40px rgba(168, 85, 247, 0.35), 0 0 80px rgba(236, 72, 153, 0.18);
  --glow-btn: 0 8px 24px rgba(236, 72, 153, 0.35), 0 0 40px rgba(168, 85, 247, 0.25);
  --shadow-card: 0 20px 60px rgba(0, 0, 0, 0.45);

  /* Transitions */
  --ease-smooth: cubic-bezier(0.22, 1, 0.36, 1);
  --duration-fast: 0.2s;
  --duration-med: 0.4s;
  --duration-slow: 0.7s;

  /* Layout */
  --max-width: 480px;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  min-height: 100svh;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--color-text-primary);
  background: var(--gradient-bg);
  background-color: var(--color-bg-deep);
  overflow-x: hidden;
  position: relative;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

img,
svg {
  display: block;
  max-width: 100%;
}

/* Respect users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* =========================================================
   BACKGROUND DECORATION
   ========================================================= */
.glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(70px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.55;
}

.glow--one {
  width: 300px;
  height: 300px;
  top: -60px;
  left: -60px;
  background: var(--color-accent-1);
  animation: float-glow 9s ease-in-out infinite;
}

.glow--two {
  width: 340px;
  height: 340px;
  bottom: -80px;
  right: -80px;
  background: var(--color-accent-2);
  animation: float-glow 11s ease-in-out infinite reverse;
}

@keyframes float-glow {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(20px, 30px) scale(1.1); }
}

.particles {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.particle {
  position: absolute;
  bottom: -10px;
  border-radius: 50%;
  background: var(--color-text-primary);
  opacity: 0.35;
  animation-name: particle-rise;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}

@keyframes particle-rise {
  0% {
    transform: translateY(0) translateX(0);
    opacity: 0;
  }
  10% {
    opacity: 0.5;
  }
  90% {
    opacity: 0.3;
  }
  100% {
    transform: translateY(-110vh) translateX(var(--drift, 20px));
    opacity: 0;
  }
}

/* =========================================================
   LAYOUT
   ========================================================= */
.page {
  position: relative;
  z-index: 1;
  min-height: 100svh;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-lg);
  padding: var(--space-lg) var(--space-md) var(--space-xl);
  max-width: var(--max-width);
  margin-inline: auto;
  text-align: center;
}

.page__header {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  align-self: center;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  color: var(--color-accent-3);
  padding: 0.35em 0.9em;
  border-radius: var(--radius-full);
  background: var(--color-glass-bg);
  border: 1px solid var(--color-glass-border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* =========================================================
   CUSTOM SVG ICONS
   Replace the earlier emoji-based icons with vector marks
   drawn from the same accent palette, so every icon inherits
   the page's own gradient rather than a system emoji font.
   ========================================================= */
.icon-inline {
  display: block;
  flex-shrink: 0;
}

.icon-inline--gift {
  width: 1.15em;
  height: 1.15em;
}

.icon-inline--sparkle-small {
  width: 1em;
  height: 1em;
  color: var(--color-btn-text);
  opacity: 0.55;
}

.icon-inline--sparkle-large {
  width: 100%;
  height: 100%;
}

.icon-inline--celebration {
  width: 100%;
  height: 100%;
}

.page__title {
  font-family: var(--font-body);
  font-size: clamp(1.05rem, 4vw, 1.3rem);
  font-weight: 500;
  color: var(--color-text-secondary);
  line-height: 1.4;
  overflow-wrap: normal;
}

/* =========================================================
   GLASSMORPHISM CARD
   ========================================================= */
.offer-card {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xl) var(--space-lg);
  border-radius: var(--radius-lg);
  background: var(--color-glass-bg);
  border: 1px solid var(--color-glass-border);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: var(--shadow-card), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.offer-card::before {
  content: "";
  position: absolute;
  inset: -40% -40% auto -40%;
  height: 220px;
  background: radial-gradient(closest-side, rgba(168, 85, 247, 0.35), transparent);
  pointer-events: none;
  z-index: 0;
}

.offer-card > * {
  position: relative;
  z-index: 1;
}

.spin-wheel {
  width: clamp(9rem, 34vw, 11.25rem);
  height: clamp(9rem, 34vw, 11.25rem);
  margin-bottom: var(--space-xs);
  filter: drop-shadow(0 0 20px rgba(168, 85, 247, 0.4));
}

.spin-wheel svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.wheel-ring {
  transition: filter var(--duration-med) var(--ease-smooth);
}

.spin-wheel.is-spinning .wheel-ring {
  filter: drop-shadow(0 0 10px rgba(236, 72, 153, 0.6));
}

/* Only the rotor (hub + icon) spins — the outer ring, rim ticks, and top
   pointer stay fixed, so the pointer always marks the same landing spot.
   1800deg is exactly 5 full rotations, so the icon returns to its original
   upright orientation at rest. The cubic-bezier curve front-loads the
   rotation speed and eases out gradually, reading as momentum losing to
   friction rather than a linear spin that just stops. */
.wheel-rotor {
  transform-origin: 90px 90px;
  transition: transform 2.6s cubic-bezier(0.15, 0.85, 0.25, 1);
}

.spin-wheel.is-spinning .wheel-rotor {
  transform: rotate(1800deg);
}

.offer-card__title {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 6.5vw, 1.9rem);
  font-weight: 400;
  letter-spacing: 0.02em;
  background: var(--gradient-accent);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.offer-card__text {
  font-size: 0.98rem;
  color: var(--color-text-secondary);
  max-width: 280px;
  line-height: 1.6;
  margin-bottom: var(--space-sm);
  overflow-wrap: normal;
}

/* =========================================================
   BUTTONS
   ========================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6em;
  width: 100%;
  min-height: 56px;
  padding: 0.9em 1.5em;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 400;
  letter-spacing: 0.01em;
  border-radius: var(--radius-full);
  transition:
    transform var(--duration-fast) var(--ease-smooth),
    box-shadow var(--duration-fast) var(--ease-smooth),
    opacity var(--duration-fast) var(--ease-smooth);
  touch-action: manipulation;
}

.btn--primary {
  background: var(--gradient-accent);
  color: var(--color-btn-text);
  box-shadow: var(--glow-btn);
}

.btn--primary:hover:not(:disabled) {
  transform: translateY(-2px) scale(1.015);
  box-shadow: 0 12px 32px rgba(236, 72, 153, 0.45), 0 0 50px rgba(168, 85, 247, 0.32);
}

.btn--primary:active:not(:disabled) {
  transform: translateY(0) scale(0.98);
}

.btn--primary:focus-visible {
  outline: 3px solid var(--color-accent-4);
  outline-offset: 3px;
}

.btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}

.btn__icon {
  font-size: 1.1em;
}

.btn--modal {
  margin-top: var(--space-sm);
}

/* =========================================================
   STATUS MESSAGE + PROGRESS BAR
   ========================================================= */
.status-message {
  min-height: 1.4em;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--color-accent-4);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity var(--duration-med) var(--ease-smooth),
    transform var(--duration-med) var(--ease-smooth);
}

.status-message.is-visible {
  opacity: 1;
  transform: translateY(0);
}
}

/* =========================================================
   DISCLAIMER
   ========================================================= */
.disclaimer {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  line-height: 1.6;
  max-width: 320px;
  overflow-wrap: normal;
}

/* =========================================================
   CONFETTI CANVAS
   ========================================================= */
.confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 50;
}

/* =========================================================
   MODAL
   ========================================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
  background: rgba(6, 4, 16, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity var(--duration-med) var(--ease-smooth);
}

.modal-overlay[hidden] {
  display: none;
}

.modal-overlay.is-open {
  opacity: 1;
}

.modal {
  position: relative;
  width: 100%;
  max-width: 380px;
  max-height: 90svh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  text-align: center;
  padding: var(--space-xl) var(--space-lg) var(--space-lg);
  border-radius: var(--radius-lg);
  background: var(--color-glass-bg-strong);
  border: 1px solid var(--color-glass-border);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  box-shadow: var(--shadow-card), var(--glow-accent), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transform: scale(0.9) translateY(12px);
  opacity: 0;
  transition: transform var(--duration-slow) var(--ease-smooth),
    opacity var(--duration-slow) var(--ease-smooth);
}

.modal-overlay.is-open .modal {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.modal__close {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 1rem;
  color: var(--color-text-secondary);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--color-glass-border);
  transition: background var(--duration-fast) var(--ease-smooth),
    color var(--duration-fast) var(--ease-smooth),
    transform var(--duration-fast) var(--ease-smooth);
}

.modal__close:hover {
  background: rgba(255, 255, 255, 0.16);
  color: var(--color-text-primary);
  transform: rotate(90deg);
}

.modal__close:focus-visible {
  outline: 3px solid var(--color-accent-4);
  outline-offset: 2px;
}

.modal__icon {
  width: clamp(2.75rem, 10vw, 3.25rem);
  height: clamp(2.75rem, 10vw, 3.25rem);
  margin-inline: auto;
  filter: drop-shadow(0 0 20px rgba(250, 204, 21, 0.5));
  animation: icon-pop 0.6s var(--ease-smooth);
}

@keyframes icon-pop {
  0% { transform: scale(0.3) rotate(-15deg); opacity: 0; }
  60% { transform: scale(1.15) rotate(8deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.modal__title {
  font-family: var(--font-display);
  font-size: clamp(1.3rem, 6vw, 1.65rem);
  font-weight: 400;
  letter-spacing: 0.01em;
  background: var(--gradient-accent);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  line-height: 1.35;
}

.modal__text {
  font-family: var(--font-body);
  font-size: 0.98rem;
  color: var(--color-text-primary);
  max-width: 260px;
  line-height: 1.6;
  overflow-wrap: normal;
}

.modal__note {
  font-family: var(--font-body);
  font-size: 0.88rem;
  color: var(--color-text-secondary);
  max-width: 260px;
  line-height: 1.5;
  margin-bottom: var(--space-xs);
  overflow-wrap: normal;
}

.modal__link-hint {
  font-family: var(--font-body);
  font-size: 0.76rem;
  color: var(--color-text-muted);
  word-break: normal;
  overflow-wrap: break-word;
}

/* =========================================================
   RESPONSIVE BREAKPOINTS
   ========================================================= */

/* Small phones (360px baseline) */
@media (max-width: 374px) {
  .page {
    padding-inline: var(--space-sm);
    gap: var(--space-md);
  }

  .offer-card {
    padding: var(--space-lg) var(--space-md);
  }

  .btn {
    font-size: 0.94rem;
    min-height: 52px;
  }
}

/* Tablets and up */
@media (min-width: 600px) {
  .page {
    max-width: 520px;
    gap: var(--space-xl);
  }

  .offer-card {
    padding: calc(var(--space-xl) + var(--space-md)) var(--space-xl);
  }

  .modal {
    max-width: 420px;
  }
}

/* Desktop */
@media (min-width: 1024px) {
  .page {
    max-width: 560px;
  }

  .offer-card:hover {
    box-shadow: var(--shadow-card), var(--glow-accent), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  }

  .btn--primary:hover:not(:disabled) {
    transform: translateY(-3px) scale(1.02);
  }
}

/* Short viewports (landscape phones) */
@media (max-height: 480px) {
  .page {
    justify-content: flex-start;
    padding-top: var(--space-md);
  }

  .modal {
    max-height: 85svh;
  }
}
