:root {
  --fondo: #ffffff;
  --carta: #ffffff;
  --foglio: #f7f3ee;
  --foglio-scuro: #ebe4da;
  --inchiostro: #17181c;
  --grigio: #6c6f78;
  --tenue: #a7aab2;
  --linea: rgba(23, 24, 28, 0.08);
  --accento: #b4532a;
  --accento-tenue: rgba(180, 83, 42, 0.1);
  --stella: #eaa53a;
  --stella-vuota: #e9e7e3;
  --verde: #2f7d5b;
  --font: 'Mona Sans Variable', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--fondo);
  color: var(--inchiostro);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }

.stage {
  position: relative;
  height: 100vh;
  display: grid;
  place-items: center;
  overflow: hidden;
}

/* scaled by the script so card and open reply always fit the window */
.fit { transform-origin: 50% 50%; }
.group { position: relative; width: 352px; }

/* ---------- the card ---------- */
.review {
  --mx: 70%;
  position: relative;
  z-index: 2;
  padding: 20px 20px 16px;
  border-radius: 20px;
  background: var(--carta);
  box-shadow:
    0 0 0 1px var(--linea),
    0 1px 2px rgba(23, 24, 28, 0.04),
    0 8px 18px -6px rgba(23, 24, 28, 0.08),
    0 28px 48px -20px rgba(60, 40, 20, 0.16);
  overflow: hidden;
}
/* the 1px edge that catches the light near the pointer */
.review__edge {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: radial-gradient(160px 120px at var(--mx) 0%, rgba(234, 165, 58, 0.55), transparent 70%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}
.review__sheen {
  position: absolute;
  top: -20%;
  bottom: -20%;
  left: 0;
  width: 70px;
  background: linear-gradient(100deg, transparent, rgba(255, 244, 225, 0.75), transparent);
  transform: translateX(-120px) skewX(-14deg);
  pointer-events: none;
  mix-blend-mode: multiply;
  opacity: 0;
}

.review__head { display: flex; align-items: center; gap: 11px; }
.avatar {
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12.5px;
  font-weight: 640;
  letter-spacing: 0.02em;
  color: #6b3a22;
  background: radial-gradient(circle at 30% 25%, #f8e3cf, #e8c3a2 70%);
  box-shadow: inset 0 0 0 1px rgba(107, 58, 34, 0.12), inset 0 -3px 6px rgba(107, 58, 34, 0.1);
}
.review__who { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.review__name { font-size: 14.5px; font-weight: 620; letter-spacing: -0.01em; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 560;
  color: var(--verde);
  white-space: nowrap;
}
.badge svg { width: 14px; height: 14px; }
.badge__ring { fill: rgba(47, 125, 91, 0.12); stroke: var(--verde); stroke-width: 1.1; stroke-linejoin: round; }
.badge__tick { fill: none; stroke: var(--verde); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.review__date { margin-left: auto; align-self: flex-start; font-size: 12px; color: var(--tenue); padding-top: 2px; }

.review__rate { display: flex; align-items: center; gap: 9px; margin-top: 15px; }
.stars { display: block; width: 104px; height: 19px; }
.stars svg { display: block; width: 100%; height: 100%; overflow: visible; }
.star-base { fill: var(--stella-vuota); }
.star-gold { fill: var(--stella); }
.star-glint { fill: url(#glint-grad); }
.review__score { font-size: 13px; font-weight: 640; font-variant-numeric: tabular-nums; color: var(--inchiostro); }

.product {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding: 6px 12px 6px 6px;
  border-radius: 12px;
  background: #faf8f5;
  box-shadow: inset 0 0 0 1px var(--linea);
  width: max-content;
  max-width: 100%;
}
.product__photo {
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(23, 24, 28, 0.06), 0 2px 5px rgba(60, 40, 20, 0.16);
}
.product__photo img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: 57% 62%; }
.product__text { display: flex; flex-direction: column; gap: 1px; }
.product__name { font-size: 12.5px; font-weight: 600; }
.product__meta { font-size: 11px; color: var(--grigio); }

.review__title { margin: 15px 0 0; font-size: 16px; line-height: 1.25; font-weight: 640; letter-spacing: -0.015em; font-stretch: 104%; }
.review__text { margin: 7px 0 0; font-size: 13.5px; line-height: 1.5; color: #45474f; }
.line { display: block; overflow: hidden; white-space: nowrap; }
.line > span { display: inline-block; }

.review__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 15px;
  padding-top: 13px;
  border-top: 1px solid var(--linea);
}
.helpful, .toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 560;
  transition: background-color 0.25s, box-shadow 0.25s, color 0.25s;
}
.helpful { box-shadow: inset 0 0 0 1px var(--linea); color: var(--grigio); }
.helpful__icon { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linejoin: round; overflow: visible; }
.helpful__count {
  display: inline-block;
  min-width: 1.4em;
  height: 1.3em;
  overflow: hidden;
  font-variant-numeric: tabular-nums;
  color: var(--inchiostro);
  text-align: left;
}
.helpful__count span { display: inline-block; }
.helpful[aria-pressed='true'] { color: var(--accento); background: var(--accento-tenue); box-shadow: inset 0 0 0 1px rgba(180, 83, 42, 0.25); }
.helpful[aria-pressed='true'] .helpful__icon { fill: rgba(180, 83, 42, 0.18); }
.helpful[aria-pressed='true'] .helpful__count { color: var(--accento); }

.toggle { color: var(--inchiostro); font-weight: 600; }
.toggle__words { display: inline-block; font-stretch: 100%; transition: font-stretch 0.35s cubic-bezier(.3, 1.4, .5, 1); }
.toggle__chev { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.toggle[aria-expanded='true'] { background: var(--foglio); }
@media (hover: hover) {
  .helpful:hover { background: #f6f5f3; color: var(--inchiostro); }
  .helpful[aria-pressed='true']:hover { background: rgba(180, 83, 42, 0.14); color: var(--accento); }
  .toggle:hover, .toggle.is-hover { background: var(--foglio); }
  .toggle:hover .toggle__words, .toggle.is-hover .toggle__words { font-stretch: 112%; }
}
.helpful:focus-visible, .toggle:focus-visible { outline: 2px solid var(--accento); outline-offset: 2px; }

/* ---------- the shop's reply, folded under the card ---------- */
.reply {
  position: absolute;
  z-index: 1;
  left: 14px;
  right: 14px;
  top: calc(100% - 22px);
  perspective: 900px;
  perspective-origin: 50% 0%;
}
.fold { position: relative; transform-style: preserve-3d; transform-origin: 50% 0%; }
.fold__face { position: relative; background: var(--foglio); }
.fold--a > .fold__face {
  padding: 32px 16px 2px;
  box-shadow: inset 0 0 0 1px rgba(110, 80, 50, 0.08);
}
.fold--b {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
}
.fold--b > .fold__face {
  padding: 0 16px 14px;
  border-radius: 0 0 16px 16px;
  box-shadow: inset 0 0 0 1px rgba(110, 80, 50, 0.08), 0 14px 26px -14px rgba(60, 40, 20, 0.28);
}
/* the light and shadow on each panel while it turns */
.fold__shade {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(60, 40, 20, 0.05), rgba(60, 40, 20, 0.32));
  opacity: 0;
}
.fold--b > .fold__shade { border-radius: 0 0 16px 16px; background: linear-gradient(180deg, rgba(60, 40, 20, 0.34), rgba(60, 40, 20, 0.08)); }
/* the crease between the two panels */
.fold--b > .fold__face::before {
  content: '';
  position: absolute;
  left: 10px;
  right: 10px;
  top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(110, 80, 50, 0.14) 20%, rgba(110, 80, 50, 0.14) 80%, transparent);
}

.reply__head { display: flex; align-items: center; gap: 8px; }
.reply__mark { width: 24px; height: 24px; flex: none; }
.reply__mark-bg { fill: var(--accento); }
.reply__mark-arch, .reply__mark-floor { fill: none; stroke: #fff3e8; stroke-width: 1.6; stroke-linecap: round; }
.reply__mark-flame { fill: #ffd9a8; transform-origin: 14px 18px; }
.reply__who { font-size: 12.5px; color: var(--grigio); }
.reply__who strong { color: var(--inchiostro); font-weight: 640; }
.reply__when { margin-left: auto; font-size: 11.5px; color: var(--tenue); }
.reply__line { margin: 0; padding-top: 9px; font-size: 13px; line-height: 1.45; color: #4a4339; white-space: nowrap; }
.fold--b .reply__line { padding-top: 0; }
.reply__sign { margin: 8px 0 0; font-size: 12px; font-weight: 600; color: var(--accento); white-space: nowrap; }
.reply__sign span { color: var(--tenue); font-weight: 500; }

/* ---------- the drawn pointer of the demo ---------- */
.pointer {
  position: absolute;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  z-index: 5;
  fill: var(--inchiostro);
  stroke: #ffffff;
  stroke-width: 1.4;
  stroke-linejoin: round;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.22));
  opacity: 0;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .toggle__words { transition: none; }
}
