/*
 * polish/press.css — the single press-feedback contract for every control.
 *
 * Geometry contract:
 *   A press never changes scale, transform, dimensions, or icon position.
 *   Feedback is paint-only: compact controls dim while row-style controls
 *   receive a neutral tint, so repeated clicks feel anchored and predictable.
 *
 * State:
 *   :active — native CSS press (paint-only, no JS class mirroring per v3 motion contract).
 *
 * Per-control intensity: set `--press-opacity`; compact icon controls use the
 * stronger --ui-press-opacity-sm value. Reduced motion uses the same stable
 * geometry and a slightly quieter dim.
 */

:where(button, [role='button'], [role='tab'], [role='menuitem'], [role='option']) {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* Compact icon controls dim slightly further so their small surface still
   gives clear feedback without moving the glyph. */
:where(
  .icon-btn,
  .btn-icon,
  .sidebar-view-btn,
  .viz-btn,
  .exec-artifact-download,
  .display-prefs-seg,
  .recent-item-del,
  .msg-toolbar button,
  .new-reply-pill
) {
  --press-opacity: var(--ui-press-opacity-sm);
}

/* Row-style controls: a whole row (or menu item) shrinking reads as a
   wobble, so these acknowledge the press with a tint only. The .app-shell
   branch outranks the shell's own `.app-shell .row.active` / `:hover`
   backgrounds, so the currently selected row still visibly presses. */
:is(
    [role='menuitem'],
    [role='option'],
    .press-tint,
    .recent-item,
    .composer-tools-item,
    .tool-run-summary,
    .sidebar-nav-btn,
    .sidebar-more-item,
    .user-row,
    .kb-node,
    .home-quick-action,
    .thinking-status-clickable
  ):not(:disabled, [aria-disabled='true']):active,
.app-shell
  :is(
    [role='menuitem'],
    [role='option'],
    .press-tint,
    .recent-item,
    .composer-tools-item,
    .tool-run-summary,
    .sidebar-nav-btn,
    .sidebar-more-item,
    .user-row,
    .kb-node,
    .home-quick-action,
    .thinking-status-clickable
  ):not(:disabled, [aria-disabled='true']):active {
  background-color: var(--ui-press-tint);
}

@media (prefers-reduced-motion: no-preference) {
  :is(button, [role='button'], [role='tab']):not(
    :disabled,
    [aria-disabled='true'],
    [role='menuitem'],
    [role='option'],
    .press-tint,
    .recent-item,
    .composer-tools-item,
    .tool-run-summary,
    .sidebar-nav-btn,
    .sidebar-more-item,
    .user-row,
    .kb-node,
    .home-quick-action,
    .thinking-status-clickable
  ) {
    scale: 1;
    /* A press must not replace the button's hover colors with an opacity-only
       transition. Keep the same paint channels through press and release. */
    transition:
      opacity var(--ui-duration-fast) var(--ui-ease-out),
      background-color var(--ui-duration-hover) var(--ui-ease-out),
      border-color var(--ui-duration-hover) var(--ui-ease-out),
      color var(--ui-duration-hover) var(--ui-ease-out),
      box-shadow var(--ui-duration-hover) var(--ui-ease-out);
  }

  :is(button, [role='button'], [role='tab']):not(
      :disabled,
      [aria-disabled='true'],
      [role='menuitem'],
      [role='option'],
      .press-tint,
      .recent-item,
      .composer-tools-item,
      .tool-run-summary,
      .sidebar-nav-btn,
      .sidebar-more-item,
      .user-row,
      .kb-node,
      .home-quick-action,
      .thinking-status-clickable
    ):active {
    scale: 1;
    opacity: var(--press-opacity, var(--ui-press-opacity));
  }
}

@media (prefers-reduced-motion: reduce) {
  :is(button, [role='button'], [role='tab']):not(:disabled, [aria-disabled='true']):active {
    scale: 1;
    opacity: var(--ui-press-opacity);
  }
}

/* Hover may tint, but it must not move the control. Press feedback is
   paint-only. Migrated from restore/chatgpt-v2.css. */
.app-shell :where(button, a, [role='button']):hover {
  transform: none;
}
