/**
 * Bet Card Styles
 *
 * All styles for bet cards, option buttons, wager selectors, and result
 * annotations.  Cards have multiple states: pending, active (waiting),
 * won, lost, expired, legendary, and risky.
 */

/* === Bet Card Base === */
.bet-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  transition: border-color 0.2s ease, background 0.2s ease, opacity 0.2s ease,
              box-shadow 0.3s ease, transform 0.3s var(--spring-soft);
}

/* State variants */
.bet-card.placed   { padding: 10px 14px; background: var(--bg); border-color: var(--border); opacity: 0.78; }
.bet-card.placed .bet-header { margin-bottom: 6px; }
.bet-card.placed .bet-title  { font-size: 0.88rem; font-weight: 500; }
.bet-card.placed .bet-context { font-size: 0.74rem; margin-bottom: 6px; }
.bet-card.won      { border-color: var(--green);  background: linear-gradient(135deg, var(--surface) 0%, rgba(102, 187, 106, 0.05) 100%); }
.bet-card.lost     { border-color: var(--red);    background: linear-gradient(135deg, var(--surface) 0%, rgba(239, 83, 80,  0.05) 100%); opacity: 0.7; }
.bet-card.expired  { border-color: var(--text-dim); opacity: 0.5; }
.bet-card.legendary { border-color: var(--gold);   box-shadow: 0 0 25px var(--gold-glow);   background: linear-gradient(135deg, var(--surface) 0%, rgba(255, 213, 79, 0.05) 100%); }
.bet-card.risky    { border-color: var(--purple);  box-shadow: 0 0 20px var(--purple-glow); }
.bet-card.blink-out { animation: betBlinkOut 0.55s ease-in forwards; pointer-events: none; }

/* Physics-based card transitions */
.bet-card.slide-in-left  { animation: cardSlideInLeft  0.45s cubic-bezier(0.22, 1, 0.36, 1) both; }
.bet-card.slide-in-right { animation: cardSlideInRight 0.45s cubic-bezier(0.22, 1, 0.36, 1) both; }
.bet-card.slide-out-right { animation: cardSlideOutRight 0.4s cubic-bezier(0.55, 0, 1, 0.45) forwards; pointer-events: none; }
.bet-card.slide-out-left  { animation: cardSlideOutLeft  0.4s cubic-bezier(0.55, 0, 1, 0.45) forwards; pointer-events: none; }

/* Result animations */
.bet-card.win-pop      { animation: cardWinPop      0.5s  cubic-bezier(0.22, 1, 0.36, 1) both; }
.bet-card.lose-slump   { animation: cardLoseSlump   0.45s ease-out both; }
.bet-card.expire-shrink { animation: cardExpireShrink 0.4s ease-out both; }
.bet-card.settle-down  { animation: cardSettleDown   0.4s cubic-bezier(0.22, 1, 0.36, 1) both; }

/* === Card Header === */
.bet-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}

.bet-title {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
  flex: 1;
  padding-right: 8px;
}

.bet-timer {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
  padding: 2px 8px;
  background: var(--accent-glow);
  border-radius: 20px;
}

.bet-timer.urgent {
  color: var(--red);
  background: var(--red-glow);
  animation: pulse 1s ease-in-out infinite;
}

/* Period/game-scope label — replaces the countdown for long-horizon bets */
.bet-scope {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-dim);
  white-space: nowrap;
  padding: 2px 8px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 20px;
  letter-spacing: 0.02em;
}

.bet-multiplier {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--gold);
  background: var(--gold-glow);
  padding: 2px 7px;
  border-radius: 10px;
  margin-left: 6px;
}

/* === Context Line === */
.bet-context {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 12px;
  line-height: 1.4;
}

/* === Option Buttons === */
.bet-options {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.bet-btn {
  flex: 1;
  min-width: 60px;
  /* 48px minimum touch target — WCAG 2.5.5 success criterion */
  min-height: 48px;
  padding: 12px 8px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-bright);
  color: var(--text);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.2s var(--spring-soft), border-color 0.15s ease,
              background 0.15s ease, color 0.15s ease, box-shadow 0.2s ease;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
}

.bet-btn:active    { transform: scale(0.93); transition-duration: 0.08s; }
.bet-btn.selected  { border-color: var(--accent); background: var(--accent-glow); color: var(--accent); animation: selectPop 0.25s var(--spring) both; }
.bet-btn.correct   { border-color: var(--green);  background: var(--green-glow);  color: var(--green); animation: selectPop 0.3s var(--spring) both; }
.bet-btn.incorrect { border-color: var(--red);    background: var(--red-glow);    color: var(--red);   opacity: 0.6; }

.bet-btn .odds {
  display: block;
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--text-dim);
  margin-top: 2px;
}

/* === Wager Selector === */
.bet-wager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  /* Allow wager row to scroll horizontally on very small screens
     rather than wrapping or overflowing the card */
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scrollbar-width: none; /* Firefox */
}

.bet-wager::-webkit-scrollbar { display: none; } /* Chrome/Safari */

.wager-label {
  font-size: 0.85rem;
  color: var(--text-dim);
  /* Keep the label from disappearing when the row scrolls */
  flex-shrink: 0;
}

.wager-btns {
  display: flex;
  gap: 6px;
  /* Don't let the button row wrap — rely on horizontal scroll instead */
  flex-shrink: 0;
}

.wager-btn {
  /* 44px minimum touch target height */
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface-bright);
  color: var(--text);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.2s var(--spring-soft), border-color 0.15s ease,
              background 0.15s ease, color 0.15s ease, box-shadow 0.2s ease;
  /* Prevent button from shrinking and becoming un-tappable */
  flex-shrink: 0;
  white-space: nowrap;
}

.wager-btn:active   { transform: scale(0.92); transition-duration: 0.06s; }
.wager-btn.selected { border-color: var(--gold); background: var(--gold-glow); color: var(--gold); animation: selectPop 0.25s var(--spring) both; }
.wager-btn:disabled { opacity: 0.3; pointer-events: none; }

/* === Combo / Power Play Meter === */
.combo-meter {
  padding: 8px 16px;
  background: linear-gradient(135deg, rgba(255,152,0,0.06), rgba(255,213,79,0.04));
  border-bottom: 1px solid rgba(255,152,0,0.25);
  transition: all 0.3s ease;
}

.combo-meter-inner {
  display: flex;
  align-items: center;
  gap: 10px;
}

.combo-meter-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--orange);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Three pip indicators that fill up as the combo grows */
.combo-pips {
  display: flex;
  gap: 6px;
  flex: 1;
}

.combo-pip {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

.combo-pip.filled {
  background: linear-gradient(90deg, var(--orange), var(--gold));
  box-shadow: 0 0 8px rgba(255,152,0,0.4);
  animation: comboPipFlash 0.4s ease;
}

@keyframes comboPipFlash {
  0%   { transform: scaleY(1.8); }
  100% { transform: scaleY(1); }
}

/* Lock In button — appears at 2 wins to let the player cash out early */
.combo-lock-btn {
  /* 36px min-height; it's a strip control, not a primary CTA, so slightly smaller */
  min-height: 36px;
  padding: 6px 14px;
  border: 1px solid var(--orange);
  border-radius: 20px;
  background: rgba(255,152,0,0.12);
  color: var(--orange);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s ease, transform 0.2s var(--spring-soft);
  -webkit-tap-highlight-color: transparent;
}

.combo-lock-btn:hover  { background: rgba(255,152,0,0.22); }
.combo-lock-btn:active { transform: scale(0.91); transition-duration: 0.06s; }

/* === AI-Generated Bet Cards === */
.bet-card.ai-generated {
  border-color: var(--accent);
  background: linear-gradient(135deg, var(--surface) 0%, rgba(79, 195, 247, 0.04) 100%);
  border-left: 3px solid var(--accent);
}

.bet-card.ai-generated.won  { border-left-color: var(--green); }
.bet-card.ai-generated.lost { border-left-color: var(--red); }

/* === Compact Resolved Card === */
/* Single-row layout: icon · title · pick + pts — replaces full-button card in results section */
.bet-card.resolved-compact {
  padding: 7px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.rc-icon {
  font-size: 0.85rem;
  font-weight: 700;
  flex-shrink: 0;
  width: 14px;
  text-align: center;
}

.bet-card.won  .rc-icon { color: var(--green); }
.bet-card.lost .rc-icon { color: var(--red); }
.bet-card.expired .rc-icon { color: var(--text-dim); }

.rc-title {
  flex: 1;
  font-size: 0.82rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rc-result {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  font-size: 0.78rem;
}

.rc-pick {
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  max-width: 120px;
  text-overflow: ellipsis;
}

.rc-pts {
  font-weight: 700;
  white-space: nowrap;
}

.rc-pts.rc-win  { color: var(--green); }
.rc-pts.rc-lose { color: var(--red); }

.rc-no-pick {
  color: var(--text-dim);
  font-style: italic;
  font-size: 0.75rem;
}

/* === Placed Bet Summary Row === */
/* Shown instead of option buttons + wager for bets the player has already locked in */
.bet-placed-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
  font-size: 0.82rem;
}

.placed-choice {
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.placed-payout {
  color: var(--text-dim);
  white-space: nowrap;
  flex-shrink: 0;
}

.placed-payout strong {
  color: var(--green);
  font-weight: 700;
}

.ai-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-glow);
  padding: 2px 6px;
  border-radius: 4px;
  margin-right: 6px;
  vertical-align: middle;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* === Star Spotlight Cards === */
/* Player prop bets with live stat context — gold left-stripe + subtle warm glow */
.bet-card.star-spotlight {
  border-color: var(--gold);
  border-left: 3px solid var(--gold);
  background: linear-gradient(135deg, var(--surface) 0%, rgba(255, 213, 79, 0.04) 100%);
}

.bet-card.star-spotlight.won  { border-left-color: var(--green); }
.bet-card.star-spotlight.lost { border-left-color: var(--red);   }

/* Banner strip at the top of the card */
.spotlight-badge {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

/* Live stat line — compact stats displayed below the context */
.spotlight-stat-line {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 10px;
  padding: 6px 10px;
  background: rgba(255, 213, 79, 0.06);
  border-radius: var(--radius-sm);
  border-left: 2px solid var(--gold);
  line-height: 1.4;
}

.spotlight-stat-line.heat-hot  {
  color: var(--orange);
  border-left-color: var(--orange);
  background: rgba(255, 152, 0, 0.07);
}

.spotlight-stat-line.heat-cold {
  color: var(--accent);
  border-left-color: var(--accent);
  background: rgba(79, 195, 247, 0.07);
}


/* === Postgame Card === */
.postgame-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 28px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
}

.postgame-score {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
}

.postgame-winner {
  font-size: 1rem;
  font-weight: 600;
  color: var(--green);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.postgame-label {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-top: 4px;
}

/* ===================================================================
 * Mobile Tactility — touch-specific enhancements
 * Only on coarse-pointer (finger) devices to avoid affecting desktop.
 * =================================================================== */

/* ── Small phones: wrap wager buttons 2×2 instead of horizontal scroll ── */
@media (max-width: 390px) {
  .wager-btns {
    flex-wrap: wrap;
    justify-content: center;
  }

  .wager-btn {
    min-width: 60px;
    padding: 8px 12px;
  }

  .bet-wager {
    flex-wrap: wrap;
    gap: 8px;
  }
}

@media (pointer: coarse) {
  /* Deeper press feedback on touch — fingers expect more travel than mouse */
  .bet-btn:active      { transform: scale(0.91); }
  .wager-btn:active    { transform: scale(0.90); }

  /* Tap glow ring on bet cards when touched (not while swiping) */
  .bet-card:not(.swiping):active {
    box-shadow: 0 0 0 3px var(--tap-glow);
  }

  /* Sport/game cards get a stronger press-in on touch */
  .sport-option:active  { transform: scale(0.93); }
  .game-option:active   { transform: scale(0.96); }

  /* ── Compact Mobile Bet Cards ─────────────────────────────────────────────
   * Tighter padding + smaller fonts so more cards fit on screen.
   * Pending cards go from ~150px to ~110px — fits 5-6 on a phone. */
  .bet-card {
    padding: 10px 12px;
  }

  .bet-header {
    margin-bottom: 6px;
  }

  .bet-title {
    font-size: 0.92rem;
  }

  .bet-context {
    font-size: 0.78rem;
    margin-bottom: 8px;
    line-height: 1.3;
  }

  .bet-options {
    gap: 6px;
  }

  .bet-btn {
    min-height: 44px;
    padding: 10px 8px;
    font-size: 0.9rem;
  }

  .bet-wager {
    margin-top: 8px;
    padding-top: 8px;
    gap: 8px;
  }

  .wager-btn {
    min-height: 40px;
    padding: 6px 12px;
    font-size: 0.82rem;
  }

  /* Compact resolved cards */
  .bet-card.resolved-compact {
    padding: 5px 10px;
  }

  /* Compact placed/waiting cards */
  .bet-card.placed {
    padding: 8px 12px;
  }

  .bet-card.placed .bet-title {
    font-size: 0.82rem;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
 * Swipe-to-Bet Overlay & Hints
 * Shown on pending bet cards during horizontal drag on touch devices.
 * ═══════════════════════════════════════════════════════════════════════════ */

.bet-card.swiping {
  z-index: 10;
  will-change: transform;
}

.swipe-hint {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 72px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.05s ease;
  border-radius: var(--radius);
  padding: 0 10px;
  text-align: center;
  white-space: nowrap;
  z-index: 2;
}

.swipe-hint-right {
  right: 4px;
  color: var(--green);
  background: linear-gradient(to left, rgba(102, 187, 106, 0.18), transparent);
}

.swipe-hint-left {
  left: 4px;
  color: var(--accent);
  background: linear-gradient(to right, rgba(79, 195, 247, 0.18), transparent);
}

/* Dynamic payout shown below the hint label during tilt */
.swipe-hint-payout {
  display: block;
  font-size: 0.65rem;
  font-weight: 600;
  margin-top: 2px;
  opacity: 0.85;
}

/* Swipe-up discard indicator */
.swipe-up-hint {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.05s ease;
  z-index: 2;
  white-space: nowrap;
}

/* Swipe commit summary toast — fixed at bottom of viewport */
.swipe-commit-toast {
  position: fixed;
  bottom: calc(48px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface-bright);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 8px 18px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

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

.swipe-commit-toast .commit-choice {
  color: var(--accent);
}

.swipe-commit-toast .commit-payout {
  color: var(--green);
  margin-left: 6px;
}

/* ═══════════════════════════════════════════════════════════════════════════
 * Screen Shake (applied to #app)
 * ═══════════════════════════════════════════════════════════════════════════ */

#app.shake-win     { animation: shakeWin     0.3s  ease-out; }
#app.shake-big     { animation: shakeBig     0.45s ease-out; }
#app.shake-jackpot { animation: shakeJackpot 0.6s  ease-out; }
#app.shake-lose    { animation: shakeLose    0.3s  ease-out; }

/* ═══════════════════════════════════════════════════════════════════════════
 * Streak Fire Particles
 * ═══════════════════════════════════════════════════════════════════════════ */

.streak-fire-particle {
  position: absolute;
  bottom: 10%;
  font-size: 1.5rem;
  pointer-events: none;
  animation: streakFireRise 1.2s ease-out forwards;
}

/* ═══════════════════════════════════════════════════════════════════════════
 * Swipe Instruction Hint (shown once for new players on first pending card)
 * ═══════════════════════════════════════════════════════════════════════════ */

@media (pointer: coarse) {
  .bet-card:not(.placed):not(.resolved-compact) {
    position: relative;
  }
}

/* Swipe tutorial hint — "← Swipe to pick →" overlay on first bet */
.swipe-tutorial-hint {
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(79, 195, 247, 0.12);
  border: 1px solid rgba(79, 195, 247, 0.25);
  border-radius: 20px;
  padding: 4px 14px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
  pointer-events: none;
  z-index: 5;
  animation: swipeHintBounce 1.5s ease-in-out infinite;
}

.swipe-tutorial-hint.fade-out {
  opacity: 0;
  transition: opacity 0.3s ease;
}

.swipe-tutorial-arrow {
  display: inline-block;
  animation: swipeArrowSlide 1.5s ease-in-out infinite;
}

.swipe-tutorial-arrow:first-child {
  animation-name: swipeArrowSlideLeft;
}

@keyframes swipeHintBounce {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50%      { transform: translateX(-50%) translateY(-3px); }
}

@keyframes swipeArrowSlide {
  0%, 100% { transform: translateX(0); }
  50%      { transform: translateX(4px); }
}

@keyframes swipeArrowSlideLeft {
  0%, 100% { transform: translateX(0); }
  50%      { transform: translateX(-4px); }
}
