/*
 * Overlay chrome — static file, deliberately OUTSIDE the Tailwind pipeline:
 * v4's --watch incremental rebuilds drop entry-authored custom rules (one-shot
 * builds keep them), which kept silently killing the rules here. public/
 * assets are copied verbatim and served as-is. (The name is historical: it
 * held the task panel's morph chrome (D55) until the morph flights were
 * removed on 2026-10-16.)
 *
 * The task overlay's scrim is the package's <dialog-backdrop> (views/
 * TaskOverlay.pzl is a <dialog-panel>), faded by the package's own stylesheet.
 */

/* Soften the skeleton → loaded swap inside the task panel: a hard content pop
   as the bundle lands reads as a hitch. ONLY after a skeleton (TaskPanel's
   `contentInClass`): a task seeded from the store is on screen from the
   panel's first frame, and fading it again showed the panel's chrome over a
   body still at ~30% opacity. */
.pyr-task-content-in {
  animation: pyr-content-in 200ms ease-out both;
}

@keyframes pyr-content-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/*
 * ---------------------------------------------------------------------------
 * COMMAND-PALETTE SCRIM
 * ---------------------------------------------------------------------------
 *
 * Cory, 2026-09-18: "when the search panel opens up it should use the
 * dialog-backdrop with the bg blur and bg-noise effect." And 2026-10-05: "we
 * should still use the <dialog-panel> to manage state and keep the texture and
 * colored overlay in the backdrop element, not the ::backdrop".
 *
 * IT IS THE PANEL'S <dialog-backdrop>, NOT `::backdrop`. The palette is a
 * <dialog-panel> (components/ui/Command.pzl), and the package keeps the native
 * ::backdrop transparent and paints every overlay on this element. That is also
 * what lets the scrim fade OUT: a ::backdrop is torn down the instant its
 * dialog closes, while this element stays rendered through the panel's
 * `hiding` state and fades with the dialog. The colour and the grain are
 * utilities on the element (`bg-scrim noise`); the package's [state] rules
 * show it (`display`) and fade it (`opacity`). This file adds the blur and the
 * saturation, and times all of it.
 *
 * WHY THE FILTER IS HAND-WRITTEN AND NOT `backdrop-blur-sm backdrop-saturate-115`.
 * Two reasons, both recorded on STYLE-COLORS already:
 *  - backdrop-filter has to be transitioned EXPLICITLY or Chrome applies the
 *    blur at full strength whatever the element's opacity, so an opacity-only
 *    fade leaves the app blurred and then pops (the same gotcha the old
 *    hand-rolled task backdrop hit before it became a <dialog-panel>).
 *  - a transition needs both ends written in the same property, and Tailwind's
 *    backdrop utilities compose one out of a stack of `--tw-backdrop-*`
 *    variables that a plain rule cannot interpolate against.
 * The values are READ FROM THE THEME rather than copied: `--blur-sm` is the
 * token `backdrop-blur-sm` itself compiles to, `--saturate-scrim` is a token
 * added beside it in pieces.css because `backdrop-saturate-115` takes a bare
 * integer and leaves none, and `--ease-popover` is the curve the palette's
 * panel fades on. Tailwind v4 emits them on `:root`, so a plain stylesheet
 * outside the pipeline can still read them and cannot drift from the utilities.
 *
 * THE TIMING IS THE PANEL'S, 150ms both ways, and that is not a taste call:
 * dialog-panel waits on the <dialog>'s own `transitionend` and then drops this
 * element to `display: none`, so a scrim slower than the panel would be cut
 * off part-way through its fade. Unlayered, so it outranks the package's
 * layered `transition` in every state.
 *
 * Nothing here can dim the app on its own: the element is `display: none`
 * outside the panel's showing/shown/hiding states (the package's stylesheet),
 * so a stale or missing copy of this file costs the blur, never a page.
 */
dialog-panel > dialog-backdrop.pyr-palette-backdrop {
  -webkit-backdrop-filter: blur(0) saturate(1);
  backdrop-filter: blur(0) saturate(1);
  transition:
    opacity 150ms var(--ease-popover),
    -webkit-backdrop-filter 150ms var(--ease-popover),
    backdrop-filter 150ms var(--ease-popover);
}

dialog-panel[state='shown'] > dialog-backdrop.pyr-palette-backdrop {
  -webkit-backdrop-filter: blur(var(--blur-sm)) saturate(var(--saturate-scrim));
  backdrop-filter: blur(var(--blur-sm)) saturate(var(--saturate-scrim));
}

/* Reduced motion: the panel cross-dissolves in 100ms linear (Command.pzl's
   `motion-reduce:` utilities), and the scrim keeps step with it, because a hard
   cut to a blurred page is its own jolt.

   TWO SELECTORS FOR THE SAME RULE, because the motion axis is three-way: the OS
   flag unless the account preference says 'full', or an explicit 'reduced'.
   `data-motion` is written onto <html> by app/lib/appearance.js; the same split
   is the `motion-reduce` variant in styles.css, `--motion-shift` in pieces.css
   and `reducedMotion()` in app/lib/motion.js. This file is outside the Tailwind
   pipeline (see the header), so it spells the rule out. */
@media (prefers-reduced-motion: reduce) {
  :root:not([data-motion='full']) dialog-panel > dialog-backdrop.pyr-palette-backdrop {
    transition:
      opacity 100ms linear,
      -webkit-backdrop-filter 100ms linear,
      backdrop-filter 100ms linear;
  }
}

:root[data-motion='reduced'] dialog-panel > dialog-backdrop.pyr-palette-backdrop {
  transition:
    opacity 100ms linear,
    -webkit-backdrop-filter 100ms linear,
    backdrop-filter 100ms linear;
}
