/* Quiet disclosure and dialog motion, written with Animate UI's tokens as plain CSS.
 * Site is static HTML, so the React package cannot be used here (see AI_HANDOFF.md).
 * Tokens: transition.disclosure 350ms ease.soft; transition.overlay 400ms ease.soft; transition.fade 200ms ease.out.
 * Everything is progressive: a browser without ::details-content, interpolate-size or allow-discrete keeps today's instant behaviour.
 * Reduced motion gets none of it. Layout, sizes and open/closed logic are untouched.
 */
@media (prefers-reduced-motion: no-preference) {
  :root {
    --am-soft: cubic-bezier(.215, .61, .355, 1);
    --am-out: cubic-bezier(.23, 1, .32, 1);
  }

  /* Disclosures: FAQ, shipment help and footer groups unfold instead of snapping. */
  @supports selector(details::details-content) and (interpolate-size: allow-keywords) {
    :is(.support-faq, .shipment-help, .store-footer) details {
      interpolate-size: allow-keywords;
    }
    :is(.support-faq, .shipment-help, .store-footer) details::details-content {
      block-size: 0;
      opacity: 0;
      overflow: clip;
      overflow-clip-margin: 8px; /* keeps focus rings of links inside from being cut */
      transition:
        block-size 350ms var(--am-soft),
        opacity 200ms var(--am-out),
        content-visibility 350ms allow-discrete;
    }
    :is(.support-faq, .shipment-help, .store-footer) details[open]::details-content {
      block-size: auto;
      opacity: 1;
    }
  }

  /* Native dialogs that had no entrance: driver help, PPM/S-BUS notice, product video. */
  :is(#driverHelpDialog, #ppmBusDialog, .product-video-dialog) {
    opacity: 1;
    scale: 1;
    transition:
      opacity 240ms var(--am-soft),
      scale 240ms var(--am-soft),
      overlay 240ms allow-discrete,
      display 240ms allow-discrete;
  }
  :is(#driverHelpDialog, #ppmBusDialog, .product-video-dialog):not([open]) {
    opacity: 0;
    scale: .96;
  }
  :is(#driverHelpDialog, #ppmBusDialog, .product-video-dialog)::backdrop {
    transition:
      opacity 300ms var(--am-soft),
      overlay 300ms allow-discrete,
      display 300ms allow-discrete;
  }
  :is(#driverHelpDialog, #ppmBusDialog, .product-video-dialog):not([open])::backdrop {
    opacity: 0;
  }
  @starting-style {
    :is(#driverHelpDialog, #ppmBusDialog, .product-video-dialog)[open] {
      opacity: 0;
      scale: .96;
    }
    :is(#driverHelpDialog, #ppmBusDialog, .product-video-dialog)[open]::backdrop {
      opacity: 0;
    }
  }
}
