/* The string bag cart: a white cart on a white page; the colour is in the fruit, the green net and the kraft tag. */
:root {
  --page: #ffffff;          /* the page */
  --panel: #ffffff;         /* the cart */
  --edge: #ebe7df;          /* the cart's edge and the lines between */
  --stall: #f5f1e8;         /* the wall the bag hangs on */
  --ink: #22201b;           /* the text */
  --muted: #7d776b;         /* the quieter text */
  --net: #2f5e45;           /* the cotton net */
  --dowel: #d9b27a;         /* the wooden handle */
  --brass: #b98a3e;         /* the rail and the hook */
  --tag: #e8d3ad;           /* the kraft tag */
  --orange: #ee7426;        /* the blood oranges */
  --orange-blush: #b8282a;  /* their red blush */
  --lemon: #f3d03c;         /* the lemons */
  --apple: #c9303a;         /* the apples */
  --apple-blush: #efc45b;   /* their yellow side */
  --plum: #5b2a5f;          /* the plums */
  --free: #2f6b47;          /* free delivery */
  --pay: #b9432a;           /* the pay button */
  --pay-ink: #fff7ef;       /* the words on it */
  --done: #2f6b47;          /* the pay button once the order is placed */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

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

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

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

/* the cart hangs from the top: lines going and coming move its bottom, never the bag */
.stage {
  min-height: 100svh;
  display: grid;
  justify-items: center;
  align-content: start;
  padding: max(24px, 6vh) 16px 24px;
}

.cart {
  width: min(390px, 100%);
  padding: 18px 16px 16px;
  border: 1px solid var(--edge);
  border-radius: 26px;
  background: var(--panel);
  box-shadow: 0 1px 2px rgba(34, 32, 27, 0.04), 0 24px 48px -28px rgba(34, 32, 27, 0.24);
}

.cart__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0 4px;
}

.cart__title {
  margin: 0;
  font: 560 22px/1.1 'Fraunces Variable', Georgia, serif;
  font-variation-settings: 'SOFT' 100, 'WONK' 1;
  letter-spacing: -0.01em;
}

.cart__count {
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 540;
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- the bag on its rail */
/* the drawing is made at one size and scaled to the cart; nothing in it ever goes over the words round it */
.stall {
  position: relative;
  margin-top: 12px;
  border-radius: 18px;
  background: var(--stall);
  overflow: hidden;
  aspect-ratio: 358 / 284;
}

.stall__art {
  position: absolute;
  left: 0;
  top: 0;
  width: 358px;
  height: 284px;
  transform-origin: 0 0;
}

.stall__net {
  display: block;
  width: 358px;
  height: 284px;
  touch-action: pan-y;
}

/* the kraft tag on its string: the outer box swings with the string, the card inside spins round it */
.tag {
  position: absolute;
  left: 0;
  top: 0;
  width: 96px;
  transform-origin: 48px 9px;
  perspective: 420px;
  pointer-events: none;
  will-change: transform;
}

.tag__card {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 1px;
  height: 64px;
  padding: 17px 6px 0;
  background:
    radial-gradient(120% 90% at 30% 10%, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0) 60%),
    var(--tag);
  clip-path: polygon(15px 0, calc(100% - 15px) 0, 100% 15px, 100% 100%, 0 100%, 0 15px);
  -webkit-mask: radial-gradient(circle at 48px 9px, transparent 3.2px, #000 3.8px);
  mask: radial-gradient(circle at 48px 9px, transparent 3.2px, #000 3.8px);
  color: var(--ink);
  text-align: center;
  transform-style: preserve-3d;
  will-change: transform;
}

/* the eyelet round the hole, a ring of darker card */
.tag__card::before {
  content: '';
  position: absolute;
  left: 41.5px;
  top: 2.5px;
  width: 13px;
  height: 13px;
  border: 2.2px solid color-mix(in srgb, var(--tag) 70%, #6b4a22);
  border-radius: 50%;
}

.tag__total {
  font: 640 21px/1 'Fraunces Variable', Georgia, serif;
  font-variation-settings: 'SOFT' 100, 'WONK' 0, 'opsz' 48;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums lining-nums;
  white-space: nowrap;
}

.tag__goal {
  max-width: 84px;
  color: color-mix(in srgb, var(--ink) 72%, var(--tag));
  font-size: 10px;
  font-weight: 600;
  line-height: 1.15;
  text-wrap: balance;
}

.tag.is-free .tag__goal {
  color: var(--free);
  font-weight: 720;
}

/* with nothing left in the cart, the way back to a full bag */
.restart {
  position: absolute;
  left: 50%;
  top: 40%;
  height: 38px;
  padding: 0 16px;
  border: 1px solid var(--edge);
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink);
  font: 640 13.5px 'Figtree Variable', system-ui, sans-serif;
  white-space: nowrap;
  cursor: pointer;
  translate: -50% -50%;
  transition: border-color 0.15s ease, scale 0.12s ease;
}

.restart[hidden] {
  display: none;
}

.restart:active {
  scale: 0.96;
}

@media (hover: hover) {
  .restart:hover {
    border-color: color-mix(in srgb, var(--edge) 40%, var(--ink));
  }
}

/* ---------------------------------------------------------------- the lines */
.lines {
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.line {
  position: relative;
  overflow: hidden;
}

.line + .line .line__body,
.line + .line .undo {
  border-top: 1px solid var(--edge);
}

.line__body {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  column-gap: 12px;
  align-items: center;
  padding: 6px 4px;
}

.line__body[hidden] {
  display: none;
}

.thumb {
  grid-row: 1 / 3;
  display: block;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--stall);
}

.line__name {
  margin: 0;
  font: 520 15.5px/1.15 'Fraunces Variable', Georgia, serif;
  font-variation-settings: 'SOFT' 100, 'WONK' 0;
}

.line__each {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.line__total {
  margin: 0;
  justify-self: end;
  font-size: 15px;
  font-weight: 680;
  font-variant-numeric: tabular-nums;
}

.remove {
  padding: 2px 0;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  font: 560 13px 'Figtree Variable', system-ui, sans-serif;
  cursor: pointer;
  transition: color 0.15s ease;
}

@media (hover: hover) {
  .remove:hover {
    color: var(--pay);
  }
}

.qty {
  display: flex;
  align-items: center;
  justify-self: end;
  margin-top: 2px;
  border-radius: 999px;
  background: var(--stall);
}

.qty button {
  display: grid;
  place-items: center;
  width: 32px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.15s ease, scale 0.12s ease;
}

.qty button:active {
  scale: 0.9;
}

@media (hover: hover) {
  .qty button:hover {
    background: color-mix(in srgb, var(--stall) 60%, var(--edge));
  }
}

.qty button[aria-disabled='true'] {
  color: color-mix(in srgb, var(--muted) 50%, transparent);
  cursor: default;
}

.qty svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
}

.qty__n {
  display: inline-block;
  min-width: 16px;
  font-size: 14px;
  font-weight: 680;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* a line removed: what it was, and Undo, with the time left drawn round the arrow */
.undo {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 50px;
  padding: 0 4px;
}

.undo[hidden] {
  display: none;
}

.undo .thumb {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  opacity: 0.55;
}

.undo__text {
  flex: 1;
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
}

.undo__btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px 6px 7px;
  border: 1px solid var(--edge);
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink);
  font: 640 13.5px 'Figtree Variable', system-ui, sans-serif;
  cursor: pointer;
  transition: border-color 0.15s ease, scale 0.12s ease;
}

.undo__btn:active {
  scale: 0.96;
}

@media (hover: hover) {
  .undo__btn:hover {
    border-color: color-mix(in srgb, var(--edge) 40%, var(--ink));
  }
}

.undo__btn svg {
  width: 20px;
  height: 20px;
  overflow: visible;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.undo__ring {
  stroke: var(--edge);
  stroke-width: 1.6;
}

.undo__left {
  stroke: var(--ink);
  stroke-width: 1.6;
}

.undo__arrow {
  stroke: currentColor;
  stroke-width: 1.7;
}

/* ---------------------------------------------------------------- the sums and the pay button */
.sums {
  margin-top: 4px;
  padding: 10px 4px 0;
  border-top: 1px solid var(--edge);
}

.sums__row {
  display: flex;
  justify-content: space-between;
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13.5px;
}

.sums__n {
  display: inline-flex;
  gap: 6px;
  color: var(--ink);
  font-weight: 640;
  font-variant-numeric: tabular-nums;
}

.sums__was {
  color: var(--muted);
  font-weight: 500;
}

.sums__was:empty {
  display: none;
}

.sums__n.is-free {
  color: var(--free);
}

.pay {
  position: relative;
  display: block;
  width: 100%;
  height: 50px;
  margin-top: 10px;
  padding: 0;
  border: 0;
  border-radius: 15px;
  background: var(--pay);
  color: var(--pay-ink);
  font: 680 16px 'Figtree Variable', system-ui, sans-serif;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: scale 0.14s ease, background-color 0.3s ease;
}

.pay:active {
  scale: 0.98;
}

@media (hover: hover) {
  .pay:hover {
    background: color-mix(in srgb, var(--pay) 88%, #000000);
  }
}

.pay.is-done {
  background: var(--done);
}

.pay[aria-disabled='true'] {
  background: color-mix(in srgb, var(--pay) 30%, #ffffff);
  cursor: default;
}

.pay__face {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  height: 100%;
}

.pay__label {
  font-variant-numeric: tabular-nums;
}

.pay__spin,
.pay__tick {
  display: none;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.pay.is-busy .pay__spin,
.pay.is-done .pay__tick {
  display: block;
}

/* the focus rings show for the keys, not after a finger or the mouse */
.cart button:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.pay:focus-visible {
  outline-offset: 3px;
}

.qty button:focus-visible {
  outline-offset: -2px;
}

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

/* the back of the tag is plain card */
.tag__card.is-back > span {
  visibility: hidden;
}

/* il telefono basso (la casella dell'anteprima, 341 per 410): la borsa un po' più piccola e le righe più strette,
   perché il carrello intero stia nella casella */
@media (max-width: 760px) and (max-height: 720px) {
  .stage {
    padding: 12px 16px;
  }

  .cart {
    padding: 14px 12px 12px;
  }

  .stall {
    width: min(100%, 236px);
    margin: 8px auto 0;
  }

  .lines {
    margin-top: 6px;
  }

  .line__body {
    padding: 4px 4px;
  }

  .undo {
    height: 44px;
  }

  .sums {
    margin-top: 2px;
    padding-top: 8px;
  }

  .sums__row {
    margin-bottom: 2px;
  }

  .pay {
    height: 46px;
    margin-top: 8px;
  }
}
