/*
 * ByteRoute motion layer (homepage hero and product page feature icons)
 * Output path: public/static/byteroute-motion.css
 * Load only on the homepage and product pages, after byteroute-revamp.css, with byteroute-motion.js.
 * Decorative only. Nothing here moves the shortener, navigation, buttons, form fields or readable text.
 *
 * Rules
 * - Only transform-family properties (translate, scale) and opacity are animated.
 * - translate is used instead of transform so a card's existing rotate() tilt is kept.
 * - Every loop starts and ends on the same value with ease-in-out, so there is no jump at the boundary.
 * - Negative delays stagger elements from first paint, with no start-up pause.
 * - A region pauses when its .br-motion container is offscreen (.is-offscreen) or when the visitor
 *   presses the pause control (html.br-motion-paused). Both set animation-play-state, so motion
 *   resumes from where it stopped rather than restarting.
 * - Phones (under 768px) keep only the phone preview float and the widget dot, at smaller amplitude.
 * - prefers-reduced-motion: reduce shows the complete static design and hides the pause control.
 */

/* Floating decorative cards */
@keyframes br-float {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 var(--br-float-amp, -5px); }
}
.br-float {
  animation: br-float var(--br-float-dur, 10s) ease-in-out var(--br-float-delay, 0s) infinite both;
  will-change: translate;
}
.br-float--a { --br-float-dur: 10s; --br-float-delay: -2.5s; --br-float-amp: -5px; }  /* QR card */
.br-float--b { --br-float-dur: 12s; --br-float-delay: -7s;   --br-float-amp: -6px; }  /* phone bio preview */
.br-float--c { --br-float-dur: 9s;  --br-float-delay: -4.5s; --br-float-amp: -4px; }  /* short link card */

/* Highlight ring that travels between sample bio links. Text never moves. */
@keyframes br-bio-cycle {
  0%, 14%   { translate: 0 0; }
  25%, 39%  { translate: 0 var(--br-bio-step, 62px); }
  50%, 64%  { translate: 0 calc(var(--br-bio-step, 62px) * 2); }
  75%, 89%  { translate: 0 var(--br-bio-step, 62px); }
  100%      { translate: 0 0; }
}
.br-bio-links { position: relative; }
/* Two-link variant, used in the phone hero preview */
@keyframes br-bio-cycle-2 {
  0%, 40%  { translate: 0 0; }
  50%, 90% { translate: 0 var(--br-bio-step, 62px); }
  100%     { translate: 0 0; }
}
.br-bio-ring.br-bio-ring--2 { animation-name: br-bio-cycle-2; animation-duration: 10s; }
.br-bio-ring {
  position: absolute; left: -4px; right: -4px; top: -4px;
  height: calc(var(--br-bio-row, 50px) + 8px);
  border: 2px solid #1B1714; border-radius: 999px; box-sizing: border-box;
  pointer-events: none;
  animation: br-bio-cycle 12s ease-in-out -1s infinite both;
  will-change: translate;
}

/* Widget grid icon: a dot steps through the four cells */
@keyframes br-grid-dot {
  0%, 18%   { translate: 0 0; }
  25%, 43%  { translate: 10.5px 0; }
  50%, 68%  { translate: 10.5px 10.5px; }
  75%, 93%  { translate: 0 10.5px; }
  100%      { translate: 0 0; }
}
.br-ico { position: relative; }
.br-ico-dot {
  position: absolute; left: calc(50% - 7.25px); top: calc(50% - 7.25px);
  width: 4px; height: 4px; border-radius: 50%; background: #1B1714;
  animation: br-grid-dot 8s ease-in-out infinite both;
}

/* QR icon: a soft orange ring breathes in and out, offset from the grid dot */
@keyframes br-soft-ring {
  0%, 55%, 100% { opacity: 0; scale: 0.94; }
  75%           { opacity: 0.7; scale: 1.06; }
}
.br-ico-ring {
  position: absolute; inset: -5px; border-radius: 21px; border: 2px solid #FE6300;
  pointer-events: none; opacity: 0;
  animation: br-soft-ring 8s ease-in-out -3s infinite both;
}

/* Hover feedback: transforms only, so nothing around the element shifts */
.br-lift .br-icon-tile, .br-lift [data-br-tile] { transition: rotate 200ms ease, scale 200ms ease; }
.br-lift:hover .br-icon-tile, .br-lift:hover [data-br-tile] { rotate: -4deg; scale: 1.04; }

/* Pause control */
.br-motion-toggle {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px;
  border: 1.5px solid #E8DFD3; border-radius: 999px; background: #FFFFFF; color: #1B1714;
  font: inherit; font-size: 14px; font-weight: 700; cursor: pointer;
}
.br-motion-toggle:hover { background: #F4EEE5; border-color: #8C8178; }
.br-motion-toggle:focus-visible { outline: 3px solid #1B1714; outline-offset: 3px; }

/* Pausing: offscreen regions and the visitor's choice */
.br-motion.is-offscreen *, .br-motion-paused .br-motion * { animation-play-state: paused !important; }

/* Phones: fewer, smaller movements */
@media (max-width: 767px) {
  .br-float--a, .br-float--c, .br-ico-ring { animation: none; }
  .br-float--b { --br-float-amp: -3px; }
}

/* Reduced motion: complete static design */
@media (prefers-reduced-motion: reduce) {
  .br-float, .br-bio-ring, .br-ico-dot, .br-ico-ring { animation: none !important; }
  .br-bio-ring, .br-ico-ring { display: none; }
  .br-motion-toggle { display: none; }
  .br-lift .br-icon-tile, .br-lift [data-br-tile] { transition: none; }
}
