/* Home page intro: five chips sweep in from the sides, land off-center, skid and hop into a stack on a
   dark screen, then the page fades in. Only index.html loads this file. The page content is always in
   the HTML underneath, so search engines and screen readers are not affected. Timeline (all CSS, no
   network, no storage): chips land by ~1.4s, the screen fades out from 1.95s, gone by ~2.45s. Tap, click
   or any key skips it. Added to the page by an inline script in <head> (class "intro-on" on <html>), and
   not at all when the visitor prefers reduced motion. Without JavaScript the intro never shows.
   Motion is split in three nested layers so each can have its own timing:
   .ichip = sideways sweep and skid (--sx start, --bx skid, --x final), .ihop = fall and hops,
   .itilt = the tumble. Per chip: --i order, --x final x, --sx start x, --bx skid, --rz start spin. */

#intro { display: none; }

html.intro-on { overflow: hidden; }
html.intro-on #intro {
  --d: clamp(96px, 26vmin, 170px);
  display: block; position: fixed; inset: 0; z-index: 9999;
  background: #050806; overflow: hidden; cursor: pointer;
  animation: intro-out .5s ease 1.95s forwards;
}
html.intro-on.intro-skip #intro { animation: intro-skip-out .25s ease forwards; }

/* faint spade behind the stack (same suit as the site icon) */
#intro .iwm {
  position: absolute; left: 50%; top: 46%; transform: translate(-50%, -50%);
  font: 700 88vmin/1 Georgia, "Times New Roman", serif; color: #fff;
  opacity: 0; animation: iwm 1.1s ease .05s forwards; user-select: none;
}

#intro .istage { position: absolute; left: 50%; top: 56%; width: 0; height: 0; }

#intro .ichip {
  --lift: calc(var(--i) * -9px);
  --c: #f3f0e6;
  position: absolute; left: calc(var(--d) / -2); top: calc(var(--d) / -2);
  width: var(--d); height: var(--d);
  transform: translateX(var(--sx));
  animation: idx .95s linear calc(.1s + var(--i) * .17s) forwards;
}
#intro .ichip.top { --c: #d8b45c; }

#intro .ihop {
  position: absolute; inset: 0;
  transform: translateY(calc(-60vh + var(--lift)));
  animation: idy .95s linear calc(.1s + var(--i) * .17s) forwards;
}

#intro .itilt {
  position: absolute; inset: 0; transform-style: preserve-3d;
  transform: perspective(700px) rotateX(68deg) rotateZ(0deg);
  animation: ispin .9s cubic-bezier(.2, .6, .3, 1) calc(.1s + var(--i) * .17s) backwards;
}
#intro .iface, #intro .iside {
  position: absolute; inset: 0; border-radius: 50%;
  border: max(4px, calc(var(--d) * .035)) solid var(--c); background: #050806;
}
#intro .iside { transform: translateZ(calc(var(--d) * -.07)); }
/* notched band around the rim, like the edge spots on a real chip */
#intro .iface::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: repeating-conic-gradient(var(--c) 0 11deg, transparent 11deg 30deg);
  -webkit-mask: radial-gradient(circle, transparent 66%, #000 67%, #000 86%, transparent 87%);
          mask: radial-gradient(circle, transparent 66%, #000 67%, #000 86%, transparent 87%);
  opacity: .9;
}
#intro .iface::after {
  content: ""; position: absolute; inset: 24%; border-radius: 50%;
  border: max(2px, calc(var(--d) * .015)) solid var(--c);
}

#intro .ihint {
  position: absolute; left: 0; right: 0; text-align: center;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 24px);
  font: 12px/1 var(--f-mono, ui-monospace, Menlo, monospace); letter-spacing: .06em;
  color: #6b7f73; opacity: 0; animation: ifade .4s ease .8s forwards;
}

/* sideways: even speed while falling (so the path is an arc), lands past the stack, skids back */
@keyframes idx {
  0%   { transform: translateX(var(--sx)); animation-timing-function: linear; }
  58%  { transform: translateX(calc(var(--x) + var(--bx))); animation-timing-function: ease-out; }
  74%  { transform: translateX(calc(var(--x) + var(--bx) * .5)); animation-timing-function: ease-in-out; }
  86%  { transform: translateX(calc(var(--x) - var(--bx) * .22)); animation-timing-function: ease-in-out; }
  93%  { transform: translateX(calc(var(--x) + var(--bx) * .07)); animation-timing-function: ease-in-out; }
  100% { transform: translateX(var(--x)); }
}
/* vertical: gravity fall, then two hops */
@keyframes idy {
  0%   { transform: translateY(calc(-60vh + var(--lift))); animation-timing-function: cubic-bezier(.5, 0, .9, .6); }
  58%  { transform: translateY(var(--lift)); animation-timing-function: cubic-bezier(.2, .6, .4, 1); }
  74%  { transform: translateY(calc(var(--lift) - 18px)); animation-timing-function: cubic-bezier(.5, 0, .9, .6); }
  86%  { transform: translateY(var(--lift)); animation-timing-function: cubic-bezier(.2, .6, .4, 1); }
  93%  { transform: translateY(calc(var(--lift) - 5px)); animation-timing-function: cubic-bezier(.5, 0, .9, .6); }
  100% { transform: translateY(var(--lift)); }
}
@keyframes ispin {
  from { transform: perspective(700px) rotateX(0deg) rotateZ(var(--rz)); }
  to   { transform: perspective(700px) rotateX(788deg) rotateZ(0deg); }
}
@keyframes iwm   { to { opacity: .05; } }
@keyframes ifade { to { opacity: 1; } }
@keyframes intro-out      { to { opacity: 0; visibility: hidden; pointer-events: none; } }
@keyframes intro-skip-out { to { opacity: 0; visibility: hidden; pointer-events: none; } }

@media (prefers-reduced-motion: reduce) {
  html.intro-on #intro { display: none; }
  html.intro-on { overflow: auto; }
}
