/* The shop sign button: a pill painted like the door of a small shop, bottle green with gilded words, on a white
   page. The sign, its twine, its nail and its shadow on the door are drawn by script.js on a canvas (their colours
   come from here); the pill, the words and the states are CSS. */
:root {
  --page: #ffffff;          /* the page */
  --door: #1d4a3a;          /* the pill, the painted door, open, at its top */
  --door-deep: #0f2c22;     /* the door at its foot */
  --door-shut: #1b2622;     /* the door once the shop is closed: the lights are off */
  --door-shut-deep: #0e1513;    /* the closed door at its foot */
  --gilt: #ead8a4;          /* the gilded words */
  --gilt-shut: #a9b1a9;     /* the words once the shop is closed */
  --enamel: #f6eedb;        /* the sign, cream enamel */
  --enamel-edge: #d9ccad;   /* the sign at its rim, and its thickness */
  --open: #1f6a49;          /* OPEN, and its border */
  --closed: #b5322a;        /* CLOSED, and its border */
  --twine: #c9b48a;         /* the twine */
  --brass: #d3a95a;         /* the nail and the eyelets */
  --focus: #1d4a3a;         /* the ring of the keyboard's focus */
}

* {
  box-sizing: border-box;
}

/* a tap is a click at once: no wait for a double tap */
html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--door);
  font-family: 'Mona Sans Variable', 'Mona Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.stage {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 72px 16px;
}

.shop {
  display: grid;
  justify-items: center;
}

/* ---------------------------------------------------------------- the pill */
.shop__btn {
  position: relative;
  display: block;
  /* the script sets the width from the longest words; this is the width before it does */
  width: 262px;
  max-width: calc(100vw - 32px);
  height: 60px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--gilt);
  font: inherit;
  cursor: pointer;
  isolation: isolate;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.shop__btn[aria-disabled='true'] {
  cursor: progress;
}

/* the fill is a layer of its own, so it can swell past the pill with a bounce without moving anything; the closed
   door is a second coat over it that fades in */
.shop__fill {
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background:
    radial-gradient(80% 130% at 22% 0%, rgba(255, 246, 220, 0.09), transparent 60%),
    linear-gradient(180deg, var(--door), var(--door-deep));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    inset 0 -1px 0 rgba(0, 0, 0, 0.4),
    0 1px 2px rgba(10, 30, 22, 0.22),
    0 14px 28px -14px rgba(10, 30, 22, 0.62);
  transition:
    inset 0.6s cubic-bezier(0.34, 1.9, 0.45, 1),
    box-shadow 0.4s ease;
}

.shop__fill::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    radial-gradient(80% 130% at 22% 0%, rgba(255, 255, 255, 0.05), transparent 60%),
    linear-gradient(180deg, var(--door-shut), var(--door-shut-deep));
  opacity: var(--shut, 0);
}

/* a thin gilded line inside the rim, like the bead of a painted door panel */
.shop__fill::before {
  content: '';
  position: absolute;
  inset: 4px;
  z-index: 1;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(234, 216, 164, 0.16);
}

.shop__btn:focus-visible {
  outline: 2.5px solid var(--focus);
  outline-offset: 5px;
}

html[data-using='pointer'] .shop__btn:focus-visible {
  outline: none;
}

/* the sign hangs in the round left end of the pill; the canvas is a little larger than its corner of the door */
.shop__sign {
  position: absolute;
  left: 0;
  top: 0;
  width: 96px;
  height: 60px;
  pointer-events: none;
}

/* ---------------------------------------------------------------- the words */
.shop__words {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 92px;
  right: 18px;
  display: flex;
  align-items: center;
  pointer-events: none;
}

.shop__word {
  display: block;
  padding-bottom: 1px;
  font-size: 17px;
  font-weight: 620;
  font-stretch: 100%;
  letter-spacing: -0.006em;
  line-height: 1;
  white-space: nowrap;
  color: var(--gilt);
  transition:
    font-stretch 0.6s cubic-bezier(0.34, 1.9, 0.45, 1),
    font-weight 0.6s cubic-bezier(0.34, 1.9, 0.45, 1),
    color 0.8s ease;
}

.shop[data-shut] .shop__word {
  color: var(--gilt-shut);
}

/* ---------------------------------------------------------------- under the pointer */
@media (hover: hover) and (pointer: fine) {
  .shop__btn:not([aria-disabled='true']):hover .shop__fill {
    inset: -2px -7px;
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.12),
      inset 0 -1px 0 rgba(0, 0, 0, 0.4),
      0 1px 2px rgba(10, 30, 22, 0.22),
      0 18px 32px -14px rgba(10, 30, 22, 0.68);
  }

  .shop__btn:not([aria-disabled='true']):hover .shop__word {
    font-stretch: 116%;
    font-weight: 680;
  }
}

/* the keys bring the focus: the words widen as under the pointer */
html[data-using='keys'] .shop__btn:focus-visible .shop__word {
  font-stretch: 116%;
  font-weight: 680;
}

/* ---------------------------------------------------------------- reduced motion: no swelling, no widening */
@media (prefers-reduced-motion: reduce) {
  .shop__fill,
  .shop__word {
    transition: box-shadow 0.3s ease, filter 0.3s ease, color 0.6s ease;
  }

  html[data-using='keys'] .shop__btn:focus-visible .shop__word {
    font-stretch: 100%;
    font-weight: 620;
  }
}

@media (prefers-reduced-motion: reduce) and (hover: hover) and (pointer: fine) {
  .shop__btn:not([aria-disabled='true']):hover .shop__fill {
    inset: 0;
    filter: brightness(1.18);
  }

  .shop__btn:not([aria-disabled='true']):hover .shop__word {
    font-stretch: 100%;
    font-weight: 620;
  }
}
