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


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


/**
 * @prop --mds-status-bar-max-width: Public. Maximum width of the status bar.
 * @prop --mds-status-bar-backdrop: Background color of the status bar backdrop.
 * @prop --mds-status-bar-backdrop-filter: Filter applied to the status bar backdrop.
 */

/* ❌ Not supported
@property --mds-status-bar-backdrop-filter {
  inherits: false;
  initial-value: blur(10px);
  syntax: "<filter-function>";
}
*/

:host {
  --mds-status-bar-max-width: --spacing(12500);

  /* a translucent tray of the text ink, darker than the page in light and lighter in dark
   * like a wash: not a projected shadow, so not --magma-shadow-ink */
  --mds-status-bar-backdrop: rgb(var(--magma-text-default, var(--text-neutral-default, 5 5 5)) / 0.1);
  --mds-status-bar-backdrop-filter: blur(--spacing(250));

  display: block;
}

mds-modal {
  --mds-modal-custom-window-distance: 0;
  --mds-modal-custom-closed-transform: translate(0, 100%);
}

.status-bar-area {
  -webkit-backdrop-filter: var(--mds-status-bar-backdrop-filter);
          backdrop-filter: var(--mds-status-bar-backdrop-filter);
  background-color: var(--mds-status-bar-backdrop, rgb(var(--magma-text-default, var(--text-neutral-default, 5 5 5)) / 0.1));
  border-radius: var(--magma-radius-xl, var(--radius-squircle-xl, 36px)) var(--magma-radius-xl, var(--radius-squircle-xl, 36px)) 0 0;
  corner-shape: var(--magma-corner-shape, squircle);
  margin-left: --spacing(600);
  margin-right: --spacing(600);

  /* the area is the window of the inner mds-modal, which gives a slotted window the width of a
     dialog (#1202): the area hugs the bar instead, and a rule of this tree wins over ::slotted */
  max-width: none;
  padding: --spacing(200) --spacing(200) --spacing(600);
  transition-property: background-color, transform, opacity;
  width: auto;
}

.status-bar {

  /* overlay: the fields inside take the step below (#1193) */
  --magma-field-fill: var(--magma-surface-default, var(--surface-neutral-default, 242 242 242));

  align-items: flex-start;
  background-color: rgb(var(--magma-surface-overlay, var(--surface-neutral-overlay, 255 255 255)));
  border-radius: var(--magma-radius-lg, var(--radius-squircle-lg, 28px));
  box-shadow: var(--shadow-md, 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1));
  box-sizing: border-box;
  corner-shape: var(--magma-corner-shape, squircle);
  display: inline-flex;
  flex-wrap: wrap;
  gap: --spacing(400);
  max-width: var(--mds-status-bar-max-width, --spacing(12500));
  padding: --spacing(600);
}

.actions {
  display: inline-flex;
  flex-grow: 1;
  flex-wrap: wrap;
  gap: var(--magma-rhythm-inline, 12px);
}

@media (width <= 480px) {
  .status-bar-area {
    border-radius: 0;
    margin-left: 0;
    margin-right: 0;
    padding: --spacing(400);
    width: 100%;
  }

  /* the bar takes the width of the window here, so it is the container of its row of actions */

  .status-bar {
    container-name: status-bar;
    container-type: inline-size;
    width: 100%;
  }

  ::slotted(*) {
    flex-grow: 1;
  }
}

/* actions/stacked (#1189): under --magma-container-actions the row stacks on a line of its own,
   every action at the full width in the order of the row, the main action at the bottom; the
   query reads its Tailwind bridge at build time, since a container query reads no var() */

@container status-bar (width < --theme(--container-actions)) {
  .actions {
    flex-basis: 100%;
    flex-direction: column;
  }

  /* mds-button holds itself at the start of a row: stretched here, a rule of this tree wins */

  ::slotted(*) {
    align-self: stretch;
  }
}

/* Consumption preference. The component mirrors the resolved level from <html>
 * onto its host as pref-consumption (see subscribePreference in @common/preference);
 * this plain shadow selector then drops the backdrop filter. Cross-browser, no
 * :host-context. */

:host([pref-consumption='medium']) {
  --mds-status-bar-backdrop-filter: none;
}

/* 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-status-bar-backdrop: rgb(var(--magma-text-default, var(--text-neutral-default, 5 5 5)) / 0.3);
}

@media (prefers-contrast: more) {
  :host([pref-contrast='system']),
  :host(:not([pref-contrast])) {
    --mds-status-bar-backdrop: rgb(var(--magma-text-default, var(--text-neutral-default, 5 5 5)) / 0.3);
  }
}

/* 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'])) .status-bar,
:host([pref-theme-scheme='dark']) .status-bar {
  box-shadow: var(--shadow-ring-weak, 0 0 0 1px rgb(var(--tone-neutral-01, 5 5 5) / 0.15));
}

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

