/* The shopping list with the checked rows that drop into the basket: the list of a made-up grocery app (Fennow) on a
   warm white page. Seven items with a small drawn icon; checked ones fall into a basket drawn in lines. */
:root {
  --page: #efede7;          /* the page */
  --page-light: #f9f8f4;    /* the soft light on the page */
  --card: #fcfbf8;          /* the body of the card */
  --well: #f3f1ec;          /* the well of the rows under the pointer */
  --ink: #17181a;           /* the words */
  --muted: #85847f;         /* the small words */
  --line: rgba(23, 24, 26, 0.08); /* the thin lines between rows */
  --accent: #2f7a4b;        /* basil: the ticks, the counter, the basket */
  --accent-soft: rgba(47, 122, 75, 0.07); /* the inside of the basket */
  --pill: #ffffff;          /* a row once it is loose */
}

* {
  box-sizing: border-box;
}

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

body {
  background:
    radial-gradient(70% 60% at 30% 14%, var(--page-light), transparent 70%),
    var(--page);
  color: var(--ink);
  font-family: 'Mona Sans Variable', 'Mona Sans', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.stage {
  position: relative;
  height: 100vh;
  display: grid;
  place-items: center;
  padding: min(4vw, 3.4vh);
  overflow: hidden;
  touch-action: none;
}

/* ---------------------------------------------------------------- the card */
.card {
  --pad: clamp(12px, min(4.4vw, 3.6vh), 24px);
  --row: clamp(25px, min(6.7vh, 10vw), 42px);
  --basket: clamp(84px, 21vh, 150px);
  --lx: 22%;
  --ly: 0%;
  --lit: 0.55;
  position: relative;
  width: min(400px, 100%);
  padding: var(--pad);
  border-radius: clamp(18px, min(5vw, 4.6vh), 26px);
  background: linear-gradient(180deg, #fefefd, var(--card) 40%);
  box-shadow:
    0 0 0 1px rgba(23, 24, 26, 0.06),
    0 1px 1px rgba(23, 24, 26, 0.04),
    0 4px 8px -2px rgba(23, 24, 26, 0.05),
    0 18px 32px -12px rgba(23, 24, 26, 0.12),
    0 44px 70px -30px rgba(23, 24, 26, 0.18);
  opacity: 0;
  user-select: none;
  -webkit-user-select: none;
}

.card__rim {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: radial-gradient(240px 180px at var(--lx) var(--ly), rgba(255, 255, 255, var(--lit)), rgba(255, 255, 255, 0) 70%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0) 30%);
  -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);
  pointer-events: none;
  z-index: 6;
}

.card__shine {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(320px 220px at var(--lx) var(--ly), rgba(255, 255, 255, calc(var(--lit) * 0.7)), rgba(255, 255, 255, 0) 70%);
  pointer-events: none;
}

/* ---------------------------------------------------------------- the head */
.head {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: clamp(6px, 1.6vh, 12px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: clamp(10.5px, min(3vw, 2.6vh), 12.5px);
  font-weight: 600;
  font-stretch: 106%;
  color: var(--muted);
}

.brand__mark {
  width: 1.4em;
  height: 1.4em;
  fill: var(--accent);
}

.brand__mark path {
  fill: none;
  stroke: #fff;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.title {
  margin: clamp(2px, 0.6vh, 5px) 0 0;
  font-size: clamp(17px, min(5.4vw, 4.6vh), 25px);
  font-weight: 640;
  font-stretch: 112%;
  letter-spacing: -0.02em;
  line-height: 1.05;
}

.count {
  display: grid;
  justify-items: end;
  gap: 1px;
}

.count__num {
  display: inline-flex;
  align-items: baseline;
  gap: 0.3em;
  font-size: clamp(15px, min(4.6vw, 4vh), 21px);
  font-weight: 620;
  letter-spacing: -0.01em;
}

.count__win {
  position: relative;
  display: inline-block;
  height: 1.15em;
  width: 0.62em;
  overflow: hidden;
  color: var(--accent);
  -webkit-mask: linear-gradient(transparent, #000 22%, #000 78%, transparent);
  mask: linear-gradient(transparent, #000 22%, #000 78%, transparent);
}

.count__d {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  line-height: 1.15em;
  text-align: center;
}

.count__of {
  color: var(--ink);
}

.count__cap {
  font-family: 'Geist Mono Variable', ui-monospace, monospace;
  font-size: clamp(8.5px, min(2.4vw, 2.1vh), 10px);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------------------------------------------------------------- the list */
.list {
  position: relative;
  z-index: 2;
  height: calc(var(--row) * 7 + 4px);
  margin-top: 4px;
}

.rows {
  list-style: none;
  margin: 0;
  padding: 0;
}

.row {
  position: relative;
  height: var(--row);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  touch-action: none;
}

.row[hidden] {
  display: none;
}

.row__bg {
  position: absolute;
  inset: 2px -8px;
  border-radius: 10px;
  background: var(--well);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.row + .row::before {
  content: '';
  position: absolute;
  left: calc(var(--row) * 0.78);
  right: 0;
  top: 0;
  height: 1px;
  background: var(--line);
}

.row__slot {
  position: relative;
  height: 100%;
  display: flex;
  align-items: center;
}

.qty {
  position: relative;
  font-family: 'Geist Mono Variable', ui-monospace, monospace;
  font-size: clamp(9.5px, min(2.7vw, 2.3vh), 11.5px);
  color: var(--muted);
  white-space: nowrap;
  transition: transform 0.3s cubic-bezier(0.23, 1, 0.32, 1);
}

/* the item: one element for the physics (chip), the face inside for GSAP and the CSS */
.chip {
  position: relative;
  display: block;
  will-change: transform;
}

.chip.is-loose {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
}

.chip__face {
  display: flex;
  align-items: center;
  gap: clamp(7px, 1.6vh, 10px);
  height: calc(var(--row) * 0.82);
  padding: 0 10px 0 0;
  border-radius: 999px;
  white-space: nowrap;
  transform-origin: 50% 50%;
  transition: background-color 0.25s ease, box-shadow 0.25s ease;
}

.chip.is-loose .chip__face {
  padding: 0 12px 0 6px;
  background: var(--pill);
  box-shadow:
    0 0 0 1px rgba(23, 24, 26, 0.07),
    0 1px 1px rgba(23, 24, 26, 0.05),
    0 6px 12px -6px rgba(23, 24, 26, 0.22),
    inset 0 1px 0 #fff;
}

.box {
  flex: none;
  width: calc(var(--row) * 0.5);
  height: calc(var(--row) * 0.5);
  overflow: visible;
}

.box__ring {
  fill: #fff;
  stroke: rgba(23, 24, 26, 0.24);
  stroke-width: 1.3;
  transition: stroke 0.2s ease;
}

.box__fill {
  fill: var(--accent);
  transform-box: fill-box;
  transform-origin: 50% 50%;
}

.box__tick {
  fill: none;
  stroke: #fff;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ico {
  flex: none;
  width: calc(var(--row) * 0.52);
  height: calc(var(--row) * 0.52);
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.35;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.86;
}

.name {
  font-size: clamp(12px, min(3.7vw, 3.2vh), 15px);
  font-weight: 520;
  font-stretch: 104%;
  letter-spacing: -0.005em;
}

.empty {
  position: absolute;
  left: 0;
  right: 0;
  top: 34%;
  margin: 0;
  text-align: center;
  font-size: clamp(11.5px, min(3.4vw, 3vh), 14px);
  color: var(--muted);
  opacity: 0;
  pointer-events: none;
}

/* put back: a small ghost pill in the room the rows leave */
.back {
  position: absolute;
  right: -4px;
  bottom: 2px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: clamp(24px, 5.6vh, 32px);
  padding: 0 12px 0 10px;
  border: 0;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(23, 24, 26, 0.1), 0 2px 6px -3px rgba(23, 24, 26, 0.2);
  color: var(--ink);
  font: inherit;
  font-size: clamp(10.5px, min(3vw, 2.6vh), 12.5px);
  font-weight: 560;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
}

.back svg {
  width: 1.15em;
  height: 1.15em;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------------------------------------------------------------- the basket */
.basket {
  position: relative;
  height: var(--basket);
  margin-top: clamp(4px, 1vh, 8px);
}

.basket__back,
.basket__front {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.basket__back {
  z-index: 1;
}

.basket__front {
  z-index: 5;
  pointer-events: none;
}

.basket__fill {
  fill: var(--accent-soft);
}

.basket__slats line {
  stroke: var(--accent);
  stroke-opacity: 0.13;
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.basket__line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.4;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.basket__line--soft {
  stroke-opacity: 0.35;
  stroke-width: 1;
}

.basket__handle {
  position: absolute;
  top: calc(var(--basket) * 0.09 - 13px);
  width: 30px;
  height: 14px;
  border: 1.4px solid var(--accent);
  border-bottom: 0;
  border-radius: 15px 15px 0 0;
  opacity: 0.8;
}

.basket__handle--l {
  left: 8%;
}

.basket__handle--r {
  right: 8%;
}

.world {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

.chip.is-held {
  z-index: 2;
}

@media (hover: hover) {
  .row:hover .row__bg {
    opacity: 1;
  }
  .row:hover .box__ring {
    stroke: var(--accent);
  }
  .row:hover .qty {
    transform: translateX(-3px);
  }
  .row:hover {
    cursor: grab;
  }
  .back:hover {
    box-shadow: 0 0 0 1px rgba(47, 122, 75, 0.35), 0 4px 10px -4px rgba(23, 24, 26, 0.25);
  }
}

.row.is-hot .row__bg {
  opacity: 1;
}

.row.is-hot .box__ring {
  stroke: var(--accent);
}

/* ---------------------------------------------------------------- the pointer of the walk on its own */
.cursor {
  position: absolute;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  fill: var(--ink);
  stroke: #fff;
  stroke-width: 1.4;
  stroke-linejoin: round;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.25));
  pointer-events: none;
  opacity: 0;
  z-index: 10;
}

@media (prefers-reduced-motion: reduce) {
  .row__bg,
  .qty,
  .chip__face {
    transition: none;
  }
}
