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


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


/**
 * @prop --mds-usage-border-color: The border-color applied to the usage container or indicator.
 * @prop --mds-usage-header-background: The background-color of the usage header.
 * @prop --mds-usage-header-color: The text/icon color of the usage header.
 */

:host {
  --mds-usage-border-color: rgb(var(--magma-info-border-strong, var(--border-info-strong, 18 154 196)));
  --mds-usage-header-background: var(--mds-usage-border-color, rgb(var(--magma-info-border-strong, var(--border-info-strong, 18 154 196))));
  --mds-usage-header-color: rgb(var(--magma-text-on-emphasis, var(--tone-neutral-seed, 255 255 255)));
  --mds-usage-transition-duration: var(--duration-200, 200ms);
  --private-usage-transition-duration: var(--mds-usage-transition-duration);

  @apply ease-out;

  border-color: var(--mds-usage-border-color, rgb(var(--magma-info-border-strong, var(--border-info-strong, 18 154 196))));
  border-radius: var(--magma-radius-lg, var(--radius-squircle-lg, 28px));
  border-style: solid;
  border-width: --spacing(50);
  corner-shape: var(--magma-corner-shape, squircle);

  /* is seems it's not working on web components, due of a bug
  container-name: mds-usage;
  container-type: inline-size;
  */
  display: grid;
  gap: --spacing(200);
  grid-auto-rows: min-content;
  grid-template-columns: minmax(0, 100%);
  padding: --spacing(400);
  padding-top: 0;
  position: relative;
  transition-duration: var(--private-usage-transition-duration);
  transition-property: background-color, box-shadow, color;
  width: 100%;
}

.label {
  color: var(--mds-usage-header-color, rgb(var(--magma-text-on-emphasis, var(--tone-neutral-seed, 255 255 255))));
}

mds-icon {
  fill: var(--mds-usage-header-color, rgb(var(--magma-text-on-emphasis, var(--tone-neutral-seed, 255 255 255))));
  height: --spacing(400);
  width: --spacing(400);
}

.header {
  align-items: center;
  background-color: var(--mds-usage-header-background, rgb(var(--magma-info-border-strong, var(--border-info-strong, 18 154 196))));
  border-bottom-left-radius: var(--magma-radius-xs, var(--radius-squircle-xs, 14px));
  border-bottom-right-radius: var(--magma-radius-xs, var(--radius-squircle-xs, 14px));
  corner-shape: var(--magma-corner-shape, squircle);
  display: inline-flex;
  gap: --spacing(200);
  height: --spacing(600);
  justify-self: start;
  padding-left: --spacing(200);
  padding-right: --spacing(200);
}

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

@media (prefers-reduced-motion: reduce) {
  :host([pref-animation='system']),
  :host(:not([pref-animation])) {
    --private-usage-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.
 *
 * The header background is NOT refined here. It was, in eight declarations that
 * never took effect: the header painted with --mds-usage-border-color until the
 * token was wired up. They are a snapshot of the raw ramp from before #638 put
 * the status fills on the emphasis band, so reviving them would REGRESS that
 * migration, in dark only: info/do/dont would fall from the emphasis fill back
 * to the raw 05 step (on-emphasis 74.9 -> 67.1/67.4 APCA Lc), `warn` would land
 * its ink at 25.0 Lc (#ffe595 on #edb100), and a host with no variant attribute
 * would take a header one ramp step off its own border. Measured with the APCA
 * helpers in projects/design-tokens/src/lib/contrast-gate.ts; do not restore
 * without measuring again. */

:host([pref-mode='dark']:not([pref-theme-scheme='light'])),
:host([pref-theme-scheme='dark']) {
  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'])) {
    box-shadow: var(--shadow-ring, 0 0 0 1px rgb(var(--tone-neutral-01, 5 5 5) / 0.3));
  }
}

:host([variant='do']) {
  --mds-usage-border-color: rgb(var(--magma-success-emphasis, var(--status-success-04, 0 128 57)));
  --mds-usage-header-color: rgb(var(--magma-success-on-emphasis, var(--tone-neutral-seed, 255 255 255)));
}

:host([variant='info']) {
  --mds-usage-border-color: rgb(var(--magma-info-emphasis, var(--status-info-04, 0 119 164)));
  --mds-usage-header-color: rgb(var(--magma-info-on-emphasis, var(--tone-neutral-seed, 255 255 255)));
}

:host([variant='dont']) {
  --mds-usage-border-color: rgb(var(--magma-danger-emphasis, var(--status-error-04, 196 64 65)));
  --mds-usage-header-color: rgb(var(--magma-danger-on-emphasis, var(--tone-neutral-seed, 255 255 255)));
}

:host([variant='warn']) {
  --mds-usage-border-color: rgb(var(--magma-warning-wash-strong, var(--status-warning-08, 255 205 57)));
  --mds-usage-header-color: rgb(var(--magma-warning-text-muted, var(--text-warning-muted, 88 66 0)));
}

