/* The shop's motion layer (17 Nov 2026). One set of timings and a few reusable effects, loaded on every page
   after app.css; assets/js/motion.js drives the parts that need to know what is on screen.
   Rules: transform and opacity only; nothing waits for an animation; everything is fully visible without
   JavaScript and in print; all of it is off when the reader asks for reduced motion. Colours come from the tokens.
   Opt a block out with data-motion="off" (on it or on a parent). Opt a block in with data-reveal (itself) or
   data-reveal="group" (its children, one after the other). */
:root {
  --m-fast: 180ms;
  --m-mid: 320ms;
  --m-slow: 600ms;
  --m-ease: var(--ease, cubic-bezier(.2, .8, .2, 1));
  --m-step: 70ms; /* delay between neighbours that arrive together */
}

@media (prefers-reduced-motion: no-preference) {
  /* ---------------------------------------------------------------- controls */
  .chip, .tabs a, .topnav a, .icon-btn, .tabbar a, .admin-side nav a, .admin-side-foot a, .stat, .card, .link-more .icon, .segmented label, .input, .select, .textarea {
    transition: background-color var(--m-fast) var(--m-ease), border-color var(--m-fast) var(--m-ease), color var(--m-fast) var(--m-ease), box-shadow var(--m-fast) var(--m-ease), transform var(--m-fast) var(--m-ease);
  }
  .icon-btn:active, .chip:active, .tabbar a:active .tab-ico { transform: scale(.94); }
  .link-more:hover .icon, .btn:hover .icon-go { transform: translateX(3px); }
  a.stat:hover, a.card:hover { transform: translateY(-2px); }
  [data-scheme-toggle] .icon { transition: transform var(--m-mid) var(--m-ease); }
  [data-scheme-toggle]:hover .icon { transform: rotate(18deg); }
  [data-scheme-toggle]:active .icon { transform: rotate(60deg) scale(.9); }

  /* ---------------------------------------------------------------- book covers: tilt, lift and a light sheen */
  .portal-public .cover { transform-origin: 0 60%; transition: transform var(--m-mid) var(--m-ease); will-change: auto; }
  .portal-public .cover::before {
    content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none; opacity: 0; border-radius: 3px 6px 6px 3px;
    background: linear-gradient(105deg, transparent 32%, rgba(255, 255, 255, .34) 47%, rgba(255, 255, 255, .08) 56%, transparent 66%);
    transition: opacity var(--m-mid) var(--m-ease);
  }
  .portal-public .cover:has(.cover-typeset)::before { display: none; }
  @media (hover: hover) {
    .pcard:hover .cover, .slide-art .cover:hover, .gallery-main .cover:hover, a:hover > .cover, .cover-tilt:hover, .launch-stage .ls:hover .cover {
      transform: perspective(900px) rotateY(-11deg) rotateX(2deg) translateY(-6px) scale(1.02);
    }
    .pcard:hover .cover::before, .slide-art .cover:hover::before, .gallery-main .cover:hover::before, a:hover > .cover::before, .cover-tilt:hover::before, .launch-stage .ls:hover .cover::before { opacity: 1; }
  }
  /* the first cover on a page settles into place, as if set down on a table */
  .slide:first-child .slide-art > .cover, .gallery-main > :first-child > .cover, .cover-settle { animation: cover-settle var(--m-slow) var(--m-ease) both; }
  @keyframes cover-settle { from { transform: perspective(900px) rotateY(-18deg) rotateX(5deg) translateY(14px) scale(.96); } }

  /* ---------------------------------------------------------------- basket feedback */
  .btn.is-added { animation: btn-added var(--m-mid) var(--m-ease); }
  .btn.is-added .icon { animation: pop-in var(--m-mid) var(--m-ease) both; }
  @keyframes btn-added { 40% { transform: scale(1.06); } }
  @keyframes pop-in { from { transform: scale(.3) rotate(-30deg); opacity: 0; } }
  .dot-count.is-bump { animation: bump var(--m-mid) var(--m-ease); }
  @keyframes bump { 35% { transform: scale(1.45); } 70% { transform: scale(.92); } }

  /* ---------------------------------------------------------------- toasts, menus, dialogs, sheets */
  .toast.is-leaving { animation: toast-out var(--m-fast) ease-in forwards; }
  @keyframes toast-out { to { opacity: 0; transform: translateY(8px) scale(.98); } }
  dialog[open]:not(.sheet) { animation: dialog-in var(--m-mid) var(--m-ease); }
  dialog[open]::backdrop { animation: fade-in var(--m-mid) ease-out; }
  @keyframes dialog-in { from { opacity: 0; transform: translateY(12px) scale(.97); } }
  @keyframes fade-in { from { opacity: 0; } }
  @media (min-width: 641px) { dialog.sheet[open] { animation: dialog-in var(--m-mid) var(--m-ease); } }
  .notify-panel { animation: menu-in var(--m-fast) var(--m-ease); transform-origin: 100% 0; }
  @keyframes menu-in { from { opacity: 0; transform: translateY(-6px) scale(.97); } }
  .cookie-notice, .pwa-update { animation: rise-in var(--m-mid) var(--m-ease) both; }
  @keyframes rise-in { from { opacity: 0; transform: translateY(14px); } }

  /* ---------------------------------------------------------------- the theme switch: a soft cross-fade */
  html.scheme-switching::view-transition-old(root) { animation: none; }
  html.scheme-switching::view-transition-new(root) { animation: fade-in var(--m-mid) ease-out both; }
}

@media print { .cover::before { display: none !important; } }
