/* Shared public/EAP motion. No hidden starting states or layout-changing motion. */
@media (prefers-reduced-motion: no-preference) {
  :root {
    --et-motion-ease: cubic-bezier(.2, .7, .2, 1);
  }

  :is(.button, .action-button, .portal-primary, .portal-secondary) {
    transition: background-color 180ms ease, border-color 180ms ease,
      box-shadow 180ms ease, color 180ms ease, translate 180ms var(--et-motion-ease);
  }

  :is(.desktop-nav, .top-actions, .portal-navigation) a {
    transition: color 180ms ease, background-color 180ms ease;
  }

  :is(.service-card, .team-card, .team-profile-card, .resource-card,
      .library-topic-card, .eap-recommended-card, .eap-content-image-card,
      .portal-resource-row, .eap-manager-popular-card) {
    transition: border-color 220ms ease, background-color 220ms ease,
      box-shadow 220ms ease, transform 220ms var(--et-motion-ease);
  }

  :is(.mobile-drawer:not([hidden]) .mobile-drawer-panel,
      .eap-mobile-drawer:not([hidden])) {
    animation: et-menu-enter 240ms var(--et-motion-ease) both;
  }

  .portal-manager-menu[open] > :not(summary) {
    animation: et-disclosure-enter 180ms var(--et-motion-ease) both;
  }

  details.faq-card[open] > :not(summary) {
    animation: et-disclosure-enter 240ms var(--et-motion-ease) both;
  }

  .menu-toggle span:not(.sr-only), .eap-mobile-menu-button span {
    transition: rotate 180ms ease, translate 180ms ease, opacity 180ms ease;
  }

  :is(.menu-toggle, .eap-mobile-menu-button)[aria-expanded="true"] span:nth-child(1) {
    translate: 0 7px;
    rotate: 45deg;
  }

  :is(.menu-toggle, .eap-mobile-menu-button)[aria-expanded="true"] span:nth-child(2) {
    opacity: 0;
  }

  :is(.menu-toggle, .eap-mobile-menu-button)[aria-expanded="true"] span:nth-child(3) {
    translate: 0 -7px;
    rotate: -45deg;
  }

  @media (max-width: 1079px) {
    .portal-navigation:not([hidden]) {
      animation: et-disclosure-enter 200ms var(--et-motion-ease) both;
    }
  }

  @media (hover: hover) and (pointer: fine) {
    :is(.button, .action-button, .portal-primary, .portal-secondary):not(:focus-visible, form *, .eap-crisis-page *, .eap-booking-marketing-page *):hover {
      translate: 0 -2px;
    }

    :is(.library-topic-card, .eap-recommended-card, .eap-content-image-card,
        .portal-resource-row, .eap-manager-popular-card):hover {
      transform: translateY(-2px);
    }
  }

  :is(.button, .action-button, .portal-primary, .portal-secondary):active {
    translate: 0 0;
  }

  /* Keep all controls still while they have keyboard focus. */
  :is(.button, .action-button, .portal-primary, .portal-secondary):focus-visible {
    translate: none;
  }

  :is(.service-card, .team-card, .resource-card, .library-topic-card,
      .eap-recommended-card, .eap-content-image-card, .portal-resource-row,
      .eap-manager-popular-card):focus-visible {
    /* Override existing tenant/portal hover-and-focus lifts, including ID-scoped rules. */
    transform: none !important;
  }
}

@keyframes et-menu-enter {
  from { opacity: .6; translate: 12px 0; }
  to { opacity: 1; translate: 0 0; }
}

@keyframes et-disclosure-enter {
  from { opacity: .6; translate: 0 -4px; }
  to { opacity: 1; translate: 0 0; }
}

/* Also cover existing site/portal hover effects and native page transitions. */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }

  :is(.button, .action-button, .portal-primary, .portal-secondary,
      .service-card, .team-card, .resource-card, .library-topic-card,
      .eap-recommended-card, .eap-content-image-card, .portal-resource-row,
      .eap-manager-popular-card, .eap-popular-topic, .eap-dashboard-action-card,
      .eap-contact-action):is(:hover, :focus-visible) {
    /* Existing portal selectors include IDs; accessibility must take precedence. */
    transform: none !important;
    translate: none !important;
  }
}
