/* The marbled button: a board covered in marbled paper, with a paper label pasted in the middle. The inks are drawn
   on a canvas (their colours are the palettes in script.js); the bath they float on, the label and the board come
   from here. */
:root {
  --page: #ffffff;          /* the page */
  --bath: #efe5d0;          /* the bath the inks float on: it shows in the pale veins between them */
  --label: #fbf7ee;         /* the paper of the label */
  --label-ink: #2b1f17;     /* the words, the icon and the double rule printed on the label */
  --edge: #241812;          /* the edge of the board */
  --focus: #1d3557;         /* 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(--label-ink);
  font-family: 'EB Garamond Variable', Garamond, Georgia, 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;
}

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

/* ---------------------------------------------------------------- the board */
.marble__btn {
  position: relative;
  display: grid;
  place-items: center;
  width: min(320px, calc(100vw - 48px));
  height: 60px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: var(--bath);
  /* the board: a dark edge underneath, as thick as a book's cover, and its shadow on the page */
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--edge) 55%, transparent),
    0 2px 0 var(--edge),
    0 3px 2px color-mix(in srgb, var(--edge) 30%, transparent),
    0 18px 30px -18px color-mix(in srgb, var(--edge) 70%, transparent);
  color: var(--label-ink);
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  /* a finger dragged across combs the inks; up and down it still scrolls the page */
  touch-action: pan-y;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 160ms cubic-bezier(0.23, 1, 0.32, 1), box-shadow 160ms cubic-bezier(0.23, 1, 0.32, 1);
}

.marble__btn:active {
  transform: scale(0.97);
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--edge) 55%, transparent),
    0 1px 0 var(--edge),
    0 2px 1px color-mix(in srgb, var(--edge) 30%, transparent),
    0 10px 20px -16px color-mix(in srgb, var(--edge) 70%, transparent);
}

.marble__btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 6px;
}

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

/* the marbled sheet, and its copy that fades away when the motion is reduced */
.marble__sheet {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  pointer-events: none;
}

.marble__ghost {
  opacity: 0;
}

/* the paper is burnished: a soft gloss where the light meets the pointer */
.marble__sheen {
  position: absolute;
  left: 0;
  top: 0;
  width: 160px;
  height: 160px;
  margin: -80px 0 0 -80px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0.16) 55%, rgba(255, 255, 255, 0));
  mix-blend-mode: soft-light;
  opacity: 0;
  pointer-events: none;
}

/* ---------------------------------------------------------------- the label */
.marble__label {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 14px 1px;
  border-radius: 2px;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.35 0 0 0 0 0.27 0 0 0 0 0.17 0 0 0 0.09 0'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23g)'/%3E%3C/svg%3E"),
    var(--label);
  /* a double rule printed just inside the edge, and the label's own edge, a little raised where it is pasted */
  box-shadow:
    inset 0 0 0 3px var(--label),
    inset 0 0 0 3.8px color-mix(in srgb, var(--label-ink) 80%, transparent),
    inset 0 0 0 5.4px var(--label),
    inset 0 0 0 5.9px color-mix(in srgb, var(--label-ink) 55%, transparent),
    0 0.5px 0 color-mix(in srgb, var(--edge) 40%, transparent),
    0 1px 2px color-mix(in srgb, var(--edge) 35%, transparent);
  font-size: 17px;
  font-weight: 540;
  line-height: 1;
  letter-spacing: 0.005em;
  white-space: nowrap;
  pointer-events: none;
  transition: box-shadow 160ms cubic-bezier(0.23, 1, 0.32, 1);
}

.marble__btn:active .marble__label {
  box-shadow:
    inset 0 0 0 3px var(--label),
    inset 0 0 0 3.8px color-mix(in srgb, var(--label-ink) 80%, transparent),
    inset 0 0 0 5.4px var(--label),
    inset 0 0 0 5.9px color-mix(in srgb, var(--label-ink) 55%, transparent),
    0 0 0 color-mix(in srgb, var(--edge) 40%, transparent),
    0 0.5px 1px color-mix(in srgb, var(--edge) 35%, transparent);
}

.marble__words {
  display: block;
  text-align: center;
}

/* the shuffle arrows, and the tick that takes their place when the new palette is in */
.marble__icons {
  position: relative;
  display: block;
  width: 16px;
  height: 16px;
  flex: none;
}

.marble__icon {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  overflow: visible;
}

.marble__icon--done {
  opacity: 0;
}

@media (max-width: 380px) {
  .marble__label {
    padding: 0 12px 1px;
    gap: 7px;
    font-size: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .marble__btn,
  .marble__btn:active {
    transform: none;
  }

  .marble__btn:active {
    filter: brightness(0.97);
  }
}
