/**
 * uniq.me - animated profile picture effects
 * Layers are built by includes/assets/js/core/uniq-profile-effects.js around [data-uq-fx] avatar wrappers.
 * Effect canvas = 140% of the avatar box (the avatar is the centre 100/140).
 */

/* ---------- layers ---------- */
/* zero specificity: a wrapper that is already positioned (e.g. the absolute profile avatar) keeps its own position */
:where(.uq-fx-host) {
  position: relative;
}
.uq-fx-host {
  isolation: isolate;
  overflow: visible;
}
/* geometry is !important: site rules such as ".profile-avatar-wrapper img {width:160px}" also match the layer <img> */
.uq-fx-layer {
  position: absolute !important;
  /* 140 % of the host, centred - or of the avatar box when the js sets --uq-fx-* (avatar smaller than its wrapper) */
  inset: auto !important;
  left: var(--uq-fx-l, -20%) !important;
  top: var(--uq-fx-t, -20%) !important;
  width: var(--uq-fx-w, 140%) !important;
  height: var(--uq-fx-h, 140%) !important;
  max-width: none !important;
  max-height: none !important;
  min-width: 0 !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  border-radius: 0 !important;
  box-shadow: none !important;
  border: 0 !important;
  background: none !important;
  object-fit: fill !important;
  transform: none !important;
  transition: none !important;
  filter: none !important;
}
.uq-fx-back {
  z-index: 0;
}
/* only the avatar itself is lifted above the back layer (other children keep their own positioning);
   an avatar the site already positions (absolute / fixed / sticky, flagged by the js) keeps that position */
.uq-fx-host .uq-fx-avatar {
  z-index: 1;
}
.uq-fx-host .uq-fx-avatar:not(.uq-fx-avatar-placed) {
  position: relative;
}
.uq-fx-front {
  z-index: 2;
}
/* avatars far outside the viewport: layers not rendered, so their animations cost nothing (set by the js) */
.uq-fx-off > .uq-fx-layer {
  display: none !important;
}

/* ---------- profile page avatar ---------- */
/* owner controls stay above the front layer */
.profile-avatar-wrapper.uq-fx-host > .profile-avatar-change,
.profile-avatar-wrapper.uq-fx-host > .profile-avatar-crop,
.profile-avatar-wrapper.uq-fx-host > .profile-avatar-delete,
.profile-avatar-wrapper.uq-fx-host > .profile-avatar-change-loader,
.profile-avatar-wrapper.uq-fx-host > .gift-on-profile {
  z-index: 3;
}

/* ---------- site-wide avatars ---------- */
/* badges drawn over an avatar stay above the front layer */
.post-avatar.uq-fx-host > .online-dot,
.data-avatar.uq-fx-host > .data-reaction {
  z-index: 3;
}

/* ---------- Effect button on the profile cover (owner only) ----------
   Top-right corner, styled like the theme's own cover buttons (.profile-cover-buttons: camera, crop, delete):
   white at 40 % opacity until the cover is hovered, on a faint dark pill that darkens under the pointer. */
.uq-fx-cover-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin: 0;
  padding: 4px 10px 4px 8px;
  border: 0;
  border-radius: 999px;
  background: rgb(0 0 0 / .1);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  line-height: 31px; /* same height as the theme's cover buttons: 39 px on phones, 34 px from 768 px */
  opacity: .4;
  cursor: pointer;
  transition: all .5s;
}
.profile-cover-wrapper:hover .uq-fx-cover-btn,
.uq-fx-cover-btn:focus-visible {
  opacity: 1;
}
.uq-fx-cover-btn:hover {
  background: rgb(0 0 0 / .25);
}
.uq-fx-cover-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .85);
}
.uq-fx-cover-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}
@media (min-width: 768px) {
  .uq-fx-cover-btn {
    top: 15px;
    right: 15px;
    font-size: 14px;
    line-height: 26px;
  }
  .uq-fx-cover-btn svg {
    width: 16px;
    height: 16px;
  }
}

/* ---------- "Profile effect" picker ---------- */
.uq-fxm-lock,
.uq-fxm-lock body {
  overflow: hidden !important;
  overscroll-behavior: none; /* a stray horizontal swipe on the dialog must not trigger browser back/forward */
}
.uq-fxm-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10060;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(15, 18, 30, .45);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity .16s ease;
}
.uq-fxm-backdrop.is-open {
  opacity: 1;
}
.uq-fxm {
  width: 440px;
  max-width: 100%;
  background: #fff;
  color: #1c1e21;
  border-radius: 16px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .25);
  transform: translateY(10px) scale(.98);
  transition: transform .16s ease;
  text-align: left;
}
.uq-fxm-backdrop.is-open .uq-fxm {
  transform: none;
}
.uq-fxm-head {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 14px 18px;
  border-bottom: 1px solid #e4e6eb;
}
.uq-fxm-title {
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
}
.uq-fxm-cancel,
.uq-fxm-save {
  margin: 0;
  padding: 4px 2px;
  border: 0;
  border-radius: 6px;
  background: none;
  font-size: 15px;
  line-height: 1.2;
  cursor: pointer;
}
.uq-fxm-cancel {
  justify-self: start;
  color: #8a8d91;
}
.uq-fxm-save {
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #1c1e21;
  font-weight: 700;
}
.uq-fxm-save[disabled] {
  opacity: .55;
  cursor: default;
}
.uq-fxm-cancel:focus-visible,
.uq-fxm-save:focus-visible,
.uq-fxm-arrow:focus-visible {
  outline: 2px solid #5e72e4;
  outline-offset: 2px;
}
.uq-fxm-spinner {
  display: none;
  width: 13px;
  height: 13px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: uq-fxm-spin .7s linear infinite;
}
.uq-fxm-save.is-busy .uq-fxm-spinner {
  display: inline-block;
}
@keyframes uq-fxm-spin {
  to {
    transform: rotate(360deg);
  }
}
.uq-fxm-body {
  padding: 8px 12px 16px;
}
.uq-fxm-preview {
  display: flex;
  justify-content: center;
  padding: 34px 0 30px;
}
.uq-fxm-preview-host,
.uq-fxm-tile-host {
  display: inline-block;
  flex: 0 0 auto;
  border-radius: 50%;
}
.uq-fxm-preview-host,
.uq-fxm-preview-img {
  width: 96px;
  height: 96px;
}
.uq-fxm-preview-img,
.uq-fxm-tile-img {
  display: block;
  border-radius: 50%;
  object-fit: cover;
}
.uq-fxm-label {
  margin: 0 6px 2px;
  font-size: 15px;
  font-weight: 600;
  color: #606770;
}
/* always left to right, also on RTL pages: the arrows and arrow keys page left/right */
.uq-fxm-carousel {
  display: flex;
  align-items: center;
  gap: 4px;
  direction: ltr;
}
.uq-fxm-arrow {
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  margin: 0;
  padding: 0 0 2px;
  border: 0;
  border-radius: 50%;
  background: #f0f2f5;
  color: #1c1e21;
  font-size: 22px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity .15s;
}
.uq-fxm-arrow[aria-disabled="true"] {
  opacity: .3;
  cursor: default;
}
.uq-fxm-track {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}
.uq-fxm-track::-webkit-scrollbar {
  display: none;
}
.uq-fxm-tile {
  flex: 0 0 25%;
  min-width: 0;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin: 0;
  padding: 18px 2px 10px;
  border: 2px solid transparent;
  border-radius: 14px;
  background: none;
  color: #65676b;
  font-size: 12.5px;
  line-height: 1.2;
  cursor: pointer;
}
.uq-fxm-tile:hover {
  background: #f0f2f5;
}
.uq-fxm-tile[aria-checked="true"] {
  border-color: #5e72e4;
  color: #5e72e4;
  font-weight: 600;
}
.uq-fxm-tile:focus-visible {
  outline: 2px solid rgba(94, 114, 228, .55);
  outline-offset: -5px;
}
.uq-fxm-tile-host,
.uq-fxm-tile-img {
  width: 56px;
  height: 56px;
}
.uq-fxm-tile-name {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.uq-fxm-error {
  margin: 12px 6px 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: #fdecea;
  color: #b42318;
  font-size: 13px;
}
.uq-fxm-error[hidden] {
  display: none;
}

/* night mode */
body.night-mode .uq-fxm {
  background: #242526;
  color: #e4e6eb;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .6);
}
body.night-mode .uq-fxm-head {
  border-bottom-color: #3e4042;
}
body.night-mode .uq-fxm-save {
  color: #e4e6eb;
}
body.night-mode .uq-fxm-cancel,
body.night-mode .uq-fxm-label,
body.night-mode .uq-fxm-tile {
  color: #b0b3b8;
}
body.night-mode .uq-fxm-arrow {
  background: #3a3b3c;
  color: #e4e6eb;
}
body.night-mode .uq-fxm-tile:hover {
  background: #3a3b3c;
}
body.night-mode .uq-fxm-tile[aria-checked="true"] {
  border-color: #8b9cff;
  color: #8b9cff;
}
body.night-mode .uq-fxm-error {
  background: #3b1f1f;
  color: #ffb4ab;
}

/* phones: full width, 3 tiles per page */
@media (max-width: 420px) {
  .uq-fxm-backdrop {
    padding: 8px;
  }
  .uq-fxm {
    width: 100%;
  }
  .uq-fxm-tile {
    flex-basis: 33.3333%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .uq-fxm-backdrop,
  .uq-fxm,
  .uq-fx-cover-btn {
    transition: none;
  }
  .uq-fxm-track {
    scroll-behavior: auto;
  }
}

/* Avatar Frame is a PRO feature: tag on the Effect button, note + Upgrade link in the picker */
.uq-fx-pro {
  padding: 0 6px;
  border-radius: 999px;
  background: linear-gradient(135deg, #f7b733, #fc4a1a);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .04em;
  line-height: 16px;
}
.uq-fxm-note {
  margin: 0 0 14px;
  padding: 9px 12px;
  border-radius: 10px;
  background: #fff4e5;
  color: #663c00;
  font-size: 13px;
  line-height: 1.4;
  text-align: center;
}
body.night-mode .uq-fxm-note {
  background: #3a2c14;
  color: #ffd699;
}
a.uq-fxm-upgrade,
a.uq-fxm-upgrade:hover,
a.uq-fxm-upgrade:focus {
  color: #5e72e4;
  text-decoration: none;
}
body.night-mode a.uq-fxm-upgrade,
body.night-mode a.uq-fxm-upgrade:hover,
body.night-mode a.uq-fxm-upgrade:focus {
  color: #8f9cff;
}
