/* Flash container (the turbo-frame) */
#flash {
  position: fixed;
  display: flex;
  flex-direction: column-reverse;
  gap: 1.5rem;
  align-items: center;
  top: 2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 102;
}

/* Individual flash */
flash {
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 2.5rem 1rem 1.5rem;
  border-radius: 0.25rem;
  z-index: 100;
  font-weight: 600;

  /* Retain animation values applied by the last keyframe */
  animation-fill-mode: both !important;
  will-change: transform;
  animation: fade-in .3s ease,
  slide-in .3s ease;

  a {
    text-decoration: underline;
  }

  &.center {
    display: block;
    text-align: center;
  }

  &.right {
    display: block;
    text-align: right;
  }

  /* Flash types */

  &:is([type="info"], [type="notice"]) {
    background: var(--brand-charcoal);
    box-shadow: 0 0.1rem 0.25rem var(--brand-charcoal);
    color: var(--pure-white);

    .flash__icon {
      fill: var(--pure-white);
    }

    .flash__close-btn {
      fill: var(--pure-white);
    }
  }

  &:is([type="success"]) {
    background-color: var(--success-lightest);
    box-shadow: 0 0.1rem 0.25rem var(--success-dark);
    color: var(--success-dark);

    .flash__icon {
      fill: var(--success-dark);
    }

    .flash__close-btn {
      fill: var(--success-dark);
    }
  }

  &:is([type="warning"], [type="alert"]) {
    background-color: var(--warning-lightest);
    box-shadow: 0 0.1rem 0.25rem var(--warning-dark);
    color: var(--warning-dark);

    .flash__icon {
      fill: var(--warning-dark);
    }

    .flash__close-btn {
      fill: var(--warning-dark);
    }
  }

  &:is([type="danger"], [type="error"]) {
    background-color: var(--danger-lightest);
    box-shadow: 0 0.1rem 0.25rem var(--danger-dark);
    color: var(--danger-dark);

    .flash__icon {
      fill: var(--danger-dark);
    }

    .flash__close-btn {
      fill: var(--danger-dark);
    }
  }

  &:is([type="light"]) {
    background-color: #fff;
    border: 1px solid #edf2f7;
    color: #1a202c;
  }

  &:is([type="dark"]) {
    background-color: #2d3748;
    border: 1px solid #1a202c;
    color: #d3d3d3;
  }

  /* TODO: the autosave flash needs to be refactored - either make it use the alerts controller and appear
      at the top with other alerts, or move these styles elsewhere. */

  &:is([type="autosave"]) {
    color: var(--theme-color-darker);
    font-size: 0.875rem;
    font-style: italic;
    margin: 0.5rem 0;
    padding: 0;
    text-align: right;

    &::after {
      display: none;
    }
  }
}

.flash__close-btn {
  position: absolute;
  right: 0;
  top: 0;
  transform: translateX(-1rem) translateY(1.2rem);
}


/* Animation keyframes */
@keyframes fade-in {
  from {
    opacity: 0
  }
}

@keyframes fade-out {
  to {
    opacity: 0
  }
}

@keyframes slide-in {
  from {
    transform: translateY(-5vh)
  }
}
