/* Motion layer (loaded last): press feedback on every button and an entrance
   animation for every window. Additive only — it never changes layout, and it
   uses the individual `scale`/`translate` properties so it composes with the
   transforms the components already use. Everything is skipped when the visitor
   asks the system for reduced motion. */

:root {
  --motion-pop: cubic-bezier(0.34, 1.56, 0.64, 1);
  --motion-out: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---- Tap ripple (a small "water drop" at the pointer, drawn by motion.js) ---- */
.tap-ripple {
  position: fixed;
  z-index: 100000;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border-radius: 50%;
  pointer-events: none;
  border: 2px solid color-mix(in srgb, var(--gold-500, #d9b45b) 85%, transparent);
  background: color-mix(in srgb, var(--gold-400, #e4c16f) 28%, transparent);
  animation: tap-ripple 0.55s var(--motion-out) forwards;
}

@keyframes tap-ripple {
  from { scale: 0.4; opacity: 0.9; }
  to { scale: 3.2; opacity: 0; }
}

@keyframes tap-press {
  0% { scale: 1; }
  35% { scale: 0.93; }
  70% { scale: 1.03; }
  100% { scale: 1; }
}

@keyframes win-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes win-pop {
  from { opacity: 0; scale: 0.92; translate: 0 14px; }
  to { opacity: 1; scale: 1; translate: 0 0; }
}

@keyframes win-drop {
  from { opacity: 0; scale: 0.96; translate: 0 -10px; }
  to { opacity: 1; scale: 1; translate: 0 0; }
}

@keyframes item-in {
  from { opacity: 0; translate: 0 6px; }
  to { opacity: 1; translate: 0 0; }
}

@media (prefers-reduced-motion: no-preference) {
  /* Buttons: a short press bounce (class added by motion.js on click) */
  .is-tapped {
    animation: tap-press 0.34s var(--motion-out);
  }

  /* Modals: lightbox, media, Maqraa */
  .modal:not([hidden]) .modal__backdrop,
  .search-modal:not([hidden]) .search-modal__backdrop {
    animation: win-fade 0.25s ease both;
  }
  .modal:not([hidden]) .modal__dialog,
  .search-modal:not([hidden]) .search-modal__dialog {
    animation: win-pop 0.38s var(--motion-pop) both;
  }

  /* Menus that appear under their trigger */
  .accent-picker__menu:not([hidden]),
  .mega-menu:not([hidden]) {
    animation: win-drop 0.28s var(--motion-out) both;
  }
  .accent-picker__menu:not([hidden]) .accent-option {
    animation: item-in 0.3s var(--motion-out) both;
  }
  .accent-picker__menu:not([hidden]) .accent-option:nth-child(2) { animation-delay: 40ms; }
  .accent-picker__menu:not([hidden]) .accent-option:nth-child(3) { animation-delay: 80ms; }
  .accent-picker__menu:not([hidden]) .accent-option:nth-child(4) { animation-delay: 120ms; }

  /* Institutes / centres dropdowns: the panel already slides in; its rows follow one by one */
  .nav-dropdown[data-open="true"] .nav-dropdown__item,
  .nav-dropdown[data-open="true"] .nav-dropdown__section-title {
    animation: item-in 0.32s var(--motion-out) both;
  }
  .nav-dropdown[data-open="true"] .nav-dropdown__item:nth-child(2) { animation-delay: 30ms; }
  .nav-dropdown[data-open="true"] .nav-dropdown__item:nth-child(3) { animation-delay: 60ms; }
  .nav-dropdown[data-open="true"] .nav-dropdown__item:nth-child(4) { animation-delay: 90ms; }
  .nav-dropdown[data-open="true"] .nav-dropdown__item:nth-child(5) { animation-delay: 120ms; }
  .nav-dropdown[data-open="true"] .nav-dropdown__item:nth-child(6) { animation-delay: 150ms; }
  .nav-dropdown[data-open="true"] .nav-dropdown__item:nth-child(n + 7) { animation-delay: 180ms; }

  /* Floating share menu: buttons pop out in sequence */
  .sticky-share.is-active .sticky-share__btn {
    animation: win-pop 0.3s var(--motion-pop) both;
  }
  .sticky-share.is-active .sticky-share__btn:nth-child(2) { animation-delay: 40ms; }
  .sticky-share.is-active .sticky-share__btn:nth-child(3) { animation-delay: 80ms; }
  .sticky-share.is-active .sticky-share__btn:nth-child(4) { animation-delay: 120ms; }
  .sticky-share.is-active .sticky-share__btn:nth-child(5) { animation-delay: 160ms; }

  /* Mobile navigation panel */
  .site-header[data-menu-open="true"] .site-nav {
    animation: win-drop 0.3s var(--motion-out) both;
  }

  /* AI summary on news pages: its text rises in as the panel opens */
  .ai-summary-panel.is-open .ai-summary-panel__inner {
    animation: win-pop 0.4s var(--motion-out) both;
  }

  /* Flash messages */
  .flash-message {
    animation: win-drop 0.35s var(--motion-out) both;
  }
}
