/* Small, hand-written CSS overrides/additions that we want available on every page. */

/* Progressive enhancement: enable View Transition API for full navigations where supported. */
@view-transition {
  navigation: auto;
}

/* Ensure the flow tab indicator can animate (slide) without covering labels.
   We do this by putting the tabbar snapshot above the indicator snapshot. */
::view-transition-group(root) {
  z-index: 0;
}

::view-transition-group(flow-panel-tabbar) {
  z-index: 2;
}

::view-transition-old(flow-panel-tabbar),
::view-transition-new(flow-panel-tabbar) {
  animation: none;
  opacity: 1;
}

::view-transition-group(flow-panel-tab-indicator) {
  z-index: 1;
  animation-duration: 240ms;
  animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* For the tab indicator we want spatial movement, not cross-fade. */
::view-transition-old(flow-panel-tab-indicator),
::view-transition-new(flow-panel-tab-indicator) {
  opacity: 1;
}

/* Generic "loading" affordance for Datastar @post actions.
   Pattern: set `el.classList.add('is-loading')` before @post; clear on morph re-render. */
.ds-loading-indicator {
  display: none;
}

.ds-loading-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: opacity 120ms ease;
}

.is-loading {
  pointer-events: none;
  opacity: 0.65;
}

.is-loading .ds-loading-label {
  opacity: 0;
}

.is-loading .ds-loading-indicator {
  display: inline-flex;
}

/* Overlay-only loading for link navigation (keeps content visible, dims it). */
.is-loading-overlay {
  pointer-events: none;
}

.is-loading-overlay .step-loading-content {
  opacity: 0.65;
}

.is-loading-overlay .ds-loading-indicator {
  display: flex;
}

/* Artifact sidepeek fullscreen transition: smooth expansion in-place. */
#sidepeek-panel-container.sidepeek-panel-shell {
  transition-property: width, border-color;
  transition-duration: 240ms;
  transition-timing-function: cubic-bezier(0.32, 0.72, 0, 1);
}

#sidepeek-panel-container.sidepeek-panel-shell .sidepeek-panel-content {
  transition-property: opacity, transform;
  transition-duration: 240ms;
  transition-timing-function: cubic-bezier(0.32, 0.72, 0, 1);
}

#sidepeek-panel-container.sidepeek-panel-shell.sidepeek-artifact-fullscreen {
  width: calc(100dvw - 4rem) !important;
  max-width: calc(100dvw - 4rem);
  margin-left: 0 !important;
}

#sidepeek-panel-container.sidepeek-panel-shell.sidepeek-artifact-fullscreen .sidepeek-panel-content {
  width: 100%;
}

.artifact-panel-shell {
  transition-property: opacity, transform;
  transition-duration: 240ms;
  transition-timing-function: cubic-bezier(0.32, 0.72, 0, 1);
  opacity: 0.98;
  transform: translateX(0.125rem);
}

.artifact-panel-shell.artifact-panel-fullscreen {
  opacity: 1;
  transform: translateX(0);
}

@media (prefers-reduced-motion: reduce) {
  #sidepeek-panel-container.sidepeek-panel-shell,
  #sidepeek-panel-container.sidepeek-panel-shell .sidepeek-panel-content,
  .artifact-panel-shell {
    transition-duration: 0ms !important;
    animation-duration: 0ms !important;
  }
}

/* Dark mode: disabled dropdown items should read clearly as inactive. */
[data-theme="dark"] [data-dropdown-menu-item][aria-disabled="true"] {
  opacity: 0.3;
}
