/* EMPOLAS Game – popup.css v3.1.0 */
/* Google Fonts jsou načítány přes wp_enqueue_style v PHP – zde jen fallback definice */

:root {
  --eg-primary:    #2ea87e;
  --eg-primary-dk: #22896a;
  --eg-primary-lt: #e8f7f2;
  --eg-accent:     #f97316;
  --eg-bg:         #ffffff;
  --eg-surface:    #f8fafb;
  --eg-border:     #e5e9ee;
  --eg-text:       #1a2332;
  --eg-muted:      #6b7280;
  /* Barvy textu – přepisovatelné přes JS z nastavení */
  --eg-color-title:      #1a2332;
  --eg-color-subtitle:   #2c2e31;
  --eg-color-text:       #2c2e31;
  --eg-color-hint:       #2c2e31;
  --eg-color-hint-below: #6b7280;
  --eg-radius:     20px;
  --eg-shadow:     0 24px 64px rgba(0,0,0,.18), 0 4px 16px rgba(0,0,0,.08);
  --eg-font:       'Nunito', sans-serif;
  --eg-anim-dur:   1.3s;
}

/* ─── overlay ──────────────────────────────────────────────────── */
.eg-overlay {
  position: fixed;
  /* BUG FIX: inset fallback pro starší prohlížeče (Safari < 14.1, Chrome < 87) */
  top: 0; right: 0; bottom: 0; left: 0;
  inset: 0;
  z-index: 999999;
  background: rgba(20,30,50,.55);
  /* BUG FIX: -webkit- prefix pro iOS Safari / starší Chrome */
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  /* VÝCHOZÍ: skrytý */
  display: none;
  align-items: flex-start;
  justify-content: center;
  /* BUG FIX: padding pro iOS safe area (notch, home indicator) */
  padding: 16px;
  padding-top: max(16px, env(safe-area-inset-top));
  padding-right: max(16px, env(safe-area-inset-right));
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  padding-left: max(16px, env(safe-area-inset-left));
  /* BUG FIX: overscroll-behavior zabraňuje scrollování pozadí přes overlay */
  overscroll-behavior: contain;
  /* BUG FIX: overflow-y pro případ kdy popup je vyšší než viewport (malý mobil + klávesnice) */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
/* Zobrazit jen když má třídu .eg-open */
.eg-overlay.eg-open {
  display: flex;
  animation: eg-fade-in .2s ease;
}
@keyframes eg-fade-in { from{opacity:0} to{opacity:1} }

/* ─── popup karta ──────────────────────────────────────────── */
.eg-popup {
  position: relative;
  background: var(--eg-bg);
  border-radius: var(--eg-radius);
  box-shadow: var(--eg-shadow);
  width: 100%; max-width: 460px;
  padding: 52px 36px 32px;
  font-family: var(--eg-font);
  color: var(--eg-text);
  text-align: center;
  animation: eg-slide-up .3s cubic-bezier(.22,1,.36,1);
  overflow: hidden;
  /* BUG FIX: overscroll-behavior a max-height pro malé obrazovky */
  overscroll-behavior: contain;
  /* Margin auto centruje popup vertikálně pokud je místo, jinak se zarovná nahoru */
  margin: auto 0;
  /* BUG FIX: -webkit-overflow-scrolling pro iOS momentum scrolling */
  -webkit-overflow-scrolling: touch;
  /* Zajistit, že popup nepřeteče mimo overlay na výšku */
  box-sizing: border-box;
}

/* Deco obrázky přesahují popup */
.eg-popup.eg-deco-overflow {
  overflow: visible;
}
/* Při overflow skrýt canvas konfet jen do bounds */
.eg-popup.eg-deco-overflow #eg-confetti {
  position: absolute;
  /* BUG FIX: inset fallback */
  top: 0; right: 0; bottom: 0; left: 0;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  border-radius: var(--eg-radius);
  overflow: hidden;
}
@keyframes eg-slide-up {
  from { opacity:0; transform:translateY(30px) scale(.97) }
  to   { opacity:1; transform:none }
}

/* ─── křížek ─────────────────────────────────────────────────── */
.eg-close {
  position: absolute; top: 12px; right: 12px; z-index: 20;
  background: #fff; border: 1.5px solid var(--eg-border); color: var(--eg-muted);
  border-radius: 50%; width: 36px; height: 36px; font-size: 16px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s, border-color .15s;
  box-shadow: 0 2px 6px rgba(0,0,0,.08);
  pointer-events: all;
  /* BUG FIX: touch-action pro okamžitou odezvu na mobilu (eliminuje 300ms delay) */
  touch-action: manipulation;
  /* Větší tap target na mobilu (min 44×44 dle Apple HIG) */
  min-width: 36px; min-height: 36px;
}
.eg-close:hover { background: #fee2e2; color: #dc2626; border-color: #fca5a5; }

/* ─── deco obrázky ───────────────────────────────────────────── */
.eg-deco { position: absolute; pointer-events: none; object-fit: contain; z-index: 0; display: none; }
.eg-deco--tl { top: -8px;   left: -8px;   width: 100px; height: 100px; transform: rotate(-12deg); }
.eg-deco--bl { bottom: -8px; left: -8px;  width: 100px; height: 100px; transform: rotate(8deg); }
.eg-deco--br { bottom: -8px; right: -8px; width: 95px;  height: 95px;  transform: rotate(5deg); }
.eg-deco.eg-deco-visible { display: block; }

/* ─── nadpisy ────────────────────────────────────────────────── */
.eg-title   { font-size: 24px; font-size: clamp(19px,4.5vw,24px); font-weight: 900; margin: 0 0 6px; position: relative; z-index: 1; color: var(--eg-color-title); }
.eg-subtitle{ color: var(--eg-color-subtitle); font-size: 16px; margin: 0 0 16px; line-height: 1.6; position: relative; z-index: 1; }
.eg-hint         { font-size: 13px; color: var(--eg-muted); margin: 12px 0 0; }
.eg-hint--cta    {
  font-size: 24px; font-size: clamp(19px,4.5vw,24px); font-weight: 900;
  color: var(--eg-color-hint);
  margin: 0 0 14px;
  letter-spacing: -0.01em;
}
.eg-hint--below  {
  font-size: 16px; font-weight: 600;
  color: var(--eg-color-hint-below);
  margin: 14px 0 0;
  font-style: italic;
}

/* ─── loader při losování ────────────────────────────────────── */
.eg-loader {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 20px 0 10px;
}
.eg-loader.eg-loader-visible { display: flex; }
.eg-loader-spinner {
  width: 44px; height: 44px;
  border: 4px solid var(--eg-primary-lt);
  border-top-color: var(--eg-primary);
  border-radius: 50%;
  animation: eg-spin .8s linear infinite;
}
@keyframes eg-spin { to { transform: rotate(360deg); } }
.eg-loader-text { font-size: 15px; font-weight: 700; color: var(--eg-primary-dk); }

/* ─── skořápky ───────────────────────────────────────────────── */
.eg-shells { display: flex; gap: 12px; justify-content: center; position: relative; z-index: 1; }
.eg-shell {
  flex: 1; background: transparent; border: none; border-radius: 12px;
  cursor: pointer; padding: 4px;
  display: flex; align-items: center; justify-content: center;
  transition: transform .2s cubic-bezier(.34,1.56,.64,1); outline: none;
  /* BUG FIX: touch-action – eliminuje 300ms tap delay na Androidu a starším iOS */
  touch-action: manipulation;
  /* Zajistit dostatečný tap target */
  min-height: 70px;
}
.eg-shell:hover  { transform: translateY(-6px) scale(1.06); }
.eg-shell:active { transform: scale(.95); }
.eg-shell.picked { opacity: .45; pointer-events: none; transform: scale(.9); transition: all .3s; }
.eg-shell-img {
  width: 100%; max-width: 120px; height: auto; display: block;
  min-height: 80px;
  filter: drop-shadow(0 6px 14px rgba(0,0,0,.15)); transition: filter .2s;
  /* Zabrání výběru obrázku při tapnutí na mobilech */
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
}
.eg-shell:hover .eg-shell-img { filter: drop-shadow(0 10px 20px rgba(46,168,126,.3)); }

/* ─── animace skořápek ───────────────────────────────────────── */
@keyframes eg-shake  { 0%,100%{transform:translateX(0)} 20%{transform:translateX(-5px)} 40%{transform:translateX(5px)} 60%{transform:translateX(-3px)} 80%{transform:translateX(3px)} }
@keyframes eg-pulse  { 0%,100%{transform:scale(1)} 50%{transform:scale(1.1)} }
@keyframes eg-bounce { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-12px)} }
@keyframes eg-random { 0%{transform:translate(0,0)} 25%{transform:translate(-4px,-6px) rotate(-2deg)} 50%{transform:translate(3px,-2px) rotate(1.5deg)} 75%{transform:translate(-2px,-8px) rotate(-1deg)} 100%{transform:translate(0,0)} }

.eg-anim-shake  .eg-shell-img { animation: eg-shake  var(--eg-anim-dur) infinite ease-in-out; }
.eg-anim-pulse  .eg-shell-img { animation: eg-pulse  var(--eg-anim-dur) infinite ease-in-out; }
.eg-anim-bounce .eg-shell-img { animation: eg-bounce var(--eg-anim-dur) infinite ease-in-out; }
.eg-anim-random .eg-shell-img { animation: eg-random var(--eg-anim-dur) infinite ease-in-out; }
.eg-shells .eg-shell:nth-child(2) .eg-shell-img { animation-delay: .15s; }
.eg-shells .eg-shell:nth-child(3) .eg-shell-img { animation-delay: .3s; }

/* ─── konfety canvas ──────────────────────────────────────────── */
#eg-confetti {
  position: absolute;
  /* BUG FIX: inset fallback */
  top: 0; right: 0; bottom: 0; left: 0;
  inset: 0;
  pointer-events: none; z-index: 5;
  border-radius: var(--eg-radius);
}

/* ─── reward inline badge ─────────────────────────────────────── */
.eg-reward-inline { margin-bottom: 12px; }
.eg-reward-badge {
  display: inline-block;
  background: var(--eg-primary-lt); border: 1.5px solid #b6e8d6;
  color: var(--eg-primary-dk); border-radius: 100px;
  font-size: 16px; font-weight: 800; padding: 6px 20px;
}

/* ─── formulář ───────────────────────────────────────────────── */
.eg-field { margin-bottom: 14px; text-align: left; }
.eg-field label { display: block; font-size: 12px; font-weight: 800; color: var(--eg-muted); margin-bottom: 6px; letter-spacing: .07em; text-transform: uppercase; }
.eg-field input {
  width: 100%; box-sizing: border-box;
  background: var(--eg-surface); border: 1.5px solid var(--eg-border);
  border-radius: 10px; padding: 14px 20px;
  color: var(--eg-text); font-family: var(--eg-font); font-size: 16px; /* min 16px zabrání iOS zoom při focusu */
  line-height: 1.5;
  transition: border-color .2s, box-shadow .2s; outline: none;
  /* BUG FIX: -webkit-appearance none pro konzistentní vzhled na iOS */
  -webkit-appearance: none;
  appearance: none;
}
.eg-field input:focus { border-color: var(--eg-primary); box-shadow: 0 0 0 3px var(--eg-primary-lt); }
.eg-field input::placeholder { color: #c0c8d0; }
.eg-consent { margin: 4px 0 14px; text-align: left; }
.eg-consent-label { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; color: var(--eg-muted); cursor: pointer; }
.eg-consent-label input[type=checkbox] {
  width: 18px; height: 18px; flex-shrink: 0; margin-top: 2px;
  accent-color: var(--eg-primary);
  /* BUG FIX: Větší tap target pro checkbox na mobilu */
  cursor: pointer;
}
.eg-form-error { font-size: 13px; color: #dc2626; min-height: 18px; margin-bottom: 6px; text-align: left; }

/* ─── kupón box ───────────────────────────────────────────────── */
.eg-coupon-box {
  background: var(--eg-surface); border: 2px dashed var(--eg-primary);
  border-radius: 16px; padding: 18px 20px 14px; margin: 10px 0 12px;
}
.eg-coupon-label { font-size: 11px; font-weight: 800; color: var(--eg-muted); letter-spacing: .08em; text-transform: uppercase; margin-bottom: 5px; }
.eg-coupon-code {
  font-family: 'Courier New', monospace;
  font-size: 30px; font-size: clamp(22px, 6vw, 30px); font-weight: 700;
  color: var(--eg-primary-dk); letter-spacing: .18em;
  margin-bottom: 10px; word-break: break-all;
  /* BUG FIX: Výběr textu povolený pro ruční kopírování */
  -webkit-user-select: text;
  user-select: text;
}

/* ─── odpočet platnosti ───────────────────────────────────────── */
.eg-countdown {
  display: inline-flex; align-items: center; gap: 6px;
  background: #fff1f2; border: 1.5px solid #fca5a5;
  border-radius: 8px; padding: 9px 16px;
  font-size: 14px; font-weight: 800;
  color: #dc2626;
  margin-top: 2px;
}
.eg-countdown-time { font-variant-numeric: tabular-nums; letter-spacing: .04em; }
.eg-countdown.urgent { animation: eg-pulse-urgent 1s infinite; }
@keyframes eg-pulse-urgent { 0%,100%{opacity:1} 50%{opacity:.65} }

/* Popin efekt při zobrazení kroku 3 */
@keyframes eg-countdown-popin {
  0%   { opacity:0; transform: scale(.7) translateY(6px); }
  60%  { opacity:1; transform: scale(1.07) translateY(-2px); }
  80%  { transform: scale(.97); }
  100% { opacity:1; transform: scale(1) translateY(0); }
}
.eg-countdown--popin-run {
  animation: eg-countdown-popin .55s cubic-bezier(.34,1.56,.64,1) forwards;
}

/* ─── highlight blok (shortcode/text) ────────────────────────── */
.eg-highlight-block {
  background: #f0fdf4; border: 1.5px solid #bbf7d0;
  border-radius: 10px; padding: 12px 16px; margin: 12px 0;
  text-align: left; font-size: 16px; color: var(--eg-color-text);
}
.eg-highlight-label {
  font-size: 11px; font-weight: 800; color: #16a34a;
  text-transform: uppercase; letter-spacing: .07em; margin-bottom: 5px;
}
.eg-highlight-text { line-height: 1.5; }

/* ─── tlačítka ────────────────────────────────────────────────── */
.eg-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: 10px; cursor: pointer;
  font-family: var(--eg-font); font-weight: 800; font-size: 15px;
  padding: 14px 20px; transition: transform .15s, filter .15s; line-height: 1.3;
  /* BUG FIX: touch-action pro okamžitou odezvu, žádný 300ms delay */
  touch-action: manipulation;
  /* Zajistit min tap target dle Apple HIG (44px) */
  min-height: 44px;
  /* BUG FIX: zabrání výběru textu při double-tapu */
  -webkit-user-select: none;
  user-select: none;
}
.eg-btn:active { transform: scale(.97); }
.eg-btn--primary { background: linear-gradient(135deg, var(--eg-primary), var(--eg-primary-dk)); color: #fff; box-shadow: 0 4px 14px rgba(46,168,126,.35); }
.eg-btn--primary:hover { filter: brightness(1.06); }
.eg-btn--primary:disabled { opacity: .6; cursor: not-allowed; }
.eg-btn--full { width: 100%; box-sizing: border-box; }
.eg-btn.copied { background: linear-gradient(135deg, #16a34a, #15803d) !important; }
.eg-expiry-detail { font-size: 12px; color: var(--eg-muted); margin: 10px 0 4px; }
.eg-expiry-detail--strong {
  font-size: 15px; font-weight: 700;
  color: var(--eg-color-text);
  margin: 12px 0 4px;
}
.eg-email-note { font-size: 14px; color: var(--eg-color-text); margin: 4px 0 0; }

/* ─── mini bublina ────────────────────────────────────────────── */
.eg-bubble {
  position: fixed;
  bottom: 24px; left: 20px;
  /* BUG FIX: iOS safe area insets – home indicator / notch */
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  left: calc(20px + env(safe-area-inset-left, 0px));
  z-index: 999998;
  width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(135deg, var(--eg-primary), var(--eg-primary-dk));
  color: #fff; font-size: 24px;
  display: none; align-items: center; justify-content: center;
  cursor: pointer; box-shadow: 0 4px 20px rgba(46,168,126,.5); border: 3px solid #fff;
  transition: transform .2s;
  /* BUG FIX: touch-action + min size pro lepší tapability na mobilu */
  touch-action: manipulation;
}
.eg-bubble.eg-open { display: flex; animation: eg-bubble-in .4s cubic-bezier(.34,1.56,.64,1); }
.eg-bubble:hover { transform: scale(1.12); }
@keyframes eg-bubble-in { from{opacity:0;transform:scale(.4) translateY(20px)} to{opacity:1;transform:scale(1)} }

/* ─── responsive ─────────────────────────────────────────────── */
/* Tablet (768px) – mírné zmenšení */
@media (max-width: 768px) {
  .eg-overlay {
    align-items: flex-start;
    padding-top: max(12px, env(safe-area-inset-top, 12px));
  }
  .eg-popup {
    max-width: 440px;
    padding: 44px 28px 28px;
    /* Popup nesmí přesáhnout výšku viewportu (důležité při otevřené klávesnici) */
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px);
    overflow-y: auto;
  }
}

/* Malý telefon (480px) */
@media (max-width: 480px) {
  .eg-overlay {
    padding: max(8px, env(safe-area-inset-top, 8px)) 8px max(8px, env(safe-area-inset-bottom, 8px)) 8px;
  }
  .eg-popup {
    padding: 44px 18px 22px;
    border-radius: 16px;
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
    overflow-y: auto;
  }
  .eg-shell-img { max-width: 90px; }
  .eg-shells { gap: 8px; }
  .eg-btn { font-size: 14px; padding: 13px 14px; }
  .eg-title { font-size: 22px; font-size: clamp(17px, 5vw, 22px); }
  .eg-subtitle { font-size: 15px; }
  .eg-coupon-code { font-size: 26px; font-size: clamp(20px, 6vw, 26px); letter-spacing: .12em; }
}

/* Velmi malý telefon (360px a méně – starší Android, iPhone SE 1. gen) */
@media (max-width: 360px) {
  .eg-popup { padding: 40px 14px 20px; border-radius: 14px; }
  .eg-shell-img { max-width: 76px; min-height: 60px; }
  .eg-shells { gap: 6px; }
  .eg-title { font-size: 17px; }
  .eg-btn { font-size: 13px; padding: 12px 10px; }
  .eg-coupon-code { font-size: 22px; font-size: clamp(18px, 5.5vw, 22px); letter-spacing: .08em; }
  .eg-field input { padding: 12px 14px; }
}

/* Větší přesah deco při overflow módu */
.eg-deco-overflow .eg-deco--tl { top: -30px;  left: -30px;  width: 130px; height: 130px; }
.eg-deco-overflow .eg-deco--bl { bottom: -30px; left: -30px; width: 130px; height: 130px; }
.eg-deco-overflow .eg-deco--br { bottom: -30px; right: -30px; width: 120px; height: 120px; }

/* Zmenšit deco na malých mobilech – zabrání přetečení */
@media (max-width: 480px) {
  .eg-deco--tl, .eg-deco--bl, .eg-deco--br { width: 70px; height: 70px; }
  .eg-deco-overflow .eg-deco--tl,
  .eg-deco-overflow .eg-deco--bl,
  .eg-deco-overflow .eg-deco--br { width: 90px; height: 90px; }
}

/* Pulse efekt na reward badge */
@keyframes eg-reward-pulse-anim {
  0%   { transform: scale(1);    box-shadow: 0 0 0 0 rgba(46,168,126,.4); }
  40%  { transform: scale(1.07); box-shadow: 0 0 0 8px rgba(46,168,126,.15); }
  70%  { transform: scale(1.03); box-shadow: 0 0 0 14px rgba(46,168,126,.05); }
  100% { transform: scale(1);    box-shadow: 0 0 0 0 rgba(46,168,126,0); }
}
.eg-reward-badge.eg-reward-pulse {
  animation: eg-reward-pulse-anim 0.7s ease-out 3;
}

/* ─── Landscape mode – nízká výška (telefon na šířku) ───────── */
@media (max-height: 500px) and (orientation: landscape) {
  .eg-overlay { align-items: flex-start; padding-top: 8px; padding-bottom: 8px; }
  .eg-popup   { max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); overflow-y: auto; padding: 36px 24px 20px; }
  .eg-hint--below { margin: 8px 0 0; }
  .eg-shells { gap: 10px; }
  .eg-shell-img { max-width: 80px; min-height: 60px; }
}

/* ─── Přístupnost: prefers-reduced-motion ─────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .eg-overlay.eg-open,
  .eg-popup,
  .eg-bubble.eg-open { animation: none; }
  .eg-anim-shake .eg-shell-img,
  .eg-anim-pulse .eg-shell-img,
  .eg-anim-bounce .eg-shell-img,
  .eg-anim-random .eg-shell-img { animation: none; }
}
