/* =========================================================================
   ORBIT HERO
   The rotating ring of national flags around a static community photograph.
   Ported from divi5-rotating-flags-hero.html and put on tokens.

   Loaded only on pages that use [cgmoh_orbit_hero]; see inc/shortcodes.php.

   On motion: this is the one continuous animation in the system, and it is a
   deliberate exception to "motion confirms an interaction". It is slow (80s
   for a full turn, below the threshold where the eye reads it as movement),
   it pauses on hover so a visitor can read a flag, and it stops entirely
   under prefers-reduced-motion. Do not add a second exception.
   ========================================================================= */

.cgmoh-orbit-hero,
.cgmoh-orbit-hero * { box-sizing: border-box; }

.cgmoh-orbit-hero {
  position: relative;
  width: min(88vw, 560px);
  aspect-ratio: 1;
  margin-inline: auto;
  isolation: isolate;
}

/* The orbit and portrait move as one composed disc, independent of the hands. */
.cgmoh-orbit-hero__disc {
  position: absolute;
  inset: 0;
  z-index: 2;
  transform: translateY(-11%);
}

/* Two fine orbits give the flags a route without turning the centre into a white donut. */
.cgmoh-orbit-hero__ring {
  position: absolute;
  inset: 4%;
  z-index: 1;
  border: 2px solid rgba(255, 248, 236, .92);
  border-radius: 50%;
  background: transparent;
  box-shadow: 0 0 0 1px rgba(11, 122, 69, .22);
}

.cgmoh-orbit-hero__ring::after {
  content: "";
  position: absolute;
  inset: 9%;
  border: 1.5px solid rgba(242, 176, 30, .72);
  border-radius: 50%;
}

/* The static centre sits inside the inner orbit with a deliberately light rim. */
.cgmoh-orbit-hero__center {
  position: absolute;
  inset: 15%;
  z-index: 2;
  overflow: hidden;
  border: 3px solid #FFF8EC;
  border-radius: 50%;
  outline: 2px solid var(--green-600, #0B7A45);
  background: #FFFFFF;
}

.cgmoh-orbit-hero__center img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* The layer that turns. */
.cgmoh-orbit-hero__orbit {
  position: absolute;
  inset: 4%;
  z-index: 3;
  animation: cgmoh-orbit-spin 80s linear infinite;
}

.cgmoh-orbit-hero__flag-slot {
  position: absolute;
  inset: 0;
  transform: rotate(var(--angle));
}

.cgmoh-orbit-hero__flag {
  position: absolute;
  top: 0;
  left: 50%;
  display: block;
  width: clamp(34px, 3.6vw, 46px);
  aspect-ratio: 1;
  overflow: hidden;
  border: 2px solid #FFFFFF;
  border-radius: 50%;
  background: #FFFFFF;
  object-fit: cover;
  transform: translate(-50%, -50%) rotate(var(--counter-angle));
  animation: cgmoh-flag-counter-spin 80s linear infinite;
}

/* Multiple hands rise from the base of the orbit. The artwork stays decorative
   and never participates in the orbit animation. */
.cgmoh-orbit-hero__hearts {
  position: absolute;
  left: 50%;
  bottom: -24%;
  z-index: 4;
  width: 84%;
  max-width: none;
  transform: translateX(-50%);
  pointer-events: none;
  opacity: .76;
  filter: drop-shadow(0 4px 10px rgba(4, 60, 38, .22));
}

@media (max-width: 980px) {
  .cgmoh-orbit-hero__disc { transform: translateY(-8%); }
  .cgmoh-orbit-hero__hearts { bottom: -18%; }
}

@media (max-width: 479px) {
  .cgmoh-orbit-hero { width: min(76vw, 296px); }
  .cgmoh-orbit-hero__disc { transform: translateY(-6%); }
  .cgmoh-orbit-hero__flag { width: 34px; }
  .cgmoh-orbit-hero__hearts { bottom: -10%; width: 90%; }
}

@keyframes cgmoh-orbit-spin {
  to { transform: rotate(360deg); }
}

/* Cancels the orbit's rotation for the artwork only, so flags stay upright. */
@keyframes cgmoh-flag-counter-spin {
  to { transform: translate(-50%, -50%) rotate(calc(var(--counter-angle) - 360deg)); }
}

/* A pause lets a visitor read an individual flag. */
.cgmoh-orbit-hero:hover .cgmoh-orbit-hero__orbit,
.cgmoh-orbit-hero:hover .cgmoh-orbit-hero__flag,
.cgmoh-orbit-hero:focus-within .cgmoh-orbit-hero__orbit,
.cgmoh-orbit-hero:focus-within .cgmoh-orbit-hero__flag {
  animation-play-state: paused;
}

@media (prefers-reduced-motion: reduce) {
  .cgmoh-orbit-hero__orbit,
  .cgmoh-orbit-hero__flag { animation: none; }
}
