/*
 * THE BLOCKING CONFIRM. It sits one rung ABOVE every other overlay: an alert is
 * ABOUT the surface under it, so it can never be covered by the surface it is
 * asking about.
 */
@layer theme, base, lotics, components, utilities;
@layer lotics.tokens, lotics.reset, lotics.components;

@layer lotics.components {
  .lotics-alert__backdrop {
    position: fixed;
    inset: 0;
    /* Its own strength, between the overlay scrim and the strong one: an alert
       usually lands ON an already-scrimmed surface and still has to read as
       blocking. */
    background-color: color-mix(in srgb, var(--lotics-shadow-color) 30%, transparent);
    backdrop-filter: blur(3px);
    opacity: 1;
    transition: opacity var(--lotics-duration-base) var(--lotics-ease-standard);
    z-index: var(--lotics-z-overlay-above);
  }

  .lotics-alert__backdrop[data-starting-style],
  .lotics-alert__backdrop[data-ending-style] {
    opacity: 0;
  }

  /* A scrim on its way out is not a target — `css_contract.test.ts` § a closing
     scrim, which is where the reason is. */
  .lotics-alert__backdrop[data-ending-style] {
    pointer-events: none;
  }

  .lotics-alert__viewport {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    padding: var(--lotics-space-16);
    z-index: var(--lotics-z-overlay-above);
  }

  .lotics-alert__popup {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    min-width: 280px;
    max-width: 480px;
    max-height: 90vh;
    gap: var(--lotics-space-8);
    padding: var(--lotics-space-24);
    background-color: var(--card);
    color: var(--lotics-ink-default);
    border-radius: var(--lotics-radius-overlay);
    box-shadow:
      0 4px 6px color-mix(in srgb, var(--lotics-shadow-color) 10%, transparent),
      0 2px 4px color-mix(in srgb, var(--lotics-shadow-color) 6%, transparent);
    opacity: 1;
    transform: translateY(0);
    transition:
      opacity var(--lotics-duration-base) var(--lotics-ease-standard),
      transform var(--lotics-duration-base) var(--lotics-ease-standard);
  }

  .lotics-alert__popup[data-starting-style],
  .lotics-alert__popup[data-ending-style] {
    opacity: 0;
    transform: translateY(var(--lotics-space-24));
  }

  .lotics-alert__actions {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    gap: var(--lotics-space-8);
    margin-top: var(--lotics-space-8);
  }

  /* A neutral deferral sits apart from the decision pair beside it. */
  .lotics-alert__spacer {
    flex: 1;
    min-width: 0;
  }

  /* THE TYPED GATE — the instruction over the field it instructs, between the
     consequence and the buttons, so the reader meets it in the order they act. */
  .lotics-alert__typed {
    display: flex;
    flex-direction: column;
    gap: var(--lotics-space-4);
    margin-top: var(--lotics-space-4);
  }

  /* A refused commit, under the button that was pressed — the dialog stays open,
     so the failure has to be where the act was. */
  .lotics-alert__error {
    display: block;
  }
}
