/* Curve motion layer. Shared depth, entrance, feedback and live-value effects
   for every page. Loaded after curve-theme.css. Everything here is decorative:
   no element relies on it to become visible, and reduced-motion users get the
   static design. Classes are applied by /curve-motion.mjs. */
:root {
  --motion-ease: cubic-bezier(.22, 1, .36, 1);
  --motion-spring: cubic-bezier(.34, 1.4, .64, 1);
  --motion-fast: 150ms;
  --motion-mid: 260ms;
  --motion-slow: 560ms;
  --motion-glow: #f4d79726;
  --motion-glow-strong: #ebb58a52;
  --motion-up: #7fe0a8;
  --motion-down: #f49a9a;
}

/* Ambient sunrise light that slowly drifts behind every page. */
body.relay-terminal { isolation: isolate; }
.motion-ambient {
  position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden;
  contain: strict;
}
.motion-ambient span {
  position: absolute; width: 62vmax; height: 62vmax; border-radius: 50%;
  filter: blur(70px); opacity: .55; will-change: transform;
}
.motion-ambient span:nth-child(1) { left: -22vmax; top: -30vmax; background: radial-gradient(circle, #b5728e33, transparent 66%); animation: motion-drift-a 46s var(--motion-ease) infinite alternate; }
.motion-ambient span:nth-child(2) { right: -26vmax; top: -24vmax; background: radial-gradient(circle, #ebb58a24, transparent 64%); animation: motion-drift-b 58s ease-in-out infinite alternate; }
.motion-ambient span:nth-child(3) { left: 18vmax; bottom: -44vmax; background: radial-gradient(circle, #776e992e, transparent 66%); animation: motion-drift-c 64s ease-in-out infinite alternate; }
@keyframes motion-drift-a { to { transform: translate3d(14vmax, 9vmax, 0) scale(1.12); } }
@keyframes motion-drift-b { to { transform: translate3d(-12vmax, 12vmax, 0) scale(.9); } }
@keyframes motion-drift-c { to { transform: translate3d(10vmax, -8vmax, 0) scale(1.08); } }

/* Header: glass that deepens once the page scrolls, with a sunrise hairline. */
body.relay-terminal .app-header { view-transition-name: curve-header; transition: box-shadow var(--motion-mid) var(--motion-ease), background-color var(--motion-mid) var(--motion-ease); }
body.relay-terminal .app-header > .motion-hairline {
  position: absolute; left: 0; right: 0; bottom: -1px; height: 1px; pointer-events: none;
  background: linear-gradient(90deg, transparent, #f4d79766 22%, #da7f7d80 50%, #776e9966 78%, transparent);
  background-size: 200% 100%; opacity: 0; transition: opacity var(--motion-slow) var(--motion-ease);
  animation: motion-hairline 9s linear infinite;
}
body.relay-terminal .app-header.motion-scrolled { box-shadow: 0 14px 34px -18px #07030ccc; }
body.relay-terminal .app-header.motion-scrolled > .motion-hairline { opacity: 1; }
@keyframes motion-hairline { to { background-position: -200% 0; } }

/* Brand mark spins up on hover; the dot keeps a gentle heartbeat. */
body.relay-terminal .brand .mark { transition: transform var(--motion-slow) var(--motion-spring), filter var(--motion-mid) ease; }
body.relay-terminal .brand:hover .mark { transform: rotate(-14deg) scale(1.08); filter: drop-shadow(0 0 10px #ebb58a66); }
body.relay-terminal .brand-dot { display: inline-block; animation: motion-heartbeat 3.6s ease-in-out infinite; }
@keyframes motion-heartbeat { 0%, 70%, 100% { transform: none; } 78% { transform: scale(1.35); } 86% { transform: scale(.92); } }

/* Scroll progress bar for long pages. */
.motion-scroll-progress {
  position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 1400; pointer-events: none;
  transform-origin: 0 50%; transform: scaleX(var(--motion-scroll, 0));
  background: linear-gradient(90deg, #f4d797, #ebb58a 45%, #da7f7d 75%, #b5728e);
  opacity: 0; transition: opacity var(--motion-mid) ease;
}
.motion-scroll-progress.is-visible { opacity: .9; }

/* Page entrance: every top-level section rises in, staggered. */
body.relay-terminal main > :not([hidden]):not(script) {
  animation: motion-rise var(--motion-slow) var(--motion-ease) backwards;
  animation-delay: calc(min(var(--motion-index, 0), 8) * 55ms);
}
@keyframes motion-rise { from { opacity: 0; transform: translate3d(0, 14px, 0); } to { opacity: 1; transform: none; } }
@keyframes motion-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes motion-pop { from { opacity: 0; transform: translate3d(0, 10px, 0) scale(.975); } to { opacity: 1; transform: none; } }

/* Content reveal for cards, tiles and rows registered by the motion script. */
.motion-pending { opacity: 0; }
.motion-in { animation: motion-pop var(--motion-slow) var(--motion-ease) backwards; animation-delay: calc(min(var(--motion-i, 0), 12) * 45ms); }

/* Depth and hover lift for interactive surfaces. */
body.relay-terminal :is(.explore-coin, .explore-mini-coin, .token-card, .token-launch-card, .documentation-card, .analytics-metric, .launch-admin-row, .admin-card, .coin-trade-panel, .card) {
  transition: transform var(--motion-mid) var(--motion-ease), box-shadow var(--motion-mid) var(--motion-ease), border-color var(--motion-mid) ease, background-color var(--motion-mid) ease;
}
body.relay-terminal :is(.explore-coin, .explore-mini-coin, .token-launch-card, .documentation-card):hover {
  transform: translate3d(0, -4px, 0);
  box-shadow: 0 18px 40px -22px #000c, 0 0 0 1px #ebb58a40, 0 10px 34px -14px var(--motion-glow-strong);
}
body.relay-terminal :is(.analytics-metric, .token-card):hover { box-shadow: 0 16px 36px -24px #000b, 0 0 0 1px #ebb58a2e; }

/* Cursor spotlight on cards that opt in through the motion script. */
.motion-spotlight { position: relative; }
.motion-spotlight > .motion-spot {
  position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: 0;
  background: radial-gradient(340px circle at var(--motion-x, 50%) var(--motion-y, 50%), #ffe9c51a, transparent 62%);
  opacity: 0; transition: opacity var(--motion-mid) ease;
}
.motion-spotlight:hover > .motion-spot { opacity: 1; }

/* Buttons: tactile press, primary shine and ripple. */
body.relay-terminal :is(button, .small-button, .primary, .top-launch, a.small-button):not(:disabled) { transition: transform var(--motion-fast) var(--motion-ease), background-color var(--motion-mid) ease, border-color var(--motion-mid) ease, color var(--motion-mid) ease, box-shadow var(--motion-mid) ease, filter var(--motion-mid) ease; }
body.relay-terminal :is(button, .small-button, .primary, .top-launch):not(:disabled):active { transform: scale(.965); }
body.relay-terminal :is(.primary, .top-launch) { position: relative; overflow: hidden; isolation: isolate; }
body.relay-terminal :is(.primary, .top-launch)::before {
  content: ""; position: absolute; inset: -40% auto -40% -60%; width: 46%; z-index: -1; pointer-events: none;
  background: linear-gradient(100deg, transparent, #ffffff70, transparent);
  transform: translateX(0) skewX(-18deg); opacity: 0;
}
body.relay-terminal :is(.primary, .top-launch):not(:disabled):hover::before { animation: motion-shine 900ms var(--motion-ease); }
body.relay-terminal :is(.primary, .top-launch):not(:disabled):hover { box-shadow: 0 10px 28px -10px #ebb58a99, 0 0 0 1px #f4cc9d88; filter: saturate(1.08); }
@keyframes motion-shine { 0% { opacity: 0; transform: translateX(0) skewX(-18deg); } 20% { opacity: 1; } 100% { opacity: 0; transform: translateX(420%) skewX(-18deg); } }
body.relay-terminal .top-launch { animation: motion-launch-glow 4.8s ease-in-out infinite; }
@keyframes motion-launch-glow { 0%, 100% { box-shadow: 0 0 0 0 #ebb58a00; } 50% { box-shadow: 0 0 22px -4px #ebb58a73; } }
.motion-ripple {
  position: absolute; border-radius: 50%; pointer-events: none; z-index: -1;
  width: var(--motion-size); height: var(--motion-size); left: var(--motion-x); top: var(--motion-y);
  background: radial-gradient(circle, #ffffffa6 0%, #ffffff33 45%, transparent 70%);
  transform: translate(-50%, -50%) scale(0); animation: motion-ripple 620ms var(--motion-ease) forwards;
}
@keyframes motion-ripple { to { transform: translate(-50%, -50%) scale(1); opacity: 0; } }

/* Links and text buttons get a sliding underline. */
body.relay-terminal :is(.text-button, .site-footer-links a) { background-image: linear-gradient(currentColor, currentColor); background-size: 0% 1px; background-repeat: no-repeat; background-position: 0 100%; transition: background-size var(--motion-mid) var(--motion-ease), color var(--motion-mid) ease; }
body.relay-terminal :is(.text-button, .site-footer-links a):hover { background-size: 100% 1px; }

/* Live values: flash up/down and a soft settle after a count animation. */
.motion-up { animation: motion-flash-up 1.1s var(--motion-ease); }
.motion-down { animation: motion-flash-down 1.1s var(--motion-ease); }
@keyframes motion-flash-up { 0% { color: var(--motion-up); text-shadow: 0 0 14px #7fe0a866; } 100% { text-shadow: 0 0 0 transparent; } }
@keyframes motion-flash-down { 0% { color: var(--motion-down); text-shadow: 0 0 14px #f49a9a66; } 100% { text-shadow: 0 0 0 transparent; } }
.motion-counting { font-variant-numeric: tabular-nums; }

/* Skeletons and placeholders shimmer instead of sitting still. */
body.relay-terminal :is(.explore-skeleton, .explore-leader-placeholder, .motion-skeleton, [aria-busy=true] > .skeleton) {
  background-image: linear-gradient(100deg, transparent 20%, #ffffff0d 42%, #ffe2c414 50%, #ffffff0d 58%, transparent 80%) !important;
  background-size: 220% 100% !important; animation: motion-shimmer 1.6s linear infinite !important;
}
@keyframes motion-shimmer { from { background-position: 120% 0; } to { background-position: -120% 0; } }

/* Progress bars fill smoothly and glow at the leading edge. */
body.relay-terminal :is(.explore-progress, .coin-progress-wrap progress)::-webkit-progress-value { transition: width var(--motion-slow) var(--motion-ease); }

/* Dialogs scale in over a blurred backdrop. */
html.motion-ready dialog[open] { animation: motion-dialog var(--motion-mid) var(--motion-ease); }
html.motion-ready dialog[open]::backdrop { animation: motion-fade var(--motion-mid) ease; backdrop-filter: blur(6px); background: #0b0710a6; }
@keyframes motion-dialog { from { opacity: 0; transform: translate3d(0, 12px, 0) scale(.97); } to { opacity: 1; transform: none; } }

/* Disclosure panels open with a fade instead of a jump. */
html.motion-ready details[open] > :not(summary) { animation: motion-fade var(--motion-mid) ease; }
body.relay-terminal summary { transition: color var(--motion-mid) ease; }

/* Status lights breathe. */
body.relay-terminal :is(.status-light, .admin-secure i, .explore-live-dot) { animation: motion-breathe 2.4s ease-in-out infinite; }
@keyframes motion-breathe { 50% { opacity: .45; transform: scale(.82); } }

/* Smooth page-to-page swaps (View Transitions API, used by the router). */
::view-transition-old(root) { animation: motion-vt-out 220ms var(--motion-ease) both; }
::view-transition-new(root) { animation: motion-vt-in 380ms var(--motion-ease) both; }
::view-transition-group(curve-header) { animation-duration: 0s; }
@keyframes motion-vt-out { to { opacity: 0; transform: translate3d(0, -6px, 0); } }
@keyframes motion-vt-in { from { opacity: 0; transform: translate3d(0, 10px, 0); } }

/* Celebration confetti canvas (launch and trade success). */
.motion-confetti { position: fixed; inset: 0; z-index: 2000; pointer-events: none; }

/* Toast used by the motion script to confirm copy actions. */
.motion-toast {
  position: fixed; left: 50%; bottom: 26px; z-index: 1900; pointer-events: none;
  padding: 9px 16px; border-radius: 999px; font: 600 13px var(--sans);
  color: #2e1d30; background: linear-gradient(105deg, #f4d797, #ebb58a 58%, #e69986);
  box-shadow: 0 14px 30px -12px #000c; transform: translate(-50%, 16px); opacity: 0;
  transition: transform var(--motion-mid) var(--motion-spring), opacity var(--motion-mid) ease;
}
.motion-toast.is-visible { transform: translate(-50%, 0); opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .motion-ambient span, .brand-dot, .top-launch, .motion-hairline { animation: none !important; }
  body.relay-terminal main > *, .motion-in, html.motion-ready dialog[open], html.motion-ready details[open] > :not(summary) { animation: none !important; }
  .motion-pending { opacity: 1 !important; }
  ::view-transition-old(root), ::view-transition-new(root) { animation: none !important; }
  .motion-up, .motion-down { animation: none !important; }
  .motion-ripple, .motion-confetti { display: none !important; }
  body.relay-terminal :is(.explore-coin, .explore-mini-coin, .token-launch-card, .documentation-card):hover { transform: none; }
}
@media print { .motion-ambient, .motion-scroll-progress, .motion-confetti, .motion-toast { display: none !important; } }

/* Full page loads between Curve pages cross-fade where the browser supports it. */
@view-transition { navigation: auto; }
