@keyframes focus-bounce {
  0%,
  75%,
  100% {
    outline-offset: var(--magma-outline-focus-offset, 2px);
  }

  50% {
    outline-offset: var(--magma-outline-blur-offset, 6px);
  }
}

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


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


/**
 * @prop --mds-filter-item-count-background-default: Sets the default `background-color` of the count element
 * @prop --mds-filter-item-count-color-default: Sets the default text `color` of the count element
 * @prop --mds-filter-item-count-background-selected: Sets the `background-color` of the count element when it's selected
 * @prop --mds-filter-item-count-color-selected: Sets the `color` of the count element when it's selected
 */

:host {
  --mds-filter-item-transition-duration: var(--duration-200, 200ms);
  --private-filter-item-transition-duration: var(--mds-filter-item-transition-duration);
  --mds-filter-item-count-background-default: rgb(var(--magma-wash-strong, var(--tone-neutral-08, 208 208 208)));
  --mds-filter-item-count-color-default: rgb(var(--magma-text-default, var(--text-neutral-default, 5 5 5)));
  --mds-filter-item-count-background-selected: rgb(var(--magma-surface-inverse-muted, var(--tone-neutral-03, 73 73 73)));
  --mds-filter-item-count-color-selected: rgb(var(--magma-on-inverse, var(--tone-neutral-seed, 255 255 255)));

  @apply focus-bounce;

  align-items: center;
  border-radius: var(--magma-radius-full, var(--radius-full, 1000px));
  color: rgb(var(--magma-text-muted, var(--text-neutral-muted, 73 73 73)));
  cursor: pointer;
  display: flex;
  fill: currentcolor;
  gap: --spacing(100);
  justify-content: center;
  padding: --spacing(200) --spacing(400);
  transition-duration: var(--private-filter-item-transition-duration);
  transition-property: background-color, box-shadow, color, outline, outline-offset;
  transition-timing-function: var(--ease-out-cubic, cubic-bezier(0.215, 0.61, 0.355, 1));
  -webkit-user-select: none;
          user-select: none;
  white-space: nowrap;
}

mds-text {
  white-space: nowrap;
}

/* 16px on a 16px tall count was a circle, a pill once the number widens it: the pill, out of the
   corner axis */

.count {
  align-items: center;
  background-color: var(--mds-filter-item-count-background-default, rgb(var(--magma-wash-strong, var(--tone-neutral-08, 208 208 208))));
  border-radius: var(--magma-radius-full, var(--radius-full, 1000px));
  box-sizing: border-box;
  color: currentcolor;
  color: var(--mds-filter-item-count-color-default, rgb(var(--magma-text-default, var(--text-neutral-default, 5 5 5))));
  display: inline-flex;
  flex-shrink: 0;
  height: --spacing(400);
  justify-content: center;
  min-width: --spacing(400);
  padding-left: --spacing(150);
  padding-right: --spacing(150);
  transition-duration: var(--duration-200, 200ms);
  transition-property: background-color, color;
  transition-timing-function: var(--ease-out-cubic, cubic-bezier(0.215, 0.61, 0.355, 1));
  -webkit-user-select: none;
          user-select: none;
}

:host(:focus-visible) {
  @apply focus-bounce--focused;
}

/* a disabled item does nothing on click and leaves the tab order: it shows as disabled and drops
 * the hover feedback of a control that answers */

:host([disabled]:not([disabled='false'])) {
  color: rgb(var(--magma-text-disabled, var(--text-neutral-disabled, 119 119 119)));
  pointer-events: none;
}

:host([icon]:not([label])) {
  height: --spacing(900);
  padding: 0;
  width: --spacing(900);
}

:host([selected]:not([selected='false'])),
:host(:hover) {
  background-color: rgb(var(--magma-surface-overlay, var(--surface-neutral-overlay, 255 255 255)));
}

:host(:hover) {
  box-shadow: var(--shadow-sm, 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1));
}

:host([selected]:not([selected='false'])) {
  color: rgb(var(--magma-text-default, var(--text-neutral-default, 5 5 5)));
}

:host([selected]:not([selected='false'])) .count {
  background-color: var(--mds-filter-item-count-background-selected, rgb(var(--magma-surface-inverse-muted, var(--tone-neutral-03, 73 73 73))));
  color: var(--mds-filter-item-count-color-selected, rgb(var(--magma-on-inverse, var(--tone-neutral-seed, 255 255 255))));
}

/* 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-filter-item-transition-duration: 0s;
}

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

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

:host([pref-mode='dark']:not([pref-theme-scheme='light'])),
:host([pref-theme-scheme='dark']) {
  background-color: rgb(var(--magma-wash-soft, var(--tone-neutral-10, 237 237 237)));

  &:host([selected]:not([selected='false'])) {
    background-color: rgb(var(--magma-wash-strong, var(--tone-neutral-08, 208 208 208)));
    box-shadow: var(--shadow-ring, 0 0 0 1px rgb(var(--tone-neutral-01, 5 5 5) / 0.3));
  }

  &:host(:hover) {
    box-shadow: var(--shadow-ring, 0 0 0 1px rgb(var(--tone-neutral-01, 5 5 5) / 0.3));
  }
}

@media (prefers-color-scheme: dark) {
  :host([pref-mode='system']:not([pref-theme-scheme='light'])),
  :host(:not([pref-mode]):not([pref-theme-scheme='light'])) {
    background-color: rgb(var(--magma-wash-soft, var(--tone-neutral-10, 237 237 237)));

    &:host([selected]:not([selected='false'])) {
      background-color: rgb(var(--magma-wash-strong, var(--tone-neutral-08, 208 208 208)));
      box-shadow: var(--shadow-ring, 0 0 0 1px rgb(var(--tone-neutral-01, 5 5 5) / 0.3));
    }

    &:host(:hover) {
      box-shadow: var(--shadow-ring, 0 0 0 1px rgb(var(--tone-neutral-01, 5 5 5) / 0.3));
    }
  }
}

/* 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']) {
  &:host([selected]:not([selected='false'])),
  &:host(:hover) {
    box-shadow: var(--shadow-ring-strong-2, 0 0 0 2px rgb(var(--tone-neutral-01, 5 5 5) / 0.6));
  }
}

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

