// Alert banners provide persistent, contextual feedback in a page.
.alert {
  --alert-container: var(--md-sys-color-surface-variant);
  --alert-on-container: var(--md-sys-color-on-surface-variant);
  --alert-border: var(--md-sys-color-outline-variant);

  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 0.875rem;
  width: 100%;
  box-sizing: border-box;
  padding: 1rem 1.125rem;
  margin: 0 0 1rem;
  border: 1px solid transparent;
  border-radius: 0.75rem;
  background: var(--alert-container);
  color: var(--alert-on-container);
  line-height: 1.5;

  .alert-icon {
    flex: 0 0 auto;
    align-self: center;
    margin-top: 0;
    font-size: 1.375rem;
    line-height: 1;
  }

  .alert-image {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    object-fit: cover;
  }

  .alert-content {
    min-width: 0;
    flex: 1 1 auto;
  }

  .alert-title {
    display: block;
    margin: 0 0 0.25rem;
    font-weight: 600;
  }

  .alert-message {
    margin: 0;
  }

  .alert-close {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    margin: -0.25rem -0.375rem -0.25rem 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: inherit;
    cursor: pointer;

    &:hover,
    &:focus-visible {
      background: color-mix(in srgb, currentColor 12%, transparent);
    }

    .material-icons {
      font-size: 1.25rem;
    }
  }

  &.alert-info {
    --alert-container: var(--md-sys-color-secondary-container);
    --alert-on-container: var(--md-sys-color-on-secondary-container);
    --alert-border: var(--md-sys-color-secondary);
  }

  &.alert-success {
    --alert-container: var(--md-sys-color-tertiary-container);
    --alert-on-container: var(--md-sys-color-on-tertiary-container);
    --alert-border: var(--md-sys-color-tertiary);
  }

  &.alert-warning {
    --alert-container: var(--md-sys-color-primary-container);
    --alert-on-container: var(--md-sys-color-on-primary-container);
    --alert-border: var(--md-sys-color-primary);
  }

  &.alert-error {
    --alert-container: var(--md-sys-color-error-container);
    --alert-on-container: var(--md-sys-color-on-error-container);
    --alert-border: var(--md-sys-color-error);
  }

  &.alert-outlined {
    border-color: var(--alert-border);
    background: transparent;
  }

  &.alert-filled {
    border-color: var(--alert-border);
    background: var(--alert-border);
    color: var(--md-sys-color-on-primary);
  }

  &.alert-compact {
    align-items: center;
    padding-block: 0.625rem;
  }

  &[hidden] {
    display: none;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .alert {
    transition: opacity 180ms ease, transform 180ms ease;

    &.alert-dismissing {
      opacity: 0;
      transform: translateY(-0.25rem);
    }
  }
}
