/* Shared motion layer for Opti. Noticeable, clean, and deliberately compositor-safe. */

@keyframes opti-heartbeat {
  0%, 54%, 100% {
    transform: scale(1);
    box-shadow:
      inset 0 0 34px rgba(141, 255, 103, 0.045),
      0 0 80px rgba(103, 255, 66, 0.14);
  }
  60% {
    transform: scale(1.24);
    box-shadow:
      inset 0 0 38px rgba(141, 255, 103, 0.12),
      0 0 48px rgba(141, 255, 103, 0.38),
      0 0 105px rgba(103, 255, 66, 0.2);
  }
  65% {
    transform: scale(0.97);
    box-shadow:
      inset 0 0 34px rgba(141, 255, 103, 0.055),
      0 0 70px rgba(103, 255, 66, 0.16);
  }
  72% {
    transform: scale(1.12);
    box-shadow:
      inset 0 0 36px rgba(141, 255, 103, 0.09),
      0 0 44px rgba(141, 255, 103, 0.3),
      0 0 90px rgba(103, 255, 66, 0.18);
  }
  79% {
    transform: scale(1);
    box-shadow:
      inset 0 0 34px rgba(141, 255, 103, 0.045),
      0 0 80px rgba(103, 255, 66, 0.14);
  }
}

@keyframes opti-heartbeat-reduced {
  0%, 58%, 100% {
    transform: scale(1);
    box-shadow:
      inset 0 0 34px rgba(141, 255, 103, 0.045),
      0 0 80px rgba(103, 255, 66, 0.14);
  }
  66% {
    transform: scale(1.1);
    box-shadow:
      inset 0 0 36px rgba(141, 255, 103, 0.09),
      0 0 52px rgba(141, 255, 103, 0.28),
      0 0 92px rgba(103, 255, 66, 0.18);
  }
  73% {
    transform: scale(0.99);
  }
  80% {
    transform: scale(1.05);
  }
  87% {
    transform: scale(1);
  }
}

@keyframes opti-grid-drift {
  from { background-position: 0 0, 0 0; }
  to { background-position: 52px 26px, 26px 52px; }
}

@keyframes opti-grid-breathe {
  0%, 100% { opacity: 0.48; }
  50% { opacity: 0.68; }
}

@keyframes opti-store-grid-drift {
  from { background-position: 0 0, 0 0; }
  to { background-position: 54px 27px, 27px 54px; }
}

@keyframes opti-status-pulse {
  0%, 100% { opacity: 0.7; transform: scale(0.94); }
  50% { opacity: 1; transform: scale(1.13); }
}

/* Stronger scroll reveal: short entrance window, more travel, solid through the middle. */
@keyframes opti-scroll-reveal {
  0% {
    opacity: 0;
    translate: 0 46px;
    scale: 0.975;
  }
  10%, 90% {
    opacity: 1;
    translate: 0 0;
    scale: 1;
  }
  100% {
    opacity: 0;
    translate: 0 -46px;
    scale: 0.975;
  }
}

@keyframes opti-scroll-fade {
  0%, 100% { opacity: 0; }
  7%, 93% { opacity: 1; }
}

/* Two independent, tiny but bright shooting stars in the hero background. */
@keyframes opti-shooting-star-a {
  0%, 10% {
    opacity: 0;
    transform: translate3d(-90px, -42px, 0) rotate(-23deg) scaleX(0.72);
  }
  12% {
    opacity: 1;
  }
  23% {
    opacity: 1;
    transform: translate3d(390px, 165px, 0) rotate(-23deg) scaleX(1);
  }
  26%, 100% {
    opacity: 0;
    transform: translate3d(465px, 198px, 0) rotate(-23deg) scaleX(0.92);
  }
}

@keyframes opti-shooting-star-b {
  0%, 37% {
    opacity: 0;
    transform: translate3d(-65px, -32px, 0) rotate(-21deg) scaleX(0.76);
  }
  39% {
    opacity: 1;
  }
  49% {
    opacity: 1;
    transform: translate3d(350px, 142px, 0) rotate(-21deg) scaleX(1);
  }
  52%, 100% {
    opacity: 0;
    transform: translate3d(420px, 172px, 0) rotate(-21deg) scaleX(0.92);
  }
}

@keyframes opti-shooting-star-reduced-a {
  0%, 14% {
    opacity: 0;
    transform: translate3d(-55px, -22px, 0) rotate(-22deg) scaleX(0.78);
  }
  16% {
    opacity: 1;
  }
  24% {
    opacity: 1;
    transform: translate3d(185px, 76px, 0) rotate(-22deg) scaleX(1);
  }
  27%, 100% {
    opacity: 0;
    transform: translate3d(225px, 92px, 0) rotate(-22deg) scaleX(0.9);
  }
}

@keyframes opti-shooting-star-reduced-b {
  0%, 51% {
    opacity: 0;
    transform: translate3d(-45px, -18px, 0) rotate(-20deg) scaleX(0.8);
  }
  53% {
    opacity: 1;
  }
  60% {
    opacity: 1;
    transform: translate3d(165px, 66px, 0) rotate(-20deg) scaleX(1);
  }
  63%, 100% {
    opacity: 0;
    transform: translate3d(205px, 82px, 0) rotate(-20deg) scaleX(0.9);
  }
}

/* The exact large Opti tile above “Meet Opti.” */
.hero-logo {
  transform-origin: center;
  animation: opti-heartbeat 2.45s ease-in-out 0.35s infinite;
}

/* Keep the inner mark locked to the tile so the whole logo reads as one heartbeat. */
.hero-logo svg {
  transform: none !important;
  animation: none !important;
}

.hero-logo::after {
  display: none !important;
  animation: none !important;
}

/* Ambient background motion: small, steady changes only. */
.hero::before {
  animation:
    opti-grid-drift 20s linear infinite,
    opti-grid-breathe 7s ease-in-out infinite;
}

.store::before {
  animation: opti-store-grid-drift 24s linear infinite;
}

.download-grid {
  animation: opti-grid-drift 22s linear infinite;
}

/* The existing particle layer doubles as a clipped shooting-star canvas. */
.particles {
  overflow: hidden;
}

.particles::before,
.particles::after {
  position: absolute;
  z-index: 1;
  width: 66px;
  height: 8px;
  content: "";
  pointer-events: none;
  border-radius: 999px;
  opacity: 0;
  transform-origin: 100% 50%;
  background:
    radial-gradient(circle at 100% 50%, rgba(235, 255, 227, 1) 0 1.4px, rgba(184, 255, 159, 1) 1.5px 2.5px, rgba(141, 255, 103, 0.42) 3px, transparent 5.5px),
    linear-gradient(90deg, transparent 0%, rgba(141, 255, 103, 0.08) 18%, rgba(141, 255, 103, 0.38) 55%, rgba(141, 255, 103, 0.9) 84%, rgba(184, 255, 159, 1) 100%) center / 100% 2px no-repeat;
  filter:
    drop-shadow(0 0 4px rgba(141, 255, 103, 0.9))
    drop-shadow(0 0 10px rgba(111, 255, 76, 0.65));
}

.particles::before {
  top: 16%;
  left: 8%;
  animation: opti-shooting-star-a 6.4s linear 0.8s infinite;
}

.particles::after {
  top: 30%;
  left: 54%;
  width: 56px;
  animation: opti-shooting-star-b 8.1s linear 2.2s infinite;
}

/* Explicitly keep the large blurred/ring layers static to avoid Chromium compositor flashing. */
.hero::after,
.voxel-layer,
.showcase::before,
.store-panel::before,
.store-panel::after,
.download-glow {
  animation: none !important;
  will-change: auto !important;
}

.reveal,
.nav-download,
.button-primary,
.button-secondary,
.button-ghost,
.compact-button,
.launcher-window,
.store-panel,
.changelog-card,
.support-card,
.release-card,
.verify-card,
.scan-preview-card,
.help-card {
  will-change: auto !important;
}

/* Buttons move as a single object. Text and icons never animate separately. */
.nav-download,
.button-primary,
.button-secondary,
.button-ghost,
.compact-button {
  transform-origin: center;
  transition:
    transform 220ms cubic-bezier(.2, .75, .25, 1),
    background 200ms ease,
    border-color 200ms ease,
    box-shadow 220ms ease !important;
}

.nav-download:hover,
.button-primary:hover {
  transform: translateY(-3px) scale(1.018);
  box-shadow: 0 16px 40px rgba(110, 255, 73, 0.25);
}

.button-secondary:hover,
.button-ghost:hover,
.compact-button:hover {
  transform: translateY(-3px) scale(1.012);
}

.nav-download:active,
.button-primary:active,
.button-secondary:active,
.button-ghost:active,
.compact-button:active {
  transform: translateY(-1px) scale(0.995);
  transition-duration: 90ms !important;
}

.button-icon,
.nav-download:hover .button-icon,
.button-primary:hover .button-icon,
.button-secondary:hover .button-icon,
.button-ghost:hover .button-icon {
  flex: 0 0 auto;
  transform: none !important;
  transition: none !important;
  animation: none !important;
}

.brand-mark::before,
.brand-mark::after,
.feature-icon,
.mini-check,
.launcher-side-icon,
.launcher-mini-card,
.store-icon,
.verify-icon,
.windows-mark {
  transition: transform 230ms cubic-bezier(.2, .75, .25, 1), border-color 230ms ease, background 230ms ease, box-shadow 230ms ease;
}

.brand:hover .brand-mark::before {
  transform: rotate(45deg) scale(1.1);
}

.version-dot,
.store-status-dot,
.release-chip > span {
  transform-origin: center;
  animation: opti-status-pulse 2.6s ease-in-out infinite;
}

.trust-item {
  transition: background 220ms ease, color 220ms ease, transform 220ms cubic-bezier(.2, .75, .25, 1);
}

.trust-item:hover {
  transform: translateY(-3px);
  background: rgba(141, 255, 103, 0.032);
}

.trust-item:hover svg {
  filter: drop-shadow(0 0 9px rgba(141, 255, 103, 0.32));
}

.feature-card:hover .feature-icon {
  transform: translateY(-2px) scale(1.06);
  border-color: rgba(141, 255, 103, 0.3);
  box-shadow: 0 12px 30px rgba(111, 255, 76, 0.09);
}

.mini-list-item:hover .mini-check {
  transform: scale(1.07);
  border-color: rgba(141, 255, 103, 0.32);
  background: rgba(141, 255, 103, 0.09);
}

.launcher-window {
  transition: transform 280ms cubic-bezier(.2, .75, .25, 1), border-color 240ms ease, box-shadow 280ms ease;
}

.launcher-window:hover {
  transform: translateY(-4px);
  border-color: rgba(141, 255, 103, 0.18);
  box-shadow: 0 34px 95px rgba(0, 0, 0, 0.48), 0 0 0 1px rgba(141, 255, 103, 0.05);
}

.launcher-mini-card:hover {
  transform: translateY(-2px);
  border-color: rgba(141, 255, 103, 0.15);
  background: rgba(141, 255, 103, 0.04);
}

.store-panel,
.changelog-card,
.support-card {
  transition: transform 280ms cubic-bezier(.2, .75, .25, 1), border-color 240ms ease, box-shadow 280ms ease;
}

.store-panel:hover,
.support-card:hover {
  transform: translateY(-4px);
  border-color: rgba(141, 255, 103, 0.21);
}

.store-panel:hover .store-icon {
  transform: scale(1.06);
  box-shadow: 0 0 50px rgba(111, 255, 76, 0.12);
}

.changelog-card:hover {
  transform: translateY(-2px);
  border-color: rgba(141, 255, 103, 0.16);
}

.change-item {
  transition: background 220ms ease, padding-left 220ms cubic-bezier(.2, .75, .25, 1);
}

.change-item:hover {
  padding-left: 5px;
  background: linear-gradient(90deg, rgba(141, 255, 103, 0.035), transparent 72%);
}

.footer-column a {
  transition: color 180ms ease, transform 180ms ease;
}

.footer-column a:hover {
  transform: translateX(3px);
}

.release-card,
.verify-card,
.scan-preview-card,
.help-card {
  transition: transform 260ms cubic-bezier(.2, .75, .25, 1), border-color 230ms ease, box-shadow 260ms ease, background 230ms ease;
}

.release-card:hover,
.verify-card:hover,
.scan-preview-card:hover,
.help-card:hover {
  transform: translateY(-4px);
  border-color: rgba(141, 255, 103, 0.2);
  box-shadow: 0 22px 58px rgba(0, 0, 0, 0.16);
}

.release-card:hover .windows-mark,
.verify-card:hover .verify-icon {
  transform: scale(1.06);
  border-color: rgba(141, 255, 103, 0.3);
  background: rgba(141, 255, 103, 0.08);
}

.text-link span {
  display: inline-block;
  transition: transform 180ms ease;
}

.text-link:hover span {
  transform: translate(2px, -2px);
}

.scan-image-link {
  transition: border-color 220ms ease, box-shadow 220ms ease;
}

.scan-image-link:hover {
  border-color: rgba(141, 255, 103, 0.18);
  box-shadow: 0 20px 55px rgba(0, 0, 0, 0.22);
}

/*
  Bidirectional scroll reveal.
  The element now arrives more decisively near the viewport edge, stays solid
  through almost the entire viewport, then exits with the same motion reversed.
*/
@supports (animation-timeline: view()) {
  .reveal,
  .trust-item,
  .footer-brand,
  .footer-column {
    transform: none !important;
    transition-delay: 0ms !important;
    animation-name: opti-scroll-reveal;
    animation-duration: 1ms;
    animation-fill-mode: both;
    animation-timing-function: linear;
    animation-timeline: view();
    animation-range: entry 0% exit 100%;
  }

  .reveal.visible {
    transform: none !important;
  }

  .trust-item:nth-child(2),
  .feature-card:nth-child(2),
  .footer-column:nth-child(2) {
    animation-range: entry 2% exit 98%;
  }

  .trust-item:nth-child(3),
  .feature-card:nth-child(3) {
    animation-range: entry 4% exit 96%;
  }

  .trust-item:nth-child(4) {
    animation-range: entry 6% exit 94%;
  }
}

@media (max-width: 700px) {
  .launcher-window:hover,
  .store-panel:hover,
  .support-card:hover,
  .release-card:hover,
  .verify-card:hover,
  .scan-preview-card:hover,
  .help-card:hover {
    transform: none;
  }
}

/*
  base.css reduces motion globally for devices that request it. Keep a gentler
  heartbeat and a high-contrast fade-only viewport reveal instead of movement.
  Shooting stars still run here, but less often and over a shorter distance.
*/
@media (prefers-reduced-motion: reduce) {
  .hero-logo {
    animation: opti-heartbeat-reduced 3s ease-in-out 0.35s infinite !important;
  }

  .version-dot,
  .store-status-dot,
  .release-chip > span {
    animation: opti-status-pulse 3.2s ease-in-out infinite !important;
  }

  .nav-download,
  .button-primary,
  .button-secondary,
  .button-ghost,
  .compact-button {
    transition:
      transform 140ms ease,
      background 140ms ease,
      border-color 140ms ease,
      box-shadow 140ms ease !important;
  }

  .hero::before,
  .store::before,
  .download-grid {
    animation: none !important;
  }

  .particles::before {
    animation: opti-shooting-star-reduced-a 9.5s linear 1.2s infinite !important;
  }

  .particles::after {
    animation: opti-shooting-star-reduced-b 12s linear 3.4s infinite !important;
  }

  @supports (animation-timeline: view()) {
    .reveal,
    .trust-item,
    .footer-brand,
    .footer-column {
      opacity: 1;
      transform: none !important;
      translate: none;
      scale: 1;
      animation-name: opti-scroll-fade !important;
      animation-duration: 1ms !important;
      animation-iteration-count: 1 !important;
      animation-fill-mode: both !important;
      animation-timing-function: linear !important;
      animation-timeline: view() !important;
      animation-range: entry 0% exit 100% !important;
      transition: none !important;
    }
  }
}
