/* ============================================================
   BGF Sentinel — buttons for thumbs.

   Loaded after grove.css by both phone apps. One press feel, hover
   only where there is a mouse, 44px targets, Geist on every label,
   no glow. Selectors mirror the ones they override so the cascade,
   not !important, decides (except where grove.css already uses it).
   ============================================================ */

button, .btn, [role="button"] {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
button:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--glacier);
  outline-offset: 2px;
}

/* ── Base (Apple HIG Tactile Physics) ────────────────────── */
.btn {
  min-height: 44px;
  border-radius: var(--tp-radius-md, var(--gw-r-ctl));
  font-family: var(--sans);
  font-weight: 600;
  letter-spacing: -0.01em;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), var(--tp-shadow-sm, 0 1px 2px rgba(0,0,0,0.3));
  transition: transform 0.16s cubic-bezier(0.25, 1, 0.5, 1),
              background-color 0.15s ease,
              border-color 0.15s ease,
              color 0.15s ease,
              filter 0.15s ease,
              box-shadow 0.15s ease;
}
.btn-primary {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 2px 6px rgba(0, 0, 0, 0.25);
  letter-spacing: -0.015em;
}
[data-theme="light"] .btn:not(.btn-primary) { box-shadow: 0 1px 2px rgba(0,0,0,0.06); }
.btn:disabled, .btn[disabled] { box-shadow: none; opacity: 0.45; }

/* Apple iOS spring press: proportional shrink + slight brightness dip */
button:active:not(:disabled):not([disabled]):not(#btn-confirm-sos),
.btn:active:not(:disabled):not([disabled]):not(#btn-confirm-sos),
.btn-primary:active:not(:disabled):not([disabled]),
.map-ctrl-btn:active:not(:disabled):not([disabled]),
.lang-switcher:active:not(:disabled):not([disabled]) {
  transform: scale(0.965);
}
.btn:not(.btn-primary):not(.btn-danger):not(.tag-del):active:not(:disabled) {
  background: var(--hair);
  filter: brightness(0.95);
}
.btn-primary:active:not(:disabled) {
  filter: brightness(0.92);
}

/* A primary button never turns grey under a finger or a cursor. */
.btn-primary:hover { background: var(--glacier); }
@media (hover: hover) {
  .btn-primary:hover { filter: brightness(1.06); }
}
/* Touch screens keep :hover after a tap; undo it so nothing stays lit. */
@media (hover: none) {
  .btn:not(.btn-primary):not(.btn-danger):not(.tag-del):hover { background: var(--slate-3); }
  .tag-actions .tag-del:hover { background: transparent; }
  .btn-primary:hover { filter: none; }
  .btn-danger:hover { background: rgba(229, 83, 75, 0.2); color: var(--oxblood); }
  .agent-acts .btn-danger:hover { background: transparent; color: var(--bone-dim); border-color: var(--hair); }
  .ord-btn:hover:not([disabled]) { background: var(--slate-3); color: var(--bone-dim); border-color: var(--hair); }
}

/* ── Icon buttons ─────────────────────────────────────────── */
.btn-x {
  flex: none; display: grid; place-items: center;
  width: 44px; height: 44px; min-width: 44px; padding: 0;
  border-radius: var(--gw-r-ctl);
  border: 1px solid var(--hair); background: transparent; color: var(--bone-dim);
  cursor: pointer;
}
.btn-x:active { background: var(--slate-3); color: var(--bone); }
.btn-ico { flex: none; }

/* ── Sentinel Superviseur ─────────────────────────────────── */
.mobile-app-actions .mobile-app-action { width: 44px; height: 44px; min-width: 44px; min-height: 44px; }

.map-ctrl-btn,
.map-ctrl-select { min-height: 44px !important; height: 44px; }
#btn-measure-tool,
.map-ctrl-btn[onclick="recenterMap()"] { width: 44px !important; }

/* Points: editing is ordinary, deleting is a small deliberate target. */
.tag-actions .tag-edit { justify-content: center; }
.tag-actions .tag-del {
  width: 44px; min-width: 44px; height: 44px; padding: 0;
  justify-content: center;
  background: transparent; border-color: var(--hair); color: var(--oxblood);
}
.tag-actions .tag-del:active:not(:disabled) { background: color-mix(in srgb, var(--oxblood) 14%, transparent); border-color: var(--oxblood); }
@media (hover: hover) {
  .tag-actions .tag-del:hover { background: color-mix(in srgb, var(--oxblood) 14%, transparent); border-color: var(--oxblood); }
}

/* Envoi: documents and outbox rows are plain actions, not alerts. */
.wa-doc { justify-content: center; font-size: 13px; }
.wa-row-btn { min-height: 40px; padding: 0 12px; font-size: 12px; }

/* ── Sentinel Agents ──────────────────────────────────────── */
.gw-header .lang-switcher,
.gw-header .btn-end { height: 44px; }
.gw-header .lang-switcher { min-width: 44px; }

.gw-actions .note-btn { height: 56px; min-height: 56px; margin: 0; white-space: nowrap; }

/* Sign-in / sign-up: Apple HIG iOS Segmented Control */
.auth-tabs, .gw-seg, .sd-seg {
  display: grid; grid-template-columns: 1fr 1fr; gap: 3px;
  padding: 3px; margin-bottom: 18px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--tp-border, var(--hair));
  border-radius: var(--tp-radius-md, 12px);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.4);
}
.auth-tab, .gw-seg-btn, .sd-seg-btn {
  min-height: 40px; padding: 0 14px;
  border: 1px solid transparent; border-radius: calc(var(--tp-radius-md, 12px) - 3px);
  background: transparent; color: var(--tp-text-muted, var(--bone-faint));
  font-family: var(--tp-font-sans, var(--sans));
  font-size: 13.5px; font-weight: 600; letter-spacing: -0.01em;
  transition: all 0.18s cubic-bezier(0.25, 1, 0.5, 1);
}
.auth-tab.active, .gw-seg-btn[aria-selected="true"], .sd-seg-btn.active {
  background: var(--tp-surface, var(--slate-3));
  color: var(--tp-text-primary, var(--bone));
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

/* Dialog buttons: sentence case, same height side by side. */
.modal-actions .btn,
.modal-actions .btn-primary {
  min-height: 48px; padding: 12px;
  border-radius: var(--gw-r-ctl);
  text-transform: none; letter-spacing: 0;
  font: 600 15px/1.2 var(--sans);
}
.modal-actions #btn-confirm-sos { font: 700 12px/1.25 var(--mono); letter-spacing: 0.06em; }

.btn-close-guide,
.install-guide-sheet .btn-close-guide {
  min-height: 48px; border-radius: var(--gw-r-ctl);
  font: 600 15px/1 var(--sans);
}
.btn-close-cam { min-height: 44px; border-radius: var(--gw-r-ctl); font-family: var(--sans); }

@media (prefers-reduced-motion: reduce) {
  .btn, button { transition: none; }
}
