/* App-wide interaction layer (owner: Claude), loaded last. Rules from the charles-ux-animation skill:
   press 150ms ease-out scale .96 on small targets, background change on wide rows, hover only on real pointers,
   sheets enter 280ms ease-out and leave 200ms ease-in, no transition on tab switch or theme switch. */
:root { --ease-in: cubic-bezier(.55,0,1,.45); --ease-in-out: cubic-bezier(.77,0,.175,1); --press: 150ms; }

/* press: small targets scale, the response itself */
:is(.icon-btn, .chip, .btn, .shell-tab, .cp-chip, .cp-send, .chat-send, .ask-suggestion, .you-chip, .you-segment, .you-icon-btn,
    .you-primary-btn, .you-ghost-btn, .you-text-btn, .ex-action, .ex-icon-btn, .ex-segment, .ex-clear, .ex-continue-btn, .saved-segment,
    .saved-remove, .saved-note-save, .listen-control, .paywall-primary, .paywall-secondary, .paywall-restore, .shell-size-option, .cp-new, .cp-notice-action, .ask-retry, .ask-paywall-action) {
  transition-property: transform, background-color, border-color, color, opacity; transition-duration: var(--press); transition-timing-function: var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}
:is(.icon-btn, .chip, .btn, .shell-tab, .cp-chip, .cp-send, .chat-send, .ask-suggestion, .you-chip, .you-segment, .you-icon-btn,
    .you-primary-btn, .you-ghost-btn, .you-text-btn, .ex-action, .ex-icon-btn, .ex-segment, .ex-clear, .ex-continue-btn, .saved-segment,
    .saved-remove, .saved-note-save, .listen-control, .paywall-primary, .paywall-secondary, .paywall-restore, .shell-size-option, .cp-new, .cp-notice-action, .ask-retry, .ask-paywall-action):not(:disabled):active { transform: scale(.96); }
.shell-onboard-action:not(:disabled):active, .paywall-primary:not(:disabled):active { transform: scale(.98); }   /* full-width: smaller squeeze */

/* wide surfaces (rows, cards) change background instead of scaling */
:is(.ex-book, .ex-result, .ex-continue, .saved-item, .you-setting-row, .you-reset-row, .you-memory-item, .shell-start-card, .paywall-plan, .listen-timer-option) {
  transition: background-color var(--press) ease, border-color var(--press) ease; -webkit-tap-highlight-color: transparent;
}
:is(.ex-book, .ex-result, .ex-continue, .saved-item, .you-setting-row, .you-reset-row, .shell-start-card, .paywall-plan, .listen-timer-option):active { background-color: var(--surface-2); }

/* hover only where a real pointer hovers; touch screens would keep a sticky hover after a tap */
@media (hover: hover) and (pointer: fine) {
  :is(.ex-book, .ex-result, .ex-continue, .saved-item, .you-setting-row, .you-reset-row, .shell-start-card, .paywall-plan):hover { background-color: var(--surface-2); border-color: var(--muted); }
  :is(.chip, .cp-chip, .ask-suggestion, .you-chip, .ex-action, .ex-segment, .saved-segment, .you-segment):not(.is-selected, .is-on, [aria-pressed="true"]):hover { color: var(--ink); border-color: var(--muted); }
  :is(.cp-send, .chat-send, .paywall-primary, .btn-primary, .you-primary-btn):not(:disabled):hover { opacity: .88; }
  .feed-action:hover .icon { transform: scale(1.08); }
  .feed-action .icon { transition: transform var(--press) var(--ease-out); }
  .shell-tab:hover { color: var(--ink); }
}
@media (hover: none) { .cp-chip:hover, .shell-start-card:hover { transform: none; } }   /* module hover lifts off on touch */

/* sheets: enter ease-out, leave the way they came, shorter and ease-in (ui.js adds .sheet-closing) */
dialog.sheet { animation: sheet-in 280ms var(--ease-out) both; }
dialog.sheet::backdrop { animation: scrim-in 280ms var(--ease-out) both; }
dialog.sheet.sheet-closing { animation: sheet-out 200ms var(--ease-in) both; pointer-events: none; }
dialog.sheet.sheet-closing::backdrop { animation: scrim-out 200ms var(--ease-in) both; }
@keyframes sheet-in { from { transform: translateY(100%); } }
@keyframes sheet-out { to { transform: translateY(100%); } }
@keyframes scrim-in { from { opacity: 0; } }
@keyframes scrim-out { to { opacity: 0; } }
@media (min-width: 600px) { @keyframes sheet-in { from { opacity: 0; transform: translateY(24px) scale(.97); } } @keyframes sheet-out { to { opacity: 0; transform: translateY(16px) scale(.97); } } }

/* tabs are switched many times a session: show the new screen on the next frame. Theme switch: no page-wide colour fade. */
.shell-screen-active { animation: none; }
body { transition: none; }

/* the tab bar stays pinned to the viewport on every screen (it was absolute inside a growing #app) */
#tabbar { position: fixed; left: 0; right: 0; margin: 0 auto; max-width: var(--app-w); }

/* toast: ease-out in, quicker ease-in out */
.toast { transition: opacity 200ms var(--ease-in), transform 200ms var(--ease-in); }
.toast.show { transition: opacity 260ms var(--ease-out), transform 260ms var(--ease-out); }

@media (prefers-reduced-motion: reduce) { :is(*):active { transform: none !important; } dialog.sheet, dialog.sheet::backdrop { animation: none !important; } }

/* reveal(): AI answers flow in word by word */
.rv { animation: rv-in .32s var(--ease) both; }
@keyframes rv-in { from { opacity: 0; filter: blur(3px); } }
