/*
 * Circuit reconnection dialog (ADR-0006).
 *
 * Its own file rather than an addition to site.css, so the design layer - which
 * was reworked immediately before the Blazor migration - stays byte-for-byte
 * what it was. Nothing here styles anything outside #components-reconnect-modal.
 *
 * The class names are the framework's: blazor.web.js puts
 * components-reconnect-show / -retrying / -failed / -paused / -resume-failed on
 * the dialog, and circuit.js adds circuit-notice--rejected for the one state the
 * framework signals by event rather than by class. Renaming any of them silently
 * stops the dialog from ever appearing, which is why they are quoted here rather
 * than tidied.
 */

/* Every state's copy is hidden by default; a state class reveals its own. */
.components-reconnect-first-attempt-visible,
.components-reconnect-repeated-attempt-visible,
.components-reconnect-failed-visible,
.components-pause-visible,
.components-resume-failed-visible,
.circuit-notice__rejected-visible,
.components-rejoining-animation {
  display: none;
}

#components-reconnect-modal.components-reconnect-show p.components-reconnect-first-attempt-visible,
#components-reconnect-modal.components-reconnect-show .components-rejoining-animation,
#components-reconnect-modal.components-reconnect-retrying p.components-reconnect-repeated-attempt-visible,
#components-reconnect-modal.components-reconnect-retrying .components-rejoining-animation,
#components-reconnect-modal.components-reconnect-failed p.components-reconnect-failed-visible,
#components-reconnect-modal.components-reconnect-paused p.components-pause-visible,
#components-reconnect-modal.components-reconnect-resume-failed p.components-resume-failed-visible,
#components-reconnect-modal.circuit-notice--rejected p.circuit-notice__rejected-visible {
  display: block;
}

/* The same state classes sit on the buttons, which are inline-flex - block
   would stretch them across the dialog. */
#components-reconnect-modal.components-reconnect-failed button.components-reconnect-failed-visible,
#components-reconnect-modal.components-reconnect-paused button.components-pause-visible,
#components-reconnect-modal.components-reconnect-resume-failed button.components-resume-failed-visible,
#components-reconnect-modal.circuit-notice--rejected button.circuit-notice__rejected-visible {
  display: inline-flex;
}

/* ---------- the dialog itself ---------- */

.circuit-notice {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-block-start: 4px solid var(--accent-text);
  border-radius: var(--irc-radius);
  box-shadow: var(--irc-shadow-2);
  color: var(--fg);
  font-family: var(--irc-font-body);
  font-size: var(--irc-fs-300);
  line-height: var(--irc-lh-body);
  margin: 12vh auto;
  max-inline-size: min(28rem, calc(100vw - 2 * var(--irc-gutter)));
  padding: var(--irc-s6);
}

.circuit-notice::backdrop {
  /* Ink rather than plain black, so the overlay belongs to the palette. */
  background: rgba(23, 19, 20, 0.55);
}

.circuit-notice__title {
  font-size: var(--irc-fs-500);
  margin: 0 0 var(--irc-s3);
}

.circuit-notice p {
  margin: 0 0 var(--irc-s5);
}

.circuit-notice__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--irc-s3);
}

/* ---------- rejoining animation ---------- */

.components-rejoining-animation {
  block-size: 6px;
  border-radius: 3px;
  inline-size: 100%;
  margin-block-end: var(--irc-s4);
  overflow: hidden;
  position: relative;
}

.components-rejoining-animation div {
  animation: circuit-notice-sweep 1.4s var(--irc-ease) infinite;
  background: var(--accent);
  block-size: 100%;
  border-radius: 3px;
  inline-size: 40%;
  inset-block-start: 0;
  position: absolute;
}

.components-rejoining-animation div:nth-child(2) {
  animation-delay: -0.7s;
  opacity: 0.4;
}

@keyframes circuit-notice-sweep {
  from {
    inset-inline-start: -40%;
  }
  to {
    inset-inline-start: 100%;
  }
}

/*
 * A sweeping bar is decoration. Respecting the preference is not optional for a
 * dialog that can be on screen for a while (WCAG 2.3.3, and 2.2.2 for anything
 * that moves for more than five seconds).
 */
@media (prefers-reduced-motion: reduce) {
  .components-rejoining-animation div {
    animation: none;
    inline-size: 100%;
    inset-inline-start: 0;
  }

  .components-rejoining-animation div:nth-child(2) {
    display: none;
  }
}
