/* The footer badge: the mark, its loop, and the credit line beside it.
   Served at /shared/brand/badge.css on every site after `npm run sync`.

   Deliberately free of the business name, including in these comments, so this one file can
   also be dropped into the back office — whose tests fail if the name appears anywhere under
   public/, since every brand word there is filled in by the Worker at request time.

   It inherits the client's own footer text colour through currentColor, so it
   never fights their palette: the only fixed colour is the gold light, which is
   the one thing anybody notices. Nothing here needs JavaScript.

   The markup to go with it is badge.html. */

.ns-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: inherit;
  text-decoration: none;
  font: 500 12px/1 var(--ns-badge-font, Inter, system-ui, -apple-system, sans-serif);
  letter-spacing: 0.04em;
}

.ns-badge > svg { flex: none; display: block; }

.ns-badge-name {
  font-family: var(--ns-badge-serif, Spectral, Georgia, "Times New Roman", serif);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.ns-badge:hover .ns-badge-name,
.ns-badge:focus-visible .ns-badge-name { text-decoration: underline; }

/* ---- the 7-second loop ----------------------------------------------------
   1. the fish unzips, nose to tail            (stroke-dashoffset)
   2. its light carries across, becoming the site's favicon   (transform)
   3. the window opens out of that corner       (transform + opacity)
   4. the page builds, a piece at a time        (opacity)
   Then it collapses back and the fish draws itself on again.
   Three properties only, all of them compositor-friendly.                   */

.ns-badge-fish {
  stroke-dasharray: 260;
  animation: ns-badge-fish 7s cubic-bezier(.5, 0, .3, 1) infinite;
}
.ns-badge-light {
  transform-box: fill-box;
  transform-origin: center;
  animation: ns-badge-light 7s cubic-bezier(.5, 0, .3, 1) infinite;
}
.ns-badge-win {
  transform-box: fill-box;
  transform-origin: left top;
  animation: ns-badge-win 7s cubic-bezier(.4, 0, .2, 1) infinite;
}
.ns-badge-a { animation: ns-badge-a 7s ease-out infinite; }
.ns-badge-b { animation: ns-badge-b 7s ease-out infinite; }

/* The gold is the one colour the badge does not inherit. The default suits a light footer;
   a dark one adds the --dark modifier to the badge itself. A class rather than a style
   attribute on purpose: some of these sites send a CSP that refuses inline styles. */
.ns-badge-a,
.ns-badge-light { fill: var(--ns-gold, #C98A2E); }

.ns-badge--dark { --ns-gold: #F6D592; }

@keyframes ns-badge-fish {
  0%, 10%   { stroke-dashoffset: 0; }
  22%, 80%  { stroke-dashoffset: 260; }
  92%, 100% { stroke-dashoffset: 0; }
}
@keyframes ns-badge-light {
  0%, 10%   { transform: none; }
  22%, 80%  { transform: translate(-56px, -25px) scale(0.62); }
  92%, 100% { transform: none; }
}
@keyframes ns-badge-win {
  0%, 14%   { opacity: 0; transform: scale(0.18); }
  26%, 74%  { opacity: 1; transform: scale(1); }
  84%, 100% { opacity: 0; transform: scale(0.18); }
}
@keyframes ns-badge-a {
  0%, 27%   { opacity: 0; }
  34%, 74%  { opacity: 1; }
  80%, 100% { opacity: 0; }
}
@keyframes ns-badge-b {
  0%, 32%   { opacity: 0; }
  39%, 74%  { opacity: 1; }
  80%, 100% { opacity: 0; }
}

/* Someone who has asked their system for less motion gets the still mark:
   the lit fish, which is the static logo anyway. */
@media (prefers-reduced-motion: reduce) {
  .ns-badge-fish,
  .ns-badge-light,
  .ns-badge-win,
  .ns-badge-a,
  .ns-badge-b { animation: none; }
  .ns-badge-fish { stroke-dashoffset: 0; }
  .ns-badge-win,
  .ns-badge-a,
  .ns-badge-b { opacity: 0; }
}
