/* bind's loader: the logo slab, the same as the iPhone apps' pull to refresh (mobile/ios/App/App/SlabRefresh.swift).
   One component for the web app, deal pages and admin. Markup: <span class="spinner" aria-hidden="true"><i></i><i></i></span>
   (cap, then body). Size it with --h (its height; it's 2:3, like the 20 x 30 logo). It draws in currentColor: white
   on dark, the text color on light (a white button's dark label, say), with a faint outline of both pieces behind.
   1. It appears: the body fills bottom-up while the cap hovers above, faint; the cap drops on with a short spring.
   2. Loading: a card flip on Y, 0 to 180 to 360 degrees over 76% of a 1.1s cycle, then a rest. Repeats.
   3. Done (add .out if it stays on screen): it fades and shrinks away.
   Reduced motion: no flip, a slow pulse. A bare <span class="spinner"></span> still works: the slab, flipping. */
.spinner {
  --h: 18px;
  --r: calc(var(--h) * .15); /* 4.5 of 30 */
  position: relative; display: inline-block; flex: none; vertical-align: middle;
  width: calc(var(--h) * 2 / 3); height: var(--h);
  transform-style: preserve-3d;
  animation: slab-flip 1.1s .72s infinite; /* starts 0.12s after the cap lands */
  transition: opacity .22s cubic-bezier(.23,1,.32,1), transform .22s cubic-bezier(.23,1,.32,1);
}
/* the two pieces' slots: each draws the faint outline, and its ::before is the piece itself */
/* (doubled class: beats page rules for <i> it may sit inside, like the card lookup's step circles) */
.spinner.spinner > i { display: block; width: auto; min-width: 0; margin: 0; padding: 0; border: 0; background: none; font-style: normal; transform: none; animation: none; transition: none; }
.spinner.spinner > i, .spinner:empty::before, .spinner:empty::after { position: absolute; left: 0; right: 0; }
.spinner.spinner > i { box-shadow: inset 0 0 0 max(.75px, calc(var(--h) * .042)) color-mix(in srgb, currentColor 32%, transparent); }
.spinner.spinner > i:first-child, .spinner:empty::before { top: 0; height: 18%; border-radius: var(--r) var(--r) 0 0; }
.spinner.spinner > i:last-child, .spinner:empty::after { bottom: 0; height: 77%; border-radius: 0 0 var(--r) var(--r); }
.spinner.spinner > i::before, .spinner:empty::before, .spinner:empty::after { content: ''; background: currentColor; }
.spinner.spinner > i::before { position: absolute; inset: 0; border-radius: inherit; }
.spinner.spinner > i:last-child::before { animation: slab-fill .32s cubic-bezier(.23,1,.32,1) both; }
.spinner.spinner > i:first-child::before { animation: slab-cap .6s both; }
.spinner.out { opacity: 0; transform: scale(.85); animation: none; }

@keyframes slab-fill { from { clip-path: inset(100% 0 0 0); } to { clip-path: inset(0); } }
/* hovers 5px over (of 30), faint, while the body fills; then drops on with a short spring (a little past, back,
   settled), about stiffness 420 and damping 14 */
@keyframes slab-cap {
  0% { transform: translateY(calc(var(--h) * -.167)); opacity: .25; animation-timing-function: ease-in-out; }
  50% { transform: translateY(calc(var(--h) * -.167)); opacity: .6; animation-timing-function: cubic-bezier(.55,0,1,.45); }
  68% { transform: translateY(calc(var(--h) * .05)); opacity: 1; animation-timing-function: cubic-bezier(0,.55,.45,1); }
  80% { transform: translateY(calc(var(--h) * -.018)); animation-timing-function: ease-in-out; }
  90% { transform: translateY(calc(var(--h) * .006)); animation-timing-function: ease-in-out; }
  100% { transform: none; opacity: 1; }
}
/* perspective: the iPhone's m34 = -1/180 at 20 wide, so 9 widths (6 heights) at any size */
@keyframes slab-flip {
  0% { transform: perspective(calc(var(--h) * 6)) rotateY(0deg); animation-timing-function: cubic-bezier(.65,0,.35,1); }
  38% { transform: perspective(calc(var(--h) * 6)) rotateY(180deg); animation-timing-function: cubic-bezier(.65,0,.35,1); }
  76%, 100% { transform: perspective(calc(var(--h) * 6)) rotateY(360deg); }
}
@keyframes slab-pulse { from { opacity: 1; } to { opacity: .45; } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation: slab-pulse .6s ease-in-out infinite alternate; transition: opacity .22s ease-out; }
  .spinner.spinner > i::before { animation: none; }
  .spinner.out { transform: none; }
}
