/* The watch window with the light sliding over the glass: three cards of a made-up watchmaker on a warm dark page.
   Each card is a stack: two shadow layers (one at rest, one that grows as the card rises), then the frame with the
   photo, a soft vignette, the specular glare that follows the pointer, a long diagonal streak like the reflection on a
   watch glass, a fine grain and a 1px rim that catches the light where the pointer is. The script only writes CSS
   variables on each card (--l lift, --d dim, --g glare, --gx/--gy where the light is, --sx where the streak is) and
   the transform of .card__body; the rest is here. */
:root {
  --page: #14100c;          /* the page, a warm near black */
  --page-glow: #2a1f15;     /* the warm light in the middle of the page */
  --card: #1d1712;          /* the card behind the photo */
  --ink: #f3ebe0;           /* the names */
  --muted: #9a8b79;         /* the small words and the prices */
  --accent: #e2b77c;        /* the warm gold of the light and of the rule */
  --light: 255, 238, 214;   /* the colour of the glare on the glass, as r, g, b */
  --w: min(232px, 28.5vw, 33vh); /* the width of one card */
  --gap: min(30px, 3.2vw);  /* the space between the cards */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

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

body {
  min-height: 100svh;
  background:
    radial-gradient(60% 50% at 50% 46%, var(--page-glow), transparent 72%),
    var(--page);
  color: var(--ink);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* a fine grain over the whole page, so the dark does not band */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

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

.stage {
  min-height: 100svh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: min(26px, 4.4vh);
  padding: 12px;
  overflow: hidden;
}

/* the line over the cards: the maker on the left, the window on the right */
.head {
  width: calc(var(--w) * 3 + var(--gap) * 2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  opacity: 0;
}

.brand {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5em;
  font-size: clamp(12px, 1.4vw, 15px);
  font-weight: 620;
  font-stretch: 118%;
  letter-spacing: 0.01em;
}

.brand__mark {
  width: 1.2em;
  height: 1.2em;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.4;
  stroke-linecap: round;
}

.head__note {
  margin: 0;
  font-size: clamp(10.5px, 1.1vw, 12.5px);
  font-weight: 450;
  font-stretch: 104%;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.row {
  position: relative;
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: var(--gap);
}

.card {
  --l: 0;
  --d: 0;
  --g: 0;
  --gx: 30%;
  --gy: 20%;
  --sx: -60%;
  position: relative;
  width: var(--w);
  container-type: inline-size;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* the part GSAP moves: tilt, rise and press */
.card__body {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  will-change: transform;
}

.card__shadow {
  position: absolute;
  inset: 0;
  border-radius: 14px;
  pointer-events: none;
}

.card__shadow--rest {
  box-shadow:
    0 1px 1px rgba(0, 0, 0, 0.35),
    0 4px 8px -2px rgba(0, 0, 0, 0.4),
    0 12px 24px -10px rgba(0, 0, 0, 0.55);
}

/* the shadow of the risen card: long, soft and warm at its edge, it grows with --l */
.card__shadow--lift {
  opacity: var(--l);
  box-shadow:
    0 2px 3px rgba(0, 0, 0, 0.3),
    0 10px 18px -6px rgba(0, 0, 0, 0.45),
    0 26px 44px -16px rgba(0, 0, 0, 0.7),
    0 48px 70px -30px rgba(0, 0, 0, 0.8),
    0 30px 60px -34px rgba(226, 183, 124, 0.22);
}

.card__frame {
  position: absolute;
  inset: 0;
  border-radius: 14px;
  overflow: hidden;
  background: var(--card);
  isolation: isolate;
}

.card__photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(calc((1.04 + 0.03 * var(--l)) * var(--z, 1)));
  filter: brightness(calc(0.94 + 0.08 * var(--l) - 0.4 * var(--d))) saturate(calc(1 - 0.38 * var(--d)));
}

.card__photo--linden {
  --z: 1.32;
  object-position: 50% 50%;
  transform-origin: 54% 54%;
}

.card__photo--onyx {
  --z: 1.6;
  object-position: 50% 47%;
  transform-origin: 54% 47%;
}

.card__photo--nocturne {
  --z: 1.15;
  object-position: 14% 50%;
  transform-origin: 40% 35%;
}

.card__vignette {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 90% at 50% 40%, transparent 55%, rgba(10, 7, 4, 0.5)),
    linear-gradient(to top, rgba(10, 7, 4, 0.45), transparent 32%);
}

/* the specular light on the glass: a soft wide pool in soft-light and a small hot core in screen */
.card__glare,
.card__glare::after {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.card__glare {
  opacity: var(--g);
  mix-blend-mode: soft-light;
  background: radial-gradient(circle at var(--gx) var(--gy),
    rgba(var(--light), 1) 0%, rgba(var(--light), 0.75) 18%, rgba(var(--light), 0.25) 38%, transparent 60%);
}

.card__glare::after {
  content: '';
  mix-blend-mode: screen;
  opacity: 0.9;
  background: radial-gradient(circle at var(--gx) var(--gy),
    rgba(var(--light), 0.8) 0%, rgba(var(--light), 0.34) 7%, rgba(var(--light), 0.1) 19%, transparent 34%);
}

/* the long diagonal reflection, the kind a window leaves on a watch glass; it slides opposite to the pointer */
.card__streak {
  position: absolute;
  inset: 0;
  overflow: hidden;
  mix-blend-mode: screen;
  opacity: calc(var(--g) * 0.85);
  pointer-events: none;
}

.card__streak i {
  position: absolute;
  top: -20%;
  bottom: -20%;
  left: 0;
  width: 100%;
  translate: var(--sx) 0;
  background: linear-gradient(104deg,
    transparent 30%,
    rgba(var(--light), 0.05) 40%,
    rgba(var(--light), 0.2) 46%,
    rgba(var(--light), 0.07) 49%,
    rgba(var(--light), 0.16) 52%,
    transparent 60%);
}

.card__grain {
  position: absolute;
  inset: 0;
  opacity: 0.16;
  mix-blend-mode: overlay;
  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='1.1' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* the 1px rim: faint all around, bright only near the light */
.card__rim {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: radial-gradient(circle at var(--gx) var(--gy),
    rgba(var(--light), calc(0.12 + 0.7 * var(--g))) 0%, rgba(var(--light), 0.1) 38%, rgba(255, 255, 255, 0.06) 70%);
  -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;
}

/* under the card: a hairline that draws itself, the name and the price that rise into place */
.card__info {
  position: relative;
  padding-top: min(14px, 2.6vh);
}

.card__rule {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 1px;
  background: linear-gradient(90deg, var(--accent), rgba(226, 183, 124, 0.15));
  transform-origin: 0 50%;
  transform: scaleX(0.14);
  opacity: 0.45;
}

.card__line {
  margin: 0;
  overflow: hidden;
  padding-bottom: 0.12em;
}

.card__line--price {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-top: 0.2em;
}

.card__name,
.card__price,
.card__view {
  display: inline-block;
  transform: translateY(110%);
}

.card__name {
  font-size: clamp(11px, 8cqi, 16.5px);
  font-weight: 600;
  font-stretch: 112%;
  letter-spacing: -0.005em;
  white-space: nowrap;
}

.card__price {
  font-size: clamp(10px, 6.4cqi, 13.5px);
  font-weight: 480;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.card__view {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  font-size: clamp(10px, 5.8cqi, 12.5px);
  font-weight: 540;
  font-stretch: 108%;
  color: var(--accent);
}

.card__view svg {
  width: 1em;
  height: 1em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@container (max-width: 140px) {
  .card__view {
    font-size: 0;
    gap: 0;
  }

  .card__view svg {
    width: 11px;
    height: 11px;
  }
}

@media (hover: hover) {
  .card:hover .card__view svg {
    transform: translateX(2px);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .card__photo {
    transform: scale(calc(1.04 * var(--z, 1)));
  }
}
