/* Ochre motion for Tailwind v4. Import after ochre-tailwind.css.
   Ease-out curves, no overshoot: things start quickly and settle gently. CSS, Vue, plain HTML and the
   Web Animations API share the same curves. Each easing has a duration to pair with.
     snappy  presses, toggles, indicators, small moves     (320ms)
     bouncy  things arriving: pops, toasts, checks          (360ms; the name stays for compatibility, it no longer bounces)
     soft    panels, sheets, heights, anything large        (440ms)
   Classes: ease-snappy, ease-bouncy, ease-soft, spring-snappy|bouncy|soft (easing + duration),
   transition-ui, press, animate-pop-in, animate-rise-in, animate-fade-in, animate-blur-in, animate-shake,
   animate-draw, animate-pulse-soft, stagger (with style="--i: n"). Reduced motion turns movement off. */

@theme {
  --ease-snappy: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-bouncy: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-soft: cubic-bezier(0.22, 1, 0.36, 1);

  --animate-pop-in: ochre-pop-in var(--duration-bouncy) var(--ease-bouncy) both;
  --animate-rise-in: ochre-rise-in var(--duration-snappy) var(--ease-snappy) both;
  --animate-fade-in: ochre-fade-in 160ms var(--motion-ease-out) both;
  --animate-blur-in: ochre-blur-in 420ms var(--motion-ease-out) both;
  --animate-shake: ochre-shake 360ms var(--motion-ease-out);
  --animate-draw: ochre-draw 320ms var(--motion-ease-out) both;
  --animate-pulse-soft: ochre-pulse-soft 1.6s ease-in-out infinite;

  @keyframes ochre-pop-in {
    from { opacity: 0; scale: 0.96; }
    to { opacity: 1; scale: 1; }
  }
  @keyframes ochre-rise-in {
    from { opacity: 0; translate: 0 4px; }
    to { opacity: 1; translate: 0 0; }
  }
  @keyframes ochre-fade-in {
    from { opacity: 0; }
  }
  @keyframes ochre-blur-in {
    from { opacity: 0; filter: blur(4px); translate: 0 2px; }
    to { opacity: 1; filter: blur(0); translate: 0 0; }
  }
  @keyframes ochre-shake {
    0%, 100% { translate: 0 0; }
    20% { translate: -4px 0; }
    40% { translate: 4px 0; }
    60% { translate: -3px 0; }
    80% { translate: 2px 0; }
  }
  @keyframes ochre-draw {
    from { stroke-dashoffset: var(--draw-length, 24); }
    to { stroke-dashoffset: 0; }
  }
  @keyframes ochre-pulse-soft {
    50% { opacity: 0.55; }
  }
}

:root {
  --duration-snappy: 320ms;
  --duration-bouncy: 360ms;
  --duration-soft: 440ms;
  --press-scale: 0.97;
  --stagger: 40ms;
}

@utility spring-snappy {
  transition-timing-function: var(--ease-snappy);
  transition-duration: var(--duration-snappy);
}
@utility spring-bouncy {
  transition-timing-function: var(--ease-bouncy);
  transition-duration: var(--duration-bouncy);
}
@utility spring-soft {
  transition-timing-function: var(--ease-soft);
  transition-duration: var(--duration-soft);
}

/* Colours and shadows change quickly; anything that moves eases out on snappy. */
@utility transition-ui {
  transition:
    background-color var(--motion-fast) var(--motion-ease-out),
    border-color var(--motion-fast) var(--motion-ease-out),
    color var(--motion-fast) var(--motion-ease-out),
    box-shadow var(--motion-fast) var(--motion-ease-out),
    opacity var(--motion-base) var(--motion-ease-out),
    scale var(--duration-snappy) var(--ease-snappy),
    translate var(--duration-snappy) var(--ease-snappy),
    rotate var(--duration-snappy) var(--ease-snappy);
}

/* Pressed things give a little. Pair with transition-ui. */
@utility press {
  &:active:not(:disabled, [aria-disabled="true"]) {
    scale: var(--press-scale);
  }
}

@utility stagger {
  animation-delay: calc(var(--i, 0) * var(--stagger));
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --duration-snappy: 1ms;
    --duration-bouncy: 1ms;
    --duration-soft: 1ms;
    --press-scale: 1;
    --stagger: 0ms;
  }
  *, ::before, ::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
  }
}
