/* Pull-to-refresh (narrow touch PWA only) */

html.pwa-mode {
  /* Let our transform handle top overscroll instead of native 1:1 rubber-band. */
  overscroll-behavior-y: none;
}

#main-content {
  position: relative;
  overflow: visible;
}

.pull-to-refresh-indicator {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0.5rem;
  min-height: 3.5rem;
  padding: 0 var(--space-6) 0.35rem;
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
}

.pull-to-refresh-bar {
  width: min(8rem, 56vw);
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  flex-shrink: 0;
}

.pull-to-refresh-bar__fill {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: var(--accent-primary);
  transition: background-color 0.15s ease;
}

.pull-to-refresh-indicator--ready .pull-to-refresh-bar__fill {
  background: var(--success);
}

.pull-to-refresh-indicator--refreshing .pull-to-refresh-bar__fill {
  background: var(--success);
}

.pull-to-refresh-spinner {
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.12s ease, visibility 0.12s ease;
}

.pull-to-refresh-spinner__ring {
  display: block;
  width: 100%;
  height: 100%;
  border: 2px solid rgba(16, 185, 129, 0.22);
  border-top-color: var(--success);
  border-radius: 50%;
}

.pull-to-refresh-indicator--refreshing .pull-to-refresh-spinner {
  opacity: 1;
  visibility: visible;
}

.pull-to-refresh-indicator--refreshing .pull-to-refresh-spinner__ring {
  animation: pull-to-refresh-spin 0.7s linear infinite;
}

@keyframes pull-to-refresh-spin {
  to {
    transform: rotate(360deg);
  }
}

.pull-to-refresh-surface {
  position: relative;
  touch-action: pan-y;
  /* Avoid will-change: transform here — it creates a stacking context that traps
     in-page Bootstrap modals (e.g. Solitaire "New game") below the body backdrop. */
}

.pull-to-refresh-surface--spring {
  transition: transform 0.28s cubic-bezier(0.25, 0.8, 0.25, 1);
}

html.pwa-mode .pull-to-refresh-indicator {
  display: flex;
}

html:not(.pwa-mode) .pull-to-refresh-indicator {
  display: none !important;
}

@media (min-width: 992px) {
  html.pwa-mode .pull-to-refresh-indicator {
    display: none !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pull-to-refresh-surface--spring {
    transition: none;
  }

  .pull-to-refresh-indicator--refreshing .pull-to-refresh-spinner__ring {
    animation: none;
    border-top-color: var(--success);
    border-right-color: var(--success);
  }
}
