/* ===== Gringo hero (homepage): the real Gringo sniffs, sits, follows the cursor, then goes into the photo =====
   z-order: page + header (1000) < veil (1100) < Gringo + texts (1200) */
@font-face {
  font-family: "Reenie Beanie";
  src: url("../fonts/ReenieBeanie-Regular.woff2") format("woff2");
  font-display: swap;
}
:root {
  --gr-tint-rgb: 16, 16, 16;
  --gr-ink: #F4EFE6;
  --gr-halo: rgba(16, 16, 16, 0.55);
}
:root[data-theme="light"] {
  --gr-tint-rgb: 254, 253, 251;
  --gr-ink: #1A1A1A;
  --gr-halo: rgba(254, 253, 251, 0.75);
}
.gr-pin { position: relative; }
.gr-pin > .hero { position: sticky; }
/* the 3D pup only comes once the real Gringo has gone into the photo */
/* parked off screen, not display:none: the WebGL canvas is already composited, so showing it later
   does not make iOS rebuild its layers (that flashed the whole screen) */
html:not(.gr-done):not(.gr-pup) .gr-pin .dog-intro { transform: translateX(-300vw); }
/* done: the hero is the normal page again (no pin), Gringo + veil are gone for this page view */
/* stays position: sticky; only its sticking point goes. Switching sticky -> relative made iOS rebuild its layers,
   and for two frames it drew neither the photo nor the (sticky) header: a flash */
.gr-done .gr-pin > .hero { top: auto !important; }
.gr-done .gr, .gr-done .gr-veil, .gr-done .gr-say { visibility: hidden; pointer-events: none; }
/* and once the scroll is at rest they are taken out completely: hidden fixed layers (one with backdrop-filter)
   made iOS drop the photo, cards and header for a few frames whenever Safari's toolbar changed size */
.gr-gone .gr, .gr-gone .gr-veil, .gr-gone .gr-say { display: none; }
/* and the hero is a normal block again, exactly like the page without the Gringo hero: a hero that stayed
   position: sticky got redrawn by iOS whenever Safari's toolbar changed size (photo + header flashed) */
.gr-gone .gr-pin > .hero { position: relative; }
/* intro skipped (in-site navigation, back/forward, #hash; set in index.html's <head>): the hero is there at once */
.gr-skip .hero__text > * { animation: none !important; }

/* fixed layers as tall as the large viewport (Safari clips them there anyway) */
.gr-veil {
  position: fixed; left: 0; right: 0; top: 0; bottom: auto; height: 100vh; height: 100lvh; z-index: 1100;
  /* blur AND saturation ease out together: a saturate that stayed at 1.15 until the veil switched off made the
     colours jump at the very end (a flash when scrolling fast) */
  -webkit-backdrop-filter: blur(calc(var(--gr-blur, 12) * 1px)) saturate(var(--gr-sat, 1.15));
  backdrop-filter: blur(calc(var(--gr-blur, 12) * 1px)) saturate(var(--gr-sat, 1.15));
  background: rgba(var(--gr-tint-rgb), var(--gr-tint, 0.35));
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .gr-veil { background: rgba(var(--gr-tint-rgb), calc(var(--gr-tint, 0.35) * 2.5)); }
}
.gr-veil.is-passive { pointer-events: none; }
.gr-veil.is-off { visibility: hidden; }

.gr { position: fixed; left: 0; right: 0; top: 0; height: 100vh; height: 100lvh; z-index: 1200; pointer-events: none; overflow: hidden; }
.gr__stage {
  position: absolute; left: 0; top: 0; width: 1600px; height: 1000px;
  transform-origin: 0 0; will-change: transform, opacity;
}
.gr__intro, .gr__canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
/* touch screens: the close-up's frame edge (a cut through his chest) fades out before the screen edge,
   so Safari never samples dark fur into the strip under its toolbar */
@media (hover: none) {
  .gr__intro { -webkit-mask-image: linear-gradient(to bottom, #000 80%, transparent 99%); mask-image: linear-gradient(to bottom, #000 80%, transparent 99%); }
}
.gr__canvas { opacity: 0; transform-origin: 50% 100%; }
/* hand-over (from hero5): the sweep frame is shown at once UNDER the video, then only the video fades out */
.gr.is-follow .gr__canvas { opacity: 1; }
.gr.is-follow .gr__intro { opacity: 0; transition: opacity 140ms ease-out; }

.gr-say {
  position: fixed; left: 0; top: 0; z-index: 1200; margin: 0; pointer-events: none;
  font-family: "Reenie Beanie", cursive; font-weight: 400;
  font-size: clamp(34px, 3.4vw, 72px); line-height: 1;
  color: var(--gr-ink);
  text-shadow: 0 0 14px var(--gr-halo), 0 0 4px var(--gr-halo);
  white-space: pre; opacity: var(--gr-say-o, 1);
}
.gr-sniff { font-size: clamp(42px, 4vw, 84px); }
.gr-say.on-fur { --gr-ink: #F4EFE6; --gr-halo: rgba(0, 0, 0, 0.5); }
.gr-say__line { display: block; }
/* "Sniff..." / "Who dis?": each part in on the beat, out together (250 ms, a few px up) */
.gr-sniff .gr-say__line { opacity: 0; transform: translateY(4px); transition: opacity 220ms ease-out, transform 320ms cubic-bezier(.2, .7, .2, 1); }
.gr-sniff .gr-say__line.on { opacity: 1; transform: none; }
.gr-sniff.is-out .gr-say__line { opacity: 0; transform: translateY(-6px); transition-duration: 250ms; }
/* "Howl u doin?": written by hand, letter by letter */
.gr-howl .l { display: inline-block; opacity: 0; transform: translateY(2px) rotate(var(--r, 0deg)); clip-path: inset(-20% 100% -20% -10%);
  transition: opacity 160ms ease-out, transform 260ms cubic-bezier(.2, .7, .2, 1), clip-path 200ms ease-out; }
.gr-howl .l.on { opacity: 1; transform: rotate(var(--r, 0deg)); clip-path: inset(-20% -20% -20% -10%); }
.gr-howl.is-shown .l { transition: opacity 300ms ease-out; opacity: 1; transform: rotate(var(--r, 0deg)); clip-path: none; }

@media (prefers-reduced-motion: reduce) {
  .gr-sniff .gr-say__line, .gr-howl .l { transition: none !important; }
}
