/* CoyLin motion: press feedback on every tappable surface and page-to-page transitions.
   Principles (Apple HIG, "Designing Fluid Interfaces"): feedback lands on pointer-down and is
   quick (60 ms in), release eases back (160 ms); nothing blocks input; reduced motion keeps the
   colour change and drops movement. */

/* ---------- Press feedback ---------- */
:is(.cy-topnav a, .cy-pills a, .cy-tabs a, .cy-subnav a, .cy-filetoc a, .cy-hint a, .cy-mobile-nav a,
  .cy-icon-btn, .cy-account, .cy-logo, .cy-tag, .cy-palette-list [role="option"],
  html.coylin .dropdown-menu [data-popover] [role="menuitem"]) {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background-color var(--cy-fast), color var(--cy-fast), transform 160ms var(--cy-ease);
}
:is(.cy-topnav a, .cy-pills a, .cy-tabs a, .cy-subnav a, .cy-filetoc a, .cy-hint a, .cy-mobile-nav a,
  .cy-icon-btn, .cy-account, .cy-logo, .cy-tag):active {
  transform: scale(0.96);
  transition-duration: 60ms;
}
:is(.cy-topnav a, .cy-pills a, .cy-subnav a, .cy-filetoc a, .cy-mobile-nav a, .cy-icon-btn):active {
  background: var(--cy-fill-2);
  color: var(--cy-fg);
}
html.coylin .dropdown-menu [data-popover] [role="menuitem"]:active {
  background: var(--cy-fill-2);
}
/* Cards press in as one object (the title link's overlay makes the whole card the target). */
.cy-card:active {
  transform: scale(0.985);
  box-shadow: var(--cy-shadow-soft);
  transition-duration: 60ms;
}
/* While a boosted navigation is in flight, the thing that was clicked says so. */
a.htmx-request {
  cursor: progress;
}
/* A submitted form cannot be sent twice while its request is in flight, and says it is working. */
form.htmx-request :is(button[type="submit"], input[type="submit"]) {
  opacity: 0.66;
  pointer-events: none;
  cursor: progress;
}
.cy-card:has(a.htmx-request) {
  opacity: 0.72;
  transition: opacity 120ms;
}

/* ---------- Page transitions (htmx boosted swaps use the View Transitions API) ---------- */
.cy-header {
  view-transition-name: cy-header;
}
::view-transition-old(cy-header),
::view-transition-new(cy-header) {
  animation: none;
}
::view-transition-old(root) {
  animation: cy-page-out 90ms cubic-bezier(0.4, 0, 1, 1) both;
}
::view-transition-new(root) {
  animation: cy-page-in 200ms var(--cy-ease) both;
}
@keyframes cy-page-out {
  to { opacity: 0; }
}
@keyframes cy-page-in {
  from { opacity: 0; transform: translateY(6px); }
}
/* Browsers without View Transitions: fade the new content in after the swap. */
.cy-main.cy-enter {
  animation: cy-page-in 200ms var(--cy-ease) backwards; /* no lingering transform: toasts are fixed inside */
}

@media (prefers-reduced-motion: reduce) {
  :is(.cy-topnav a, .cy-pills a, .cy-tabs a, .cy-subnav a, .cy-filetoc a, .cy-hint a, .cy-mobile-nav a,
    .cy-icon-btn, .cy-account, .cy-logo, .cy-tag, .cy-card):active {
    transform: none;
  }
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) {
    animation: none !important;
  }
  .cy-main.cy-enter {
    animation: none;
  }
}
