/* Vintage year picker: the vintage selector of Cellarmark, an invented winery, alone on white. A white card with a
   layered shadow; the wine seen from above in the glass, the score and the price, three tasting notes, a wheel of
   years to drag with a spring snap, and the Add to cart button that swells when pressed. */
:root {
  --page: #ffffff;          /* the page */
  --card: #ffffff;          /* the card */
  --ink: #1b1416;           /* the words */
  --muted: #8f8689;         /* the small words */
  --line: #ece7e6;          /* thin lines, the ruler, the pills */
  --accent: #7c1e2c;        /* the wine red of the tick, the badge and the glow */
  --pill: #f7f3f2;          /* the fill of the tasting notes */
  --button: #1b1416;        /* the Add to cart button */
  --button-ink: #ffffff;    /* the words on the button */
}

* {
  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: 'Mona Sans 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;
}

.stage {
  position: relative;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 12px;
  overflow: hidden;
}

/* ---------------------------------------------------------------- the card */
.wine {
  position: relative;
  width: min(336px, 92vw);
  padding: clamp(12px, 3.4vh, 20px) 18px clamp(12px, 3.2vh, 18px);
  border-radius: 24px;
  background: var(--card);
  box-shadow:
    0 0 0 1px rgba(27, 20, 22, 0.06),
    0 1px 1px rgba(27, 20, 22, 0.04),
    0 4px 8px -2px rgba(27, 20, 22, 0.05),
    0 18px 36px -14px rgba(27, 20, 22, 0.14),
    0 42px 70px -40px rgba(124, 30, 44, 0.3);
  opacity: 0;
  user-select: none;
  -webkit-user-select: none;
}

/* the 1px edge that catches the light at the top */
.wine::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 1), rgba(27, 20, 22, 0.05) 40%, rgba(27, 20, 22, 0.02));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

/* a very fine grain on the card */
.wine::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='.5'/%3E%3C/svg%3E");
  opacity: 0.035;
  mix-blend-mode: multiply;
  pointer-events: none;
}

.wine__head {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.wine__house {
  margin: 0;
  font-size: 10.5px;
  font-weight: 600;
  font-stretch: 112%;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.wine__title {
  margin: 2px 0 0;
  font-family: 'Fraunces Variable', Georgia, serif;
  font-size: clamp(24px, 6.4vh, 30px);
  font-weight: 560;
  line-height: 1;
  letter-spacing: -0.01em;
}

.wine__sub {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
  font-stretch: 96%;
}

/* the badge of a rare vintage: an element for GSAP, its content for the CSS */
.rare {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
  padding: 5px 9px 5px 7px;
  border-radius: 999px;
  background: linear-gradient(180deg, #fbf1f1, #f6e6e7);
  box-shadow: inset 0 0 0 1px rgba(124, 30, 44, 0.16), 0 4px 10px -6px rgba(124, 30, 44, 0.5);
  color: var(--accent);
  font-size: 11px;
  font-weight: 560;
  white-space: nowrap;
  opacity: 0;
  transform-origin: 100% 50%;
}

.rare svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.rare b {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- the glass and the facts */
.glassrow {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: clamp(8px, 2.4vh, 16px);
}

.drop {
  flex: none;
  width: min(98px, 21vh);
  aspect-ratio: 1;
  filter: drop-shadow(0 10px 14px rgba(124, 30, 44, 0.16));
}

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

.drop__bowl {
  fill: #fbfafa;
  stroke: rgba(27, 20, 22, 0.1);
  stroke-width: 1;
}

.drop__bowl--in {
  fill: #ffffff;
  stroke: rgba(27, 20, 22, 0.06);
}

.drop__rim {
  fill: none;
  stroke: rgba(255, 255, 255, 0.28);
  stroke-width: 1;
}

.drop__spec {
  fill: none;
  stroke: #ffffff;
  stroke-width: 3;
  stroke-linecap: round;
  opacity: 0.32;
}

.drop__ripple {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1;
  opacity: 0;
  transform-origin: 60px 60px;
}

.facts {
  flex: 1;
  margin: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 12px;
}

.fact dt {
  font-size: 10.5px;
  font-weight: 560;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.fact dd {
  margin: 3px 0 0;
  display: flex;
  align-items: baseline;
  gap: 3px;
  white-space: nowrap;
}

.fact__cur {
  font-size: 18px;
  font-weight: 600;
}

.fact__unit {
  font-size: 11px;
  color: var(--muted);
}

.facts__window {
  grid-column: 1 / -1;
  margin: 8px 0 0;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
}

/* the rolling digits: a box 1ch wide, a column from 0 to 9 inside */
.roll {
  display: inline-flex;
  font-variant-numeric: tabular-nums;
}

.roll--big {
  font-size: clamp(24px, 6.2vh, 30px);
  font-weight: 640;
  font-stretch: 92%;
  letter-spacing: -0.02em;
  line-height: 1;
}

.digit {
  position: relative;
  display: inline-block;
  width: 1ch;
  height: 1em;
  overflow: hidden;
  -webkit-mask: linear-gradient(transparent, #000 16%, #000 84%, transparent);
  mask: linear-gradient(transparent, #000 16%, #000 84%, transparent);
}

.digit__col {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  will-change: transform;
}

.digit__col span {
  display: block;
  height: 1em;
  line-height: 1;
  text-align: center;
}

/* ---------------------------------------------------------------- the tasting notes */
.notes {
  display: flex;
  gap: 6px;
  margin: clamp(10px, 2.6vh, 16px) 0 0;
  padding: 0;
  list-style: none;
}

.note {
  position: relative;
  height: 28px;
  border-radius: 999px;
  background: var(--pill);
  box-shadow: inset 0 0 0 1px var(--line), 0 1px 0 rgba(255, 255, 255, 0.9);
  overflow: hidden;
  white-space: nowrap;
}

.note__in {
  display: block;
  padding: 0 11px;
  line-height: 28px;
  font-size: 12px;
  font-weight: 520;
}

/* ---------------------------------------------------------------- the wheel of years */
.years {
  position: relative;
  margin: clamp(10px, 2.8vh, 18px) -18px 0;
  padding-top: 16px;
  outline: none;
  cursor: grab;
  touch-action: pan-y;
}

.years:active {
  cursor: grabbing;
}

.years__label {
  position: absolute;
  top: 0;
  left: 18px;
  font-size: 10.5px;
  font-weight: 560;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.years__track {
  position: relative;
  height: clamp(50px, 12vh, 58px);
  overflow: hidden;
  -webkit-mask: linear-gradient(90deg, transparent, #000 22%, #000 78%, transparent);
  mask: linear-gradient(90deg, transparent, #000 22%, #000 78%, transparent);
}

.years__strip,
.years__ruler {
  position: absolute;
  left: 0;
  top: 0;
  will-change: transform;
}

.year {
  position: absolute;
  top: 6px;
  width: 64px;
  margin-left: -32px;
  text-align: center;
  font-family: 'Fraunces Variable', Georgia, serif;
  font-size: 23px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  line-height: 1;
  cursor: pointer;
  transform-origin: 50% 60%;
}

.years__ruler i {
  position: absolute;
  top: 0;
  width: 1px;
  height: 5px;
  background: rgba(27, 20, 22, 0.16);
}

.years__ruler i.is-year {
  height: 9px;
  background: rgba(27, 20, 22, 0.34);
}

.years__ruler {
  top: auto;
  bottom: 4px;
  height: 9px;
}

.years__ruler i {
  top: auto;
  bottom: 0;
}

/* the thin tick in the middle that snaps: an element for the layout, its child for GSAP */
.years__tick {
  position: absolute;
  left: 50%;
  bottom: 2px;
  width: 2px;
  height: 15px;
  margin-left: -1px;
}

.years__tick i {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 1px;
  background: var(--accent);
  transform-origin: 50% 100%;
}

.years:focus-visible .years__track {
  box-shadow: inset 0 0 0 2px rgba(124, 30, 44, 0.35);
  border-radius: 12px;
}

/* ---------------------------------------------------------------- the button */
.cart {
  display: block;
  width: 100%;
  margin-top: clamp(10px, 2.6vh, 16px);
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

.cart__face {
  position: relative;
  display: grid;
  place-items: center;
  height: clamp(44px, 11vh, 50px);
  border-radius: 999px;
  background: var(--button);
  color: var(--button-ink);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    0 1px 2px rgba(27, 20, 22, 0.2),
    0 10px 22px -10px rgba(27, 20, 22, 0.5);
  overflow: hidden;
}

.cart__glow {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 140%;
  height: 260%;
  margin: -130% 0 0 -70%;
  background: radial-gradient(closest-side, rgba(176, 48, 70, 0.85), rgba(176, 48, 70, 0) 70%);
  opacity: 0;
  pointer-events: none;
}

.cart__label {
  position: relative;
  grid-area: 1 / 1;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14.5px;
  font-weight: 600;
  font-stretch: 104%;
}

.cart__label--done {
  opacity: 0;
}

.cart__bag,
.cart__check {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.cart:focus-visible .cart__face {
  box-shadow: 0 0 0 3px #fff, 0 0 0 5px rgba(124, 30, 44, 0.5);
}

@media (hover: hover) {
  .cart:hover .cart__face {
    background: #2b1d21;
    transition: background-color 0.3s;
  }
  .year:hover {
    color: var(--accent);
  }
}
