/* Site-wide motion (js/motion.js) + small round-result pill (js/games/win-popup.js).
   Everything here is switched off for people who ask for reduced motion. */

:root {
  --tb-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --tb-ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --tb-win: rgb(32 208 149);
  --tb-lose: rgb(255 107 122);
}

/* ---------- page entrance ---------- */

.site-content > *,
.tide-game-page .site-content > * {
  animation: tb-rise 0.5s var(--tb-ease-out) backwards;
}
.site-content > *:nth-child(2) { animation-delay: 0.06s; }
.site-content > *:nth-child(3) { animation-delay: 0.12s; }
.site-content > *:nth-child(4) { animation-delay: 0.18s; }

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

/* ---------- scroll reveal (motion.js adds .tb-reveal, then .tb-in) ---------- */

html .tb-reveal {
  transition:
    opacity 0.55s var(--tb-ease-out) var(--tb-delay, 0s),
    transform 0.55s var(--tb-ease-out) var(--tb-delay, 0s);
}
html .tb-reveal:not(.tb-in) {
  opacity: 0;
  transform: translateY(18px) scale(0.985);
}

/* ---------- home hero ---------- */

.home-hero {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}
.home-hero::before {
  content: "";
  position: absolute;
  inset: -40%;
  z-index: -1;
  background:
    radial-gradient(closest-side at 30% 40%, rgba(43, 99, 244, 0.28), transparent 70%),
    radial-gradient(closest-side at 75% 65%, rgba(32, 208, 149, 0.14), transparent 70%);
  animation: tb-drift 18s ease-in-out infinite alternate;
  pointer-events: none;
}
@keyframes tb-drift {
  to {
    transform: translate(6%, -4%) rotate(8deg) scale(1.08);
  }
}
.home-hero__title {
  background: linear-gradient(90deg, #fff 0%, #fff 40%, rgb(147 178 255) 50%, #fff 60%, #fff 100%) 0 0 / 250% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: tb-sheen 6s ease-in-out infinite;
}
@keyframes tb-sheen {
  0%, 60% { background-position: 100% 0; }
  100% { background-position: -150% 0; }
}

/* ---------- game cards ---------- */

.game-card {
  overflow: hidden;
  transition:
    transform 0.28s var(--tb-ease-spring),
    border-color 0.22s ease,
    box-shadow 0.28s ease;
}
.game-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 35%, rgba(255, 255, 255, 0.09) 50%, transparent 65%) 0 0 / 250% 100%;
  background-position: 150% 0;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}
.game-card:hover:not(.game-card--soon) {
  transform: translateY(-5px) scale(1.015);
  box-shadow: 0 16px 34px -10px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(59, 130, 246, 0.35), 0 0 26px -6px rgba(43, 99, 244, 0.55);
}
.game-card:hover::after {
  opacity: 1;
  animation: tb-card-shine 0.9s ease forwards;
}
@keyframes tb-card-shine {
  to { background-position: -60% 0; }
}
.game-card__art img {
  animation: tb-float 4.5s ease-in-out infinite;
  transition: transform 0.3s var(--tb-ease-spring);
}
.game-card:nth-child(2n) .game-card__art img { animation-delay: -1.5s; }
.game-card:nth-child(3n) .game-card__art img { animation-delay: -3s; }
.game-card:hover .game-card__art img {
  transform: scale(1.15) rotate(-6deg);
}
@keyframes tb-float {
  50% { translate: 0 -5px; }
}
.game-card__badge {
  position: relative;
}
.game-card__badge::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 5px;
  border-radius: 50%;
  background: currentColor;
  vertical-align: 1px;
  animation: tb-live 1.6s ease-in-out infinite;
}
@keyframes tb-live {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 currentColor; }
  50% { opacity: 0.55; box-shadow: 0 0 0 4px transparent; }
}

/* ---------- buttons & links ---------- */

.ax-btn,
.twm-submit,
.topbar-wallet-btn,
.tbs-fab,
button.pressable-medium {
  transition:
    transform 0.18s var(--tb-ease-spring),
    filter 0.15s ease,
    box-shadow 0.2s ease,
    background-color 0.2s ease;
}
.ax-btn:hover {
  transform: translateY(-2px);
}
.ax-btn:active,
.topbar-wallet-btn:active,
button.pressable-medium:active {
  transform: scale(0.95);
}
.ax-btn--primary {
  position: relative;
  overflow: hidden;
}
.ax-btn--primary::after,
.topbar-wallet-btn::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.28) 50%, transparent 70%) 0 0 / 250% 100%;
  background-position: 150% 0;
  animation: tb-btn-shine 4.5s ease-in-out infinite;
  pointer-events: none;
}
.topbar-wallet-btn {
  position: relative;
  overflow: hidden;
}
@keyframes tb-btn-shine {
  0%, 70% { background-position: 150% 0; }
  100% { background-position: -60% 0; }
}

.site-ax-nav__link {
  position: relative;
  transition: color 0.18s ease, background-color 0.18s ease;
}
.site-ax-nav__link::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 3px;
  height: 2px;
  border-radius: 2px;
  background: var(--tb-accent, rgb(43 99 244));
  transform: scaleX(0);
  transition: transform 0.25s var(--tb-ease-out);
}
.site-ax-nav__link:hover::after {
  transform: scaleX(1);
}

/* Click ripple (motion.js) */
.tb-ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
  transform: scale(0);
  animation: tb-ripple 0.55s ease-out forwards;
  pointer-events: none;
}
@keyframes tb-ripple {
  to {
    transform: scale(1);
    opacity: 0;
  }
}

/* ---------- topbar balance ---------- */

.currency-picker__trigger {
  transition: border-color 0.2s ease, box-shadow 0.3s ease, transform 0.2s var(--tb-ease-spring);
}
.currency-picker__trigger:hover {
  border-color: rgba(147, 178, 255, 0.45);
}
.currency-picker__bal.tb-bal-up {
  animation: tb-bal-up 0.9s ease;
}
.currency-picker__bal.tb-bal-down {
  animation: tb-bal-down 0.7s ease;
}
@keyframes tb-bal-up {
  0% { color: var(--tb-win); transform: translateY(-3px); }
  100% { color: inherit; transform: none; }
}
@keyframes tb-bal-down {
  0% { color: var(--tb-lose); }
  100% { color: inherit; }
}
.tb-chip-win {
  animation: tb-chip-win 1.1s ease;
}
.tb-chip-lose {
  animation: tb-chip-lose 0.5s ease;
}
@keyframes tb-chip-win {
  0% { box-shadow: 0 0 0 0 rgba(32, 208, 149, 0.7); border-color: var(--tb-win); transform: scale(1.06); }
  40% { transform: scale(1); }
  100% { box-shadow: 0 0 0 14px rgba(32, 208, 149, 0); }
}
@keyframes tb-chip-lose {
  0%, 100% { transform: none; }
  25% { transform: translateX(-3px); border-color: var(--tb-lose); }
  75% { transform: translateX(3px); }
}

/* ---------- round result pill (replaces the full-screen popup) ---------- */

.tb-result {
  position: fixed;
  z-index: 260;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 7px 16px 8px;
  border-radius: 999px;
  background: rgb(18 23 49 / 0.96);
  border: 1px solid var(--tb-line, rgba(148, 163, 214, 0.18));
  box-shadow: 0 12px 28px -10px rgba(0, 0, 0, 0.7);
  transform: translateX(-50%);
  animation: tb-result-in 0.45s var(--tb-ease-spring) both;
  pointer-events: none;
  white-space: nowrap;
}
.tb-result--win {
  border-color: rgba(32, 208, 149, 0.55);
  box-shadow: 0 12px 28px -10px rgba(0, 0, 0, 0.7), 0 0 22px -4px rgba(32, 208, 149, 0.55);
}
.tb-result--lose {
  border-color: rgba(255, 107, 122, 0.35);
  padding: 5px 13px 6px;
}
.tb-result__amount {
  font-weight: 800;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}
.tb-result--win .tb-result__amount {
  color: var(--tb-win);
  font-size: 1.125rem;
}
.tb-result--lose .tb-result__amount {
  color: var(--tb-lose);
  font-size: 0.875rem;
}
.tb-result__meta {
  color: rgb(164 170 198);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.tb-result--out {
  animation: tb-result-out 0.4s ease forwards;
}
@keyframes tb-result-in {
  from {
    opacity: 0;
    transform: translate(-50%, -14px) scale(0.7);
  }
}
@keyframes tb-result-out {
  to {
    opacity: 0;
    transform: translate(-50%, -18px) scale(0.92);
  }
}
.tb-result__spark {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 5px;
  height: 5px;
  margin: -2.5px;
  border-radius: 50%;
  background: var(--tb-win);
  box-shadow: 0 0 6px var(--tb-win);
  animation: tb-spark 0.75s ease-out 0.1s forwards;
  opacity: 0;
}
.tb-result__spark:nth-child(3n) {
  background: #ffd166;
  box-shadow: 0 0 6px #ffd166;
}
@keyframes tb-spark {
  0% {
    opacity: 1;
    transform: rotate(var(--a)) translateX(10px);
  }
  100% {
    opacity: 0;
    transform: rotate(var(--a)) translateX(calc(var(--d) + 40px)) scale(0.4);
  }
}

/* ---------- game panels ---------- */

.tide-game-page .original-panel,
.tide-game-page .fs-fakestake-mount {
  animation: tb-rise 0.55s var(--tb-ease-out) 0.05s backwards;
}
.fs-mines-cell--idle {
  transition: transform 0.2s var(--tb-ease-spring), filter 0.15s ease;
}
.fs-mines-cell--idle:hover {
  filter: brightness(1.15);
}
.fs-mines-cell--idle:active {
  transform: scale(0.9);
}

/* ---------- chat & misc ---------- */

.site-chat-message,
.chat-message,
.tbs-msg {
  animation: tb-msg-in 0.35s var(--tb-ease-out) backwards;
}
@keyframes tb-msg-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

.twm-tab--active {
  animation: tb-tab-pop 0.3s var(--tb-ease-spring);
}
@keyframes tb-tab-pop {
  from { transform: scale(0.94); }
}
.twm-body > *,
.twm-form > * {
  animation: tb-rise 0.35s var(--tb-ease-out) backwards;
}
.twm-body > *:nth-child(2), .twm-form > *:nth-child(2) { animation-delay: 0.04s; }
.twm-body > *:nth-child(3), .twm-form > *:nth-child(3) { animation-delay: 0.08s; }
.twm-body > *:nth-child(4), .twm-form > *:nth-child(4) { animation-delay: 0.12s; }
.twm-body > *:nth-child(n + 5), .twm-form > *:nth-child(n + 5) { animation-delay: 0.16s; }

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html .tb-reveal:not(.tb-in) {
    opacity: 1;
    transform: none;
  }
}
