/**
 * Inspired Crystal Awards — Corner Stack + Music Modal + PWA Install Prompt
 * Floating bottom-right stack: music note above back-to-top arrow.
 * Z-index 9990 sits below cookie consent (which uses higher z-index in appwt-cookie-consent.php).
 */

/* ===== Corner stack (music note + back-to-top) ===== */
.ica-corner-stack {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 10000; /* above appwt cookie banner z-index 9999 */
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none; /* children re-enable */
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* Hide corner stack while the AppWT cookie consent banner is showing — user makes cookie decision first */
.ica-corner-stack.is-cookie-blocked {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.ica-corner-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #0f2744 0%, #1e3a5f 100%);
  color: #ffffff;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.3s ease, visibility 0.3s ease;
  pointer-events: auto;
  outline: none;
  position: relative; /* own stacking context */
  z-index: 100000;    /* override any third-party overlay */
}

.ica-corner-btn:hover,
.ica-corner-btn:focus-visible {
  transform: translateY(-3px) scale(1.06);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}

.ica-corner-btn:focus-visible {
  outline: 2px solid #c4a052;
  outline-offset: 3px;
}

.ica-corner-btn svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

/* Music note styled distinct (gold accent ring) */
#ica-music-toggle {
  background: linear-gradient(135deg, #c4a052 0%, #d4b366 100%);
  color: #0f2744;
}

/* Back-to-top — hidden until user scrolls 300px down */
#ica-back-to-top {
  opacity: 0;
  visibility: hidden;
}

#ica-back-to-top.is-visible {
  opacity: 1;
  visibility: visible;
}

/* Mobile — slightly smaller buttons + closer to corner */
@media (max-width: 640px) {
  .ica-corner-stack {
    right: 16px;
    bottom: 16px;
    gap: 10px;
  }
  .ica-corner-btn {
    width: 48px;
    height: 48px;
  }
}

/* ===== Music modal ===== */
.ica-music-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 39, 68, 0.78);
  backdrop-filter: blur(4px);
  z-index: 10001; /* above cookie banner + corner stack */
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: ica-fade-in 0.25s ease;
}

.ica-music-modal.is-open {
  display: flex;
}

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

.ica-music-modal-content {
  background: #ffffff;
  border-radius: 16px;
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px 28px 24px;
  position: relative;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.4);
  animation: ica-slide-up 0.3s ease;
}

@keyframes ica-slide-up {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.ica-music-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: #f2f3f5;
  color: #0f2744;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.2s;
}

.ica-music-modal-close:hover {
  background: #e4e6ea;
  transform: rotate(90deg);
}

.ica-music-modal h2 {
  margin: 0 0 6px 0;
  font-size: 1.6rem;
  color: #0f2744;
  padding-right: 50px;
}

.ica-music-modal .ica-music-meta {
  margin: 0 0 18px 0;
  color: #6b7280;
  font-size: 0.92rem;
  font-style: italic;
}

.ica-music-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  border-bottom: 1px solid #e4e6ea;
  padding-bottom: 8px;
}

.ica-music-tab {
  flex: 1;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 600;
  color: #6b7280;
  transition: all 0.2s;
}

.ica-music-tab:hover {
  background: #f7f8fa;
  color: #0f2744;
}

.ica-music-tab.is-active {
  background: #0f2744;
  color: #ffffff;
  border-color: #0f2744;
}

.ica-music-modal audio {
  width: 100%;
  margin-bottom: 14px;
}

.ica-lyrics-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid #c4a052;
  color: #c4a052;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.92rem;
  transition: all 0.2s;
  margin-bottom: 12px;
}

.ica-lyrics-toggle:hover {
  background: #c4a052;
  color: #ffffff;
}

.ica-lyrics-body {
  background: #f7f8fa;
  border-radius: 8px;
  padding: 18px;
  margin-top: 8px;
  white-space: pre-line;
  font-size: 0.95rem;
  line-height: 1.6;
  color: #334155;
  display: none;
}

.ica-lyrics-body.is-open {
  display: block;
}

.ica-lyrics-body h3 {
  color: #c4a052;
  margin-top: 14px;
  margin-bottom: 4px;
  font-size: 0.95rem;
  font-weight: 700;
}

.ica-lyrics-body h3:first-child {
  margin-top: 0;
}

/* ===== PWA install prompt — gentle slide-in banner ===== */
.ica-pwa-install-banner {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(120%);
  background: #ffffff;
  border: 1px solid #e4e6ea;
  border-radius: 12px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.18);
  z-index: 9989;
  max-width: calc(100vw - 32px);
  transition: transform 0.4s ease;
}

.ica-pwa-install-banner.is-visible {
  transform: translateX(-50%) translateY(0);
}

.ica-pwa-install-banner img {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  flex-shrink: 0;
}

.ica-pwa-install-banner-text {
  flex: 1;
  min-width: 0;
}

.ica-pwa-install-banner-text strong {
  display: block;
  color: #0f2744;
  font-size: 0.95rem;
  line-height: 1.2;
  margin-bottom: 2px;
}

.ica-pwa-install-banner-text span {
  color: #6b7280;
  font-size: 0.82rem;
}

.ica-pwa-install-banner button {
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  flex-shrink: 0;
}

.ica-pwa-install-banner .ica-install-confirm {
  background: #c4a052;
  color: #ffffff;
}

.ica-pwa-install-banner .ica-install-dismiss {
  background: transparent;
  color: #6b7280;
  padding: 8px 10px;
}

@media (max-width: 480px) {
  .ica-pwa-install-banner {
    bottom: 90px; /* clear the corner stack on mobile */
  }
}
