/**
 * @file
 * Node Actions pseudo-field.
 *
 * Flag builds its own link markup, so the button styling is applied to that
 * link (classes come from noderender_preprocess_flag()) rather than by
 * re-templating flag. The icons are drawn here for the same reason: Bootstrap's
 * own .bi class sets the icon font on the whole element, which would swallow
 * the link text.
 */

/* Slots -------------------------------------------------------------------- */

.noderender-action {
  position: relative;
  flex: 1 1 0;
}

.noderender-action > .btn,
.noderender-action > .flag {
  width: 100%;
  height: 100%;
}

/**
 * Flag decides for itself whether a user may see a link, and it is lazy-built,
 * so a slot can come back empty after the template has already placed it.
 * Collapse it rather than leaving a gap in the row.
 */
.noderender-action:not(:has(a, button)) {
  display: none;
}

/**
 * The overflow menu is an icon button, so it keeps its natural width while the
 * labelled actions share the rest of the row.
 */
.noderender-action-menu {
  flex: 0 0 auto;
}

.noderender-action-menu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  aspect-ratio: 1;
}

/* Flag links --------------------------------------------------------------- */

.noderender-flag-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.noderender-flag-link::before {
  font-family: "bootstrap-icons", sans-serif;
  font-weight: normal;
  font-style: normal;
  line-height: 1;
  margin-inline-end: 0.5rem;
}

.noderender-flag-count {
  background-color: rgba(255, 255, 255, 0.25);
  font-size: 0.75em;
  font-weight: 600;
}

/* The action class lives on flag's wrapper, not on the link itself. */
.noderender-flag-bookmark::before {
  content: "\f1a2";
}

.action-unflag .noderender-flag-bookmark::before {
  content: "\f199";
}

.noderender-flag-like::before {
  content: "\f407";
}

.action-unflag .noderender-flag-like::before {
  content: "\f406";
}

/* AJAX throbber ------------------------------------------------------------ */

/**
 * Core injects the throbber as a sibling of the link it was triggered from,
 * which lands it in the button row and resizes every button. Pinning it over
 * its own slot keeps the row still; the label is hidden for the moment the
 * spinner is up so the two do not overlap.
 */
.noderender-action .ajax-progress-throbber {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  pointer-events: none;
}

.noderender-action:has(.ajax-progress-throbber) > .btn,
.noderender-action:has(.ajax-progress-throbber) .noderender-flag-link {
  color: transparent;
}

/* Core's throbber is a black GIF; draw a spinner in the button's text colour. */
.noderender-action .ajax-progress-throbber .throbber {
  width: 1.15rem;
  height: 1.15rem;
  margin: 0;
  padding: 0;
  background: none;
  border: 2px solid #fff;
  border-right-color: transparent;
  border-radius: 50%;
  animation: noderender-spin 0.75s linear infinite;
}

.noderender-action .ajax-progress-throbber .message {
  display: none;
}

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

@media (prefers-reduced-motion: reduce) {
  .noderender-action .ajax-progress-throbber .throbber {
    animation-duration: 2s;
  }
}
