/* One native modal, bounded by the visible workspace and shared spacing. */
dialog.processing {
  position: fixed;
  inset: auto;
  inset-block-start: var(--processing-center-y);
  inset-inline-start: var(--processing-center-x);
  box-sizing: border-box;
  width: min(24rem, calc(var(--processing-viewport-width) - 2 * var(--ui-space-4)));
  max-height: calc(var(--processing-viewport-height) - 2 * var(--ui-space-4));
  margin: 0;
  padding: var(--ui-surface-padding);
  overflow: auto;
  color: var(--color-text);
  font-family: var(--ui-font-family);
  background: var(--color-input-background);
  border: 1px solid var(--color-border-faint);
  border-radius: var(--ui-radius-surface);
  transform: translate(-50%, -50%);
  overscroll-behavior: contain;
}

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

.processing_box {
  display: grid;
  gap: var(--ui-space-3);
  min-width: 0;
}

.processing_box :is(h2, p) {
  margin: 0;
  overflow-wrap: anywhere;
}

.processing_box .process_task {
  font-size: var(--ui-font-size-control);
  font-weight: var(--ui-weight-strong);
  line-height: var(--ui-line-height-control);
}

.processing_box :is(.process_step, .process_feedback) {
  font-size: var(--ui-font-size-body);
  line-height: var(--ui-line-height-body);
}

.processing .spinner_container {
  display: grid;
  place-items: start;
}

.processing_box .process_progress {
  box-sizing: border-box;
  width: 100%;
  height: var(--ui-space-2);
  overflow: hidden;
  background: var(--color-processing-progress-track);
  border: 0;
  border-radius: var(--ui-radius-control);
  appearance: none;
}

.process_progress::-webkit-progress-bar {
  background: var(--color-processing-progress-track);
}

.process_progress::-webkit-progress-value {
  background: var(--color-neutral);
  transition: width var(--ui-duration-feedback) var(--ui-ease-feedback);
}

.process_progress::-moz-progress-bar {
  background: var(--color-neutral);
}

.process_actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--ui-space-2);
}

.process_actions .button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: var(--ui-touch-target);
  margin: 0;
  text-decoration: none;
}

.processing [hidden],
.process_feedback:empty,
.process_actions:not(:has(:not([hidden]))),
.processing:is([data-state='unconfirmed'], [data-state='failed'], [data-state='complete']) :is(.spinner_container, .process_progress) {
  display: none;
}

.processing_box .process_step {
  white-space: pre-line;
}

/* The task heading takes focus when the box opens, so assistive technology
   reads it. It is a heading, not a control, so it shows no focus ring. */
.processing_box .process_task:focus {
  outline: none;
}

/* Short modal tasks keep their indicator beside the two-line status. */
.processing:not([data-stage])[data-state='working'] .processing_box {
  grid-template-columns: var(--ui-space-6) minmax(0, 1fr);
  gap: var(--ui-space-1) var(--ui-space-3);
}

.processing:not([data-stage])[data-state='working'] .spinner_container {
  align-self: center;
  grid-column: 1;
  grid-row: 1 / 3;
}

.processing:not([data-stage])[data-state='working'] .dpg-spinner {
  width: var(--ui-space-6);
  height: var(--ui-space-6);
}

.processing:not([data-stage])[data-state='working'] :is(.process_task, .process_step) {
  grid-column: 2;
}

.processing:not([data-stage])[data-state='working'] :is(.process_progress, .process_feedback, .process_actions) {
  grid-column: 1 / -1;
  margin-block-start: var(--ui-space-2);
}

/* A processing box shown over one region instead of in the modal (the design
   tool's preview while a page loads). It is a floating panel of its own,
   centred by the loading overlay it sits in. The knobs bound its width. */
.processing_panel {
  --processing-panel-max-width: 360px;
  align-items: center;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--ui-space-1) var(--ui-space-4);

  box-sizing: border-box;
  width: min(var(--processing-panel-max-width), calc(100% - 2 * var(--ui-space-4)));
  min-width: 0;
  padding: var(--ui-space-6);
  color: var(--color-text);
  background: var(--color-canvas);
  border: 1px solid var(--color-border-faint);
  border-radius: var(--ui-radius-surface);
  box-shadow: var(--shadow-menu);
}

.processing_panel .spinner_container {
  display: grid;
  grid-column: 1;
  grid-row: 1 / 3;
  place-items: center;
  margin: 0;
}

.processing_panel .process_task {
  grid-column: 2;
  margin: 0;
  font-size: var(--ui-font-size-control);
  text-align: start;
}

.processing_panel .process_step {
  grid-column: 2;
  min-height: calc(2 * var(--ui-font-size-small) * var(--ui-line-height-body));
  margin: 0;
  color: var(--color-text-secondary);
  font-size: var(--ui-font-size-small);
  text-align: start;
}

.processing_panel .process_progress {
  display: block;
  grid-column: 1 / -1;
  width: 100%;
  height: var(--ui-space-1);
  margin-block-start: var(--ui-space-4);
}

.processing_panel .process_progress::-webkit-progress-value {
  background: var(--color-processing-progress-value);
}

.processing_panel .process_progress::-moz-progress-bar {
  background: var(--color-processing-progress-value);
}

/* Full-window website build stage, enabled by website_wizard.markWebsiteBuildStage. */
dialog.processing[data-stage] {
  inset: 0;
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  padding: var(--ui-space-12) var(--ui-space-6);
  color: var(--color-processing-screen-text);
  background: var(--color-canvas);
  border: 0;
  border-radius: 0;
  transform: none;
}

dialog.processing[data-stage]::backdrop {
  background: var(--color-canvas);
}

[data-stage] .processing_box {
  align-content: center;
  justify-items: center;
  gap: var(--ui-space-4);
  box-sizing: border-box;
  max-width: calc(var(--ui-space-12) * 24);
  min-height: 100%;
  margin-inline: auto;
  text-align: center;
}

[data-stage] .spinner_container {
  display: none;
}

[data-stage] :is(.process_task, .process_feedback) {
  color: var(--color-text-secondary);
  font-size: var(--ui-font-size-lead);
  font-weight: var(--ui-weight-medium);
}

[data-stage] .process_stage_title {
  max-width: 100%;
  margin: 0;
  color: var(--color-processing-screen-text);
  font-family: var(--ui-font-family-display);
  /* As big as the window lets a word be (a phone's is about a sixth of its
     width). A name then never breaks inside a word. */
  font-size: min(calc(var(--ui-font-size-display) * 2.5), 15vw);
  font-weight: var(--ui-weight-heavy);
  line-height: 1;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

[data-stage] .process_step {
  color: var(--color-processing-screen-text);
  font-family: var(--ui-font-family-display);
  font-size: min(calc(var(--ui-font-size-display) * 0.75), 8vw);
  font-weight: var(--ui-weight-thin);
  line-height: 1.2;
}

[data-stage] .process_progress {
  width: min(calc(var(--ui-space-12) * 10), 100%);
  height: 2px;
  border-radius: 0;
}

[data-stage] .process_progress::-webkit-progress-value {
  background: var(--color-processing-progress-value);
}

[data-stage] .process_progress::-moz-progress-bar {
  background: var(--color-processing-progress-value);
}

/* Where the stage says what happened (a failure, a check), the box's feedback
   and actions sit under it, centred. */
[data-stage] .process_actions {
  justify-content: center;
}

/* The step's picture, over the words, the frame the scene fits (640 by 320,
   and smaller on a short or narrow window). Once the work stops (a failure,
   a check) it goes, and the card holds its message and actions alone. */
.process_stage_scene {
  width: min(calc(var(--ui-space-12) * 14), 100%);
  height: min(calc(var(--ui-space-12) * 7), 34dvh);
  pointer-events: none;
}

.process_stage_scene > canvas {
  display: block;
  width: 100%;
  height: 100%;
}

[data-scene]:not([data-state='working'], [data-state='waiting'], [data-state='complete']) .process_stage_scene {
  display: none;
}

[data-media] .process_stage_scene {
  display: none;
}

.process_media {
  width: min(48rem, 100%);
}

.process_media_pictures {
  display: grid;
  align-items: center;
  grid-template-columns: 1fr 1fr 2.5fr 1fr 1fr;
  gap: var(--ui-space-3);
  min-height: min(18rem, 32dvh);
}

.process_media_frame {
  display: grid;
  grid-column: var(--media-column);
  grid-row: 1;
  min-width: 0;
  overflow: hidden;
  background: var(--color-processing-progress-track);
  border-radius: var(--ui-radius-surface);
  aspect-ratio: 1;
  place-items: center;
}

.process_media_frame[data-current='true'] {
  aspect-ratio: 4 / 3;
}

.process_media_frame :is(img, canvas) {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.process_media_placeholder {
  color: var(--color-text-secondary);
  font-size: var(--ui-font-size-heading);
}

[data-mode='batch'] .process_media_pictures {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  max-width: 32rem;
  margin-inline: auto;
}

[data-mode='batch'] .process_media_frame {
  grid-row: auto;
  max-height: 16dvh;
  aspect-ratio: 4 / 3;
}

.processing_box .process_media_caption {
  margin-block: var(--ui-space-3) 0;
  color: var(--color-text-secondary);
  font-size: var(--ui-font-size-body);
  overflow-wrap: anywhere;
}

[data-media] .process_stage_title {
  font-size: min(var(--ui-font-size-display), 10vw);
}

@media (width <= 600px) {
  .process_media_pictures {
    grid-template-columns: 0 1fr 3fr 1fr 0;
    gap: var(--ui-space-1);
  }
}
