/* Track B Commercial Spine2D UI Motion CSS Presets v2.9 / UI Vault Contract v2.2
 * -----------------------------------------------------------------------------------
 * Curves distilled from 2,323 commercial Spine UI & VFX rigs + 9 Colab UI Vault styles:
 *   - Snappy Pop: cubic-bezier(0.08, 0.65, 0.75, 1.0)
 *   - Smooth Idle: cubic-bezier(0.25, 0.0, 0.75, 1.0)
 *   - Snappy Close: cubic-bezier(0.42, 0.0, 1.0, 0.55)
 *   - 7 Play Store Visual Archetypes ([data-tb-archetype="..."])
 *   - 9 Colab UI Vault Style Profiles ([data-ui-vault-style="..."]) + --tb-slot-* tokens
 *   - Grounded bottom-anchor (50% 94%) for shelf/bench/pedestal units & pop-out busts
 *   - Portal tooltips (.tb-tooltip-portal z:9800), badge-safe bounds & sold-out hover cue
 *   - Independent CSS `scale`/`translate` keyframes preserve rotated card fans & skewed UI
 *   - Overflow-safe `.tb-cta-pulse` & `.tb-booster-btn` (never clips pop-out icons or badges)
 *   - WebView2 pointer-passthrough overlay + prefers-reduced-motion comfort guardrails
 */
:root {
  --tb-ease-snappy: cubic-bezier(0.08, 0.65, 0.75, 1.0);
  --tb-ease-inout:  cubic-bezier(0.25, 0.0, 0.75, 1.0);
  --tb-ease-close:  cubic-bezier(0.42, 0.0, 1.0, 0.55);
  --tb-ease-pop:    var(--tb-ease-snappy);
  --tb-squash-x:    1.18;
  --tb-squash-y:    0.88;
  --tb-rebound-x:   0.94;
  --tb-rebound-y:   1.06;
  --tb-open-ms:     520ms;
  --tb-close-ms:    330ms;
  --tb-stagger-ms:  85ms;
  --tb-stagger-casual: 67ms;
  --tb-stagger-rpg:    95ms;
  --tb-slot-z:      3;
}

/* 1-to-1 Play Store Visual Archetype Motion Physics Presets */
[data-tb-archetype="playstore_glossy_casual"] {
  --tb-squash-x: 1.21; --tb-squash-y: 0.85; --tb-rebound-x: 0.88; --tb-rebound-y: 1.07;
  --tb-open-ms: 520ms; --tb-close-ms: 330ms; --tb-stagger-ms: 67ms;
}
[data-tb-archetype="playstore_cartoon_vibrant"] {
  --tb-squash-x: 1.20; --tb-squash-y: 0.86; --tb-rebound-x: 0.91; --tb-rebound-y: 1.12;
  --tb-open-ms: 500ms; --tb-close-ms: 330ms; --tb-stagger-ms: 80ms;
}
[data-tb-archetype="hypercasual_toy_3d"] {
  --tb-squash-x: 1.24; --tb-squash-y: 0.82; --tb-rebound-x: 0.90; --tb-rebound-y: 1.12;
  --tb-open-ms: 460ms; --tb-close-ms: 280ms; --tb-stagger-ms: 60ms;
}
[data-tb-archetype="cozy_pastel_storybook"] {
  --tb-ease-pop: var(--tb-ease-inout);
  --tb-squash-x: 1.08; --tb-squash-y: 0.94; --tb-rebound-x: 0.97; --tb-rebound-y: 1.04;
  --tb-open-ms: 580ms; --tb-close-ms: 380ms; --tb-stagger-ms: 120ms;
}
[data-tb-archetype="modern_tactical_bright"] {
  --tb-squash-x: 1.16; --tb-squash-y: 0.88; --tb-rebound-x: 0.94; --tb-rebound-y: 1.08;
  --tb-open-ms: 500ms; --tb-close-ms: 330ms; --tb-stagger-ms: 95ms;
}
[data-tb-archetype="arcade_neon_kinetic"] {
  --tb-squash-x: 1.18; --tb-squash-y: 0.88; --tb-rebound-x: 0.94; --tb-rebound-y: 1.08;
  --tb-open-ms: 440ms; --tb-close-ms: 280ms; --tb-stagger-ms: 85ms;
}
[data-tb-archetype="dark_arcane_rpg"] {
  --tb-squash-x: 1.18; --tb-squash-y: 0.90; --tb-rebound-x: 0.95; --tb-rebound-y: 1.06;
  --tb-open-ms: 520ms; --tb-close-ms: 330ms; --tb-stagger-ms: 100ms;
}

/* 1-to-1 Colab UI Vault Style Motion Physics & Slot Contract Defaults */
[data-ui-vault-style="tactical_angled_steel"] {
  --tb-squash-x: 1.14; --tb-squash-y: 0.90; --tb-rebound-x: 0.95; --tb-rebound-y: 1.06;
  --tb-open-ms: 440ms; --tb-close-ms: 280ms; --tb-stagger-ms: 85ms;
}
[data-ui-vault-style="cozy_stationery_craft"] {
  --tb-ease-pop: var(--tb-ease-inout);
  --tb-squash-x: 1.08; --tb-squash-y: 0.94; --tb-rebound-x: 0.97; --tb-rebound-y: 1.04;
  --tb-open-ms: 580ms; --tb-close-ms: 380ms; --tb-stagger-ms: 120ms;
}
[data-ui-vault-style="ornate_storybook_rpg"] {
  --tb-squash-x: 1.20; --tb-squash-y: 0.86; --tb-rebound-x: 0.91; --tb-rebound-y: 1.12;
  --tb-open-ms: 500ms; --tb-close-ms: 330ms; --tb-stagger-ms: 80ms;
}
[data-ui-vault-style="plush_stitched_casual"] {
  --tb-squash-x: 1.22; --tb-squash-y: 0.84; --tb-rebound-x: 0.88; --tb-rebound-y: 1.09;
  --tb-open-ms: 520ms; --tb-close-ms: 330ms; --tb-stagger-ms: 67ms;
}
[data-ui-vault-style="inked_parchment_roguelite"] {
  --tb-squash-x: 1.14; --tb-squash-y: 0.90; --tb-rebound-x: 0.95; --tb-rebound-y: 1.05;
  --tb-open-ms: 500ms; --tb-close-ms: 320ms; --tb-stagger-ms: 95ms;
}
[data-ui-vault-style="vibrant_popout_tycoon"] {
  --tb-squash-x: 1.24; --tb-squash-y: 0.82; --tb-rebound-x: 0.90; --tb-rebound-y: 1.12;
  --tb-open-ms: 460ms; --tb-close-ms: 280ms; --tb-stagger-ms: 60ms;
}
[data-ui-vault-style="steampunk_brass_rail"] {
  --tb-squash-x: 1.16; --tb-squash-y: 0.88; --tb-rebound-x: 0.94; --tb-rebound-y: 1.08;
  --tb-open-ms: 480ms; --tb-close-ms: 310ms; --tb-stagger-ms: 90ms;
}
[data-ui-vault-style="cyber_pcb_terminal"] {
  --tb-ease-pop: cubic-bezier(0.16, 1.0, 0.3, 1.0);
  --tb-squash-x: 1.06; --tb-squash-y: 0.96; --tb-rebound-x: 0.99; --tb-rebound-y: 1.02;
  --tb-open-ms: 260ms; --tb-close-ms: 180ms; --tb-stagger-ms: 45ms;
}
[data-ui-vault-style="indigo_arcade_gloss"] {
  --tb-squash-x: 1.22; --tb-squash-y: 0.84; --tb-rebound-x: 0.90; --tb-rebound-y: 1.10;
  --tb-open-ms: 360ms; --tb-close-ms: 240ms; --tb-stagger-ms: 65ms;
}

@keyframes tbModalOpen {
  0%   { opacity: 0; translate: 0 56px; scale: 0.22 0.22; }
  44%  { opacity: 1; translate: 0 -8px; scale: 1.07 0.94; }
  74%  { opacity: 1; translate: 0 2px;  scale: 0.97 1.03; }
  100% { opacity: 1; translate: 0 0;    scale: 1 1; }
}

@keyframes tbModalClose {
  0%   { opacity: 1; translate: 0 0;     scale: 1 1; }
  22%  { opacity: 1; translate: 0 4px;   scale: 1.04 0.95; }
  100% { opacity: 0; translate: 0 -22px; scale: 0.86 0.92; }
}

/* Independent CSS `scale` & `translate` preserve existing `transform: rotate(...)` / `skewX(-8deg)`! */
@keyframes tbRubberPop {
  0%   { opacity: 0; scale: 0.20 0.20; }
  38%  { opacity: 1; scale: var(--tb-squash-x, 1.21) var(--tb-squash-y, 0.85); }
  68%  { opacity: 1; scale: var(--tb-rebound-x, 0.93) var(--tb-rebound-y, 1.08); }
  100% { opacity: 1; scale: 1 1; }
}

@keyframes tbStaggerCardIn {
  0%   { opacity: 0; translate: 0 22px; scale: 0.26 0.26; }
  40%  { opacity: 1; translate: 0 -4px; scale: var(--tb-squash-x, 1.18) var(--tb-squash-y, 0.88); }
  70%  { opacity: 1; translate: 0 1px;  scale: var(--tb-rebound-x, 0.94) var(--tb-rebound-y, 1.06); }
  100% { opacity: 1; translate: 0 0;    scale: 1 1; }
}

@keyframes tbChestReveal {
  0%   { scale: 1 1; rotate: 0deg; translate: 0 0; }
  12%  { scale: 1.08 0.90; rotate: -4deg; translate: 0 0; }
  24%  { scale: 1.10 0.88; rotate: 4deg; translate: 0 0; }
  42%  { scale: 1.22 0.84; rotate: 0deg; translate: 0 -10px; }
  72%  { scale: 0.95 1.06; rotate: 0deg; translate: 0 0; }
  100% { scale: 1 1; rotate: 0deg; translate: 0 0; }
}

@keyframes tbHeartbeatCTA {
  0%, 72%, 100% { scale: 1 1; }
  80%           { scale: 1.06 0.95; }
  88%           { scale: 0.97 1.04; }
  94%           { scale: 1.02 0.99; }
}

@keyframes tbGlintSweep {
  0%        { background-position: 165% 0; opacity: 0; }
  12%       { opacity: 0.88; }
  48%       { background-position: -65% 0; opacity: 0; }
  100%      { background-position: -65% 0; opacity: 0; }
}

/* Idle-Hidden WebView2 VFX Overlay Layer */
.tb-vfx-overlay {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
  display: none;
}

/* Spine-DNA Choreography Utility Classes */
.tb-modal-open   { animation: tbModalOpen var(--tb-open-ms, 520ms) var(--tb-ease-pop) both; will-change: transform, scale, translate, opacity; }
.tb-modal-close  { animation: tbModalClose var(--tb-close-ms, 330ms) var(--tb-ease-close) forwards; will-change: transform, scale, translate, opacity; }
.tb-rubber-pop   { animation: tbRubberPop 440ms var(--tb-ease-pop) both; }
.tb-stagger-in   { animation: tbStaggerCardIn 440ms var(--tb-ease-pop) both; }
.tb-chest-reveal { animation: tbChestReveal 860ms var(--tb-ease-pop) both; transform-origin: 50% 80%; }

/* Tactile 3D Pressable Button */
.tb-btn-juicy {
  transition: transform 95ms var(--tb-ease-snappy), scale 95ms var(--tb-ease-snappy), translate 95ms var(--tb-ease-snappy), filter 120ms ease;
  user-select: none;
  cursor: pointer;
  touch-action: manipulation;
}
.tb-btn-juicy:hover  { filter: brightness(1.06); }
.tb-btn-juicy:active { translate: 0 2px; scale: 0.94 0.96; }

/* Pop-Out-Safe Specular Glint CTA (NO overflow:hidden -> never clips pop-out icons or .notify-badge!) */
.tb-cta-pulse {
  animation: tbHeartbeatCTA 2.4s var(--tb-ease-inout) infinite;
  position: relative;
  overflow: visible;
}
.tb-cta-pulse::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  clip-path: inset(0);
  background: linear-gradient(
    114deg,
    transparent 0%,
    transparent 35%,
    rgba(255, 255, 255, 0.56) 49%,
    rgba(255, 255, 255, 0.72) 51%,
    transparent 65%,
    transparent 100%
  );
  background-size: 260% 100%;
  background-repeat: no-repeat;
  animation: tbGlintSweep 2.6s var(--tb-ease-snappy) infinite;
  pointer-events: none;
}

.tb-counter-num {
  font-variant-numeric: tabular-nums;
}

/* Round 5 Spatial Law: Grounded Bottom-Anchor (50% 94%) for Shelf/Bench/Pedestal Units & Bust Portraits */
.tb-grounded,
.tb-shelf-unit,
.tb-bust-popout,
[data-tb-grounded="true"] {
  transform-origin: 50% 94%;
  overflow: visible;
}
@keyframes tbGroundedPop {
  0%   { opacity: 0; scale: 0.76 0.66; }
  42%  { opacity: 1; scale: var(--tb-squash-x, 1.14) var(--tb-squash-y, 0.88); }
  74%  { opacity: 1; scale: var(--tb-rebound-x, 0.95) var(--tb-rebound-y, 1.05); }
  100% { opacity: 1; scale: 1 1; }
}
.tb-grounded-pop {
  transform-origin: 50% 94%;
  animation: tbGroundedPop 380ms var(--tb-ease-pop) both;
}

/* Round 5 Spatial Law: Compact Square Booster Buttons (68-84px) — Unclipped Badges + Center-Safe Hit-Test */
.tb-booster-btn {
  position: relative;
  overflow: visible;
  transform-origin: 50% 50%;
}
.tb-booster-btn > .notify-badge,
.tb-booster-btn > .tool-count {
  z-index: 8;
  pointer-events: none;
}

/* Round 6 Micro-Interactions: PCB Hardware Pulse, Tactile Puzzle Pick & One-Shot Forge Glint */
@keyframes tbPcbPulse {
  0%   { scale: 1 1; }
  38%  { scale: 1.06 1.06; }
  100% { scale: 1 1; }
}
.tb-pcb-pulse {
  animation: tbPcbPulse 320ms cubic-bezier(0.16, 1.0, 0.3, 1.0) both;
}
.tb-puzzle-picked {
  scale: 1.04 1.04;
  transition: scale 80ms cubic-bezier(0.25, 0.46, 0.45, 0.94), translate 80ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
@keyframes tbForgeArrowFlash {
  0%   { scale: 0.9 0.9; filter: brightness(1); }
  45%  { scale: 1.16 1.16; filter: brightness(1.45); }
  100% { scale: 1 1; filter: brightness(1); }
}
.tb-forge-arrow-flash {
  animation: tbForgeArrowFlash 320ms cubic-bezier(0.16, 1.0, 0.3, 1.0) both;
}
@keyframes tbGlintOnce {
  0%   { background-position: 170% 0; opacity: 0; }
  18%  { opacity: 0.92; }
  100% { background-position: -70% 0; opacity: 0; }
}
.tb-glint-once {
  position: relative;
  overflow: visible;
}
.tb-glint-once::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  clip-path: inset(0);
  background: linear-gradient(
    114deg,
    transparent 0%,
    transparent 36%,
    rgba(255, 255, 255, 0.65) 49%,
    rgba(255, 255, 255, 0.82) 51%,
    transparent 64%,
    transparent 100%
  );
  background-size: 260% 100%;
  background-repeat: no-repeat;
  animation: tbGlintOnce 520ms var(--tb-ease-snappy) 1 forwards;
  pointer-events: none;
  z-index: 6;
}

/* Module 13 VPS Field Invariants: Anti-Buried Portal Tooltip, Badge Bounds & Sold-Out Hover */
.tb-tooltip-portal {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 9800;
  pointer-events: none;
  max-width: min(320px, calc(100vw - 16px));
  padding: 7px 11px;
  border-radius: 8px;
  background: rgba(14, 18, 28, 0.96);
  border: 1.5px solid rgba(251, 191, 36, 0.62);
  color: #F8FAFC;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.55);
  opacity: 0;
  visibility: hidden;
  transition: opacity 110ms ease;
}
.tb-tooltip-portal.is-visible {
  opacity: 1;
  visibility: visible;
}
.tb-badge-safe {
  position: relative;
  overflow: visible;
}
.tb-badge-safe > .notify-badge {
  z-index: 8;
  pointer-events: none;
  right: -4px;
  top: -6px;
}
.tb-sold-out-hover {
  cursor: not-allowed;
  transition: filter 120ms ease, scale 120ms ease;
}
.tb-sold-out-hover:hover {
  filter: brightness(1.08);
  scale: 1.02 1.02;
}
.tb-hit-flash {
  filter: brightness(1.82) saturate(1.18);
}

/* Group B: Slot Border VFX Canvas Host + Lightweight CSS Fallback Borders */
.tb-slot-vfx-host {
  position: relative;
}
.tb-slot-vfx-canvas {
  position: absolute;
  pointer-events: none;
  z-index: var(--tb-slot-z, 3);
}
@keyframes tbSlotGlowPulse {
  0%, 100% { box-shadow: 0 0 8px rgba(251, 191, 36, 0.55), inset 0 0 6px rgba(251, 191, 36, 0.30); }
  50%      { box-shadow: 0 0 18px rgba(251, 191, 36, 0.92), inset 0 0 10px rgba(254, 240, 138, 0.50); }
}
@keyframes tbSlotFlamePulse {
  0%, 100% { box-shadow: 0 0 10px rgba(249, 115, 22, 0.65), inset 0 0 8px rgba(253, 186, 116, 0.35); }
  50%      { box-shadow: 0 0 22px rgba(239, 68, 68, 0.95), 0 -4px 16px rgba(251, 191, 36, 0.72), inset 0 0 12px rgba(254, 215, 170, 0.55); }
}
@keyframes tbSlotLightningPulse {
  0%, 100% { box-shadow: 0 0 9px rgba(56, 189, 248, 0.62), inset 0 0 7px rgba(125, 211, 252, 0.32); }
  45%      { box-shadow: 0 0 20px rgba(34, 211, 238, 0.98), inset 0 0 12px rgba(224, 242, 254, 0.60); }
  55%      { box-shadow: 0 0 6px rgba(56, 189, 248, 0.42), inset 0 0 4px rgba(125, 211, 252, 0.22); }
}
@keyframes tbSlotPrismaticHue {
  0%   { filter: hue-rotate(0deg); }
  100% { filter: hue-rotate(360deg); }
}
.tb-slot-border-chaser    { animation: tbSlotGlowPulse 1.8s var(--tb-ease-inout) infinite; }
.tb-slot-border-flame     { animation: tbSlotFlamePulse 1.4s var(--tb-ease-inout) infinite; }
.tb-slot-border-lightning { animation: tbSlotLightningPulse 1.2s steps(6, end) infinite; }
.tb-slot-border-prismatic { animation: tbSlotGlowPulse 1.5s var(--tb-ease-inout) infinite, tbSlotPrismaticHue 3.6s linear infinite; }

/* Group C / Title Showcase: Living Spine2D-Style Breathing Hero Portrait + Soft Edge Feather */
@keyframes tbHeroBreath {
  0%, 100% { transform: translate3d(0, 0px, 0) scale(1.000, 1.000) rotate(0deg); }
  30%      { transform: translate3d(0, -3.5px, 0) scale(1.018, 0.992) rotate(-0.55deg); }
  65%      { transform: translate3d(0, -1.5px, 0) scale(0.996, 1.014) rotate(0.65deg); }
}
.tb-hero-portrait-live {
  transform-origin: 50% 92%;
  animation: tbHeroBreath 3.2s var(--tb-ease-inout) infinite;
  will-change: transform;
}
.tb-portrait-feather {
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, #000 76%, transparent 100%), linear-gradient(to right, transparent 0%, #000 6%, #000 88%, transparent 100%);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(to bottom, #000 0%, #000 76%, transparent 100%), linear-gradient(to right, transparent 0%, #000 6%, #000 88%, transparent 100%);
  mask-composite: intersect;
}
.tb-portrait-fx-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 4;
}

/* Accessibility & Comfort Guardrail */
@media (prefers-reduced-motion: reduce) {
  .tb-modal-open,
  .tb-modal-close,
  .tb-rubber-pop,
  .tb-stagger-in,
  .tb-chest-reveal,
  .tb-cta-pulse,
  .tb-cta-pulse::after,
  .tb-slot-border-chaser,
  .tb-slot-border-flame,
  .tb-slot-border-lightning,
  .tb-slot-border-prismatic,
  .tb-hero-portrait-live,
  .tb-grounded-pop,
  .tb-pcb-pulse,
  .tb-forge-arrow-flash,
  .tb-glint-once::after {
    animation: none !important;
  }
  .tb-btn-juicy,
  .tb-puzzle-picked {
    transition: none !important;
  }
}
