:root {
  --alert-height: auto;
  --alert-padding: 0.75rem 1rem;
  --alert-radius: 6px;
  --alert-shadow: 0 8px 24px rgba(2, 8, 23, 0.35);
  --alert-z: 9999;

  /* colors (defaults - override per variant) */
  --alert-bg: #0f172a;
  --alert-color: #fff;
  --alert-accent: rgba(255, 255, 255, 0.08);
  --alert-link: #fff;
  --alert-transition: 240ms ease;
}

/* base container (fixed top) */
.alert {
  box-sizing: border-box;
  position: fixed;
  inset-inline: 1rem; /* left/right safe spacing */
  top: 1rem;
  z-index: var(--alert-z);
  display: flex;
  align-items: stretch;
  padding: var(--alert-padding);
  gap: 0.75rem;
  border-radius: var(--alert-radius);
  color: var(--alert-color);
  background: linear-gradient(
    90deg,
    var(--alert-bg),
    rgba(255, 255, 255, 0.02)
  );
  box-shadow: var(--alert-shadow);
  max-width: calc(100% - 2rem);
  align-items: center;
  transition: transform var(--alert-transition), opacity var(--alert-transition);
  transform-origin: top center;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
    Arial;
}

/* hidden state */
.alert[hidden] {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px) scale(0.995);
}

/* inner layout */
.alert__icon {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--alert-accent);
}
.alert__content {
  flex: 1 1 auto;
  min-width: 0;
}
.alert__message {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.3;
  color: var(--alert-color);
  word-break: break-word;
}
.alert__actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-left: 0.5rem;
  flex: 0 0 auto;
}

/* CTA button */
.alert__cta {
  background: rgba(255, 255, 255, 0.12);
  color: var(--alert-link);
  border: none;
  padding: 0.45rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.alert__cta:focus {
  outline: 3px solid rgba(255, 255, 255, 0.12);
  outline-offset: 2px;
}

/* Close button */
.alert__close {
  background: transparent;
  border: none;
  color: var(--alert-color);
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  border-radius: 6px;
}
.alert__close:focus {
  outline: 3px solid rgba(255, 255, 255, 0.12);
}

/* small screens */
@media (max-width: 640px) {
  .alert {
    inset-inline: 0.5rem;
    top: 0.75rem;
    padding: 0.6rem;
    gap: 0.5rem;
  }
  .alert__icon {
    width: 36px;
    height: 36px;
  }
}

/* Variants */
.alert--info {
  --alert-bg: #065f46;
  --alert-color: #e6fffa;
  --alert-accent: rgba(230, 255, 250, 0.06);
  --alert-link: #ccffeb;
}
.alert--success {
  --alert-bg: #065f46;
  --alert-color: #e6fffa;
  --alert-accent: rgba(230, 255, 250, 0.06);
  --alert-link: #d1fae5;
}
.alert--warning {
  --alert-bg: #854d0e;
  --alert-color: #fff7ed;
  --alert-accent: rgba(255, 245, 230, 0.06);
  --alert-link: #ffedd5;
}
.alert--danger {
  --alert-bg: #7f1d1d;
  --alert-color: #fff1f2;
  --alert-accent: rgba(255, 230, 235, 0.06);
  --alert-link: #ffdede;
}

/* compact variant */
.alert--compact {
  padding: 0.5rem 0.75rem;
  gap: 0.5rem;
}

/* visually hidden helper (for screen reader-only text) */
.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
