/* Nomios web UI: the confirm window and the short notices (U52). Design system:
   docs/design/DESIGN_SYSTEM.md. The stylesheets are linked in this order: tokens, base, shell,
   components, tasks, pages, modal, meetings, connection, search, viewing, confirm.

   The window is the modal family (the same tokens, radius and type), but more transparent: a
   lighter tint, a fine specular highlight on the top edge, a soft shadow, and the page behind
   dimmed and blurred as for the task window. It is ONE small element that does not scroll, so
   its blur costs next to nothing (the blur that cost frames was on scrolling regions, U46); no
   scrolling region gets a blur here. The text sits on a tint dark enough for 4.5:1 against the
   worst backdrop (a test checks it), and with reduced transparency the window is solid. */

@layer confirm {
  /* Which of the two is shown is decided by the script having run (confirm.js sets data-confirm on
     <html>), in the stylesheet and not by moving things around afterwards, so that nothing flashes
     when a part of the page is swapped: without the script the form that works on its own is
     there; with it, the button that asks first. */
  html:not([data-confirm="on"]) [data-confirm-only],
  html[data-confirm="on"] [data-confirm-fallback] {
    display: none;
  }

  .confirm {
    width: min(26rem, calc(100% - var(--space-6)));
    padding: 0;
    color: var(--color-text);
    background:
      linear-gradient(165deg, var(--glass-confirm-sheen), transparent 45%), var(--glass-confirm-bg);
    -webkit-backdrop-filter: blur(var(--glass-confirm-blur)) saturate(var(--glass-saturate));
    backdrop-filter: blur(var(--glass-confirm-blur)) saturate(var(--glass-saturate));
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-glass-confirm);
    overflow: hidden;
  }

  /* The page behind is dimmed and blurred less than behind the task window, so that the board
     still shows through the glass a little. */
  .confirm::backdrop {
    background: var(--scrim);
    -webkit-backdrop-filter: blur(var(--glass-confirm-backdrop-blur)) saturate(var(--glass-saturate));
    backdrop-filter: blur(var(--glass-confirm-backdrop-blur)) saturate(var(--glass-saturate));
  }

  @media (prefers-reduced-motion: no-preference) {
    .confirm[open] {
      animation: confirm-in var(--dur-base) var(--ease-spring);
    }

    .confirm[open]::backdrop {
      animation: confirm-backdrop-in var(--dur-base) var(--ease-standard);
    }
  }

  @keyframes confirm-in {
    from {
      opacity: 0;
      transform: translateY(var(--space-3)) scale(0.97);
    }
  }

  @keyframes confirm-backdrop-in {
    from {
      opacity: 0;
    }
  }

  /* The window never grows past the screen: the part that stands in it (the model list) shrinks
     and scrolls inside its own box, the question and the two buttons stay where they are. */
  .confirm {
    max-height: calc(100dvh - var(--space-8));
  }

  .confirm-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    max-height: calc(100dvh - var(--space-8));
    margin: 0;
    padding: var(--space-6);
  }

  .confirm-title {
    margin: 0;
    font-size: var(--text-lg);
    font-weight: 650;
    line-height: 1.3;
    overflow-wrap: anywhere;
  }

  .confirm-text {
    margin: 0;
    color: var(--color-text-muted);
    overflow-wrap: anywhere;
    text-wrap: pretty;
  }

  /* A part of the page that stands in the window (the model list of a Solve): the question and
     the choice are in the window, its own buttons are not (the window has them). */
  .confirm:has(.confirm-extra:not([hidden])) {
    width: min(34rem, calc(100% - var(--space-6)));
  }

  .confirm-extra .proposal-actions {
    display: none;
  }

  .confirm-extra {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .confirm-extra > * {
    margin: 0;
  }

  .confirm-extra .model-scroll {
    max-height: min(14rem, 30dvh);
  }

  .confirm-word {
    margin: 0;
  }

  .confirm-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: var(--space-2);
    margin-top: var(--space-2);
  }

  /* The notices: small glass at the bottom centre. The floating "+" of the board sits at the right
     edge and the notices never reach it on a desktop window (a test measures the gap at the three
     pilot sizes); on a narrow window they stand above it. */
  .toast-region {
    position: fixed;
    inset-block-end: var(--space-4);
    inset-inline: var(--space-4);
    z-index: var(--z-overlay);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    pointer-events: none;
  }

  @media (max-width: 40rem) {
    .toast-region {
      inset-block-end: calc(var(--space-6) + var(--fab-size) + var(--space-3));
    }
  }

  .toast {
    max-width: min(26rem, 100%);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3) var(--space-2) var(--space-4);
    color: var(--color-text);
    background:
      linear-gradient(165deg, var(--glass-confirm-sheen), transparent 55%), var(--glass-confirm-bg);
    -webkit-backdrop-filter: blur(var(--glass-confirm-blur)) saturate(var(--glass-saturate));
    backdrop-filter: blur(var(--glass-confirm-blur)) saturate(var(--glass-saturate));
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow-glass-confirm);
    pointer-events: auto;
  }

  @media (prefers-reduced-motion: no-preference) {
    .toast {
      animation: confirm-in var(--dur-base) var(--ease-spring);
    }
  }

  .toast-text {
    overflow-wrap: anywhere;
  }

  .toast-action {
    flex: none;
    padding: var(--space-1) var(--space-3);
    font: inherit;
    font-weight: 650;
    color: var(--color-link);
    background: transparent;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-pill);
    cursor: pointer;
  }

  .toast-action:hover {
    background: var(--color-hover);
  }

  /* The feedback form: in the window of the sidebar button and on the page /feedback. */
  .feedback-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    margin: 0;
  }

  .feedback-form textarea {
    width: 100%;
    min-height: 7rem;
    resize: vertical;
  }

  .feedback-page {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-height: 2.75rem;
    color: var(--color-text-muted);
  }

  .feedback-error {
    margin: 0;
    color: var(--status-failed);
    overflow-wrap: anywhere;
  }

  .feedback-page-form {
    max-width: 40rem;
  }

  .feedback-dialog .confirm-form {
    gap: var(--space-3);
  }
}
