/* ══════════════════════════════════════════════════════════════════════════
   CHESTS.CSS — Treasure Chest Animation & Icon System
   Rise Family Quest
   ══════════════════════════════════════════════════════════════════════════ */

/* ── RARITY GLOW COLORS ── */
.chest-rarity-common    { --chest-glow: #C0C0C0; --chest-glow-dim: rgba(192,192,192,0.35); }
.chest-rarity-rare      { --chest-glow: #4AAED9; --chest-glow-dim: rgba(74,174,217,0.35); }
.chest-rarity-epic      { --chest-glow: #9B59B6; --chest-glow-dim: rgba(155,89,182,0.35); }
.chest-rarity-legendary { --chest-glow: #E9A825; --chest-glow-dim: rgba(233,168,37,0.35); }

/* ══════════════════════════════════════════════════════════════════════════
   CHEST UNLOCK OVERLAY
   ══════════════════════════════════════════════════════════════════════════ */

.chest-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 24px 20px;
  box-sizing: border-box;
  animation: overlay-fade-in 0.35s ease-out forwards;
}

.chest-overlay--exit {
  animation: overlay-fade-out 0.35s ease-in forwards;
}

@keyframes overlay-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes overlay-fade-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* Headline above chest */
.chest-headline {
  font-family: 'Lexend', sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted, #7A90B8);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 24px;
  text-align: center;
}

/* ── CHEST STAGE (centered column) ── */
.chest-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  width: 280px;
}

/* ── STAR ROW ── */
.chest-stars {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 12px;
  height: 36px;
}

.chest-star {
  font-size: 28px;
  opacity: 0;
  transform: scale(0) rotate(-20deg);
  transition: none;
  filter: drop-shadow(0 0 8px var(--chest-glow, #E9A825));
}

.chest-star--visible {
  animation: star-pop 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes star-pop {
  0%   { opacity: 0; transform: scale(0) rotate(-20deg); }
  70%  { opacity: 1; transform: scale(1.2) rotate(5deg); }
  100% { opacity: 1; transform: scale(1.0) rotate(0deg); }
}

/* ── CHEST CONTAINER ── */
.chest-container {
  position: relative;
  width: 160px;
  height: 140px;
  perspective: 600px;
  flex-shrink: 0;
}

/* ── GLOW RING ── */
.chest-glow {
  position: absolute;
  width: 220px;
  height: 220px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, var(--chest-glow-dim, rgba(233,168,37,0.35)) 0%, transparent 70%);
  box-shadow: 0 0 32px 12px var(--chest-glow-dim, rgba(233,168,37,0.3));
  opacity: 0;
  pointer-events: none;
  z-index: 0;
  transition: opacity 0.3s;
}

.chest-glow--pulsing {
  opacity: 1;
  animation: glow-pulse 1.8s ease-in-out infinite;
}

@keyframes glow-pulse {
  0%   { transform: translate(-50%, -50%) scale(1.0);  box-shadow: 0 0 32px 12px var(--chest-glow-dim); }
  50%  { transform: translate(-50%, -50%) scale(1.25); box-shadow: 0 0 60px 24px var(--chest-glow-dim); }
  100% { transform: translate(-50%, -50%) scale(1.0);  box-shadow: 0 0 32px 12px var(--chest-glow-dim); }
}

/* ── CHEST ART ── */
.chest-art {
  position: absolute;
  width: 100%;
  height: 100%;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* Chest body (bottom portion) */
.chest-body {
  width: 120px;
  height: 70px;
  background: linear-gradient(160deg, #7C4A1A 0%, #5C3410 50%, #3A1E08 100%);
  border: 3px solid #A0622A;
  border-radius: 6px 6px 10px 10px;
  position: relative;
  box-shadow:
    0 4px 16px rgba(0,0,0,0.6),
    inset 0 1px 0 rgba(255,200,100,0.2),
    0 0 0 1px rgba(160,98,42,0.5);
  z-index: 2;
}

/* Metal band across the chest body */
.chest-body::after {
  content: '';
  position: absolute;
  top: 50%;
  left: -3px; right: -3px;
  height: 14px;
  transform: translateY(-50%);
  background: linear-gradient(180deg, #B87333 0%, #8B5820 50%, #B87333 100%);
  border-top: 1px solid #D4954A;
  border-bottom: 1px solid #D4954A;
}

/* Lock clasp on chest body */
.chest-clasp {
  position: absolute;
  width: 20px;
  height: 22px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 3;
  background: linear-gradient(180deg, #E9A825 0%, #C07820 100%);
  border: 2px solid #FFD700;
  border-radius: 4px;
  box-shadow: 0 0 8px var(--chest-glow, #E9A825);
}

/* Chest lid */
.chest-lid {
  width: 124px;
  height: 44px;
  background: linear-gradient(160deg, #9A5C22 0%, #7C4214 50%, #5C2E0A 100%);
  border: 3px solid #A0622A;
  border-radius: 6px 6px 2px 2px;
  position: relative;
  top: 4px;
  transform-origin: center bottom;
  transform-style: preserve-3d;
  box-shadow:
    0 -3px 12px rgba(0,0,0,0.4),
    inset 0 1px 0 rgba(255,200,100,0.2);
  z-index: 3;
  transition: none;
}

/* Metal band on lid */
.chest-lid::after {
  content: '';
  position: absolute;
  bottom: 4px;
  left: -3px; right: -3px;
  height: 10px;
  background: linear-gradient(180deg, #B87333 0%, #8B5820 50%, #B87333 100%);
  border-top: 1px solid #D4954A;
  border-bottom: 1px solid #D4954A;
}

.chest-lid--shaking {
  animation: lid-shake 0.6s linear forwards;
}

@keyframes lid-shake {
  0%   { transform: rotate(0deg) translateX(0); }
  15%  { transform: rotate(4deg) translateX(3px); }
  30%  { transform: rotate(-4deg) translateX(-3px); }
  50%  { transform: rotate(3deg) translateX(2px); }
  70%  { transform: rotate(-3deg) translateX(-2px); }
  85%  { transform: rotate(1deg) translateX(1px); }
  100% { transform: rotate(0deg) translateX(0); }
}

.chest-lid--open {
  animation: chest-open 0.4s ease-out forwards;
}

@keyframes chest-open {
  0%   { transform: rotateX(0deg) translateY(0px); }
  100% { transform: rotateX(-130deg) translateY(-10px); }
}

/* ── LIGHT BURST ── */
.chest-burst {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 0; height: 0;
  pointer-events: none;
  z-index: 4;
}

.chest-burst--active .chest-ray {
  animation: ray-burst 0.5s ease-out forwards;
}

.chest-ray {
  position: absolute;
  width: 3px;
  height: 60px;
  background: linear-gradient(to top, var(--chest-glow, #E9A825), transparent);
  transform-origin: center bottom;
  opacity: 0;
  top: -60px;
  left: -1.5px;
}

@keyframes ray-burst {
  0%   { transform: rotate(var(--ray-angle)) scaleY(0); opacity: 1; }
  60%  { transform: rotate(var(--ray-angle)) scaleY(1); opacity: 0.8; }
  100% { transform: rotate(var(--ray-angle)) scaleY(1.1); opacity: 0; }
}

/* ── RARITY LABEL ── */
.chest-rarity-label {
  font-family: 'Lexend', sans-serif;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: 20px;
  margin-top: 14px;
}

.chest-rarity-label--common    { color: #C0C0C0; background: rgba(192,192,192,0.15); border: 1px solid rgba(192,192,192,0.3); }
.chest-rarity-label--rare      { color: #4AAED9; background: rgba(74,174,217,0.15);  border: 1px solid rgba(74,174,217,0.3); }
.chest-rarity-label--epic      { color: #B07FCC; background: rgba(155,89,182,0.15);  border: 1px solid rgba(155,89,182,0.3); }
.chest-rarity-label--legendary { color: #E9A825; background: rgba(233,168,37,0.15);  border: 1px solid rgba(233,168,37,0.3); }

/* ── CHEST NAME ── */
.chest-name {
  font-family: 'Lexend', sans-serif;
  font-size: 20px;
  font-weight: 800;
  color: var(--text, #EEF0F8);
  text-align: center;
  margin-top: 8px;
  text-shadow: 0 0 20px var(--chest-glow, #E9A825);
}

/* ── REWARD REVEAL ── */
.chest-reward-reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: none;
  text-align: center;
  width: 100%;
  margin-top: 16px;
}

.chest-reward-reveal--visible {
  animation: reward-rise 0.5s ease-out forwards;
}

@keyframes reward-rise {
  0%   { opacity: 0; transform: translateY(16px); }
  100% { opacity: 1; transform: translateY(0); }
}

.chest-reward-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}

.chest-reward-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 10px 14px;
}

.chest-reward-icon { font-size: 20px; flex-shrink: 0; }
.chest-reward-text { font-family: 'Lexend', sans-serif; font-size: 14px; font-weight: 600; color: var(--text, #EEF0F8); }

/* ── CONTINUE BUTTON ── */
.chest-continue-btn {
  width: 280px;
  padding: 14px;
  background: linear-gradient(135deg, var(--blue-dark, #1A6FA8), var(--blue, #4AAED9));
  border: none;
  border-radius: 14px;
  color: white;
  font-family: 'Lexend', sans-serif;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  margin-top: 20px;
  opacity: 0;
  transform: translateY(10px);
  box-shadow: 0 4px 20px rgba(74,174,217,0.4);
  letter-spacing: 0.3px;
}

.chest-continue-btn--visible {
  animation: btn-appear 0.3s ease-out forwards, btn-pulse 1.5s ease-in-out 0.3s infinite;
}

@keyframes btn-appear {
  0%   { opacity: 0; transform: translateY(10px); }
  100% { opacity: 1; transform: translateY(0); }
}

@keyframes btn-pulse {
  0%, 100% { transform: scale(1.0); }
  50%       { transform: scale(1.03); }
}

/* ── PARTICLE ── */
@keyframes particle-fly {
  0%   { transform: translate(-50%, -50%) translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -50%) translate(var(--dx), var(--dy)) scale(0); opacity: 0; }
}

/* ══════════════════════════════════════════════════════════════════════════
   CHEST ICONS (on Rise Road and Arena Map screens)
   ══════════════════════════════════════════════════════════════════════════ */

.chest-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  user-select: none;
}

.chest-icon__art {
  font-size: 22px;
  line-height: 1;
  transition: filter 0.2s, opacity 0.2s;
}

/* Locked state */
.chest-icon--locked .chest-icon__art {
  opacity: 0.35;
  filter: grayscale(1);
}

.chest-icon__lock {
  position: absolute;
  bottom: -4px;
  right: -4px;
  font-size: 12px;
  background: var(--card, #1F2E4A);
  border-radius: 50%;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border, #2E4070);
}

/* Pending (unlocked, ready to open) */
.chest-icon--pending .chest-icon__art {
  filter: drop-shadow(0 0 8px var(--chest-glow, #E9A825));
}

.chest-icon__pulse-ring {
  position: absolute;
  inset: -5px;
  border-radius: 14px;
  border: 2px solid var(--chest-glow, #E9A825);
  animation: icon-pulse-ring 1.2s ease-out infinite;
}

@keyframes icon-pulse-ring {
  0%   { transform: scale(0.9); opacity: 1; }
  100% { transform: scale(1.35); opacity: 0; }
}

/* Opened state */
.chest-icon--opened .chest-icon__art {
  opacity: 0.4;
  filter: grayscale(0.5);
}

/* Rarity-colored borders on pending chests */
.chest-icon--pending.chest-icon--common    { --chest-glow: #C0C0C0; }
.chest-icon--pending.chest-icon--rare      { --chest-glow: #4AAED9; }
.chest-icon--pending.chest-icon--epic      { --chest-glow: #9B59B6; }
.chest-icon--pending.chest-icon--legendary { --chest-glow: #E9A825; }

/* Tooltip */
.chest-icon__tooltip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--card, #1F2E4A);
  border: 1px solid var(--border, #2E4070);
  border-radius: 6px;
  padding: 4px 8px;
  font-family: 'Lexend', sans-serif;
  font-size: 10px;
  color: var(--muted, #7A90B8);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 10;
}

.chest-icon:hover .chest-icon__tooltip {
  opacity: 1;
}

/* ══════════════════════════════════════════════════════════════════════════
   CHEST EDIT MODAL (Admin)
   ══════════════════════════════════════════════════════════════════════════ */

.chest-edit-modal {
  position: fixed;
  inset: 0;
  z-index: 800;
  display: none;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
}

.chest-edit-modal__sheet {
  background: var(--card, #1F2E4A);
  border-radius: 24px 24px 0 0;
  padding: 24px 20px 36px;
  width: 100%;
  max-width: 430px;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 -8px 40px rgba(0,0,0,0.5);
  animation: sheet-slide-up 0.3s ease-out forwards;
}

@keyframes sheet-slide-up {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.chest-edit-modal__title {
  font-family: 'Lexend', sans-serif;
  font-size: 17px;
  font-weight: 800;
  color: var(--text, #EEF0F8);
  margin-bottom: 20px;
}

.chest-form-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted, #7A90B8);
  letter-spacing: 0.8px;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.chest-form-input,
.chest-form-select {
  width: 100%;
  background: var(--bg, #0F1117);
  border: 1.5px solid var(--border, #2E4070);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text, #EEF0F8);
  font-family: 'Lexend', sans-serif;
  font-size: 14px;
  font-weight: 500;
  outline: none;
  box-sizing: border-box;
  margin-bottom: 14px;
  appearance: none;
  -webkit-appearance: none;
}

.chest-form-input:focus,
.chest-form-select:focus {
  border-color: var(--blue, #4AAED9);
}

.chest-form-row {
  display: flex;
  gap: 10px;
}

.chest-form-row .chest-form-input,
.chest-form-row .chest-form-select {
  flex: 1;
}

/* ── Reward rows section ── */
.chest-form-rewards-header {
  font-family: 'Lexend', sans-serif;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted, #7A90B8);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 10px;
  margin-top: 4px;
}

.chest-form-add-reward-btn {
  width: 100%;
  padding: 10px;
  background: rgba(74,174,217,0.08);
  border: 1.5px dashed rgba(74,174,217,0.35);
  border-radius: 10px;
  color: var(--blue, #4AAED9);
  font-family: 'Lexend', sans-serif;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 4px;
  margin-bottom: 14px;
}

.chest-form-save-btn {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--blue-dark, #1A6FA8), var(--blue, #4AAED9));
  border: none;
  border-radius: 13px;
  color: white;
  font-family: 'Lexend', sans-serif;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  margin-bottom: 10px;
  box-shadow: 0 4px 16px rgba(74,174,217,0.35);
}

.chest-form-cancel-btn {
  width: 100%;
  padding: 12px;
  background: none;
  border: 1.5px solid var(--border, #2E4070);
  border-radius: 12px;
  color: var(--muted, #7A90B8);
  font-family: 'Lexend', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
