/** Shared ATOMIC atom logo — 3 oval orbits (0°, 60°, 120°) each with a ball. */
(function (w) {
  "use strict";

  var ORBIT_PATH =
    "M 25 100 A 75 28 0 1 0 175 100 A 75 28 0 1 0 25 100";

  function orbitGroup(angle, duration, delay) {
    return (
      '<g transform="rotate(' +
      angle +
      ' 100 100)">' +
      '<ellipse cx="100" cy="100" rx="75" ry="28" fill="none" stroke="currentColor" stroke-width="4" opacity="0.95"/>' +
      '<circle r="9" fill="currentColor">' +
      '<animateMotion dur="' +
      duration +
      's" repeatCount="indefinite" begin="' +
      (delay || 0) +
      's" path="' +
      ORBIT_PATH +
      '"/>' +
      "</circle></g>"
    );
  }

  w.ATOMIC_LOGO_SVG =
    '<svg class="atomic-logo" viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">' +
    '<circle cx="100" cy="100" r="14" fill="currentColor"/>' +
    orbitGroup(0, 2.4, 0) +
    orbitGroup(60, 2.8, 0.35) +
    orbitGroup(120, 3.1, 0.7) +
    "</svg>";

  w.mountAtomicLogo = function () {
    document.querySelectorAll("[data-atomic-logo]").forEach(function (el) {
      if (el.dataset.mounted === "1") return;
      el.dataset.mounted = "1";
      el.innerHTML = w.ATOMIC_LOGO_SVG;
    });
  };

  if (document.readyState === "loading") {
    document.addEventListener("DOMContentLoaded", w.mountAtomicLogo);
  } else {
    w.mountAtomicLogo();
  }
})(window);
