/* The vase in the sun: the card of a hand-blown glass vase on a white page. The vase stands on a pale table in the
   sun, and the four glasses lie under it as small tiles of the same glass, casting their shadows in the same light. */
:root {
  --page: #ffffff;          /* the page */
  --card: #ffffff;          /* the card */
  --ink: #18211f;           /* the words */
  --muted: #6b7571;
  --line: rgba(24, 33, 31, 0.12);
  --table: #e6e1d8;         /* the table the vase stands on, in the sun */
  --sun: #fff1dc;           /* the colour of the sunlight */
  --sky: #dfe3ea;           /* the colour of the light in the shadows */
  --button: #18211f;        /* the button */
  --button-lit: #2c3734;    /* the button under the pointer */
  --sea: #9cd6c3;           /* the sea glass */
  --amber: #e9a443;         /* the amber glass */
  --cobalt: #4c76d9;        /* the cobalt glass */
  --smoke: #a7a097;         /* the smoke glass */
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
}

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

.stage {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
}

/* ---------------------------------------------------------------- the card */
.vase {
  width: min(340px, 100%);
  padding: 8px;
  border-radius: 26px;
  background: var(--card);
  box-shadow:
    0 0 0 1px rgba(24, 33, 31, 0.07),
    0 2px 6px -2px rgba(24, 33, 31, 0.08),
    0 30px 50px -26px rgba(24, 33, 31, 0.32);
}

/* the picture: a canvas the script draws, the table and the vase in the sun */
.vase__shot {
  position: relative;
  aspect-ratio: 324 / 300;
  overflow: hidden;
  border-radius: 19px;
  background: var(--table);
  isolation: isolate;
  /* a finger moving sideways over the picture moves the sun; up and down, the page scrolls */
  touch-action: pan-y;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}

.vase__shot::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(24, 33, 31, 0.06);
  pointer-events: none;
}

.vase__canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.vase__body {
  padding: 18px 14px 14px;
}

.vase__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.vase__name {
  margin: 0;
  font-family: 'Imbue Variable', 'Times New Roman', serif;
  font-size: 33px;
  font-weight: 460;
  font-variation-settings: 'opsz' 60;
  line-height: 1;
  letter-spacing: -0.005em;
}

.vase__price {
  margin: 0;
  font-size: 18px;
  font-weight: 620;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.vase__meta {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

/* ---------------------------------------------------------------- the glasses: a real radio group */
.glass {
  --shx: 1px;               /* the shadow of a tile one unit off the card, written by the script from the sun */
  --shy: 1px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: baseline;
  column-gap: 8px;
  margin-top: 18px;
}

.glass__label {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

/* the glass chosen, written in its own colour (a darker shade of it, so it reads) */
.glass__name {
  margin: 0;
  color: var(--name, var(--ink));
  font-size: 14px;
  font-weight: 650;
}

.glass__tiles {
  grid-column: 1 / -1;
  display: flex;
  gap: 12px;
  margin-top: 12px;
}

@property --lift {
  syntax: '<number>';
  inherits: true;
  initial-value: 1;
}

/* a tile of the glass lying on the card: the one chosen floats a little higher, so its coloured shadow falls further */
.tile {
  --lift: 0.7;
  position: relative;
  display: block;
  width: 44px;
  height: 44px;
  cursor: pointer;
  transition: --lift 0.5s cubic-bezier(0.3, 1.7, 0.45, 1);
  -webkit-tap-highlight-color: transparent;
}

.tile.is-on {
  --lift: 6;
}

@media (hover: hover) {
  .tile:not(.is-on):hover {
    --lift: 2.6;
  }
}

.tile__input {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

/* the shadow: the light through the tile, in its colour, with a brighter seam where the glass gathers it */
.tile::before,
.tile::after {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 11px;
  pointer-events: none;
  transform: translate(calc(var(--shx) * var(--lift)), calc(var(--shy) * var(--lift)));
}

.tile::before {
  background: color-mix(in srgb, var(--tint) 62%, rgba(24, 33, 31, 0.5));
  filter: blur(calc(1px + var(--lift) * 0.7px));
  opacity: 0.5;
}

.tile::after {
  inset: 9px;
  border-radius: 8px;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--tint) 40%, #ffffff), transparent);
  opacity: 0.85;
  mix-blend-mode: screen;
}

.tile__glass {
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: 12px;
  background:
    linear-gradient(var(--glint, 150deg), rgba(255, 255, 255, 0.75) 0%, rgba(255, 255, 255, 0.12) 38%, rgba(255, 255, 255, 0) 60%),
    radial-gradient(120% 120% at 50% 50%, color-mix(in srgb, var(--tint) 55%, #ffffff), var(--tint));
  box-shadow:
    inset 0 0 0 1.5px color-mix(in srgb, var(--tint) 70%, #18211f),
    inset 0 1.5px 0 2px rgba(255, 255, 255, 0.35);
  transform: translateY(calc(var(--lift) * -0.8px));
  opacity: 0.94;
}

.tile__input:focus-visible + .tile__glass {
  outline: 2.5px solid var(--ink);
  outline-offset: 3px;
}

/* ---------------------------------------------------------------- the button */
.buy {
  display: flex;
  gap: 8px;
  margin-top: 20px;
}

.add,
.undo {
  height: 50px;
  border-radius: 999px;
  font: 600 15.5px/1 'Hanken Grotesk Variable', system-ui, sans-serif;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.add {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-width: 0;
  padding: 0 20px;
  overflow: hidden;
  border: 0;
  background: var(--button);
  color: #ffffff;
  white-space: nowrap;
  transition: transform 0.45s cubic-bezier(0.3, 1.6, 0.5, 1), background-color 0.3s ease, color 0.3s ease;
}

/* the wrapping, filled by the script */
.add__fill {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.14);
  transform: scaleX(0);
  transform-origin: left center;
}

.add__icon {
  position: relative;
  width: 20px;
  height: 20px;
  flex: none;
}

.add__bag,
.add__tick {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.add__tick {
  stroke-width: 2.1;
  opacity: 0;
}

.add__bag path:last-child {
  transition: transform 0.35s cubic-bezier(0.3, 1.8, 0.5, 1);
}

.add__label {
  position: relative;
}

.add.is-done {
  background: var(--done, #e3efe9);
  color: var(--ink);
}

.undo {
  flex: none;
  padding: 0 18px;
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--ink);
  overflow: hidden;
  white-space: nowrap;
  transition: transform 0.45s cubic-bezier(0.3, 1.6, 0.5, 1), border-color 0.25s ease;
}

.undo[hidden] {
  display: none;
}

@media (hover: hover) {
  .add:hover {
    transform: scale(1.02);
  }

  .add:not(.is-done):hover {
    background: var(--button-lit);
  }

  /* pointed at, the bag's handle lifts as if picked up */
  .add:not(.is-done):hover .add__bag path:last-child {
    transform: translateY(-1.6px);
  }

  .undo:hover {
    border-color: rgba(24, 33, 31, 0.35);
  }
}

.add:active,
.undo:active {
  transform: scale(0.97);
  transition-duration: 0.12s;
}

.add:focus-visible,
.undo:focus-visible {
  outline: 2.5px solid var(--ink);
  outline-offset: 3px;
}

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

/* ---------------------------------------------------------------- less motion */
@media (prefers-reduced-motion: reduce) {
  .tile,
  .add,
  .undo,
  .add__bag path:last-child {
    transition: none;
  }

  .add:active,
  .undo:active {
    transform: none;
  }
  @media (hover: hover) {
    .add:hover {
      transform: none;
    }
  }
}
