/* ==========================================================================
   INTERACTIVE FEATURES: DYNAMIC ISLAND MASCOT, LUCKY WHEEL SYNC, BUBBLE & MEDALS
   Apple Liquid Glass Design System Integration
   ========================================================================== */

/* 1. DYNAMIC ISLAND MASCOT CAPSULE */
/* Dynamic Island Wrapper Container for Smooth Height & Layout Slide Transitions */
.dynamic-island-wrapper {
  display: none;
  grid-template-rows: 0fr;
  opacity: 0;
  margin-top: 0;
  margin-bottom: 0;
  overflow: hidden;
  width: 100%;
  pointer-events: none;
}

.dynamic-island-wrapper.is-expanded {
  display: grid;
  grid-template-rows: 1fr;
  opacity: 1;
  margin-top: 12px;
  margin-bottom: 20px;
  pointer-events: auto;
}

.dynamic-island-wrapper.island-opening,
.dynamic-island-wrapper.island-closing {
  transition: grid-template-rows 0.38s cubic-bezier(0.16, 1, 0.3, 1),
              margin-top 0.38s cubic-bezier(0.16, 1, 0.3, 1),
              margin-bottom 0.38s cubic-bezier(0.16, 1, 0.3, 1),
              opacity 0.28s ease;
}

.dynamic-island-wrapper-inner {
  min-height: 0;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 4px 0;
}

.dynamic-island-wrapper .dynamic-island-capsule {
  margin: 0 auto;
}

.dynamic-island-capsule {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: fit-content;
  max-width: min(92vw, 780px);
  min-width: 44px;
  margin: 12px auto 20px auto;
  padding: 6px 18px 6px 10px;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(28px) saturate(190%);
  -webkit-backdrop-filter: blur(28px) saturate(190%);
  border: 1.5px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08), inset 0 1px 2px rgba(255, 255, 255, 0.95);
  position: relative;
  z-index: 40;
  box-sizing: border-box;
  overflow: hidden;
  will-change: transform, opacity;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s ease;
}

html[data-theme="dark"] .dynamic-island-capsule {
  background: rgba(24, 24, 27, 0.92);
  border-color: rgba(255, 255, 255, 0.16);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.65), inset 0 1px 1px rgba(255, 255, 255, 0.12);
}

.dynamic-island-capsule:hover {
  transform: translateY(-1px) scale(1.008);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.12);
}

/* Opening & Closing Morph Animations */
.dynamic-island-capsule.island-opening {
  animation: islandCircleToPill 0.72s cubic-bezier(0.22, 1, 0.36, 1) both !important;
}

.dynamic-island-capsule.island-opening .capsule-body {
  animation: islandBodyFadeIn 0.42s cubic-bezier(0.22, 1, 0.36, 1) 0.2s both;
}

.dynamic-island-capsule.island-closing {
  animation: islandPillToCircleVanish 0.48s cubic-bezier(0.4, 0, 0.2, 1) both !important;
  pointer-events: none;
}

.dynamic-island-capsule.island-closing .capsule-body {
  animation: islandBodyFadeOut 0.16s ease forwards;
}

@keyframes islandCircleToPill {
  0% {
    border-radius: 50%;
    opacity: 0;
    transform: scale(0.2, 0.72);
    filter: blur(5px);
  }
  62% {
    border-radius: 9999px;
    opacity: 1;
    transform: scale(1.015, 1.015);
    filter: blur(0);
  }
  100% {
    border-radius: 9999px;
    opacity: 1;
    transform: scale(1);
    filter: blur(0);
  }
}

@keyframes islandPillToCircleVanish {
  0% {
    border-radius: 9999px;
    opacity: 1;
    transform: scale(1);
    filter: blur(0);
  }
  70% {
    border-radius: 50%;
    opacity: 0.7;
    transform: scale(0.42, 0.82);
    filter: blur(1px);
  }
  100% {
    border-radius: 50%;
    opacity: 0;
    transform: scale(0.2, 0.72);
    filter: blur(5px);
  }
}

@keyframes islandBodyFadeIn {
  from {
    opacity: 0;
    transform: scale(0.85) translateX(-8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateX(0);
  }
}

@keyframes islandBodyFadeOut {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.65);
  }
}

.island-morph-pulse {
  animation: islandMorphEffect 0.42s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes islandMorphEffect {
  0% { transform: scale(1); }
  45% { transform: scale(1.012); }
  100% { transform: scale(1); }
}

.mascot-avatar-wrap,
.capsule-mascot {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  animation: mascotBob 3.2s ease-in-out infinite;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.capsule-mascot .mascot-svg,
.mascot-avatar-wrap .mascot-svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Mood Auras and Glows */
.dynamic-island-capsule[data-mood="happy"] .capsule-mascot {
  filter: drop-shadow(0 2px 8px rgba(0, 122, 255, 0.45));
}

.dynamic-island-capsule[data-mood="cheer"] .capsule-mascot {
  filter: drop-shadow(0 2px 8px rgba(255, 149, 0, 0.5));
}

.dynamic-island-capsule[data-mood="fire"] .capsule-mascot {
  filter: drop-shadow(0 2px 10px rgba(255, 59, 48, 0.6));
  animation: mascotFlamePulse 1.8s ease-in-out infinite;
}

.dynamic-island-capsule[data-mood="relax"] .capsule-mascot {
  filter: drop-shadow(0 2px 8px rgba(52, 199, 89, 0.45));
}

@keyframes mascotFlamePulse {
  0%, 100% { transform: translateY(0) scale(1); filter: drop-shadow(0 2px 6px rgba(255, 59, 48, 0.45)); }
  50% { transform: translateY(-2px) scale(1.08); filter: drop-shadow(0 4px 14px rgba(255, 149, 0, 0.75)); }
}

@keyframes mascotBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px) scale(1.05); }
}

.capsule-content,
.capsule-body {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  animation: capsuleFadeIn 0.4s ease forwards;
}

@keyframes capsuleFadeIn {
  from { opacity: 0; transform: translateX(-4px); }
  to { opacity: 1; transform: translateX(0); }
}

.capsule-tag {
  background: #007AFF;
  color: #FFFFFF;
  padding: 3px 9px;
  border-radius: 9999px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0, 122, 255, 0.3);
  transition: background-color 0.25s ease, box-shadow 0.25s ease;
}

.capsule-text {
  font-size: 0.84rem;
  font-weight: 700;
  color: #18181B;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 0.2s ease;
  min-width: 0;
  flex: 1;
  position: relative;
  display: block;
}

html[data-theme="dark"] .capsule-text {
  color: #F4F4F5;
}

.capsule-text.is-marquee {
  text-overflow: clip !important;
  overflow: hidden !important;
  -webkit-mask-image: linear-gradient(90deg, #000 0%, #000 calc(100% - 14px), transparent 100%);
  mask-image: linear-gradient(90deg, #000 0%, #000 calc(100% - 14px), transparent 100%);
}

.capsule-text-inner {
  display: inline-block;
  white-space: nowrap;
  will-change: transform;
}

.capsule-status-dot {
  display: none !important;
}

@keyframes dotBlink {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.capsule-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 9999px;
  background: rgba(0, 122, 255, 0.12);
  color: #007AFF;
  font-size: 0.76rem;
  font-weight: 800;
  text-decoration: none;
  border: 1px solid rgba(0, 122, 255, 0.25);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
}

.capsule-link-btn:hover {
  background: #007AFF;
  color: #FFFFFF;
  transform: scale(1.04);
}

.capsule-link-btn:active {
  transform: scale(0.95);
}



/* 4. OLYMPIC MEDAL TALLY STYLING */
.viewer-medal-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.03);
}

html[data-theme="dark"] .viewer-medal-card {
  background: rgba(30, 30, 34, 0.85);
  border-color: rgba(255, 255, 255, 0.1);
}

.medal-team-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.05rem;
  font-weight: 800;
}

.medal-tally-chips {
  display: flex;
  align-items: center;
  gap: 8px;
}

.medal-tally-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.86rem;
  font-weight: 800;
  font-family: var(--font-outfit, sans-serif);
}

.badge-gold {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.25) 0%, rgba(255, 165, 0, 0.25) 100%);
  color: #B26A00;
  border: 1px solid rgba(255, 215, 0, 0.4);
}

.badge-silver {
  background: linear-gradient(135deg, rgba(226, 232, 240, 0.3) 0%, rgba(148, 163, 184, 0.2) 100%);
  color: #475569;
  border: 1px solid rgba(203, 213, 225, 0.4);
}

.badge-bronze {
  background: linear-gradient(135deg, rgba(205, 127, 50, 0.25) 0%, rgba(180, 83, 9, 0.2) 100%);
  color: #92400E;
  border: 1px solid rgba(205, 127, 50, 0.4);
}

html[data-theme="dark"] .badge-gold { color: #FCD34D; }
html[data-theme="dark"] .badge-silver { color: #E2E8F0; }
html[data-theme="dark"] .badge-bronze { color: #FDBA74; }

/* 5. TACTILE BUTTON MICRO-ANIMATIONS */
button, .btn-primary, .btn-action, .admin-action-btn, .admin-submit-btn, .filter-chip, .day-tab-pill {
  transition: transform 0.16s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.16s ease !important;
}

button:active, .btn-primary:active, .btn-action:active, .admin-action-btn:active, .admin-submit-btn:active, .filter-chip:active {
  transform: scale(0.95) !important;
}

/* 6. SPORTS THEMED SVG ICONS */
.sport-icon-svg {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
  stroke: currentColor;
  margin-right: 6px;
}

.mcard-sport-pill, .match-sport-text, .badge-sport {
  display: inline-flex !important;
  align-items: center !important;
}

/* Mobile Adjustments */
@media (max-width: 768px) {
  .dynamic-island-wrapper.is-expanded {
    margin-top: 8px;
    margin-bottom: 14px;
  }
  .dynamic-island-capsule {
    width: fit-content;
    max-width: 100%;
    margin: 8px auto 14px auto;
    padding: 6px 14px 6px 10px;
    gap: 8px;
  }
  .capsule-body {
    gap: 8px;
  }
  .capsule-tag {
    font-size: 0.72rem;
    padding: 2.5px 8px;
  }
  .capsule-text {
    font-size: 0.82rem;
  }
  .viewer-wheel-bubble {
    bottom: calc(76px + env(safe-area-inset-bottom, 12px));
    right: 16px;
    width: 52px;
    height: 52px;
  }
  .lucky-wheel-modal {
    padding: 18px 20px;
    width: 94%;
  }
  .wheel-canvas-wrapper {
    width: 280px;
    height: 280px;
  }
  #viewerWheelCanvas, #wheelCanvas {
    width: 280px !important;
    height: 280px !important;
  }
}

.sport-icon-img {
  width: 18px;
  height: 18px;
  object-fit: contain;
  vertical-align: middle;
  display: inline-block;
  margin-right: 5px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.25));
}

@media (prefers-reduced-motion: reduce) {
  .dynamic-island-wrapper,
  .dynamic-island-wrapper.is-expanded,
  .dynamic-island-capsule,
  .dynamic-island-capsule.island-opening,
  .dynamic-island-capsule.island-closing,
  .dynamic-island-capsule.island-opening .capsule-body,
  .capsule-mascot,
  .mascot-avatar-wrap {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
