/* The e-ink button: a Sync library button drawn as a piece of electronic paper in a graphite bezel, on a white page.
   The screen is a canvas at one pixel per CSS pixel, scaled up without smoothing, so its pixels show up close. */
:root {
  --page: #ffffff;          /* the page */
  --e-paper: #dedbd0;       /* the electronic paper, all white */
  --e-ink: #262522;         /* the electronic paper, all black */
  --bezel: #2c2c2a;         /* the bezel round the screen */
  --ring: #1d1d1b;          /* the ring of the focus */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

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

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ring);
  font-family: 'Literata Variable', Georgia, serif;
  -webkit-font-smoothing: antialiased;
}

p {
  margin: 0;
}

.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: 32px 16px;
}

.eink {
  position: relative;
}

/* ---------------------------------------------------------------- the button: a bezel with the screen in it */
.eink__btn {
  position: relative;
  display: block;
  width: 340px;
  height: 120px;
  padding: 0;
  border: 0;
  border-radius: 18px;
  background: transparent;
  cursor: pointer;
  transition: transform 0.25s cubic-bezier(0.3, 1.4, 0.5, 1);
  -webkit-tap-highlight-color: transparent;
}

.eink__bezel {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0) 30%, rgba(0, 0, 0, 0) 70%, rgba(0, 0, 0, 0.25)),
    var(--bezel);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    inset 0 -1px 0 rgba(0, 0, 0, 0.5),
    0 1px 2px rgba(0, 0, 0, 0.25),
    0 12px 22px -10px rgba(0, 0, 0, 0.45),
    0 30px 46px -26px rgba(0, 0, 0, 0.5);
  transition: box-shadow 0.25s;
}

/* the screen sits a little under the bezel, with its edge in shadow */
.eink__screen {
  position: absolute;
  left: 14px;
  top: 14px;
  width: 312px;
  height: 92px;
  overflow: hidden;
  border-radius: 3px;
  background: var(--e-paper);
}

.eink__canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* the matte film over the paper and the shadow the bezel casts on it */
.eink__glass {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0) 40%);
  box-shadow:
    inset 0 2px 3px rgba(0, 0, 0, 0.32),
    inset 0 0 0 1px rgba(0, 0, 0, 0.35),
    inset 0 -1px 1px rgba(255, 255, 255, 0.12);
  pointer-events: none;
}

/* hover, press and focus: the bezel is the only thing that moves; e-ink itself cannot glow */
@media (hover: hover) and (pointer: fine) {
  .eink__btn:hover {
    transform: translateY(-2px);
  }

  .eink__btn:hover .eink__bezel {
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.22),
      inset 0 -1px 0 rgba(0, 0, 0, 0.5),
      0 1px 2px rgba(0, 0, 0, 0.25),
      0 16px 26px -10px rgba(0, 0, 0, 0.45),
      0 38px 54px -26px rgba(0, 0, 0, 0.5);
  }
}

.eink__btn[data-press] {
  transform: translateY(1px) scale(0.99);
  transition-duration: 0.08s;
}

.eink__btn[data-press] .eink__bezel {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    inset 0 -1px 0 rgba(0, 0, 0, 0.5),
    0 1px 1px rgba(0, 0, 0, 0.3),
    0 6px 12px -8px rgba(0, 0, 0, 0.45);
}

.eink__btn:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 5px;
}

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

@media (max-width: 380px) {
  .eink__btn {
    transform-origin: 50% 50%;
    scale: 0.94;
  }
}

@media (prefers-reduced-motion: reduce) {
  .eink__btn,
  .eink__bezel {
    transition: none;
  }

  @media (hover: hover) {
    .eink__btn:hover {
      transform: none;
    }
  }
}
