/**
 * BIOPATRIOT — Subtle GPU Micro-UX Patch (V7A «Лазурь»)
 *
 * Philosophy:
 * - Subtle, tactile, Apple / Telegram / Samokat level responsiveness.
 * - Strictly compositor-only animations (`transform`, `opacity`) + `allow-discrete`
 *   for `[hidden]` overlays. Zero layout/paint thrashing, 60 FPS on entry-level Android.
 * - Zero PHP changes, zero impact on WooCommerce / CDEK / Tochka Bank handlers.
 * - Full `prefers-reduced-motion: reduce` support.
 */

/* ==========================================================================
   1. TACTILE SPRING TAP (:active scale 0.97 in 85ms, soft 140ms release)
   ========================================================================== */
.bp-btn,
.woocommerce button.button,
.woocommerce a.button,
.woocommerce input.button,
a.bpca-add,
.bpca-add,
.bp-product-buy-btn,
.bp-cart-dock-btn,
.bp-rf-tab,
.bp-header__cart,
.bp-header__account,
.bp-nav__link,
.bp-drawer-link,
.bp-shop-app-strip,
.bp-thankyou-btn,
.bp-portal-btn,
.bp-portal-tab-btn,
.bp-co-coupon-toggle,
.bp-footer__social {
  transition:
    transform 140ms cubic-bezier(0.22, 1, 0.36, 1),
    opacity 140ms ease,
    background-color 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    box-shadow 160ms ease;
  transform-origin: center;
}

.bp-btn:not(:disabled):not([aria-disabled="true"]):active,
.woocommerce button.button:not(:disabled):active,
.woocommerce a.button:not([aria-disabled="true"]):active,
.woocommerce input.button:not(:disabled):active,
a.bpca-add:not([aria-disabled="true"]):active,
.bpca-add:not([aria-disabled="true"]):active,
.bp-product-buy-btn:not(:disabled):active,
.bp-rf-tab:active,
.bp-header__cart:active,
.bp-header__account:active,
.bp-nav__link:active,
.bp-drawer-link:active,
.bp-thankyou-btn:active,
.bp-portal-btn:not(:disabled):active,
.bp-portal-tab-btn:active,
.bp-co-coupon-toggle:active,
.bp-footer__social:active,
#bp-cart-dock:active .bp-cart-dock-btn {
  transform: scale(0.97);
  transition-duration: 85ms;
  transition-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1);
}

.bp-shop-app-strip:active {
  transform: scale(0.985);
  transition-duration: 85ms;
}

/* Mobile menu button preserves translateY(-50%) vertical centering */
.bp-header__menu-btn {
  transition:
    transform 140ms cubic-bezier(0.22, 1, 0.36, 1),
    background-color 160ms ease,
    border-color 160ms ease,
    color 160ms ease;
}

@media (max-width: 767px) {
  .bp-header__menu-btn:active {
    transform: translateY(-50%) scale(0.93);
    transition-duration: 85ms;
  }
}

/* Stepper +/- controls (compact tap targets) */
.bpca-step-btn,
.bp-qty-btn,
.quantity .minus,
.quantity .plus {
  transition:
    transform 130ms cubic-bezier(0.22, 1, 0.36, 1),
    background-color 140ms ease,
    opacity 130ms ease;
  transform-origin: center;
}

.bpca-step-btn:not(:disabled):active,
.bp-qty-btn:not(:disabled):active,
.quantity .minus:not(:disabled):active,
.quantity .plus:not(:disabled):active {
  transform: scale(0.92);
  transition-duration: 80ms;
}

/* Product cards compress only when tapping photo or title, not +/- buttons */
.bp-product-card {
  transition:
    transform 150ms cubic-bezier(0.22, 1, 0.36, 1),
    border-color 160ms ease,
    box-shadow 160ms ease;
  transform-origin: center;
}

.bp-product-card:has(> .bp-product-card__media:active, .bp-product-card__title a:active),
.bp-akcii-card:active,
.bp-app-benefit-card:active {
  transform: scale(0.975);
  transition-duration: 85ms;
}

/* Mobile tabbar tactile press smoothness */
@media (max-width: 767px) {
  .bp-tabbar-item {
    transition:
      transform 140ms cubic-bezier(0.22, 1, 0.36, 1),
      opacity 140ms ease,
      color 140ms ease,
      background-color 140ms ease;
  }

  .bp-tabbar-item:active,
  .bp-tabbar-item.is-tapped {
    transition-duration: 85ms;
  }
}

/* ==========================================================================
   2. SMOOTH «В КОРЗИНУ» <-> «− 1 ШТ. +» TRANSITION (130ms, 0px height jump)
   ========================================================================== */
@keyframes bpStepperEnter {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes bpAddRestore {
  from {
    opacity: 0.72;
    transform: scale(0.97);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.bp-product-card__actions .bpca-stepper,
.bp-product-cart-form .bpca-stepper {
  animation: bpStepperEnter 135ms cubic-bezier(0.22, 1, 0.36, 1) backwards;
  transform-origin: center;
}

.bp-product-card__actions .bpca-add {
  animation: bpAddRestore 130ms cubic-bezier(0.22, 1, 0.36, 1) backwards;
  transform-origin: center;
}

.bp-product-buy-btn {
  transition:
    opacity 135ms cubic-bezier(0.22, 1, 0.36, 1),
    transform 140ms cubic-bezier(0.22, 1, 0.36, 1),
    background-color 160ms ease,
    border-color 160ms ease;
}

@starting-style {
  .bp-product-buy-btn:not([hidden]) {
    opacity: 0.7;
    transform: scale(0.97);
  }
}

/* ==========================================================================
   3. CART BADGE POP-BOUNCE ON COUNT CHANGE (Odd/Even data-count alternation)
   ========================================================================== */
@keyframes bpBadgePopOdd {
  0% {
    transform: scale(0.84);
    opacity: 0.72;
  }
  55% {
    transform: scale(1.16);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes bpBadgePopEven {
  0% {
    transform: scale(0.84);
    opacity: 0.72;
  }
  55% {
    transform: scale(1.16);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.bp-tabbar-badge:not([hidden])[data-count$="1"],
.bp-tabbar-badge:not([hidden])[data-count$="3"],
.bp-tabbar-badge:not([hidden])[data-count$="5"],
.bp-tabbar-badge:not([hidden])[data-count$="7"],
.bp-tabbar-badge:not([hidden])[data-count$="9"],
.bp-header__cart .minicart-item-count[data-count$="1"]:not([data-count="0"]),
.bp-header__cart .minicart-item-count[data-count$="3"]:not([data-count="0"]),
.bp-header__cart .minicart-item-count[data-count$="5"]:not([data-count="0"]),
.bp-header__cart .minicart-item-count[data-count$="7"]:not([data-count="0"]),
.bp-header__cart .minicart-item-count[data-count$="9"]:not([data-count="0"]) {
  animation: bpBadgePopOdd 210ms cubic-bezier(0.22, 1, 0.36, 1);
  transform-origin: center;
}

.bp-tabbar-badge:not([hidden])[data-count$="0"],
.bp-tabbar-badge:not([hidden])[data-count$="2"],
.bp-tabbar-badge:not([hidden])[data-count$="4"],
.bp-tabbar-badge:not([hidden])[data-count$="6"],
.bp-tabbar-badge:not([hidden])[data-count$="8"],
.bp-header__cart .minicart-item-count[data-count$="2"],
.bp-header__cart .minicart-item-count[data-count$="4"],
.bp-header__cart .minicart-item-count[data-count$="6"],
.bp-header__cart .minicart-item-count[data-count$="8"],
.bp-header__cart .minicart-item-count[data-count$="0"]:not([data-count="0"]) {
  animation: bpBadgePopEven 210ms cubic-bezier(0.22, 1, 0.36, 1);
  transform-origin: center;
}

/* ==========================================================================
   4. STICKY CART DOCK (#bp-cart-dock) & MOBILE DRAWER SLIDE-UP / SLIDE-DOWN
   ========================================================================== */
@media (max-width: 767px) {
  #bp-cart-dock {
    opacity: 1;
    transform: translate3d(0, 0, 0);
    transition:
      opacity 180ms cubic-bezier(0.22, 1, 0.36, 1),
      transform 200ms cubic-bezier(0.22, 1, 0.36, 1),
      display 200ms allow-discrete;
  }

  #bp-cart-dock[hidden] {
    display: none;
    opacity: 0;
    transform: translate3d(0, 22px, 0);
    pointer-events: none;
  }

  @starting-style {
    #bp-cart-dock:not([hidden]) {
      opacity: 0;
      transform: translate3d(0, 22px, 0);
    }
  }

  #bp-mobile-menu-backdrop {
    opacity: 1;
    transition:
      opacity 170ms ease,
      display 170ms allow-discrete;
  }

  #bp-mobile-menu-backdrop[hidden] {
    display: none;
    opacity: 0;
  }

  @starting-style {
    #bp-mobile-menu-backdrop:not([hidden]) {
      opacity: 0;
    }
  }

  #bp-mobile-menu-drawer {
    opacity: 1;
    transform: translate3d(0, 0, 0);
    transition:
      opacity 175ms cubic-bezier(0.22, 1, 0.36, 1),
      transform 190ms cubic-bezier(0.22, 1, 0.36, 1),
      display 190ms allow-discrete;
  }

  #bp-mobile-menu-drawer[hidden] {
    display: none;
    opacity: 0;
    transform: translate3d(0, -10px, 0);
  }

  @starting-style {
    #bp-mobile-menu-drawer:not([hidden]) {
      opacity: 0;
      transform: translate3d(0, -10px, 0);
    }
  }
}

/* ==========================================================================
   5. SMOOTH CATEGORY FILTER PILLS FLOW (.bp-rf-tabs) & CARD REVEAL
   ========================================================================== */
.bp-rf-tab {
  position: relative;
  z-index: 0;
  overflow: hidden;
  isolation: isolate;
}

.bp-rf-tab::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: var(--bp-btn-primary-bg);
  box-shadow: var(--bp-btn-primary-shadow);
  opacity: 0;
  transform: scale(0.92);
  transition:
    opacity 180ms cubic-bezier(0.22, 1, 0.36, 1),
    transform 190ms cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
}

.bp-rf-tab.is-active {
  background: var(--bp-bg-surface-subtle);
}

.bp-rf-tab.is-active::before {
  opacity: 1;
  transform: scale(1);
}

@keyframes bpFilterCardIn {
  from {
    opacity: 0.7;
    transform: translate3d(0, 6px, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

.bp-products-grid .bp-product-card:not(.is-hidden):not(.bp-rf-hidden) {
  animation: bpFilterCardIn 160ms cubic-bezier(0.22, 1, 0.36, 1) backwards;
}

/* ==========================================================================
   6. DELICATE PRODUCT PHOTO FADE-IN & ACCOUNT «ОБНОВЛЯЕМ ДАННЫЕ…» PILL
   ========================================================================== */
.bp-product-card__img,
.bp-product-gallery__main {
  transition:
    opacity 240ms cubic-bezier(0.22, 1, 0.36, 1),
    transform 260ms cubic-bezier(0.22, 1, 0.36, 1);
}

.bp-img-pending {
  opacity: 0.01 !important;
  transform: scale(0.988);
}

.bp-img-ready {
  opacity: 1 !important;
  transform: scale(1);
}

@media (hover: hover) and (pointer: fine) {
  .bp-product-card:hover .bp-product-card__img:not(.bp-img-pending) {
    transform: scale(1.018);
  }
}

/* Smooth GPU pill without costly backdrop-filter blur on weak Android devices */
#bp-acc-sync-pill {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  background: rgba(15, 47, 42, 0.94) !important;
  transition:
    opacity 220ms cubic-bezier(0.22, 1, 0.36, 1),
    transform 220ms cubic-bezier(0.22, 1, 0.36, 1) !important;
}

/* ==========================================================================
   7. SMOOTH <details> ACCORDIONS & CLEAN INPUT FOCUS FEEDBACK
   ========================================================================== */
@keyframes bpDetailsBodyIn {
  from {
    opacity: 0;
    transform: translate3d(0, -4px, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

details > summary {
  transition:
    transform 140ms cubic-bezier(0.22, 1, 0.36, 1),
    background-color 150ms ease,
    color 150ms ease;
  -webkit-tap-highlight-color: transparent;
}

details > summary:active {
  transform: scale(0.99);
  transition-duration: 85ms;
}

details > summary::after {
  transition: transform 180ms cubic-bezier(0.22, 1, 0.36, 1);
}

details[open] > :not(summary) {
  animation: bpDetailsBodyIn 180ms cubic-bezier(0.22, 1, 0.36, 1) backwards;
}

/* Crisp focus feedback for theme & portal inputs without layout shift */
.bp-field-label,
.bp-profile-field__label,
.bp-portal-onb-field > span {
  display: inline-block;
  transition:
    transform 150ms cubic-bezier(0.22, 1, 0.36, 1),
    color 150ms ease;
}

.bp-field:focus-within .bp-field-label,
.bp-profile-field:focus-within .bp-profile-field__label,
.bp-portal-onb-field:focus-within > span {
  color: var(--bp-accent-ink, #145e57);
  transform: translate3d(0, -1px, 0);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="tel"]:focus,
input[type="password"]:focus,
input[type="search"]:focus,
input[type="number"]:focus,
input[type="url"]:focus,
select:focus,
textarea:focus,
.bp-profile-field__input:focus {
  border-color: var(--bp-accent, #196c64) !important;
  box-shadow: 0 0 0 3px rgba(25, 108, 100, 0.16) !important;
}

/* ==========================================================================
   8. REDUCED MOTION ACCESSIBILITY
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .bp-btn,
  .woocommerce button.button,
  .woocommerce a.button,
  .woocommerce input.button,
  a.bpca-add,
  .bpca-add,
  .bpca-stepper,
  .bpca-step-btn,
  .bp-qty-btn,
  .quantity .minus,
  .quantity .plus,
  .bp-product-buy-btn,
  .bp-product-card,
  .bp-product-card__img,
  .bp-product-gallery__main,
  .bp-rf-tab,
  .bp-rf-tab::before,
  .bp-tabbar-item,
  .bp-tabbar-badge,
  .bp-header__cart,
  .bp-header__cart .minicart-item-count,
  .bp-header__account,
  .bp-nav__link,
  .bp-header__menu-btn,
  .bp-drawer-link,
  .bp-shop-app-strip,
  .bp-thankyou-btn,
  .bp-portal-btn,
  .bp-portal-tab-btn,
  .bp-co-coupon-toggle,
  .bp-footer__social,
  .bp-cart-dock-btn,
  #bp-cart-dock,
  #bp-mobile-menu-backdrop,
  #bp-mobile-menu-drawer,
  #bp-acc-sync-pill,
  #bp-acc-sync-pill > span,
  details > summary,
  details > summary::after,
  details[open] > :not(summary),
  .bp-field-label,
  .bp-profile-field__label,
  .bp-portal-onb-field > span {
    animation: none !important;
    transition: none !important;
  }

  .bp-btn:active,
  a.bpca-add:active,
  .bpca-add:active,
  .bp-product-buy-btn:active,
  .bp-rf-tab:active,
  .bp-header__cart:active,
  .bp-header__account:active,
  .bp-nav__link:active,
  .bp-drawer-link:active,
  .bp-shop-app-strip:active,
  .bp-thankyou-btn:active,
  .bp-portal-btn:active,
  .bp-portal-tab-btn:active,
  .bp-co-coupon-toggle:active,
  .bp-footer__social:active,
  .bpca-step-btn:active,
  .bp-qty-btn:active,
  .quantity .minus:active,
  .quantity .plus:active,
  .bp-product-card:active,
  .bp-product-card:hover .bp-product-card__img,
  .bp-akcii-card:active,
  .bp-app-benefit-card:active,
  .bp-tabbar-item:active,
  #bp-cart-dock:active .bp-cart-dock-btn,
  details > summary:active,
  .bp-field:focus-within .bp-field-label,
  .bp-profile-field:focus-within .bp-profile-field__label,
  .bp-portal-onb-field:focus-within > span {
    transform: none !important;
  }

  .bp-header__menu-btn:active {
    transform: translateY(-50%) !important;
  }
}
