/* =====================================================================
   Letstick — experience layer: hands-on stage (gesture.js) and the
   signature moments added on top of the campaign design.
   ===================================================================== */

/* ---------- hands-on stage overlay ---------- */
.mirror.is-gesture { touch-action: none; cursor: crosshair; -webkit-user-select: none; user-select: none; }
.mirror.is-gesture .ingr { pointer-events: none; }
.g-ui { position: absolute; inset: 0; z-index: 7; pointer-events: none; overflow: hidden; --fx: 50%; --fy: 40%; }

/* instruction pill: three or four words, only while a gesture is expected */
.g-pill {
  position: absolute; left: 50%; top: calc(env(safe-area-inset-top) + 74px); translate: -50% -8px;
  display: flex; align-items: center; gap: 9px; white-space: nowrap;
  padding: 9px 16px 9px 14px; border-radius: 999px;
  background: rgba(18, 13, 10, .62); border: 1px solid rgba(242, 220, 142, .35); color: var(--ivory);
  font-weight: 600; font-size: .95rem; box-shadow: 0 14px 30px rgba(0, 0, 0, .35);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  opacity: 0; transition: opacity .35s, translate .5s cubic-bezier(.2, .8, .2, 1);
}
.g-pill__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--butter); box-shadow: 0 0 0 0 rgba(242, 220, 142, .6); animation: gDot 1.6s ease-out infinite; }
@keyframes gDot { 70% { box-shadow: 0 0 0 9px rgba(242, 220, 142, 0); } 100% { box-shadow: 0 0 0 0 rgba(242, 220, 142, 0); } }
.g-ui[data-mode]:not([data-mode=""]) .g-pill { opacity: 1; translate: -50% 0; }
.g-ui.is-touching .g-pill { opacity: .35; }

/* progress along the photo's lower edge */
.g-bar { position: absolute; left: 22px; right: 22px; bottom: 10px; height: 3px; border-radius: 2px; background: rgba(246, 238, 225, .18); opacity: 0; transition: opacity .3s; }
.g-bar i { position: absolute; inset: 0; border-radius: inherit; background: linear-gradient(90deg, var(--gold), var(--butter), #FFF6D6);
  transform: scaleX(0); transform-origin: right center; transition: transform .25s ease-out; box-shadow: 0 0 12px rgba(242, 220, 142, .6); }
.g-ui[data-mode]:not([data-mode=""]) .g-bar { opacity: 1; }

/* the tool rides on the finger */
.g-tool { position: absolute; left: 0; top: 0; opacity: 0; transition: opacity .2s; will-change: transform; filter: drop-shadow(0 14px 16px rgba(0, 0, 0, .5)); }
.g-tool--amber, .g-tool--blue { height: 118px; width: auto; transform: translate(calc(var(--fx) + 4px), calc(var(--fy) - 126px)) rotate(-24deg); transform-origin: 20% 10%; }
.g-tool--blue { height: 104px; }
.g-tool--comb { width: 128px; height: 36px; fill: var(--ivory); transform: translate(calc(var(--fx) - 64px), calc(var(--fy) - 14px)); }
.g-ui[data-mode="spray-amber"].is-touching .g-tool--amber,
.g-ui[data-mode="spray-blue"].is-touching .g-tool--blue,
.g-ui[data-mode="comb"].is-touching .g-tool--comb { opacity: 1; }
.g-ui[data-mode="spray-amber"].is-touching .g-tool--amber,
.g-ui[data-mode="spray-blue"].is-touching .g-tool--blue { animation: gPump .7s ease-in-out infinite; }
@keyframes gPump { 50% { filter: drop-shadow(0 14px 16px rgba(0, 0, 0, .5)) brightness(1.08); } }

/* hold ring around the finger */
.g-ring { position: absolute; left: 0; top: 0; width: 104px; height: 104px; opacity: 0; transition: opacity .2s;
  transform: translate(calc(var(--fx) - 52px), calc(var(--fy) - 52px)) rotate(-90deg); }
.g-ring circle { fill: none; }
.g-ring__track { stroke: rgba(246, 238, 225, .28); stroke-width: 4; }
.g-ring__fill { stroke: var(--butter); stroke-width: 6; stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: 100; filter: drop-shadow(0 0 6px rgba(242, 220, 142, .8)); }
.g-ui[data-mode="hold"].is-touching .g-ring { opacity: 1; }

/* ghost finger shows the move when she hesitates */
.g-hand { position: absolute; left: 0; top: 0; width: 46px; height: 46px; margin: -23px 0 0 -23px; opacity: 0; transition: opacity .4s; }
.g-hand i { position: absolute; inset: 0; border-radius: 50%; background: rgba(255, 255, 255, .55); border: 2px solid #fff;
  box-shadow: 0 0 0 8px rgba(255, 255, 255, .18), 0 8px 18px rgba(0, 0, 0, .35); }
.g-ui.is-idle:not(.is-touching)[data-mode]:not([data-mode=""]) .g-hand { opacity: 1; }
.g-ui[data-mode^="spray"] .g-hand { animation: gRub 2.4s ease-in-out infinite; }
.g-ui[data-mode="comb"] .g-hand { animation: gComb 1.6s cubic-bezier(.5, 0, .3, 1) infinite; }
.g-ui[data-mode="hold"] .g-hand { left: 50%; top: 38%; animation: gPress 1.6s ease-in-out infinite; }
@keyframes gRub { 0% { left: 30%; top: 26%; } 25% { left: 70%; top: 32%; } 50% { left: 34%; top: 42%; } 75% { left: 68%; top: 50%; } 100% { left: 30%; top: 26%; } }
@keyframes gComb { 0% { left: 58%; top: 16%; opacity: 0; } 15% { opacity: 1; } 80% { left: 58%; top: 70%; opacity: 1; } 100% { left: 58%; top: 74%; opacity: 0; } }
@keyframes gPress { 0%, 100% { transform: scale(1); } 40% { transform: scale(.78); } }

/* a band of light runs down the photo when a step lands */
.g-sweep { position: absolute; left: 0; right: 0; top: 0; height: 38%; transform: translateY(-110%); mix-blend-mode: screen;
  background: linear-gradient(180deg, transparent, rgba(255, 244, 214, .38) 50%, transparent); }
.g-sweep.is-on { animation: gSweep 1.1s cubic-bezier(.4, 0, .2, 1) both; }
@keyframes gSweep { to { transform: translateY(300%); } }

@media (prefers-reduced-motion: reduce) {
  .g-hand, .g-pill__dot, .g-tool { animation: none !important; }
  .g-sweep.is-on { animation: none; }
}

/* ---------- depth transition: the old screen moves toward you, the new one settles in ---------- */
.screen { transform: scale(.955); transition: opacity .55s cubic-bezier(.2, .8, .2, 1), transform .8s cubic-bezier(.2, .8, .2, 1), visibility 0s .55s; }
.screen.is-active { transform: none; transition: opacity .6s cubic-bezier(.2, .8, .2, 1) .08s, transform .8s cubic-bezier(.2, .8, .2, 1), visibility 0s; }
.screen.is-leaving { transform: scale(1.06); }

/* the picked card grows into the stage photo */
.xp-hero { position: fixed; z-index: 40; object-fit: cover; pointer-events: none; box-shadow: 0 30px 60px rgba(0, 0, 0, .45); }

/* ---------- splash gold dust ---------- */
.xp-dust { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; mix-blend-mode: screen; }
.screen--splash .stage-scene { transform: perspective(900px) rotateY(calc(var(--tilt-x, 0deg) * .35)) rotateX(calc(var(--tilt-y, 0deg) * .35)) scale(1.04); transition: transform .3s ease-out; }

/* ---------- quiz: hair-type answers are hair photos ---------- */
.quiz__opts.is-photos { grid-template-columns: 1fr 1fr; }
.quiz__opt.quiz__opt--photo, .quiz__opt.quiz__opt--photo:hover {
  min-height: 138px; color: var(--ivory); text-shadow: 0 2px 10px rgba(0, 0, 0, .6);
  background:
    linear-gradient(0deg, rgba(18, 13, 10, .88) 0%, rgba(18, 13, 10, .15) 58%, rgba(18, 13, 10, 0) 100%) padding-box,
    var(--swatch) 18% 74% / 230% auto no-repeat padding-box,
    radial-gradient(180px circle at var(--mx) var(--my), rgba(242, 220, 142, .9), rgba(246, 238, 225, .18) 60%) border-box;
}
.quiz__opt.quiz__opt--photo.is-picked {
  color: var(--espresso); text-shadow: none;
  background:
    linear-gradient(0deg, rgba(242, 220, 142, .95) 0%, rgba(242, 220, 142, .2) 60%, rgba(242, 220, 142, 0) 100%) padding-box,
    var(--swatch) 18% 74% / 230% auto no-repeat padding-box,
    linear-gradient(var(--butter), var(--gold)) border-box;
}

/* ---------- buy: the bottles drop into the Letstick bag ---------- */
.xp-bag { position: fixed; inset: 0; z-index: 60; pointer-events: none; display: grid; place-items: center; }
.xp-bag__veil { position: absolute; inset: 0; background: radial-gradient(90% 70% at 50% 60%, rgba(42, 28, 18, .92), rgba(18, 13, 10, .97)); opacity: 0; transition: opacity .45s; }
.xp-bag.is-on .xp-bag__veil { opacity: 1; }
.xp-bag__bag { position: absolute; left: 50%; bottom: 14%; width: min(64vw, 300px); height: auto; translate: -50% 0; z-index: 2;
  filter: drop-shadow(0 30px 40px rgba(0, 0, 0, .55)); opacity: 0; transform: translateY(60px) scale(.9);
  transition: opacity .45s, transform .7s cubic-bezier(.2, 1.3, .3, 1); }
.xp-bag.is-on .xp-bag__bag { opacity: 1; transform: none; }
.xp-bag.is-in .xp-bag__bag { animation: xpBagBump .55s cubic-bezier(.3, 1.6, .4, 1); }
@keyframes xpBagBump { 35% { transform: scale(1.04, .93); } 70% { transform: scale(.98, 1.03); } }
.xp-bag__bottle { position: absolute; left: 50%; top: 14%; height: min(30vh, 260px); width: auto; z-index: 1;
  --dx: calc((var(--i) - (var(--n) - 1) / 2) * 34%);
  translate: calc(-50% + var(--dx)) 0;
  filter: drop-shadow(0 22px 22px rgba(0, 0, 0, .5)); opacity: 0; transform: translateY(-40px) rotate(calc((var(--i) - .5) * 10deg));
  transition: opacity .4s calc(var(--i) * .08s), transform .6s cubic-bezier(.2, .8, .2, 1) calc(var(--i) * .08s); }
.xp-bag__bottle--blue { height: min(26vh, 225px); }
.xp-bag.is-on .xp-bag__bottle { opacity: 1; transform: translateY(0) rotate(calc((var(--i) - .5) * 6deg)); }
.xp-bag.is-drop .xp-bag__bottle { transform: translateY(46vh) rotate(calc((var(--i) - .5) * -8deg)) scale(.62);
  transition: transform .62s cubic-bezier(.55, 0, .75, .4) calc(var(--i) * .1s), opacity .2s .5s; }
.xp-bag.is-in .xp-bag__bottle { opacity: 0; }
.xp-bag__note { position: absolute; left: 0; right: 0; bottom: calc(5% + env(safe-area-inset-bottom)); margin: 0; z-index: 3; text-align: center;
  color: var(--ivory); font-size: 1rem; opacity: 0; transform: translateY(10px); transition: opacity .4s, transform .5s; }
.xp-bag__note b { color: var(--butter); font-family: var(--latin); letter-spacing: .08em; }
.xp-bag.is-in .xp-bag__note { opacity: 1; transform: none; }

/* ---------- gift: holographic finish ---------- */
.scratch.is-holo .scratch__card { animation: xpFlip .9s cubic-bezier(.2, .8, .2, 1), float 5s ease-in-out 1s infinite !important; }
@keyframes xpFlip { from { transform: rotateY(-180deg) scale(.92); } }
.scratch__inside::after { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; mix-blend-mode: overlay;
  background: linear-gradient(115deg, transparent 20%, rgba(255, 214, 140, .55) 34%, rgba(170, 215, 255, .45) 44%, rgba(255, 175, 215, .4) 54%, rgba(255, 236, 170, .5) 62%, transparent 76%) 0 0 / 260% 100%; }
.scratch.is-holo .scratch__inside::after { opacity: 1; animation: xpHolo 4.5s ease-in-out infinite alternate; }
@keyframes xpHolo { from { background-position: 100% 0; } to { background-position: 0% 0; } }

@media (prefers-reduced-motion: reduce) {
  .screen, .screen.is-leaving { transform: none !important; }
  .xp-dust { display: none; }
  .scratch.is-holo .scratch__card, .scratch.is-holo .scratch__inside::after { animation: none !important; }
}

/* ---------- before/after magnifier ---------- */
.xp-lens { position: absolute; z-index: 6; width: 150px; height: 150px; margin: -205px 0 0 -75px; border-radius: 50%; pointer-events: none;
  border: 2px solid var(--butter); box-shadow: 0 0 0 5px rgba(18, 13, 10, .35), 0 22px 40px rgba(0, 0, 0, .5);
  opacity: 0; transform: scale(.6); transform-origin: 50% 130%; transition: opacity .18s, transform .28s cubic-bezier(.2, 1.4, .3, 1); }
.xp-lens.is-on { opacity: 1; transform: none; }

/* ---------- greeting on the first screen (no separate welcome page) ---------- */
.splash__hint { transition: opacity .4s; }
body.is-welcoming .splash__hint { opacity: 0; }
body.is-welcoming #startBtn {
  background: linear-gradient(rgba(18, 13, 10, .55), rgba(18, 13, 10, .55)) padding-box, conic-gradient(from var(--mu-a), rgba(246, 238, 225, .2) 0deg, rgba(246, 238, 225, .2) 250deg, #FFF6D6 300deg, var(--gold) 330deg, rgba(246, 238, 225, .2) 360deg) border-box;
  color: var(--ivory); box-shadow: none;
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  transition: background .4s, color .4s;
}
body.is-welcoming #startBtn::after { display: none; }

/* locked while the welcome plays: a gold fill follows the voice; unlocks as "كمّلي" */
#startBtn { isolation: isolate; }
#startBtn.is-locked { cursor: default; }
#startBtn.is-locked::before {
  content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; pointer-events: none;
  background: linear-gradient(90deg, rgba(242, 220, 142, .38), rgba(201, 164, 92, .28));
  transform-origin: right center; transform: scaleX(var(--fill, 0));
}
body.is-welcoming #startBtn.is-locked { color: rgba(246, 238, 225, .75); }
body.is-welcoming #startBtn.is-next {
  background: linear-gradient(var(--ivory), var(--ivory)) padding-box,
    conic-gradient(from var(--mu-a), rgba(201, 164, 92, .35) 0deg, rgba(201, 164, 92, .35) 250deg, #FFF6D6 300deg, var(--gold) 330deg, rgba(201, 164, 92, .35) 360deg) border-box;
  color: var(--espresso); box-shadow: 0 14px 34px rgba(0, 0, 0, .35), 0 0 30px rgba(242, 220, 142, .35);
  animation: muSpin 3.2s linear infinite, xpReady .7s cubic-bezier(.2, 1.4, .3, 1);
}
@keyframes xpReady { 0% { transform: scale(.96); } 60% { transform: scale(1.04); } }

/* later screens' photos wait until the opening is on screen (body.bg-ready, set by app.js) */
body:not(.bg-ready) .screen--quiz::before,
body:not(.bg-ready) .screen--choose::before,
body:not(.bg-ready) .screen--reward::before,
body:not(.bg-ready) .screen--cta .stage-scene__bg { background-image: none !important; }
body:not(.bg-ready) .quiz__opt--photo { --swatch: none; }
