.mod-facebox-circle {
  --mfc-photo: 8rem;
  --mfc-toggle: 2.5rem;
  --mfc-radius: 5.25rem;
  --mfc-size: 2.5rem;
  /* The links fan out over --mfc-span degrees starting at --mfc-start (0deg = right, 90deg = down),
     so by default they open downwards, away from the photo and the text beside it. */
  --mfc-start: 10deg;
  --mfc-span: 160deg;
  --mfc-duration: .45s;
  --mfc-stagger: 50ms;
  /* Centre of the toggle: on the photo's edge at its bottom-right (45deg), pushed slightly outwards. */
  --mfc-anchor: calc(var(--mfc-photo) * .87);
  display: grid;
  grid-template-columns: var(--mfc-photo) 1fr;
  gap: 1.5rem;
  align-items: center;
}

.mod-facebox-circle__media {
  position: relative;
  width: var(--mfc-photo);
  height: var(--mfc-photo);
}

.mod-facebox-circle__info {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  min-width: 0;
}

.mod-facebox-circle__name {
  margin: 0;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--bs-border-color, #dee2e6);
  font-size: 1.25rem;
  font-weight: 600;
}

.mod-facebox-circle__content {
  color: var(--bs-secondary-color, #6c757d);
  font-size: .9rem;
}

.mod-facebox-circle__content > :last-child {
  margin-bottom: 0;
}

/* Small screens: keep photo and text side by side, with a smaller photo and ring. */
@media (max-width: 30rem) {
  .mod-facebox-circle {
    --mfc-photo: 6rem;
    --mfc-toggle: 2.25rem;
    --mfc-radius: 4.5rem;
    --mfc-size: 2.25rem;
    --mfc-start: 15deg;
    --mfc-span: 150deg;
    gap: 1rem;
  }
}

.mod-facebox-circle__avatar {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background-color: var(--bs-tertiary-bg, #f8f9fa);
  border-radius: 50%;
}

.mod-facebox-circle__toggle {
  position: absolute;
  top: calc(var(--mfc-anchor) - var(--mfc-toggle) / 2);
  left: calc(var(--mfc-anchor) - var(--mfc-toggle) / 2);
  z-index: 3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--mfc-toggle);
  height: var(--mfc-toggle);
  padding: 0;
  font-size: 1rem;
  color: var(--bs-white, #fff);
  cursor: pointer;
  background-color: var(--bs-primary, #0d6efd);
  border: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 3px var(--bs-body-bg, #fff), 0 .25rem .75rem rgba(0, 0, 0, .25);
}

.mod-facebox-circle__toggle[hidden] {
  display: none;
}

.mod-facebox-circle__toggle > [aria-hidden] {
  transition: transform var(--mfc-duration) ease;
}

.mod-facebox-circle__toggle[aria-expanded="true"] > [aria-hidden] {
  transform: rotate(180deg);
}

.mod-facebox-circle__toggle:focus-visible,
.mod-facebox-circle__links a:focus-visible {
  outline: 2px solid var(--bs-primary, #0d6efd);
  outline-offset: 3px;
}

/* A zero-size anchor at the toggle's centre; the links are placed around it. */
.mod-facebox-circle__links {
  position: absolute;
  top: var(--mfc-anchor);
  left: var(--mfc-anchor);
  z-index: 2;
  width: 0;
  height: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Each link sits on the arc at its own angle; the second rotate keeps the icon upright. */
.mod-facebox-circle__links li {
  --mfc-angle: calc(var(--mfc-start) + var(--mfc-span) * (var(--mfc-i) + .5) / var(--mfc-count));
  position: absolute;
  top: 0;
  left: 0;
  width: var(--mfc-size);
  height: var(--mfc-size);
  margin: calc(var(--mfc-size) / -2) 0 0 calc(var(--mfc-size) / -2);
  transform: rotate(var(--mfc-angle)) translateX(var(--mfc-radius)) rotate(calc(-1 * var(--mfc-angle))) scale(1);
  transition:
    transform var(--mfc-duration) cubic-bezier(.34, 1.56, .64, 1) calc(var(--mfc-i) * var(--mfc-stagger)),
    opacity calc(var(--mfc-duration) / 2) ease calc(var(--mfc-i) * var(--mfc-stagger)),
    visibility 0s linear 0s;
}

/* Closed: gathered behind the toggle, a quarter turn back, so opening swirls them into place.
   Only with scripting on, so the links stay reachable when JavaScript is off. */
@media (scripting: enabled) {
  .mod-facebox-circle:not(.is-open) .mod-facebox-circle__links li {
    visibility: hidden;
    opacity: 0;
    transform: rotate(calc(var(--mfc-angle) - 90deg)) translateX(0) rotate(calc(90deg - var(--mfc-angle))) scale(.2);
    transition:
      transform calc(var(--mfc-duration) * .7) ease-in calc((var(--mfc-count) - 1 - var(--mfc-i)) * var(--mfc-stagger) / 2),
      opacity calc(var(--mfc-duration) * .7) ease-in calc((var(--mfc-count) - 1 - var(--mfc-i)) * var(--mfc-stagger) / 2),
      visibility 0s linear calc(var(--mfc-duration) * .7 + var(--mfc-count) * var(--mfc-stagger) / 2);
  }
}

.mod-facebox-circle__links a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: var(--bs-emphasis-color, #000);
  text-decoration: none;
  background-color: var(--bs-secondary-bg, #e9ecef);
  border-radius: 50%;
  box-shadow: 0 .125rem .5rem rgba(0, 0, 0, .2);
  transition: background-color .2s ease, transform .2s ease;
}

.mod-facebox-circle__links a:hover {
  background-color: var(--bs-tertiary-bg, #f8f9fa);
  transform: scale(1.1);
}

@media (prefers-reduced-motion: reduce) {
  .mod-facebox-circle {
    --mfc-duration: 0s;
    --mfc-stagger: 0ms;
  }

  .mod-facebox-circle__links a:hover {
    transform: none;
  }
}
