/* NodeBook — save bar, dialogs, toasts, boot and error screens. */

/* ---------- save bar ---------- */

.savebar {
  position: absolute;
  z-index: 800;
  left: 50%;
  bottom: var(--space-5);
  transform: translate(-50%, 140%);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-2) var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-2);
  max-width: calc(100% - 32px);
}

.savebar:not(.is-visible) {
  box-shadow: none;
}

.savebar.is-visible {
  transform: translate(-50%, 0);
}

.savebar-text {
  font-size: var(--text-sm);
  font-weight: 600;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.savebar-text .dot {
  background: var(--accent);
}

/* ---------- dialog ---------- */

/* Dialogs are glass (ra-glas over the page, ra-schaduw-glas); on glass the muted text and links
   take their glass shades. Fields, tables and the footer inside stay solid. */
.dialog {
  border: 1px solid var(--glass-line);
  border-radius: var(--radius-lg);
  background: var(--glass);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  color: var(--text);
  --text-2: var(--glass-mut);
  --text-3: var(--glass-mut);
  --link: var(--glass-link);
  padding: 0;
  width: min(560px, calc(100vw - 24px));
  max-height: min(86dvh, 820px);
  box-shadow: var(--shadow-glass);
  display: flex;
  flex-direction: column;
}

/* No backdrop-filter, or less transparency asked for: a solid panel. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .dialog {
    background: var(--surface);
  }
}

@media (prefers-reduced-transparency: reduce) {
  .dialog {
    background: var(--surface);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

.dialog:not([open]) {
  display: none;
}

.dialog--sm {
  width: min(440px, calc(100vw - 24px));
}

.dialog--lg {
  width: min(760px, calc(100vw - 24px));
}

.dialog--xl {
  width: min(980px, calc(100vw - 24px));
}

.dialog::backdrop {
  background: var(--scrim);
}

.dialog-head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-4) var(--space-3) var(--space-5);
}

.dialog-head h2 {
  flex: 1;
  font-size: var(--text-lg);
}

.dialog-body {
  padding: 0 var(--space-5) var(--space-5);
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.dialog-foot {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* A line under the footer buttons, e.g. why one of them is off. */
.dialog-foot:has(.dialog-hint) {
  flex-wrap: wrap;
}

.dialog-hint {
  flex-basis: 100%;
  order: 1;
  text-align: right;
  font-size: var(--text-xs);
  color: var(--text-2);
}

.dialog-hint[hidden] {
  display: none;
}

.prose p + p {
  margin-top: var(--space-2);
}

.prose * + h4 {
  margin-top: var(--space-4);
}

.choice-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.choice {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}

@media (hover: hover) {
  .choice:hover {
    background: var(--accent-soft);
    border-color: var(--accent);
  }

  .choice--danger:hover {
    background: var(--danger-soft);
    border-color: var(--danger);
  }
}

.choice span {
  font-size: var(--text-sm);
  color: var(--text-2);
}

.choice--icon {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: var(--space-3);
}

.choice--icon > .icon {
  grid-row: 1 / span 2;
  align-self: center;
  color: var(--text-2);
}

.choice--danger strong {
  color: var(--danger);
}

.choice--primary {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.choice--primary > .icon {
  color: var(--text);
}

.choice-heading {
  margin: var(--space-2) 0 0;
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-3);
}

.change-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.change {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 2px var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  font-size: var(--text-sm);
}

.change-kind {
  grid-row: span 2;
  align-self: start;
}

.change-detail {
  color: var(--text-2);
  font-size: var(--text-xs);
  overflow-wrap: anywhere;
}

.change-lines {
  grid-column: 2;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-1);
}

.change-fields {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: var(--text-2);
  font-size: var(--text-xs);
  overflow-wrap: anywhere;
}

.change-fields[hidden] {
  display: none;
}

.change-more {
  padding: 0;
  border: 0;
  background: none;
  color: var(--link);
  font: inherit;
  font-size: var(--text-xs);
  cursor: pointer;
  text-decoration: underline;
}

/* A segmented switch as on the #BEmesh tools: one framed row; the pressed choice pale gold with a
   gold rim, in bold (never colour alone). */
.segmented {
  display: inline-flex;
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  gap: 2px;
}

.segmented button {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  padding: 4px var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}

.segmented button[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text);
  font-weight: 700;
}

@media (hover: hover) {
  .segmented button:hover:not([aria-pressed="true"]) {
    background: var(--accent-soft);
  }
}

.field > .segmented {
  align-self: flex-start;
}

/* ---------- toasts ---------- */

.toasts {
  position: fixed;
  z-index: 2000;
  top: var(--space-4);
  right: var(--space-4);
  bottom: auto;
  left: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
  max-width: min(420px, calc(100vw - 32px));
}

/* In the top layer (popover) the browser's popover box would centre it and draw a frame;
   the corner comes from .toasts, its top from the bars above it (overlay.js). */
.toasts[popover] {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  overflow: visible;
  color: inherit;
}

.toast {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  padding: var(--space-3) var(--space-2) var(--space-3) var(--space-4);
  pointer-events: auto;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-2);
  font-size: var(--text-sm);
  opacity: 0;
  transition: opacity var(--dur-med) var(--ease);
}

.toast-text {
  flex: 1;
  align-self: center;
}

.toast .toast-close {
  width: 28px;
  height: 28px;
  margin: -4px 0;
}

.toast.is-in {
  opacity: 1;
}

.toast--success > .icon {
  color: var(--ok);
}

.toast--error > .icon {
  color: var(--danger);
}

.toast--info > .icon {
  color: var(--info);
}

/* ---------- boot / errors ---------- */

.boot {
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  color: var(--text-2);
  padding: var(--space-8);
  text-align: center;
}

.spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
