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


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


/**
 * @prop --mds-filter-items-background-active: Public. Sets the background-color of the items row area when a filter is active
 * @prop --mds-filter-items-background: Public. Sets the background-color of the items row area
 * @prop --mds-filter-items-gap: Sets the gap between items
 * @prop --mds-filter-items-padding: Sets the padding of the items row area
 * @prop --mds-filter-items-radius: Sets the border-radius of the items row area
 * @prop --mds-filter-items-scroll-behavior: Sets the scroll-behavior animation;
 * @prop --mds-filter-label-gap: Sets the gap between the label and the items row area
 * @prop --mds-filter-label-padding: Sets the padding of the label
 * @prop --mds-filter-wrapper-shadow-color: Sets the effect of the outline border
 * @prop --mds-filter-wrapper-shadow: Public. Sets the shadow used as outline border
 * @prop --mds-filter-wrapper-shadow-opacity: Sets the opacity of the outline border
 */

/* ❌ Not supported: <shadow> syntax is not allowed in @property
@property --mds-filter-wrapper-shadow {
  inherits: false;
  syntax: "<shadow>";
  initial-value: 0 0 0 2px var(--mds-filter-wrapper-shadow-color) inset;
}
*/

:host {
  --mds-filter-items-background-active: rgb(var(--magma-wash-base, var(--tone-neutral-09, 225 225 225)));
  --mds-filter-items-background: rgb(var(--magma-wash-base, var(--tone-neutral-09, 225 225 225)));
  --mds-filter-items-gap: --spacing(200);
  --mds-filter-items-padding: --spacing(200);
  --mds-filter-items-radius: var(--magma-radius-full, var(--radius-full, 1000px));
  --mds-filter-items-scroll-behavior: smooth;
  --mds-filter-items-transition-duration: var(--duration-300, 300ms);
  --private-filter-items-transition-duration: var(--mds-filter-items-transition-duration);

  /* the gap a field leaves under its label (mds-input-field): 4px glued it to the ring (#1144) */
  --mds-filter-label-gap: --spacing(300);
  --mds-filter-label-padding: 0 --spacing(600);
  --mds-filter-wrapper-shadow-color: rgb(var(--magma-border-default, var(--border-neutral-default, 183 183 183)));
  --mds-filter-wrapper-shadow: 0 0 0 --spacing(50) var(--mds-filter-wrapper-shadow-color, rgb(var(--magma-border-default, var(--border-neutral-default, 183 183 183)))) inset;
  --mds-filter-wrapper-shadow-opacity: 0.1;

  display: grid;
  gap: var(--mds-filter-label-gap, --spacing(300));
  grid-auto-rows: min-content;
}

/* Animation preference: scroll-behavior is a keyword and cannot be derived from
 * is handled here, cross-browser, via @media (it follows the OS preference).
 * The .items transition-duration is reduced separately in
 * css/mds-filter-pref-animation.css. */

@media (prefers-reduced-motion: reduce) {
  :host {
    --mds-filter-items-scroll-behavior: auto;
  }
}

.items {
  @apply hide-scrollbar;

  background-color: var(--mds-filter-items-background, rgb(var(--magma-wash-base, var(--tone-neutral-09, 225 225 225))));
  border-radius: var(--mds-filter-items-radius, var(--magma-radius-full, var(--radius-full, 1000px)));
  display: flex;
  gap: var(--mds-filter-items-gap, --spacing(200));
  overflow: auto;
  padding: var(--mds-filter-items-padding, --spacing(200));
  position: relative;
  scroll-behavior: var(--mds-filter-items-scroll-behavior, smooth);
  scroll-snap-type: x mandatory;
  transition-duration: var(--private-filter-items-transition-duration);
  transition-property: background-color;
  transition-timing-function: var(--ease-in-out-expo, cubic-bezier(1, 0, 0, 1));
}

.items-wrapper {
  display: grid;
  overflow: hidden;
  position: relative;
}

.items-wrapper::after {
  border-radius: var(--mds-filter-items-radius, var(--magma-radius-full, var(--radius-full, 1000px)));
  box-shadow: var(--mds-filter-wrapper-shadow);
  content: '';
  inset: 0;
  opacity: var(--mds-filter-wrapper-shadow-opacity, 0.1);
  pointer-events: none;
  position: absolute;
}

.items::-webkit-scrollbar {
  display: none;
}

.label {
  padding: var(--mds-filter-label-padding, 0 --spacing(600));
}

.active {
  background-color: var(--mds-filter-items-background-active, rgb(var(--magma-wash-base, var(--tone-neutral-09, 225 225 225))));
}

.reset {
  display: flex;
  flex-grow: 1;
  justify-content: flex-end;
  transform: scale(0);
  transform-origin: center;
  transition-duration: var(--duration-300, 300ms);
  transition-property: transform;
  transition-timing-function: var(--ease-in-out-expo, cubic-bezier(1, 0, 0, 1));
}

.reset-button {
  transform: scale(0);
  transition-duration: var(--duration-300, 300ms);
  transition-property: transform;
  transition-timing-function: var(--ease-in-out-expo, cubic-bezier(1, 0, 0, 1));
}

.reset-button-opened {
  transform: scale(1);
}

:host([reset]:not([reset='false'])) .reset {
  transform: scale(1);
}

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

@media (prefers-reduced-motion: reduce) {
  :host([pref-animation='system']),
  :host(:not([pref-animation])) {
    --private-filter-items-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'])) .items,
:host([pref-theme-scheme='dark']) .items {
  --mds-filter-items-background-active: rgb(var(--magma-wash-soft, var(--tone-neutral-10, 237 237 237)));
  --mds-filter-items-background: rgb(var(--magma-wash-base, var(--tone-neutral-09, 225 225 225)));
}

@media (prefers-color-scheme: dark) {
  :host([pref-mode='system']:not([pref-theme-scheme='light'])),
  :host(:not([pref-mode]):not([pref-theme-scheme='light'])) {
    .items {
      --mds-filter-items-background-active: rgb(var(--magma-wash-soft, var(--tone-neutral-10, 237 237 237)));
      --mds-filter-items-background: rgb(var(--magma-wash-base, var(--tone-neutral-09, 225 225 225)));
    }
  }
}

/* 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']) {
  --mds-filter-items-background-active: rgb(var(--magma-wash-base, var(--tone-neutral-09, 225 225 225)));
  --mds-filter-items-background: rgb(var(--magma-wash-soft, var(--tone-neutral-10, 237 237 237)));
  --mds-filter-wrapper-shadow-opacity: 0.3;
  --mds-filter-wrapper-shadow: 0 0 0 --spacing(50) var(--mds-filter-wrapper-shadow-color, rgb(var(--magma-border-default, var(--border-neutral-default, 183 183 183)))) inset;
}

@media (prefers-contrast: more) {
  :host([pref-contrast='system']),
  :host(:not([pref-contrast])) {
    --mds-filter-items-background-active: rgb(var(--magma-wash-base, var(--tone-neutral-09, 225 225 225)));
    --mds-filter-items-background: rgb(var(--magma-wash-soft, var(--tone-neutral-10, 237 237 237)));
    --mds-filter-wrapper-shadow-opacity: 0.3;
    --mds-filter-wrapper-shadow: 0 0 0 --spacing(50) var(--mds-filter-wrapper-shadow-color, rgb(var(--magma-border-default, var(--border-neutral-default, 183 183 183)))) inset;
  }
}

