/* The opening animation of /kezeles/: an unbranded pack in the site's colours opens, the cigarettes rise,
   and the pack flies at the viewer while the layer fades. control-intro.js builds the elements and
   removes them when the layer's own animation ends.

   Geometry: one unit (--u) is one millimetre of a real pack, 55 wide, 88 tall, 22 deep. Every group is a
   0x0 box at the pack's centre (x right, y down, z toward the viewer); a face is centred on its point by
   its margins, then moved by --x/--y/--z and turned by --r.
   Timeline: every animation lasts 2000ms and starts when the layer is added, so one currentTime
   gives one frame. Only transform and opacity move. */
.ctl-opening{
  --u:min(2.8px,calc(100vmin / 180),calc(100vw / 150));
  position:fixed;inset:0;z-index:90;overflow:hidden;cursor:pointer;-webkit-tap-highlight-color:transparent;
  background:
    radial-gradient(42% 22% at 50% 74%,rgba(244,162,89,.10),rgba(244,162,89,0)),
    radial-gradient(70% 60% at 50% 44%,rgba(47,107,73,.95),rgba(15,50,33,.96) 62%,rgba(7,24,15,.97));
  opacity:0;
  animation:co-layer 2000ms linear both;
}
@keyframes co-layer{
  0%{opacity:0;animation-timing-function:cubic-bezier(.3,0,.4,1)}
  12.5%{opacity:1}
  80%{opacity:1;animation-timing-function:cubic-bezier(.5,0,.8,.6)}
  100%{opacity:0}
}

/* The camera: perspective, with the pack's centre a little below the middle so the risen cigarettes fit. */
.co-scene{position:absolute;left:50%;top:calc(50% + 12 * var(--u));width:0;height:0;perspective:calc(400 * var(--u))}
.co-g{position:absolute;left:0;top:0;width:0;height:0;transform-style:preserve-3d}
.co-fly{animation:co-fly 2000ms both;will-change:transform}
.co-world{transform:rotateX(-17deg)}
.co-spin{animation:co-spin 2000ms both;will-change:transform}

/* In from far away and above, rest, then at the viewer. */
@keyframes co-fly{
  0%{transform:translate3d(0,calc(-14 * var(--u)),calc(-320 * var(--u)));animation-timing-function:cubic-bezier(.16,1,.3,1)}
  40%{transform:translate3d(0,0,0)}
  77.5%{transform:translate3d(0,0,0);animation-timing-function:cubic-bezier(.55,0,.8,.3)}
  100%{transform:translate3d(0,calc(-6 * var(--u)),calc(245 * var(--u)))}
}
/* A slow turn: the right side shows first, the left side at the end. */
@keyframes co-spin{
  0%{transform:rotateY(-42deg);animation-timing-function:cubic-bezier(.16,1,.3,1)}
  40%{transform:rotateY(-16deg);animation-timing-function:cubic-bezier(.45,0,.55,1)}
  100%{transform:rotateY(14deg)}
}
/* The same turn backwards, so each cigarette's plane keeps facing the camera, as a round thing would. */
@keyframes co-unspin{
  0%{transform:rotateY(42deg);animation-timing-function:cubic-bezier(.16,1,.3,1)}
  40%{transform:rotateY(16deg);animation-timing-function:cubic-bezier(.45,0,.55,1)}
  100%{transform:rotateY(-14deg)}
}

/* ---------- faces ---------- */
.co-f{
  position:absolute;left:0;top:0;
  width:calc(var(--w) * var(--u));height:calc(var(--h) * var(--u));
  margin-left:calc(var(--w) * var(--u) / -2);margin-top:calc(var(--h) * var(--u) / -2);
  transform:translate3d(calc(var(--x,0) * var(--u)),calc(var(--y,0) * var(--u)),calc(var(--z,0) * var(--u))) var(--r,rotateY(0deg));
  backface-visibility:hidden;-webkit-backface-visibility:hidden;
}
/* Faces with the same look on both sides. */
.co-two{backface-visibility:visible;-webkit-backface-visibility:visible}

/* The body: y -20 to 44, open at the top. */
.co-body-front{--w:55;--h:64;--y:12;--z:11;overflow:hidden;
  background:
    linear-gradient(90deg,rgba(255,255,255,.10),rgba(255,255,255,0) 6%,rgba(0,0,0,0) 92%,rgba(0,0,0,.22)),
    linear-gradient(180deg,transparent 56%,#FFD166 56%,#FFD166 57.2%,#F4A259 57.2%,#E58F45 66.8%,#FFD166 66.8%,#FFD166 68%,transparent 68%),
    repeating-linear-gradient(45deg,rgba(255,255,255,.018) 0 2px,rgba(255,255,255,0) 2px 4px),
    linear-gradient(170deg,#22593C 0%,#1B4B32 42%,#0F3221 100%)}
.co-body-back{--w:55;--h:64;--y:12;--z:-11;--r:rotateY(180deg);
  background:linear-gradient(180deg,transparent 56%,#B9773A 56%,#A86A31 68%,transparent 68%),linear-gradient(#123726,#0B2618)}
.co-body-right{--w:22;--h:64;--x:27.5;--y:12;--r:rotateY(90deg);
  background:
    linear-gradient(90deg,rgba(255,255,255,.05),rgba(0,0,0,.18)),
    linear-gradient(180deg,transparent 56%,#E0A15A 56%,#E0A15A 57.2%,#C7803F 57.2%,#B46E30 66.8%,#E0A15A 66.8%,#E0A15A 68%,transparent 68%),
    linear-gradient(180deg,#184630,#0D2C1D)}
.co-body-left{--w:22;--h:64;--x:-27.5;--y:12;--r:rotateY(-90deg);
  background:
    linear-gradient(90deg,rgba(0,0,0,.12),rgba(255,255,255,.08)),
    linear-gradient(180deg,transparent 56%,#FFD877 56%,#FFD877 57.2%,#F7AC66 57.2%,#EC9A50 66.8%,#FFD877 66.8%,#FFD877 68%,transparent 68%),
    linear-gradient(180deg,#286444,#1B4B32)}
.co-body-bottom{--w:55;--h:22;--y:44;--r:rotateX(-90deg);background:#0A2216}

/* The label on the front: a small mango diamond and the name, above the stripe. */
.co-mark{position:absolute;left:50%;top:calc(13 * var(--u));width:calc(4.2 * var(--u));height:calc(4.2 * var(--u));
  margin-left:calc(-2.1 * var(--u));transform:rotate(45deg);background:linear-gradient(135deg,#FFD166,#F4A259 55%,#D9822F);
  box-shadow:0 0 0 calc(.6 * var(--u)) rgba(255,209,102,.18)}
.co-name{position:absolute;left:0;right:0;top:calc(20 * var(--u));text-align:center;white-space:nowrap;
  font-family:'Fredoka','Nunito',system-ui,sans-serif;font-weight:600;font-size:calc(7.4 * var(--u));line-height:1;
  letter-spacing:.01em;color:#F6EFDF;text-shadow:0 calc(.3 * var(--u)) 0 rgba(0,0,0,.25)}
.co-rule{position:absolute;left:calc(17 * var(--u));right:calc(17 * var(--u));top:calc(30.5 * var(--u));height:calc(.35 * var(--u));
  background:linear-gradient(90deg,rgba(255,209,102,0),rgba(255,209,102,.7),rgba(255,209,102,0))}

/* A gloss band crossing the closed front. Its skew turns about the seam, so the band on the lid and the
   band on the body make one line. */
.co-body-front::after,.co-lid-front::after{content:'';position:absolute;inset:0;
  background:linear-gradient(90deg,rgba(255,255,255,0) 36%,rgba(255,255,255,.20) 50%,rgba(255,255,255,0) 64%);
  animation:co-sweep 2000ms both;will-change:transform}
.co-body-front::after{transform-origin:50% 0}
.co-lid-front::after{transform-origin:50% 100%}
@keyframes co-sweep{
  0%,10%{transform:translateX(-120%) skewX(-22deg);animation-timing-function:cubic-bezier(.45,0,.55,1)}
  47.5%,100%{transform:translateX(120%) skewX(-22deg)}
}

/* The inner collar, cream card standing 9 above the body front, its sides cut down toward the back. */
.co-collar-front{--w:54.2;--h:15;--y:-21.5;--z:10.6;
  background:linear-gradient(180deg,#FBF5E6,#E7DBC0 70%,#D4C4A2);box-shadow:inset 0 calc(.35 * var(--u)) 0 rgba(255,255,255,.7)}
.co-collar-right{--w:10.6;--h:15;--x:27.1;--y:-21.5;--z:5.3;--r:rotateY(90deg);
  clip-path:polygon(0 0,100% 60%,100% 100%,0 100%);background:linear-gradient(90deg,#DCCEAE,#C3B28D)}
.co-collar-left{--w:10.6;--h:15;--x:-27.1;--y:-21.5;--z:5.3;--r:rotateY(-90deg);
  clip-path:polygon(0 60%,100% 0,100% 100%,0 100%);background:linear-gradient(90deg,#F3EAD5,#E2D5B6)}

/* The foil round the cigarettes, torn at the top. */
.co-foil{background:
  repeating-linear-gradient(115deg,rgba(255,255,255,.0) 0 3px,rgba(255,255,255,.16) 3px 4px,rgba(0,0,0,.05) 4px 7px),
  linear-gradient(100deg,#8C9690 0%,#E8EEEA 18%,#A1ABA5 33%,#F5F8F6 49%,#97A29C 64%,#DCE3DF 80%,#86918B 100%)}
.co-foil-back{--w:54;--h:74;--y:3;--z:-10.4;
  clip-path:polygon(0 3%,9% 1%,17% 3.5%,28% .5%,39% 2.5%,52% 0,63% 3%,74% 1%,86% 3.2%,94% .8%,100% 2.6%,100% 100%,0 100%)}
.co-foil-right{--w:21;--h:70;--x:26.9;--y:5;--r:rotateY(-90deg);
  clip-path:polygon(0 1.5%,22% 0,47% 2.6%,71% .6%,100% 3%,100% 100%,0 100%)}
.co-foil-left{--w:21;--h:70;--x:-26.9;--y:5;--r:rotateY(90deg);
  clip-path:polygon(0 3%,29% .6%,53% 2.6%,78% 0,100% 1.5%,100% 100%,0 100%)}

/* The two back rows: only their filter ends show, so they are drawn on one level plane. */
.co-bed{--w:53.2;--h:14;--y:-41.6;--z:-3.5;--r:rotateX(90deg);
  --end:radial-gradient(circle closest-side,#FAF4E6 0 52%,#E6DBC4 68%,#CDBD9C 76%,#C2763C 80%,#9E5726 94%,rgba(0,0,0,0) 100%);
  background:var(--end) 0 0 / calc(7.6 * var(--u)) calc(7 * var(--u)) repeat-x,
    var(--end) calc(3.8 * var(--u)) calc(7 * var(--u)) / calc(7.6 * var(--u)) calc(7 * var(--u)) repeat-x,
    #1C150D}

/* ---------- the lid: y -44 to -20, hinged on the back top edge of the body (y -20, z -11) ---------- */
.co-lid{animation:co-lid 2000ms both;will-change:transform}
@keyframes co-lid{
  0%,30%{transform:translate3d(0,calc(-20 * var(--u)),calc(-11 * var(--u))) rotateX(0deg) translate3d(0,calc(20 * var(--u)),calc(11 * var(--u)));
    animation-timing-function:cubic-bezier(.5,0,.2,1)}
  54%{transform:translate3d(0,calc(-20 * var(--u)),calc(-11 * var(--u))) rotateX(108deg) translate3d(0,calc(20 * var(--u)),calc(11 * var(--u)));
    animation-timing-function:cubic-bezier(.4,0,.6,1)}
  64%,100%{transform:translate3d(0,calc(-20 * var(--u)),calc(-11 * var(--u))) rotateX(100deg) translate3d(0,calc(20 * var(--u)),calc(11 * var(--u)))}
}
.co-lid-front{--w:55;--h:24;--y:-32;--z:11;overflow:hidden;
  background:
    linear-gradient(90deg,rgba(255,255,255,.10),rgba(255,255,255,0) 6%,rgba(0,0,0,0) 92%,rgba(0,0,0,.22)),
    linear-gradient(180deg,transparent 78%,rgba(255,209,102,.75) 78%,rgba(255,209,102,.75) 80.5%,transparent 80.5%),
    linear-gradient(170deg,#2F7550,#22593C);
  box-shadow:inset 0 calc(-.4 * var(--u)) 0 rgba(0,0,0,.35)}
.co-lid-back{--w:55;--h:24;--y:-32;--z:-11;--r:rotateY(180deg);background:linear-gradient(#174531,#123726)}
.co-lid-right{--w:22;--h:24;--x:27.5;--y:-32;--r:rotateY(90deg);
  background:linear-gradient(90deg,rgba(255,255,255,.05),rgba(0,0,0,.18)),linear-gradient(180deg,#1C5036,#184630);
  box-shadow:inset 0 calc(-.4 * var(--u)) 0 rgba(0,0,0,.35)}
.co-lid-left{--w:22;--h:24;--x:-27.5;--y:-32;--r:rotateY(-90deg);
  background:linear-gradient(90deg,rgba(0,0,0,.12),rgba(255,255,255,.08)),linear-gradient(180deg,#2E6E4B,#286444);
  box-shadow:inset 0 calc(-.4 * var(--u)) 0 rgba(0,0,0,.35)}
.co-lid-top{--w:55;--h:22;--y:-44;--r:rotateX(90deg);
  background:linear-gradient(180deg,rgba(255,255,255,.10),rgba(255,255,255,0) 30%),linear-gradient(180deg,#2C6E4A,#22593C)}
/* Its inside, cream card, seen once it is open. */
.co-in{background:linear-gradient(180deg,#F1E9D6,#D8CBAE)}
.co-lid-in-front{--w:54.4;--h:23.6;--y:-32;--z:10.7;--r:rotateY(180deg)}
.co-lid-in-back{--w:54.4;--h:23.6;--y:-32;--z:-10.7}
.co-lid-in-right{--w:21.4;--h:23.6;--x:27.2;--y:-32;--r:rotateY(-90deg);background:linear-gradient(180deg,#E2D7BD,#C9BA98)}
.co-lid-in-left{--w:21.4;--h:23.6;--x:-27.2;--y:-32;--r:rotateY(90deg);background:linear-gradient(180deg,#E2D7BD,#C9BA98)}
.co-lid-in-top{--w:54.4;--h:21.4;--y:-43.7;--r:rotateX(-90deg);
  background:radial-gradient(60% 70% at 50% 60%,#FBF6EA,#E4D9C0 70%,#CDBF9F)}

/* ---------- the cigarettes of the front row ---------- */
/* .co-cig sits at the top of the cigarette's axis and rises; .co-bill turns back against the pack's turn. */
.co-cig{transform:translate3d(calc(var(--x) * var(--u)),calc(-42 * var(--u)),calc(7 * var(--u)));
  animation:co-rise 520ms cubic-bezier(.22,1.3,.36,1) calc(820ms + var(--i) * 50ms) both;will-change:transform}
@keyframes co-rise{
  from{transform:translate3d(calc(var(--x) * var(--u)),calc(-42 * var(--u)),calc(7 * var(--u)))}
  to{transform:translate3d(calc(var(--x) * var(--u)),calc((-42 - var(--rise)) * var(--u)),calc(7 * var(--u)))}
}
.co-bill{animation:co-unspin 2000ms both;will-change:transform}
.co-paper{position:absolute;left:calc(-3.6 * var(--u));top:0;width:calc(7.2 * var(--u));height:calc(82 * var(--u));overflow:hidden;
  background:linear-gradient(180deg,#FFFFFF,#F4F1EA)}
.co-filter{position:absolute;left:0;right:0;top:0;height:calc(22 * var(--u));
  background:
    radial-gradient(circle,rgba(255,226,170,.55) 0 .6px,rgba(255,226,170,0) 1px) 0 0 / 3px 4px,
    radial-gradient(circle,rgba(110,52,18,.45) 0 .6px,rgba(110,52,18,0) 1px) 1.5px 2px / 3px 4px,
    linear-gradient(180deg,#D88A49,#C0702F);
  box-shadow:inset 0 calc(-.5 * var(--u)) 0 #E7C27A}
/* Round shading, over paper and filter alike. */
.co-paper::after{content:'';position:absolute;inset:0;
  background:linear-gradient(90deg,rgba(40,30,20,.34),rgba(255,255,255,.30) 30%,rgba(255,255,255,0) 52%,rgba(40,30,20,.12) 78%,rgba(40,30,20,.40))}
.co-end{position:absolute;left:calc(-3.6 * var(--u));top:calc(-3.6 * var(--u));width:calc(7.2 * var(--u));height:calc(7.2 * var(--u));
  border-radius:50%;transform:rotateX(90deg);
  background:radial-gradient(circle closest-side,#FDF8EC 0 50%,#EAE0CA 68%,#D2C3A4 78%,#C9803F 82%,#A65E2A 100%)}

/* ---------- the soft shadow on the floor, under the pack ---------- */
.co-shadow{--w:110;--h:58;
  background:
    radial-gradient(30% 26% at 50% 50%,rgba(2,12,7,.50),rgba(2,12,7,0)),
    radial-gradient(closest-side,rgba(2,12,7,.55),rgba(2,12,7,.26) 50%,rgba(2,12,7,0));
  animation:co-shadow 2000ms both;will-change:transform,opacity}
@keyframes co-shadow{
  0%{opacity:0;transform:translate3d(0,calc(44.6 * var(--u)),0) rotateX(90deg) scale(.35);animation-timing-function:cubic-bezier(.16,1,.3,1)}
  40%{opacity:1;transform:translate3d(0,calc(44.6 * var(--u)),0) rotateX(90deg) scale(1)}
  77.5%{opacity:1;transform:translate3d(0,calc(44.6 * var(--u)),0) rotateX(90deg) scale(1);animation-timing-function:cubic-bezier(.5,0,.8,.4)}
  100%{opacity:0;transform:translate3d(0,calc(44.6 * var(--u)),0) rotateX(90deg) scale(1.4)}
}

/* control-intro.js never starts it then; this is only in case. */
@media (prefers-reduced-motion:reduce){
  .ctl-opening{display:none}
}
