/* The Start a return button that prints the shipping label. The graphite pill is a real <button>; above it sits the
   slot of the printer (closed at rest) and, above that, the feed: a box whose bottom edge is the slot, clipped right
   there, so the paper hidden below it only shows as it comes out. Every size on the label is in cqw (a share of the
   label's width), so the script only has to choose that width and the whole label scales with it. */
:root {
  --page: #ffffff;          /* the page */
  --graphite: #18191c;      /* the pill */
  --graphite-top: #2c2e33;  /* the light on top of the pill */
  --ink-on: #f3f2ee;        /* the words on the pill */
  --muted-on: #9a9ca3;      /* the small words on the pill */
  --accent: #ff6a2b;        /* the print head, the tick */
  --paper: #fbfaf6;         /* the thermal paper */
  --paper-edge: #e9e6de;    /* the edge of the paper */
  --print: #1c1b19;         /* the thermal print */
  --muted: #7b7a76;         /* the refund line */
  --lw: 212px;              /* the label's width (set by the script) */
}

* {
  box-sizing: border-box;
  margin: 0;
}

html {
  touch-action: manipulation;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  background: var(--page);
  color: var(--print);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

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

.stage {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 12px;
  overflow: hidden;
}

/* the whole piece: the feed above, the pill, the refund line */
.ret {
  --pw: min(252px, 78vw);
  position: relative;
  width: var(--pw);
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ---------------------------------------------------------------- the feed and the label */
.feed {
  position: relative;
  width: 100%;
  height: var(--fh, 260px);
  /* clipped only at the bottom, where the slot is */
  clip-path: inset(-400px -400px 0 -400px);
}

.feed.is-free {
  clip-path: none;
}

.label {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: var(--lw);
  margin-left: calc(var(--lw) / -2);
  container-type: inline-size;
  will-change: transform;
}

/* the soft shadow the label casts once it lies down */
.feed__shadow {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: var(--lw);
  height: var(--lh, 230px);
  margin-left: calc(var(--lw) / -2);
  border-radius: 6px;
  background: rgba(30, 26, 20, 0.5);
  filter: blur(14px);
  opacity: 0;
  pointer-events: none;
}

.paper {
  position: relative;
  padding: 6cqw 6.5cqw 5cqw;
  border-radius: 1.6cqw;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0) 30%),
    linear-gradient(90deg, rgba(0, 0, 0, 0.025), rgba(0, 0, 0, 0) 12%, rgba(0, 0, 0, 0) 88%, rgba(0, 0, 0, 0.03)),
    var(--paper);
  color: var(--print);
  box-shadow:
    inset 0 0 0 1px var(--paper-edge),
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 1px 1px rgba(30, 26, 20, 0.06),
    0 4px 10px -4px rgba(30, 26, 20, 0.14),
    0 18px 30px -18px rgba(30, 26, 20, 0.28);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.paper__grain {
  position: absolute;
  inset: 0;
  opacity: 0.2;
  mix-blend-mode: multiply;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.95' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0.33 0.33 0.33 0 0.2 0.33 0.33 0.33 0 0.2 0.33 0.33 0.33 0 0.2 0 0 0 0 1'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* the shade that comes on as the paper curls back a little */
.paper__curl {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(40, 32, 20, 0.16), rgba(40, 32, 20, 0.04) 30%, rgba(255, 255, 255, 0) 55%, rgba(255, 255, 255, 0.35) 100%);
}

.row {
  position: relative;
  display: flex;
  flex-direction: column;
}

.row--head {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 3cqw;
}

.lab__brand {
  font-size: 5.6cqw;
  white-space: nowrap;
  font-weight: 760;
  font-stretch: 118%;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  line-height: 1;
}

.lab__tag {
  font-size: 3.6cqw;
  font-weight: 700;
  font-stretch: 112%;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  line-height: 1;
  color: var(--paper);
  background: var(--print);
  padding: 1.3cqw 2cqw 1.2cqw;
  border-radius: 0.8cqw;
}

.rule {
  display: block;
  height: 1px;
  margin: 3cqw 0;
  background: var(--print);
  opacity: 0.85;
}

.rule--thick {
  height: 2px;
  margin-top: 0;
  opacity: 1;
}

.rule--dash {
  background: repeating-linear-gradient(90deg, var(--print) 0 2.4cqw, transparent 2.4cqw 4cqw);
  opacity: 0.6;
}

.lab__small {
  font-size: 3.2cqw;
  font-weight: 640;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.62;
  line-height: 1.2;
  margin-bottom: 0.8cqw;
}

.lab__addr {
  font-size: 5cqw;
  font-weight: 520;
  line-height: 1.3;
  white-space: nowrap;
}

.lab__addr--name {
  font-weight: 700;
}

.row--mid {
  flex-direction: row;
  align-items: center;
  gap: 5cqw;
}

.qr {
  flex: none;
  width: 25cqw;
  height: 25cqw;
  fill: var(--print);
}

.mid {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.lab__rma {
  font-size: 6.4cqw;
  font-weight: 760;
  font-stretch: 108%;
  letter-spacing: 0.01em;
  line-height: 1.1;
  margin-bottom: 1.4cqw;
  white-space: nowrap;
}

.lab__line {
  font-size: 3.7cqw;
  font-weight: 500;
  line-height: 1.35;
  white-space: nowrap;
  opacity: 0.86;
}

.bars {
  display: block;
  width: 100%;
  height: 15cqw;
  fill: var(--print);
}

.row--digits {
  align-items: center;
  padding-top: 1.6cqw;
}

.lab__digits {
  font-size: 3.6cqw;
  font-weight: 560;
  letter-spacing: 0.32em;
  margin-right: -0.32em;
  line-height: 1;
}

/* ---------------------------------------------------------------- the slot of the printer */
.slot {
  position: absolute;
  left: 50%;
  top: var(--fh, 260px);
  width: calc(var(--lw) + 12px);
  height: 7px;
  margin: -3px 0 0 calc((var(--lw) + 12px) / -2);
  border-radius: 4px;
  background: linear-gradient(180deg, #050506, #0d0e10 60%, #26282c);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.16),
    inset 0 1px 2px rgba(0, 0, 0, 0.9);
  transform: scaleX(0);
  z-index: 3;
  pointer-events: none;
}

/* the hot line of the print head inside the slot */
.slot__head {
  position: absolute;
  left: 6px;
  right: 6px;
  top: 2px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
  box-shadow: 0 0 6px 1px color-mix(in srgb, var(--accent) 70%, transparent);
  opacity: 0;
}

/* the warm haze the head leaves on the paper right above the slot */
.warm {
  position: absolute;
  left: 50%;
  top: calc(var(--fh, 260px) - 18px);
  width: var(--lw);
  height: 18px;
  margin-left: calc(var(--lw) / -2);
  background: linear-gradient(0deg, color-mix(in srgb, var(--accent) 22%, transparent), transparent);
  mix-blend-mode: multiply;
  opacity: 0;
  z-index: 2;
  pointer-events: none;
}

/* ---------------------------------------------------------------- the pill */
.pill {
  position: relative;
  width: 100%;
  height: 60px;
  padding: 0;
  border: 0;
  border-radius: 30px;
  overflow: hidden;
  font: inherit;
  color: var(--ink-on);
  cursor: pointer;
  background: radial-gradient(120% 100% at 50% 0%, var(--graphite-top) 0%, var(--graphite) 60%, #101113 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.13),
    inset 0 -1px 0 rgba(0, 0, 0, 0.5),
    0 1px 1px rgba(14, 15, 17, 0.18),
    0 4px 8px -2px rgba(14, 15, 17, 0.18),
    0 14px 28px -12px rgba(14, 15, 17, 0.38),
    0 30px 60px -30px rgba(14, 15, 17, 0.35);
  isolation: isolate;
  will-change: transform;
  z-index: 1;
}

.pill:focus-visible {
  outline: 2px solid var(--graphite);
  outline-offset: 4px;
}

.pill__skin,
.pill__grain,
.pill__edge {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
}

.pill__grain {
  opacity: 0.22;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0.33 0.33 0.33 0 0 0.33 0.33 0.33 0 0 0.33 0.33 0.33 0 0 0 0 0 0 1'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.pill__edge {
  padding: 1px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0.04) 40%, rgba(255, 255, 255, 0) 70%, rgba(255, 255, 255, 0.06));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
}

.face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  white-space: nowrap;
  pointer-events: none;
}

.rest__icon {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  overflow: visible;
}

.rest__seam {
  opacity: 0.55;
}

.rest__back {
  stroke: var(--accent);
}

.rest__words {
  font-size: 16px;
  font-weight: 580;
  font-variation-settings: 'wdth' 100;
  letter-spacing: 0.005em;
}

.busy {
  visibility: hidden;
  gap: 12px;
}

.busy__words {
  font-size: 15px;
  font-weight: 540;
  color: var(--ink-on);
}

.busy__pct {
  display: inline-block;
  min-width: 3.2ch;
  font-size: 13px;
  font-weight: 560;
  text-align: right;
  color: var(--accent);
}

.done {
  visibility: hidden;
  gap: 11px;
}

.done__tick {
  flex: none;
  width: 26px;
  height: 26px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  overflow: visible;
}

.done__tick circle,
.done__tick path {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

.done__tick circle {
  opacity: 0.45;
}

.done__text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.15;
}

.done__top {
  font-size: 15px;
  font-weight: 640;
}

.done__sub {
  font-size: 12.5px;
  font-weight: 480;
  color: var(--muted-on);
}

/* ---------------------------------------------------------------- the refund line */
.refund {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 20px;
  margin-top: 12px;
  font-size: 13px;
  font-weight: 480;
  color: var(--muted);
  white-space: nowrap;
  opacity: 0;
}

.refund__icon {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.refund__sum {
  font-weight: 650;
  color: var(--print);
}

@media (hover: hover) {
  .pill:hover {
    background: radial-gradient(120% 100% at 50% 0%, #34363c 0%, var(--graphite) 62%, #101113 100%);
  }
}
