/* Shared motion follows the login sheet without changing page geometry. */
.user-body {
  --ui-ease: cubic-bezier(.22, 1, .36, 1);
  --ui-control-duration: 160ms;
  --ui-panel-duration: 240ms;
}

/* Keep disclosure contents visible until the closing height transition ends. */
.user-body #site-drawer {
  transition: transform 320ms var(--ui-ease);
}

.user-body .drawer-shade {
  transition: opacity 220ms ease, visibility 220ms ease;
}

.user-body #site-drawer .nav-group-items {
  transition-property: grid-template-rows, opacity, visibility;
  transition-duration: 260ms, 180ms, 0s;
  transition-timing-function: var(--ui-ease), ease, linear;
  transition-delay: 0s, 0s, 0s;
}

.user-body #site-drawer .nav-group.is-closed .nav-group-items {
  transition-delay: 0s, 0s, 260ms;
}

.user-body #site-drawer .nav-group-title > .icon {
  transition: transform 260ms var(--ui-ease);
}

/* These elements are short-lived local surfaces, never page/fixed-bar parents. */
.user-body #modal-root > .modal-shade {
  animation: ui-shade-enter 180ms ease;
}

.user-body #modal-root > .modal-shade > .modal {
  animation: ui-modal-enter 300ms var(--ui-ease);
}

.user-body .birth-wizard .birth-step-panel:not([hidden]),
.user-body .sp-detail .sp-situation-panel:not([hidden]),
.user-body .re-page .re-situation-panel:not([hidden]),
.user-body .dr-page .dr-question-panel:not([hidden]) {
  animation: ui-panel-enter var(--ui-panel-duration) var(--ui-ease);
}

.user-body :is(
  .primary-button,
  .secondary-button,
  .text-button,
  .icon-button,
  .filter-tab,
  .sd-filter-chip,
  .sp-button,
  .re-button,
  .dr-button,
  .sp-situation-tabs button,
  .re-situation-tabs button,
  .dr-topic-button,
  .notes-categories button,
  .mypage-tabs button,
  .mypage-mode-tabs button,
  .mypage-activity-tabs button,
  .birth-choice > span
) {
  transition:
    color var(--ui-control-duration) ease,
    background-color var(--ui-control-duration) ease,
    border-color var(--ui-control-duration) ease,
    box-shadow var(--ui-control-duration) ease,
    transform var(--ui-control-duration) var(--ui-ease);
}

@keyframes ui-shade-enter {
  from { opacity: .65; }
  to { opacity: 1; }
}

@keyframes ui-modal-enter {
  from { opacity: .75; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes ui-panel-enter {
  from { opacity: .72; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .user-body #site-drawer,
  .user-body .drawer-shade,
  .user-body #site-drawer .nav-group-items,
  .user-body #site-drawer .nav-group-title > .icon,
  .user-body :is(.primary-button, .secondary-button, .text-button, .icon-button,
    .filter-tab, .sd-filter-chip, .sp-button, .re-button, .dr-button,
    .sp-situation-tabs button, .re-situation-tabs button, .dr-topic-button,
    .notes-categories button, .mypage-tabs button, .mypage-mode-tabs button,
    .mypage-activity-tabs button, .birth-choice > span) {
    transition: none;
  }

  .user-body #modal-root > .modal-shade,
  .user-body #modal-root > .modal-shade > .modal,
  .user-body .birth-wizard .birth-step-panel:not([hidden]),
  .user-body .sp-detail .sp-situation-panel:not([hidden]),
  .user-body .re-page .re-situation-panel:not([hidden]),
  .user-body .dr-page .dr-question-panel:not([hidden]) {
    animation: none;
  }
}

/* The toast lifecycle is handled by the shared motion helper. */
.user-body .toast {
  animation: none;
}

/* Local surfaces do not move the page or its fixed purchase bar. */
.user-body .personal-dropdown:not([hidden]) {
  animation: ui-menu-enter 180ms var(--ui-ease);
}

.user-body .rp-pane.is-active,
.user-body .inline-review-form:not([hidden]),
.user-body [data-hm-card-group]:not([hidden]) {
  animation: ui-fade-enter 180ms ease;
}

.user-body :is(.notes-pagination button, [data-hm-tab], [data-hm-quick-topic], [data-fp-topic]) {
  transition:
    color 160ms ease,
    background-color 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

/* Standalone login has its own body and keeps the existing sheet motion. */
.login-column,
.policy-shade {
  --ui-ease: cubic-bezier(.22, 1, .36, 1);
}

.policy-shade:not([hidden]) {
  animation: ui-shade-enter 180ms ease;
}

.policy-shade:not([hidden]) .policy-dialog {
  animation: ui-menu-enter 220ms var(--ui-ease);
}

.login-column :is(#name-row, #code-row):not([hidden]) {
  animation: ui-fade-enter 180ms ease;
}

@keyframes ui-menu-enter {
  from { opacity: .75; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes ui-fade-enter {
  from { opacity: .78; }
  to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .user-body .personal-dropdown:not([hidden]),
  .user-body .rp-pane.is-active,
  .user-body .inline-review-form:not([hidden]),
  .user-body [data-hm-card-group]:not([hidden]),
  .policy-shade:not([hidden]),
  .policy-shade:not([hidden]) .policy-dialog,
  .login-column :is(#name-row, #code-row):not([hidden]) {
    animation: none;
  }

  .user-body :is(.notes-pagination button, [data-hm-tab], [data-hm-quick-topic], [data-fp-topic]) {
    transition: none;
  }
}
