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


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


/**
 * @prop --mds-badge-background: Public. Sets the background-color of the component
 * @prop --mds-badge-radius: Public. Sets the border-radius of the component
 * @prop --mds-badge-color: Public. Sets the text color of the component
 * @prop --mds-badge-border-color: Sets the border color of the component when tone is "outline"
 * @prop --mds-badge-border-width: Sets the border width of the component when tone is "outline"
 */

:host {
  --mds-badge-background: rgb(var(--label-sky-09, 196 229 250));
  --mds-badge-border-color: rgb(var(--label-sky-06, 82 180 238));
  --mds-badge-border-width: 1px;
  --mds-badge-color: rgb(var(--label-sky-03, 4 95 136));

  /* 16px on a badge 15-17px tall was a pill already: the pill, out of the corner axis */
  --mds-badge-radius: var(--magma-radius-full, var(--radius-full, 1000px));
  --mds-badge-transition-duration: var(--duration-200, 200ms);
  --private-badge-transition-duration: var(--mds-badge-transition-duration);

  align-items: center;
  background-color: var(--mds-badge-background, rgb(var(--label-sky-09, 196 229 250)));
  border-radius: var(--mds-badge-radius, var(--magma-radius-full, var(--radius-full, 1000px)));
  color: var(--mds-badge-color, rgb(var(--magma-text-on-emphasis, var(--tone-neutral-seed, 255 255 255))));
  display: inline-flex;
  min-width: min-content;
  padding: --spacing(100) --spacing(200);
  transition-duration: var(--private-badge-transition-duration);
  transition-property: background-color, border-color, border-width, color;
  transition-timing-function: var(--ease-out-quad, cubic-bezier(0.25, 0.46, 0.45, 0.94));
}

/* An outline badge is never filled. Set on background-color itself, not through
   --mds-badge-background: every variant sheet restates that token, and the CSS
   minifier merges same-selector rules, so an order-based reset loses to them. */

:host([tone='outline']) {
  background-color: transparent;
  border-color: var(--mds-badge-border-color, rgb(var(--label-sky-06, 82 180 238)));
  border-style: solid;
  border-width: var(--mds-badge-border-width, 1px);
}

:host([variant='red']) {
  --mds-badge-background: rgb(var(--label-red-04, 212 28 28));

  &:host([tone='weak']) {
    --mds-badge-background: rgb(var(--label-red-09, 250 215 215));
    --mds-badge-color: rgb(var(--label-red-02, 131 17 17));
  }

  &:host([tone='outline']) {
    --mds-badge-border-color: rgb(var(--label-red-06, 241 144 144));
    --mds-badge-color: rgb(var(--label-red-04, 212 28 28));
  }
}

:host([variant='amaranth']) {
  --mds-badge-background: rgb(var(--label-amaranth-04, 202 51 77));

  &:host([tone='weak']) {
    --mds-badge-background: rgb(var(--label-amaranth-09, 255 214 215));
    --mds-badge-color: rgb(var(--label-amaranth-02, 126 28 45));
  }

  &:host([tone='outline']) {
    --mds-badge-border-color: rgb(var(--label-amaranth-06, 255 135 144));
    --mds-badge-color: rgb(var(--label-amaranth-04, 202 51 77));
  }
}

:host([variant='aqua']) {
  --mds-badge-background: rgb(var(--label-aqua-04, 4 122 143));

  &:host([tone='weak']) {
    --mds-badge-background: rgb(var(--label-aqua-09, 151 237 252));
    --mds-badge-color: rgb(var(--label-aqua-02, 2 75 88));
  }

  &:host([tone='outline']) {
    --mds-badge-border-color: rgb(var(--label-aqua-06, 6 186 217));
    --mds-badge-color: rgb(var(--label-aqua-04, 4 122 143));
  }
}

:host([variant='blue']) {
  --mds-badge-background: rgb(var(--label-blue-04, 44 96 250));

  &:host([tone='weak']) {
    --mds-badge-background: rgb(var(--label-blue-09, 209 224 254));
    --mds-badge-color: rgb(var(--label-blue-02, 9 41 189));
  }

  &:host([tone='outline']) {
    --mds-badge-border-color: rgb(var(--label-blue-06, 131 170 255));
    --mds-badge-color: rgb(var(--label-blue-04, 44 96 250));
  }
}

:host([variant='green']) {
  --mds-badge-background: rgb(var(--label-green-04, 21 128 61));

  &:host([tone='weak']) {
    --mds-badge-background: rgb(var(--label-green-09, 154 242 188));
    --mds-badge-color: rgb(var(--label-green-02, 12 79 37));
  }

  &:host([tone='outline']) {
    --mds-badge-border-color: rgb(var(--label-green-06, 34 195 93));
    --mds-badge-color: rgb(var(--label-green-04, 21 128 61));
  }
}

:host([variant='lime']) {
  --mds-badge-background: rgb(var(--label-lime-04, 81 124 12));

  &:host([tone='weak']) {
    --mds-badge-background: rgb(var(--label-lime-09, 186 240 97));
    --mds-badge-color: rgb(var(--label-lime-02, 49 76 6));
  }

  &:host([tone='outline']) {
    --mds-badge-border-color: rgb(var(--label-lime-06, 123 189 20));
    --mds-badge-color: rgb(var(--label-lime-04, 81 124 12));
  }
}

:host([variant='orange']) {
  --mds-badge-background: rgb(var(--label-orange-04, 181 82 13));

  &:host([tone='weak']) {
    --mds-badge-background: rgb(var(--label-orange-09, 255 215 194));
    --mds-badge-color: rgb(var(--label-orange-02, 114 49 5));
  }

  &:host([tone='outline']) {
    --mds-badge-border-color: rgb(var(--label-orange-06, 253 141 81));
    --mds-badge-color: rgb(var(--label-orange-04, 181 82 13));
  }
}

:host([variant='orchid']) {
  --mds-badge-background: rgb(var(--label-orchid-04, 202 34 125));

  &:host([tone='weak']) {
    --mds-badge-background: rgb(var(--label-orchid-09, 255 212 229));
    --mds-badge-color: rgb(var(--label-orchid-02, 129 0 66));
  }

  &:host([tone='outline']) {
    --mds-badge-border-color: rgb(var(--label-orchid-06, 248 134 183));
    --mds-badge-color: rgb(var(--label-orchid-04, 202 34 125));
  }
}

:host([variant='sky']) {
  --mds-badge-background: rgb(var(--label-sky-04, 7 118 169));

  &:host([tone='weak']) {
    --mds-badge-background: rgb(var(--label-sky-09, 196 229 250));
    --mds-badge-color: rgb(var(--label-sky-02, 3 73 106));
  }

  &:host([tone='outline']) {
    --mds-badge-border-color: rgb(var(--label-sky-06, 82 180 238));
    --mds-badge-color: rgb(var(--label-sky-04, 7 118 169));
  }
}

:host([variant='violet']) {
  --mds-badge-background: rgb(var(--label-violet-04, 128 78 232));

  &:host([tone='weak']) {
    --mds-badge-background: rgb(var(--label-violet-09, 225 219 255));
    --mds-badge-color: rgb(var(--label-violet-02, 84 7 175));
  }

  &:host([tone='outline']) {
    --mds-badge-border-color: rgb(var(--label-violet-06, 178 157 254));
    --mds-badge-color: rgb(var(--label-violet-04, 128 78 232));
  }
}

:host([variant='purple']) {
  --mds-badge-background: rgb(var(--label-purple-04, 150 64 227));

  &:host([tone='weak']) {
    --mds-badge-background: rgb(var(--label-purple-09, 233 217 255));
    --mds-badge-color: rgb(var(--label-purple-02, 95 0 162));
  }

  &:host([tone='outline']) {
    --mds-badge-border-color: rgb(var(--label-purple-06, 197 150 254));
    --mds-badge-color: rgb(var(--label-purple-04, 150 64 227));
  }
}

:host([variant='yellow']) {
  --mds-badge-background: rgb(var(--label-yellow-04, 140 107 22));

  &:host([tone='weak']) {
    --mds-badge-background: rgb(var(--label-yellow-09, 254 219 157));
    --mds-badge-color: rgb(var(--label-yellow-02, 86 67 20));
  }

  &:host([tone='outline']) {
    --mds-badge-border-color: rgb(var(--label-yellow-06, 214 163 15));
    --mds-badge-color: rgb(var(--label-yellow-04, 140 107 22));
  }
}

:host([variant='warning']) {
  --mds-badge-background: rgb(var(--magma-warning-emphasis, var(--status-warning-04, 142 106 0)));

  &:host([tone='weak']) {
    --mds-badge-background: rgb(var(--magma-warning-wash-base, var(--status-warning-09, 255 220 117)));
    --mds-badge-color: rgb(var(--magma-warning-text-muted, var(--text-warning-muted, 88 66 0)));
  }

  &:host([tone='outline']) {
    --mds-badge-border-color: rgb(var(--magma-warning-border-strong, var(--border-warning-strong, 184 130 0)));
    --mds-badge-color: rgb(var(--magma-warning-emphasis, var(--status-warning-04, 142 106 0)));
  }
}

:host([variant='error']) {
  --mds-badge-background: rgb(var(--magma-danger-emphasis, var(--status-error-04, 196 64 65)));

  &:host([tone='weak']) {
    --mds-badge-background: rgb(var(--magma-danger-wash-base, var(--status-error-09, 255 214 211)));
    --mds-badge-color: rgb(var(--magma-danger-text-muted, var(--text-error-muted, 132 0 11)));
  }

  &:host([tone='outline']) {
    --mds-badge-border-color: rgb(var(--magma-danger-border-strong, var(--border-error-strong, 218 96 93)));
    --mds-badge-color: rgb(var(--magma-danger-emphasis, var(--status-error-04, 196 64 65)));
  }
}

:host([variant='success']) {
  --mds-badge-background: rgb(var(--magma-success-emphasis, var(--status-success-04, 0 128 57)));

  &:host([tone='weak']) {
    --mds-badge-background: rgb(var(--magma-success-wash-base, var(--status-success-09, 191 233 205)));
    --mds-badge-color: rgb(var(--magma-success-text-muted, var(--text-success-muted, 0 80 7)));
  }

  &:host([tone='outline']) {
    --mds-badge-border-color: rgb(var(--magma-success-border-strong, var(--border-success-strong, 17 166 98)));
    --mds-badge-color: rgb(var(--magma-success-emphasis, var(--status-success-04, 0 128 57)));
  }
}

:host([variant='info']) {
  --mds-badge-background: rgb(var(--magma-info-emphasis, var(--status-info-04, 0 119 164)));

  &:host([tone='weak']) {
    --mds-badge-background: rgb(var(--magma-info-wash-base, var(--status-info-09, 193 230 246)));
    --mds-badge-color: rgb(var(--magma-info-text-muted, var(--text-info-muted, 0 71 114)));
  }

  &:host([tone='outline']) {
    --mds-badge-border-color: rgb(var(--magma-info-border-strong, var(--border-info-strong, 18 154 196)));
    --mds-badge-color: rgb(var(--magma-info-emphasis, var(--status-info-04, 0 119 164)));
  }
}

/* The light / dark variants are a pure-inversion pair: light is painted in the
 * paper of the mode, --tone-neutral-seed (#fff light / #000 dark), dark in the
 * ink of the mode. The seed is the intended value here, not a surface: no
 * elevation role is paper in both modes (SEMANTIC_COLOR_SPEC 10 and 15). */

:host([variant='light']) {
  --mds-badge-background: rgb(var(--tone-neutral-seed, 255 255 255));
  --mds-badge-color: rgb(var(--magma-text-muted, var(--text-neutral-muted, 73 73 73)));

  &:host([tone='weak']) {
    --mds-badge-background: rgb(var(--magma-wash-soft, var(--tone-neutral-10, 237 237 237)));
    --mds-badge-color: rgb(var(--magma-text-muted, var(--text-neutral-muted, 73 73 73)));
  }

  &:host([tone='outline']) {
    --mds-badge-color: rgb(var(--magma-text-default, var(--text-neutral-default, 5 5 5)));
    --mds-badge-border-color: rgb(var(--magma-border-strong, var(--border-neutral-strong, 140 140 140)));
  }
}

:host([variant='dark']) {
  --mds-badge-background: rgb(var(--magma-surface-inverse-muted, var(--tone-neutral-03, 73 73 73)));
  --mds-badge-color: rgb(var(--magma-on-inverse, var(--tone-neutral-seed, 255 255 255)));

  &:host([tone='weak']) {
    --mds-badge-background: rgb(var(--magma-wash-soft, var(--tone-neutral-10, 237 237 237)));
    --mds-badge-color: rgb(var(--magma-text-muted, var(--text-neutral-muted, 73 73 73)));
  }

  &:host([tone='outline']) {
    --mds-badge-color: rgb(var(--magma-text-default, var(--text-neutral-default, 5 5 5)));
    --mds-badge-border-color: rgb(var(--magma-border-strong, var(--border-neutral-strong, 140 140 140)));
  }
}

:host {
  --mds-badge-color: rgb(var(--magma-text-on-emphasis, 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-badge-transition-duration: 0s;
}

@media (prefers-reduced-motion: reduce) {
  :host([pref-animation='system']),
  :host(:not([pref-animation])) {
    --private-badge-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']) {
  &:host([tone='strong']),
  &:host([tone='weak']) {
    box-shadow: var(--shadow-ring, 0 0 0 1px rgb(var(--tone-neutral-01, 5 5 5) / 0.3)) inset;
  }
}

@media (prefers-color-scheme: dark) {
  :host([pref-mode='system']:not([pref-theme-scheme='light'])),
  :host(:not([pref-mode]):not([pref-theme-scheme='light'])) {
    &:host([tone='strong']),
    &:host([tone='weak']) {
      box-shadow: var(--shadow-ring, 0 0 0 1px rgb(var(--tone-neutral-01, 5 5 5) / 0.3)) inset;
    }
  }
}

/* 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([tone='weak']) {
  box-shadow: var(--shadow-ring, 0 0 0 1px rgb(var(--tone-neutral-01, 5 5 5) / 0.3)) inset;
}

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

:host([pref-contrast='more'][pref-mode='dark']:not([pref-theme-scheme='light'])[tone='strong']),
:host([pref-contrast='more'][pref-theme-scheme='dark'][tone='strong']),
:host([pref-contrast='more'][pref-mode='dark']:not([pref-theme-scheme='light'])[tone='weak']),
:host([pref-contrast='more'][pref-theme-scheme='dark'][tone='weak']) {
  box-shadow: var(--shadow-outline-strong, rgb(0 0 0 / 0.25) 0px 1px 1px, rgb(0 0 0 / 0.13) 0px 0px 1px 1px) inset;
}

@media (prefers-contrast: more) {
  :host([pref-contrast='system'][pref-mode='dark']:not([pref-theme-scheme='light'])[tone='strong']),
  :host([pref-contrast='system'][pref-theme-scheme='dark'][tone='strong']),
  :host([pref-contrast='system'][pref-mode='dark']:not([pref-theme-scheme='light'])[tone='weak']),
  :host([pref-contrast='system'][pref-theme-scheme='dark'][tone='weak']) {
    box-shadow: var(--shadow-outline-strong, rgb(0 0 0 / 0.25) 0px 1px 1px, rgb(0 0 0 / 0.13) 0px 0px 1px 1px) inset;
  }
}

@media (prefers-color-scheme: dark) {
  :host([pref-contrast='more'][pref-mode='system']:not([pref-theme-scheme='light'])[tone='strong']),
  :host([pref-contrast='more'][pref-mode='system']:not([pref-theme-scheme='light'])[tone='weak']) {
    box-shadow: var(--shadow-outline-strong, rgb(0 0 0 / 0.25) 0px 1px 1px, rgb(0 0 0 / 0.13) 0px 0px 1px 1px) inset;
  }
}

@media (prefers-contrast: more) and (prefers-color-scheme: dark) {
  :host([pref-contrast='system'][pref-mode='system']:not([pref-theme-scheme='light'])[tone='strong']),
  :host([pref-contrast='system'][pref-mode='system']:not([pref-theme-scheme='light'])[tone='weak']) {
    box-shadow: var(--shadow-outline-strong, rgb(0 0 0 / 0.25) 0px 1px 1px, rgb(0 0 0 / 0.13) 0px 0px 1px 1px) inset;
  }
}

