/* =====================================================================
   css/image-adjust.css — Avatar & Cover Positioning Editor + Inline Cover Reposition
   ===================================================================== */

/* ---------- Universal clipped circular avatar wrapper (SX.av & previews) ---------- */
.ia-av-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 9999px;
  flex-shrink: 0;
  background: var(--content);
  position: relative;
}
.ia-av-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 9999px;
  pointer-events: none;
  user-select: none;
}
.sx-stack > .sx-av + .sx-av {
  margin-left: -6px;
}
.sx-stack > .sx-av {
  box-shadow: 0 0 0 1.5px var(--background);
}
.sh-top-avatar {
  overflow: hidden;
}

/* ---------- Own Profile Cover Action Buttons & Inline Reposition ---------- */
.sx-cover img {
  transition: transform 140ms ease;
}
.sx-cover.is-inline-editing img {
  transition: none !important;
}
.sx-cover.is-inline-editing {
  cursor: grab;
  touch-action: none;
  user-select: none;
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}
.sx-cover.is-inline-editing.is-dragging {
  cursor: grabbing;
}

.ia-cover-actions {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.ia-cover-adj-btn {
  height: 34px;
  padding: 0 13px;
  border-radius: 9999px;
  background: rgba(10, 14, 24, .64);
  backdrop-filter: blur(12px) saturate(160%);
  -webkit-backdrop-filter: blur(12px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, .22);
  color: #fff;
  font-size: 12.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: background-color 150ms ease, transform 120ms ease, opacity 150ms ease;
}
.ia-cover-adj-btn svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}
.ia-cover-adj-btn:hover {
  background: rgba(10, 14, 24, .84);
}
.ia-cover-adj-btn:active {
  transform: scale(.94);
}
.ia-cover-actions .sx-cover-btn {
  position: static;
}

/* Inline Cover Grid Overlay */
.ia-inline-grid {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0.28;
  transition: opacity 160ms ease;
}
.sx-cover.is-inline-editing.is-interacting .ia-inline-grid {
  opacity: 0.92;
}
.ia-inline-grid::before,
.ia-inline-grid::after {
  content: "";
  position: absolute;
  inset: 0;
}
.ia-inline-grid::before {
  background:
    linear-gradient(to right,
      transparent calc(33.333% - 0.5px), rgba(255, 255, 255, .52) calc(33.333% - 0.5px), rgba(255, 255, 255, .52) calc(33.333% + 0.5px), transparent calc(33.333% + 0.5px),
      transparent calc(66.666% - 0.5px), rgba(255, 255, 255, .52) calc(66.666% - 0.5px), rgba(255, 255, 255, .52) calc(66.666% + 0.5px), transparent calc(66.666% + 0.5px));
}
.ia-inline-grid::after {
  background:
    linear-gradient(to bottom,
      transparent calc(33.333% - 0.5px), rgba(255, 255, 255, .52) calc(33.333% - 0.5px), rgba(255, 255, 255, .52) calc(33.333% + 0.5px), transparent calc(33.333% + 0.5px),
      transparent calc(66.666% - 0.5px), rgba(255, 255, 255, .52) calc(66.666% - 0.5px), rgba(255, 255, 255, .52) calc(66.666% + 0.5px), transparent calc(66.666% + 0.5px));
}

/* Inline Top Action Pills */
.ia-inline-topbar {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
}
.ia-inline-topbar > * {
  pointer-events: auto;
}
.ia-inline-hint {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 11px;
  border-radius: 9999px;
  background: rgba(10, 14, 24, .74);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, .18);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  max-width: 48%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ia-inline-hint svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: .85;
}
.ia-inline-btns {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.ia-pill-btn {
  height: 30px;
  padding: 0 12px;
  border-radius: 9999px;
  font-size: 12.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  transition: transform 120ms ease, background-color 140ms ease, opacity 140ms ease;
  white-space: nowrap;
}
.ia-pill-btn:active {
  transform: scale(.95);
}
.ia-pill-glass {
  background: rgba(10, 14, 24, .74);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, .2);
  color: #fff;
}
.ia-pill-glass:hover {
  background: rgba(10, 14, 24, .9);
}
.ia-pill-save {
  background: var(--primary);
  color: var(--primary-foreground);
  border: 1px solid rgba(255, 255, 255, .18);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .28);
}
.ia-pill-save:hover {
  opacity: .92;
}

/* Inline Bottom Zoom Slider Overlay (right-aligned so it clears bottom-left profile avatar!) */
.ia-inline-zoom {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 6;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 8px;
  border-radius: 9999px;
  background: rgba(10, 14, 24, .78);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, .2);
  color: #fff;
  max-width: calc(100% - 122px);
}
.ia-inline-zbtn {
  width: 24px;
  height: 24px;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: rgba(255, 255, 255, .12);
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 120ms ease, transform 120ms ease;
}
.ia-inline-zbtn:hover {
  background: rgba(255, 255, 255, .24);
}
.ia-inline-zbtn:active {
  transform: scale(.9);
}
.ia-inline-zbtn svg {
  width: 13px;
  height: 13px;
}
.ia-inline-range {
  width: 96px;
  height: 4px;
  accent-color: #fff;
  cursor: pointer;
}
@media (max-width: 440px) {
  .ia-inline-hint-lbl {
    display: none;
  }
  .ia-inline-range {
    width: 74px;
  }
}
body.mobile-sim .ia-inline-hint-lbl {
  display: none;
}
body.mobile-sim .ia-inline-range {
  width: 74px;
}
.ia-inline-zval {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 11.5px;
  font-weight: 700;
  min-width: 34px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ---------- Edit Profile Cover & Avatar Interactive Affordances ---------- */
.sx-ep-cover {
  cursor: pointer;
}
.sx-ep-cover-pill {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 3;
  height: 32px;
  padding: 0 12px;
  border-radius: 9999px;
  background: rgba(10, 14, 24, .68);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, .22);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}
.sx-ep-cover-pill svg {
  width: 15px;
  height: 15px;
}
.sx-ep-av-inner {
  border: 3px solid var(--background);
  background: var(--background);
}

/* =====================================================================
   FULL-SCREEN (MOBILE) / CENTERED DIALOG (DESKTOP) CROP & POSITION EDITOR
   ===================================================================== */
.ia-modal-wrap {
  position: fixed;
  inset: 0;
  z-index: 84;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(8, 11, 20, .62);
  backdrop-filter: blur(10px) saturate(140%);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  animation: iaFadeIn 170ms ease-out forwards;
}
.ia-modal-wrap.hidden {
  display: none !important;
}
.ia-modal {
  width: 100%;
  max-width: 620px;
  max-height: min(92vh, 780px);
  display: flex;
  flex-direction: column;
  background: var(--background);
  color: var(--foreground);
  border: 1px solid var(--card-border);
  border-radius: 24px;
  box-shadow: var(--ds-shadow-pop);
  overflow: hidden;
  animation: iaPopIn 220ms var(--ds-ease) forwards;
}

@media (max-width: 767px) {
  .ia-modal-wrap {
    padding: 0;
    align-items: stretch;
    justify-content: stretch;
    background: var(--background);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  .ia-modal {
    max-width: 100%;
    height: var(--vvh, 100dvh);
    max-height: var(--vvh, 100dvh);
    border: 0;
    border-radius: 0;
    box-shadow: none;
    animation: iaSheetUp 260ms var(--ds-ease) forwards;
  }
}
body.mobile-sim .ia-modal-wrap {
  position: absolute;
  inset: 0;
  padding: 0;
  align-items: stretch;
  justify-content: stretch;
  background: var(--background);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
body.mobile-sim .ia-modal {
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  animation: iaSheetUp 260ms var(--ds-ease) forwards;
}

@keyframes iaFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes iaPopIn { from { opacity: 0; transform: scale(.96) translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes iaSheetUp { from { opacity: 0; transform: translate3d(0, 28px, 0); } to { opacity: 1; transform: none; } }

/* Top bar */
.ia-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 54px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--ds-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  flex-shrink: 0;
}
.ia-bar-center {
  flex: 1;
  min-width: 0;
  text-align: center;
}
.ia-bar-title {
  font-family: var(--ds-font-display);
  font-size: clamp(14.5px, 3.8vw, 16px);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--foreground);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ia-bar-sub {
  font-size: 12px;
  color: var(--muted-foreground);
  font-variant-numeric: tabular-nums;
}

/* Scrollable inner body */
.ia-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
}

/* Crop stage */
.ia-stage {
  position: relative;
  width: 100%;
  background: #0a0d16;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 22px 16px 38px;
  overflow: hidden;
  user-select: none;
  flex-shrink: 0;
}
.ia-stage.is-cover {
  padding: 26px 16px 42px;
}

.ia-crop-box {
  position: relative;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
  user-select: none;
  background: #141926;
}
.ia-crop-box.is-dragging {
  cursor: grabbing;
}
.ia-crop-box.is-avatar {
  width: min(260px, 68vw);
  height: min(260px, 68vw);
  border-radius: 16px;
}
@media (min-width: 768px) {
  body:not(.mobile-sim) .ia-crop-box.is-avatar {
    width: 280px;
    height: 280px;
  }
}
.ia-crop-box.is-cover {
  width: 100%;
  max-width: 540px;
  aspect-ratio: 16 / 6;
  border-radius: 12px;
}

.ia-crop-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  user-select: none;
  will-change: transform;
}

/* Circle mask (avatar) & rectangular vignette mask (cover) */
.ia-mask {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}
.ia-crop-box.is-avatar .ia-mask {
  border-radius: 9999px;
  box-shadow: 0 0 0 999px rgba(8, 11, 20, .62);
  border: 1.5px solid rgba(255, 255, 255, .86);
}
.ia-crop-box.is-cover .ia-mask {
  border-radius: 12px;
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .85), 0 0 0 999px rgba(8, 11, 20, .55);
}

/* Rule-of-thirds grid overlay */
.ia-grid {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0.18;
  transition: opacity 180ms ease;
}
.ia-crop-box.is-avatar .ia-grid {
  border-radius: 9999px;
  overflow: hidden;
}
.ia-crop-box.is-cover .ia-grid {
  border-radius: 12px;
  overflow: hidden;
}
.ia-crop-box.is-interacting .ia-grid {
  opacity: 0.9;
}
.ia-grid::before,
.ia-grid::after {
  content: "";
  position: absolute;
  inset: 0;
}
.ia-grid::before {
  background:
    linear-gradient(to right,
      transparent calc(33.333% - 0.5px), rgba(255, 255, 255, .52) calc(33.333% - 0.5px), rgba(255, 255, 255, .52) calc(33.333% + 0.5px), transparent calc(33.333% + 0.5px),
      transparent calc(66.666% - 0.5px), rgba(255, 255, 255, .52) calc(66.666% - 0.5px), rgba(255, 255, 255, .52) calc(66.666% + 0.5px), transparent calc(66.666% + 0.5px));
}
.ia-grid::after {
  background:
    linear-gradient(to bottom,
      transparent calc(33.333% - 0.5px), rgba(255, 255, 255, .52) calc(33.333% - 0.5px), rgba(255, 255, 255, .52) calc(33.333% + 0.5px), transparent calc(33.333% + 0.5px),
      transparent calc(66.666% - 0.5px), rgba(255, 255, 255, .52) calc(66.666% - 0.5px), rgba(255, 255, 255, .52) calc(66.666% + 0.5px), transparent calc(66.666% + 0.5px));
}
.ia-crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  opacity: 0;
  transition: opacity 180ms ease;
}
.ia-crop-box.is-interacting .ia-crosshair {
  opacity: 0.75;
}
.ia-crosshair::before,
.ia-crosshair::after {
  content: "";
  position: absolute;
  background: rgba(255, 255, 255, .8);
  border-radius: 1px;
}
.ia-crosshair::before { left: 6px; top: 0; width: 2px; height: 14px; }
.ia-crosshair::after { top: 6px; left: 0; height: 2px; width: 14px; }

.ia-stage-hint {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 12px;
  border-radius: 9999px;
  background: rgba(255, 255, 255, .1);
  border: 1px solid rgba(255, 255, 255, .14);
  color: rgba(255, 255, 255, .86);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
}

/* Controls panel */
.ia-controls {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  border-bottom: 1px solid var(--border);
  background: var(--background);
}

.ia-zoom-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ia-step-btn {
  width: 34px;
  height: 34px;
  border-radius: 9999px;
  border: 1px solid var(--card-border);
  background: var(--content);
  color: var(--foreground);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  transition: background-color 140ms ease, transform 120ms ease;
}
.ia-step-btn:hover { background: var(--ds-press); }
.ia-step-btn:active { transform: scale(.92); }
.ia-step-btn:disabled { opacity: .4; pointer-events: none; }
.ia-step-btn svg { width: 16px; height: 16px; }

.ia-range {
  flex: 1;
  min-width: 0;
  height: 6px;
  accent-color: var(--primary);
  cursor: pointer;
}
.ia-zoom-val {
  min-width: 48px;
  text-align: right;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--foreground);
  font-variant-numeric: tabular-nums;
}

/* Nudge + quick actions row */
.ia-tools-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.ia-nudge-pad {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.ia-nudge-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: var(--card);
  color: var(--foreground);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, transform 100ms ease;
}
.ia-nudge-btn:hover {
  background: var(--ds-hover);
  border-color: var(--primary);
}
.ia-nudge-btn:active {
  transform: scale(.92);
}
.ia-nudge-btn svg {
  width: 16px;
  height: 16px;
}
.ia-tools-right {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.ia-coord-pill {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted-foreground);
  padding: 4px 9px;
  border-radius: 9999px;
  background: var(--content);
  font-variant-numeric: tabular-nums;
}

/* Live previews section */
.ia-previews {
  padding: 14px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--card);
  flex: 1;
}
.ia-prev-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted-foreground);
}

/* Avatar preview chips (40px post + 88px profile) */
.ia-prev-av-grid {
  display: flex;
  align-items: stretch;
  gap: 10px;
}
.ia-prev-chip {
  border-radius: 16px;
  border: 1px solid var(--card-border);
  background: var(--background);
  padding: 11px 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}
.ia-prev-chip.is-feed {
  flex: 1;
}
.ia-prev-chip.is-prof {
  align-items: center;
  text-align: center;
  flex-shrink: 0;
  min-width: 118px;
}
.ia-prev-chip-lbl {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted-foreground);
}
.ia-prev-feed-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.ia-prev-feed-meta {
  min-width: 0;
  flex: 1;
}
.ia-prev-feed-name {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--ds-font-display);
  font-size: 13.5px;
  font-weight: 700;
  color: var(--foreground);
}
.ia-prev-feed-handle {
  font-size: 12px;
  color: var(--muted-foreground);
}
.ia-prev-feed-line {
  margin-top: 4px;
  font-size: 12.5px;
  color: var(--foreground);
  opacity: .85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Cover preview chips (Mobile 390px + Desktop 600px) */
.ia-prev-cov-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.ia-prev-cov-card {
  border-radius: 16px;
  border: 1px solid var(--card-border);
  background: var(--background);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.ia-prev-cov-banner {
  position: relative;
  width: 100%;
  overflow: hidden;
  background: var(--content);
}
.ia-prev-cov-banner.is-mob {
  aspect-ratio: 390 / 146;
}
.ia-prev-cov-banner.is-desk {
  aspect-ratio: 600 / 220;
}
.ia-prev-cov-banner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.ia-prev-cov-foot {
  position: relative;
  padding: 0 10px 9px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.ia-prev-cov-av {
  margin-top: -15px;
  width: 30px;
  height: 30px;
  border-radius: 9999px;
  border: 2px solid var(--background);
  background: var(--background);
  overflow: hidden;
  position: relative;
  z-index: 2;
}
.ia-prev-cov-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--foreground);
}
.ia-prev-cov-dim {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted-foreground);
  font-variant-numeric: tabular-nums;
}
