/* ==========================================================================
   The Cricket News - Progressive Web App
   1) launch (splash) screen - colours come from Admin -> Site Settings -> App (PWA) & Splash
      (--ct-sp-dark / --ct-sp-light / --ct-sp-accent, printed by App\Libraries\Pwa::headTags)
   2) installed-app (standalone) safe-area polish
   3) install banner + "new version" toast
   ========================================================================== */

#ctPwaSplash {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  z-index: 2147483647;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--ct-sp-dark, #0d1627);
  background: radial-gradient(circle at 50% 34%, color-mix(in srgb, var(--ct-sp-dark, #0d1627) 78%, #6d8fc7) 0%, var(--ct-sp-dark, #0d1627) 52%, color-mix(in srgb, var(--ct-sp-dark, #0d1627) 55%, #000) 100%);
  color: #FFFFFF;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  opacity: 1;
  transform: scale(1);
  transition: opacity 0.38s cubic-bezier(0.22, 1, 0.36, 1), transform 0.38s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: auto;
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
  -webkit-transform: translateZ(0);
}

html[data-theme="light"] #ctPwaSplash {
  background: var(--ct-sp-light, #f4f6f9);
  background: radial-gradient(circle at 50% 34%, #ffffff 0%, var(--ct-sp-light, #f4f6f9) 60%, color-mix(in srgb, var(--ct-sp-light, #f4f6f9) 92%, #64748b) 100%);
  color: #0F172A;
}

html.ct-pwa-splash-on #ctPwaSplash {
  display: flex;
}

/* "Image" style: full-screen artwork */
.ct-sp-art { position: absolute; inset: 0; background-position: center; background-repeat: no-repeat; }
/* uploaded wordmark instead of the text title */
.ct-sp-logo { display: block; max-width: min(72vw, 320px); max-height: 56px; object-fit: contain; }
/* "Minimal" style: no motion */
.ct-sp-center.is-static .ct-sp-icon, .ct-sp-center.is-static .ct-sp-icon::after, .ct-sp-center.is-static .ct-sp-bar::after { animation: none; }
.ct-sp-center.is-static .ct-sp-bar::after { width: 100%; }

html.ct-pwa-splash-on,
html.ct-pwa-splash-on body {
  overflow: hidden !important;
}

#ctPwaSplash.is-leaving {
  opacity: 0;
  transform: scale(1.04);
  pointer-events: none;
}

.ct-sp-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: translateY(-18px);
}

.ct-sp-stage {
  position: relative;
  width: 112px;
  height: 112px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 22px;
}

.ct-sp-ring {
  position: absolute;
  inset: 6px;
  border-radius: 28px;
  border: 2px solid color-mix(in srgb, var(--ct-sp-accent, #e61e36) 55%, transparent);
  pointer-events: none;
  animation: ctSpPulse 1.65s cubic-bezier(0.16, 1, 0.3, 1) infinite;
}

.ct-sp-ring--2 {
  animation-delay: 0.55s;
  border-color: color-mix(in srgb, var(--ct-sp-accent, #e61e36) 35%, transparent);
}

.ct-sp-icon {
  position: relative;
  z-index: 2;
  width: 88px;
  height: 88px;
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.48), 0 0 0 1px rgba(255, 255, 255, 0.14);
  animation: ctSpFloat 1.8s ease-in-out infinite;
}

html[data-theme="light"] .ct-sp-icon {
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.18), 0 0 0 1px rgba(15, 23, 42, 0.08);
}

.ct-sp-icon img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.ct-sp-icon::after {
  content: "";
  position: absolute;
  inset: -40%;
  background: linear-gradient(115deg, transparent 35%, rgba(255, 255, 255, 0.34) 50%, transparent 65%);
  transform: translateX(-120%) rotate(12deg);
  animation: ctSpSheen 1.6s ease-in-out infinite;
  pointer-events: none;
}

.ct-sp-wordmark {
  display: flex;
  align-items: baseline;
  font-size: 30px;
  line-height: 1.05;
  letter-spacing: -0.025em;
  animation: ctSpFadeUp 0.5s cubic-bezier(0.22, 1, 0.36, 1) 0.12s both;
}

.ct-sp-serif {
  font-family: "Source Serif 4", Georgia, serif;
  font-style: italic;
  font-weight: 700;
}

.ct-sp-sans {
  font-family: Inter, system-ui, -apple-system, sans-serif;
  font-weight: 900;
  margin-left: 2px;
  letter-spacing: -0.03em;
}

.ct-sp-bar {
  width: 84px;
  height: 4px;
  border-radius: 999px;
  margin-top: 16px;
  background: color-mix(in srgb, var(--ct-sp-accent, #e61e36) 22%, transparent);
  overflow: hidden;
  position: relative;
  animation: ctSpFadeUp 0.5s cubic-bezier(0.22, 1, 0.36, 1) 0.2s both;
}

.ct-sp-bar::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 46%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--ct-sp-accent, #e61e36) 0%, color-mix(in srgb, var(--ct-sp-accent, #e61e36) 60%, #fff) 60%, #FBBF24 100%);
  animation: ctSpSlide 1.05s cubic-bezier(0.45, 0, 0.55, 1) infinite;
}

.ct-sp-dots {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 18px;
  animation: ctSpFadeUp 0.5s ease 0.26s both;
}

.ct-sp-dots i {
  display: block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ct-sp-accent, #e61e36);
  animation: ctSpBounce 0.9s ease-in-out infinite;
}

.ct-sp-dots i:nth-child(2) {
  animation-delay: 0.15s;
  background: color-mix(in srgb, var(--ct-sp-accent, #e61e36) 70%, #fff);
}

.ct-sp-dots i:nth-child(3) {
  animation-delay: 0.3s;
  background: #FBBF24;
}

.ct-sp-foot {
  position: absolute;
  bottom: calc(28px + env(safe-area-inset-bottom));
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  animation: ctSpFadeUp 0.55s ease 0.24s both;
}

.ct-sp-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ct-sp-accent, #e61e36) 16%, transparent);
  color: color-mix(in srgb, var(--ct-sp-accent, #e61e36) 70%, #fff);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

html[data-theme="light"] .ct-sp-pill {
  background: color-mix(in srgb, var(--ct-sp-accent, #e61e36) 10%, transparent);
  color: color-mix(in srgb, var(--ct-sp-accent, #e61e36) 85%, #000);
}

.ct-sp-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ct-sp-accent, #e61e36);
  animation: ctSpBlink 1s ease-in-out infinite;
}

.ct-sp-sub {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.54);
}

html[data-theme="light"] .ct-sp-sub {
  color: rgba(15, 23, 42, 0.52);
}

@keyframes ctSpPulse {
  0%   { transform: scale(0.92); opacity: 0.78; }
  75%  { transform: scale(1.48); opacity: 0; }
  100% { transform: scale(1.48); opacity: 0; }
}

@keyframes ctSpFloat {
  0%, 100% { transform: translateY(0) scale(1); }
  50%      { transform: translateY(-5px) scale(1.035); }
}

@keyframes ctSpSheen {
  0%   { transform: translateX(-130%) rotate(12deg); }
  60%  { transform: translateX(130%) rotate(12deg); }
  100% { transform: translateX(130%) rotate(12deg); }
}

@keyframes ctSpFadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes ctSpSlide {
  0%   { transform: translateX(-110%); }
  100% { transform: translateX(225%); }
}

@keyframes ctSpBounce {
  0%, 80%, 100% { transform: translateY(0) scale(0.85); opacity: 0.55; }
  40%           { transform: translateY(-7px) scale(1.15); opacity: 1; }
}

@keyframes ctSpBlink {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.35; transform: scale(0.8); }
}

@media all and (display-mode: standalone) {
  html, body {
    overscroll-behavior-y: contain;
    -webkit-tap-highlight-color: transparent;
  }
  .ux-header {
    padding-top: env(safe-area-inset-top);
  }
  .mtab {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

.ct-pwa-banner {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(70px + env(safe-area-inset-bottom));
  max-width: 420px;
  margin: 0 auto;
  z-index: 99990;
  background: #0F172A;
  color: #F8FAFC;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  padding: 14px 16px;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.36);
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-family: Inter, system-ui, -apple-system, sans-serif;
  transform: translateY(18px);
  opacity: 0;
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.28s ease;
}

.ct-pwa-banner.is-visible {
  transform: translateY(0);
  opacity: 1;
}

html[data-theme="light"] .ct-pwa-banner {
  background: #FFFFFF;
  color: #0F172A;
  border-color: rgba(15, 23, 42, 0.10);
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.16);
}

.ct-pwa-row { display: flex; align-items: center; gap: 12px; }
.ct-pwa-ic { width: 46px; height: 46px; border-radius: 12px; overflow: hidden; flex-shrink: 0; box-shadow: 0 6px 16px rgba(0, 0, 0, 0.28); }
.ct-pwa-ic img { width: 100%; height: 100%; display: block; }
.ct-pwa-copy { flex: 1; min-width: 0; }
.ct-pwa-title { margin: 0 0 2px; font-size: 14.5px; font-weight: 800; line-height: 1.25; }
.ct-pwa-desc { margin: 0; font-size: 12.5px; line-height: 1.35; color: #94A3B8; }
html[data-theme="light"] .ct-pwa-desc { color: #5B6778; }
.ct-pwa-close { appearance: none; border: 0; background: transparent; color: inherit; opacity: 0.55; width: 28px; height: 28px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; font-size: 18px; line-height: 1; flex-shrink: 0; }
.ct-pwa-close:hover { opacity: 1; background: rgba(148, 163, 184, 0.14); }
.ct-pwa-ios-steps { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 10px; background: rgba(148, 163, 184, 0.12); font-size: 12.5px; line-height: 1.4; }
.ct-pwa-ios-steps svg { width: 18px; height: 18px; flex-shrink: 0; color: #38BDF8; }

.ct-pwa-install { appearance: none; border: 0; border-radius: 999px; padding: 8px 16px; background: var(--ct-sp-accent, #e61e36); color: var(--ct-sp-on, #fff); font: 700 13px/1 Inter, system-ui, sans-serif; cursor: pointer; flex-shrink: 0; }
.ct-pwa-install:hover { filter: brightness(1.08); }

.ct-pwa-update { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 99991; display: flex; align-items: center; gap: 12px;
  padding: 10px 12px 10px 16px; border-radius: 999px; background: #0f172a; color: #f8fafc; font: 600 13px/1.2 Inter, system-ui, sans-serif;
  box-shadow: 0 14px 36px rgba(0, 0, 0, .32); transform: translate(-50%, 16px); opacity: 0; transition: transform .25s ease, opacity .25s ease; }
.ct-pwa-update.is-visible { transform: translate(-50%, 0); opacity: 1; }
.ct-pwa-update button { appearance: none; border: 0; border-radius: 999px; padding: 7px 14px; background: var(--ct-sp-accent, #e61e36); color: var(--ct-sp-on, #fff); font-weight: 700; font-size: 12.5px; line-height: 1; font-family: inherit; cursor: pointer; }

@media (prefers-reduced-motion: reduce) {
  #ctPwaSplash, .ct-sp-ring, .ct-sp-icon, .ct-sp-icon::after, .ct-sp-wordmark,
  .ct-sp-bar, .ct-sp-bar::after, .ct-sp-dots, .ct-sp-dots i, .ct-sp-dot, .ct-pwa-banner, .ct-pwa-update {
    animation: none !important;
    transition: none !important;
  }
}
