/* polish: buttons — see AGENTS.md (v77 polish pass). Loaded after trip.css.
 *
 * Shared button / chip system. Three sizes only:
 *   md   – action buttons & nav/map links ........ min-height 40px, 0 16px, .86rem
 *   sm   – chips, filters, segmented items ........ min-height 32px, 0 12px, .8rem
 *   icon – round icon-only buttons ................ 40×40
 * Only geometry, typography, transitions and interaction states are normalised
 * here; colours stay with trip.css (light + dark). Sizing uses !important where
 * trip.css media rules or inline style="padding:…" would otherwise win.
 */

:root {
  --btn-md-h: 40px;
  --btn-sm-h: 32px;
  --btn-icon: 40px;
  --btn-transition:
    background-color var(--duration-fast, 140ms) var(--ease-out, ease),
    border-color var(--duration-fast, 140ms) var(--ease-out, ease),
    color var(--duration-fast, 140ms) var(--ease-out, ease),
    box-shadow var(--duration-fast, 140ms) var(--ease-out, ease),
    transform var(--duration-fast, 140ms) var(--ease-out, ease);
}

/* ------------------------------------------------------------------ */
/* Shared base: every button-like control in the system                */
/* ------------------------------------------------------------------ */
:is(.btn-share, .btn-share-editorial, .btn-map, .btn-day-nav-footer, .btn-ticket-link,
    .btn-backup-gmap, .btn-submit-expense, .btn-day-step, .btn-rate-refresh, .btn-gps-tactile,
    .curr-btn, .curr-pill-btn, .subtab-btn, .daily-mode-btn, .settle-mode-btn,
    .target-segmented-btn, .member-chip-btn, .cat-chip-btn, .preset-chip, .jp-filter-chip,
    .vn-filter-chip, .loc-chip-btn, .modal-close, .phrase-speak-btn, .curr-swap-btn),
.editorial-pill-link:not(#topHero .editorial-pill-link) {
  box-sizing: border-box;
  align-items: center;
  justify-content: center;
  line-height: 1.2;
  font-family: inherit;
  text-decoration: none;
  vertical-align: middle;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: var(--btn-transition) !important;
}
/* keep the monospace numerals where trip.css asked for them */
.curr-pill-btn,
.preset-chip { font-family: 'DM Mono', monospace; }

/* ------------------------------------------------------------------ */
/* md — default action buttons, map / nav links                        */
/* ------------------------------------------------------------------ */
.btn-share,
.btn-share-editorial,
.btn-map,
.btn-day-nav-footer,
.btn-ticket-link,
.member-chip-btn,
.cat-chip-btn {
  display: inline-flex;
  min-height: var(--btn-md-h);
  padding: 8px 16px !important;
  gap: 6px;
  font-size: 0.86rem !important;
  font-weight: 600;
  border-radius: var(--radius-md, 8px);
  text-align: center;
}
/* share/copy buttons were the odd pill out; align with the other md buttons */
.btn-share { border-radius: var(--radius-md, 8px); }
/* selection tiles (member / category pickers) keep label weight but use md geometry */
.member-chip-btn,
.cat-chip-btn { padding: 8px 12px !important; }
.btn-day-nav-footer,
.btn-ticket-link { font-weight: 700; }

/* Dense inline variants: markup asks for a compact button via
   style="padding:2px 8px / 3px 10px / 4px 10px". Map them onto sm instead
   of their ad-hoc 24–28px heights. */
:is(.btn-share, .btn-share-editorial, .btn-map)[style*="padding:2px"],
:is(.btn-share, .btn-share-editorial, .btn-map)[style*="padding:3px"],
:is(.btn-share, .btn-share-editorial, .btn-map)[style*="padding:4px"],
.btn-backup-gmap,
.btn-day-step,
.btn-rate-refresh,
.btn-gps-tactile {
  display: inline-flex;
  min-height: var(--btn-sm-h);
  padding: 6px 12px !important;
  gap: 6px;
  font-size: 0.8rem !important;
  border-radius: var(--radius-sm, 6px);
  white-space: nowrap;
}
.btn-rate-refresh { border-radius: var(--radius-pill, 9999px); }

/* Primary submit CTA: keeps its full-width prominence, aligned to the scale */
.btn-submit-expense {
  display: inline-flex;
  min-height: 48px;
  padding: 12px 24px !important;
  gap: 8px;
  border-radius: var(--radius-md, 8px);
  font-size: 0.94rem !important;
  flex-wrap: wrap;
  row-gap: 2px;
  text-align: center;
}
.btn-submit-expense > span { margin-left: 0 !important; }

/* ------------------------------------------------------------------ */
/* sm — chips, filter pills, quick-pick pills                          */
/* ------------------------------------------------------------------ */
.jp-filter-chip,
.vn-filter-chip,
.loc-chip-btn,
.editorial-pill-link:not(#topHero .editorial-pill-link) {
  display: inline-flex;
  min-height: var(--btn-sm-h);
  padding: 6px 12px !important;
  gap: 6px;
  font-size: 0.8rem !important;
  font-weight: 600;
  border-radius: var(--radius-pill, 9999px);
  white-space: nowrap;
}

/* ------------------------------------------------------------------ */
/* Segmented controls: track gives 4px inset, items are sm             */
/* ------------------------------------------------------------------ */
.subtab-switch,
.daily-mode-switch,
.settle-mode-bar,
.target-segmented-bar,
.curr-pill-selector,
.currency-toggle {
  padding: 4px !important;
  gap: 4px !important;
  align-items: center;
}
.subtab-switch,
.daily-mode-switch { margin-bottom: 20px !important; }

.subtab-btn,
.daily-mode-btn,
.settle-mode-btn,
.target-segmented-btn,
.curr-pill-btn,
.curr-btn {
  display: inline-flex;
  min-height: var(--btn-sm-h);
  padding: 6px 12px !important;
  gap: 6px;
  font-size: 0.8rem !important;
  white-space: nowrap;
}
/* pill tracks → pill items; rounded-rect tracks → 6px items */
.subtab-btn,
.daily-mode-btn,
.settle-mode-btn,
.curr-btn { border-radius: var(--radius-pill, 9999px); }
.target-segmented-btn,
.curr-pill-btn { border-radius: var(--radius-sm, 6px); }
.subtab-btn,
.daily-mode-btn { padding: 6px 16px !important; font-weight: 700; }
.curr-btn { border: 1px solid transparent; }

/* Currency preset tiles are two-line (amount + label); keep auto height */
.preset-chip {
  min-height: var(--btn-md-h);
  gap: 2px;
  border-radius: var(--radius-sm, 6px);
}

/* ------------------------------------------------------------------ */
/* icon-only                                                           */
/* ------------------------------------------------------------------ */
.modal-close,
.phrase-speak-btn,
.curr-swap-btn {
  display: inline-flex;
  width: var(--btn-icon) !important;
  height: var(--btn-icon) !important;
  min-width: var(--btn-icon) !important;
  min-height: var(--btn-icon) !important;
  padding: 0 !important;
  border-radius: var(--radius-pill, 9999px) !important;
  flex-shrink: 0;
  line-height: 1;
}

/* ------------------------------------------------------------------ */
/* Button groups                                                       */
/* ------------------------------------------------------------------ */
.node-footer-btns,
.day-action-btns {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px !important;
}
:is(.node-footer-btns, .day-action-btns) > :is(a, button) { margin: 0 !important; }

@media (max-width: 480px) {
  /* 2–3 md buttons in a group become equal full-width columns */
  .node-footer-btns > :is(.btn-map, .btn-share, .btn-share-editorial),
  .day-action-btns > :is(.btn-map, .btn-share, .btn-share-editorial) {
    flex: 1 1 0 !important;
    min-width: calc(50% - 4px);
    padding-left: 12px !important;
    padding-right: 12px !important;
  }
  .btn-day-nav-footer { justify-content: center; }
}

/* ------------------------------------------------------------------ */
/* States                                                              */
/* ------------------------------------------------------------------ */
:is(.btn-share, .btn-share-editorial, .btn-map, .btn-day-nav-footer, .btn-ticket-link,
    .btn-backup-gmap, .btn-submit-expense, .btn-day-step, .btn-rate-refresh, .btn-gps-tactile,
    .curr-btn, .curr-pill-btn, .subtab-btn, .daily-mode-btn, .settle-mode-btn,
    .target-segmented-btn, .member-chip-btn, .cat-chip-btn, .preset-chip, .jp-filter-chip,
    .vn-filter-chip, .loc-chip-btn, .modal-close, .phrase-speak-btn, .curr-swap-btn,
    .editorial-pill-link):focus-visible {
  outline: 2px solid var(--accent) !important;
  outline-offset: 2px !important;
}

:is(.btn-share, .btn-share-editorial, .btn-map, .btn-day-nav-footer, .btn-ticket-link,
    .btn-backup-gmap, .btn-submit-expense, .btn-day-step, .btn-rate-refresh, .btn-gps-tactile,
    .curr-btn, .curr-pill-btn, .subtab-btn, .daily-mode-btn, .settle-mode-btn,
    .target-segmented-btn, .member-chip-btn, .cat-chip-btn, .preset-chip, .jp-filter-chip,
    .vn-filter-chip, .loc-chip-btn, .modal-close, .phrase-speak-btn, .curr-swap-btn):active,
.editorial-pill-link:not(#topHero .editorial-pill-link):active {
  transform: translateY(1px) !important;
}

/* Hover lift only on devices that really hover (no sticky lift on touch) */
@media (hover: none) {
  :is(.btn-share, .btn-share-editorial, .btn-map, .btn-day-nav-footer, .btn-ticket-link,
      .btn-backup-gmap, .member-chip-btn, .cat-chip-btn, .preset-chip, .jp-filter-chip,
      .btn-submit-expense):hover:not(:active) {
    transform: none;
  }
}

:is(.btn-share, .btn-share-editorial, .btn-map, .btn-day-nav-footer, .btn-ticket-link,
    .btn-backup-gmap, .btn-submit-expense, .btn-day-step, .btn-rate-refresh, .btn-gps-tactile,
    .curr-btn, .curr-pill-btn, .subtab-btn, .daily-mode-btn, .settle-mode-btn,
    .target-segmented-btn, .member-chip-btn, .cat-chip-btn, .preset-chip, .jp-filter-chip,
    .vn-filter-chip, .loc-chip-btn, .modal-close, .phrase-speak-btn, .curr-swap-btn):is(:disabled, [aria-disabled="true"]) {
  opacity: 0.5 !important;
  cursor: not-allowed !important;
  transform: none !important;
  box-shadow: none !important;
}

/* Hover affordance for segmented items that had none in the dark theme */
@media (hover: hover) {
  :root[data-theme="dark"] :is(.subtab-btn, .daily-mode-btn):not(.active):hover { color: #F2F7FF; }
}

/* Compact buttons inside table cells keep the sm height but stay narrow */
td > :is(.btn-share, .btn-share-editorial, .btn-map) {
  padding: 6px 10px !important;
  font-size: 0.76rem !important;
}

/* Currency segmented selector must never push past the card on phones */
.curr-pill-selector { max-width: 100%; }
@media (max-width: 480px) {
  .curr-pill-btn {
    flex: 1 1 auto;
    min-width: 0;
    padding: 6px 6px !important;
    font-size: 0.74rem !important;
    letter-spacing: -0.01em;
    white-space: nowrap;
  }
}
