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


mds-badge,
mds-icon,
mds-progress,
mds-text {
  &:not(:is([hydrated], .hydrated)) {
    @apply not-hydrated;
  }
}


/**
 * @prop --mds-stepper-bar-item-color: Public. Sets the color of the text
 * @prop --mds-stepper-bar-item-duration: Sets the duration of the animation
 * @prop --mds-stepper-bar-item-icon-background-done: Sets the background-color of the icon when the component is done
 * @prop --mds-stepper-bar-item-icon-background-current: Sets the background-color of the icon when the component is current
 * @prop --mds-stepper-bar-item-icon-background: Sets the background-color of the icon
 * @prop --mds-stepper-bar-item-icon-color-done: Sets the color of the icon when the component is done
 * @prop --mds-stepper-bar-item-icon-color-current: Sets the color of the icon when the component is current
 * @prop --mds-stepper-bar-item-icon-color: Sets the color of the icon
 * @prop --mds-stepper-bar-item-min-width: Public. Sets the minimum width of the component; the last item, which has no bar, takes the width of its texts instead
 * @prop --mds-stepper-bar-item-progress-background: Sets the background color of the progress bar
 * @prop --mds-stepper-bar-item-progress-color: Sets the color of the progress bar
 * @prop --mds-stepper-bar-item-progress-thickness: Sets the thickness of the progress bar
 */

:host {
  --mds-stepper-bar-item-header-gap: var(--mds-stepper-bar-gap, --spacing(50));
  --mds-stepper-bar-item-color: rgb(var(--magma-text-muted, var(--text-neutral-muted, 73 73 73)));

  /* stylelint-disable-next-line magma/token-values -- 250ms no --duration-* step says it */
  --mds-stepper-bar-item-duration: 250ms;
  --private-stepper-bar-item-duaration: var(--mds-stepper-bar-item-duration, 250ms);
  --mds-stepper-bar-item-transition-duration: var(--duration-200, 200ms);
  --private-stepper-bar-item-transition-duration: var(--mds-stepper-bar-item-transition-duration);
  --mds-stepper-bar-item-icon-background-done: rgb(var(--magma-success-emphasis, var(--status-success-04, 0 128 57)));
  --mds-stepper-bar-item-icon-background-current: rgb(var(--magma-accent-emphasis, var(--variant-primary-04, 11 96 255)));
  --mds-stepper-bar-item-icon-background: var(
    --mds-stepper-bar-item-progress-background,
    rgb(var(--magma-wash-strong, var(--tone-neutral-08, 208 208 208)))
  );
  --mds-stepper-bar-item-icon-color-done: rgb(var(--magma-success-on-emphasis, var(--tone-neutral-seed, 255 255 255)));
  --mds-stepper-bar-item-icon-color-current: rgb(var(--magma-text-on-emphasis, var(--tone-neutral-seed, 255 255 255)));
  --mds-stepper-bar-item-icon-color: rgb(var(--magma-text-subtle, var(--text-neutral-subtle, 99 99 99)));
  --mds-stepper-bar-item-min-width: --spacing(4500);
  --mds-stepper-bar-item-progress-background: rgb(var(--magma-wash-strong, var(--tone-neutral-08, 208 208 208)));
  --mds-stepper-bar-item-progress-color: rgb(var(--magma-success-emphasis, var(--status-success-04, 0 128 57)));
  --mds-stepper-bar-item-progress-thickness: --spacing(200);

  align-items: flex-start;
  border-radius: var(--magma-radius-xl, var(--radius-squircle-xl, 36px));
  corner-shape: var(--magma-corner-shape, squircle);
  display: grid;
  flex-basis: 0;
  flex-direction: column;
  flex-grow: 1;
  flex-shrink: 0;
  gap: --spacing(400);
  min-width: var(--mds-stepper-bar-item-min-width, --spacing(4500));
  position: relative;
  scroll-snap-align: center;
  transition-duration: var(--private-stepper-bar-item-duaration);
  transition-property: outline, outline-offset, background-color;
}

/* :host {
  @apply focus-bounce;

  cursor: pointer;

  &:host(:focus-visible) {
    @apply focus-bounce--focused z-10;
  }
} */

/* the last step draws no bar after its icon: it takes the width of its texts, and the room of a
   wider row goes to the bars of the steps before it instead of an empty column (#680, entry 14) */

:host(:last-of-type) {
  flex-basis: auto;
  flex-grow: 0;
  min-width: auto;
}

:host(:last-of-type) .progress {
  display: none;
}

:host([done]) .icon {
  --mds-stepper-bar-item-icon-background: var(--mds-stepper-bar-item-icon-background-done, rgb(var(--magma-success-emphasis, var(--status-success-04, 0 128 57))));
  --mds-stepper-bar-item-icon-color: var(--mds-stepper-bar-item-icon-color-done, rgb(var(--magma-success-on-emphasis, var(--tone-neutral-seed, 255 255 255))));

  transition-delay: 0ms;
}

/*
:host(:not([done])) {
  pointer-events: none;
}

:host([done]:hover) .icon {
  --mds-stepper-bar-item-icon-background: var(--mds-stepper-bar-item-icon-background-current);
  --mds-stepper-bar-item-icon-color: var(--mds-stepper-bar-item-icon-color-current);
} */

:host([current]) .icon {
  --mds-stepper-bar-item-icon-background: var(--mds-stepper-bar-item-icon-background-current, rgb(var(--magma-accent-emphasis, var(--variant-primary-04, 11 96 255))));
  --mds-stepper-bar-item-icon-color: var(--mds-stepper-bar-item-icon-color-current, rgb(var(--magma-text-on-emphasis, var(--tone-neutral-seed, 255 255 255))));

  transition-delay: calc(var(--private-stepper-bar-item-duaration) / 2);
}

.header {
  @apply ease-out;

  align-items: center;
  border-radius: var(--magma-radius-md, var(--radius-squircle-md, 20px));
  corner-shape: var(--magma-corner-shape, squircle);
  display: flex;
  gap: var(--mds-stepper-bar-item-header-gap);
  transition-duration: var(--private-stepper-bar-item-transition-duration);
  transition-property: outline, outline-offset;
  width: 100%;
}

.icon {
  @apply ease-in-out;

  background-color: var(--mds-stepper-bar-item-icon-background, rgb(var(--magma-wash-strong, var(--tone-neutral-08, 208 208 208))));
  border-radius: var(--magma-radius-full, var(--radius-full, 1000px));
  display: flex;
  fill: var(--mds-stepper-bar-item-icon-color, rgb(var(--magma-text-subtle, var(--text-neutral-subtle, 99 99 99))));
  flex-shrink: 0;
  padding: --spacing(200);
  position: relative;
  transition-duration: var(--private-stepper-bar-item-duaration);
  transition-property: background-color, fill;
}

.progress {
  --mds-progress-background: var(--mds-stepper-bar-item-progress-background, rgb(var(--magma-wash-strong, var(--tone-neutral-08, 208 208 208))));
  --mds-progress-color: var(--mds-stepper-bar-item-progress-color, rgb(var(--magma-success-emphasis, var(--status-success-04, 0 128 57))));
  --mds-progress-thickness: var(--mds-stepper-bar-item-progress-thickness, --spacing(200));
  --mds-progress-radius: 0;

  flex-grow: 1;
}

.infos {
  display: grid;
  gap: --spacing(100);
  padding-left: --spacing(100);
}

.text {
  @apply ease-in-out;

  color: var(--mds-stepper-bar-item-color, rgb(var(--magma-text-muted, var(--text-neutral-muted, 73 73 73))));
  pointer-events: none;
  transition-duration: var(--private-stepper-bar-item-duaration);
  transition-property: color;
}

.badge {
  border-radius: var(--magma-radius-full, var(--radius-full, 1000px));
  pointer-events: none;
}

.step {
  border-radius: var(--magma-radius-full, var(--radius-full, 1000px));
  color: rgb(var(--magma-text-subtle, var(--text-neutral-subtle, 99 99 99)));
  pointer-events: none;
}

/* 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-stepper-bar-item-duaration: 0s;
  --private-stepper-bar-item-transition-duration: 0s;
}

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

