/*
 * Page or block message. role="status" by default; role="alert" only for errors (it interrupts the reader).
 * Tint background always takes the -strong text (>= 8:1, docs/DESIGN.md, Tokens); the base color only marks the edge and icon.
 */
@layer components {
  .alert {
    --alert-tint: var(--color-info-tint);
    --alert-strong: var(--color-info-strong);
    --alert-accent: var(--color-info);

    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border: var(--border-width) solid var(--alert-accent);
    border-inline-start-width: var(--space-1);
    border-radius: var(--radius-lg);
    background: var(--alert-tint);
    color: var(--alert-strong);
    font-size: var(--text-sm);
  }

  .alert--success {
    --alert-tint: var(--color-success-tint);
    --alert-strong: var(--color-success-strong);
    --alert-accent: var(--color-success);
  }

  .alert--danger {
    --alert-tint: var(--color-danger-tint);
    --alert-strong: var(--color-danger-strong);
    --alert-accent: var(--color-danger);
  }

  .alert--warning {
    --alert-tint: var(--color-warning-tint);
    --alert-strong: var(--color-warning-strong);
    --alert-accent: var(--color-warning);
  }

  .alert--info {
    --alert-tint: var(--color-info-tint);
    --alert-strong: var(--color-info-strong);
    --alert-accent: var(--color-info);
  }

  .alert__icon {
    flex: none;
    inline-size: 1.25em;
    block-size: 1.25em;
    margin-block-start: var(--space-1);
    color: var(--alert-accent);
  }

  /* Grows to fill the row; below ~15rem of room the action wraps under the text. */
  .alert__body {
    flex: 1 1 15rem;
    min-inline-size: 0;
  }

  .alert__title {
    font-weight: var(--weight-bold);
  }

  .alert__text {
    line-height: var(--leading-normal);
  }

  /* Contextual action ("Tentar de novo"): outlined in the alert's own strong color, so it fits every variant. */
  .alert__action {
    flex: none;
    min-block-size: var(--space-8);
    padding: var(--space-1) var(--space-3);
    border: var(--border-width) solid var(--alert-strong);
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--alert-strong);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    transition: transform var(--duration-fast) var(--ease-out);

    &:hover:not(:disabled) {
      background: var(--color-surface);
    }

    &:active:not(:disabled) {
      transform: scale(0.97);
    }

    /* Retry in flight: the label stays, the cursor tells it is busy. */
    &[aria-busy="true"] {
      cursor: progress;
    }

    &:disabled {
      opacity: 0.55;
    }
  }
}
