/* ============================================================
   Motion pass — Dark Matter
   Restrained on purpose: things arrive, lean and settle. Nothing
   loops in the corner of your eye. Every rule here is inert under
   prefers-reduced-motion (see the block at the bottom).
   ============================================================ */

/* -- display headings rise out of a clipped line -------------------------- */
.line {
  display: block;
  overflow: hidden;
}

.line-inner {
  display: block;
  transform: translateY(105%);
  transition:
    transform 1s cubic-bezier(0.22, 0.7, 0.2, 1),
    opacity 1s ease;
  opacity: 0;
  /* each line follows the one above it */
  transition-delay: calc(var(--i, 0) * 90ms);
}

.in-view .line-inner {
  transform: translateY(0);
  opacity: 1;
}

/* The hero title keeps its own markup (its styling depends on the direct-child
   selector), so it rises via CSS rather than being re-wrapped. */
.hero h1 > span {
  animation: hero-rise 1.1s cubic-bezier(0.22, 0.7, 0.2, 1) both;
}

.hero h1 > span:nth-child(2) {
  animation-delay: 0.12s;
}

.hero-description,
.hero-buttons,
.hero-bottom {
  animation: hero-rise 1.1s cubic-bezier(0.22, 0.7, 0.2, 1) both;
}

.hero-description {
  animation-delay: 0.26s;
}
.hero-buttons {
  animation-delay: 0.36s;
}
.hero-bottom {
  animation-delay: 0.46s;
}

@keyframes hero-rise {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
}

@keyframes line-rise {
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* -- pricing passes lean toward the cursor -------------------------------- */
.pricing-pass {
  transform: perspective(1100px) rotateX(var(--tilt-x, 0deg))
    rotateY(var(--tilt-y, 0deg));
  transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(0.22, 0.7, 0.2, 1);
  will-change: transform;
}

/* A soft highlight tracks the pointer across the card face. */
.pricing-pass::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(
    340px circle at var(--glow-x, 50%) var(--glow-y, 50%),
    rgba(255, 110, 140, 0.13),
    transparent 62%
  );
  transition: opacity 0.45s ease;
}

.pricing-pass:hover::after {
  opacity: 1;
}

/* -- primary buttons catch a single pass of light on hover ---------------- */
.button-primary,
.checkout-visit,
.directory-store-link {
  position: relative;
  overflow: hidden;
}

.button-primary::after,
.checkout-visit::after,
.directory-store-link::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -60%;
  width: 40%;
  pointer-events: none;
  transform: skewX(-18deg);
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.16),
    transparent
  );
  transition: left 0.75s cubic-bezier(0.22, 0.7, 0.2, 1);
}

.button-primary:hover::after,
.checkout-visit:hover::after,
.directory-store-link:hover::after {
  left: 130%;
}

/* -- the live dot actually breathes --------------------------------------- */
.status-dot {
  animation: dot-pulse 3.4s ease-in-out infinite;
}

@keyframes dot-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

/* -- checkout rows stagger in when the dialog opens ----------------------- */
.purchase-dialog[open] .checkout-reseller {
  animation: row-in 0.55s cubic-bezier(0.22, 0.7, 0.2, 1) both;
}

.purchase-dialog[open] .checkout-reseller:nth-child(2) {
  animation-delay: 0.07s;
}
.purchase-dialog[open] .checkout-reseller:nth-child(3) {
  animation-delay: 0.14s;
}
.purchase-dialog[open] .checkout-reseller:nth-child(n + 4) {
  animation-delay: 0.2s;
}

@keyframes row-in {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
}

/* -- stat figures hold their width while counting ------------------------- */
.stats strong {
  font-variant-numeric: tabular-nums;
}

.pricing-pass-price [data-price-value] {
  font-variant-numeric: tabular-nums;
}

/* -- nav links get a travelling underline --------------------------------- */
.nav-links a {
  position: relative;
}

.nav-links a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -6px;
  height: 1px;
  background: #e33462;
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.45s cubic-bezier(0.22, 0.7, 0.2, 1);
}

.nav-links a:hover::after,
.nav-links a.active::after {
  transform: scaleX(1);
  transform-origin: left;
}

/* ========================================================================
   Reduced motion: everything lands in its final state immediately.
   ======================================================================== */
@media (prefers-reduced-motion: reduce) {
  .line-inner,
  .hero h1 > span,
  .hero-description,
  .hero-buttons,
  .hero-bottom {
    transform: none;
    opacity: 1;
    animation: none;
    transition: none;
  }

  .pricing-pass {
    transform: none;
    transition: none;
  }

  .pricing-pass::after,
  .button-primary::after,
  .checkout-visit::after,
  .directory-store-link::after {
    display: none;
  }

  .status-dot {
    animation: none;
  }

  .purchase-dialog[open] .checkout-reseller {
    animation: none;
  }

  .nav-links a::after {
    transition: none;
  }
}

/* ============================================================
   Atmosphere
   ============================================================ */

/* -- film grain -----------------------------------------------------------
   Inline SVG turbulence: no extra request, no image to cache-bust. Sits above
   everything except dialogs, never intercepts a click. */
.film-grain {
  position: fixed;
  /* inset:0, not -50%: there is no motion on this layer, so covering four
     viewports only multiplied the repaint area. */
  inset: 0;
  z-index: 9;
  pointer-events: none;
  opacity: 0.032;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='3' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='160' height='160' filter='url(%23n)'/></svg>");
  background-size: 160px 160px;
}

/* Dialogs sit in the top layer, so grain must not wash over their content. */
dialog[open] ~ .film-grain {
  opacity: 0.018;
}

/* -- cursor spotlight on cards -------------------------------------------- */
.feature-card,
.checkout-reseller {
  position: relative;
}

.feature-card::after,
.checkout-reseller::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  border-radius: inherit;
  background: radial-gradient(
    280px circle at var(--mx, 50%) var(--my, 50%),
    rgba(255, 108, 140, 0.1),
    transparent 68%
  );
  transition: opacity 0.5s ease;
}

.feature-card:hover::after,
.checkout-reseller:hover::after {
  opacity: 1;
}
/* The wash paints OVER the content rather than under it. Forcing
   `position: relative` on direct children would have overridden
   .card-corner's absolute pin (same specificity, later in the cascade). */

/* -- the eclipse departs as you scroll ------------------------------------
   --depart runs 0 (hero in view) to 1 (hero fully passed). */
.hero-scene {
  --depart: 0;
}

.hero-scene .eclipse {
  transform: translateY(calc(var(--depart) * 46px))
    scale(calc(1 - var(--depart) * 0.05));
}

.hero-scene .corona-detail,
.hero-scene .eclipse-flare {
  opacity: calc(1 - var(--depart) * 0.75);
}

.hero-scene .hero-nebula {
  opacity: calc(1 - var(--depart) * 0.5);
}

@media (prefers-reduced-motion: reduce) {
  .feature-card::after,
  .checkout-reseller::after {
    display: none;
  }

  .hero-scene .eclipse {
    transform: none;
  }

  .hero-scene .corona-detail,
  .hero-scene .eclipse-flare,
  .hero-scene .hero-nebula {
    opacity: 1;
  }
}

/* ============================================================
   Asset load-in
   Only armed once JS runs (.assets-armed), so a no-JS visitor
   never sees a hidden image.
   ============================================================ */
.assets-armed .hero-rocks img,
.assets-armed .corona-detail,
.assets-armed .distant-terrain img,
.assets-armed .interface-viewport img,
.assets-armed .reveal-stage img {
  opacity: 0;
  transform: translateY(18px) scale(1.012);
  transition:
    opacity 1.1s cubic-bezier(0.22, 0.7, 0.2, 1),
    transform 1.3s cubic-bezier(0.22, 0.7, 0.2, 1);
  transition-delay: var(--asset-delay, 0ms);
}

/* Both forms are needed: the hiding rule above uses a descendant `img`
   selector (0,2,1), which outranks a bare `.asset-in` (0,2,0) and would leave
   revealed images stuck at opacity 0. `img.asset-in` ties and wins on order. */
.assets-armed .asset-in,
.assets-armed img.asset-in {
  opacity: 1;
  transform: none;
}

/* The corona resolves as light rather than as a moving object. */
.assets-armed .corona-detail {
  transform: scale(0.94);
}

.assets-armed .corona-detail.asset-in {
  transform: scale(1);
}

/* While the product shot is in flight the frame holds a faint sweep, so the
   space reads as loading rather than as an empty black box. */
.interface-viewport,
.reveal-stage {
  position: relative;
}

.assets-armed .interface-viewport::after,
.assets-armed .reveal-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    100deg,
    transparent 20%,
    rgba(215, 25, 64, 0.07) 45%,
    rgba(255, 255, 255, 0.05) 52%,
    transparent 78%
  );
  background-size: 260% 100%;
  animation: art-sweep 1.5s ease-in-out infinite;
}

.assets-armed .interface-viewport.art-ready::after,
.assets-armed .reveal-stage.art-ready::after {
  animation: none;
  opacity: 0;
  transition: opacity 0.6s ease;
}

@keyframes art-sweep {
  from {
    background-position: 140% 0;
  }
  to {
    background-position: -40% 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .assets-armed .hero-rocks img,
  .assets-armed .corona-detail,
  .assets-armed .distant-terrain img,
  .assets-armed .interface-viewport img,
  .assets-armed .reveal-stage img {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .assets-armed .interface-viewport::after,
  .assets-armed .reveal-stage::after {
    display: none;
  }
}
