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


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


/**
 * @prop --mds-input-field-message-color: Public. Sets the message text color of the component
 * @prop --mds-input-field-message-background: Public. Sets the message background color of the component, will be visible only if there is a text defined by `message` component attribute
 */

:host {
  --mds-input-field-message-color: rgb(var(--magma-text-muted, var(--text-neutral-muted, 73 73 73)));
  --mds-input-field-message-background: rgb(var(--magma-wash-soft, var(--tone-neutral-10, 237 237 237)));

  color: rgb(var(--magma-text-default, var(--text-neutral-default, 5 5 5)));
  corner-shape: var(--magma-corner-shape, squircle);
  display: grid;

  /* between the label and the control (#1189, rhythm/label-control) */
  gap: var(--magma-rhythm-label-control, 12px);
}

.message-window {
  background-color: transparent;
  border-radius: var(--magma-radius-2xl, var(--radius-squircle-2xl, 40px));
  color: var(--mds-input-field-message-color, rgb(var(--magma-text-muted, var(--text-neutral-muted, 73 73 73))));
  corner-shape: inherit;
  display: grid;
  gap: 0;
  padding: 0;
  transition-duration: var(--duration-300, 300ms);
  transition-property: background-color, color, gap, padding;
  transition-timing-function: var(--ease-out-expo, cubic-bezier(0.19, 1, 0.22, 1));
}

.message-window:has(.message:not(:empty)) {
  background-color: var(--mds-input-field-message-background, rgb(var(--magma-wash-soft, var(--tone-neutral-10, 237 237 237))));
  gap: --spacing(200);
  padding: --spacing(200);
}

.message {
  display: flex;
  flex-direction: column;
  height: auto;
  interpolate-size: allow-keywords;
  padding-bottom: --spacing(200);
  padding-left: --spacing(200);
  padding-right: --spacing(200);
  padding-top: --spacing(100);
  transition-duration: var(--duration-300, 300ms);
  transition-property: height, margin-top, opacity, padding;
  transition-timing-function: var(--ease-out-expo, cubic-bezier(0.19, 1, 0.22, 1));
}

.message:empty {
  height: 0;
  max-height: 0;
  opacity: 0;
  padding: 0;
}

.label:empty {
  display: none;
}

/* the icon before the label (`icon`), on the line of the label, in the colour of the variant */

.label-row {
  align-items: center;
  display: flex;
  gap: --spacing(100);
}

.label-icon {
  fill: rgb(var(--magma-text-muted, var(--text-neutral-muted, 73 73 73)));
  flex-shrink: 0;
  height: --spacing(400);
  width: --spacing(400);
}

.content {
  container-name: content;
  container-type: inline-size;
  display: flex;
  flex-wrap: wrap;
  gap: --spacing(200);
}

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

::slotted(*:not(:first-child)) {
  flex-shrink: 0;
}

@container content (max-width: 300px) {
  ::slotted(*) {
    flex-grow: 1;
    min-width: 100%;
  }
}

:host([variant='ai']) {
  --mds-input-field-message-color: rgb(var(--magma-accent-ai-emphasis-active, var(--variant-ai-02, 84 7 175)));
  --mds-input-field-message-background: rgb(var(--magma-accent-ai-surface, var(--variant-ai-09, 225 219 255)));
}

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

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

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

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

/* the icon before the label takes the emphasis of the variant, as the icon of the control does */

:host([variant='ai']) .label-icon {
  fill: rgb(var(--magma-accent-ai-emphasis, var(--variant-ai-04, 128 78 232)));
}

:host([variant='info']) .label-icon {
  fill: rgb(var(--magma-info-emphasis, var(--status-info-04, 0 119 164)));
}

:host([variant='success']) .label-icon {
  fill: rgb(var(--magma-success-emphasis, var(--status-success-04, 0 128 57)));
}

:host([variant='warning']) .label-icon {
  fill: rgb(var(--magma-warning-emphasis, var(--status-warning-04, 142 106 0)));
}

:host([variant='error']) .label-icon {
  fill: rgb(var(--magma-danger-emphasis, var(--status-error-04, 196 64 65)));
}

/* Propagate the field variant to the slotted input from the parent via
 * ::slotted, instead of the input reading its field. Cross-browser (no
 * :host-context); ::slotted (outer tree) wins over the input's own variant. */

:host([variant='info']) ::slotted(mds-input) {
  --mds-input-icon-color: rgb(var(--magma-info-emphasis, var(--status-info-04, 0 119 164)));
  --mds-input-tip-background: rgb(var(--magma-info-emphasis, var(--status-info-04, 0 119 164)));
  --mds-input-variant-color-rgb: 0 0 0;
}

:host([variant='info']) ::slotted(mds-input:focus) {
  --mds-input-icon-color: rgb(var(--magma-info-emphasis, var(--status-info-04, 0 119 164)));
  --mds-input-variant-color-rgb: var(--magma-info-emphasis, var(--status-info-04, 0 119 164));
}

:host([variant='warning']) ::slotted(mds-input) {
  --mds-input-icon-color: rgb(var(--magma-warning-emphasis, var(--status-warning-04, 142 106 0)));
  --mds-input-tip-background: rgb(var(--magma-warning-emphasis, var(--status-warning-04, 142 106 0)));
  --mds-input-variant-color-rgb: 0 0 0;
}

:host([variant='warning']) ::slotted(mds-input:focus) {
  --mds-input-icon-color: rgb(var(--magma-warning-emphasis, var(--status-warning-04, 142 106 0)));
  --mds-input-variant-color-rgb: var(--magma-warning-emphasis, var(--status-warning-04, 142 106 0));
}

:host([variant='success']) ::slotted(mds-input) {
  --mds-input-icon-color: rgb(var(--magma-success-emphasis, var(--status-success-04, 0 128 57)));
  --mds-input-tip-background: rgb(var(--magma-success-emphasis, var(--status-success-04, 0 128 57)));
  --mds-input-variant-color-rgb: 0 0 0;
}

:host([variant='success']) ::slotted(mds-input:focus) {
  --mds-input-icon-color: rgb(var(--magma-success-emphasis, var(--status-success-04, 0 128 57)));
  --mds-input-variant-color-rgb: var(--magma-success-emphasis, var(--status-success-04, 0 128 57));
}

:host([variant='error']) ::slotted(mds-input) {
  --mds-input-icon-color: rgb(var(--magma-danger-emphasis, var(--status-error-04, 196 64 65)));
  --mds-input-tip-background: rgb(var(--magma-danger-emphasis, var(--status-error-04, 196 64 65)));
  --mds-input-variant-color-rgb: 0 0 0;
}

:host([variant='error']) ::slotted(mds-input:focus) {
  --mds-input-icon-color: rgb(var(--magma-danger-emphasis, var(--status-error-04, 196 64 65)));
  --mds-input-variant-color-rgb: var(--magma-danger-emphasis, var(--status-error-04, 196 64 65));
}

