/* Motion shared by every page: how blocks arrive, how controls answer the pointer, how messages come and go.
   Loaded just before responsive.css, which switches most of it off for people who ask for less motion. */

:root {
  --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);
  --ease-spring: cubic-bezier(0.3, 1.4, 0.5, 1);
}

/* Arrival: the page's blocks rise into place one after another.
   "backwards" keeps no transform after the end, so nothing inside gets a new stacking context. */
.page > *,
.profile-page > * {
  animation: rise-in 0.45s var(--ease-out) backwards;
}

.page > :nth-child(2),
.profile-page > :nth-child(2) {
  animation-delay: 0.06s;
}

.page > :nth-child(3),
.profile-page > :nth-child(3) {
  animation-delay: 0.12s;
}

.page > :nth-child(n + 4),
.profile-page > :nth-child(n + 4) {
  animation-delay: 0.18s;
}

@keyframes rise-in {
  from { opacity: 0; transform: translateY(10px); }
}

/* Header links: a thin line grows from the middle on hover; the current page keeps the ember one */
.header-link:not([aria-current="page"])::after {
  content: "";
  position: absolute;
  right: 12px;
  bottom: -1px;
  left: 12px;
  height: 2px;
  background: var(--steel);
  border-radius: 2px 2px 0 0;
  transform: scaleX(0);
  transition: transform 0.2s var(--ease-out);
}

.header-link:hover::after {
  transform: scaleX(1);
}

/* Tabs slide their colour in instead of switching at once */
.tab {
  transition-property: background-color, box-shadow, color;
  transition-duration: 0.2s;
  transition-timing-function: var(--ease-out);
}

/* Skin cards lift, their rarity glows underneath, and the skin turns towards you a little */
.skin-card {
  transition-property: transform, border-color, box-shadow;
  transition-duration: 0.2s;
  transition-timing-function: var(--ease-out);
}

.skin-card-selectable:hover {
  box-shadow: 0 10px 22px -12px color-mix(in srgb, var(--rarity, var(--steel)) 80%, transparent);
}

.skin-card .skin-image {
  transition-property: opacity, transform;
  transition-duration: 0.25s;
  transition-timing-function: var(--ease-out);
}

.skin-card-selectable:hover .skin-image {
  transform: scale(1.05) rotate(-2deg);
}

.skin-card-selectable:active {
  transform: translateY(0) scale(0.98);
}

/* In Mystery the catalog only shows what can drop: its cards are not buttons, so they stay still */
.mystery-mode .skin-card-selectable:hover,
.mystery-mode .skin-card-selectable:active {
  box-shadow: none;
  transform: none;
}

.mystery-mode .skin-card-selectable:hover .skin-image {
  transform: none;
}

/* The tick on a chosen card pops in */
.skin-card-selected::after {
  animation: tick-in 0.3s var(--ease-spring);
}

@keyframes tick-in {
  from { opacity: 0; transform: scale(0.4); }
}

/* A skin added to the stake drops into its slot */
.stake-tile-new {
  animation: tile-in 0.3s var(--ease-spring);
}

@keyframes tile-in {
  from { opacity: 0; transform: translateY(-8px) scale(0.9); }
}

/* The target arrives in its slot */
.target-image {
  animation: target-in 0.35s var(--ease-out);
}

@keyframes target-in {
  from { opacity: 0; transform: scale(0.92); }
}

/* Forge button: when there is something to forge, the metal breathes heat,
   and on hover a bright edge runs across it */
.button-primary {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.button-primary::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.35) 50%, transparent 65%);
  transform: translateX(-100%);
  pointer-events: none;
}

.button-primary:hover:not(:disabled)::after {
  transform: translateX(100%);
  transition: transform 0.6s var(--ease-out);
}

#forge-button:not(:disabled) {
  animation: forge-ready 2.4s ease-in-out infinite;
}

@keyframes forge-ready {
  0%, 100% { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), var(--glow); }
  50% { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), var(--glow-strong); }
}

/* The balance flashes warm when it changes, so a buy, a sale or a win is felt in the header too */
.balance-changed {
  animation: balance-flash 0.7s var(--ease-out);
}

@keyframes balance-flash {
  0% { background-color: color-mix(in srgb, var(--ember) 35%, var(--iron)); }
  100% { background-color: var(--iron); }
}

/* Small controls */
.multiplier-button,
.deposit-amount,
.coins-max,
.coins-edit,
.icon-button,
.account-chip,
.drop {
  transition-property: background-color, border-color, color, box-shadow, transform;
  transition-duration: 0.15s;
  transition-timing-function: var(--ease-out);
}

.multiplier-button:active,
.deposit-amount:active,
.icon-button:active,
.button-secondary:active:not(:disabled) {
  transform: scale(0.96);
}

.drop:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
}

/* Pop-up messages slide in and fade out */
.toast {
  animation: toast-in 0.25s var(--ease-out);
}

.toast-leaving {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.15s ease-in, transform 0.15s ease-in;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(16px); }
}
