/* The Firify 3D mascot: one picture per expression, animated in code. */
.mascot-wrap {
  position: absolute; left: 50%; top: 55%; transform: translate(-50%, -50%); z-index: 5;
  width: min(80vw, calc(58vh * 0.852), 420px); aspect-ratio: 300 / 352; outline: none; -webkit-tap-highlight-color: transparent;
  /* where the eyes sit on the picture (fractions of its width and height). Change these if the picture changes. */
  --elx: 0.3217; --ely: 0.5398; --erx: 0.6433; --ery: 0.5398; --ed: 0.135;
}
.mascot-wrap:focus-visible { outline: 3px solid #5fd6e6; outline-offset: 8px; border-radius: 28px; }
.m3d { position: relative; width: 100%; height: 100%; transition: filter 0.55s ease; filter: drop-shadow(0 18px 50px rgba(242, 122, 26, 0.25)); }
.stage { position: relative; width: 100%; height: 100%; cursor: pointer; transform-origin: 50% 100%; animation: idle 3.2s ease-in-out infinite alternate; user-select: none; -webkit-user-select: none; }
.pose { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; pointer-events: none; -webkit-user-drag: none; transition: opacity 0.12s; }
.pose.on { opacity: 1; }
@keyframes idle { from { transform: translateY(4px) scale(1.012, 0.988); } to { transform: translateY(-9px) scale(0.99, 1.01); } }

/* three colours, one click each, then back to the first */
.m3d[data-skin='1'] { filter: hue-rotate(-62deg) saturate(1.12) drop-shadow(0 18px 50px rgba(230, 60, 130, 0.28)); }
.m3d[data-skin='2'] { filter: hue-rotate(68deg) saturate(1.1) drop-shadow(0 18px 50px rgba(120, 100, 255, 0.3)); }

/* eyes on top of the picture; the pupils follow the cursor */
.eye {
  position: absolute; border-radius: 50%; overflow: hidden; pointer-events: none; transform: translate(-50%, -50%);
  width: calc(var(--ed) * 100%); aspect-ratio: 1; background: radial-gradient(circle at 38% 32%, #ffffff 0%, #f1f5fa 62%, #cfd8e6 100%);
  box-shadow: inset 0 0 0 1.5px rgba(40, 60, 100, 0.25); transition: opacity 0.12s;
}
#eyeL { left: calc(var(--elx) * 100%); top: calc(var(--ely) * 100%); }
#eyeR { left: calc(var(--erx) * 100%); top: calc(var(--ery) * 100%); }
.pup {
  position: absolute; left: 50%; top: 50%; width: 52%; height: 52%; border-radius: 50%; background: #17234a;
  transform: translate(calc(-50% + var(--tx, 0px)), calc(-50% + var(--ty, 0px))); transition: transform 0.06s linear;
}
.pup::after { content: ''; position: absolute; left: 22%; top: 18%; width: 30%; height: 30%; border-radius: 50%; background: #fff; }
.m3d.expr .eye { opacity: 0; }

/* effects drawn over the mascot */
.marks { position: absolute; opacity: 0; pointer-events: none; transition: opacity 0.15s; }
.marks-anger { right: 4%; top: 6%; width: 17%; }
.marks-shock { left: 28%; top: -10%; width: 44%; }
.m3d[data-mood='mad'] .marks-anger { opacity: 1; animation: pop 0.5s ease-out; }
.m3d[data-mood='shock'] .marks-shock { opacity: 1; animation: pop 0.4s ease-out; }
@keyframes pop { 0% { transform: scale(0.2); } 60% { transform: scale(1.3); } 100% { transform: scale(1); } }
.hearts { position: absolute; inset: 0; pointer-events: none; }
.hearts i { position: absolute; width: 9%; aspect-ratio: 1; margin: -4.5% 0 0 -4.5%; animation: floaty var(--dur, 1.4s) ease-out forwards; animation-delay: var(--delay, 0s); opacity: 0; }
.hearts svg { width: 100%; height: 100%; display: block; }
@keyframes floaty { 0% { transform: translate(0, 0) scale(0.4); opacity: 1; } 100% { transform: translate(var(--dx, 0px), var(--dy, -120px)) scale(var(--sc, 1.1)); opacity: 0; } }

/* body reactions: these play even before the expression pictures exist */
.do-pet .stage { animation: pet 0.7s ease-in-out 2; }
.do-laugh .stage { animation: laugh 0.2s ease-in-out 8 alternate; }
.do-mad .stage { animation: shake 0.08s linear 16 alternate; }
.do-shock .stage { animation: jump 0.8s cubic-bezier(0.2, 1.5, 0.4, 1); }
.do-kiss .stage { animation: lean 1s ease-in-out; }
.do-mad:not(.has-mad) .pose.on { filter: sepia(0.55) saturate(2.4) hue-rotate(-35deg) brightness(1.02); }
.do-shock:not(.has-shock) .pose.on { filter: brightness(1.25) contrast(1.1); }
@keyframes pet { 0%, 100% { transform: scale(1, 1); } 50% { transform: scale(1.06, 0.88); } }
@keyframes laugh { from { transform: rotate(-4deg) translateY(0); } to { transform: rotate(4deg) translateY(-12px); } }
@keyframes shake { from { transform: translateX(-5px); } to { transform: translateX(5px); } }
@keyframes jump { 0% { transform: translateY(0); } 30% { transform: translateY(-50px) scale(0.96, 1.06); } 100% { transform: translateY(0); } }
@keyframes lean { 0%, 100% { transform: rotate(0); } 35% { transform: rotate(-5deg) translateY(-6px); } }

/* speech bubble */
.bubble {
  position: absolute; left: 70%; top: -2%; transform: translate(-50%, 0) scale(0); transform-origin: 30% 100%; z-index: 3;
  background: #fff; color: #101f4d; font-weight: 600; font-size: clamp(18px, 2.4vw, 26px); padding: 10px 20px; border-radius: 22px 22px 22px 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35); white-space: nowrap; pointer-events: none; transition: transform 0.3s cubic-bezier(0.2, 1.5, 0.4, 1);
}
.bubble.show { transform: translate(-50%, 0) scale(1); }

@media (prefers-reduced-motion: reduce) {
  .stage, .do-pet .stage, .do-laugh .stage, .do-mad .stage, .do-shock .stage, .do-kiss .stage, .hearts i { animation: none !important; }
}

/* video clips: the clip is keyed onto a canvas (navy removed) and sits over the mascot picture */
.clipcv { position: absolute; pointer-events: none; opacity: 0; transition: opacity 0.1s; z-index: 2; }
.clip-on .clipcv { opacity: 1; }
.clip-on .pose, .clip-on .eye, .clip-on .marks { opacity: 0 !important; }

/* ---- fully-video mascot: one big stage, two stacked canvases (live picture + fading snapshot) ---- */
.mascot-wrap { width: calc(min(84vh, 730px, 136vw) * 1.0667); height: min(84vh, 730px, 136vw); aspect-ratio: auto; top: 52%; }
.stage { animation: none !important; cursor: pointer; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#cvB { opacity: 0; }
.bubble { top: 10%; left: 66%; }

/* ---- GPU version: the black background is removed by the browser (screen blend), so no per-frame script work.
   Rule: nothing above the videos may create a stacking context (no transform, filter, fixed, or z-index on the wrapper chain). ---- */
.play-wrap { position: relative !important; inset: auto !important; display: block !important; width: 100%; height: 100vh; height: 100svh; overflow: hidden; }
.mascot-wrap {
  --mh: min(84vh, 730px, 136vw);
  position: absolute; left: 50%; top: 52%; transform: none !important; z-index: auto !important; aspect-ratio: auto;
  width: calc(var(--mh) * 1.0667); height: var(--mh); margin-left: calc(var(--mh) * -0.5333); margin-top: calc(var(--mh) * -0.5);
}
.m3d, .m3d[data-skin='1'], .m3d[data-skin='2'] { position: relative; width: 100%; height: 100%; filter: none !important; transition: none; }
.m3d[data-skin='0'] { --hue: 0deg; }
.m3d[data-skin='1'] { --hue: -62deg; }
.m3d[data-skin='2'] { --hue: 68deg; }
.stage { position: relative; width: 100%; height: 100%; animation: none !important; cursor: pointer; }
.clip {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; pointer-events: none; -webkit-user-drag: none;
  mix-blend-mode: screen; filter: contrast(1.15) hue-rotate(var(--hue, 0deg)); transition: opacity 0.26s linear, filter 0.5s ease;
}
.clip.on { opacity: 1; }
.bubble { top: 10%; left: 66%; }
/* the page's <main> must not form its own stacking context on the main page, or the videos cannot blend with the background */
body.play main { position: static; z-index: auto; }

/* the big words sit behind him, and are cut away along his outline (flame on top, round body), so he looks solid */
body.play { --mh: min(84vh, 730px, 136vw); }
.big-hi {
  position: absolute; left: 0; right: 0; top: 34%; margin-top: 0;
  transform: translate(calc(var(--px, 0) * -20px), calc(-50% + var(--py, 0) * -14px));
  -webkit-mask-image:
    radial-gradient(ellipse calc(var(--mh) * 0.31) calc(var(--mh) * 0.30) at 50% calc(50% + 18vh + var(--mh) * 0.115), transparent 0%, transparent 88%, #000 100%),
    radial-gradient(ellipse calc(var(--mh) * 0.17) calc(var(--mh) * 0.21) at 50% calc(50% + 18vh - var(--mh) * 0.20), transparent 0%, transparent 88%, #000 100%);
  mask-image:
    radial-gradient(ellipse calc(var(--mh) * 0.31) calc(var(--mh) * 0.30) at 50% calc(50% + 18vh + var(--mh) * 0.115), transparent 0%, transparent 88%, #000 100%),
    radial-gradient(ellipse calc(var(--mh) * 0.17) calc(var(--mh) * 0.21) at 50% calc(50% + 18vh - var(--mh) * 0.20), transparent 0%, transparent 88%, #000 100%);
  -webkit-mask-composite: source-in; mask-composite: intersect;
}
@media (prefers-reduced-motion: reduce) { .big-hi { transform: translateY(-50%); } }
@media (max-width: 860px) {
  .big-hi {
    top: 25%;
    -webkit-mask-image:
      radial-gradient(ellipse calc(var(--mh) * 0.31) calc(var(--mh) * 0.30) at 50% calc(50% + 27vh + var(--mh) * 0.115), transparent 0%, transparent 88%, #000 100%),
      radial-gradient(ellipse calc(var(--mh) * 0.17) calc(var(--mh) * 0.21) at 50% calc(50% + 27vh - var(--mh) * 0.20), transparent 0%, transparent 88%, #000 100%);
    mask-image:
      radial-gradient(ellipse calc(var(--mh) * 0.31) calc(var(--mh) * 0.30) at 50% calc(50% + 27vh + var(--mh) * 0.115), transparent 0%, transparent 88%, #000 100%),
      radial-gradient(ellipse calc(var(--mh) * 0.17) calc(var(--mh) * 0.21) at 50% calc(50% + 27vh - var(--mh) * 0.20), transparent 0%, transparent 88%, #000 100%);
  }
}

/* the big words: one line across the top, clear of the mascot, so nothing needs cutting away */
.big-hi {
  top: clamp(70px, 9vh, 110px); font-size: clamp(40px, 10vw, 190px); line-height: 1; white-space: nowrap; margin-top: 0;
  transform: translate(calc(var(--px, 0) * -14px), calc(var(--py, 0) * -8px));
  -webkit-mask-image: none; mask-image: none;
}
.big-hi span { display: inline; }
.big-hi span + span { margin-left: 0.28em; }
@media (max-width: 860px) {
  .big-hi { top: 15.5vh; font-size: 11.6vw; -webkit-mask-image: none; mask-image: none; }
}
@media (prefers-reduced-motion: reduce) { .big-hi { transform: none; } }
@media (max-width: 860px) { .big-hi { top: 19.5vh; } }

/* the two arrow buttons at the edges: left makes him run off and come back from the right, right makes him roll off and come back from the left */
.edge-btn {
  position: fixed; top: 54%; z-index: 12; width: clamp(54px, 5.2vw, 78px); aspect-ratio: 1; margin-top: calc(clamp(54px, 5.2vw, 78px) / -2); padding: 0; border-radius: 50%;
  display: grid; place-items: center; color: #eaf2ff; cursor: pointer; background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.22);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); -webkit-tap-highlight-color: transparent;
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1), background 0.2s, border-color 0.2s;
}
.edge-btn svg { width: 42%; height: 42%; }
.edge-left { left: clamp(14px, 4vw, 64px); }
.edge-right { right: clamp(14px, 4vw, 64px); }
.edge-btn:hover { background: rgba(255, 255, 255, 0.18); border-color: rgba(255, 255, 255, 0.5); transform: scale(1.1); }
.edge-btn:active { transform: scale(0.94); }
.edge-btn:focus-visible { outline: 3px solid #5fd6e6; outline-offset: 4px; }
.edge-btn::after { content: ''; position: absolute; inset: -1px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.35); animation: edgePulse 2.8s ease-out infinite; pointer-events: none; }
.edge-right::after { animation-delay: 1.4s; }
@keyframes edgePulse { 0% { transform: scale(1); opacity: 0.7; } 100% { transform: scale(1.5); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .edge-btn { display: none; } }

/* ---- menu: the logo and the four buttons glide in from the top one after another, and lift when you hover ---- */
body.play .brand, body.play .links.pills a { animation: dropIn 0.75s cubic-bezier(0.2, 0.9, 0.3, 1) backwards; }
body.play .brand { animation-delay: 0.1s; }
body.play .links.pills a:nth-child(1) { animation-delay: 0.25s; }
body.play .links.pills a:nth-child(2) { animation-delay: 0.34s; }
body.play .links.pills a:nth-child(3) { animation-delay: 0.43s; }
body.play .links.pills a:nth-child(4) { animation-delay: 0.52s; }
@keyframes dropIn { from { opacity: 0; transform: translateY(-30px) scale(0.92); } to { opacity: 1; transform: none; } }
body.play .links.pills a:hover { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(0, 0, 0, 0.4); }
body.play .links.pills a:active { transform: translateY(0) scale(0.96); box-shadow: none; }
@media (prefers-reduced-motion: reduce) {
  body.play .brand, body.play .links.pills a { animation: none; }
}

/* the run and roll clips are shown at the same scale as the idle loop but across the full page width, so he really leaves at the sides. The outer edges fade so he never gets cut off sharply on wide screens. */
.clip.full {
  inset: auto; left: 50%; top: 50%; width: calc(var(--mh) * 1.7778); height: var(--mh);
  margin-left: calc(var(--mh) * -0.8889); margin-top: calc(var(--mh) * -0.5); object-fit: cover;
}
/* on phones the arrows sit low in the corners, under him, so they never cover his hands */
@media (max-width: 860px) { .edge-btn { top: auto; bottom: 15vh; margin-top: 0; } }

@media (max-width: 860px) { body.play .links.pills { row-gap: 20px; padding-top: 6px; } }
@media (max-width: 860px) { .big-hi { top: 22.5vh; } }

/* ---- minimal menu: plain words with a dot between each, underline on hover ---- */
body.play nav .links.pills { gap: 0; align-items: center; }
body.play nav .links.pills a {
  position: relative; background: transparent; border: 0; border-radius: 0; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none;
  padding: 8px 14px; min-height: 40px; font-weight: 400; letter-spacing: 0.02em; color: #eaf2ff;
}
body.play nav .links.pills a + a::before { content: '\00B7'; position: absolute; left: -3px; top: 50%; transform: translateY(-52%); color: rgba(234, 242, 255, 0.45); font-weight: 700; }
body.play nav .links.pills a::after { content: ''; position: absolute; left: 14px; right: 14px; bottom: 6px; height: 1px; background: #eaf2ff; transform: scaleX(0); transform-origin: left; transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1); }
body.play nav .links.pills a:hover, body.play nav .links.pills a:active { background: transparent; border: 0; box-shadow: none; transform: none; }
body.play nav .links.pills a:hover::after, body.play nav .links.pills a:focus-visible::after { transform: scaleX(1); }

/* Home is now in the home menu too: five items, current page underlined like the inner pages */
body.play .links.pills a:nth-child(1) { animation-delay: 0.2s; }
body.play .links.pills a:nth-child(2) { animation-delay: 0.28s; }
body.play .links.pills a:nth-child(3) { animation-delay: 0.36s; }
body.play .links.pills a:nth-child(4) { animation-delay: 0.44s; }
body.play .links.pills a:nth-child(5) { animation-delay: 0.52s; }
body.play nav .links.pills a.on::after { transform: scaleX(1); }
