/* Original flat controls. Keep popup/glass tokens intact and scope tokens to
   each control so focus, pressed and autofill rules still work. */
:is(button, input, select, textarea, .back-link, .button-link, .nav-tile,
    .userbox, .custom-select-trigger, .file-picker-control,
    .document-policy-option, .task-register-row.is-clickable) {
  --tile-shadow: 0 1px 0 rgba(255, 255, 255, .28) inset;
  --action-shadow: 0 1px 0 rgba(255, 255, 255, .20) inset;
  --control-shadow: var(--tile-shadow);
}

/* A small, contracted shadow under ordinary actions suggests a flat surface
   floating above the page. No bevel, directional border or inner depression.
   Preserve existing hover/touch transforms and transitions. */
:root {
  --flat-action-float: 0 4px 6px -5px rgba(24, 28, 34, .18);
  --flat-action-contact: 0 2px 4px -3px rgba(24, 28, 34, .12);
}
@media (prefers-color-scheme: dark) {
  :root {
    --flat-action-float: 0 4px 6px -5px rgba(0, 0, 0, .36);
    --flat-action-contact: 0 2px 4px -3px rgba(0, 0, 0, .24);
  }
}
:is(.nav-tile, .back-link, .button-link, button.secondary, button.accent,
    .userbox, .task-register-row.is-clickable, .push-setup-close,
    #loginPage button, #toolbar button, .file-picker-button):not(:disabled):not([aria-disabled="true"]):not(.is-disabled) {
  box-shadow: var(--flat-action-float) !important;
}
:is(.nav-tile, .back-link, .button-link, button.secondary, button.accent,
    .userbox, .task-register-row.is-clickable, .push-setup-close,
    #loginPage button, #toolbar button, .file-picker-button):not(:disabled):not([aria-disabled="true"]):not(.is-disabled):is(:active, .is-touching),
.file-picker-control.is-field-touching .file-picker-button {
  box-shadow: var(--flat-action-contact) !important;
}

/* These compact groups can have touching/wrapped controls or only a 4px row
   gap. Keep them flat instead of casting a shadow onto the next control. */
:is(#offlineQueue, #adminUserQualificationsList, #referenceStaffQualificationsList) :is(button, .back-link) {
  --flat-action-float: none;
  --flat-action-contact: none;
}

.wb-plane-field input { box-shadow: var(--tile-shadow); }

@media (prefers-color-scheme: dark) {
  :is(button, input, select, textarea, .back-link, .button-link, .nav-tile,
      .userbox, .custom-select-trigger, .file-picker-control,
      .document-policy-option, .task-register-row.is-clickable) {
    --tile-shadow: 0 1px 0 rgba(255, 255, 255, .08) inset;
    --action-shadow: 0 1px 0 rgba(255, 255, 255, .14) inset;
  }
}

/* Safari: navigation controls should activate on tap, without link previews
   on hold. Leave ordinary text links, selection and input menus unchanged.
   This property is inherited by the SVG/image/label inside each control. */
:is(a.back-link, a.button-link, a.nav-tile, a.userbox, a.brand-home-link,
    a.task-register-link, a[role="button"], .logo a[href]) {
  -webkit-touch-callout: none;
}

/* All app-owned actions, including dynamically inserted document/chart tools.
   The dedicated field and Liquid Glass controls retain their own feedback. */
:is(button, input[type="button"], input[type="submit"], input[type="reset"], [role="button"], summary, a.brand-home-link, a.support-contact):not(:disabled):not([aria-disabled="true"]):not(.is-disabled):not(.custom-select-trigger):not([data-mobile-section]):not(.accent):not(.secondary):not(.primary):not(.document-action):not(#loginBtn):not(#passkeyLoginBtn):not(.support-contact):not(.back-link):not(.nav-tile):not(.button-link):not(.userbox):not(.task-register-row):is(:active,.portal-button-pressed) {
  filter: brightness(.94) !important;
  box-shadow: var(--flat-action-contact) !important;
}
:is(.nav-tile, .back-link, .button-link, .userbox, .task-register-row.is-clickable, .push-setup-close):not(:disabled):not([aria-disabled="true"]):not(.is-disabled).portal-button-pressed {
  background: var(--tile-active-bg) !important;
  border-color: var(--tile-active-border) !important;
  color: var(--tile-active-text) !important;
  -webkit-text-fill-color: var(--tile-active-text) !important;
  box-shadow: var(--flat-action-contact) !important;
}
:is(button.accent,button.secondary,button.primary,button.document-action,#loginPage button,a.support-contact,.policy-heading > .back-link):not(:disabled):not([aria-disabled="true"]):not(.is-disabled):is(:active,.portal-button-pressed) {
  background: var(--action-active-bg) !important;
  border-color: var(--action-active-border,var(--action-border)) !important;
  color: var(--action-active-text,#f2f2f2) !important;
  -webkit-text-fill-color: var(--action-active-text,#f2f2f2) !important;
  filter: none !important;
  box-shadow: var(--flat-action-contact) !important;
}
button.back-link.study-docs-delete-button.portal-button-pressed {
  color: var(--accent) !important;
  -webkit-text-fill-color: var(--accent) !important;
}
@media (prefers-reduced-motion:no-preference) {
  .wb-actions button.primary:not(:disabled):is(:active,.portal-button-pressed) { transform:translateY(1px); }
}

/* Credential editors keep their native selection/paste menu and a stable
   caret rectangle throughout a long press. Button feedback stays unchanged. */
:is(#email, #password, #sessionAccount, #sessionPassword) {
  -webkit-touch-callout: default;
  -webkit-user-select: text;
  user-select: text;
  transform: none !important;
  transition: none !important;
}
