/* =================================================
   MOTIFS: decorative background/foreground layers,
   frosted glass, the whimsy animation library, and
   the big "shout" words (FUN / YES, AND).
   ================================================= */

/* Foreground motifs — above content */
.foreground-motifs {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 100;
}

.fg-motif {
  position: absolute;
  user-select: none;
}

.fg-motif-lightning {
  width: 96px;
  bottom: 12%;
  right: -18px;
  transform: rotate(12deg);
  opacity: 0.95;
  filter: drop-shadow(2px 4px 6px rgba(0, 0, 0, 0.18));
}

.fg-motif-pacman {
  width: 108px;
  top: 38%;
  left: -22px;
  transform: rotate(-15deg) scaleX(-1);
  opacity: 0.95;
  filter: drop-shadow(-2px 4px 6px rgba(0, 0, 0, 0.15));
}

@media (max-width: 600px) {
  .fg-motif-lightning { width: 64px; right: -12px; }
  .fg-motif-pacman    { width: 72px; left: -16px;  }
}

/* Scattered motifs — fixed full-page layer */
.page-motifs {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

/* Frosted glass pane between the motif layer and the content. It blurs and
   lightly veils the moving motifs so the shapes stay ambient texture instead
   of pulling focus. Shares z-index 0 with .page-motifs but comes later in the
   DOM, so it stacks above them while still sitting beneath the content. */
.page-frost {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: rgba(255, 251, 245, 0.22);
  backdrop-filter: blur(6px) saturate(115%);
  -webkit-backdrop-filter: blur(6px) saturate(115%);
}

body > *:not(.page-motifs):not(.page-frost) {
  position: relative;
  z-index: 1;
}

/* The header (and its mobile dropdown) must sit above page content, so it
   overrides the blanket z-index:1 above. The :not() pairs match the specificity
   of the rule above; declared later, so this wins the tie. */
body > .site-header:not(.page-motifs):not(.page-frost) {
  z-index: 30;
}

.motif {
  position: absolute;
  opacity: 0.38;
  user-select: none;
  /* Each motif's tilt lives in --motif-rot; the animations layer movement on
     top of it. animation-name/duration/delay are assigned per-motif below. */
  will-change: transform;
  animation-iteration-count: infinite;
}

/* --- Whimsy animation library -------------------------------------------
   A spread of distinct motions: lazy float, end-over-end tumble, a pendulum
   sway, a heartbeat pop, a slow spin, and two travelling moves (zoom across,
   tumble down) that periodically send a shape sailing through the layout. The
   travelling ones spend most of their cycle off-screen, so they read as
   occasional surprises. ------------------------------------------------------ */

@keyframes motif-float {
  0%, 100% { transform: var(--motif-rot) translateY(0); }
  50%      { transform: var(--motif-rot) translateY(-14px); }
}

@keyframes motif-tumble {
  0%   { transform: var(--motif-rot) rotate(0deg) translateY(0); }
  50%  { transform: var(--motif-rot) rotate(180deg) translateY(-10px); }
  100% { transform: var(--motif-rot) rotate(360deg) translateY(0); }
}

@keyframes motif-sway {
  0%, 100% { transform: var(--motif-rot) rotate(-12deg); }
  50%      { transform: var(--motif-rot) rotate(12deg); }
}

@keyframes motif-pop {
  0%, 70%, 100% { transform: var(--motif-rot) scale(1); }
  78%           { transform: var(--motif-rot) scale(1.35); }
  86%           { transform: var(--motif-rot) scale(0.9); }
  92%           { transform: var(--motif-rot) scale(1.08); }
}

@keyframes motif-spin {
  from { transform: var(--motif-rot) rotate(0deg); }
  to   { transform: var(--motif-rot) rotate(360deg); }
}

/* Sails left-to-right across the viewport, spinning, invisible the rest of the
   cycle so it feels like an occasional fly-by. */
@keyframes motif-zoom {
  0%   { transform: translateX(-30vw) rotate(0deg); opacity: 0; }
  6%   { opacity: 0.6; }
  40%  { opacity: 0.6; }
  46%  { transform: translateX(120vw) rotate(540deg); opacity: 0; }
  100% { transform: translateX(120vw) rotate(540deg); opacity: 0; }
}

/* Tumbles down from above the fold, end over end, then rests off-screen. */
@keyframes motif-drop {
  0%   { transform: translateY(-40vh) rotate(0deg); opacity: 0; }
  8%   { opacity: 0.38; }
  38%  { transform: translateY(115vh) rotate(720deg); opacity: 0; }
  100% { transform: translateY(115vh) rotate(720deg); opacity: 0; }
}

/* Breaks through to foreground layer: expands and rises briefly, then settles. */
@keyframes motif-breakthrough {
  0%   { z-index: 1; opacity: 0.38; transform: var(--motif-rot) scale(1); }
  12%  { z-index: 1; opacity: 0.38; transform: var(--motif-rot) scale(1); }
  15%  { z-index: 1000; opacity: 0.7; transform: var(--motif-rot) scale(1.3) translateY(-20px); filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.25)); }
  35%  { z-index: 1000; opacity: 0.7; transform: var(--motif-rot) scale(1.25) translateY(-8px); }
  50%  { z-index: 1000; opacity: 0.6; transform: var(--motif-rot) scale(1.1) translateY(-2px); }
  65%  { z-index: 1; opacity: 0.38; transform: var(--motif-rot) scale(1); filter: drop-shadow(0 0px 0px rgba(0, 0, 0, 0)); }
  100% { z-index: 1; opacity: 0.38; transform: var(--motif-rot) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .motif { animation: none !important; }
}

/* Each motif sets its tilt via --motif-rot, then picks one motion. Durations
   and delays are deliberately uneven (prime-ish) so the layer never falls into
   a visible rhythm. */
.motif-1  { width: 78px;  top: 4%;   left: 3%;    --motif-rot: rotate(-15deg); animation-name: motif-breakthrough; animation-duration: 47s; animation-delay: -8s;  animation-timing-function: ease-in-out; }
.motif-2  { width: 104px; top: 3%;   right: 4%;   --motif-rot: rotate(10deg);  animation-name: motif-breakthrough; animation-duration: 53s; animation-delay: -12s; animation-timing-function: ease-in-out; }
.motif-3  { width: 82px;  top: 12%;  left: 22%;   --motif-rot: rotate(-22deg); animation-name: motif-breakthrough; animation-duration: 61s; animation-delay: -18s; animation-timing-function: ease-in-out; }
.motif-4  { width: 66px;  top: 14%;  right: 20%;  --motif-rot: rotate(8deg);   animation-name: motif-breakthrough; animation-duration: 43s; animation-delay: -5s;  animation-timing-function: ease-in-out; }
.motif-5  { width: 60px;  top: 8%;   left: 50%;   --motif-rot: rotate(20deg);  animation-name: motif-breakthrough; animation-duration: 59s; animation-delay: -22s; animation-timing-function: ease-in-out; }
.motif-6  { width: 84px;  top: 28%;  right: 6%;   --motif-rot: rotate(-30deg); animation-name: motif-breakthrough; animation-duration: 51s; animation-delay: -11s; animation-timing-function: ease-in-out; }
.motif-7  { width: 76px;  top: 38%;  left: 8%;    --motif-rot: rotate(18deg);  animation-name: motif-breakthrough; animation-duration: 67s; animation-delay: -25s; animation-timing-function: ease-in-out; }
.motif-8  { width: 92px;  top: 32%;  right: 24%;  --motif-rot: rotate(-5deg);  animation-name: motif-breakthrough; animation-duration: 55s; animation-delay: -9s;  animation-timing-function: ease-in-out; }
.motif-9  { width: 70px;  top: 52%;  left: 28%;   --motif-rot: rotate(-12deg); animation-name: motif-breakthrough; animation-duration: 63s; animation-delay: -21s; animation-timing-function: ease-in-out; }
.motif-10 { width: 86px;  top: 58%;  right: 5%;   --motif-rot: rotate(25deg);  animation-name: motif-breakthrough; animation-duration: 41s; animation-delay: -6s;  animation-timing-function: ease-in-out; }
.motif-11 { width: 80px;  top: 68%;  left: 4%;    --motif-rot: rotate(-20deg); animation-name: motif-breakthrough; animation-duration: 58s; animation-delay: -17s; animation-timing-function: ease-in-out; }
.motif-12 { width: 70px;  top: 74%;  right: 28%;  --motif-rot: rotate(40deg);  animation-name: motif-breakthrough; animation-duration: 49s; animation-delay: -14s; animation-timing-function: ease-in-out; }
.motif-13 { width: 88px;  top: 46%;  left: 55%;   --motif-rot: rotate(-8deg);  animation-name: motif-breakthrough; animation-duration: 71s; animation-delay: -28s; animation-timing-function: ease-in-out; }
.motif-14 { width: 82px;  top: 84%;  left: 18%;   --motif-rot: rotate(15deg);  animation-name: motif-breakthrough; animation-duration: 45s; animation-delay: -7s;  animation-timing-function: ease-in-out; }
.motif-15 { width: 102px; top: 87%;  right: 3%;   --motif-rot: rotate(-18deg); animation-name: motif-breakthrough; animation-duration: 57s; animation-delay: -15s; animation-timing-function: ease-in-out; }
.motif-16 { width: 92px;  top: 92%;  left: 60%;   --motif-rot: rotate(30deg);  animation-name: motif-breakthrough; animation-duration: 69s; animation-delay: -26s; animation-timing-function: ease-in-out; }

@media (max-width: 600px) {
  .motif { opacity: 0.28; }
  .motif-1  { width: 50px; }
  .motif-2  { width: 62px; }
  .motif-3, .motif-5, .motif-8, .motif-13 { display: none; }
  .motif-4  { width: 44px; }
  .motif-6  { width: 56px; }
  .motif-7  { width: 52px; }
  .motif-9  { width: 46px; }
  .motif-10 { width: 56px; }
  .motif-11 { width: 52px; }
  .motif-12 { width: 46px; }
  .motif-14 { width: 54px; }
  .motif-15 { width: 64px; }
  .motif-16 { width: 60px; }
}

/* -------------------------------------------------
   SHOUT WORDS (FUN / YES, AND / random shouts)
------------------------------------------------- */

/* Oversized, tilted "FUN" — the loud brand accent. Outlined so it reads as a
   graphic element rather than body copy. */
.fun-shout {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(4rem, 15vw, 9rem);
  line-height: 0.85;
  letter-spacing: -0.03em;
  color: transparent;
  -webkit-text-stroke: 3px var(--ink);
  transform: rotate(-7deg);
  transform-origin: left center;
  user-select: none;
  pointer-events: none;
  /* Let the tilted word breathe past the panel's padding. Negative top margin
     tucks it up toward the eyebrow. */
  margin: -0.3rem 0 0.4rem -0.15em;
  display: inline-block;
}

/* The three dots of color sit just inside the outline so FUN isn't only
   black-and-cream. */
.fun-shout .fun-f { -webkit-text-stroke-color: var(--yellow); }
.fun-shout .fun-u { -webkit-text-stroke-color: var(--green); }
.fun-shout .fun-n { -webkit-text-stroke-color: var(--blue); }

@media (prefers-reduced-motion: no-preference) {
  .fun-shout { animation: fun-wobble 5s ease-in-out infinite; }
}

@keyframes fun-wobble {
  0%, 100% { transform: rotate(-7deg); }
  50%      { transform: rotate(-3deg) translateY(-4px); }
}

/* Second shout: "YES, AND" — the improv credo, used as a divider above the
   "Who We Are" section. Tilts the opposite way from FUN so the two big words
   echo each other down the page. */
.yesand-shout {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.6rem, 11vw, 6.5rem);
  line-height: 0.85;
  letter-spacing: -0.03em;
  color: transparent;
  -webkit-text-stroke: 3px var(--ink);
  transform: rotate(4deg);
  transform-origin: right center;
  user-select: none;
  pointer-events: none;
  margin: 0.4rem 0 1.2rem;
  text-align: right;
  display: block;
}

.yesand-shout .yesand-yes { -webkit-text-stroke-color: var(--pink); }
.yesand-shout .yesand-and { -webkit-text-stroke-color: var(--blue); }

@media (prefers-reduced-motion: no-preference) {
  .yesand-shout { animation: yesand-wobble 6s ease-in-out infinite; }
}

@keyframes yesand-wobble {
  0%, 100% { transform: rotate(4deg); }
  50%      { transform: rotate(1deg) translateY(-4px); }
}

@media (max-width: 600px) {
  .fun-shout    { font-size: clamp(3.2rem, 18vw, 7rem); }
  .yesand-shout { font-size: clamp(2.2rem, 13vw, 5.5rem); }
}

/* Random rotating shout words sprinkled between sections. */
.random-shout {
  margin: 0.8rem 0;
  text-align: center;
  font-size: 0;
}

.random-shout span {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.4rem, 8vw, 2.2rem);
  line-height: 0.9;
  letter-spacing: -0.02em;
  color: transparent;
  -webkit-text-stroke: 2px;
  -webkit-text-stroke-color: var(--random-stroke, #f5c400);
  transform: rotate(var(--random-rotation, -3deg));
  user-select: none;
  pointer-events: none;
  display: inline-block;
  animation: shout-entrance 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes shout-entrance {
  from {
    opacity: 0;
    transform: rotate(var(--random-rotation, -3deg)) scale(0.8);
  }
  to {
    opacity: 1;
    transform: rotate(var(--random-rotation, -3deg)) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .random-shout span { animation: none; }
}
