:root {
  --fondo: #efede8;
  --inchiostro: #1b1a18;
  --grigio: #8d8a84;
  --accento: #e8552f;
  --cartone: #e6d3b3;
  --cartone-chiaro: #efdfc3;
  --cartone-scuro: #cdb48c;
  --cartone-dentro: #b99c72;
  --cartone-fondo: #9e8160;
  --nastro: rgba(201, 168, 112, 0.82);
  --altoparlante: #2a2a2c;
  --altoparlante-lato: #1f1f21;
}

* { box-sizing: border-box; margin: 0; }

html, body { height: 100%; overflow: hidden; }

body {
  background: var(--fondo);
  color: var(--inchiostro);
  font-family: "Mona Sans Variable", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.stage {
  position: relative;
  height: 100vh;
  overflow: clip;
  touch-action: none;
  user-select: none;
  cursor: grab;
  background:
    radial-gradient(60% 52% at 50% 52%, #f8f7f3 0%, transparent 72%),
    var(--fondo);
}

.stage.is-holding { cursor: grabbing; }

.head {
  position: absolute;
  top: clamp(14px, 5vh, 40px);
  left: 0;
  right: 0;
  text-align: center;
  z-index: 3;
  pointer-events: none;
}

.head__brand {
  font-size: clamp(15px, 2.6vh, 20px);
  font-weight: 680;
  font-stretch: 112%;
  letter-spacing: 0.01em;
}

.head__line {
  margin-top: 3px;
  font-size: clamp(11px, 1.8vh, 14px);
  color: var(--grigio);
  font-weight: 450;
}

.head__line span { display: inline-block; color: var(--inchiostro); }

/* the scene is drawn in its own pixels (400 by 400) and the wrapper scales it to the box, height included */
.fit {
  position: absolute;
  left: 50%;
  top: 53%;
  width: 400px;
  height: 400px;
  transform: translate(-50%, -50%);
}

.scene {
  position: absolute;
  inset: 0;
  perspective: 1300px;
  perspective-origin: 50% 34%;
}

.floor {
  position: absolute;
  left: 50%;
  top: 70%;
  width: 300px;
  height: 64px;
  margin-left: -150px;
  margin-top: -32px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(40, 30, 18, 0.32), rgba(40, 30, 18, 0));
  filter: blur(7px);
}

.turn,
.origin,
.side,
.hinge,
.prod,
.prod__spin,
.paper {
  position: absolute;
  transform-style: preserve-3d;
}

.turn {
  left: 50%;
  top: 56%;
  width: 0;
  height: 0;
}

.origin { left: 0; top: 0; width: 0; height: 0; }

.side, .hinge, .prod, .prod__spin, .paper { left: 0; top: 0; width: 0; height: 0; }

.face {
  position: absolute;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* cardboard: a faint fibre and a vertical flute that shows through the paper */
.out {
  background:
    repeating-linear-gradient(90deg, rgba(120, 90, 50, 0.035) 0 2px, transparent 2px 6px),
    linear-gradient(180deg, var(--cartone-chiaro), var(--cartone));
  box-shadow: inset 0 0 0 1px rgba(110, 80, 40, 0.18);
}

.out--dark {
  background:
    repeating-linear-gradient(90deg, rgba(120, 90, 50, 0.04) 0 2px, transparent 2px 6px),
    linear-gradient(180deg, var(--cartone), var(--cartone-scuro));
}

.in {
  background:
    repeating-linear-gradient(90deg, rgba(80, 55, 25, 0.05) 0 2px, transparent 2px 6px),
    linear-gradient(180deg, var(--cartone-dentro), var(--cartone-fondo));
  box-shadow: inset 0 18px 26px -10px rgba(40, 25, 10, 0.4);
}

.bottom-in {
  background: radial-gradient(70% 70% at 50% 50%, #a88a64, #7d6346);
}

.flap-out {
  background:
    repeating-linear-gradient(0deg, rgba(120, 90, 50, 0.035) 0 2px, transparent 2px 6px),
    linear-gradient(180deg, var(--cartone-chiaro), var(--cartone));
  box-shadow: inset 0 0 0 1px rgba(110, 80, 40, 0.18);
  border-radius: 2px 2px 0 0;
}

.flap-in {
  background: linear-gradient(180deg, #d8c19a, var(--cartone-dentro));
  box-shadow: inset 0 0 0 1px rgba(110, 80, 40, 0.16);
  border-radius: 2px 2px 0 0;
}

/* the brand printed on the right side and the label on the front */
.print {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  color: rgba(40, 30, 18, 0.82);
}

.print__mark { width: 30px; height: 30px; margin: 0 auto 6px; fill: none; stroke: currentColor; stroke-width: 1.4; }
.print__name { font-size: 22px; font-weight: 720; font-stretch: 118%; letter-spacing: 0.04em; }
.print__sub { margin-top: 2px; font-size: 9px; letter-spacing: 0.18em; text-transform: uppercase; opacity: 0.7; }

.label {
  position: absolute;
  right: 14px;
  bottom: 14px;
  width: 76px;
  padding: 6px 7px;
  border-radius: 3px;
  background: var(--accento);
  color: #fff;
  font-size: 8px;
  line-height: 1.25;
  font-weight: 600;
  letter-spacing: 0.04em;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
}

.label b { display: block; font-size: 10px; font-weight: 720; letter-spacing: 0.02em; }

.updir { position: absolute; left: 12px; bottom: 12px; width: 22px; height: 22px; fill: none; stroke: rgba(40, 30, 18, 0.55); stroke-width: 1.4; }

/* the tape: what is left of it after it was torn, on the front and on the edge of the flap */
.tape {
  position: absolute;
  left: 50%;
  width: 34px;
  margin-left: -17px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.18), transparent 40%, rgba(255, 255, 255, 0.12)), var(--nastro);
}

.tape--wall {
  top: 0;
  height: 30px;
  clip-path: polygon(0 0, 100% 0, 100% 78%, 88% 92%, 76% 80%, 62% 100%, 48% 84%, 34% 96%, 20% 82%, 8% 94%, 0 84%);
}

.tape--flap {
  bottom: 0;
  height: 20px;
  clip-path: polygon(0 100%, 100% 100%, 100% 20%, 86% 6%, 72% 22%, 58% 0, 44% 18%, 30% 4%, 16% 20%, 0 8%);
}

/* tissue paper: white, a little see-through, crinkled */
.tissue {
  background:
    linear-gradient(115deg, transparent 0 18%, rgba(255, 255, 255, 0.5) 22%, transparent 30% 46%, rgba(255, 255, 255, 0.45) 52%, transparent 60%),
    linear-gradient(70deg, rgba(210, 205, 196, 0.35) 0 10%, transparent 14% 38%, rgba(210, 205, 196, 0.3) 44%, transparent 50% 72%, rgba(210, 205, 196, 0.32) 78%, transparent 84%),
    rgba(250, 249, 246, 0.97);
  box-shadow: inset 0 0 0 1px rgba(160, 150, 135, 0.18);
  clip-path: polygon(0 4%, 9% 0, 21% 5%, 33% 1%, 46% 6%, 58% 0, 71% 4%, 84% 0, 100% 5%, 100% 100%, 0 100%);
}

.tissue--back { background: linear-gradient(180deg, #ece8df, #e2ddd2); }

/* the speaker: a small cube with fabric on the front and back and a light ring on top */
.spk { border-radius: 5px; }

.spk--fabric {
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.13) 0 0.9px, transparent 1.3px) 0 0 / 5px 5px,
    linear-gradient(180deg, #38383b, var(--altoparlante));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.spk--side { background: linear-gradient(180deg, #2e2e31, var(--altoparlante-lato)); }

.spk--top {
  background:
    radial-gradient(circle at 50% 50%, transparent 0 15px, var(--accento) 15.5px 18px, transparent 18.5px),
    radial-gradient(circle at 50% 50%, #3b3b3f, #28282b);
}

.spk--bottom { background: #161618; }

.spk__badge {
  position: absolute;
  left: 50%;
  bottom: 8px;
  transform: translateX(-50%);
  font-size: 7px;
  letter-spacing: 0.22em;
  color: rgba(255, 255, 255, 0.55);
  text-transform: uppercase;
}

.spk__glint {
  position: absolute;
  inset: 0;
  border-radius: 9px;
  background: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, 0.16) 46%, transparent 60%);
  background-size: 260% 100%;
  background-position: var(--glint, 80%) 0;
}

.prodshadow {
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(30, 20, 10, 0.45), rgba(30, 20, 10, 0));
}

.hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: clamp(12px, 5vh, 40px);
  text-align: center;
  font-size: clamp(11px, 1.8vh, 13px);
  color: var(--grigio);
  pointer-events: none;
}

.pointer {
  position: absolute;
  left: 0;
  top: 0;
  width: 26px;
  height: 26px;
  margin: -4px 0 0 -5px;
  fill: var(--inchiostro);
  stroke: #fff;
  stroke-width: 1.4;
  stroke-linejoin: round;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.2));
  opacity: 0;
  pointer-events: none;
  z-index: 5;
}

@media (prefers-reduced-motion: reduce) {
  .pointer { display: none; }
}
