/* Chrome for the <smart-dialog> custom element (shared-ui/src/smart_dialog.rs). Selectors
   are scoped under the smart-dialog tag so they don't collide with the older, unrelated
   .dialog-title/.dialog-close-button/dialog rules already in main.css/reset.css. */
smart-dialog dialog {
  min-width: min(95vw, 40rem);
  max-height: min(88vh, 100%);
  border: 1px solid var(--box-border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-4);
  padding: 0;
  opacity: 0;
  transform: scale(0.96) translateY(0.5rem);
  /* overlay and display are discrete properties, so they need allow-discrete to keep the
     dialog in the top layer for the duration of the exit transition. */
  transition:
    opacity 0.2s var(--ease-2),
    transform 0.2s var(--ease-2),
    overlay 0.2s allow-discrete,
    display 0.2s allow-discrete;
}

smart-dialog[data-wide] dialog {
  min-width: min(92vw, 80rem);
}

smart-dialog dialog[open] {
  opacity: 1;
  transform: scale(1) translateY(0);
}

@starting-style {
  smart-dialog dialog[open] {
    opacity: 0;
    transform: scale(0.96) translateY(0.5rem);
  }
}

smart-dialog dialog::backdrop {
  background-color: rgba(11, 17, 16, 0.55);
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 0.2s var(--ease-2);
}

smart-dialog dialog[open]::backdrop {
  opacity: 1;
}

@starting-style {
  smart-dialog dialog[open]::backdrop {
    opacity: 0;
  }
}

smart-dialog .dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-shrink: 0;
  padding: var(--space-4) var(--space-2) var(--space-4) var(--space-4);
  border-bottom: 1px solid var(--fieldset-border-color);
}

smart-dialog .dialog-title {
  margin: 0;
  font-size: var(--font-size-md);
  font-weight: bold;
  font-family: var(--ff-heading);
  color: var(--h-color);
}

smart-dialog .dialog-close-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 50%;
  background-color: transparent;
  color: var(--color-base-foreground);
  cursor: pointer;
  font-size: var(--font-size-md);
  line-height: 1;
  transition:
    background-color 0.15s var(--ease-2),
    color 0.15s var(--ease-2);
}

smart-dialog .dialog-close-button:hover {
  background-color: var(--red-1);
  color: var(--red-8);
}

smart-dialog .dialog-body {
  overflow: auto;
  padding: var(--space-4);
}

smart-dialog turbo-frame {
  display: block;
  width: 100%;
  border: none;
}

/* The dialog's answer to .page-menu. The offset is 0 because .dialog-body is the
   scrollport and nothing sits above it — .page-menu's top: var(--app-header-height)
   pushed the bar down over the first rows of content, which read as an empty dialog.
   Scoped under smart-dialog on purpose: used outside one the rule cannot match, so the
   class degrades to a plain button row instead of sticking to an offset that isn't there. */
smart-dialog .dialog-menu {
  display: flex;
  gap: var(--space-2);
  background-color: var(--surface-card);
  position: sticky;
  top: 0;
  z-index: 2;
}

smart-dialog .dialog-menu:has(.button) {
  padding: var(--space-2);
  border: 1px solid var(--box-border-color);
}

smart-dialog iframe {
  display: block;
  width: min(90vw, 60rem);
  height: min(75vh, calc(75vh - 8rem));
  min-height: 10rem;
}

smart-dialog .loading-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  padding: var(--space-7) var(--space-4);
  color: var(--color-base-foreground-muted, var(--color-base-foreground));
}

smart-dialog .loading-spinner {
  width: 2rem;
  height: 2rem;
  border: 3px solid var(--fieldset-border-color);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: smart-dialog-loading-spin 0.7s linear infinite;
}

smart-dialog .loading-text {
  font-size: var(--font-size-base);
}

@keyframes smart-dialog-loading-spin {
  to {
    transform: rotate(360deg);
  }
}
