/* ============================================================
   ConcertDefense — motion.css
   Ambient loops, hover choreography, press feedback, scroll
   reveals. Every rule is disabled under prefers-reduced-motion.
   ============================================================ */

/* ---------- keyframes ---------- */
@keyframes cdSheen {
  0%   { transform: translateX(-120%) skewX(-18deg); opacity: 0; }
  18%  { opacity: .55; }
  55%  { opacity: .28; }
  100% { transform: translateX(220%) skewX(-18deg); opacity: 0; }
}

@keyframes cdRipple {
  from { transform: scale(0); opacity: .5; }
  to   { transform: scale(2.6); opacity: 0; }
}

@keyframes cdFadeUp {
  from { opacity: 0; transform: translateY(1.1rem); }
  to   { opacity: 1; transform: none; }
}

@keyframes cdFloatIn {
  0%   { opacity: 0; transform: translateY(1.4rem) scale(.97) rotate(-.8deg); }
  60%  { opacity: 1; transform: translateY(-.25rem) scale(1.006) rotate(.2deg); }
  100% { opacity: 1; transform: none; }
}

@keyframes cdBob {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50%      { transform: translateY(-3px) rotate(-2deg); }
}

@keyframes cdStripe {
  from { background-position: 0 0; }
  to   { background-position: 1.75rem 0; }
}

@keyframes cdRingPulse {
  0%, 100% { box-shadow: var(--hard-sm), 0 0 0 0 color-mix(in srgb, var(--mustard) 55%, transparent); }
  50%      { box-shadow: var(--hard-sm), 0 0 0 .5rem color-mix(in srgb, var(--mustard) 0%, transparent); }
}

@keyframes cdGlowPulse {
  0%, 100% { opacity: .55; }
  50%      { opacity: 1; }
}

@keyframes cdTapeWobble {
  0%, 100% { transform: rotate(-5deg); }
  50%      { transform: rotate(-3.4deg); }
}

@keyframes cdSpin {
  to { transform: rotate(360deg); }
}

@keyframes cdNudge {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-3px); }
  60%      { transform: translateX(3px); }
}

@keyframes cdPopUp {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.16); }
  100% { transform: scale(1); }
}

@keyframes cdSlideIn {
  from { opacity: 0; transform: translate(-50%, .9rem) rotate(-1deg); }
  to   { opacity: 1; transform: translate(-50%, 0) rotate(-1deg); }
}

@keyframes cdComboFlash {
  0%   { transform: rotate(-3deg) scale(1.06); color: var(--mustard); }
  40%  { transform: rotate(1.5deg) scale(1.22); color: var(--mustard-hi); }
  100% { transform: rotate(-3deg) scale(1.06); color: var(--mustard); }
}

@keyframes cdBarShine {
  0%   { transform: translateX(-140%); }
  100% { transform: translateX(340%); }
}

@keyframes cdDrift {
  0%   { transform: translate3d(0, 0, 0); }
  50%  { transform: translate3d(0, -6px, 0); }
  100% { transform: translate3d(0, 0, 0); }
}

/* ============================================================
   Ambient — always-on, very low amplitude
   ============================================================ */

/* hazard stripes crawl slowly across the header lid */
.site-header::before {
  background-size: 1.75rem 100%;
  animation: cdStripe 3.2s linear infinite;
}

/* the brand mark breathes instead of sitting still */
.brand-mark { animation: cdBob 5.5s ease-in-out infinite; }

/* focal glow behind the hero art drifts */
.hero-art svg,
.hero-art img { animation: cdDrift 9s ease-in-out infinite; }

/* card tape subtly settles */
.card::before { animation: cdTapeWobble 7s ease-in-out infinite; }
.card::after  { animation: cdTapeWobble 7.8s ease-in-out infinite reverse; }

/* ultimate ring breathes once it is charged */
.ult-ring.full { animation: cdRingPulse 1.6s ease-out infinite; }

/* low-integrity bar pulses with the vignette */
.meter-fill.crit { animation: crit .7s steps(2) infinite, cdGlowPulse 1.1s ease-in-out infinite; }

/* ============================================================
   Reveal on scroll
   ============================================================ */
[data-reveal] {
  opacity: 0;
  transform: translateY(1.1rem);
}
[data-reveal].is-revealed {
  animation: cdFadeUp .62s cubic-bezier(.22, 1, .36, 1) forwards;
}
[data-reveal][data-reveal-delay="1"] { animation-delay: .07s; }
[data-reveal][data-reveal-delay="2"] { animation-delay: .14s; }
[data-reveal][data-reveal-delay="3"] { animation-delay: .21s; }
[data-reveal][data-reveal-delay="4"] { animation-delay: .28s; }
[data-reveal][data-reveal-delay="5"] { animation-delay: .35s; }

/* ============================================================
   Buttons — sheen, lift, press
   ============================================================ */
.btn,
.nav-btn--cta,
.gear-btn,
.hype-btn,
.share-btn,
.icon-btn,
.tier-btn,
.link-card,
.shop-item button,
.board-tabs button {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  -webkit-tap-highlight-color: transparent;
}

/* travelling highlight on hover */
.btn::before,
.nav-btn--cta::before,
.hype-btn::before,
.tier-btn::before {
  content: "";
  position: absolute;
  top: -60%;
  bottom: -60%;
  left: 0;
  width: 40%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .42), transparent);
  pointer-events: none;
  z-index: -1;
  opacity: 0;
}

.btn:hover::before,
.nav-btn--cta:hover::before,
.hype-btn:hover::before,
.tier-btn:hover::before {
  animation: cdSheen .82s cubic-bezier(.3, .7, .4, 1);
}

/* press feedback — a touch more snap than the base translate */
.btn:active { transition-duration: .04s; }
.btn--primary:hover { filter: saturate(1.12) brightness(1.03); }

/* keyboard focus ring gets a brief bloom */
:where(a, button, input, textarea, select, summary, [tabindex]):focus-visible {
  animation: cdRingPulse 1.5s ease-out 1;
}

/* icons inside icon buttons rotate on hover */
.icon-btn svg { transition: transform .25s cubic-bezier(.2, .9, .3, 1.5); }
.icon-btn:hover svg { transform: rotate(-8deg) scale(1.08); }
#themeBtn:hover svg { transform: rotate(35deg) scale(1.08); }
#fsBtn:hover svg { transform: scale(1.12); }

/* nav links slide their rule */
.nav-btn::after { transition: width .22s cubic-bezier(.22, 1, .36, 1), transform .22s cubic-bezier(.22, 1, .36, 1); }

/* mobile menu items cascade in */
.site-nav[data-open="true"] .nav-btn {
  animation: cdFadeUp .34s cubic-bezier(.22, 1, .36, 1) backwards;
}
.site-nav[data-open="true"] .nav-btn:nth-child(1) { animation-delay: .02s; }
.site-nav[data-open="true"] .nav-btn:nth-child(2) { animation-delay: .06s; }
.site-nav[data-open="true"] .nav-btn:nth-child(3) { animation-delay: .1s; }
.site-nav[data-open="true"] .nav-btn:nth-child(4) { animation-delay: .14s; }
.site-nav[data-open="true"] .nav-btn:nth-child(5) { animation-delay: .18s; }
.site-nav[data-open="true"] .nav-btn:nth-child(6) { animation-delay: .22s; }

/* hamburger bars */
.nav-toggle .bars span { transition: transform .24s cubic-bezier(.22, 1, .36, 1), opacity .18s ease; }

/* ============================================================
   Gear dock — cascade + selection feedback
   ============================================================ */
.gear-btn {
  animation: cdFadeUp .48s cubic-bezier(.22, 1, .36, 1) backwards;
}
.gear-btn:nth-child(1) { animation-delay: .02s; }
.gear-btn:nth-child(2) { animation-delay: .06s; }
.gear-btn:nth-child(3) { animation-delay: .1s; }
.gear-btn:nth-child(4) { animation-delay: .14s; }
.gear-btn:nth-child(5) { animation-delay: .18s; }
.gear-btn:nth-child(6) { animation-delay: .22s; }

.gear-btn .gear-icon { transition: transform .22s cubic-bezier(.2, .9, .3, 1.5); }
.gear-btn:hover .gear-icon { transform: rotate(-9deg) scale(1.12); }
.gear-btn.selected .gear-icon { animation: cdPopUp .34s cubic-bezier(.2, .9, .3, 1.5); }
.gear-btn.selected { animation: cdPopUp .34s cubic-bezier(.2, .9, .3, 1.5); }

/* the dock now clips its ripples, so the selected marker sits inside */
.gear-btn.selected::after {
  top: auto;
  bottom: 3px;
  right: 4px;
  width: .42rem;
  height: .42rem;
  transform: none;
  animation: cdGlowPulse 1.4s ease-in-out infinite;
}

/* cost ticks when it changes */
.gear-cost.is-ticking { animation: cdPopUp .3s cubic-bezier(.2, .9, .3, 1.6); }

/* ============================================================
   HUD micro-motion
   ============================================================ */
.stat b { transition: color .2s ease; }
.stat b.is-bumping { animation: bump .3s cubic-bezier(.2, .9, .3, 1.6); color: var(--mustard-hi); }

.combo-wrap.active b { animation: cdComboFlash .4s cubic-bezier(.2, .9, .3, 1.5); }

/* progress-bar sheen */
.meter-track::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 34%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .5), transparent);
  z-index: 1;
  pointer-events: none;
  animation: cdBarShine 3.6s cubic-bezier(.4, 0, .6, 1) infinite;
}

.ult-ring { transition: transform .2s ease; }
.ult-ring:hover { transform: scale(1.06); }

.tier-chip { transition: transform .18s cubic-bezier(.2, .9, .3, 1.4); }
.tier-chip:hover { transform: rotate(2deg) scale(1.04); }

/* ============================================================
   Overlays & cards
   ============================================================ */
.overlay[data-open="true"] .card,
.modal[data-open="true"] .modal-panel {
  animation: cdFloatIn .42s cubic-bezier(.22, 1, .36, 1) both;
}

.modal[data-open="true"] .modal-close { animation: cdFadeUp .3s ease-out .1s backwards; }

/* shop items tick in one after another */
.shop-item { animation: cdFadeUp .34s cubic-bezier(.22, 1, .36, 1) backwards; }
.shop-item:nth-child(1) { animation-delay: .02s; }
.shop-item:nth-child(2) { animation-delay: .06s; }
.shop-item:nth-child(3) { animation-delay: .1s; }
.shop-item:nth-child(4) { animation-delay: .14s; }
.shop-item:nth-child(5) { animation-delay: .18s; }
.shop-item:nth-child(6) { animation-delay: .22s; }
.shop-item:nth-child(n+7) { animation-delay: .26s; }

.shop-item button { transition: background .16s ease, transform .1s ease, box-shadow .16s ease; }
.shop-item button:hover:not(:disabled) { transform: translate(-1px, -1px); }

/* score cells land in sequence, best value pops */
.score-cell { animation: cdFadeUp .38s cubic-bezier(.22, 1, .36, 1) backwards; }
.score-cell:nth-child(1) { animation-delay: .04s; }
.score-cell:nth-child(2) { animation-delay: .08s; }
.score-cell:nth-child(3) { animation-delay: .12s; }
.score-cell:nth-child(4) { animation-delay: .16s; }
.score-cell:nth-child(5) { animation-delay: .2s; }
.score-cell:nth-child(6) { animation-delay: .24s; }
.score-cell:nth-child(7) { animation-delay: .28s; }
.score-cell.best b { animation: cdPopUp .5s cubic-bezier(.2, .9, .3, 1.6) .3s backwards; }

.reward:not([hidden]) { animation: cdFloatIn .44s cubic-bezier(.22, 1, .36, 1) both; }

/* tier buttons: locked ones shove when poked */
.tier-btn.locked:active { animation: cdNudge .3s ease; }

/* toast */
.toast.show { animation: cdSlideIn .26s cubic-bezier(.22, 1, .36, 1); }

/* leaderboard rows stagger */
.board-row { animation: cdFadeUp .34s cubic-bezier(.22, 1, .36, 1) backwards; }
.board-row:nth-child(1) { animation-delay: .02s; }
.board-row:nth-child(2) { animation-delay: .05s; }
.board-row:nth-child(3) { animation-delay: .08s; }
.board-row:nth-child(4) { animation-delay: .11s; }
.board-row:nth-child(5) { animation-delay: .14s; }
.board-row:nth-child(n+6) { animation-delay: .17s; }
.board-row.top .tag { animation: cdGlowPulse 2.2s ease-in-out infinite; }

/* ============================================================
   Content cards
   ============================================================ */
.feature-grid article .feature-icon { transition: transform .24s cubic-bezier(.2, .9, .3, 1.5); }
.feature-grid article:hover .feature-icon { transform: rotate(7deg) scale(1.12); }
.feature-grid article::after { transition: color .22s ease; }
.feature-grid article:hover::after { color: color-mix(in srgb, var(--mustard) 26%, transparent); }

.link-card { transition: transform .16s cubic-bezier(.22, 1, .36, 1), border-color .16s ease, box-shadow .16s ease; }
.link-card b { transition: color .16s ease; }
.link-card:hover b { color: var(--mustard); }
.link-card span { transition: transform .2s ease; display: block; }
.link-card:hover span { transform: translateX(2px); }

.asset-card { transition: transform .2s cubic-bezier(.22, 1, .36, 1), box-shadow .2s ease; }
.asset-card:hover { transform: translate(-2px, -2px); box-shadow: var(--hard); }
.asset-card img { transition: filter .3s ease, transform .4s cubic-bezier(.22, 1, .36, 1); }
.asset-card:hover img { filter: saturate(1.1) contrast(1.04); transform: scale(1.015); }

/* faq chevron */
details.faq { transition: border-color .18s ease, background .18s ease; }
details.faq[open] { border-color: var(--mustard); }
details.faq summary::after { transition: transform .24s cubic-bezier(.22, 1, .36, 1), color .18s ease; }
details.faq[open] summary::after { transform: rotate(45deg); color: var(--mustard-hi); }

/* ============================================================
   JS-driven helpers
   ============================================================ */
.cd-ripple {
  position: absolute;
  border-radius: 50%;
  background: currentColor;
  pointer-events: none;
  z-index: 2;
  animation: cdRipple .55s cubic-bezier(.22, 1, .36, 1) forwards;
}

.is-pressed { animation: cdPopUp .22s cubic-bezier(.2, .9, .3, 1.6); }

/* canvas wrapper reacts to a full ultimate */
.game-shell.ult-ready .canvas-wrap::after {
  box-shadow: inset 0 0 2.9rem rgba(0, 0, 0, .55), inset 0 0 1.6rem color-mix(in srgb, var(--blood) 55%, transparent);
  transition: box-shadow .3s ease;
}

/* ============================================================
   Reduced motion — strip everything decorative
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .site-header::before,
  .brand-mark,
  .hero-art svg,
  .hero-art img,
  .card::before,
  .card::after,
  .ult-ring.full,
  .meter-fill.crit,
  .meter-track::before,
  .gear-btn,
  .gear-btn.selected,
  .gear-btn.selected::after,
  .shop-item,
  .score-cell,
  .board-row,
  .board-row.top .tag,
  .btn::before,
  .nav-btn--cta::before,
  .hype-btn::before,
  .tier-btn::before,
  .gear-btn .gear-icon {
    animation: none !important;
  }

  [data-reveal] { opacity: 1; transform: none; }
  .cd-ripple { display: none; }
  .is-pressed { animation: none; }
  .overlay[data-open="true"] .card,
  .modal[data-open="true"] .modal-panel { animation: none; }
}
