/* Site-wide motion (owner review, 2026-11-14: "much more animation than now,
   not too much"). Linked last from base.html and _auth_layout.html.

   What moves, and why:
   - continuity: a page change dissolves into the next page, an in-page link
     glides to its target;
   - feedback: a button gives under the press, a card that is a link lifts,
     a menu drops out of its button, a message settles into place, the cookie
     dialog leaves when it is answered and its settings unfold.
   Scroll reveals and the in-place switches (templates filter, billing period)
   are animations.js; the springs on the animated pages are Motion.

   Rules: transform and opacity only, so nothing shifts the layout; 280 ms at
   most; nothing waits for an animation before it works; all of it sits in
   `prefers-reduced-motion: no-preference`, so with reduced motion the pages
   are still. */

@media (prefers-reduced-motion: no-preference) {
  /* ── page changes ──────────────────────────────────────────────────
     Cross-document view transitions: the browser cross-fades the old page
     into the new one. The header and footer are the same pixels on both, so
     they do not flash. A browser without it loads the page as before. */
  @view-transition { navigation: auto; }

  /* ── in-page links ─────────────────────────────────────────────────
     Smooth only once the visitor has put the focus in the page (a click on an
     account tab, "On this page", the FAQ menu). A page opened at #anchor, the
     browser's find and its back button still jump at once. */
  html:focus-within { scroll-behavior: smooth; }

  /* ── press and hover ───────────────────────────────────────────────
     Pages with Motion (.fx) spring their buttons from animations.js; every
     other page gets the press here. */
  html:not(.fx) .btn:not(:disabled, [aria-disabled="true"]):active { transform: scale(0.97); }

  /* a card that is one link lifts; a card that only holds content stays put */
  a.card { transition: transform 180ms var(--ease), box-shadow 180ms var(--ease), background 150ms ease, color 150ms ease; }
  a.card:active { transform: scale(0.99); }

  /* ── menus ─────────────────────────────────────────────────────────
     The Hosting menu, the bell's list and the phone menu drop out of the
     button that opens them. Closing is instant: the click already said so. */
  .nav-drop.open .nav-drop-panel,
  .site-header:not([data-menu]) .nav-drop:hover .nav-drop-panel,
  .site-header:not([data-menu]) .nav-drop:focus-within .nav-drop-panel { animation: menu-in 160ms var(--ease); transform-origin: 24px 0; }
  .bell-panel:not([hidden]) { animation: menu-in 160ms var(--ease); transform-origin: calc(100% - 20px) 0; }

  /* ── messages and form feedback ────────────────────────────────────
     The banner after a saved form, a refusal under its field. An element
     that was `hidden` plays this each time it is shown again. */
  .flash, .form-error, .field-error:not([hidden]), [data-form-error]:not([hidden]) { animation: notice-in 240ms var(--ease); }

  /* ── dialogs ───────────────────────────────────────────────────────*/
  dialog.whats-new[open] { animation: hd-pop 180ms var(--ease); }
  dialog[open]::backdrop { animation: fade-in 180ms ease-out; }

  /* ── cookie dialog and /cookie-settings ────────────────────────────
     Reopened from the footer it rises into place; answered (Accept, Reject,
     Save) it sinks and fades, then consent.js hides it. On first load it is
     simply there: an entrance on every page until someone answers would be
     the opposite of calm. */
  .consent[data-reopened]:not(.leaving) { animation: consent-in 260ms var(--ease); }
  .consent.leaving { animation: consent-out 170ms ease-in forwards; pointer-events: none; }
}
@media (prefers-reduced-motion: no-preference) and (hover: hover) and (pointer: fine) {
  a.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
  html:not(.fx) .btn.primary:not(:disabled, [aria-disabled="true"]):hover { transform: translateY(-1px); }
  html:not(.fx) .btn.primary:not(:disabled, [aria-disabled="true"]):active { transform: scale(0.97); }
}
@media (prefers-reduced-motion: no-preference) and (max-width: 960px) {
  .site-header[data-menu].menu-open .site-menu { animation: menu-in 200ms var(--ease); transform-origin: 50% 0; }
}

/* the page dissolve: short and even, well under the 250 ms default */
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 160ms; animation-timing-function: ease-out; }

/* "Settings" in the cookie dialog and "Compare all limits" unfold to their own
   height where the browser can interpolate to `auto`; elsewhere they open at once. */
@supports (interpolate-size: allow-keywords) {
  @media (prefers-reduced-motion: no-preference) {
    .consent, .limits-row { interpolate-size: allow-keywords; }
    .consent-details::details-content, .limits-disclosure::details-content { height: 0; overflow: clip;
      transition: height 240ms var(--ease), content-visibility 240ms allow-discrete; }
    .consent-details[open]::details-content, .limits-disclosure[open]::details-content { height: auto; }
  }
}

@keyframes menu-in { from { opacity: 0; transform: translateY(-6px) scale(0.98); } }
@keyframes notice-in { from { opacity: 0; transform: translateY(-6px); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes consent-in { from { opacity: 0; transform: translateY(16px); } }
@keyframes consent-out { to { opacity: 0; transform: translateY(12px); } }
