/* Meridian · Alert banner
   Markup:   .dm-alert.dm-alert--{info|success|warning|error} > .dm-alert__inner >
             __icon + __content (> __title? + __body) + __dismiss?
   Static inline messaging on the matching -subtle background: solid semantic color
   for the icon dot and title, on-surface for body copy.
   Dismissal collapses via the grid-template-rows trick (.dm-alert--dismissing). */

.dm-alert {
  display: grid;
  grid-template-rows: 1fr;
  background: var(--dm-color-info-subtle);
  border-left: 3px solid var(--dm-color-info);
  border-radius: var(--dm-rounded-md);
  transition: grid-template-rows var(--dm-duration-slow) var(--dm-ease-emphasized),
    opacity var(--dm-duration-base) var(--dm-ease-standard);
}

.dm-alert--dismissing {
  grid-template-rows: 0fr;
  opacity: 0;
}

.dm-alert__inner {
  display: flex;
  align-items: flex-start;
  gap: var(--dm-space-sm);
  min-height: 0;
  overflow: hidden; /* lets the 0fr row actually collapse */
  padding: var(--dm-space-md);
  transition: padding var(--dm-duration-slow) var(--dm-ease-emphasized);
}

.dm-alert--dismissing .dm-alert__inner {
  padding-top: 0;
  padding-bottom: 0;
}

/* ---- Parts ---------------------------------------------------------------- */

.dm-alert__icon {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  margin-top: 7px; /* optically centers the dot on the first text line */
  border-radius: var(--dm-rounded-full);
  background: var(--dm-color-info);
}

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

.dm-alert__title {
  font: var(--dm-type-label-md);
  letter-spacing: var(--dm-tracking-label);
  color: var(--dm-color-info);
}

.dm-alert__title + .dm-alert__body {
  margin-top: var(--dm-space-xs);
}

.dm-alert__body {
  font: var(--dm-type-body-sm);
  color: var(--dm-color-on-surface);
}

.dm-alert__dismiss {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin: -2px -4px 0 0; /* tucks the ✕ toward the corner */
  padding: 0;
  font-size: 1rem;
  line-height: 1;
  color: var(--dm-color-on-surface-variant);
  background: none;
  border: none;
  border-radius: var(--dm-rounded-full);
  cursor: pointer;
  transition: color var(--dm-duration-fast) var(--dm-ease-standard);
}

.dm-alert__dismiss:hover {
  color: var(--dm-color-on-surface);
}

/* ---- Variants --------------------------------------------------------------- */

.dm-alert--success {
  background: var(--dm-color-success-subtle);
  border-left-color: var(--dm-color-success);
}

.dm-alert--success .dm-alert__icon {
  background: var(--dm-color-success);
}

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

.dm-alert--warning {
  background: var(--dm-color-warning-subtle);
  border-left-color: var(--dm-color-warning);
}

.dm-alert--warning .dm-alert__icon {
  background: var(--dm-color-warning);
}

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

.dm-alert--error {
  background: var(--dm-color-error-subtle);
  border-left-color: var(--dm-color-error);
}

.dm-alert--error .dm-alert__icon {
  background: var(--dm-color-error);
}

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