/* Shared with the attendance app. Short, interruptible motion without layout animation. */
:root {
  --surface-enter: 280ms;
  --surface-exit: 160ms;
  --surface-settle: cubic-bezier(.22, 1, .36, 1);
  --surface-spring: cubic-bezier(.22, 1.08, .36, 1);
}

/* Individual scale preserves transforms used by the floating search control. */
:is(button, [role="button"], summary, input[type="submit"], input[type="button"]) {
  -webkit-tap-highlight-color: transparent;
  transition: scale 200ms var(--surface-spring), transform 200ms var(--surface-settle),
    background-color 140ms ease, border-color 140ms ease, color 140ms ease, opacity 140ms ease;
}
:is(button, [role="button"], summary, input[type="submit"], input[type="button"]):not(:disabled):not([aria-disabled="true"]):active {
  scale: .975;
  transition-duration: 75ms;
}
:is(button, [role="button"], input[type="submit"], input[type="button"]):is(:disabled, [aria-disabled="true"]) {
  scale: 1;
}

/* Keyframe entry is the fallback on browsers without discrete display transitions. */
dialog[open] {
  animation: surface-enter var(--surface-enter) var(--surface-spring) both;
}
@keyframes surface-enter {
  from { opacity: 0; transform: translate3d(0, 10px, 0) scale(.98); }
  to { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
}

@supports (transition-behavior: allow-discrete) and (overlay: auto) {
  dialog {
    opacity: 0;
    transform: translate3d(0, 6px, 0) scale(.985);
    transition: opacity var(--surface-exit) ease-out,
      transform var(--surface-exit) var(--surface-settle),
      display var(--surface-exit) allow-discrete, overlay var(--surface-exit) allow-discrete;
  }
  dialog[open] {
    animation: none;
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
    transition: opacity 180ms ease-out, transform var(--surface-enter) var(--surface-spring),
      display var(--surface-enter) allow-discrete, overlay var(--surface-enter) allow-discrete;
  }
  dialog::backdrop {
    opacity: 0;
    transition: opacity var(--surface-exit) ease-out,
      display var(--surface-exit) allow-discrete, overlay var(--surface-exit) allow-discrete;
  }
  dialog[open]::backdrop { opacity: 1; }
  dialog:not([open]), dialog:not([open])::backdrop { pointer-events: none; }
  @starting-style {
    dialog[open] { opacity: 0; transform: translate3d(0, 10px, 0) scale(.98); }
    dialog[open]::backdrop { opacity: 0; }
  }
}

/* Native details keep keyboard/toggle semantics. Never animate height or every list row. */
@supports selector(details::details-content) and (transition-behavior: allow-discrete) {
  details::details-content {
    opacity: 0;
    transform: translate3d(0, -4px, 0);
    transition: opacity 160ms ease-out, transform 200ms var(--surface-settle),
      content-visibility 200ms allow-discrete;
  }
  details[open]::details-content { opacity: 1; transform: translate3d(0, 0, 0); }
}
@supports not selector(details::details-content) {
  details[open] > :not(summary) { animation: surface-disclosure 180ms var(--surface-settle); }
}
@keyframes surface-disclosure {
  from { opacity: 0; transform: translate3d(0, -4px, 0); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}
@media (prefers-reduced-motion: reduce) {
  :is(button, [role="button"], summary, input[type="submit"], input[type="button"]) {
    transition: background-color 100ms linear, color 100ms linear, opacity 100ms linear;
  }
  :is(button, [role="button"], summary, input[type="submit"], input[type="button"]):not(:disabled):not([aria-disabled="true"]):active { scale: 1; }
  dialog, dialog[open], details::details-content { transform: none !important; }
  dialog[open] { animation: surface-fade 100ms linear; }
  @keyframes surface-fade { from { opacity: 0; } to { opacity: 1; } }
  @starting-style { dialog[open] { transform: none; } }
}
