/* Shared motion: screens, catalog lists, status tabs, compact popovers. */

/* CoverImages: soft iOS-like reveal instead of a hard pop-in. */
img.rm-cover-fade {
  opacity: 0;
  transition: opacity var(--motion-screen) var(--motion-ease-out);
}
img.rm-cover-fade.rm-cover-ready {
  opacity: 1;
}

@keyframes route-enter {
  from { opacity: 0.85; }
  to { opacity: 1; }
}

@keyframes ui-popup-enter {
  from { opacity: 0; }
  to { opacity: 1; }
}

html.route-dissolve-pending .screen-view.is-active {
  opacity: 0;
}

html.search-overlay.route-dissolve-pending .screen-view.is-active:not(#search-view) {
  opacity: 1;
}

.screen-view.is-route-enter {
  animation: route-enter var(--motion-screen) var(--motion-ease-out) both;
  will-change: opacity;
}

/* Catalog controls keep their position while the results change. */
@keyframes catalog-results-enter {
  from { opacity: 0.85; }
  to { opacity: 1; }
}
:is(#library-view, #authors-view, #series-view, #collections-view)
  :is(
    .books-grid,
    .books-empty,
    .authors-grid,
    .authors-empty,
    .ser-results,
    .ser-empty,
    .col-results,
    .col-empty
  ).is-catalog-fade,
#collections-results.is-catalog-fade {
  animation: catalog-results-enter var(--motion-tab) var(--motion-ease-out);
}

:is(#library-view, #authors-view, #series-view, #collections-view)
  :is(.books-statuses, .authors-statuses, .series-statuses, .collections-statuses)
  :is(.books-chip, .authors-chip, .series-status-tab, .ds-segment-bar-item),
:is(#library-view, #authors-view, #series-view, #collections-view)
  :is(.books-statuses, .authors-statuses, .series-statuses, .collections-statuses)
  :is(.books-chip, .authors-chip, .series-status-tab, .ds-segment-bar-item)
  :is(.books-badge, .authors-badge, .ds-segment-bar-badge) {
  transition:
    color var(--motion-tab) var(--motion-ease-out),
    background-color var(--motion-tab) var(--motion-ease-out),
    opacity var(--motion-tab) var(--motion-ease-out);
}

:is(#library-view, #authors-view, #collections-view)
  :is(.books-statuses, .authors-statuses, .collections-statuses)
  :is(.books-chip, .authors-chip)
  > span:first-child::after {
  transition:
    opacity var(--motion-tab) var(--motion-ease-dissolve),
    transform var(--motion-tab) var(--motion-ease-dissolve);
}

@media (max-width: 1199px) {
  :is(
    .books-popover,
    .authors-popover,
    .series-popover,
    .q-suggestions,
    .author-profile-menu-list,
    .capture-menu-list,
    .bd-menu-list,
    .ser-detail-menu-list,
    .profile-menu,
    .ds-popup,
    .is-ui-popup-replay
  ):not([hidden]),
  .is-ui-popup-replay {
    animation: ui-popup-enter var(--motion-screen) var(--motion-ease-dissolve) both;
  }

  details.books-advanced-dropdown[open] > .books-advanced-dropdown-panel {
    animation: ui-popup-enter var(--motion-screen) var(--motion-ease-dissolve) both;
  }
}

@media (prefers-reduced-motion: reduce) {
  .screen-view.is-route-enter,
  :is(#library-view, #authors-view, #series-view, #collections-view) .is-catalog-fade,
  #collections-results.is-catalog-fade,
  :is(
    .books-popover,
    .authors-popover,
    .series-popover,
    .q-suggestions,
    .author-profile-menu-list,
    .capture-menu-list,
    .bd-menu-list,
    .ser-detail-menu-list,
    .profile-menu,
    .ds-popup
  ):not([hidden]),
  details.books-advanced-dropdown[open] > .books-advanced-dropdown-panel {
    animation: none;
  }

  img.rm-cover-fade,
  img.rm-cover-fade.rm-cover-ready {
    opacity: 1;
    transition: none;
  }

  html.route-dissolve-pending .screen-view.is-active {
    opacity: 1;
  }

  :is(#library-view, #authors-view, #series-view, #collections-view)
    :is(.books-statuses, .authors-statuses, .series-statuses, .collections-statuses)
    :is(.books-chip, .authors-chip, .series-status-tab, .ds-segment-bar-item),
  :is(#library-view, #authors-view, #series-view, #collections-view)
    :is(.books-statuses, .authors-statuses, .series-statuses, .collections-statuses)
    :is(.books-chip, .authors-chip, .series-status-tab, .ds-segment-bar-item)
    :is(.books-badge, .authors-badge, .ds-segment-bar-badge) {
    transition: none;
  }
}
