/* ==========================================================================
   Profile pictures: avatar images, the editable avatar on the profile page,
   and the crop / position editor (js/core/avatar.js).
   ========================================================================== */
.avatar { position: relative; overflow: hidden; }
.avatar.has-img { background: var(--surface-2); }
.avatar-img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: inherit; }

/* ---- Profile card: editable avatar ------------------------------------------------- */
.profile-id .avatar { margin-bottom: 0; box-shadow: none; }
.avatar-edit { position: relative; margin-bottom: 12px; }
.avatar-edit-btn {
  position: relative;
  display: block;
  padding: 0; border: 0; background: none;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 0 5px var(--primary-soft), 0 14px 28px -16px rgba(0, 0, 0, .45);
  transition: transform .3s var(--ease), box-shadow .3s ease;
}
.avatar-edit-btn:hover { transform: translateY(-2px); box-shadow: 0 0 0 5px color-mix(in srgb, var(--primary) 40%, transparent), 0 18px 32px -16px rgba(0, 0, 0, .5); }
.avatar-edit-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--bg), 0 0 0 6px var(--focus); }
.avatar-edit-btn::after {
  /* hover veil with a hint that the photo is editable */
  content: "";
  position: absolute; inset: 0; border-radius: 50%;
  background: radial-gradient(circle at 50% 120%, rgba(0, 0, 0, .45), transparent 60%);
  opacity: 0;
  transition: opacity .25s ease;
}
.avatar-edit-btn:hover::after { opacity: 1; }
.avatar-cam {
  position: absolute; right: -2px; bottom: -2px; z-index: 1;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--on-primary);
  background: linear-gradient(180deg, rgba(255, 255, 255, .22), rgba(255, 255, 255, 0) 60%), var(--primary);
  border: 3px solid var(--surface);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .45), 0 4px 10px -4px rgba(0, 0, 0, .45);
  transition: transform .25s var(--ease);
}
.avatar-edit-btn:hover .avatar-cam { transform: scale(1.08) rotate(-6deg); }
.avatar-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-bottom: 10px; }

/* ---- Editor ------------------------------------------------------------------------------ */
.av-editor { display: flex; flex-direction: column; gap: 14px; }
.av-stage {
  position: relative;
  width: min(320px, 100%);
  aspect-ratio: 1;
  margin-inline: auto;
  border-radius: 20px;
  overflow: hidden;
  background:
    repeating-conic-gradient(color-mix(in srgb, var(--surface-3) 70%, transparent) 0% 25%, transparent 0% 50%) 50% / 22px 22px,
    var(--surface-2);
  border: 1px solid var(--border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .5), 0 18px 36px -24px rgba(0, 0, 0, .5);
  touch-action: none;                 /* drag / pinch handled in JS */
  cursor: grab;
  outline: none;
}
.av-stage:focus-visible { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--focus); }
.av-stage.is-dragging { cursor: grabbing; }
.av-stage.is-drop { border-color: var(--primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 30%, transparent); }
.av-stage canvas { display: block; width: 100%; height: 100%; opacity: 0; transition: opacity .3s ease; }
.has-photo .av-stage canvas { opacity: 1; }
/* everything outside the circle is dimmed: exactly what will be visible as the avatar */
.av-mask {
  position: absolute; inset: 0;
  pointer-events: none;
  border-radius: inherit;
  /* closest-side = the circle touching the stage edges, i.e. exactly the saved crop */
  background: radial-gradient(circle closest-side at 50% 50%, transparent calc(100% - 1px), rgba(10, 14, 6, .55) 100%);
  opacity: 0;
  transition: opacity .3s ease;
}
.av-mask::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .85);
}
.has-photo .av-mask { opacity: 1; }
.av-pick {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  border: 0; background: none; color: var(--text-2);
  font: inherit; font-size: .88rem; cursor: pointer;
  text-align: center; padding: 16px;
}
.av-pick strong { color: var(--text); font-size: 1rem; }
.av-pick-ico {
  width: 64px; height: 64px; margin-bottom: 6px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--on-primary);
  background: linear-gradient(180deg, rgba(255, 255, 255, .22), rgba(255, 255, 255, 0) 60%), var(--primary);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .45), 0 12px 24px -12px color-mix(in srgb, var(--primary), #000 35%);
  transition: transform .3s var(--ease);
}
.av-pick:hover .av-pick-ico { transform: translateY(-2px) scale(1.05); }
.has-photo .av-pick { display: none; }
.av-editor.is-loading .av-stage::after {
  content: ""; position: absolute; top: 50%; left: 50%;
  width: 28px; height: 28px; margin: -14px 0 0 -14px;
  border-radius: 50%; border: 3px solid var(--primary); border-right-color: transparent;
  animation: spin .7s linear infinite;
}
.av-editor.is-loading .av-pick { visibility: hidden; }
.av-zoom { display: flex; align-items: center; gap: 8px; width: min(320px, 100%); margin-inline: auto; }
.av-zoom[hidden] { display: none; }
.av-zoom .range { flex: 1; }
.av-zoom .range:focus-visible { outline: 2px solid var(--focus); outline-offset: 6px; border-radius: 99px; }
.av-hint { text-align: center; margin: 0; }
.av-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.av-actions .grow { flex: 1 1 auto; }
@media (max-width: 420px) {
  .av-actions { justify-content: stretch; }
  .av-actions .grow { display: none; }
  .av-actions .btn { flex: 1 1 auto; }
  .av-actions [data-pick-again] { flex-basis: 100%; }
}
