/* Alert Component */

/* Contextual feedback messages for user notifications */

@layer components {
  /* ============================================
     BASE ALERT
     ============================================ */
  .alert {
    /* Layout */
    display: flex;
    align-items: flex-start;
    gap: var(--space-4);
    padding: var(--space-4) var(--space-5);

    /* Typography */
    font-size: var(--text-md);
    line-height: var(--leading-normal);

    /* Appearance */
    border-radius: var(--radius-3);
    border-left: 4px solid;

    /* Animation */
    animation: alert-slide-in var(--transition-normal);
  }

  @keyframes alert-slide-in {
    from {
      opacity: 0;
      transform: translateY(-0.5rem);
    }

    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  /* ============================================
     ALERT STRUCTURE
     ============================================ */
  .alert__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 1.5rem;
    height: 1.5rem;
    margin-top: 0.125rem;
  }

  .alert__icon svg {
    width: 100%;
    height: 100%;
  }

  .alert__content {
    flex: 1;
    min-width: 0;
  }

  .alert__title {
    font-weight: var(--weight-semi);
    margin-bottom: var(--space-2);
  }

  .alert__message {
    color: inherit;
  }

  .alert__close {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 1.25rem;
    height: 1.25rem;
    padding: 0;
    margin-top: 0.125rem;
    margin-left: var(--space-3);
    background: none;
    border: none;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity var(--transition-fast);
  }

  .alert__close:hover {
    opacity: 1;
  }

  .alert__close svg {
    width: 100%;
    height: 100%;
  }

  /* ============================================
     VARIANT COLORS

     Body text uses --color-dark so alerts stay readable in both
     light and dark mode. The left border and icon carry the
     semantic color; titles/links use the semantic accent.
     ============================================ */

  /* Success */
  .alert--success {
    background-color: var(--brand-soft);
    border-left-color: var(--brand);
    color: var(--fg);
  }

  .alert--success .alert__icon {
    color: var(--brand-strong);
  }

  .alert--success .alert__title {
    color: var(--brand-strong);
  }

  .alert--success a {
    color: var(--brand-strong);
    text-decoration: underline;
    font-weight: var(--weight-medium);
  }

  .alert--success a:hover {
    text-decoration-thickness: 2px;
  }

  /* Error */
  .alert--error {
    background-color: var(--danger-soft);
    border-left-color: var(--danger);
    color: var(--fg);
  }

  .alert--error .alert__icon {
    color: var(--danger-strong);
  }

  .alert--error .alert__title {
    color: var(--danger-strong);
  }

  .alert--error a {
    color: var(--danger-strong);
    text-decoration: underline;
    font-weight: var(--weight-medium);
  }

  .alert--error a:hover {
    text-decoration-thickness: 2px;
  }

  /* Warning */
  .alert--warning {
    background-color: var(--caution-soft);
    border-left-color: var(--caution);
    color: var(--fg);
  }

  .alert--warning .alert__icon {
    color: var(--caution-strong);
  }

  .alert--warning .alert__title {
    color: var(--caution-strong);
  }

  .alert--warning a {
    color: var(--caution-strong);
    text-decoration: underline;
    font-weight: var(--weight-medium);
  }

  .alert--warning a:hover {
    text-decoration-thickness: 2px;
  }

  /* Info */
  .alert--info {
    background-color: var(--info-soft);
    border-left-color: var(--info);
    color: var(--fg);
  }

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

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

  .alert--info a {
    color: var(--info-strong);
    text-decoration: underline;
    font-weight: var(--weight-medium);
  }

  .alert--info a:hover {
    text-decoration-thickness: 2px;
  }

  /* Neutral */
  .alert--neutral {
    background-color: var(--neutral-100);
    border-left-color: var(--neutral-400);
    color: var(--fg);
  }

  .alert--neutral .alert__icon {
    color: var(--neutral-600);
  }

  .alert--neutral .alert__title {
    color: var(--fg);
  }

  .alert--neutral a {
    color: var(--brand);
    text-decoration: underline;
    font-weight: var(--weight-medium);
  }

  .alert--neutral a:hover {
    text-decoration-thickness: 2px;
  }

  /* ============================================
     DISMISSIBLE VARIANT
     ============================================ */
  .alert--dismissible {
    padding-right: var(--space-4);
  }

  /* Animation for removal */
  .alert.removing {
    animation: alert-slide-out var(--transition-normal);
  }

  @keyframes alert-slide-out {
    from {
      opacity: 1;
      transform: translateY(0);
    }

    to {
      opacity: 0;
      transform: translateY(-0.5rem);
    }
  }
}
