/* v45: shared control feedback. Load after the existing app/admin styles.
   Calendar artwork, field spinners and positioned controls keep their transforms. */
:root {
  --press-duration: 65ms;
  --release-duration: 210ms;
  --control-ease: cubic-bezier(.22, .8, .3, 1);
  --control-focus: var(--accent, #39765a);
}

body button:not(.calendar-day),
body summary,
.admin-shell .back-link {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
body button { -webkit-user-select: none; user-select: none; }
body button :is(svg, .ai-mark) { flex-shrink: 0; pointer-events: none; }
body .chat-thinking-track button { touch-action: pan-y; }

/* Explicit properties keep feedback inexpensive and never animate layout. */
body button:not(:where(.calendar-day, .password-reveal-button)),
#aiView :is(.chat-header-actions button, .chat-send-button, .chat-suggestions button),
#recordDialog :is(.duration-input-row .adjustment-button, .duration-presets button,
  .reminder-date-shortcuts button, .reminder-filters button),
#recordDialog #recordDateButton,
.admin-shell .button {
  transition: transform var(--release-duration) var(--control-ease),
    background-color 150ms ease, border-color 150ms ease, color 150ms ease,
    opacity 150ms ease;
}

/* These controls live in normal flow; their pressed state never changes the box. */
body button:not(:where(.calendar-day, .password-reveal-button, .quick-toggle,
  .month-goal-card, .brand-profile-button, .plan-content)):active:not(:disabled):not([aria-disabled="true"]),
#aiView :is(.chat-header-actions button, .chat-send-button, .chat-suggestions button):active:not(:disabled),
#recordDialog .duration-input-row .adjustment-button:active:not(:disabled) {
  transform: translateY(.5px) scale(.975);
  transition-duration: var(--press-duration);
}

/* Large surfaces respond more gently than small buttons. */
body :is(.month-goal-card, .brand-profile-button, .plan-content):active:not(:disabled) {
  transform: scale(.992);
  transition-duration: var(--press-duration);
}
.password-reveal-button {
  transition: transform var(--release-duration) var(--control-ease),
    color 150ms ease, background-color 150ms ease;
}
.password-reveal-button:active:not(:disabled) {
  transform: translateY(-50%) scale(.94);
  transition-duration: var(--press-duration);
}
.quick-toggle svg { transition: transform 230ms var(--control-ease); }

body button:disabled,
body button[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: .46;
}
body button:not(.password-reveal-button):disabled,
body button:not(.password-reveal-button)[aria-disabled="true"] {
  transform: none;
  transition: none;
}
body .password-reveal-button:disabled { transform: translateY(-50%); }

body :is(button, summary, a, select):focus-visible {
  outline: 2px solid var(--control-focus);
  outline-offset: 3px;
}
.calendar-day:focus-visible { outline-offset: -3px; }
.record-date-picker .rdp-day:focus-visible { outline-offset: -2px; }
.view-tabs .view-tab:focus-visible,
.chat-thinking-track button:focus-visible { outline-offset: -2px; }

/* Clear alignment for every action family, without changing icons or colors. */
:is(.primary-button, .secondary-button, .danger-button, .quiet-button,
  .account-switch-button, .notification-enable-button, .reminder-delete-button,
  .username-reminder-edit, .username-reminder-later, .admin-shell .button,
  .admin-shell .users-refresh) {
  align-items: center;
  justify-content: center;
  line-height: 1.4;
}
.admin-shell :is(.button, .users-refresh) {
  display: inline-flex;
  gap: 8px;
  padding-block: 10px;
  overflow-wrap: anywhere;
}
.admin-shell :is(.button, .users-refresh, .user-card-actions button) { border-radius: 12px; }
.admin-shell .back-link { align-items: center; min-height: 44px; border-radius: 8px; }
.admin-shell .user-card-actions { flex-wrap: wrap; }
.admin-shell .user-card-actions label { min-width: 0; }
.admin-shell .user-card-actions select { max-width: 100%; }
.account-switch-button { min-height: 44px; border-radius: 8px; }
.username-reminder-actions { flex-wrap: wrap; }
.username-reminder-edit, .username-reminder-later { min-height: 40px; }
.username-reminder-close { flex-shrink: 0; }

/* Hover is a surface response; the pointer target stays in place. */
@media (hover: hover) and (pointer: fine) {
  :is(.rdp-heading, .account-switch-button, .username-reminder-later):hover:not(:disabled) {
    background-color: var(--accent-soft, #edf4ef);
  }
  .admin-shell :is(.button, .users-refresh, .language-button):hover:not(:active) { transform: none; }
}

/* Phones and touch tablets share a comfortable target, including landscape.
   Seven-column date grids are exempt from min-width: 44px to prevent overflow. */
@media (max-width: 960px), (pointer: coarse) {
  .topbar .view-tabs { min-height: 52px; height: auto; }
  .topbar .view-tab { min-height: 44px; height: 44px; }
  .header-actions > .icon-button,
  .month-navigation .icon-button,
  html[lang="en"] .month-navigation .icon-button,
  .calendar-layout .day-panel-header .day-record-tools .icon-button,
  .calendar-side .day-panel .record-actions .icon-button,
  .app-dialog .dialog-close,
  #recordDialog .dialog-close,
  .app-dialog .goal-clear-button,
  #addReminderButton,
  #aiView .chat-header-actions .icon-button {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }
  #todayButton { min-height: 44px; min-width: 44px; padding-inline: 10px; }
  .calendar-layout .day-record-tools { gap: 2px; }
  .calendar-side .record-actions { gap: 2px; }
  .plans-footer .plans-view-all { min-height: 44px; margin-block: 0; }
  .plans-pager button { width: 44px; height: 44px; }
  .upcoming-plan { gap: 14px; }
  .upcoming-plan .plan-complete::before { inset: -10px; border-radius: 50%; }
  .upcoming-plan .plan-content { min-height: 44px; }
  #recordDialog :is(.composer-tab, .duration-presets button,
    .reminder-date-shortcuts button, .period-option),
  .analysis-v37 :is(.analysis-segmented button, .analysis-text-button),
  #analysisView .ai-panel-header .ai-status-button,
  #analysisView .ai-panel-header #generateAiButton,
  #aiView .chat-thinking-track button,
  #aiView .chat-suggestions button,
  .app-dialog :is(.primary-button, .secondary-button, .danger-button, .quiet-button),
  .avatar-actions button,
  .username-reminder-edit,
  .username-reminder-later,
  .toast button { min-height: 44px; }
  #recordDialog #clearReminderSearch { flex-basis: 44px; width: 44px; min-height: 44px; }
  .password-input input { padding-right: 52px; }
  .password-input .password-reveal-button { right: 2px; width: 44px; height: 44px; }
  .username-reminder-close { width: 44px; height: 44px; }
  .record-date-picker .rdp-heading { min-height: 44px; border-radius: 8px; }
  .record-date-picker :is(.rdp-icon-button, .rdp-icon-button.rdp-close) { width: 44px; height: 44px; }
  .record-date-picker :is(.rdp-today, .rdp-chooser-done) { min-height: 44px; }
  .record-date-picker .rdp-chooser-field :is(input, select) { height: 44px; }
  .record-date-picker .rdp-day { min-height: 40px; aspect-ratio: auto; }
  .admin-shell :is(.button, .users-refresh, .users-create .button,
    .user-card-actions button, .user-card-actions select, .users-create input,
    .users-create select, .users-search) { min-height: 44px; }
  .admin-shell .language-button { width: 44px; height: 44px; flex-basis: 44px; }
  .admin-shell :is(.field input, .users-create input, .users-create select,
    .users-search, .user-card-actions select) { font-size: 16px; }
  .admin-shell .user-card summary { min-height: 44px; padding-block: 12px; }
}

/* Keep long translated month names and all three picker actions readable. */
@media (max-width: 360px) {
  .calendar-toolbar { padding-inline: 7px; }
  html[lang="en"] .month-navigation h1 { font-size: 15px; }
  .record-date-picker .rdp-top { flex-wrap: wrap; column-gap: 8px; row-gap: 0; }
  .record-date-picker .rdp-heading { flex-basis: calc(100% - 144px); font-size: 14px; }
  .record-date-picker .rdp-month-chooser { grid-template-columns: minmax(0, 1fr) minmax(0, .85fr); }
  .record-date-picker .rdp-chooser-done { grid-column: 1 / -1; justify-self: stretch; }
}

/* Short landscape screens retain a scrollable picker with compact date rows. */
@media (max-height: 480px) {
  .record-date-picker .rdp-day { min-height: 35px; }
  .record-date-picker .rdp-top { margin-bottom: 2px; }
  .record-date-picker .rdp-footer { margin-top: 6px; }
}

/* Shared override also catches older, more specific control animations. */
@media (prefers-reduced-motion: reduce) {
  body button,
  body button::before,
  body button::after,
  body button svg,
  .password-eye { transition: none !important; }
  body button:not(:where(.password-reveal-button, .calendar-day)):active { transform: none !important; }
  body .password-reveal-button:active { transform: translateY(-50%) !important; }
}
