/* The perfume card: the card of an eau de parfum on a white page. Its picture is a dusky fig-leaf green wall and a
   dark stone ledge, with a faceted glass bottle of amber perfume and a gold atomizer; the notes of the perfume are
   written in cream over the green. */
:root {
  --page: #ffffff;          /* the page */
  --card: #ffffff;          /* the card */
  --ink: #1b1d16;           /* the words */
  --muted: #6c6a5d;
  --line: rgba(27, 29, 22, 0.12);
  --wall: #1f2b1e;          /* the wall behind the bottle */
  --wall-lit: #55663f;      /* the same wall where the light falls */
  --stone: #2a2f24;         /* the stone ledge the bottle stands on */
  --stone-edge: #4a5240;    /* its front edge, catching the light */
  --perfume: #e39a35;       /* the perfume where the light comes through */
  --perfume-deep: #8f3c0d;  /* the perfume at the bottom of the bottle */
  --glass: #e8f0e2;         /* the glass's edges */
  --gold: #d7b46a;          /* the atomizer and its collar */
  --gold-dark: #5e4721;
  --mist: #fff1dc;          /* the spray */
  --label: #f3e8d2;         /* the paper label on the bottle */
  --note: #fbf2e3;          /* the notes that gather out of the mist */
  --tier: #d9bb84;          /* top, heart and base */
  --button: #1f2b1e;        /* Add to bag */
  --button-lit: #2d3d2b;    /* Add to bag under the pointer */
  --added: #f3e4c4;         /* Add to bag once the perfume is in the bag */
  --thumb: #f3ead9;         /* the chosen size */
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
}

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

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

/* ---------------------------------------------------------------- the card */
.scent {
  width: min(340px, 100%);
  padding: 8px;
  border-radius: 26px;
  background: var(--card);
  box-shadow:
    0 0 0 1px rgba(27, 29, 22, 0.07),
    0 2px 6px -2px rgba(27, 29, 22, 0.08),
    0 30px 50px -26px rgba(27, 29, 22, 0.34);
}

/* the picture: a canvas the script draws, the notes over it, and the atomizer as a button. Everything in it is
   measured on the picture's own width, so it keeps its drawing at any size */
.shot {
  position: relative;
  aspect-ratio: 324 / 318;
  overflow: hidden;
  border-radius: 19px;
  background: var(--wall);
  isolation: isolate;
  container-type: inline-size;
  cursor: pointer;
  touch-action: pan-y;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}

.shot::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
  pointer-events: none;
}

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

/* the atomizer's head, where a press sprays: placed by the script over the drawing */
.shot__nozzle {
  position: absolute;
  left: 0;
  top: 0;
  width: 13cqw;
  height: 13cqw;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.shot__nozzle:focus-visible {
  outline: 2px solid var(--note);
  outline-offset: 2px;
}

/* the notes: three heights on the right of the picture, the top note highest */
.notes {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.note {
  position: absolute;
  left: 58.6cqw;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6cqw;
  white-space: nowrap;
}

.note--top {
  top: 16.7cqw;
}

.note--heart {
  top: 36.5cqw;
}

.note--base {
  top: 56.3cqw;
}

.note__tier {
  color: var(--tier);
  font-size: 3.15cqw;
  font-weight: 560;
  font-stretch: 112%;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0;
}

.note__name {
  color: var(--note);
  font-family: 'Playfair Variable', 'Didot', 'Georgia', serif;
  font-size: 7.1cqw;
  font-style: italic;
  font-weight: 460;
  line-height: 1.1;
  letter-spacing: 0;
  text-shadow: 0 0.4cqw 2.4cqw rgba(12, 18, 10, 0.55);
}

.note__name span {
  display: inline-block;
  white-space: pre;
  opacity: 0;
}

/* ---------------------------------------------------------------- the words of the card */
.scent__body {
  padding: 18px 14px 16px;
}

.scent__kind {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 560;
  letter-spacing: 0.01em;
}

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

.scent__name {
  margin: 0;
  font-family: 'Playfair Variable', 'Didot', 'Georgia', serif;
  font-size: 31px;
  font-weight: 520;
  font-stretch: 94%;
  line-height: 1.05;
  letter-spacing: -0.01em;
}

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

/* the price rolls a digit at a time: each old digit goes up, the new one comes from below */
.price {
  display: inline-flex;
  overflow: hidden;
  padding: 2px 0;
  margin: -2px 0;
}

.price span {
  display: inline-block;
  white-space: pre;
}

/* ---------------------------------------------------------------- the sizes */
.sizes {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 16px;
  padding: 4px;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px var(--line);
  isolation: isolate;
}

.sizes__thumb {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 0;
  width: 0;
  z-index: -1;
}

.sizes__thumb-fill {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--thumb);
  box-shadow: inset 0 0 0 1px rgba(143, 60, 13, 0.16), 0 1px 2px rgba(27, 29, 22, 0.08);
}

.size {
  height: 34px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--muted);
  font: 560 13.5px/1 'Mona Sans Variable', system-ui, sans-serif;
  font-stretch: 100%;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: color 0.25s ease, font-stretch 0.5s cubic-bezier(0.34, 1.9, 0.45, 1);
}

.size[aria-checked='true'] {
  color: var(--ink);
  font-weight: 640;
  cursor: default;
}

.size:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: -2px;
}

/* ---------------------------------------------------------------- the buttons: elastic pills */
.buy {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.pill {
  --bg: var(--button);
  --fg: #ffffff;
  --edge: 0 0 0 0 transparent;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  height: 50px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--fg);
  font: 600 15px/1 'Mona Sans Variable', system-ui, sans-serif;
  font-stretch: 100%;
  white-space: nowrap;
  cursor: pointer;
  isolation: isolate;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: color 0.25s ease;
}

/* the pill itself is a layer of its own: it swells past its edges and springs back, so nothing round it moves */
.pill::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: var(--bg);
  box-shadow: var(--edge);
  transition: inset 0.6s cubic-bezier(0.34, 1.9, 0.45, 1), transform 0.2s cubic-bezier(0.23, 1, 0.32, 1), background-color 0.25s ease, box-shadow 0.25s ease;
}

.pill__icon {
  position: relative;
  flex: none;
  width: 19px;
  height: 19px;
  transition: transform 0.6s cubic-bezier(0.34, 1.9, 0.45, 1);
}

.pill__icon svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.try__puff path {
  stroke-width: 1.5;
}

.add__drop {
  fill: var(--perfume) !important;
  stroke: none !important;
  opacity: 0;
}

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

/* the word grows wider on the font's width axis: it has the room for its widest form already */
.pill__label {
  position: relative;
  transition: font-stretch 0.6s cubic-bezier(0.34, 1.9, 0.45, 1);
}

.pill--add {
  flex: 1 1 auto;
}

.pill--add.is-done {
  --bg: var(--added);
  --fg: var(--ink);
}

.pill--try {
  --bg: var(--card);
  --fg: var(--ink);
  --edge: inset 0 0 0 1.5px var(--line);
  flex: none;
  padding: 0 16px 0 14px;
  gap: 7px;
}

.pill--try .pill__icon {
  width: 20px;
  height: 20px;
}

/* pointed at, the pill swells past its edges and springs back, and the word grows wider on its axis */
@media (hover: hover) and (pointer: fine) {
  .pill--add:not(.is-done):not([aria-disabled='true']):hover {
    --bg: var(--button-lit);
  }

  .pill--try:hover {
    --edge: inset 0 0 0 1.5px rgba(27, 29, 22, 0.3);
  }

  .size:not([aria-checked='true']):hover {
    color: var(--ink);
  }
}

@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  .pill:not([aria-disabled='true']):hover::before {
    inset: -2px -5px;
  }

  .pill:not([aria-disabled='true']):hover .pill__label {
    font-stretch: 112%;
  }

  .pill--add:not([aria-disabled='true']):hover .pill__icon {
    transform: translateY(-1px) rotate(-8deg);
  }

  .pill--try:hover .pill__icon {
    transform: rotate(-8deg) translateX(1px);
  }

  .size:not([aria-checked='true']):hover {
    font-stretch: 110%;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .pill:not([aria-disabled='true']):active::before {
    transform: scale(1.03, 0.9);
  }
}

.pill[aria-disabled='true'] {
  cursor: default;
}

.pill:focus-visible {
  outline: none;
}

.pill:focus-visible::before {
  box-shadow: var(--edge), 0 0 0 2px var(--card), 0 0 0 4.5px var(--ink);
}

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

/* on the narrowest phones the words keep inside */
@media (max-width: 359px) {
  .scent__name {
    font-size: 26px;
  }

  .pill {
    gap: 6px;
    padding: 0 13px;
    font-size: 14px;
  }

  .pill--try {
    padding: 0 12px 0 10px;
  }
}

/* ---------------------------------------------------------------- less motion */
@media (prefers-reduced-motion: reduce) {
  .pill::before {
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
  }

  .pill__icon,
  .pill__label,
  .size {
    transition: none;
  }
}
