/* button.css: THE button of Theirway, one file for the landing page (/) and
   the app (/app/). Square corners, and the call to action carries the
   mark's folded corner. Who loads it: index.html, files.html, agents.html,
   privacy.html and report.html as /button.css, and the app's index.html
   and demo.html as /app/css/button.css: the same bytes at two addresses.
   Where to look next: controls.css (the site's text actions and fields),
   /app/css/app.css (the app's mapping of the contract below, and its
   text-style buttons), mark.svg (the mark the fold is taken from).

   The controls follow the mark's geometry: edges at 0, 45 and 90 degrees,
   no curves. The fold is the mark's one idea, a corner folded open toward
   the client:

     +---------------------------+--+     the top-right corner is the
     |                           |  /|    mark's quadrant: a square of
     |   Join early access       |/__|    ground (the paper shows through)
     |                           +---+    with the flap in its outer half,
     +-------------------------------+    tips cut back as in the mark

   The mark the fold is taken from, printed from the two paths of mark.svg
   on their 16 by 16 grid, each pixel doubled across because a character is
   taller than it is wide (# the body, / the flap): the diamond with its
   top-right quadrant folded open as one flap.

                   ##    ////////////
                 ####      //////////
               ######        ////////
             ########          //////
           ##########            ////
         ############              //
       ##############
     ################
     ################################
       ############################
         ########################
           ####################
             ################
               ############
                 ########
                   ####

   Every button that is a button looks like this in the app as well: the
   app's .btn is this file, so there is one button, not two.

   WHICH BUTTON GETS WHAT
     .btn            square, plain: the label on whatever lies behind it
     .btn.primary    the fold, flap in --btn-flap (the mark's teal); the
                     one call to action of a view region
     .btn.quiet      a hairline box; the secondary action (no fold: one
                     fold per region keeps the call to action findable)
     .btn.danger     a destructive action: red words on a hairline box, red
                     fill on hover; the fold with a red flap, so it reads
                     as the same button doing something that cannot be
                     undone. Red over --btn-ground is AA in both themes
     .sm .lg .block  small, large, full width (the fold stays at the right
                     corner)
   Text-style buttons (.btn.link, .text-action) and icon buttons (the close
   X, carets, chips) are not boxes and are not here.

   The fold's square is 3/8 of the button's height, as the mark's flap legs
   are 6 of its 16 units. Hover lifts the flap 2px away from the hinge (the
   fold opens a little further); pressing closes it. It is still a labelled
   <button> or <a>: the fold is brand, never the only sign that it presses.

   HOW IT IS SHARED
     One file, one history, served as /button.css and as
     /app/css/button.css, the same bytes. The app's pages link it by a
     relative path, css/button.css, never by /button.css: the app is also
     served alone, where an absolute path would 404.

   THE TOKEN CONTRACT. This file reads --btn-* tokens and a few foundation
   tokens, and sets no colour or size of its own. Each side maps the
   --btn-* tokens from its own tokens in ONE place (the site in
   controls.css, the app in /app/css/app.css), so a button's colours and
   sizes follow that side's design and neither changes by accident. The
   foundation tokens, defined alike in style.css and /app/css/app.css:
   --font-sans, --text-ui, --text-m, --space-2, --dur-fast, --dur,
   --ease-out.

     --btn-height                the heights: plain, small (--btn-height-sm)
     --btn-height-sm             and large (--btn-height-lg); a touch target
     --btn-height-lg             on a phone
     --btn-pad                   the space left and right of the label, in
     --btn-pad-sm                the same three sizes
     --btn-pad-lg
     --btn-label                 the label on a plain or quiet button
     --btn-action                the primary's fill
     --btn-action-hover          and under the pointer
     --btn-on-action             the primary's label (and the danger's, on
                                 its hover fill)
     --btn-flap                  the primary's flap: the mark's teal
     --btn-danger                red words, hairline, hover fill and flap
     --btn-ground                what lies around the button: the bite shows
                                 it, so it must match. A surface (panel,
                                 sheet) sets it to its own background
     --btn-quiet-bg              the quiet and danger buttons' box,
     --btn-quiet-line            its hairline,
     --btn-quiet-line-hover      the hairline under the pointer
     --btn-quiet-hover           and the fill under the pointer
     --btn-disabled-bg           the disabled look of every variant: the
     --btn-disabled-fg           fill, the label
     --btn-disabled-flap         and the flap
     --btn-ring                  the keyboard's ring
     --btn-ring-offset           and how far it stands off the button

   Per button, set by .sm and .lg and read by the fold: --btn-h (height)
   and --btn-x (side padding). A place that needs another height (the
   phone's floating button) sets --btn-h, never height, so the fold stays
   3/8 of what is drawn.

   On both sides, the site's and the app's, every box button is square,
   every fold's bite shows the ground it stands on, and in every state the
   label meets AA contrast on its fill. */

/* --- the button --------------------------------------------------- */

.btn{--btn-h:var(--btn-height);--btn-x:var(--btn-pad);position:relative;display:inline-flex;align-items:center;justify-content:center;gap:var(--space-2);height:var(--btn-h);padding:0 var(--btn-x);border:1px solid transparent;border-radius:0;background:none;color:var(--btn-label);font:500 var(--text-ui)/20px var(--font-sans);white-space:nowrap;cursor:pointer;text-decoration:none;transition:background-color var(--dur-fast) var(--ease-out),border-color var(--dur-fast) var(--ease-out),color var(--dur-fast) var(--ease-out),transform 100ms var(--ease-out)}
.btn:active:not(:disabled){transform:scale(.98)}
.btn:focus-visible{outline:2px solid var(--btn-ring);outline-offset:var(--btn-ring-offset)}
.btn.sm{--btn-h:var(--btn-height-sm);--btn-x:var(--btn-pad-sm);font-size:var(--text-m)}
.btn.lg{--btn-h:var(--btn-height-lg);--btn-x:var(--btn-pad-lg)}
.btn.block{width:100%}

/* --- the hairline box: quiet, and the box a danger button starts from --- */

.btn.quiet{background:var(--btn-quiet-bg);border-color:var(--btn-quiet-line)}
.btn.quiet:hover{border-color:var(--btn-quiet-line-hover);background:var(--btn-quiet-hover)}
.btn.danger{background:var(--btn-quiet-bg);border-color:color-mix(in srgb,var(--btn-danger) 45%,transparent);color:var(--btn-danger)}
.btn.danger:hover{background:var(--btn-danger);border-color:var(--btn-danger);color:var(--btn-on-action)}
.btn.primary{background:var(--btn-action);color:var(--btn-on-action)}
.btn.primary:hover{background:var(--btn-action-hover)}

/* --- the fold: the primary's, and the danger's with a red flap ---- */

/* --btn-ground is what lies around the button, so the bitten corner shows
   the page through it: paper by default, white on a panel or a sheet. The
   label's side padding grows by half the fold so the words stay centred in
   the part of the button that is still whole. */
.btn.primary,.btn.danger{--fold:calc(var(--btn-h) * 3 / 8);padding-right:calc(var(--btn-x) + var(--fold) / 2)}
.btn.primary{--flap:var(--btn-flap)}
.btn.danger{--flap:var(--btn-danger)}
.btn.primary::before,.btn.primary::after,.btn.danger::before,.btn.danger::after{content:"";position:absolute;top:-1px;right:-1px;width:var(--fold);height:var(--fold)}
.btn.primary::before,.btn.danger::before{background:var(--btn-ground)}
.btn.primary::after,.btn.danger::after{background:var(--flap);clip-path:polygon(14% 0,100% 0,100% 86%);transform-origin:100% 0;transition:transform var(--dur) var(--ease-out)}
.btn.primary:hover::after,.btn.primary:focus-visible::after,.btn.danger:hover::after,.btn.danger:focus-visible::after{transform:translate(2px,-2px)}
.btn.primary:active::after,.btn.danger:active::after{transform:scale(.72)}

/* --- disabled: one look for every variant ------------------------- */

/* the doubled .btn: a disabled button must beat every variant's :hover */
.btn.btn:disabled,.btn.btn:disabled:hover{background:var(--btn-disabled-bg);border-color:transparent;color:var(--btn-disabled-fg);cursor:not-allowed}
.btn.primary:disabled::after,.btn.danger:disabled::after{background:var(--btn-disabled-flap);transform:none}
