/* ============================================================
   SILICA WORKS - the CTA button, "Plate"
   ------------------------------------------------------------
   One button for the whole site: index.html's .ap-btn, the inner
   pages' .pg-btn, the footer's "Get in Touch" (.footer-btn) and the
   contact ticket's "Send the brief" (.ct-stub-act, inside the stub
   that tears off - the stub is the real button and drives it).
   Picked from _cta-options.html (01 Plate).

   The nav bar's plate: an ink block with all four corners cut, and
   a lime tile at its right end that carries the drawn arrow. On
   hover (and keyboard focus) a solid lime sheet slides in from the
   left edge under the label, the tile turns ink and the arrow slides
   through. Nothing fades in; the sheet moves in from off the plate.

   ONE CUT. Every corner of every button - the plate, the tile, the
   icon squares, the FAQ field that sits beside its button - is cut
   by the same --btn-cut, in px, at every size. The heights are whole
   pixels too, so no cut lands on half a pixel and renders softer
   than its neighbour.

   ONE SURFACE. The plate and the sheet are one background on the
   element - a hard-stopped gradient, sheet colour then plate colour,
   that slides across on background-position - not a sheet layer
   laid over an ink plate. Two stacked layers are each anti-aliased
   along the cut, so the ink under the lime showed through as
   hairlines on the bevels and edges; one layer has one edge.
     the element    plate + sheet (one gradient, clipped)
     ::after        the tile (behind the arrow)
     .footer-btn-arrow  the arrow, centred on the tile by the padding

   A surface changes the colours through the --btn-* tokens and
   nothing else: paper (default), the footer's lime, the FAQ composer.

   NO FADES. The label and the tile never cross-fade: a colour fade
   on the tile read as a washed-out box flashing up, and on the label
   as grey type. Each one switches in a single frame, timed to the
   moment the sheet's edge reaches it, so the sheet itself appears to
   repaint them. The times are solved from the sheet's ease and hold
   within a frame for every button width on the site:
     in   label 0.27s, tile 0.32s  (the edge travelling right)
     out  tile 0.24s, label 0.29s  (the edge travelling back)
   The sheet also runs 24px past both ends of the plate (the gradient
   is the plate's width twice plus 48px, split at its middle), so the
   slow tail of its ease happens out of sight - it used to leave an
   ink sliver at the right edge that read as a border, then vanished.
   ============================================================ */
:root {
  --btn-cut: 10px;
}

.ap-btn,
.pg-btn,
.footer-row--actions .footer-btn,
.ct-stub-act {
  --btn-h: 56px;
  /* The plate's edge to the tile, on all three sides. */
  --btn-pad: 6px;
  --btn-tile: calc(var(--btn-h) - 2 * var(--btn-pad));
  --btn-arrow: 16px;
  --btn-side: 1.5rem;
  /* Padding that centres the arrow on the tile. */
  --btn-arrow-pad: calc(var(--btn-pad) + (var(--btn-tile) - var(--btn-arrow)) / 2);

  --btn-plate: var(--sw-ink);
  --btn-text: var(--sw-paper);
  --btn-tile-bg: var(--sw-accent);
  --btn-tile-fg: var(--sw-ink);
  --btn-sheet: var(--sw-accent);
  --btn-sheet-text: var(--sw-ink);
  --btn-tile-bg-on: var(--sw-ink);
  --btn-tile-fg-on: var(--sw-accent);

  --btn-in-label: 0.27s;
  --btn-in-tile: 0.32s;
  --btn-out-label: 0.29s;
  --btn-out-tile: 0.24s;

  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  /* The arrow is held to the right end, where its tile is, so it stays
     centred on the tile when js/cta.js rounds the width up. */
  justify-content: space-between;
  /* Label to tile is --btn-side, the same air as the plate's left edge. */
  gap: calc(var(--btn-side) + var(--btn-arrow-pad) - var(--btn-pad));
  width: max-content;
  height: var(--btn-h);
  padding: 0 var(--btn-arrow-pad) 0 var(--btn-side);
  border: 0;
  font-family: "sohne-bold", "Inter Tight", sans-serif;
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
  /* Sheet | plate, split at the middle; at rest the split sits 24px
     off the left edge, so only plate shows. */
  background: linear-gradient(90deg, var(--btn-sheet) 50%, var(--btn-plate) 50%)
    100% 0 / calc(200% + 48px) 100% no-repeat;
  color: var(--btn-text);
  cursor: pointer;
  clip-path: polygon(var(--btn-cut) 0, calc(100% - var(--btn-cut)) 0, 100% var(--btn-cut),
    100% calc(100% - var(--btn-cut)), calc(100% - var(--btn-cut)) 100%,
    var(--btn-cut) 100%, 0 calc(100% - var(--btn-cut)), 0 var(--btn-cut));
  transition: color 0s linear var(--btn-out-label),
    background-position 0.6s cubic-bezier(0.7, 0, 0.2, 1) 0s;
}

/* No sheet layer any more (see ONE SURFACE). */
.ap-btn::before,
.pg-btn::before,
.footer-row--actions .footer-btn::before,
.ct-stub-act::before {
  content: none;
}

/* The tile, cut by the same --btn-cut as the plate. */
.ap-btn::after,
.pg-btn::after,
.footer-row--actions .footer-btn::after,
.ct-stub-act::after {
  content: "";
  position: absolute;
  top: var(--btn-pad);
  right: var(--btn-pad);
  z-index: -1;
  width: var(--btn-tile);
  height: var(--btn-tile);
  background: var(--btn-tile-bg);
  clip-path: polygon(var(--btn-cut) 0, calc(100% - var(--btn-cut)) 0, 100% var(--btn-cut),
    100% calc(100% - var(--btn-cut)), calc(100% - var(--btn-cut)) 100%,
    var(--btn-cut) 100%, 0 calc(100% - var(--btn-cut)), 0 var(--btn-cut));
  transition: background-color 0s linear var(--btn-out-tile);
}

.ap-btn .footer-btn-arrow,
.pg-btn .footer-btn-arrow,
.footer-row--actions .footer-btn .footer-btn-arrow,
.ct-stub-act .footer-btn-arrow {
  width: var(--btn-arrow);
  height: var(--btn-arrow);
  color: var(--btn-tile-fg);
  transition: color 0s linear var(--btn-out-tile);
}

/* Inside the arrow box, only the slide-through moves. */
.ap-btn .footer-btn-arrow svg,
.pg-btn .footer-btn-arrow svg,
.footer-row--actions .footer-btn .footer-btn-arrow svg,
.ct-stub-act .footer-btn-arrow svg {
  transition: transform 0.5s cubic-bezier(0.7, 0, 0.2, 1);
}

/* clip-path cuts any outline off, so focus shows as the hover state. */
.ap-btn:focus-visible,
.pg-btn:focus-visible,
.footer-row--actions .footer-btn:focus-visible {
  outline: none;
}

/* ---- On: hover, keyboard focus, a press on touch, a tap held to
   play before it acts (.is-tap, js/page-exit.js), and the work
   sheet's "next case" peek (css/work-table.css hovers the title). */
.ap-btn.is-tap,
.pg-btn.is-tap,
.footer-row--actions .footer-btn.is-tap,
.ap-btn:focus-visible,
.pg-btn:focus-visible,
.footer-row--actions .footer-btn:focus-visible,
.ap-btn:active,
.pg-btn:active,
.footer-row--actions .footer-btn:active,
.wt-sheet-foot:has(.wt-next:hover) .pg-btn.wt-next-btn,
.ct-tk-stub:focus-visible .ct-stub-act,
.ct-tk-stub:active .ct-stub-act {
  color: var(--btn-sheet-text);
  background-position: 0 0;
  transition-delay: var(--btn-in-label), 0s;
}
.ap-btn.is-tap::after,
.pg-btn.is-tap::after,
.footer-row--actions .footer-btn.is-tap::after,
.ap-btn:focus-visible::after,
.pg-btn:focus-visible::after,
.footer-row--actions .footer-btn:focus-visible::after,
.ap-btn:active::after,
.pg-btn:active::after,
.footer-row--actions .footer-btn:active::after,
.wt-sheet-foot:has(.wt-next:hover) .pg-btn.wt-next-btn::after,
.ct-tk-stub:focus-visible .ct-stub-act::after,
.ct-tk-stub:active .ct-stub-act::after {
  background: var(--btn-tile-bg-on);
  transition-delay: var(--btn-in-tile);
}
.ap-btn.is-tap .footer-btn-arrow,
.pg-btn.is-tap .footer-btn-arrow,
.footer-row--actions .footer-btn.is-tap .footer-btn-arrow,
.ap-btn:focus-visible .footer-btn-arrow,
.pg-btn:focus-visible .footer-btn-arrow,
.footer-row--actions .footer-btn:focus-visible .footer-btn-arrow,
.ap-btn:active .footer-btn-arrow,
.pg-btn:active .footer-btn-arrow,
.footer-row--actions .footer-btn:active .footer-btn-arrow,
.wt-sheet-foot:has(.wt-next:hover) .pg-btn.wt-next-btn .footer-btn-arrow,
.ct-tk-stub:focus-visible .ct-stub-act .footer-btn-arrow,
.ct-tk-stub:active .ct-stub-act .footer-btn-arrow {
  color: var(--btn-tile-fg-on);
  transition-delay: var(--btn-in-tile);
}
.ap-btn.is-tap .footer-btn-arrow svg:first-child,
.pg-btn.is-tap .footer-btn-arrow svg:first-child,
.footer-row--actions .footer-btn.is-tap .footer-btn-arrow svg:first-child,
.ap-btn:focus-visible .footer-btn-arrow svg:first-child,
.pg-btn:focus-visible .footer-btn-arrow svg:first-child,
.footer-row--actions .footer-btn:focus-visible .footer-btn-arrow svg:first-child,
.wt-sheet-foot:has(.wt-next:hover) .pg-btn.wt-next-btn .footer-btn-arrow svg:first-child {
  transform: translate(110%, -110%);
}
.ap-btn.is-tap .footer-btn-arrow svg + svg,
.pg-btn.is-tap .footer-btn-arrow svg + svg,
.footer-row--actions .footer-btn.is-tap .footer-btn-arrow svg + svg,
.ap-btn:focus-visible .footer-btn-arrow svg + svg,
.pg-btn:focus-visible .footer-btn-arrow svg + svg,
.footer-row--actions .footer-btn:focus-visible .footer-btn-arrow svg + svg,
.wt-sheet-foot:has(.wt-next:hover) .pg-btn.wt-next-btn .footer-btn-arrow svg + svg {
  transform: none;
}

/* Hover only where there is a pointer that hovers, so a tap on a
   phone never leaves a button stuck in its hover state. */
@media (hover: hover) {
  .ap-btn:hover,
  .pg-btn:hover,
  .footer-row--actions .footer-btn:hover,
  .ct-tk-stub:hover .ct-stub-act {
    color: var(--btn-sheet-text);
    background-position: 0 0;
    transition-delay: var(--btn-in-label), 0s;
  }
  .ap-btn:hover::after,
  .pg-btn:hover::after,
  .footer-row--actions .footer-btn:hover::after,
  .ct-tk-stub:hover .ct-stub-act::after {
    background: var(--btn-tile-bg-on);
    transition-delay: var(--btn-in-tile);
  }
  .ap-btn:hover .footer-btn-arrow,
  .pg-btn:hover .footer-btn-arrow,
  .footer-row--actions .footer-btn:hover .footer-btn-arrow,
  .ct-tk-stub:hover .ct-stub-act .footer-btn-arrow {
    color: var(--btn-tile-fg-on);
    transition-delay: var(--btn-in-tile);
  }
  .ap-btn:hover .footer-btn-arrow svg:first-child,
  .pg-btn:hover .footer-btn-arrow svg:first-child,
  .footer-row--actions .footer-btn:hover .footer-btn-arrow svg:first-child {
    transform: translate(110%, -110%);
  }
  .ap-btn:hover .footer-btn-arrow svg + svg,
  .pg-btn:hover .footer-btn-arrow svg + svg,
  .footer-row--actions .footer-btn:hover .footer-btn-arrow svg + svg {
    transform: none;
  }
}

/* Phones and tablets: one step smaller, still whole pixels. */
@media (max-width: 1000px) {
  .ap-btn,
  .pg-btn,
  .footer-row--actions .footer-btn,
  .ct-stub-act {
    --btn-h: 50px;
    --btn-pad: 5px;
    --btn-side: 1.25rem;
    font-size: 0.8rem;
  }
}

.pg-btn[disabled] {
  cursor: progress;
  opacity: 0.6;
}

/* ------------------------------------------------------------
   Surfaces
   ------------------------------------------------------------ */

/* The footer's lime: the plate stays ink, the tile and the sheet
   turn paper - a lime sheet would vanish into the lime. */
.footer-row--actions .footer-btn {
  --btn-tile-bg: var(--sw-paper);
  --btn-sheet: var(--sw-paper);
  --btn-tile-fg-on: var(--sw-paper);
}

/* The contact ticket's stub: the ticket's body above it is already
   the ink block, so the button is all white - plate and tile alike,
   ink type and an ink arrow - and stays white. On, only the arrow's
   tile turns green, at once (there is no sheet for it to wait for),
   while the arrow slides through. */
.ct-stub-act {
  --btn-plate: #fff;
  --btn-text: var(--sw-ink);
  --btn-tile-bg: #fff;
  --btn-tile-fg: var(--sw-ink);
  --btn-sheet: #fff;
  --btn-sheet-text: var(--sw-ink);
  --btn-tile-bg-on: var(--sw-accent);
  --btn-tile-fg-on: var(--sw-ink);
  --btn-in-tile: 0s;
  --btn-out-tile: 0s;
}

/* ------------------------------------------------------------
   Variants
   ------------------------------------------------------------ */

/* Back (contact.html "Back to the brief"): the arrow leads, so the
   tile sits at the left end and the padding mirrors. */
.pg-btn.ct-back {
  --btn-in-tile: 0.17s;
  --btn-out-tile: 0.42s;
  padding: 0 var(--btn-side) 0 var(--btn-arrow-pad);
}
.pg-btn.ct-back::after {
  right: auto;
  left: var(--btn-pad);
}

/* Icon squares (css/work-table.css .wt-icon): a plate as wide as it
   is tall, no tile - the icon sits on the plate itself, ink on the
   lime sheet when it is on. */
.pg-btn.wt-icon {
  --btn-h: 40px;
  --btn-in-label: 0.3s;
  --btn-out-label: 0.3s;
  width: var(--btn-h);
  padding: 0;
  gap: 0;
  justify-content: center;
}
.pg-btn.wt-icon::after {
  content: none;
}
