/* Custom badge flyouts (replaces native title tooltips). Used by .badge-micro + profile .badge-chip */

:root {
  --badge-micro-size: 26px;
}

.badge-micro-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.layout .grid .card .badge-micro-strip {
  margin: 0 0 10px;
}

.badge-micro {
  position: relative;
  width: var(--badge-micro-size);
  height: var(--badge-micro-size);
  display: block;
  flex-shrink: 0;
  outline: none;
}

.badge-micro:not(.badge-emblem) {
  border-radius: 7px;
  color: var(--green, #b5ff3c);
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--field-line, rgba(255, 255, 255, 0.22));
}

.badge-micro:hover,
.badge-micro:focus {
  z-index: 400;
}

html[data-theme="light"] .badge-micro:not(.badge-emblem) {
  color: #5a50f5;
  background: rgba(90, 80, 245, 0.1);
}

.badge-micro__hit {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  cursor: default;
}

.badge-micro:not(.badge-emblem) .badge-micro__hit {
  display: grid;
  place-items: center;
}

.badge-micro:not(.badge-emblem) .badge-micro__hit svg {
  width: calc(var(--badge-micro-size) * 0.67);
  height: calc(var(--badge-micro-size) * 0.67);
  display: block;
}

.badge-micro:focus-visible {
  outline: 2px solid var(--green, #b5ff3c);
  outline-offset: 2px;
}

html[data-theme="light"] .badge-micro:focus-visible {
  outline-color: #5a50f5;
}

.badge-flyout {
  position: absolute;
  left: 50%;
  z-index: 50000;
  width: min(280px, 78vw);
  padding: 12px 14px 13px;
  border-radius: 16px;
  text-align: left;
  font-family: inherit;
  font-weight: 500;
  line-height: 1.45;
  letter-spacing: 0.01em;
  color: #14122a;
  background: linear-gradient(155deg, #eef0ff 0%, #bec8f9 42%, #f3e6ff 100%);
  border: 2px solid rgba(255, 255, 255, 0.55);
  box-shadow:
    0 0 0 1px rgba(90, 80, 245, 0.12),
    0 16px 38px rgba(14, 6, 40, 0.38);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.16s ease,
    transform 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}

html[data-theme="light"] .badge-flyout {
  color: #14122a;
  background: linear-gradient(160deg, #ffffff 0%, #eef0ff 55%, #fff8ff 100%);
  border-color: rgba(90, 80, 245, 0.22);
  box-shadow:
    0 0 0 1px rgba(90, 80, 245, 0.08),
    0 14px 34px rgba(40, 24, 90, 0.18);
}

.badge-flyout__kicker {
  display: block;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(90, 80, 245, 0.82);
  margin-bottom: 6px;
}

.badge-flyout__title {
  display: block;
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #1a1535;
  margin-bottom: 6px;
  line-height: 1.2;
}

.badge-flyout__flavor {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: #3a2f6e;
  margin-bottom: 8px;
  line-height: 1.35;
}

html[data-theme="light"] .badge-flyout__flavor {
  color: #423677;
}

.badge-flyout__body {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: rgba(26, 21, 53, 0.78);
  line-height: 1.45;
}

html[data-theme="light"] .badge-flyout__body {
  color: rgba(46, 40, 104, 0.82);
}

/* Micro badges: flyout above */
.badge-micro .badge-flyout {
  bottom: calc(100% + 11px);
  top: auto;
  transform: translateX(-50%) translateY(6px) scale(0.98);
}

.badge-micro:hover .badge-flyout,
.badge-micro:focus .badge-flyout {
  opacity: 1;
  transform: translateX(-50%) translateY(0) scale(1);
}

.badge-micro .badge-flyout::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -9px;
  width: 0;
  height: 0;
  margin-left: -8px;
  border: 8px solid transparent;
  border-top-color: #d4dafb;
  filter: drop-shadow(0 2px 1px rgba(14, 6, 40, 0.12));
}

html[data-theme="light"] .badge-micro .badge-flyout::after {
  border-top-color: #eef0ff;
}

/* Creator cards + badge pills: flyouts must sit above filters and sibling cards */
.page-creators .grid .card,
main .grid .card {
  overflow: visible;
}

.badge-pill .badge-flyout {
  z-index: 60001;
}

.badge-micro:hover,
.badge-micro:focus,
.badge-tag:hover,
.badge-tag:focus-visible,
.badge-pill:hover,
.badge-pill:focus-visible,
a.badge-chip:hover,
a.badge-chip:focus-visible {
  z-index: 60000;
}

/* Feed clip cards: badge flyouts escape the card; thumb + meta keep rounded masks */
.layout .grid .card[data-clip-slot] {
  overflow: visible;
}
.layout .grid .card[data-clip-slot] > .thumb {
  border-radius: 22px 22px 0 0;
  overflow: hidden;
}
.layout .grid .card[data-clip-slot] > .meta.clip-meta {
  border-radius: 0 0 22px 22px;
  /* overflow visible so badge flyouts are not clipped (background still respects border-radius) */
  overflow: visible;
}

/* Profile page: panels must not clip flyouts (backdrop-filter) */
#profile-root > .panel {
  overflow: visible;
}

/* Profile chips: flyout below the row (Browse uses .badge-micro above) */
a.badge-chip {
  position: relative;
  text-decoration: none;
  color: inherit;
}

a.badge-chip:hover,
a.badge-chip:focus-visible {
  z-index: 400;
}

.badge-chip__row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.badge-chip .badge-flyout {
  top: calc(100% + 12px);
  bottom: auto;
  width: min(320px, 92vw);
  padding: 14px 16px 15px;
  transform: translateX(-50%) translateY(-8px) scale(0.98);
}

.badge-chip:hover .badge-flyout,
.badge-chip:focus-visible .badge-flyout {
  opacity: 1;
  transform: translateX(-50%) translateY(0) scale(1);
}

.badge-chip .badge-flyout::after {
  content: "";
  position: absolute;
  left: 50%;
  top: -9px;
  width: 0;
  height: 0;
  margin-left: -8px;
  border: 8px solid transparent;
  border-bottom-color: #eef0ff;
  filter: drop-shadow(0 -1px 1px rgba(14, 6, 40, 0.1));
}

html[data-theme="light"] .badge-chip .badge-flyout::after {
  border-bottom-color: #ffffff;
}

@media (prefers-reduced-motion: reduce) {
  .badge-flyout {
    transition: opacity 0.08s ease;
  }

  .badge-micro .badge-flyout,
  .badge-micro:hover .badge-flyout,
  .badge-micro:focus .badge-flyout,
  .badge-chip .badge-flyout,
  .badge-chip:hover .badge-flyout,
  .badge-chip:focus-visible .badge-flyout {
    transform: translateX(-50%);
  }
}
