/* ConQurio motion: page-to-page "emerald sweep", steady sidebar, staggered reveals, micro-interactions. */

/* ---- page-to-page transition (Chrome/Edge/Safari 18.2+) ---- */
@view-transition { navigation: auto; }

/* The menu stays put while the page changes beside it */
aside[aria-label="Main menu"], .cq-side { view-transition-name: cq-nav; }
#ticker { view-transition-name: cq-ticker; }
::view-transition-group(cq-nav), ::view-transition-group(cq-ticker) { animation-duration: .3s; animation-timing-function: cubic-bezier(.2,.8,.2,1); }
::view-transition-old(cq-nav), ::view-transition-new(cq-nav),
::view-transition-old(cq-ticker), ::view-transition-new(cq-ticker) { animation-duration: .2s; }

/* Outgoing page settles back and dims; incoming page is revealed by a soft diagonal emerald sweep */
::view-transition-old(root) { animation: cq-vt-out .42s cubic-bezier(.4,0,.2,1) both; }
::view-transition-new(root) {
  animation: cq-vt-in .62s cubic-bezier(.16,1,.3,1) both;
  -webkit-mask-image: linear-gradient(105deg, #000 42%, rgba(0,0,0,.55) 50%, transparent 58%);
          mask-image: linear-gradient(105deg, #000 42%, rgba(0,0,0,.55) 50%, transparent 58%);
  -webkit-mask-size: 320% 100%; mask-size: 320% 100%;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
}
::view-transition-image-pair(root) { isolation: auto; }
@keyframes cq-vt-out {
  to { opacity: 0; transform: scale(.985); filter: blur(3px) brightness(.75); }
}
@keyframes cq-vt-in {
  from { -webkit-mask-position: 100% 0; mask-position: 100% 0; transform: translateY(8px); filter: blur(5px) saturate(1.5) hue-rotate(-8deg); }
  60%  { filter: blur(0) saturate(1.15); }
  to   { -webkit-mask-position: 0 0; mask-position: 0 0; transform: none; filter: none; }
}

/* Browsers without page transitions still get a gentle entrance */
@supports not (view-transition-class: a) {
  body > main, body > .wrap, .cq-main { animation: cq-rise .5s cubic-bezier(.16,1,.3,1) both; }
}

/* ---- in-page reveals ---- */
@keyframes cq-rise { from { opacity: 0; transform: translateY(12px); filter: blur(2px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes cq-glow { 0% { box-shadow: 0 0 0 0 rgba(54,213,189,.0); } 30% { box-shadow: 0 0 0 1px rgba(54,213,189,.45), 0 10px 40px -12px rgba(54,213,189,.45); } 100% { box-shadow: 0 0 0 0 rgba(54,213,189,0); } }

/* Content blocks rise in one after another (stock explorer, community) */
.cq-stagger > * { animation: cq-rise .55s cubic-bezier(.16,1,.3,1) both; }
.cq-stagger > *:nth-child(2) { animation-delay: .05s; }
.cq-stagger > *:nth-child(3) { animation-delay: .1s; }
.cq-stagger > *:nth-child(4) { animation-delay: .15s; }
.cq-stagger > *:nth-child(5) { animation-delay: .2s; }
.cq-stagger > *:nth-child(6) { animation-delay: .24s; }
.cq-stagger > *:nth-child(n+7) { animation-delay: .28s; }

/* Chat: the newest message rises in; an answer unfolds piece by piece */
.thread > .msg:last-child { animation: cq-rise .45s cubic-bezier(.16,1,.3,1) both; }
.thread > .msg.b:last-child .body > * { animation: cq-rise .5s cubic-bezier(.16,1,.3,1) both; }
.thread > .msg.b:last-child .body > *:nth-child(2) { animation-delay: .08s; }
.thread > .msg.b:last-child .body > *:nth-child(3) { animation-delay: .16s; }
.thread > .msg.b:last-child .body > *:nth-child(4) { animation-delay: .22s; }
.thread > .msg.b:last-child .body > *:nth-child(n+5) { animation-delay: .28s; }

/* ---- micro-interactions ---- */
a, button, .chip, .btn, input, textarea, select { transition: background-color .2s ease, border-color .2s ease, color .2s ease, box-shadow .25s ease, transform .18s cubic-bezier(.2,.8,.2,1), opacity .2s ease; }
button:active:not(:disabled), .btn:active, .chip:active { transform: scale(.97); }
.card, .it, .qi, .lead, .ql { transition: border-color .25s ease, background-color .25s ease, transform .25s cubic-bezier(.2,.8,.2,1), box-shadow .25s ease; }
.it:hover, .lead:hover { transform: translateY(-2px); box-shadow: 0 14px 40px -20px rgba(0,0,0,.6); }
.cq-flash { animation: cq-glow 1.1s ease-out; }
html { scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}
