/* Poppi pack stage. Mechanical source: https://holo.yashb.xyz/; print and portrait assets: Poppi. */
:root{
  --bg:#e8e5df;--ink:#141414;--muted:#6f6f6b;
  --pack:#2b3ff0;
  --ease-out:cubic-bezier(.23,1,.32,1);
  --spring:linear(0,0.055,0.193,0.378,0.577,0.767,0.93,1.056,1.142,1.19,1.205,1.195,1.167,1.13,1.089,1.05,1.016,0.99,0.972,0.961,0.958,0.96,0.965,0.973,0.981,0.989,0.996,1.002,1.006,1.008,1);
  /* pouch is 0.69:1; cards are 5:7 and a little narrower than the pouch so they fit inside it */
  --ph:min(420px,58vh,58svh,120vw);--pw:calc(var(--ph)*.69);--cw:calc(var(--pw)*.84);--ch:calc(var(--cw)*1.4);
  --crimp:calc(var(--ph)*.068);--d:16px;
  --rainbow:repeating-linear-gradient(110deg,#ff7aa8 0%,#ffcf6b 5%,#a8ff8a 10%,#6be2ff 15%,#9b8cff 20%,#ff7aa8 25%);
  /* thresholded noise: sparse white specks for glitter */
  --glitter:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='g'><feTurbulence type='fractalNoise' baseFrequency='.8' seed='7' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 14 0 0 0 -8.6'/></filter><rect width='160' height='160' filter='url(%23g)'/></svg>");
}
*{box-sizing:border-box}
html,body{height:100%;margin:0}
html{overscroll-behavior:none;touch-action:manipulation;-webkit-text-size-adjust:100%}   /* no pull-to-refresh halfway through a tear */
body{overflow:hidden;background:radial-gradient(120% 90% at 50% 38%,#f3f1ec,var(--bg) 58%,#d8d4cb);color:var(--ink);
  font-family:-apple-system,"SF Pro Text",system-ui,sans-serif;-webkit-font-smoothing:antialiased}
i{font-style:normal}
.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}

/* ---------- stage: one 3D context so the pack's front face can hide the cards inside it ---------- */
.stage{position:fixed;inset:0;overflow:hidden;perspective:1400px;perspective-origin:50% 40%;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none}
.scene{position:absolute;inset:0;transform-style:preserve-3d;pointer-events:none}   /* its own box is a plane at z=0 that would swallow presses on anything tilted behind it */
.hit,.card{pointer-events:auto}
.pack,.card{position:absolute;left:50%;top:50%;transform-style:preserve-3d;will-change:transform}
.pack{width:var(--pw);height:var(--ph);margin:calc(var(--ph)/-2) 0 0 calc(var(--pw)/-2)}
.ground{position:absolute;left:50%;top:50%;width:calc(var(--pw)*.95);height:calc(var(--pw)*.16);margin:calc(var(--pw)*-.08) 0 0 calc(var(--pw)*-.475);
  border-radius:50%;background:radial-gradient(closest-side,rgb(30 25 15/.3),transparent);filter:blur(6px)}

/* ---------- pouch skin: shared by both faces and the tear strip so the strip matches pixel for pixel ---------- */
.skin{position:absolute;inset:0;backface-visibility:hidden;transform:translateZ(calc(var(--d)/2));--tooth:calc(var(--pw)/26);
  background:
    var(--shade,none) 0 0/100% 100%,   /* crumpled shadow above the bottom seal, drawn for each pack in script */
    linear-gradient(90deg,transparent 91%,rgb(0 0 0/.14) 97.6%) 0 50%/100% calc(100% - 2*var(--crimp)) no-repeat,   /* the right side turns away from the light */
    repeating-linear-gradient(90deg,rgb(0 0 0/.18) 0 1px,rgb(255 255 255/.08) 1px 2px,transparent 2px 5px) 0 0/100% var(--crimp) no-repeat,   /* heat-seal ridges */
    repeating-linear-gradient(90deg,rgb(0 0 0/.18) 0 1px,rgb(255 255 255/.08) 1px 2px,transparent 2px 5px) 0 100%/100% var(--crimp) no-repeat,
    var(--pack);
  mask:   /* crimped teeth, and a filled body that sits a little narrower than its flat seals */
    conic-gradient(from 135deg at 50% 0,#0000,#000 1deg 89deg,#0000 90deg) 0 0/var(--tooth) calc(var(--tooth)/2) repeat-x,
    url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' preserveAspectRatio='none'><path d='M0 0H100V5.6C100 8 97.6 7.6 97.6 10V90C97.6 92.4 100 92 100 94.4V100H0V94.4C0 92 2.4 92.4 2.4 90V10C2.4 7.6 0 8 0 5.6Z'/></svg>") 0 50%/100% calc(100% - var(--tooth)) no-repeat,
    conic-gradient(from -45deg at 50% 100%,#0000,#000 1deg 89deg,#0000 90deg) 0 100%/var(--tooth) calc(var(--tooth)/2) repeat-x}
.skin.back{transform:rotateY(180deg) translateZ(calc(var(--d)/2))}
/* light on the foil, laid over the print so it reads as a reflection, not as part of the design. a glint runs down the left edge and
   slides as the pack turns; a shine sits where the foil swells out under the top seal, its hot spot moving along it as the pack turns
   and brightening as the top tips toward the light */
.skin::before,.skin::after{content:"";position:absolute;inset:0;z-index:1;pointer-events:none}
.skin::before{background:linear-gradient(90deg,transparent 2.4%,rgb(255 255 255/.7) 3%,rgb(255 255 255/.28) 5%,transparent 9%);
  mask:linear-gradient(transparent 7%,#000 13% 48%,transparent 84%);translate:calc(var(--gx,0)*1%) 0;opacity:var(--gl,.8)}
.skin::after{background:var(--shine,none) 0 0/100% 100%;opacity:var(--gt,.85);
  mask:linear-gradient(90deg,rgb(0 0 0/.45),#000 40% 60%,rgb(0 0 0/.45)) calc(var(--gm,50)*1%) 0/250% 100%}
.scene.flat{transform-style:flat;perspective:1400px;perspective-origin:50% 40%}   /* once out of the pack each card is its own layer, stacked in order, so cards can never cut through each other */
.rim{position:absolute}   /* rounded sides, built in script */
/* the rainbow flow pours out of the tear. it sits between the faces, so the wrapper hides where it starts and only the torn part lets it out.
   it is a layer of its own that rides with the pack until the pack drops away */
.flow{position:absolute;left:50%;top:50%;width:var(--pw);height:var(--ph);margin:calc(var(--ph)/-2) 0 0 calc(var(--pw)/-2);transform-style:preserve-3d;pointer-events:none}
.rays{position:absolute;left:0;width:100%;top:calc(10.5% - var(--pw)*.6);height:calc(var(--pw)*.76);overflow:visible;opacity:0;transform:translateZ(-6px)}

/* print */
.tag{position:absolute;left:9%;top:calc(var(--crimp) + .9%);font:700 calc(var(--pw)*.029)/1 system-ui,sans-serif;letter-spacing:.16em;text-transform:uppercase;color:rgb(255 255 255/.74)}
.mark{position:absolute;left:9%;top:15%;font:800 calc(var(--pw)*.17)/1 ui-rounded,"SF Pro Rounded",system-ui,sans-serif;letter-spacing:-.045em;color:#fff}
.series{position:absolute;right:9%;top:17.5%;font:600 calc(var(--pw)*.036)/1 system-ui,sans-serif;letter-spacing:.14em;text-transform:uppercase;color:rgb(255 255 255/.7)}
.foot{position:absolute;bottom:calc(var(--crimp) + 3.4%);font:500 calc(var(--pw)*.042)/1 system-ui,sans-serif;color:rgb(255 255 255/.78)}
.foot.l{left:9%}.foot.r{right:9%}
/* the mascot: a chrome sparkle, modelled and rendered like the card characters. its colours shift a little as the pack tilts; eyes and mouth are live layers so it can blink and grimace */
.orb{position:absolute;left:8%;width:84%;top:26.5%;aspect-ratio:1;transition:scale .35s var(--spring)}
.body,.shade{position:absolute;inset:0;width:100%;height:100%}
.orb .body{filter:hue-rotate(calc(var(--sh,0)*1deg))}
.shade{translate:0 3.5%;filter:brightness(0) blur(calc(var(--pw)*.024));opacity:.34}
.eye{position:absolute;transition:opacity .09s,scale .14s var(--ease-out)}
.pupil{display:block;width:100%;height:auto;transition:scale .2s var(--ease-out)}
.smile{position:absolute;height:auto;transition:opacity .08s,scale .2s var(--ease-out)}
/* each character's own expression when its card is hovered */
.joy{position:absolute;height:auto;opacity:0;scale:.7;transition:opacity .09s,scale .34s var(--spring)}
.glad .joy{opacity:1;scale:1}
.glad .eye,.glad .smile{opacity:0;scale:.7}
/* pain while it is being torn: eyes screw shut into > <, a wobbly grimace, a bead of sweat, and the face trembles */
.ouch{position:absolute;height:auto;opacity:0;scale:.6;transition:opacity .08s,scale .24s var(--spring)}
.drip{position:absolute;height:auto;opacity:0;scale:.7;translate:0 -45%;transition:opacity .18s,scale .3s var(--spring),translate .5s var(--ease-out)}
.held .orb{scale:1.06 .92;animation:tremble 90ms steps(2) infinite}   /* scrunches up */
.held .eye{scale:1 0}
.held .smile{opacity:0;scale:.3}
.held .ouch{opacity:1;scale:1}
.hurt .drip{opacity:1;scale:1;translate:0 0}   /* only while it hurts: let go and it gets over it */
@keyframes tremble{50%{translate:1.2px -.8px}}
@media (hover:hover) and (pointer:fine){.pack:has(.hit:hover) .pupil{scale:1.06}.pack:has(.hit:hover) .smile{scale:1.1}}
.fin{position:absolute;left:45%;width:10%;top:0;bottom:0;
  background:repeating-linear-gradient(rgb(0 0 0/.14) 0 1px,transparent 1px 4px),linear-gradient(90deg,rgb(0 0 0/.3),rgb(255 255 255/.18) 45%,rgb(0 0 0/.22))}
.mark.sm{left:0;right:0;top:20%;text-align:center;font-size:calc(var(--pw)*.1)}
.blurb{position:absolute;left:10%;right:10%;top:40%;margin:0;text-align:center;font:500 calc(var(--pw)*.044)/1.5 system-ui,sans-serif;color:rgb(255 255 255/.85)}
.code{position:absolute;left:31%;right:31%;bottom:calc(var(--crimp) + 6%);height:10%;padding:6px 8px;border-radius:4px;
  background:repeating-linear-gradient(90deg,#111 0 2px,#0000 2px 3px,#111 3px 4px,#0000 4px 7px,#111 7px 10px,#0000 10px 12px) content-box,#fff}

/* tear strip: slices along its length, each bent a little further than the last so the loose end curls toward you and shows the silver inside of the foil */
.flap{position:absolute;inset:0;transform-style:preserve-3d;visibility:hidden}
.flap.on{visibility:visible}
.ply{position:absolute;inset:0;transform-style:preserve-3d;transform-origin:0 0}
.ply .front{transform:translateZ(.4px)}
.skin.foil{transform:rotateY(180deg) translateZ(.4px);background:linear-gradient(97deg,#e3e8f2,#fff 12%,#cfd7e6 26%,#fff 44%,#dbe1ee 58%,#fff 76%,#d3dbe9)}
.skin.foil::before,.skin.foil::after{display:none}
.tone{position:absolute;inset:0;z-index:3;background:#0b0d1c;opacity:0}
/* the torn edge: the bright metal layer of the foil, thin and uneven, casting a little shadow onto the print on the pack's side */
.lips{position:absolute;inset:0;z-index:2;filter:drop-shadow(0 1.5px 1.2px rgb(0 0 0/.42))}
.lip{position:absolute;inset:0;z-index:2;clip-path:polygon(0 0);background:linear-gradient(100deg,#f4f6fb,#fff 14%,#bfc8da 27%,#fff 42%,#c9d1e1 58%,#fbfcff 72%,#b9c2d4 86%,#eef1f7)}
.hit{position:absolute;inset:-24px -16px -8px;margin:0;padding:0;border:0;border-radius:14px;   /* reaches past the edges: people grab a pack by its top */background:none;appearance:none;cursor:grab;touch-action:none;
  transform:translateZ(calc(var(--d)/2 + 1px));-webkit-tap-highlight-color:transparent}
.hit:focus-visible{outline:2px solid #0a84ff;outline-offset:8px}
.held .hit,.tug .hit{cursor:grabbing}
.tug .orb{scale:.95 1.07}   /* being pulled about doesn't hurt: it just stretches along */
.card:focus{outline:none}
.card:focus-visible .face{outline:2px solid #0a84ff;outline-offset:3px}

.card{width:var(--cw);height:var(--ch);margin:calc(var(--ch)/-2) 0 0 calc(var(--cw)/-2);touch-action:none;--px:50;--py:50;--hyp:0}
/* confetti */
.fx{position:absolute;inset:0;width:100%;height:100%;pointer-events:none}   /* all the confetti on one canvas: 240 moving elements would each be a layer of their own */

/* ---------- chrome ---------- */
.again{position:fixed;left:50%;bottom:max(24px,5vh);translate:-50% 0;white-space:nowrap;-webkit-tap-highlight-color:transparent;font:inherit;font-size:15px;padding:12px 18px;border-radius:12px;background:#fff;color:var(--ink);cursor:pointer;
  border:1px solid rgb(0 0 0/.1);box-shadow:0 1px 0 rgb(255 255 255/.9) inset,0 -1px 0 rgb(0 0 0/.04) inset,0 1px 2px rgb(0 0 0/.06),0 10px 24px -12px rgb(0 0 0/.25);
  transition:opacity .3s var(--ease-out),scale .16s var(--ease-out)}
@starting-style{.again{opacity:0}}
.again:active{scale:.97}
.again:focus-visible{outline:2px solid #0a84ff;outline-offset:3px}
.mute{-webkit-tap-highlight-color:transparent;position:fixed;right:16px;top:16px;width:44px;height:44px;display:grid;place-items:center;padding:0;border:0;border-radius:50%;background:rgb(255 255 255/.72);color:var(--ink);cursor:pointer;transition:scale .16s cubic-bezier(.23,1,.32,1),background-color .16s}
.mute:active{scale:.94}
.mute:focus-visible{outline:2px solid #0a84ff;outline-offset:3px}
.mute .off,.mute[aria-pressed="true"] .on{display:none}
.mute[aria-pressed="true"] .off{display:block}
@media (hover:hover) and (pointer:fine){.mute:hover{background:#fff}}
@media (pointer:coarse){   /* phones: a card's thickness needs only one edge layer at this size, and the pack's colour shimmer is a filter redrawn on every tilt */
  .slab:nth-child(-n+2){display:none}
  .orb .body{filter:none}
}

@media (prefers-reduced-motion:reduce){
  .held .orb{animation:none}
  .card .face,.card .pop{transition:opacity .25s ease}
  @starting-style{.card .face,.card .pop{opacity:0}}
}

/* Local Poppi print. The seal, foil cross section, lighting and physical
   transform of these surfaces above are shared with every torn segment. */
body {
  --ink:#603d51;
  background:radial-gradient(ellipse at center,#fffcf5 0%,#fffbf2ac 36%,transparent 70%),
    radial-gradient(circle at 14% 40%,#fbd5da94,transparent 34%),
    radial-gradient(circle at 88% 67%,#dbe5fc94,transparent 39%),
    radial-gradient(circle,#c88c9d36 1.2px,transparent 1.6px) 0 0 / 21px 21px,#fff2e9;
}
.stage-tools {position:fixed;inset:15px clamp(16px,4vw,57px) auto;z-index:12;display:flex;justify-content:flex-end;align-items:center;gap:8px;pointer-events:none}
.stage-tools h1 {margin:0 auto 0 0;color:#61394e;font:800 clamp(16px,1.45vw,23px)/1.2 system-ui,sans-serif;letter-spacing:.045em}
.stage-tools button,.again {appearance:none;pointer-events:auto;cursor:pointer;border-radius:22px;border:1px solid #c29bac;background:#fffaf4e8;color:#68495d;font:600 13px/1.35 system-ui,sans-serif}
.stage-tools .mute {position:static;width:36px;height:36px}
.stage-hint {position:fixed;bottom:max(22px,4vh);width:100%;margin:0;text-align:center;pointer-events:none;font:500 14px/1.5 system-ui,sans-serif;color:#76586c}
body:not([data-phase="sealed"]) .stage-hint {display:none}
.again {background:#a84871;color:#fff9f0;box-shadow:0 3px 0 #793c55;padding:9px 18px}
.pack.pa-object {filter:none;container-type:normal}
.pack .pack-print-field {position:absolute;inset:18% 7% 9.5%;border:2px solid #fff8e9;border-radius:6% / 5%;
  background:radial-gradient(ellipse at 50% 48%,#fff6,transparent 67%),linear-gradient(160deg,#fff1db,#fff9ee 48%,#ffe7ef);
  box-shadow:0 0 0 1px #9f7a82,0 2px 0 #70475636}
.skin.front>.mark {left:11%;top:20.5%;font:900 italic calc(var(--pw)*.146)/1 "Trebuchet MS",system-ui,sans-serif;letter-spacing:-.08em;color:#9c3f66;text-shadow:.4px 1.7px #f7c1cd}
.skin.front>.series {top:24%;right:11.4%;color:#7a4963;font-size:calc(var(--pw)*.034);letter-spacing:.06em}
.skin.front>.orb {left:8%;width:84%;top:27.5%;aspect-ratio:1;isolation:isolate}
.orb.pa-medallion::before {content:"";position:absolute;inset:0;width:100%;height:100%;z-index:-1;border-radius:48% 44% 48% 43%;box-shadow:0 0 0 1px #fff8;
  background:var(--cover-art) center / 100% 100%,radial-gradient(ellipse at center,#fff9,transparent 75%),color-mix(in srgb,var(--pack) 60%,#fff5e6)}
.orb.pa-medallion .body {height:100%;width:100%;object-fit:contain;filter:drop-shadow(0 3px 2px #78516530) hue-rotate(calc(var(--sh,0)*.26deg))}
.skin.front>.foot {color:#723d53;bottom:12.5%}
.foot.l {left:12%;font-weight:700}.foot.r {right:12%}
.tag {color:#583a49;font-weight:750}
.back .mark,.back .blurb {color:#643d51}
@media(hover:hover) and (pointer:fine) {
  .stage-tools button:hover {background:#fce3ed}
}
@media(max-height:460px) {
  .stage-tools {top:8px}
  .stage-hint {bottom:8px}
}

/* A sealed foil edge is about 1% of the pack width. The filled cavity is
   21.5% wide in depth; front/rear panels meet along two continuous gussets. */
.pack {--d:calc(var(--pw)*.01);}
.pack>.skin {
  mask:
    conic-gradient(from 135deg at 50% 0,#0000,#000 1deg 89deg,#0000 90deg) 0 0/var(--tooth) calc(var(--tooth)/2) repeat-x,
    linear-gradient(#000 0 0) center calc(var(--tooth)/2 - 1px)/100% 5.2% no-repeat,
    linear-gradient(#000 0 0) center 6%/97% 16% no-repeat,
    linear-gradient(#000 0 0) center 99%/97% 6.6% no-repeat,
    linear-gradient(#000 0 0) center calc(100% - var(--tooth)/2 + 1px)/100% 4.5% no-repeat,
    conic-gradient(from -45deg at 50% 100%,#0000,#000 1deg 89deg,#0000 90deg) 0 100%/var(--tooth) calc(var(--tooth)/2) repeat-x;
}
.pouch-mesh {position:absolute;inset:0;transform-style:preserve-3d;pointer-events:none;}
.pouch-core {position:absolute;inset:0;background:color-mix(in srgb,var(--pack) 87%,#63515a);pointer-events:none;}
.pouch-panel,.pouch-weld {
  display:block;position:absolute;left:0;top:0;transform-origin:0 0;pointer-events:none;
}
.pouch-panel {
  backface-visibility:hidden;
  background-color:var(--pack);
  background-image:linear-gradient(107deg,transparent 8%,transparent calc(var(--surface-glint,47%) - 15%),#fff0fa14 calc(var(--surface-glint,47%) - 4%),#fff9dc42 var(--surface-glint,47%),#fff3eb0c calc(var(--surface-glint,47%) + 3%),transparent calc(var(--surface-glint,47%) + 8%)),var(--pouch-front,none);
  background-size:var(--map-width) var(--map-height);
  background-repeat:no-repeat;
}
.pouch-panel.rear {background-image:var(--pouch-back,none);}
.pouch-weld {background:linear-gradient(90deg,#997e86,#fff9ed 38%,#b7a4a2);}
.pack>.orb.pa-medallion {
  left:12%;width:76%;top:28.8%;aspect-ratio:1;pointer-events:none;backface-visibility:hidden;
  transform:translateZ(calc(var(--pw)*.117 + .45px));
}
.pack>.orb.pa-medallion::before {display:none;}
.pack>.hit {transform:translateZ(calc(var(--pw)*.119 + 1px));}
.flap {translate:0 0 calc(var(--d)/2);}
.stage-tools #turn-pack {padding:8px 14px;}
.stage-tools #turn-pack[hidden] {display:none;}
.tag::after {content:"";position:absolute;left:120%;top:50%;width:calc(var(--pw)*.36);height:1px;background:repeating-linear-gradient(90deg,#57414d65 0 3px,transparent 3px 6px);}
@media(max-width:380px){
  .stage-tools {inset:10px 8px auto;gap:5px}
  .stage-tools #turn-pack{font-size:12px;padding:7px 8px}
}
