/*
 * The Staging Website's buttons and arrows, for every page of the Production Website.
 * Ported from the Staging app's sources (tokens.css `.btn-gradient`, cta.css, ArrowPair.tsx) as plain CSS. The
 * pages are dark, so the dark values are written out here and nothing depends on a day mode.
 *
 *   .btn-gradient   the gradient button: 40px (small) or 48px (data-size="lg", 40px on a phone), a pill, 500.
 *                   data-chevron: a chevron arrives as it hovers, and the button widens 10px (taking the width
 *                   back out of its own margin, so nothing beside it moves) on a spring, with a 4% squash
 *                   from ui.js. data-glyph="plus": the same, with a plus that turns a quarter as it arrives,
 *                   and to an x while what it opens is open.
 *   .arrow-pair     previous and next as one pill, two chevrons, a disc that comes up behind the one the
 *                   pointer is on.
 *
 * Where there is no hover (a phone) there is no glyph, no place kept for it and no growth: a tap leaves
 * nothing stuck. Reduced motion: no transitions.
 */

:root {
  --control-h-sm: 40px;
  --control-h-lg: 48px;
  --ease-house: cubic-bezier(0.25, 1, 0.5, 1);

  /* pixai.com's own swell, one curve: 10px, then 11px, then 10 again. The fallback where linear() is unknown. */
  --ease-elastic: cubic-bezier(0.25, 1.1, 0.9, 1);
  --spring-in: var(--ease-elastic);
  --spring-out: var(--ease-elastic);
  --spring-in-time: 0.5s;
  --spring-out-time: 0.5s;
}

/* The springs the widening moves on (Google Labs' "Try it now" button, gentled): out, it goes 16% past
   (11.6px) and is still within 0.6s; back, it overshoots once by 6% and is still within 0.45s. "in" is the
   curve the hovered state transitions on and "out" the resting one: a transition takes the curve of the
   state it is going to. */
@supports (transition-timing-function: linear(0, 1)) {
  :root {
    --spring-in: linear(
      0, 0.107 4.17%, 0.347 8.33%, 0.62 12.5%, 0.86 16.67%, 1.032 20.83%, 1.129 25%,
      1.163 29.17%, 1.151 33.33%, 1.114 37.5%, 1.069 41.67%, 1.029 45.83%, 0.999 50%,
      0.981 54.17%, 0.974 58.33%, 0.975 62.5%, 0.98 66.67%, 0.988 70.83%, 0.994 75%,
      1 79.17%, 1.003 83.33%, 1.004 87.5%, 1.004 91.67%, 1.003 95.83%, 1
    );
    --spring-out: linear(
      0, 0.101 5.56%, 0.316 11.11%, 0.549 16.67%, 0.75 22.22%, 0.897 27.78%, 0.99 33.33%,
      1.039 38.89%, 1.057 44.44%, 1.055 50%, 1.045 55.56%, 1.031 61.11%, 1.019 66.67%,
      1.009 72.22%, 1.002 77.78%, 0.999 83.33%, 0.997 88.89%, 0.997 94.44%, 1
    );
    --spring-in-time: 0.6s;
    --spring-out-time: 0.45s;
  }
}

/* ============================================================== the gradient button */

.btn-gradient {
  --pad: 1.25rem;
  /* The chevron (15px) and the 4px before it. */
  --slot: 19px;
  /* How much wider the button gets on hover. */
  --grow: 10px;
  /* The glow, in the dark values. */
  --cta-shadow: 0 0 10px rgb(60 123 255 / 0.5), 0 0 0 rgb(60 123 255 / 0);
  --cta-shadow-hover: 0 0 18px rgb(60 123 255 / 0.62), 0 0 0 rgb(60 123 255 / 0);
  --cta-shadow-press: 0 0 6px rgb(60 123 255 / 0.45), 0 0 0 rgb(60 123 255 / 0);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-sizing: border-box;
  height: var(--control-h-sm);
  margin: 0;
  border: 0;
  border-radius: 9999px;
  padding-block: 0;
  padding-inline: var(--pad);
  color: #070039;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 14px;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  outline: 2px solid transparent;
  outline-offset: 2px;
  background-color: transparent;
  background-image: linear-gradient(160deg, #00ebff 0%, #0063ff 100%);
  background-repeat: no-repeat;
  background-size: 100% 100%;
  background-position: 0 0;
  box-shadow: var(--cta-shadow), inset 0 1px 0 rgb(255 255 255 / 0.32);
  transition:
    background-size 0.5s ease,
    background-position 0.5s ease,
    box-shadow 0.4s ease,
    opacity 0.3s ease;
}

.btn-gradient:focus-visible {
  outline-color: #00e8ff;
}

.btn-gradient[data-size="lg"] {
  --pad: 1.5rem;
  height: var(--control-h-lg);
  font-size: 16px;
  line-height: 16px;
}

/* On a phone (below 640px) the large button is the small one, as pixai.com's is: 40px high, 14px type,
   20px a side. */
@media (width < 40rem) {
  .btn-gradient[data-size="lg"] {
    --pad: 1.25rem;
    height: var(--control-h-sm);
    font-size: 14px;
    line-height: 14px;
  }
}

.btn-gradient:disabled,
.btn-gradient.disabled {
  pointer-events: none;
  opacity: 0.5;
  box-shadow: none;
}

/* The place for the chevron, out of the right padding; on hover the button widens by --grow, and gives
   the width back out of its margin. */
@media (hover: hover) {
  .btn-gradient[data-chevron] {
    padding-inline-end: calc(var(--pad) - var(--slot));
    transition:
      background-size 0.5s ease,
      background-position 0.5s ease,
      box-shadow 0.4s ease,
      opacity 0.3s ease,
      padding-inline-end var(--spring-out-time) var(--spring-out),
      margin-inline-end var(--spring-out-time) var(--spring-out);
  }

  .btn-gradient[data-chevron]:hover,
  .btn-gradient[data-chevron]:focus-visible {
    padding-inline-end: calc(var(--pad) - var(--slot) + var(--grow));
    margin-inline-end: calc(var(--grow) * -1);
    transition:
      background-size 0.5s ease,
      background-position 0.5s ease,
      box-shadow 0.4s ease,
      opacity 0.3s ease,
      padding-inline-end var(--spring-in-time) var(--spring-in),
      margin-inline-end var(--spring-in-time) var(--spring-in);
  }
}

.btn-gradient__chevron,
.btn-glyph {
  display: flex;
  margin-inline-start: -2px;
  opacity: 0;
  transform: translateX(-15px) scale(0);
  transition:
    transform 0.3s ease,
    opacity 0.3s ease;
}

.btn-glyph[data-kind="plus"] {
  transform: translateX(-15px) rotate(-90deg) scale(0);
}

@media (hover: none) {
  .btn-gradient__chevron,
  .btn-glyph {
    display: none;
  }
}

@media (hover: hover) {
  .btn-gradient:hover {
    background-size: 150% 100%;
    background-position: 100% 0;
    box-shadow:
      var(--cta-shadow-hover),
      inset 0 1px 0 rgb(255 255 255 / 0.32);
  }
}

.btn-gradient:hover .btn-gradient__chevron,
.btn-gradient:focus-visible .btn-gradient__chevron,
[data-glyph]:is(:hover, :focus-visible) .btn-glyph {
  opacity: 1;
  transform: none;
}

/* A plus is a door: pressed, or while what it opens is open, it turns to an x. Turned, a plus is smaller
   to the eye, so 1.15 makes the two weigh the same beside the label. */
[data-glyph="plus"]:is(:active, [aria-expanded="true"]) .btn-glyph {
  transform: rotate(45deg) scale(1.15);
}

.btn-gradient:active {
  box-shadow:
    var(--cta-shadow-press),
    inset 0 1px 3px rgb(0 3 64 / 0.28);
}

/* A glyph other than the chevron: the same place and the same growth. */
@media (hover: hover) {
  .btn-gradient[data-glyph] {
    padding-inline-end: calc(var(--pad) - var(--slot));
    transition:
      background-size 0.5s ease,
      background-position 0.5s ease,
      box-shadow 0.4s ease,
      opacity 0.3s ease,
      padding-inline-end var(--spring-out-time) var(--spring-out),
      margin-inline-end var(--spring-out-time) var(--spring-out);
  }

  .btn-gradient[data-glyph]:is(:hover, :focus-visible) {
    padding-inline-end: calc(var(--pad) - var(--slot) + var(--grow));
    margin-inline-end: calc(var(--grow) * -1);
    transition:
      background-size 0.5s ease,
      background-position 0.5s ease,
      box-shadow 0.4s ease,
      opacity 0.3s ease,
      padding-inline-end var(--spring-in-time) var(--spring-in),
      margin-inline-end var(--spring-in-time) var(--spring-in);
  }
}

@media (prefers-reduced-motion: reduce) {
  .btn-gradient,
  .btn-gradient[data-chevron],
  .btn-gradient[data-glyph],
  .btn-gradient[data-chevron]:is(:hover, :focus-visible),
  .btn-gradient[data-glyph]:is(:hover, :focus-visible),
  .btn-gradient__chevron,
  .btn-glyph {
    transition: none;
  }
}

/* A button that fills its row (a form's submit) does not widen: there is no room to grow into. */
.btn-gradient.btn-block {
  display: flex;
  width: 100%;
}

@media (width < 40rem) {
  .btn-gradient.btn-block-sm {
    display: flex;
    width: 100%;
  }
}

/* ===================================================================== the arrow pair */

/*
 * Previous and next as one pill: 36 high (40 under a coarse pointer), 4px in to the two buttons, which are
 * 34 x 28 with 4px between and a 16px chevron at the 1.6 stroke. The pill is the chip over the ground at 55%,
 * the disc that comes up behind the one the pointer is on is the chip itself, and pressed it goes to the
 * tint. Each button's touch area is grown by 4px all round, so the two halves of the pill are the two buttons.
 * At either end the arrow that has nowhere to go is faded to 40% and cannot be pressed. Nothing moves in any
 * state. Shown from 640px, where the sliders it steps are (below it they scroll by hand).
 */
.arrow-pair {
  --pair-ground: #00000d;
  --pair-chip: #121830;
  --pair-trail: #0d2352;
  --pair-ink: #eef1f8;
  display: none;
  float: right;
  box-sizing: border-box;
  height: 36px;
  align-items: center;
  gap: 4px;
  border-radius: 9999px;
  padding: 4px;
  background: color-mix(in oklab, var(--pair-chip) 55%, var(--pair-ground));
}

@media (min-width: 640px) {
  .arrow-pair {
    display: inline-flex;
  }
}

@media (pointer: coarse) {
  .arrow-pair {
    height: 40px;
  }
}

/* Nothing to step (every slide fits): the sliders lock both buttons, and the pill goes with them. */
.arrow-pair:has(.swiper-button-lock) {
  display: none;
}

.arrow-pair__btn {
  position: relative;
  display: grid;
  place-items: center;
  box-sizing: border-box;
  height: 28px;
  width: 34px;
  margin: 0;
  border: 0;
  border-radius: 9999px;
  padding: 0;
  background: transparent;
  color: var(--pair-ink);
  cursor: pointer;
  outline: 2px solid transparent;
  outline-offset: 1px;
  transition:
    background-color 0.3s var(--ease-house),
    opacity 0.3s var(--ease-house),
    outline-color 0.3s var(--ease-house);
  -webkit-tap-highlight-color: transparent;
}

@media (pointer: coarse) {
  .arrow-pair__btn {
    height: 32px;
  }
}

.arrow-pair__btn::before {
  content: "";
  position: absolute;
  inset: -4px;
}

.arrow-pair__btn:focus-visible {
  outline-color: #0063ff;
}

@media (hover: hover) {
  .arrow-pair__btn:hover {
    background: var(--pair-chip);
  }
}

.arrow-pair__btn:active {
  background: var(--pair-trail);
}

.arrow-pair__btn:disabled,
.arrow-pair__btn.swiper-button-disabled {
  pointer-events: none;
  opacity: 0.4;
}

.arrow-pair__btn svg {
  display: block;
}

@media (prefers-reduced-motion: reduce) {
  .arrow-pair__btn {
    transition: none;
  }
}

/* Beside the heading it follows (the sliders' headings are 28px high from 640px and 32px from 768px), centered on it:
   the pill floats after the heading, so it is lifted by the heading's half height and its own. */
@media (min-width: 640px) {
  .arrow-pair {
    margin-top: -32px;
  }
}

@media (min-width: 768px) {
  .arrow-pair {
    margin-top: -34px;
  }
}

/* ============================================================ on a light ground */

/* The Get started pages put the button on white. A glow in the brand blue on a white page reads as a violet smudge,
   so there it is the light day mode's: a tight contact shadow with a faint azure light, and the brand blue ring. */
.btn-gradient.btn-light {
  --cta-shadow: 0 1px 3px rgb(0 100 255 / 0.3), 0 0 10px rgb(0 150 255 / 0.18);
  --cta-shadow-hover: 0 2px 6px rgb(0 100 255 / 0.3), 0 0 18px rgb(0 150 255 / 0.28);
  --cta-shadow-press: 0 0 3px rgb(0 100 255 / 0.3), 0 0 6px rgb(0 150 255 / 0.18);
}

.btn-gradient.btn-light:focus-visible {
  outline-color: #0063ff;
}

/* ============================================================ lightbox: open and close */

/*
 * The icons are Hugeicons (the Staging Website's family) at its 1.6 stroke, in the Staging Website's dark values.
 *
 * Close (IconButton variant "tinted", size md): a 40px circle in the tint (--state-trail, #0d2352) with the X in
 * --icon-tinted-ink (#7fb2ff); pointed at, the ground deepens toward the brand blue and the X goes to
 * --icon-tinted-ink-hover (#eaf2ff). 300ms on the house curve, no movement. The button keeps the position and the
 * sticking the lightbox gave it (.modal__close).
 */
.modal__close.ui-close {
  display: grid;
  place-items: center;
  box-sizing: border-box;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 9999px;
  background: #0d2352;
  color: #7fb2ff;
  cursor: pointer;
  outline: 2px solid transparent;
  outline-offset: 2px;
  transition:
    background-color 0.3s var(--ease-house),
    color 0.3s var(--ease-house),
    outline-color 0.3s var(--ease-house);
}

/* The ring is for the keyboard: the lightbox puts focus on this button when it opens, which Chrome counts as focus-visible
   after a mouse click too (ui.js sets data-input="keyboard" on <html> after a Tab). */
html[data-input="keyboard"] .modal__close.ui-close:focus-visible {
  outline-color: #0063ff;
}

@media (hover: hover) {
  .modal__close.ui-close:hover {
    background: color-mix(in oklab, #0d2352 88%, #0063ff);
    color: #eaf2ff;
  }
}

.modal__close.ui-close svg {
  display: block;
}

/*
 * Open (the Staging Website's card chip, ExpandAffordance, with a plus): a 38px circle in the corner of the card, two layers
 * that cross-fade, the tint (#e8edfd) at rest and the brand blue (#0063ff) when the card is pointed at, the plus going from
 * brand to white with them (0.6s), and the whole chip nudging 4.83px right and 4px down toward its corner (0.8s). Driven by the
 * card's hover, and by keyboard focus on the card's link. No hover (a phone): it stays at rest.
 */
.card-open {
  position: absolute;
  z-index: 10;
  right: 20px;
  bottom: 20px;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 9999px;
  color: #0063ff;
  transition:
    transform 0.8s cubic-bezier(0.165, 0.84, 0.44, 1),
    color 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.card-open::before,
.card-open::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Lower layer: the brand fill, revealed on hover. Upper layer: the tint, faded out on hover. */
.card-open::before {
  background: #0063ff;
  opacity: 0;
}

.card-open::after {
  background: #e8edfd;
  opacity: 1;
}

.card-open svg {
  position: relative;
  z-index: 1;
  display: block;
}

@media (hover: hover) {
  .swiper-slide:hover .card-open,
  a:focus-visible .card-open {
    color: #fff;
    transform: translate(4.83px, 4px);
    will-change: transform;
  }

  .swiper-slide:hover .card-open::before,
  a:focus-visible .card-open::before {
    opacity: 1;
  }

  .swiper-slide:hover .card-open::after,
  a:focus-visible .card-open::after {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .modal__close.ui-close,
  .card-open,
  .card-open::before,
  .card-open::after {
    transition: none;
  }
}

/* ======================================================================= pictures */

/* The homepage's page ground (a near-black gradient with soft blue glows, 1560x3055) as lossless WebP: the same pixels in 310KB
   instead of 496KB. Lossy is not used on it: a gradient this dark bands. */
.dark #fold {
  background-image: url("/x/img/bg.webp");
}
