/* Motion rules for the clinic site. CSS only. Everything sits inside the
   no-preference query, so visitors who ask for reduced motion get no animation. */
@media (prefers-reduced-motion: no-preference) {
  :root {
    --motion-ease-out: cubic-bezier(0.23, 1, 0.32, 1);
    --motion-ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
    --motion-enter: 200ms; /* rule 2: dropdown open, inside 150-250ms */
    --motion-exit: 160ms;  /* rule 15: exits 20% shorter than enters */
  }

  /* Rule 1: entrance uses ease-out (Elementor fadeIn, treatments accordion). */
  .animated.fadeIn {
    animation-timing-function: var(--motion-ease-out);
  }

  /* Rules 4, 13, 14: press-scale on buttons, links styled as buttons, menu toggle,
     carousel arrows and pagination dots. `scale` is used (not transform) so it
     composes with Elementor's translateY on the arrows and the grow hover.
     No transition while held; the release eases back. */
  .elementor-button,
  .elementor-button-link,
  .wp-block-button__link,
  .wpforms-submit,
  #contact-submit,
  .ast-button {
    transition: background-color 0.3s, border-color 0.3s, color 0.3s, box-shadow 0.3s,
      scale 160ms var(--motion-ease-out);
  }
  .elementor-button:active,
  .elementor-button-link:active,
  .wp-block-button__link:active,
  .wpforms-submit:active,
  #contact-submit:active,
  .ast-button:active {
    scale: 0.97;
    transition: background-color 0.3s, border-color 0.3s, color 0.3s, box-shadow 0.3s;
  }

  .main-header-menu-toggle,
  .elementor-swiper-button,
  .swiper-button-prev,
  .swiper-button-next,
  .swiper-pagination-bullet {
    transition: scale 160ms var(--motion-ease-out);
  }
  .main-header-menu-toggle:active,
  .elementor-swiper-button:active,
  .swiper-button-prev:active,
  .swiper-button-next:active,
  .elementor-swiper-button { transform-origin: 50% 0; }
  .swiper-pagination-bullet:active {
    scale: 0.97;
    transition: none;
  }

  /* Rule 13: Elementor social-icon hover grow uses ease-out, not an overshoot curve. */
  .elementor-animation-grow {
    transition-duration: 0.3s;
    transition-timing-function: var(--motion-ease-out);
    transition-property: transform, scale;
  }
  .elementor-animation-grow:active {
    scale: 0.97;
    transition-property: transform;
  }

  /* Rules 2, 10, 11, 12: mobile menu dropdown. Astra shows the menu by toggling
     body.ast-main-header-nav-open, which switches the content from display:none to block.
     Opacity and scale transition, and @starting-style gives the entry state, so it
     opens from the toggle (top right) at 0.95 and closes back toward it, faster. */
  .ast-header-break-point .ast-mobile-header-wrap .ast-mobile-header-content {
    opacity: 0;
    transform: scale(0.95);
    transform-origin: top right;
    pointer-events: none;
    transition: opacity var(--motion-exit) var(--motion-ease-out),
      transform var(--motion-exit) var(--motion-ease-out),
      display var(--motion-exit) allow-discrete;
  }
  .ast-main-header-nav-open.ast-header-break-point .ast-mobile-header-wrap .ast-mobile-header-content {
    opacity: 1;
    transform: none;
    pointer-events: auto;
    transition: opacity var(--motion-enter) var(--motion-ease-out),
      transform var(--motion-enter) var(--motion-ease-out),
      display var(--motion-enter) allow-discrete;
  }
  @starting-style {
    .ast-main-header-nav-open.ast-header-break-point .ast-mobile-header-wrap .ast-mobile-header-content {
      opacity: 0;
      transform: scale(0.95);
    }
  }

  /* Rules 3, 6: menu items settle in 30ms steps, capped at six. */
  @keyframes motion-item-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: none; }
  }
  .ast-main-header-nav-open.ast-header-break-point .ast-mobile-header-content .main-header-menu > .menu-item {
    animation: motion-item-in 200ms var(--motion-ease-out) both;
  }
  .ast-main-header-nav-open .ast-mobile-header-content .main-header-menu > .menu-item:nth-child(1) { animation-delay: 0ms; }
  .ast-main-header-nav-open .ast-mobile-header-content .main-header-menu > .menu-item:nth-child(2) { animation-delay: 30ms; }
  .ast-main-header-nav-open .ast-mobile-header-content .main-header-menu > .menu-item:nth-child(3) { animation-delay: 60ms; }
  .ast-main-header-nav-open .ast-mobile-header-content .main-header-menu > .menu-item:nth-child(4) { animation-delay: 90ms; }
  .ast-main-header-nav-open .ast-mobile-header-content .main-header-menu > .menu-item:nth-child(5) { animation-delay: 120ms; }
  .ast-main-header-nav-open .ast-mobile-header-content .main-header-menu > .menu-item:nth-child(n+6) { animation-delay: 150ms; }

  /* Rules 16, 18: menu toggle icon swap (hamburger <-> close). Astra swaps the two
     SVGs with display, so the incoming icon fades in with a blur. The outgoing icon
     is removed at once; a true overlap would need both icons kept in layout. */
  @keyframes motion-icon-in {
    from { opacity: 0; filter: blur(3px); transform: scale(0.8); }
    to { opacity: 1; filter: blur(0); transform: none; }
  }
  .main-header-menu-toggle.toggled .ast-close-svg {
    animation: motion-icon-in 160ms var(--motion-ease-out) both;
  }

  /* Rule 9: carousel slide moves ease-in-out. */
  .swiper-wrapper {
    transition-timing-function: var(--motion-ease-in-out);
  }

  /* Rule 8: success pulse. Added to #contact-status by contact-form.js on a 200. */
  @keyframes motion-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.03); }
    100% { transform: scale(1); }
  }
  #contact-status.is-success {
    animation: motion-pulse 360ms var(--motion-ease-out);
  }
}
