/* Calden Pharmacy: a click and collect order that turns into the pickup ticket. The card and the stub live in one
   .wrap, which is the container: every size inside is in em, and 1em follows the width of the card (cqw), so the
   whole piece scales as one. The card's paper is its own layer, so the notches and the torn teeth can cut it. */
:root {
  --page: #edf1ea;          /* the page, a very light sage */
  --glow: #f8f7f1;          /* the warm light in the middle */
  --paper: #fffefb;         /* the card and the ticket */
  --ink: #1c2822;           /* the words */
  --muted: #6c786f;         /* the small words */
  --line: rgba(28, 40, 34, 0.085); /* thin rules */
  --tile: #eff2ec;          /* the tiles of the packs */
  --accent: #2e6a54;        /* the one accent: sage green */
  --accent-ink: #f3f7f2;    /* the words on the button */
  --pack: #f6f6f1;          /* the packs */
  --pack-dark: #dfe3dc;     /* their shaded sides */
  --glass: #d9e2da;         /* the bottle */
  --steel: #c3c8ca;         /* the staple */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

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

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

.stage {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2vh 12px;
  overflow: hidden;
  background:
    radial-gradient(60% 52% at 50% 46%, var(--glow) 0%, rgba(248, 247, 241, 0) 100%),
    var(--page);
}

/* a soft grain over the page, so the light never bands */
.stage::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.32;
  mix-blend-mode: multiply;
  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='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .4 0 0 0 0 .42 0 0 0 0 .38 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

.wrap {
  position: relative;
  z-index: 1;
  width: min(86vw, 64vh, max(56vh, 350px), 600px);
  container-type: inline-size;
  opacity: 0;
  filter:
    drop-shadow(0 1px 1px rgba(28, 40, 34, 0.07))
    drop-shadow(0 6px 10px rgba(28, 40, 34, 0.06))
    drop-shadow(0 22px 34px rgba(46, 80, 62, 0.1));
}

/* ---------------------------------------------------------------- the card */
.card {
  position: relative;
  z-index: 2;
  height: 20em;
  font-size: 4.45cqw;
  --notch: 0em;
  --tooth: 0em;
}

.card__paper {
  position: absolute;
  inset: 0 0 var(--tooth) 0;
  border-radius: 1.15em;
  background: linear-gradient(180deg, #ffffff 0%, var(--paper) 60%, #fcfbf6 100%);
  box-shadow: inset 0 0 0 1px rgba(28, 40, 34, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  -webkit-mask:
    radial-gradient(circle at 0 100%, transparent var(--notch), #000 calc(var(--notch) + 0.6px)) left / 51% 100% no-repeat,
    radial-gradient(circle at 100% 100%, transparent var(--notch), #000 calc(var(--notch) + 0.6px)) right / 51% 100% no-repeat;
  mask:
    radial-gradient(circle at 0 100%, transparent var(--notch), #000 calc(var(--notch) + 0.6px)) left / 51% 100% no-repeat,
    radial-gradient(circle at 100% 100%, transparent var(--notch), #000 calc(var(--notch) + 0.6px)) right / 51% 100% no-repeat;
}

/* the torn teeth along the bottom of the card, pointing down */
.card__teeth,
.stub__teeth {
  position: absolute;
  left: calc(var(--notch) + 0.1em);
  right: calc(var(--notch) + 0.1em);
  height: var(--tooth);
  pointer-events: none;
  background-size: 0.5em 100%;
  background-repeat: repeat-x;
}

.card__teeth {
  bottom: 0;
  background-image: conic-gradient(from -45deg at 50% 100%, #fcfbf6 90deg, transparent 0);
}

/* a soft band of light that crosses the ticket once it is ready */
.card__sheen {
  position: absolute;
  inset: 0;
  border-radius: 1.15em;
  overflow: hidden;
  pointer-events: none;
}

.card__sheen::before {
  content: '';
  position: absolute;
  top: -20%;
  bottom: -20%;
  left: 0;
  width: 40%;
  transform: translateX(var(--sx, -120%)) skewX(-16deg);
  background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.75), rgba(255, 255, 255, 0));
  mix-blend-mode: soft-light;
}

/* the light that follows the pointer on the ticket */
.card__sheen::after {
  content: '';
  position: absolute;
  inset: 0;
  opacity: var(--glint, 0);
  background: radial-gradient(42% 34% at var(--gx, 50%) var(--gy, 30%), rgba(46, 106, 84, 0.07), rgba(46, 106, 84, 0));
  transition: opacity 0.4s ease;
}

.page {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 1.25em 1.3em 1.3em;
}

/* ---------------------------------------------------------------- page one: the order */
.head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6em;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  min-width: 0;
}

.brand__mark {
  width: 1.45em;
  height: 1.45em;
  flex: none;
}

.brand__mark rect {
  fill: var(--accent);
}

.brand__mark path {
  stroke: var(--accent-ink);
  stroke-width: 2.6;
  stroke-linecap: round;
  fill: none;
}

.brand__mark circle {
  fill: var(--accent-ink);
}

.brand__name {
  font-size: 0.86em;
  font-weight: 620;
  font-variation-settings: 'wdth' 92;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.chip {
  flex: none;
  font-size: 0.66em;
  font-weight: 560;
  letter-spacing: 0.01em;
  color: var(--accent);
  padding: 0.38em 0.75em 0.4em;
  border-radius: 99px;
  background: rgba(46, 106, 84, 0.08);
  box-shadow: inset 0 0 0 1px rgba(46, 106, 84, 0.14);
  white-space: nowrap;
}

.title {
  margin-top: 1.05em;
}

.title h1 {
  margin: 0;
  font-size: 1.5em;
  line-height: 1.05;
  font-weight: 640;
  font-variation-settings: 'wdth' 108;
  letter-spacing: -0.025em;
}

.title p {
  margin: 0.3em 0 0;
  font-size: 0.76em;
  color: var(--muted);
}

.items {
  list-style: none;
  margin: 0.9em 0 0;
  padding: 0;
}

.item {
  display: flex;
  align-items: center;
  gap: 0.75em;
  padding: 0.5em 0;
  border-top: 1px solid var(--line);
}

.item:last-child {
  border-bottom: 1px solid var(--line);
}

.item__tile {
  position: relative;
  flex: none;
  width: 2.5em;
  height: 2.5em;
  display: grid;
  place-items: center;
}

.item__bg {
  position: absolute;
  inset: 0;
  border-radius: 0.72em;
  background: linear-gradient(160deg, #f4f6f1, var(--tile));
  box-shadow: inset 0 0 0 1px rgba(28, 40, 34, 0.05), inset 0 1px 0 #fff;
}

.item__fly {
  position: relative;
  z-index: 2;
  display: block;
  width: 2.15em;
  height: 2.15em;
}

.item__icon {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

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

.item__name {
  font-size: 0.84em;
  font-weight: 580;
  letter-spacing: -0.008em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item__meta {
  font-size: 0.68em;
  color: var(--muted);
  margin-top: 0.12em;
}

.item__price {
  font-size: 0.82em;
  font-weight: 560;
  font-variant-numeric: tabular-nums;
}

/* the packs, drawn in SVG: a carton, a dropper bottle, a tube */
.p-shadow {
  stroke: rgba(28, 40, 34, 0.12);
  stroke-width: 2.2;
  stroke-linecap: round;
  fill: none;
}

.p-face,
.p-tube {
  fill: var(--pack);
  stroke: rgba(28, 40, 34, 0.32);
  stroke-width: 0.9;
}

.p-side {
  fill: var(--pack-dark);
  stroke: rgba(28, 40, 34, 0.32);
  stroke-width: 0.9;
  stroke-linejoin: round;
}

.p-top {
  fill: #fbfbf7;
  stroke: rgba(28, 40, 34, 0.32);
  stroke-width: 0.9;
  stroke-linejoin: round;
}

.p-band {
  fill: var(--accent);
}

.p-dot {
  fill: var(--accent);
  opacity: 0.85;
}

.p-print {
  stroke: rgba(28, 40, 34, 0.38);
  stroke-width: 1;
  stroke-linecap: round;
  fill: none;
}

.p-glass {
  fill: var(--glass);
  stroke: rgba(28, 40, 34, 0.32);
  stroke-width: 0.9;
}

.p-label {
  fill: var(--pack);
}

.p-glint {
  stroke: rgba(255, 255, 255, 0.95);
  stroke-width: 1.2;
  stroke-linecap: round;
  fill: none;
}

.p-bulb {
  fill: #33403a;
}

.p-cap {
  fill: #e9ece7;
  stroke: rgba(28, 40, 34, 0.32);
  stroke-width: 0.9;
}

.p-crimp {
  stroke: rgba(28, 40, 34, 0.22);
  stroke-width: 0.7;
  fill: none;
}

.total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 0.85em;
  font-size: 0.8em;
  color: var(--muted);
}

.total strong {
  font-size: 1.32em;
  font-weight: 640;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

/* the button: a pill in the accent, with a soft light on top and a sheen when it is hovered */
.btn {
  display: block;
  width: 100%;
  margin-top: 0.9em;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.btn__face {
  position: relative;
  display: grid;
  place-items: center;
  height: 2.9em;
  border-radius: 99px;
  overflow: hidden;
  color: var(--accent-ink);
  background: linear-gradient(180deg, #3a7a62 0%, var(--accent) 55%, #285e4a 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    inset 0 -1px 0 rgba(0, 0, 0, 0.12),
    0 1px 2px rgba(28, 60, 46, 0.25),
    0 6px 14px -4px rgba(46, 106, 84, 0.45);
}

.btn__sheen {
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, 0.24) 50%, transparent 70%);
  transform: translateX(-110%);
  transition: transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

.btn__words {
  position: relative;
  display: grid;
  overflow: hidden;
  height: 1.3em;
  line-height: 1.3em;
}

.btn__word {
  grid-area: 1 / 1;
  font-size: 0.9em;
  font-weight: 600;
  letter-spacing: 0.005em;
  text-align: center;
  white-space: nowrap;
}

.btn__word--b {
  opacity: 0;
}

.btn:focus-visible .btn__face,
.back:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

@media (hover: hover) {
  .btn:hover .btn__sheen {
    transform: translateX(110%);
  }

  .item:hover .item__tile {
    transform: translateY(-1.5px) rotate(-4deg) scale(1.04);
  }

  .item:hover .item__bg {
    box-shadow: inset 0 0 0 1px rgba(46, 106, 84, 0.16), 0 4px 10px -4px rgba(28, 40, 34, 0.18);
  }

  .back:hover {
    background: rgba(46, 106, 84, 0.12);
  }
}

.item__tile {
  transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.item__bg {
  transition: box-shadow 0.3s ease;
}

/* ---------------------------------------------------------------- page two: the ticket */
.page--ticket {
  opacity: 0;
  visibility: hidden;
}

.thead {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.back {
  display: inline-flex;
  align-items: center;
  gap: 0.2em;
  height: 1.9em;
  padding: 0 0.75em 0 0.45em;
  border: 0;
  border-radius: 99px;
  font: inherit;
  font-size: 0.78em;
  font-weight: 580;
  color: var(--accent);
  background: rgba(46, 106, 84, 0.07);
  cursor: pointer;
  transition: background 0.3s ease;
  -webkit-tap-highlight-color: transparent;
}

.back svg {
  width: 1.2em;
  height: 1.2em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.thead__brand {
  font-size: 0.7em;
  color: var(--muted);
  font-weight: 540;
}

.ready {
  display: flex;
  align-items: center;
  gap: 0.8em;
  margin-top: 1.05em;
}

.ready__slot {
  flex: none;
  width: 2.9em;
  height: 2.9em;
  border-radius: 0.85em;
  background: rgba(46, 106, 84, 0.07);
  box-shadow: inset 0 0 0 1px rgba(46, 106, 84, 0.1);
}

.ready__text {
  display: flex;
  flex-direction: column;
}

.ready__text strong {
  font-size: 0.98em;
  font-weight: 640;
  letter-spacing: -0.012em;
}

.ready__text span {
  font-size: 0.7em;
  color: var(--muted);
  margin-top: 0.15em;
}

.number {
  margin-top: 1em;
  display: flex;
  flex-direction: column;
}

.number__label {
  font-size: 0.68em;
  color: var(--muted);
  font-weight: 540;
  letter-spacing: 0.02em;
}

.number__digits {
  display: flex;
  margin-top: -0.04em;
  margin-bottom: -0.1em;
  font-size: 4.1em;
  line-height: 1.2;
  height: 1.2em;
  font-weight: 660;
  font-variation-settings: 'wdth' 112;
  letter-spacing: -0.04em;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.digit {
  display: block;
  height: 1.2em;
  overflow: hidden;
  /* a little fade at the top and bottom of the window while the digits roll */
  -webkit-mask: linear-gradient(180deg, transparent 0, #000 26%, #000 74%, transparent 100%);
  mask: linear-gradient(180deg, transparent 0, #000 26%, #000 74%, transparent 100%);
}

.digit__strip {
  display: flex;
  flex-direction: column;
}

.digit__strip span {
  display: block;
  height: 1.2em;
  text-align: center;
  width: 0.62em;
}

.cells {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6em;
  margin: 1em 0 0;
}

.cell {
  padding: 0.6em 0.7em 0.65em;
  border-radius: 0.75em;
  background: linear-gradient(160deg, #f6f7f3, #f0f3ee);
  box-shadow: inset 0 0 0 1px rgba(28, 40, 34, 0.05);
}

.cell dt {
  font-size: 0.64em;
  color: var(--muted);
  font-weight: 540;
}

.cell dd {
  margin: 0.25em 0 0;
  font-size: 0.8em;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.mid {
  color: var(--accent);
}

/* ---------------------------------------------------------------- the stub, under the card */
.stub {
  position: absolute;
  z-index: 1;
  left: 0;
  right: 0;
  top: 100%;
  font-size: 4.45cqw;
  --notch: 0.55em;
  --tooth: 0em;
  visibility: hidden;
}

.stub__paper {
  position: relative;
  margin-top: var(--tooth);
  padding: 1em 1.3em 1.05em;
  border-radius: 1.15em;
  background: linear-gradient(180deg, #fcfbf6, var(--paper));
  box-shadow: inset 0 0 0 1px rgba(28, 40, 34, 0.06);
  -webkit-mask:
    radial-gradient(circle at 0 0, transparent var(--notch), #000 calc(var(--notch) + 0.6px)) left / 51% 100% no-repeat,
    radial-gradient(circle at 100% 0, transparent var(--notch), #000 calc(var(--notch) + 0.6px)) right / 51% 100% no-repeat;
  mask:
    radial-gradient(circle at 0 0, transparent var(--notch), #000 calc(var(--notch) + 0.6px)) left / 51% 100% no-repeat,
    radial-gradient(circle at 100% 0, transparent var(--notch), #000 calc(var(--notch) + 0.6px)) right / 51% 100% no-repeat;
}

.stub__teeth {
  top: 0;
  background-image: conic-gradient(from 135deg at 50% 0, #fcfbf6 90deg, transparent 0);
  background-position: 0.25em 0;
}

/* the perforation: a row of small holes along the join, before it tears */
.stub__perf {
  position: absolute;
  top: 0.05em;
  left: calc(var(--notch) + 0.45em);
  right: calc(var(--notch) + 0.45em);
  height: 0.22em;
  background: radial-gradient(circle, rgba(28, 40, 34, 0.2) 0 0.07em, transparent 0.08em) 0 50% / 0.5em 100% repeat-x;
}

.stub__code {
  display: block;
  width: 100%;
  height: 2.6em;
}

.stub__code rect {
  fill: var(--ink);
}

.stub__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 0.55em;
}

.stub__num {
  font-family: 'Geist Mono Variable', ui-monospace, monospace;
  font-size: 0.7em;
  letter-spacing: 0.08em;
  color: var(--ink);
}

.stub__note {
  font-size: 0.66em;
  color: var(--muted);
}

/* ---------------------------------------------------------------- the paper bag */
.bag {
  position: absolute;
  left: 0;
  top: 0;
  width: 6.2em;
  height: 6.94em;
  overflow: visible;
  pointer-events: none;
  visibility: hidden;
  font-size: 4.45cqw;
}

.bag--back {
  z-index: 1;
}

.bag--front {
  z-index: 3;
}

.bag__inside {
  fill: #b59c71;
}

.bag__inside-shade {
  fill: rgba(80, 60, 30, 0.22);
}

.bag__body {
  fill: url(#kraft);
}

.bag__gusset {
  fill: rgba(120, 92, 50, 0.13);
}

.bag__crease {
  stroke: rgba(110, 84, 46, 0.18);
  stroke-width: 0.7;
  fill: none;
}

.bag__lip {
  stroke: rgba(255, 250, 238, 0.55);
  stroke-width: 1;
  fill: none;
}

.bag__print rect {
  fill: var(--accent);
  opacity: 0.9;
}

.bag__print path,
.bag__print circle {
  stroke: #e3d0ad;
  stroke-width: 2.2;
  stroke-linecap: round;
  fill: none;
}

.bag__print circle {
  fill: #e3d0ad;
  stroke: none;
}

.bag__print .bag__word {
  stroke: rgba(46, 106, 84, 0.55);
  stroke-width: 2;
}

.bag__flap {
  fill: url(#kraftFold);
}

.bag__flap-shadow {
  fill: rgba(90, 66, 34, 0.16);
}

.bag__flap-edge {
  stroke: rgba(255, 250, 238, 0.6);
  stroke-width: 1;
  fill: none;
}

.bag__staple rect {
  fill: var(--steel);
  stroke: rgba(60, 66, 68, 0.45);
  stroke-width: 0.5;
}

.bag__staple-hi {
  stroke: rgba(255, 255, 255, 0.9);
  stroke-width: 0.6;
  stroke-linecap: round;
}

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