/* ==========================================================================
   BUTTONS: the one source (15 Oct). Change buttons here and nowhere else.
   --------------------------------------------------------------------------
   The site loads this file. The docs load an exact copy, docs/app/buttons.css,
   written by `npm run sync` (scripts/sync-shared.mjs; the dev server runs it
   on start, and `npm run check` fails if the copy has drifted).

   It reads only these roles, which each app maps from its own theme:
     --heading          text colour of the band: the secondary's label, fill and edge
     --brand            main button fill (cream)
     --brand-on         main button label (near-black)
     --sage-green       the main button's hover sweep and edge
     --font-body        Inter

   DESIGN.md §4: 46px tall, 16px side padding, 6px corners, Inter 16.
     .btn               secondary: a quiet fill (the heading colour at 8%)
                        with a 1px edge at 16%, weight 500 (5 Nov; a
                        ghost with no fill before)
     .btn--brand        main: cream, near-black label, weight 600, no border
     .btn--compact      34px tall, 18px padding, Inter 14 at weight 500
                        (2 Nov, after exa.ai's header): header bars
     .btn-group         a row of buttons (stacked full width on phones)
   Hover (after agiloft.com): a layer sweeps in from the left and back out
   to the right on leave, and the button presses in to 98% (96% on click).
   The main button sweeps Sage green; the secondary sweeps its heading colour
   at 10% and its edge firms to 44%. With
   reduced motion the colours change without the sweep or press.
   ========================================================================== */

.btn {
  --btn-sweep: color-mix(in srgb, var(--heading) 10%, transparent);
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px;
  padding-inline: 16px;
  border: 1px solid color-mix(in srgb, var(--heading) 16%, transparent);
  border-radius: 6px;
  background: color-mix(in srgb, var(--heading) 8%, transparent);
  background-clip: padding-box;   /* a transparent edge shows the page, not a ring of the fill */
  font-family: var(--font-body), system-ui, sans-serif;
  font-size: 16px; font-weight: 500; line-height: 1.25; letter-spacing: -0.01em;
  color: var(--heading);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 200ms cubic-bezier(0.2, 0, 0.2, 1),
              transform 120ms cubic-bezier(0.2, 0, 0.2, 1);
}
.btn::before {
  content: '';
  position: absolute; inset: 0; z-index: -1;
  background: var(--btn-sweep);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 350ms cubic-bezier(0.2, 0, 0.2, 1);
}
.btn:focus-visible {
  transform: scale(0.98);
  border-color: color-mix(in srgb, var(--heading) 44%, transparent);
}
.btn:focus-visible::before { transform: scaleX(1); transform-origin: left; }
/* Hover only where hover is real (4 Nov): on touch, a tap used to fire the
   sweep and leave it swept. Keyboard focus keeps the full treatment above. */
@media (hover: hover) {
  .btn:hover {
    transform: scale(0.98);
    border-color: color-mix(in srgb, var(--heading) 44%, transparent);
  }
  .btn:hover::before { transform: scaleX(1); transform-origin: left; }
}
.btn:active { transform: scale(0.96); }

/* No border (15 Oct): the fill is the whole button. The 1px the secondary
   spends on its edge goes to padding, so both are the same size. */
.btn--brand {
  --btn-sweep: var(--sage-green);
  border: 0;
  padding-inline: 17px;
  background: var(--brand);
  color: var(--brand-on);
  font-weight: 600;
}
.btn--brand:is(:hover, :focus-visible) { color: var(--brand-on); }   /* colour only, safe without a hover gate */

.btn--compact { min-height: 34px; padding-inline: 18px; font-size: 14px; }
.btn--brand.btn--compact { padding-inline: 19px; font-weight: 500; }

.btn .icon { --icon-size: 16px; }

.btn-group { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }

/* Phones (5 Nov, user): two or more buttons in a group stack, each full
   width, main button first; "Talk to an architect" didn't fit half a
   phone's row (equal halves from 2 Nov, after exa.ai). A lone button keeps
   its own width. The compact header button opens up to full size in the
   phone menu. */
@media (max-width: 640px) {
  .btn-group:has(> .btn + .btn) { flex-direction: column; align-items: stretch; width: 100%; }
  .btn-group:has(> .btn + .btn) > .btn { width: 100%; }
}
@media (max-width: 991px) {
  .site-actions .btn--compact { min-height: 46px; font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .btn, .btn::before { transition: none; }
  .btn:is(:hover, :focus-visible), .btn:active { transform: none; }
}
