/* =====================================================================
   TsD Technology — Motion System
   File: css/animations.css  (load AFTER style.css)

   CONTENTS
   01. Motion tokens (EDIT SPEED HERE)
   02. Keyframes
   03. Hero entrance & ambient motion
   04. Buttons: hover, press, sheen, ripple
   05. Navigation & dropdowns
   06. Cards & hover lift
   07. Modals & drawer
   08. Floating live chat & page motion
   09. Toasts, badges & feedback
   10. Scroll reveal
   11. Reduced motion (accessibility)
   ===================================================================== */

/* ==================== 01. MOTION TOKENS ==================== */
:root {
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --speed-fast: 0.18s;
  --speed-base: 0.3s;
  --speed-slow: 0.7s;
}

/* ==================== 02. KEYFRAMES ==================== */
@keyframes fadeUp      { from { opacity: 0; transform: translateY(22px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn      { from { opacity: 0; } to { opacity: 1; } }
@keyframes float       { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes glowDrift   { from { transform: translate(0, 0) scale(1); } to { transform: translate(-60px, 40px) scale(1.12); } }
@keyframes sheen       { 0% { transform: translateX(-160%) skewX(-20deg); } 35%, 100% { transform: translateX(420%) skewX(-20deg); } }
@keyframes buyPulse    { 0%, 100% { box-shadow: 0 8px 22px rgba(47, 91, 255, 0.32); } 50% { box-shadow: 0 8px 34px rgba(47, 91, 255, 0.62); } }
@keyframes pulseRing   { from { opacity: 0.7; transform: scale(1); } to { opacity: 0; transform: scale(1.65); } }
@keyframes dotPulse    { 0% { box-shadow: 0 0 0 0 rgba(25, 195, 125, 0.65); } 100% { box-shadow: 0 0 0 9px rgba(25, 195, 125, 0); } }
@keyframes ripple      { to { opacity: 0; transform: scale(3.2); } }
@keyframes badgePop    { 0% { transform: scale(0.4); } 70% { transform: scale(1.25); } 100% { transform: scale(1); } }
@keyframes toastIn     { from { opacity: 0; transform: translateX(40px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes toastOut    { to { opacity: 0; transform: translateX(40px) scale(0.96); } }
@keyframes shimmer     { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }
@keyframes shake       { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@keyframes successPop  { 0% { opacity: 0; transform: scale(0.3); } 100% { opacity: 1; transform: scale(1); } }

/* ==================== 03. HERO ENTRANCE & AMBIENT MOTION ==================== */
.hero-enter { animation: fadeUp var(--speed-slow) var(--ease-out) both; }
.hero-copy .hero-enter:nth-child(2) { animation-delay: 0.08s; }
.hero-copy .hero-enter:nth-child(3) { animation-delay: 0.16s; }
.hero-copy .hero-enter:nth-child(4) { animation-delay: 0.24s; }
.hero-copy .hero-enter:nth-child(5) { animation-delay: 0.32s; }
.hero-visual.hero-enter { animation-delay: 0.2s; }

.hero-glow { animation: glowDrift 11s ease-in-out infinite alternate; }
.float-slow   { animation: float 7s ease-in-out infinite; }
.float-medium { animation: float 5.5s ease-in-out 0.6s infinite; }
.float-fast   { animation: float 4.5s ease-in-out infinite; }
.live-dot { animation: dotPulse 1.8s ease-out infinite; }

.skeleton-card { animation: shimmer 1.4s ease-in-out infinite; }

/* ==================== 04. BUTTONS: HOVER, PRESS, SHEEN, RIPPLE ==================== */
.btn, .icon-btn, .filter-chip, .user-toggle, .social-row a, .social-row button {
  transition: transform var(--speed-base) var(--ease-spring),
              background-color var(--speed-fast) ease,
              border-color var(--speed-fast) ease,
              color var(--speed-fast) ease,
              box-shadow var(--speed-base) ease,
              filter var(--speed-fast) ease;
}
.btn:hover:not(:disabled), .icon-btn:hover, .filter-chip:hover { transform: translateY(-2px); }
.btn:active:not(:disabled), .icon-btn:active, .filter-chip:active { transform: translateY(0) scale(0.96); }
.btn:hover:not(:disabled) { filter: brightness(1.07); }
.btn .icon { transition: transform var(--speed-base) var(--ease-spring); }
.btn:hover .icon { transform: scale(1.12); }
a.btn:hover .icon:last-child:not(:first-child) { transform: translateX(4px); }

/* Moving light stripe */
.btn-sheen::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: -1;
  width: 30%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.42), transparent);
  transform: translateX(-160%) skewX(-20deg);
  animation: sheen 3.4s ease-in-out infinite;
  pointer-events: none;
}
.btn-sheen:disabled::after { animation: none; }

/* Attention pulse on every Buy Now button */
.btn-buy:not(:disabled) { animation: buyPulse 2.6s ease-in-out infinite; }

/* Ripple: js/app.js inserts <span class="ripple"> at the click point */
.ripple {
  position: absolute;
  z-index: -1;
  width: 80px;
  height: 80px;
  margin: -40px 0 0 -40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  transform: scale(0);
  animation: ripple 0.6s ease-out forwards;
  pointer-events: none;
}

.add-cart-btn:hover .plus-mark { animation: badgePop 0.4s var(--ease-spring); }

.copy-btn > span { transition: opacity var(--speed-fast) ease, transform var(--speed-base) var(--ease-spring); }
.copy-btn .copy-done { opacity: 0; transform: scale(0.6); }
.copy-btn.is-copied .copy-done { opacity: 1; transform: scale(1); }
.copy-btn.is-copied .copy-default { opacity: 0; }

/* ==================== 05. NAVIGATION & DROPDOWNS ==================== */
.site-header { transition: box-shadow var(--speed-base) ease; }
.nav-link { transition: color var(--speed-fast) ease; }
.nav-link::after {
  content: "";
  position: absolute;
  right: 0.7rem;
  bottom: 2px;
  left: 0.7rem;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--speed-base) var(--ease-out);
}
.nav-link:hover::after, .nav-link.is-active::after { transform: scaleX(1); }
.dropdown-toggle .icon { transition: transform var(--speed-base) var(--ease-out); }
.dropdown.is-open > [data-dropdown-toggle] > .icon:last-child { transform: rotate(180deg); }

.dropdown-menu, .primary-nav .dropdown-menu {
  transform: translateY(-8px) scale(0.97);
  transform-origin: top;
  transition: opacity var(--speed-fast) ease, transform var(--speed-base) var(--ease-out), visibility var(--speed-base);
}
.dropdown.is-open > .dropdown-menu { transform: none; }
.dropdown-menu a, .dropdown-menu button { transition: background-color var(--speed-fast) ease, padding var(--speed-base) var(--ease-out); }
.dropdown-menu a:hover, .dropdown-menu button:hover { padding-left: 1rem; }
.search { transition: border-color var(--speed-fast) ease, box-shadow var(--speed-base) ease; }
.search-results:not([hidden]) { animation: fadeUp var(--speed-base) var(--ease-out); }

@media (max-width: 1180px) {
  .primary-nav { transform: translateY(-10px); transition: opacity var(--speed-base) ease, transform var(--speed-base) var(--ease-out), visibility var(--speed-base); }
  .primary-nav.is-open { transform: none; }
  .nav-link::after { display: none; }
}

/* ==================== 06. CARDS & HOVER LIFT ==================== */
.product-card, .highlight, .step-card {
  transition: transform var(--speed-base) var(--ease-out),
              border-color var(--speed-base) ease,
              box-shadow var(--speed-base) ease,
              opacity var(--speed-slow) ease;
}
.product-card:hover { transform: translateY(-8px); }
.highlight:hover, .step-card:hover { transform: translateY(-4px); border-color: var(--color-primary); box-shadow: var(--shadow-md); }
.product-media img { transition: transform var(--speed-slow) var(--ease-out); }
.product-card:hover .product-media img { transform: scale(1.07); }
.highlight-icon { transition: transform var(--speed-base) var(--ease-spring); }
.highlight:hover .highlight-icon { transform: rotate(-8deg) scale(1.1); }
.gallery-thumb, .payment-card-body { transition: all var(--speed-base) var(--ease-out); }
.gallery-thumb:hover { transform: translateY(-3px); }
.footer-col > a:not(.brand) { transition: color var(--speed-fast) ease, transform var(--speed-base) var(--ease-out); }
.footer-col > a:not(.brand):hover { transform: translateX(4px); }
.social-row a:hover, .social-row button:hover { transform: translateY(-4px); box-shadow: var(--shadow-glow); }

/* js/app.js re-adds .is-switching when a gallery image changes */
.gallery-main img.is-switching { animation: fadeIn 0.35s ease; }
.payment-panel:not([hidden]) { animation: fadeUp var(--speed-base) var(--ease-out); }

/* ==================== 07. MODALS & DRAWER (SCALE + FADE) ==================== */
/* visibility is delayed on close so the exit animation can finish */
.modal { transition: visibility 0s linear var(--speed-base); }
.modal.is-open { transition-delay: 0s; }
.modal-backdrop { transition: opacity var(--speed-base) ease; }
.modal-dialog {
  transform: translateY(18px) scale(0.93);
  transition: opacity var(--speed-base) ease, transform var(--speed-base) var(--ease-out);
}
.modal.is-open .modal-dialog { transform: none; }

.drawer .drawer-panel { transform: translateX(100%); }
.drawer.is-open .drawer-panel { transform: none; }

@media (max-width: 620px) {
  .modal:not(.drawer) .modal-dialog { transform: translateY(60px) scale(0.97); }
  .modal.is-open:not(.drawer) .modal-dialog { transform: none; }
}

.form-error:not([hidden]) { animation: shake 0.35s ease; }
.checkout-success:not([hidden]) .success-mark { animation: successPop 0.6s var(--ease-spring) both; }
.checkout-success:not([hidden]) > :not(.success-mark) { animation: fadeUp var(--speed-slow) var(--ease-out) 0.15s both; }

/* ==================== 08. FLOATING LIVE CHAT ==================== */
.support-fab { transition: transform var(--speed-base) var(--ease-spring); }
.support-fab:hover { transform: scale(1.08); }
.support-fab:active { transform: scale(0.94); }
.support-fab::before {
  content: "";
  position: absolute;
  inset: 0;
  border: 2px solid var(--color-whatsapp);
  border-radius: 50%;
  animation: pulseRing 2.2s ease-out infinite;
  pointer-events: none;
}
.fab-tooltip {
  transform: translate(10px, -50%) scale(0.9);
  transform-origin: right;
  transition: opacity var(--speed-fast) ease, transform var(--speed-base) var(--ease-spring), visibility var(--speed-base);
}
.support-fab:hover .fab-tooltip, .support-fab:focus-visible .fab-tooltip { transform: translate(0, -50%) scale(1); }

/* Pages, tabs and rows */
.auth-card { animation: fadeUp var(--speed-slow) var(--ease-out) both; }
.tab-panel:not([hidden]) { animation: fadeUp 0.4s var(--ease-out); }
.side-nav a, .side-nav button, .tab-switch button, .status-btn { transition: background-color var(--speed-fast) ease, color var(--speed-fast) ease, transform var(--speed-base) var(--ease-spring); }
.status-btn:active { transform: scale(0.94); }
.order-card, .stat-card { transition: transform var(--speed-base) var(--ease-out), box-shadow var(--speed-base) ease; }
.order-card:hover, .stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }

/* ==================== 09. TOASTS, BADGES & FEEDBACK ==================== */
.toast { animation: toastIn 0.4s var(--ease-spring) both; }
.toast.is-leaving { animation: toastOut var(--speed-base) ease forwards; }
/* js/app.js re-adds .is-popping whenever the cart count changes */
.cart-badge.is-popping { animation: badgePop 0.45s var(--ease-spring); }

/* ==================== 10. SCROLL REVEAL ==================== */
/* Content is hidden only after js/app.js adds .js-reveal to <html>,
   so the page never stays blank if JavaScript fails to load. */
.js-reveal .reveal { opacity: 0; translate: 0 28px; }
.js-reveal .reveal.is-visible { opacity: 1; translate: 0 0; }
.reveal { transition: opacity var(--speed-slow) var(--ease-out), translate var(--speed-slow) var(--ease-out); }
/* Keep hover lift working on elements that are also revealed */
.product-card.reveal, .highlight.reveal, .step-card.reveal {
  transition: opacity var(--speed-slow) var(--ease-out),
              translate var(--speed-slow) var(--ease-out),
              transform var(--speed-base) var(--ease-out),
              border-color var(--speed-base) ease,
              box-shadow var(--speed-base) ease;
}
.highlight:nth-child(2), .step-card:nth-child(2) { transition-delay: 0.08s, 0.08s, 0s, 0s, 0s; }
.highlight:nth-child(3), .step-card:nth-child(3) { transition-delay: 0.16s, 0.16s, 0s, 0s, 0s; }
.highlight:nth-child(4) { transition-delay: 0.24s, 0.24s, 0s, 0s, 0s; }

/* ==================== 11. REDUCED MOTION (ACCESSIBILITY) ==================== */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
  }
}
