/* loading_shimmer: a region's placeholder while its content loads for the
   first time. It is the region's own background with a soft band sweeping
   down it. It lies over the region until the content is ready, then fades
   out. The design tool's inspector column uses it (website_design/interface/preview/
   overlays.js installPanelsShimmer); its class name is the one that script
   writes. Reduced motion keeps the placeholder and stops the sweep. */
.panels-shimmer {
  /* The placeholder's ground and the band that sweeps over it. */
  --block-loading-shimmer-ground: var(--color-toolbar);
  --block-loading-shimmer-band: var(--color-toolbar-hover);

  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  background: var(--block-loading-shimmer-ground);
  transition: opacity var(--ui-duration-dismiss) var(--ui-ease-dismiss);
}

/* The region it covers is its positioning context (#panels already is). */
:has(> .panels-shimmer) {
  position: relative;
}

.panels-shimmer.is-leaving {
  opacity: 0;
}

.panels-shimmer::after {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    transparent 30%,
    var(--block-loading-shimmer-band) 46%,
    var(--block-loading-shimmer-band) 54%,
    transparent 70%
  );
  background-size: 100% 300%;
  animation: panels-shimmer-sweep var(--ui-duration-shimmer) var(--ui-ease-pulse) infinite;
  content: '';
}

@keyframes panels-shimmer-sweep {
  0% { background-position: 0 200%; }
  100% { background-position: 0 -100%; }
}

/* Continuous decoration stops completely. */
@media (prefers-reduced-motion: reduce) {
  .panels-shimmer::after {
    animation: none;
  }
}

/* The loading line: the fragment owner's status while a region's content
   loads (libraries/http/fragment, and the line a lazy tab's panel draws).
   A small turning ring before quiet secondary text. It keeps its place but
   stays hidden for --ui-delay-loading, so a fast load never flashes it.
   With reduced motion the ring is a still clock. */
.fragment_status {
  --block-loading-line-spinner: calc(var(--ui-icon-size) * 0.875);

  display: flex;
  align-items: center;
  gap: var(--ui-space-2);
  margin: 0;
  color: var(--color-text-secondary);
  font-size: var(--ui-font-size-label);
  line-height: var(--ui-line-height-body);
  animation: loading-line-reveal 0s linear var(--ui-delay-loading) backwards;
}

.fragment_status::before {
  flex: none;
  box-sizing: border-box;
  width: var(--block-loading-line-spinner);
  height: var(--block-loading-line-spinner);
  border: 2px solid var(--color-border-subtle);
  border-block-start-color: var(--color-text-secondary);
  border-radius: 50%;
  animation: dpg-spin var(--ui-duration-busy) linear infinite;
  content: '';
}

@keyframes loading-line-reveal {
  from { visibility: hidden; }
}

/* A floating line, over the workspace's lower corner, for a load that adds
   to what is shown (the filmstrip's next images): the toast's colours. */
.fragment_status[data-floating] {
  position: fixed;
  inset-block-end: var(--ui-space-3);
  inset-inline-start: var(--ui-space-4);
  z-index: var(--ui-layer-toast);
  padding: var(--ui-space-1) var(--ui-space-2);
  color: var(--color-toast-text);
  background-color: var(--color-toast-background);
}

.fragment_status[data-floating]::before {
  border-color: var(--color-toast-text);
  border-block-start-color: transparent;
}

/* A region that fills an inspector panel shows the line as the panel's
   placeholder (a lazy panel, or a panel that loads its content again). The
   line sits inside the panel's padding. Under it is a panel section's shape
   in the guide's tint: a guide, a label and field, and the footer action at
   the trailing edge. The shape keeps the panel at a section's height while
   it loads. The tint breathes slowly; reduced motion holds it still. */
.panel_content > [aria-busy='true'] > .fragment_status:only-child {
  --block-loading-placeholder-tint: var(--color-panels-guide-background);
  --block-loading-placeholder-control: var(--ui-control-height);
  --block-loading-placeholder-guide: calc(var(--ui-space-unit) * 13);

  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--ui-space-4) var(--ui-space-2);
  padding: var(--ui-panel-padding);
}

.panel_content > [aria-busy='true'] > .fragment_status:only-child::after {
  --block-loading-placeholder-label: calc(var(--block-loading-placeholder-guide) + var(--ui-space-4));
  --block-loading-placeholder-field: calc(var(--block-loading-placeholder-label) + var(--ui-space-3) + var(--ui-space-2));
  --block-loading-placeholder-action: calc(var(--block-loading-placeholder-field) + var(--block-loading-placeholder-control) + var(--ui-space-6));

  grid-column: 1 / -1;
  height: calc(var(--block-loading-placeholder-action) + var(--block-loading-placeholder-control));
  background:
    linear-gradient(var(--block-loading-placeholder-tint), var(--block-loading-placeholder-tint)) 0 0 / 100% var(--block-loading-placeholder-guide) no-repeat,
    linear-gradient(var(--block-loading-placeholder-tint), var(--block-loading-placeholder-tint)) 0 var(--block-loading-placeholder-label) / 35% var(--ui-space-3) no-repeat,
    linear-gradient(var(--block-loading-placeholder-tint), var(--block-loading-placeholder-tint)) 0 var(--block-loading-placeholder-field) / 100% var(--block-loading-placeholder-control) no-repeat,
    linear-gradient(var(--block-loading-placeholder-tint), var(--block-loading-placeholder-tint)) 100% var(--block-loading-placeholder-action) / min(var(--ui-panel-action-min-width), 100%) var(--block-loading-placeholder-control) no-repeat;
  animation: loading-placeholder-breathe var(--ui-duration-pulse) var(--ui-ease-pulse) infinite alternate;
  content: '';
}

@keyframes loading-placeholder-breathe {
  to { opacity: 0.6; }
}

@media (prefers-reduced-motion: reduce) {
  .fragment_status::before {
    width: var(--ui-icon-size);
    height: auto;
    color: var(--color-text-secondary);
    font-family: var(--ui-icon-font-family);
    font-size: var(--ui-icon-size);
    font-weight: var(--ui-icon-weight);
    line-height: 1;
    border: 0;
    border-radius: 0;
    animation: none;
    content: var(--ui-icon-clock) var(--ui-icon-alt,);
  }

  .panel_content > [aria-busy='true'] > .fragment_status:only-child::after {
    animation: none;
  }
}
