/* ==========================================================================
   Buttons — .btn and its variants (primary / icon / small / large / ghost /
   elevated / caret), plus the coarse-pointer hit-area extension.
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border-radius: var(--radius-m);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--foreground);
  font-weight: 550;
  font-size: 13px;
  white-space: nowrap;
  transition: background-color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}

.btn:hover:not(:disabled) { background: var(--surface-hover); border-color: var(--border-strong); }
.btn:active:not(:disabled) { background: var(--surface-muted); }

/* 触屏热区扩展：透明 ::after 把 32px 按钮的热区垫到 ≥44px（WCAG 2.5.8 只
   要求 24px，44px 是触屏惯例），视觉尺寸不变。inset 相对 padding box，
   1px 边框两侧各吃 1px，故用 7px 补偿（30px padding box + 2×7 = 44px）。
   命中最上层绘制者——后出现的兄弟按钮自身盒子压过前者的扩展区，扩展只
   覆盖按钮之间的缝隙与相邻空当。 */
@media (hover: none) and (pointer: coarse) {
  #app-header .btn,
  #map-fit .btn,
  .profile-head .btn { position: relative; }
  /* The header row is the 32px family, the map stacks the 34px squares. */
  #app-header .btn::after { content: ""; position: absolute; inset: -7px; }
  #map-fit .btn::after { content: ""; position: absolute; inset: -6px; }
  .profile-head .btn::after { content: ""; position: absolute; inset: -8px -5px; }
}

.btn-primary {
  background: var(--primary);
  border-color: transparent;
  color: var(--primary-foreground);
}
.btn-primary:hover:not(:disabled) { background: var(--primary); filter: brightness(1.1); }
.btn-primary:active:not(:disabled) { filter: brightness(0.95); }

.btn-icon { width: 34px; padding: 0; justify-content: center; }
.btn-small { height: 28px; padding: 0 10px; font-size: 12px; }
.btn-large { height: 40px; padding: 0 18px; font-size: 14px; }

/* The header row unifies every control — these buttons, the .btn-icon
   triggers, the Gitee link's mark square and the left side's chip /
   route-note squares and logo tile (layout.css) — at one 32px outer
   height. 32 is a multiple of 4, so the painted height is an integer
   number of device pixels at the 100 / 125 / 150 / 200% display scales
   (32/40/48/64 px); any other height sheds half a pixel of edge ink at
   125% (a 30px box paints 37.5 physical px, a 34px box 42.5). Scoped to
   the header: the map tools keep their 34px squares and the profile head
   its own set. */
#app-header .btn { height: 32px; }
#app-header .btn-icon { width: 32px; }

.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--surface-hover); border-color: transparent; }

.btn-caret .icon { width: 14px; height: 14px; color: var(--foreground-faint); }

.btn-elevated {
  background: var(--surface-elevated);
  border-color: var(--border);
  box-shadow: var(--shadow-1);
}

.btn-icon-slot { display: inline-flex; align-items: center; }
.btn-icon-slot .icon { width: 16px; height: 16px; }
