/* The wool throw product card with a lens on the knit: the product card of a made-up mill of wool throws on a warm
   paper page. The photo is a real close-up of the knit; over it a round glass opens under the pointer and shows the
   stitches bigger, with a small yarn tag swinging below; the swatches change the photo with a soft curtain. */
:root {
  --page: #efeae2;          /* the page */
  --card: #fbf8f3;          /* the card */
  --edge: rgba(60, 44, 28, 0.09); /* the hairline around the card */
  --ink: #23201c;           /* the words */
  --muted: #8a8177;         /* the small words */
  --accent: #b5522a;        /* the one colour: the swatch ring, the check */
  --button: #23201c;        /* the button */
  --button-ink: #f6f1e9;    /* the words on the button */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

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

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

.stage {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: clamp(10px, 3vh, 40px) clamp(10px, 3vw, 40px);
  overflow: hidden;
  background:
    radial-gradient(60% 55% at 30% 20%, rgba(255, 252, 246, 0.9), rgba(255, 252, 246, 0) 70%),
    radial-gradient(70% 60% at 80% 100%, rgba(196, 170, 140, 0.22), rgba(196, 170, 140, 0) 70%),
    var(--page);
}

/* ---------------------------------------------------------------- the card */
.card {
  --photo: min(42vw, 72vh, 470px);
  position: relative;
  display: grid;
  grid-template-columns: var(--photo) minmax(0, 290px);
  gap: clamp(20px, 3.4vw, 40px);
  align-items: center;
  padding: clamp(10px, 1.6vw, 16px);
  padding-right: clamp(16px, 3vw, 36px);
  border-radius: 26px;
  background: var(--card);
  box-shadow:
    0 0 0 1px var(--edge),
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 2px 4px rgba(60, 40, 20, 0.04),
    0 12px 24px -8px rgba(60, 40, 20, 0.1),
    0 40px 80px -24px rgba(60, 40, 20, 0.22);
}

/* ---------------------------------------------------------------- the photo */
.photo {
  position: relative;
  width: var(--photo);
  height: var(--photo);
  touch-action: none;
  cursor: none;
}

.photo__clip {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 18px;
  background: #ddd3c4;
  box-shadow: 0 0 0 1px rgba(40, 28, 16, 0.08) inset;
}

.photo__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

.photo__img--top {
  visibility: hidden;
}

/* the soft edge of the curtain: a wide band of light riding the cut */
.photo__edge {
  position: absolute;
  top: -10%;
  left: 0;
  width: 70px;
  height: 120%;
  margin-left: -35px;
  background: linear-gradient(90deg, rgba(255, 250, 240, 0), rgba(255, 250, 240, 0.55) 50%, rgba(255, 250, 240, 0));
  filter: blur(6px);
  opacity: 0;
  pointer-events: none;
}

.photo__dim {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  background: radial-gradient(circle at var(--lx, 50%) var(--ly, 50%), rgba(26, 18, 10, 0) var(--r1, 60px), rgba(26, 18, 10, 0.32) var(--r2, 180px));
}

.photo__grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.12;
  mix-blend-mode: overlay;
  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");
}

.photo__chip {
  position: absolute;
  left: 12px;
  top: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 11px 0 9px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--ink);
  background: rgba(251, 248, 243, 0.78);
  -webkit-backdrop-filter: blur(10px) saturate(1.3);
  backdrop-filter: blur(10px) saturate(1.3);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.5) inset, 0 4px 14px rgba(40, 24, 10, 0.12);
  pointer-events: none;
}

.photo__chip svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
}

.photo__chip-words {
  position: relative;
  display: grid;
  overflow: hidden;
  height: 16px;
  line-height: 16px;
}

.photo__chip-words > span {
  grid-area: 1 / 1;
  justify-self: start;
  white-space: nowrap;
}

/* ---------------------------------------------------------------- the lens */
.lens {
  position: absolute;
  left: 0;
  top: 0;
  width: calc(var(--r, 80px) * 2);
  height: calc(var(--r, 80px) * 2);
  pointer-events: none;
  z-index: 3;
}

.lens__pop {
  width: 100%;
  height: 100%;
  visibility: hidden;
}

.lens__glass {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.85),
    0 0 0 4px rgba(255, 252, 246, 0.35),
    0 0 0 5px rgba(40, 26, 12, 0.12),
    0 14px 28px -6px rgba(30, 18, 6, 0.38),
    0 30px 60px -18px rgba(30, 18, 6, 0.4);
}

.lens__view {
  position: absolute;
  inset: 0;
  background-repeat: no-repeat;
  background-color: #ddd3c4;
}

/* the curve of the glass: darker at the rim, like a real loupe */
.lens__shade {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, rgba(0, 0, 0, 0) 58%, rgba(20, 12, 4, 0.16) 86%, rgba(20, 12, 4, 0.34) 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35), inset 0 -6px 14px rgba(255, 245, 230, 0.18);
}

.lens__shine {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background:
    radial-gradient(48% 30% at 34% 18%, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0) 70%),
    radial-gradient(30% 14% at 66% 88%, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0) 70%);
  mix-blend-mode: screen;
}

.lens__ticks {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: rgba(255, 255, 255, 0.55);
  stroke-width: 0.6;
  stroke-dasharray: 0.5 3.15;
  transform-origin: 50% 50%;
}

/* the yarn tag that hangs under the glass */
.tag {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 4;
  display: grid;
  gap: 1px;
  padding: 7px 12px 8px 22px;
  border-radius: 10px;
  background: rgba(251, 248, 243, 0.94);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  box-shadow: 0 0 0 1px rgba(60, 40, 20, 0.08), 0 8px 18px -4px rgba(40, 24, 10, 0.25);
  white-space: nowrap;
  pointer-events: none;
  visibility: hidden;
  transform-origin: 50% 0;
}

.tag__hole {
  position: absolute;
  left: 9px;
  top: 50%;
  width: 6px;
  height: 6px;
  margin-top: -3px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1.2px rgba(60, 40, 20, 0.35);
}

.tag__yarn {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
}

.tag__ply {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- the words */
.info {
  display: grid;
  align-content: center;
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 18px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.brand__mark {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.4;
  stroke-linecap: round;
}

.brand__warp {
  stroke: var(--accent);
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.title {
  margin: 0;
  font-family: 'Fraunces Variable', Georgia, serif;
  font-weight: 420;
  font-size: clamp(24px, 2.6vw, 32px);
  line-height: 1.05;
  letter-spacing: -0.01em;
  font-variation-settings: 'SOFT' 60, 'opsz' 72;
}

.price {
  margin: 0;
  font-size: 17px;
  font-weight: 560;
  font-variant-numeric: tabular-nums;
}

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

/* a word that changes by rolling: the old one goes up, the new one comes from below */
.roll {
  position: relative;
  display: inline-grid;
  overflow: hidden;
  vertical-align: bottom;
}

.roll > span {
  grid-area: 1 / 1;
  white-space: nowrap;
}

.colour {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid rgba(60, 40, 20, 0.09);
}

.colour__label {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--muted);
}

.colour__name {
  margin-left: 4px;
  color: var(--ink);
  font-weight: 560;
}

.swatches {
  position: relative;
  display: flex;
  gap: 12px;
}

.swatch {
  position: relative;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  background: var(--img) center / 260% no-repeat;
  box-shadow: inset 0 0 0 1px rgba(40, 24, 10, 0.12), inset 0 -4px 8px rgba(30, 16, 4, 0.18), 0 2px 4px rgba(40, 24, 10, 0.12);
  -webkit-tap-highlight-color: transparent;
}

.swatch::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(60% 40% at 35% 25%, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0));
}

.swatch:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 6px;
}

.swatches__ring {
  position: absolute;
  left: 0;
  top: 0;
  width: 46px;
  height: 46px;
  margin: -5px 0 0 -5px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1.5px var(--accent);
  pointer-events: none;
}

.facts {
  list-style: none;
  margin: 20px 0 0;
  padding: 0;
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.buy {
  margin-top: 22px;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.buy__face {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 48px;
  padding: 0 22px;
  border-radius: 99px;
  color: var(--button-ink);
  background: linear-gradient(180deg, #3a352f, var(--button));
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.14) inset, 0 0 0 1px rgba(0, 0, 0, 0.2), 0 10px 20px -8px rgba(30, 18, 6, 0.5);
  font-size: 14px;
  font-weight: 560;
}

.buy__icon {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.buy__check {
  stroke: #f0b48f;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

@media (hover: hover) {
  .swatch:hover {
    filter: brightness(1.06);
  }
}

/* the drawn pointer of the tour on its own */
.ghost {
  position: absolute;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  z-index: 10;
  pointer-events: none;
  visibility: hidden;
  fill: #fff;
  stroke: var(--ink);
  stroke-width: 1.4;
  stroke-linejoin: round;
  filter: drop-shadow(0 3px 4px rgba(30, 18, 6, 0.3));
}

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

/* ---------------------------------------------------------------- narrow screens: photo on top, words below */
@media (max-width: 640px) {
  .card {
    grid-template-columns: minmax(0, 1fr);
    width: min(100%, 420px);
    gap: 12px;
    padding: 10px 10px 14px;
    border-radius: 22px;
  }

  .photo {
    width: 100%;
    height: min(64vw, 44vh);
  }

  .photo__clip {
    border-radius: 14px;
  }

  .info {
    padding: 0 6px;
  }

  .brand,
  .eyebrow,
  .facts {
    display: none;
  }

  .title {
    font-size: clamp(20px, 6vw, 26px);
  }

  .price {
    font-size: 15px;
  }

  .size {
    font-size: 12px;
    margin-top: 2px;
  }

  .colour {
    margin-top: min(12px, 2.4vh);
    padding-top: min(10px, 2vh);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }

  .colour__label {
    margin: 0;
    font-size: 12px;
  }

  .colour__label .colour__name {
    display: grid;
    margin: 2px 0 0;
  }

  .swatch {
    width: 30px;
    height: 30px;
  }

  .swatches {
    gap: 10px;
  }

  .swatches__ring {
    width: 40px;
    height: 40px;
  }

  .buy {
    margin-top: min(12px, 2.4vh);
    width: 100%;
  }

  .buy__face {
    height: min(42px, 10vh);
  }
}

@media (min-width: 641px) and (max-height: 560px) {
  .facts,
  .eyebrow {
    display: none;
  }

  .brand {
    margin-bottom: 10px;
  }
}
