/**
 * @prop --mds-zero-contents-max-width: Public. Set if the contents has a max width to be centered in the component
 */

/* the panel of an empty state, on the roles of the design language (#1189, #1231): one inset
   shared by its regions (rhythm/inset, rhythm/shared-inset), the illustration, the content and
   the actions at rhythm/content-actions, the title and the text of the content at
   rhythm/title-content, the actions side by side at rhythm/inline; with no action the footer is
   gone, so the inset stays the same on every side. The fill is surface-muted, a step under the
   page in both modes, on the plane where the items would stand (surfaces/tints-in-components,
   chosen by vittorio on the render of #1231) */

:host {
  --mds-zero-contents-max-width: --spacing(10000);
  --mds-zero-transition-duration: var(--duration-200, 200ms);
  --private-zero-transition-duration: var(--mds-zero-transition-duration);

  @apply ease-out;

  align-items: center;
  background-color: rgb(var(--magma-surface-muted, var(--surface-neutral-muted, 238 238 238)));
  border-radius: var(--magma-radius-xl, var(--radius-squircle-xl, 36px));
  corner-shape: var(--magma-corner-shape, squircle);
  display: flex;
  flex-direction: column;
  gap: var(--magma-rhythm-content-actions, 24px);
  justify-items: center;
  padding: var(--magma-rhythm-inset, 24px);
  transition-duration: var(--private-zero-transition-duration);
  transition-property: box-shadow, background-color;
}

:host .contents {
  align-items: center;
  display: flex;
  flex-direction: column;
  gap: var(--magma-rhythm-title-content, 12px);
  justify-items: center;
  max-width: var(--mds-zero-contents-max-width, --spacing(10000));
  text-align: center;
}

:host .actions {
  align-items: center;
  display: flex;
  gap: var(--magma-rhythm-inline, 12px);
  justify-items: center;
  width: 100%;
}

:host .actions--hidden {
  display: none;
}

:host ::slotted([slot='action']) {
  margin: auto;
}

/* Motion, held back.
 *
 * Every component zeroes the private durations its own base CSS reads, which composes
 * with the public knobs - but that only reaches the declarations that read them. An audit
 * of the 52 sheets found 21 transitions in 15 components that did not: the host's own
 * transition in mds-button and mds-table, the focus ring of the input family, the tab
 * slider, the close button of mds-note. This reset reaches the whole shadow tree, which is
 * what the preference promises, and keeps reaching it when a declaration is added.
 *
 * Transitions only, on purpose. A keyframe animation is usually a loader, and a loader has
 * to keep saying "working": mds-spinner slows to 8s under reduced motion instead of
 * freezing, and a duration of nearly zero on an infinite animation would spin it out of
 * control instead of stopping it.
 *
 * 0.01ms rather than 0s, so a component that waits for its own transitionend still gets
 * one: mds-modal, mds-push-notification and mds-tree-item all listen for it, and a
 * transition of zero never fires it. */

/* stylelint-disable time-min-milliseconds -- the floor is there to keep a transition
   perceivable; the point of these two is that it is not. */

:host([pref-animation='reduce']),
:host([pref-animation='reduce']) *,
:host([pref-animation='reduce']) *::before,
:host([pref-animation='reduce']) *::after {
  transition-duration: 0.01ms !important;
}

@media (prefers-reduced-motion: reduce) {
  :host([pref-animation='system']),
  :host([pref-animation='system']) *,
  :host([pref-animation='system']) *::before,
  :host([pref-animation='system']) *::after,
  :host(:not([pref-animation])),
  :host(:not([pref-animation])) *,
  :host(:not([pref-animation])) *::before,
  :host(:not([pref-animation])) *::after {
    transition-duration: 0.01ms !important;
  }
}

/* stylelint-enable time-min-milliseconds */


/* Animation preference. The component mirrors the resolved mode from <html>
 * onto its host as pref-animation (see subscribePreference in @common/preference);
 * these plain shadow selectors then zero the private duration(s) the base CSS
 * reads. `reduce` always stops; `system` and no controller follow the OS via
 * @media; `no-preference` keeps the base value. Customization composes (the base
 * sets --private from the public token, this only overrides it when reduced). */

:host([pref-animation='reduce']) {
  --private-zero-transition-duration: 0s;
}

@media (prefers-reduced-motion: reduce) {
  :host([pref-animation='system']),
  :host(:not([pref-animation])) {
    --private-zero-transition-duration: 0s;
  }
}

/* Theme preference. The fill of the panel is a surface role (--magma-surface-muted, spec 6.1),
 * which flips per mode at :root and inherits into the shadow DOM: a step under the page in light
 * and in dark, so this component needs no per-mode dark refinement. The former dark override
 * (--magma-wash-base with a ring, a light card on the dark page, #1231) is intentionally gone. */

/* Contrast preference. The component reflects the resolved mode from <html> onto
 * its host as pref-contrast (see subscribePreference in @common/preference); these
 * plain shadow selectors refine for high contrast. `more` is the explicit choice;
 * `system` and no controller follow the OS via @media. Cross-browser, no :host-context. */

:host([pref-contrast='more']) {
  box-shadow: var(--shadow-ring-2, 0 0 0 2px rgb(var(--tone-neutral-01, 5 5 5) / 0.3));
}

@media (prefers-contrast: more) {
  :host([pref-contrast='system']),
  :host(:not([pref-contrast])) {
    box-shadow: var(--shadow-ring-2, 0 0 0 2px rgb(var(--tone-neutral-01, 5 5 5) / 0.3));
  }
}

:host(:not(:is([hydrated], .hydrated))) {
  @apply not-hydrated;
}

