/* Kool & The Gang accent utilities. Requires kg-tokens.css. */

.kg {
  display: block;
  color: var(--kg-gold);
  pointer-events: none;
}

.kg--gold  { color: var(--kg-gold); }
.kg--ember { color: var(--kg-ember); }
.kg--teal  { color: var(--kg-teal); }
.kg--plum  { color: var(--kg-plum); }
.kg--bone  { color: var(--kg-bone); }

.kg--watermark { opacity: var(--kg-accent-watermark); }
.kg--ambient   { opacity: var(--kg-accent-ambient); }

/* Sit an accent over client photo or video without fighting it. */
.kg-over-media { mix-blend-mode: screen; }
.kg-over-media--light { mix-blend-mode: multiply; }

/* Backgrounds */
.kg-bg-rules {
  background-image: repeating-linear-gradient(
    108deg,
    currentColor 0 6px,
    transparent 6px 22px
  );
}

/* Masked, not a background-image. The tile is drawn in currentColor, and currentColor in
   a background-image resolves to black rather than to the element's color -- which made
   this class invisible on a dark ground and unresponsive to the `color` the docs tell you
   to set. As a mask the fill is genuinely currentColor.

   The mask property belongs to this class. To fade or shape the screen, override
   `background` on the element (a gradient works) rather than reaching for mask again. */
.kg-bg-halftone {
  background-color: currentColor;
  -webkit-mask: url("../svg/patterns/halftone-tile.svg") left top / 20px 20px repeat;
          mask: url("../svg/patterns/halftone-tile.svg") left top / 20px 20px repeat;
}

.kg-bg-grain {
  background-image: url("../svg/patterns/grain.svg");
  background-size: 300px 300px;
  background-repeat: repeat;
  mix-blend-mode: overlay;
  opacity: 0.5;
}

/* Scroll reveal, paired with kg-reveal.js.

   Animations, not a transition, and that is a correctness choice rather than a stylistic
   one. A transition lives on the `transition` property, so any element that declares its
   own -- a card with a hover border, say -- replaces this one with its shorthand and the
   reveal silently stops running, stagger included. Nothing errors and nothing logs; the
   element simply appears. Animations occupy a different property and compose instead of
   colliding, so a reveal can go on any element without first auditing what else it
   transitions.

   Two animations rather than one, because the curves differ by property and a single
   animation cannot carry two. The fade glides; the movement snaps. The snap is what makes
   the entrance percussive -- MOTION.md rules out the standard-ease fade-up by name, and
   this is the rule that keeps the reveal on the right side of it.

   The rise lives only in the keyframe, never in the base rule. That way an element whose
   animation never runs sits at its natural position rather than 18px adrift. */
@keyframes kg-reveal-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes kg-reveal-rise {
  from { transform: translateY(18px); }
  to   { transform: none; }
}

.kg-reveal { opacity: 0; }
.kg-reveal.is-in {
  animation:
    kg-reveal-fade var(--kg-dur-mid) var(--kg-ease-glide) both,
    kg-reveal-rise var(--kg-dur-mid) var(--kg-ease-snap) both;
}

/* After `.is-in`, deliberately: its shorthand resets animation-delay, so these have to
   land later in the cascade to survive. Three steps and no more -- a stagger longer than
   about a third of a second stops reading as one gesture and starts reading as a
   slideshow. Stagger a row of cards that arrive together; a vertical list does not need
   it, since each item already fires on its own entry. */
.kg-reveal[data-kg-delay="1"] { animation-delay: 90ms; }
.kg-reveal[data-kg-delay="2"] { animation-delay: 180ms; }
.kg-reveal[data-kg-delay="3"] { animation-delay: 270ms; }

@media (prefers-reduced-motion: reduce) {
  .kg-reveal { opacity: 1; transform: none; animation: none; }
}
