/* The opening of the menu. It starts by itself: a dial runs back through the years, a coloured passport stamp lands for every game,
   two low notes sound, and the PastPort - Jamaica logo slams in with a glint of light, sparkles on the compass, and "Jamaica" cycling
   through colours. There are no buttons on it. The behaviour is in intro.js, the markup is #intro in index.html.
   Without JavaScript the overlay is never shown (see the <noscript> in index.html), and if intro.js fails to load
   the overlay hides itself after 8 seconds (the animation at the top of #intro; intro.js switches it off). */
#intro{display:none;position:fixed;inset:0;z-index:100;place-items:center;overflow:hidden;touch-action:none;
  background:radial-gradient(120% 90% at 50% 42%,#0b4263 0%,#06283D 45%,#041B2A 100%);
  color:var(--paper,#FFF7E8);font-family:var(--font,system-ui,sans-serif);-webkit-font-smoothing:antialiased;
  animation:introFailsafe 0s linear 8s forwards}
.intro-on #intro{display:grid}
@keyframes introFailsafe{to{visibility:hidden;pointer-events:none}}
#intro.leaving{opacity:0;pointer-events:none;transition:opacity .7s ease}

/* the dial and its stamps. --S is the size of the whole square. When the logo arrives the dial shrinks away. */
.in-stage{--S:min(72vmin,28rem);position:relative;width:var(--S);aspect-ratio:1;display:grid;place-items:center;transition:opacity .3s ease,transform .5s ease}
#intro.arrived .in-stage{opacity:0;transform:scale(.82)}
.in-dial{position:absolute;inset:0;width:100%;height:100%;overflow:visible;filter:drop-shadow(0 0 14px rgba(255,182,39,.2))}
.in-ring{fill:none;stroke:rgba(31,181,163,.85);stroke-width:2}
.in-ring2{fill:none;stroke:rgba(255,247,232,.14);stroke-width:1}
.in-tick{stroke:rgba(255,247,232,.55);stroke-width:1.6;stroke-linecap:round}
.in-tick.major{stroke:rgba(255,182,39,.95);stroke-width:2.4}
.in-mark{fill:var(--mango,#FFB627)}
.in-halo{fill:none;stroke:var(--mango,#FFB627);stroke-width:3;opacity:0;transform-box:fill-box;transform-origin:center}
#intro.arrived .in-halo{animation:halo 1.1s ease-out}
@keyframes halo{0%{opacity:.85;transform:scale(1)}100%{opacity:0;transform:scale(1.35)}}
.in-year{position:relative;margin:0;font-weight:800;font-size:calc(var(--S) * .16);line-height:1;letter-spacing:-.04em;font-variant-numeric:tabular-nums}

/* a passport stamp for each game, in that game's own colour, tilted a little like a real one */
.in-stamp{opacity:0;transform-box:fill-box;transform-origin:center;transform:scale(1.9) rotate(calc(var(--tilt) - 14deg))}
.in-stamp.on{animation:stampIn .36s cubic-bezier(.2,1.3,.35,1) forwards}
@keyframes stampIn{0%{opacity:0;transform:scale(1.9) rotate(calc(var(--tilt) - 14deg))}45%{opacity:1}100%{opacity:1;transform:scale(1) rotate(var(--tilt))}}
.st-fill{fill-opacity:.18}
.st-ring{fill:none;stroke-width:2}
.st-dash{fill:none;stroke-width:1;stroke-dasharray:1.6 2.2;stroke-opacity:.7}
.st-burst{fill:none;stroke-width:2;opacity:0;transform-box:fill-box;transform-origin:center}
.in-stamp.on .st-burst{animation:burst .6s ease-out .12s}
@keyframes burst{0%{opacity:.8;transform:scale(1)}100%{opacity:0;transform:scale(1.9)}}
.st-year{font-family:var(--font,system-ui,sans-serif);font-weight:800;letter-spacing:-.02em;text-anchor:middle;dominant-baseline:central}

/* the logo and the effects that play over it. Every layer is the same size as the logo, so they line up exactly. */
.in-final{position:absolute;inset:0;display:grid;place-content:center;justify-items:center;gap:clamp(.7rem,2.2vh,1.3rem);padding-bottom:3vh;pointer-events:none}
#intro.named .in-final{animation:breathe 5s ease-in-out infinite}   /* it breathes a little while it is held */
@keyframes breathe{0%,100%{transform:scale(1)}50%{transform:scale(1.012)}}
.in-logo{position:relative;width:min(88vw,80vh,44rem);aspect-ratio:1200 / 838;opacity:0}
#intro.arrived .in-logo{animation:slam .55s cubic-bezier(.2,1.35,.4,1) forwards}   /* on the first low note */
@keyframes slam{0%{opacity:0;transform:scale(1.55) rotate(-5deg);filter:blur(14px)}50%{opacity:1}100%{opacity:1;transform:none;filter:blur(0)}}
.lg-base{display:block;width:100%;height:100%;filter:drop-shadow(0 0 22px rgba(255,200,40,.2))}
/* "Jamaica" cycles through colours: the same picture again, shown only where the gold script is (pastport-jamaica.webp is that mask), with its hue turning */
.lg-jam{position:absolute;inset:0;opacity:0;background:url(pastport-logo.webp) center/100% 100% no-repeat;-webkit-mask:url(pastport-jamaica.webp) center/100% 100% no-repeat;mask:url(pastport-jamaica.webp) center/100% 100% no-repeat}
#intro.named .lg-jam{opacity:1;animation:jamCycle 3s linear .6s infinite}
@keyframes jamCycle{from{filter:hue-rotate(0deg)}to{filter:hue-rotate(360deg)}}
/* a glint of light crossing the logo, kept to the logo's own shape by the mask */
.lg-shine{position:absolute;inset:0;opacity:0;-webkit-mask:url(pastport-logo.webp) center/100% 100% no-repeat;mask:url(pastport-logo.webp) center/100% 100% no-repeat;
  background:linear-gradient(105deg,rgba(255,255,255,0) 38%,rgba(255,244,205,.95) 50%,rgba(255,255,255,0) 62%) 100% 0/250% 100% no-repeat;mix-blend-mode:screen}
#intro.named .lg-shine{animation:shine 1.05s ease-in-out .15s forwards}
@keyframes shine{0%{opacity:0;background-position:100% 0}10%,90%{opacity:1}100%{opacity:0;background-position:0 0}}
/* a ring of light on each of the two low notes */
.lg-ring{position:absolute;left:45%;top:44%;width:70%;aspect-ratio:1;border-radius:50%;border:3px solid rgba(254,209,0,.9);opacity:0;transform:translate(-50%,-50%) scale(.6)}
#intro.arrived .lg-ring.r1{animation:ringOut .9s ease-out forwards}
#intro.named .lg-ring.r2{animation:ringOut .9s ease-out forwards}
@keyframes ringOut{0%{opacity:.85;transform:translate(-50%,-50%) scale(.6)}100%{opacity:0;transform:translate(-50%,-50%) scale(1.7)}}
/* a sparkle on the top, left and right points of the compass star */
.lg-spark{position:absolute;width:15%;aspect-ratio:1;transform:translate(-50%,-50%) scale(0);opacity:0;background:radial-gradient(circle,rgba(255,255,255,.95) 0,rgba(255,236,160,.75) 14%,rgba(255,220,120,0) 42%)}
.lg-spark::before,.lg-spark::after{content:"";position:absolute;left:50%;top:50%;width:100%;height:3px;transform:translate(-50%,-50%);background:linear-gradient(90deg,rgba(255,255,255,0),#fff,rgba(255,255,255,0))}
.lg-spark::after{transform:translate(-50%,-50%) rotate(90deg)}
.lg-spark.sp1{left:44.8%;top:17.4%}.lg-spark.sp2{left:11%;top:43.6%}.lg-spark.sp3{left:80.2%;top:43.6%}
#intro.named .lg-spark{animation:spark .9s ease-out forwards}
#intro.named .lg-spark.sp1{animation-delay:.55s}#intro.named .lg-spark.sp2{animation-delay:.7s}#intro.named .lg-spark.sp3{animation-delay:.85s}
@keyframes spark{0%{opacity:0;transform:translate(-50%,-50%) scale(0) rotate(-30deg)}35%{opacity:1;transform:translate(-50%,-50%) scale(1) rotate(0)}100%{opacity:0;transform:translate(-50%,-50%) scale(.25) rotate(40deg)}}
/* one line about what it is, under the logo */
.in-desc{margin:0;max-width:94vw;font-weight:600;font-size:clamp(.78rem,4.3vw,1.2rem);line-height:1.3;color:rgba(255,247,232,.9);text-align:center;opacity:0;transition:opacity .8s ease 1s;white-space:nowrap}   /* one line, down to 320px wide */
#intro.named .in-desc{opacity:1}
h1:focus{outline:none}

/* the menu rising in as the intro fades away (only after an intro has played) */
.menu-in header,.menu-in .game{animation:cardIn .7s cubic-bezier(.2,.8,.2,1) backwards;animation-delay:calc(.1s + var(--i,0) * 80ms)}
@keyframes cardIn{from{opacity:0;transform:translateY(24px) scale(.98)}to{opacity:1;transform:none}}

/* short screens, such as a phone held sideways: a smaller dial */
@media (max-height:520px){
  .in-stage{--S:min(62vmin,18rem)}
}

@media (prefers-reduced-motion:reduce){
  .in-stage{transition:none}
  #intro.arrived .in-halo,.in-stamp.on .st-burst{animation:none}
  .in-stamp.on{animation:none;opacity:1;transform:rotate(var(--tilt))}
  #intro.arrived .in-logo{animation:none;opacity:1}
  #intro.named .in-final{animation:none}
  #intro .lg-jam,#intro .lg-shine,#intro .lg-ring,#intro .lg-spark{animation:none!important;opacity:0!important}
  .menu-in header,.menu-in .game{animation:none}
}
