/* Mobile scroll & pull-down loading effects */

@media (max-width: 768px) {
  .mobile-page {
    overflow-x: hidden;
    overflow-y: visible;
    --pull-offset: 0px;
    --scroll-ratio: 0;
  }

  /* ── Top scroll progress ── */
  .mobile-scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 120;
    height: 3px;
    pointer-events: none;
    background: rgba(84, 255, 100, 0.08);
    opacity: 0;
    transition: opacity 0.3s ease;
  }

  .mobile-page.is-scrolling .mobile-scroll-progress {
    opacity: 1;
  }

  .mobile-scroll-progress i {
    display: block;
    position: relative;
    height: 100%;
    width: 100%;
    transform-origin: left center;
    transform: scaleX(var(--scroll-ratio, 0));
    background: linear-gradient(90deg, #12ef63, #54ff64, #caff5a, #54ff64);
    box-shadow: 0 0 0.65rem rgba(84, 255, 100, 0.55);
    transition: transform 0.12s linear;
  }

  .mobile-scroll-progress i::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    width: 2.5rem;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.75));
    animation: mobileProgressSpark 1.6s ease-in-out infinite;
  }

  /* ── Pull-down hint ── */
  .mobile-pull-hint {
    position: fixed;
    top: 0;
    left: 50%;
    z-index: 110;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.45rem;
    padding-top: 0.5rem;
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%, calc(-120% + var(--pull-offset, 0px)));
    transition: opacity 0.25s ease;
  }

  .mobile-page.is-pulling .mobile-pull-hint,
  .mobile-page.is-refreshing .mobile-pull-hint {
    opacity: 1;
  }

  .mobile-pull-hint__ring {
    width: 1.65rem;
    height: 1.65rem;
    border: 2px solid rgba(84, 255, 100, 0.25);
    border-top-color: #54ff64;
    border-radius: 50%;
    transition: transform 0.2s ease;
  }

  .mobile-page.is-pulling .mobile-pull-hint__ring {
    transform: rotate(calc(var(--pull-offset, 0px) * 2deg));
  }

  .mobile-page.is-refreshing .mobile-pull-hint__ring {
    animation: mobilePullSpin 0.75s linear infinite;
  }

  .mobile-page.is-pull-ready .mobile-pull-hint__ring {
    border-color: rgba(202, 255, 90, 0.35);
    border-top-color: #caff5a;
    box-shadow: 0 0 0.85rem rgba(84, 255, 100, 0.35);
  }

  .mobile-pull-hint span {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: rgba(182, 255, 187, 0.88);
    white-space: nowrap;
  }

  .mobile-page.is-pull-ready .mobile-pull-hint span {
    color: #caff5a;
  }

  /* ── Scroll glow trail ── */
  .mobile-scroll-glow {
    position: fixed;
    left: 50%;
    bottom: -4rem;
    z-index: 5;
    width: 14rem;
    height: 8rem;
    pointer-events: none;
    opacity: 0;
    transform: translateX(-50%);
    background: radial-gradient(circle, rgba(84, 255, 100, 0.14), transparent 70%);
    transition: opacity 0.4s ease, bottom 0.4s ease;
  }

  .mobile-page.is-scrolling .mobile-scroll-glow {
    opacity: 1;
    bottom: -2rem;
    animation: mobileGlowPulse 2.4s ease-in-out infinite;
  }

  /* ── Section scroll reveal (enhanced) ── */
  .mobile-section,
  .mobile-stats,
  .mobile-download,
  .mobile-footer {
    position: relative;
  }

  .mobile-section::before,
  .mobile-stats::before,
  .mobile-download::before {
    content: "";
    position: absolute;
    left: 1rem;
    right: 1rem;
    top: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(84, 255, 100, 0.35), transparent);
    opacity: 0;
    transform: scaleX(0.4);
    transition:
      opacity 0.55s ease,
      transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
  }

  .mobile-section.motion-in::before,
  .mobile-stats.motion-in::before,
  .mobile-download.motion-in::before {
    opacity: 1;
    transform: scaleX(1);
  }

  .mobile-feature-list article[data-motion],
  .mobile-steps li[data-motion],
  .mobile-stats div[data-motion] {
    animation: none !important;
    opacity: 0;
    transform: translateY(1.25rem);
    filter: blur(4px);
    transition:
      opacity 0.65s cubic-bezier(0.22, 1, 0.36, 1),
      transform 0.65s cubic-bezier(0.22, 1, 0.36, 1),
      filter 0.65s ease,
      box-shadow 0.35s ease;
  }

  .mobile-feature-list article[data-motion].motion-in,
  .mobile-steps li[data-motion].motion-in,
  .mobile-stats div[data-motion].motion-in {
    opacity: 1;
    transform: none;
    filter: blur(0);
    box-shadow: inset 0 0 0 1px rgba(125, 255, 139, 0.06), 0 1rem 2rem rgba(0, 0, 0, 0.18);
  }

  .mobile-section[data-motion].motion-in {
    animation: mobileSectionPop 0.72s cubic-bezier(0.22, 1, 0.36, 1) both;
  }

  .mobile-section[data-motion].motion-in .mobile-section-label {
    animation: mobileLabelFlash 0.8s ease both;
  }

  /* ── Bottom loading sentinel ── */
  .mobile-scroll-sentinel {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 1.5rem 0 2rem;
    opacity: 0;
    transform: translateY(0.5rem);
    transition:
      opacity 0.45s ease,
      transform 0.45s ease;
  }

  .mobile-scroll-sentinel.is-visible {
    opacity: 1;
    transform: none;
  }

  .mobile-scroll-sentinel__dot {
    width: 0.42rem;
    height: 0.42rem;
    border-radius: 50%;
    background: rgba(84, 255, 100, 0.35);
    animation: mobileDotBounce 1.1s ease-in-out infinite;
  }

  .mobile-scroll-sentinel__dot:nth-child(2) {
    animation-delay: 0.15s;
  }

  .mobile-scroll-sentinel__dot:nth-child(3) {
    animation-delay: 0.3s;
  }

  .mobile-scroll-sentinel__text {
    margin-left: 0.35rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: rgba(182, 255, 187, 0.65);
    letter-spacing: 0.08em;
  }

  /* Hero parallax on scroll */
  .mobile-page.is-scrolling .mobile-hero {
    background-position: 68% calc(0px + var(--scroll-ratio, 0) * -2rem), center;
    transition: background-position 0.1s linear;
  }

  /* Elastic bounce when pull released */
  .mobile-page.is-refreshing .mobile-hero {
    animation: mobileElasticBounce 0.55s cubic-bezier(0.22, 1, 0.36, 1);
  }
}

@keyframes mobileProgressSpark {
  0%, 100% { opacity: 0; transform: translateX(-100%); }
  50% { opacity: 1; transform: translateX(0); }
}

@keyframes mobilePullSpin {
  to { transform: rotate(360deg); }
}

@keyframes mobileGlowPulse {
  0%, 100% { opacity: 0.45; transform: translateX(-50%) scale(1); }
  50% { opacity: 0.85; transform: translateX(-50%) scale(1.08); }
}

@keyframes mobileSectionPop {
  from {
    opacity: 0;
    transform: translateY(1.5rem);
    filter: blur(6px);
  }
  60% {
    opacity: 1;
    transform: translateY(-0.15rem);
    filter: blur(0);
  }
  to {
    opacity: 1;
    transform: none;
    filter: none;
  }
}

@keyframes mobileLabelFlash {
  0% {
    box-shadow: 0 0 0 rgba(84, 255, 100, 0);
    border-color: rgba(106, 255, 124, 0.5);
  }
  40% {
    box-shadow: 0 0 1.2rem rgba(84, 255, 100, 0.35);
    border-color: rgba(202, 255, 90, 0.85);
  }
  100% {
    box-shadow: 0 0 0.55rem rgba(84, 255, 100, 0.12);
    border-color: rgba(106, 255, 124, 0.5);
  }
}

@keyframes mobileDotBounce {
  0%, 80%, 100% {
    transform: translateY(0);
    opacity: 0.45;
  }
  40% {
    transform: translateY(-0.35rem);
    opacity: 1;
    background: #54ff64;
  }
}

@keyframes mobileElasticBounce {
  0% { transform: translateY(0); }
  35% { transform: translateY(0.35rem); }
  70% { transform: translateY(-0.12rem); }
  100% { transform: translateY(0); }
}

@media (max-width: 768px) and (prefers-reduced-motion: reduce) {
  .mobile-scroll-progress,
  .mobile-pull-hint,
  .mobile-scroll-glow,
  .mobile-scroll-sentinel,
  .mobile-feature-list article[data-motion],
  .mobile-steps li[data-motion],
  .mobile-stats div[data-motion],
  .mobile-section[data-motion] {
    animation: none !important;
    transition: none !important;
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
  }
}
