/**
 * gamification.css — Phase 1 Engagement Features
 *
 * Covers:
 *  1. Enhanced Streak Badge (fire animation, tiers, shield)
 *  2. Daily Discovery Card (blur-reveal, mystery, animation)
 *  3. Mystery Combo Box (3 boxes, rarity reveal)
 *  4. Achievement Popup (unlock toast)
 *  5. Achievements Panel (overlay grid)
 */

/* ================================================================
   2. DAILY DISCOVERY CARD
   ================================================================ */

.discovery-card {
  position: relative;
  margin: 12px 16px;
  border-radius: 20px;
  overflow: hidden;
  cursor: pointer;
  outline: none;
  animation: discoverySlideIn 0.55s cubic-bezier(0.34, 1.4, 0.64, 1) forwards;
}

@keyframes discoverySlideIn {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

.discovery-card:focus-visible {
  box-shadow: 0 0 0 3px var(--accent);
}

/* Mystery (unrevealed) state */
.discovery-card__mystery {
  position: relative;
  height: 130px;
  overflow: hidden;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(30,20,50,0.95), rgba(50,30,20,0.9));
  border: 1px solid rgba(255, 200, 100, 0.15);
}

.discovery-card__blur-img {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.discovery-card__blur-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: blur(18px) brightness(0.4);
  transform: scale(1.1);
  transition: filter 0.35s ease;
}

.discovery-card__mystery-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 12px;
  text-align: center;
}

.discovery-card__gift-icon {
  font-size: 2.2rem;
  animation: giftBounce 1.8s ease-in-out infinite;
  line-height: 1;
}

@keyframes giftBounce {
  0%, 100% { transform: translateY(0) scale(1); }
  40%       { transform: translateY(-6px) scale(1.08); }
  60%       { transform: translateY(-4px) scale(1.05); }
}

.discovery-card__mystery-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.03em;
}

.discovery-card__mystery-hint {
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 999px;
  padding: 3px 14px;
  margin-top: 4px;
  animation: hintPulse 2s ease-in-out infinite;
}

@keyframes hintPulse {
  0%, 100% { border-color: rgba(255, 255, 255, 0.3); }
  50%       { border-color: rgba(247, 201, 72, 0.7); box-shadow: 0 0 10px rgba(247, 201, 72, 0.25); }
}

.discovery-card__mystery-sub {
  font-size: 0.68rem;
  color: rgba(255, 180, 100, 0.85);
  margin-top: 2px;
}

/* Revealed state */
.discovery-card.is-revealed .discovery-card__revealed {
  position: relative;
  height: 130px;
  overflow: hidden;
  border-radius: 20px;
  border: 1.5px solid rgba(247, 201, 72, 0.3);
}

.discovery-card.is-compact .discovery-card__revealed {
  position: relative;
  height: 80px;
  overflow: hidden;
  border-radius: 16px;
  border: 1px solid rgba(247, 201, 72, 0.2);
}

.discovery-card__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}


.discovery-card__overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.82) 0%, rgba(0,0,0,0.25) 55%, transparent 100%);
}

.discovery-card__content {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px 16px;
}

.discovery-card__label {
  font-size: 0.68rem;
  color: #f7c948;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 3px;
}

.discovery-card__name {
  font-size: 1.0rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.25;
}

.discovery-card__desc {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.75);
  margin-top: 4px;
  line-height: 1.4;
}

.discovery-card__tags {
  display: flex;
  gap: 6px;
  margin-top: 5px;
  flex-wrap: wrap;
}

.discovery-card__tags span {
  font-size: 0.65rem;
  background: rgba(255,255,255,0.15);
  border-radius: 999px;
  padding: 2px 8px;
  color: rgba(255,255,255,0.85);
}

/* Reveal animation */
.discovery-card.is-revealing .discovery-card__blur-img img {
  filter: blur(4px) brightness(0.7);
  transform: scale(1.05);
}

.discovery-card.is-revealing .discovery-card__mystery-overlay {
  opacity: 0;
  transform: scale(0.9);
  transition: all 0.35s ease;
}


/* ================================================================
   3. MYSTERY COMBO BOX
   ================================================================ */

.mystery-box-overlay {
  position: fixed;
  inset: 0;
  z-index: 4000;
  background: rgba(0, 0, 0, 0.82);
  display: flex;
  align-items: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
  backdrop-filter: blur(4px);
}

.mystery-box-overlay.is-visible {
  opacity: 1;
  pointer-events: all;
}

.mystery-box__panel {
  background: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
  border-radius: 28px 28px 0 0;
  border-top: 1px solid rgba(255,255,255,0.08);
  width: 100%;
  padding: 28px 20px 36px;
  transform: translateY(100%);
  transition: transform 0.38s cubic-bezier(0.34, 1.3, 0.64, 1);
}

.mystery-box-overlay.is-visible .mystery-box__panel {
  transform: translateY(0);
}

.mystery-box__header {
  text-align: center;
  margin-bottom: 24px;
}

.mystery-box__title {
  font-size: 1.35rem;
  font-weight: 800;
  color: #f7c948;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.mystery-box__subtitle {
  font-size: 0.82rem;
  color: rgba(240, 240, 245, 0.55);
}

.mystery-box__boxes {
  display: flex;
  gap: 14px;
  justify-content: center;
  margin-bottom: 20px;
}

.mystery-box__box {
  flex: 1;
  max-width: 110px;
  aspect-ratio: 1;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(255, 107, 53, 0.12) 0%, rgba(247, 201, 72, 0.08) 100%);
  border: 2px solid rgba(247, 201, 72, 0.25);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.22s ease;
  animation: boxAppear 0.5s cubic-bezier(0.34, 1.5, 0.64, 1) backwards;
  position: relative;
  overflow: hidden;
}

.mystery-box__box:nth-child(1) { animation-delay: 0.05s; }
.mystery-box__box:nth-child(2) { animation-delay: 0.12s; }
.mystery-box__box:nth-child(3) { animation-delay: 0.19s; }

@keyframes boxAppear {
  from { opacity: 0; transform: scale(0.7) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.mystery-box__box::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 0%, rgba(247, 201, 72, 0.15) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.mystery-box__box:hover,
.mystery-box__box:focus-visible {
  border-color: rgba(247, 201, 72, 0.6);
  transform: translateY(-4px) scale(1.04);
  box-shadow: 0 8px 24px rgba(247, 201, 72, 0.2);
}

.mystery-box__box:hover::before {
  opacity: 1;
}

.mystery-box__box:active {
  transform: scale(0.97);
}

.mystery-box__box-icon {
  font-size: 2rem;
  animation: giftBounce 2s ease-in-out infinite;
  line-height: 1;
}

.mystery-box__box-num {
  font-size: 0.7rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.55);
  letter-spacing: 0.05em;
}

.mystery-box__box-hint {
  font-size: 0.65rem;
  color: rgba(247, 201, 72, 0.7);
}

/* Chosen / Unchosen states */
.mystery-box__box.is-chosen {
  border-color: #f7c948;
  background: linear-gradient(135deg, rgba(247, 201, 72, 0.25) 0%, rgba(255, 107, 53, 0.15) 100%);
  animation: chosenPulse 0.4s ease forwards;
}

@keyframes chosenPulse {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.12); }
  70%  { transform: scale(0.97); }
  100% { transform: scale(1.04); }
}

.mystery-box__box.is-unchosen {
  opacity: 0.3;
  filter: grayscale(0.6);
  transform: scale(0.93);
  pointer-events: none;
}

.mystery-box__skip {
  display: block;
  width: 100%;
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  color: rgba(240, 240, 245, 0.5);
  font-size: 0.82rem;
  padding: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mystery-box__skip:hover {
  background: rgba(255,255,255,0.05);
  color: rgba(240, 240, 245, 0.8);
}


/* ================================================================
   4. ACHIEVEMENT POPUP (unlock toast)
   ================================================================ */

.achievement-popup {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%) translateY(-120%);
  z-index: 5000;
  pointer-events: none;
  transition: transform 0.42s cubic-bezier(0.34, 1.4, 0.64, 1);
  width: min(94vw, 380px);
}

.achievement-popup.is-visible {
  transform: translateX(-50%) translateY(12px);
}

.achievement-popup__inner {
  display: flex;
  align-items: center;
  gap: 14px;
  background: linear-gradient(135deg, #1a2a1a 0%, #0f1f0f 100%);
  border: 1.5px solid rgba(46, 204, 113, 0.4);
  border-radius: 20px;
  padding: 14px 18px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(46, 204, 113, 0.1) inset;
  backdrop-filter: blur(8px);
}

.achievement-popup__badge {
  font-size: 2rem;
  flex-shrink: 0;
  animation: achieveBadgeRotate 0.6s ease 0.1s backwards;
}

@keyframes achieveBadgeRotate {
  from { transform: rotate(-20deg) scale(0.5); opacity: 0; }
  to   { transform: rotate(0deg)   scale(1);   opacity: 1; }
}

.achievement-popup__content {
  min-width: 0;
  flex: 1;
}

.achievement-popup__label {
  font-size: 0.65rem;
  font-weight: 700;
  color: #2ecc71;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 2px;
}

.achievement-popup__name {
  font-size: 0.92rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.achievement-popup__desc {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.55);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}


/* ================================================================
   5. ACHIEVEMENTS PANEL (bottom sheet overlay)
   ================================================================ */

.achievements-overlay {
  position: fixed;
  inset: 0;
  z-index: 3500;
  background: rgba(0, 0, 0, 0.75);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
  display: flex;
  align-items: flex-end;
  backdrop-filter: blur(4px);
}

.achievements-overlay.is-visible {
  opacity: 1;
  pointer-events: all;
}

.achievements-panel {
  background: #0f0f1a;
  border-radius: 28px 28px 0 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.38s cubic-bezier(0.34, 1.2, 0.64, 1);
}

.achievements-overlay.is-visible .achievements-panel {
  transform: translateY(0);
}

.achievements-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

.achievements-panel__title {
  font-size: 1.15rem;
  font-weight: 800;
  color: #f7c948;
  margin: 0;
}

.achievements-panel__close {
  background: rgba(255,255,255,0.08);
  border: none;
  border-radius: 999px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(240, 240, 245, 0.7);
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s;
}

.achievements-panel__close:hover {
  background: rgba(255, 255, 255, 0.14);
}

.achievements-panel__body {
  overflow-y: auto;
  padding: 16px 16px 32px;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}

/* Achievements header with progress bar */
.ach-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.ach-header__count {
  font-size: 1.1rem;
  font-weight: 800;
  color: #f7c948;
}

.ach-header__bar {
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  overflow: hidden;
}

.ach-header__fill {
  height: 100%;
  background: linear-gradient(90deg, #ff6b35, #f7c948);
  border-radius: 999px;
  transition: width 0.8s cubic-bezier(0.34, 1.3, 0.64, 1);
}

/* Achievement groups */
.ach-group {
  margin-bottom: 20px;
}

.ach-group__title {
  font-size: 0.75rem;
  font-weight: 700;
  color: rgba(240, 240, 245, 0.45);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 10px;
  padding-left: 4px;
}

.ach-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

/* Achievement card */
.ach-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 14px;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  text-align: center;
  position: relative;
  transition: all 0.22s ease;
}

.ach-card.is-unlocked {
  background: linear-gradient(135deg, rgba(247, 201, 72, 0.1) 0%, rgba(255, 107, 53, 0.06) 100%);
  border-color: rgba(247, 201, 72, 0.3);
  box-shadow: 0 0 16px rgba(247, 201, 72, 0.08);
}

.ach-card.is-locked {
  opacity: 0.55;
  filter: grayscale(0.4);
}

.ach-card__emoji {
  font-size: 1.6rem;
  line-height: 1;
}

.ach-card.is-locked .ach-card__emoji {
  filter: grayscale(1) opacity(0.6);
}

.ach-card__name {
  font-size: 0.65rem;
  font-weight: 600;
  color: rgba(240, 240, 245, 0.7);
  line-height: 1.3;
}

.ach-card.is-unlocked .ach-card__name {
  color: rgba(240, 240, 245, 0.9);
}

.ach-card__check {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 16px;
  height: 16px;
  background: #2ecc71;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.55rem;
  color: #000;
  font-weight: 900;
}
