/* GoPoTa «fx» — the success film and the GOPOTA ceremony (see fx-ceremony.js and docs/MOTION.md).
   Every rule is scoped under html.fx: with the preview off this file changes nothing.
   Colour is brand tokens only; the six segments always have hard joins.
   Motion rules live under prefers-reduced-motion: no-preference; the only static addition is the
   coupon line in the completed GOPOTA block (server markup, visually hidden without fx). */

/* ---------- The completed block: coupon line (static, also with reduced motion) ---------- */
html.fx .gp-collect__coupon.app-sr {
  position: static; width: auto; height: auto; margin: 0; overflow: visible;
  clip: auto; white-space: normal;
}
html.fx .gp-collect__coupon { color: var(--on-feature-2); font: 500 13px/18px var(--font-sans); }
html.fx .gp-collect__coupon strong { color: var(--on-feature); font-weight: 700; }
html.fx .fx-cer-links { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 16px; margin-top: 2px; }
html.fx .fx-cer-links .app-link-btn,
html.fx .fx-cer-links a {
  padding: 0; border: 0; background: none; cursor: pointer;
  color: var(--on-feature); font: 700 13px/18px var(--font-sans);
  text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--on-feature) 40%, transparent);
  text-underline-offset: 3px;
}
html.fx .fx-cer-links .app-link-btn:hover,
html.fx .fx-cer-links a:hover { text-decoration-color: currentColor; }

@media (prefers-reduced-motion: no-preference) {
  /* ---------- Hold: no flash of the final state before the film; a CSS timer shows it if JS never comes ---------- */
  html.fx .fx-fin-hold :is(.gp-burst, [data-key-card], [data-collect]) { animation: fx-fin-safety 1ms linear 1.6s both; }

  /* ---------- The ring: six ticks, one per segment (replaces the one-sweep ring, dots and spring check) ---------- */
  html.fx .gp-burst.is-on .gp-burst__ring,
  html.fx .gp-burst.is-on .gp-burst__check svg,
  html.fx .gp-burst.is-on .gp-burst__dots > i { animation: none; }
  html.fx .gp-burst.is-on.fx-fin-ring .gp-burst__ring { animation: fx-fin-ticks 720ms linear both; }
  html.fx .fx-fin-film .gp-burst__mark { visibility: visible; }

  /* ---------- GOPOTA block: the new segment charges, the lit bar flashes once (pseudo-elements: CSS only) ---------- */
  html.fx .gp-collect__word > li.is-new::before,
  html.fx .gp-collect__word > li.is-new > span { animation: none; }
  html.fx .gp-collect__word > li.fx-fin-charge::before { animation: fx-fin-charge 340ms cubic-bezier(.65,0,.35,1) var(--fx-d, 0ms) both; }
  html.fx .gp-collect__word > li.fx-fin-flash::before { animation: fx-fin-flash 560ms cubic-bezier(.16,1,.3,1) var(--fx-d, 0ms) both; }
  html.fx .gp-collect.fx-cer-glow { animation: fx-cer-glow 900ms cubic-bezier(.16,1,.3,1) both; }
  /* anchors for the pieces the film adds (slot, echo, shot) — only while motion is allowed */
  html.fx .app-order.fx-fin-film,
  html.fx .gp-collect__word > li { position: relative; }
}
@keyframes fx-fin-safety { from { opacity: 0; } to { opacity: 1; } }
@keyframes fx-fin-ticks {
  0%      { --gp-sweep: 0deg;   animation-timing-function: cubic-bezier(.65,0,.35,1); }
  16.667% { --gp-sweep: 60deg;  animation-timing-function: cubic-bezier(.65,0,.35,1); }
  33.333% { --gp-sweep: 120deg; animation-timing-function: cubic-bezier(.65,0,.35,1); }
  50%     { --gp-sweep: 180deg; animation-timing-function: cubic-bezier(.65,0,.35,1); }
  66.667% { --gp-sweep: 240deg; animation-timing-function: cubic-bezier(.65,0,.35,1); }
  83.333% { --gp-sweep: 300deg; animation-timing-function: cubic-bezier(.65,0,.35,1); }
  100%    { --gp-sweep: 360deg; }
}
@keyframes fx-fin-charge { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes fx-fin-flash { 0% { filter: none; } 22% { filter: brightness(1.28); } 100% { filter: none; } }
@keyframes fx-cer-glow {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--feature) 70%, transparent); }
  100% { box-shadow: 0 0 0 14px color-mix(in srgb, var(--feature) 0%, transparent); }
}

/* ---------- Finale pieces (created by fx-ceremony.js, aria-hidden) ---------- */
html.fx .gp-key__top > i { transform-origin: left center; }
html.fx .gp-key__code.fx-decoding { color: transparent; }
html.fx .fx-decode {
  position: absolute; left: var(--fx-dl); top: var(--fx-dt); width: var(--fx-dw);
  pointer-events: none; user-select: none; -webkit-user-select: none;
  color: var(--on-feature);
}
html.fx .fx-sparks { position: fixed; inset: 0; z-index: 80; pointer-events: none; overflow: hidden; }
html.fx .fx-sparks > i {
  position: absolute; left: 0; top: 0;
  width: 12px; height: 3.5px; margin: -1.75px 0 0 -6px; border-radius: 2px;
  background: var(--fx-c);
  will-change: transform, opacity;
}
html.fx .fx-sparks > i:nth-child(3n) { width: 8px; margin-left: -4px; }
html.fx .fx-fin-count { position: relative; display: inline-block; }
html.fx .fx-fin-count.is-rolling { color: transparent; }
html.fx .fx-fin-reel { position: absolute; left: 0; top: 0; color: var(--on-feature-2); white-space: pre; pointer-events: none; }
html.fx .fx-fin-reel > span { display: inline-block; vertical-align: top; clip-path: inset(0 -.2em); }
html.fx .fx-fin-reel b { display: block; font-weight: inherit; }
html.fx .fx-fin-reel b::before { content: attr(data-d); }
html.fx .fx-fin-echo {
  position: absolute; left: 0; right: 0; bottom: 0; pointer-events: none;
  color: transparent; -webkit-text-stroke: 1.5px var(--gp-c);
}
html.fx .fx-fin-shot {
  position: absolute; left: 0; right: 0; top: 0; height: 6px; pointer-events: none;
  background: var(--gp-c); transform-origin: 50% 50%;
}

/* ---------- The ceremony stage ---------- */
html.fx .fx-cer {
  position: fixed; inset: 0; z-index: 90;
  display: grid; place-items: center;
  overflow: hidden; outline: none;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}
html.fx .fx-cer__scrim { position: absolute; inset: 0; background: var(--scrim); }
/* the stage is the GOPOTA block's own world: its dark feature colour, deepened, over the dimmed page */
html.fx .fx-cer__veil { position: absolute; inset: 0; background: color-mix(in srgb, var(--feature) 56%, #000); opacity: .9; }
html.fx .fx-cer__confetti { position: absolute; inset: 0; pointer-events: none; }
html.fx .fx-cer__confetti > i {
  position: absolute; left: 0; top: 0;
  width: 18px; height: 6px; margin: -3px 0 0 -9px; border-radius: 2px;
  background: var(--fx-c);
  will-change: transform, opacity;
}
html.fx .fx-cer__confetti > i:nth-child(4n) { width: 12px; margin-left: -6px; }
html.fx .fx-cer__confetti > i:nth-child(5n) { height: 5px; }

/* the giant wordmark */
html.fx .fx-cer__row {
  position: absolute; left: 50%; top: 50%;
  display: flex; align-items: baseline;
  font: 800 var(--fx-word, 120px)/1 var(--font-sans);
  letter-spacing: -.035em;
  white-space: nowrap;
  pointer-events: none;
  translate: -50% -58%;
}
html.fx .fx-cer__ly, html.fx .fx-cer__ls { display: inline-block; }
html.fx .fx-cer__ly { position: relative; z-index: 1; }
html.fx .fx-cer__ls { color: var(--fx-c); will-change: transform, opacity; }
html.fx .fx-cer__echo {
  position: absolute; left: 0; top: 0; pointer-events: none;
  color: transparent; -webkit-text-stroke: max(1.5px, .008em) var(--fx-c);
  transform-origin: 50% 55%;
}
html.fx .fx-cer__seg {
  position: absolute; z-index: 0; top: 100%; height: var(--fx-bar, 8px); margin-top: .1em;
  background: var(--fx-c);
  transform-origin: 0 50%;
}
html.fx .fx-cer__seg:first-of-type { border-radius: 999px 0 0 999px; }
html.fx .fx-cer__seg.is-last { border-radius: 0 999px 999px 0; }
html.fx .fx-cer__shine {
  position: absolute; z-index: 2; left: 0; top: 0; height: calc(100% + .1em + var(--fx-bar, 8px) + 4px);
  width: 24%; overflow: hidden; pointer-events: none;
  transform-origin: 0 0;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 42%, #000 58%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 42%, #000 58%, transparent);
}
html.fx .fx-cer__shine-in { position: absolute; left: 0; top: 0; display: flex; align-items: baseline; transform-origin: 0 0; color: rgba(255,255,255,.44); }
html.fx .fx-cer__frame { position: fixed; left: 0; top: 0; overflow: hidden; pointer-events: none; opacity: 0; }
html.fx .fx-cer__frame > .fx-cer__edge { height: 6px; }

/* the column: pass + actions */
html.fx .fx-cer__col {
  position: relative; display: grid; justify-items: center; gap: 22px;
  width: var(--fx-pass-w, 420px);
  padding-bottom: env(safe-area-inset-bottom);
}
html.fx .fx-cer__lift { position: relative; width: 100%; filter: drop-shadow(0 26px 30px rgba(0,0,0,.32)) drop-shadow(0 4px 6px rgba(0,0,0,.16)); }
html.fx .fx-cer__persp { perspective: 1200px; perspective-origin: 50% 100%; }
html.fx .fx-cer__pass {
  --fx-perf: 70%;
  position: relative; display: grid;
  width: 100%;
  padding: 1.55em 1.6em 0;
  border-radius: 1.15em;
  overflow: hidden;
  font: 500 calc(var(--fx-pass-w, 420px) / 26)/1.35 var(--font-sans);
  background: var(--feature);
  color: var(--on-feature);
  transform-origin: 50% 100%;
  -webkit-mask:
    radial-gradient(circle .62em at 0 var(--fx-perf), #0000 97%, #000) left / 51% 100% no-repeat,
    radial-gradient(circle .62em at 100% var(--fx-perf), #0000 97%, #000) right / 51% 100% no-repeat;
  mask:
    radial-gradient(circle .62em at 0 var(--fx-perf), #0000 97%, #000) left / 51% 100% no-repeat,
    radial-gradient(circle .62em at 100% var(--fx-perf), #0000 97%, #000) right / 51% 100% no-repeat;
}
/* the six-segment edge runs along the bottom, as on the storefront pass */
html.fx .fx-cer__edge { position: absolute; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(6, 1fr); height: .36em; }
html.fx .fx-cer__edge > i { display: block; background: var(--fx-c); }
html.fx .fx-cer__kick {
  display: flex; justify-content: space-between; gap: 1em;
  margin: 0; color: var(--on-feature-2);
  font-size: .62em; line-height: 1.4; font-weight: 800; letter-spacing: .14em; text-transform: uppercase;
}
html.fx .fx-cer__title { margin: 1em 0 0; font-size: 3.25em; line-height: .98; font-weight: 800; letter-spacing: -.035em; }
html.fx .fx-cer__title > span { display: block; }
html.fx .fx-cer__title > span + span { font-weight: 500; letter-spacing: -.045em; }
html.fx .fx-cer__name > b { font-weight: inherit; color: var(--fx-c); }
html.fx .fx-cer__cap { margin: .95em 0 1.35em; font-size: 1em; font-weight: 600; color: var(--on-feature); }
html.fx .fx-cer__perf { position: relative; margin: 0 -1.6em; border-top: 1.5px dashed color-mix(in srgb, var(--on-feature) 32%, transparent); }
html.fx .fx-cer__foot { display: flex; justify-content: space-between; align-items: center; gap: 1em; padding: .9em 0 1.4em; }
html.fx .fx-cer__foot > span:first-child { font-size: .82em; color: var(--on-feature-2); }
html.fx .fx-cer__foot > b { font-size: 1.75em; line-height: 1; font-weight: 800; letter-spacing: -.03em; color: var(--on-feature); }
html.fx .fx-cer__foil, html.fx .fx-cer__glare { position: absolute; pointer-events: none; }
html.fx .fx-cer__foil {
  inset: -60%;
  background: repeating-linear-gradient(118deg,
    var(--rainbow-green) 0 3px, var(--rainbow-orange) 3px 6px, var(--rainbow-red) 6px 9px,
    var(--rainbow-purple) 9px 12px, var(--rainbow-blue) 12px 15px, var(--rainbow-yellow) 15px 18px);
  -webkit-mask-image: linear-gradient(118deg, transparent 36%, rgba(0,0,0,.65) 46%, #000 50%, rgba(0,0,0,.65) 54%, transparent 64%);
  mask-image: linear-gradient(118deg, transparent 36%, rgba(0,0,0,.65) 46%, #000 50%, rgba(0,0,0,.65) 54%, transparent 64%);
  mix-blend-mode: overlay;
  opacity: .34;
}
html.fx .fx-cer__glare {
  left: -60%; top: -60%; width: 220%; height: 220%;
  background: radial-gradient(closest-side, rgba(255,255,255,.18), rgba(255,255,255,.05) 45%, rgba(255,255,255,0) 70%);
}
html.fx .fx-cer__acts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
html.fx .fx-cer__acts .gp-btn { min-width: 0; padding: 0 12px; }
html.fx .fx-cer__acts .fx-cer__primary { background: var(--on-feature); color: var(--feature); }
/* opaque on the stage: the dimmed page must not show through the buttons */
html.fx .fx-cer .gp-btn--on-feature { background: color-mix(in srgb, var(--on-feature) 14%, var(--feature)); }
html.fx .fx-cer__count { position: absolute; left: 12px; right: 12px; bottom: 7px; display: grid; grid-template-columns: repeat(6, 1fr); height: 3px; border-radius: 3px; overflow: hidden; pointer-events: none; }
html.fx .fx-cer__count > i { display: block; background: var(--fx-c); transform-origin: 0 50%; transform: scaleX(0); }
html.fx .fx-cer__skip {
  position: absolute; z-index: 2;
  top: max(16px, calc(env(safe-area-inset-top) + 10px), calc(var(--mini-safe-top, 0px) + 12px));
  right: max(16px, calc(env(safe-area-inset-right) + 10px));
}
html.fx .fx-cer .is-later { visibility: hidden; }
@media (max-width: 380px) {
  html.fx .fx-cer__acts { grid-template-columns: 1fr; }
  html.fx .fx-cer__col { gap: 16px; }
}
@media (max-height: 520px) {
  html.fx .fx-cer__col { gap: 12px; }
}
