/* ═══════════════════════════════════════════════════════════════════════════
   Wolf Compose — Shared CSS for the Edit / Create Post modal
   Used by: posts-feed.html, profile.html, post-details.html
   Depends on theme vars: --linkB, --linkC, --contentB, --contentBs,
                          --contentL, --headC, --bodyC, --bodyCa
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Backdrop + Box ────────────────────────────────────────────── */
.wf-modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55); backdrop-filter: blur(4px);
  z-index: 900;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem .5rem; overflow-y: auto;
  opacity: 0; visibility: hidden; transition: opacity .25s;
}
.wf-modal-backdrop.open { opacity: 1; visibility: visible; }
.wf-modal-box {
  background: var(--contentB, #fff);
  border: 1px solid var(--contentL, #e5e7eb);
  border-radius: 12px;
  width: 100%; max-width: 520px;
  padding: 1.5rem; position: relative; margin: auto;
  transform: scale(.96) translateY(8px); transition: transform .25s;
}
.wf-modal-backdrop.open .wf-modal-box { transform: scale(1) translateY(0); }
.wf-modal-x {
  position: absolute; top: 1rem; left: 1rem;
  width: 30px; height: 30px; border-radius: 50%;
  color: var(--bodyCa, #9ca3af); font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
  background: none; border: 0; cursor: pointer; transition: .2s;
}
.wf-modal-x:hover { background: #fee2e2; color: #ef4444; }

/* ── Form primitives ───────────────────────────────────────────── */
.wf-form-group { margin-bottom: 1rem; }
.wf-form-label {
  display: block; font-size: .83rem; font-weight: 700;
  color: var(--headC, #374151); margin-bottom: .4rem;
}
.wf-form-input, .wf-form-textarea {
  width: 100%; padding: .7rem .9rem;
  background: var(--contentBs, #f9fafb);
  border: 1px solid var(--contentL, #e5e7eb);
  border-radius: 8px;
  color: var(--bodyC, #374151);
  font-family: inherit; font-size: .9rem;
  outline: none; transition: .2s;
}
.wf-form-input:focus, .wf-form-textarea:focus {
  border-color: var(--linkC, #3b82f6);
  background: var(--contentB, #fff);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--linkC, #3b82f6) 15%, transparent);
}
.wf-form-textarea { resize: vertical; min-height: 100px; }
.wf-form-label-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: .35rem;
}
.wf-form-label-row .wf-form-label { margin: 0; }
.wf-form-counter {
  font-size: .68rem; font-weight: 700;
  color: var(--bodyCa, #9ca3af); font-variant-numeric: tabular-nums;
}
.wf-form-counter.warn { color: #f59e0b; }
.wf-form-counter.over { color: #ef4444; }

/* ── Drop zone + progress ──────────────────────────────────────── */
.wf-drop-zone {
  border: 2px dashed var(--contentL, #e5e7eb);
  border-radius: 8px; padding: 1.5rem;
  text-align: center; cursor: pointer;
  background: var(--contentBs, #f9fafb);
  display: block; transition: .2s;
}
.wf-drop-zone:hover, .wf-drop-zone.dragover {
  border-color: var(--linkC, #3b82f6);
  background: color-mix(in srgb, var(--linkC, #3b82f6) 5%, transparent);
}
.wf-drop-zone p { margin: .4rem 0 0; font-size: .82rem; color: var(--bodyCa, #9ca3af); }
.wf-drop-icon { font-size: 1.5rem; color: var(--bodyCa, #9ca3af); transition: .2s; }
.wf-drop-zone:hover .wf-drop-icon { color: var(--linkC, #3b82f6); transform: translateY(-3px); }
.wf-upload-progress { margin-top: .75rem; display: none; }
.wf-upload-progress.show { display: block; }
.wf-progress-track {
  width: 100%; height: 6px;
  background: var(--contentL, #e5e7eb);
  border-radius: 10px; overflow: hidden;
}
.wf-progress-fill {
  height: 100%; background: var(--linkC, #3b82f6);
  border-radius: 10px; transition: width .3s; width: 0;
}

/* ── Image previews (with sortable variant) ────────────────────── */
.wf-img-previews {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: .5rem; margin-top: .75rem;
}
.wf-img-preview-item {
  position: relative; border-radius: 8px; overflow: hidden;
  aspect-ratio: 1; border: 1px solid var(--contentL, #e5e7eb);
}
.wf-img-preview-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.wf-img-preview-item.wf-img-preview-new { border-color: var(--linkC, #3b82f6); }

.wf-img-preview-order {
  position: absolute; top: 4px; inset-inline-start: 4px;
  background: rgba(0,0,0,.65); color: #fff;
  font-size: .62rem; font-weight: 800;
  padding: 1px 6px; border-radius: 999px;
  pointer-events: none; z-index: 2;
}
.wf-img-remove {
  position: absolute;
  top: 4px; inset-inline-end: 4px;
  width: 24px; height: 24px;
  background: #ef4444; color: #fff;
  border-radius: 50%; border: 2px solid #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem; cursor: pointer;
  opacity: 0; transform: scale(.85);
  transition: opacity .18s, transform .18s;
  z-index: 3;
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
}
.wf-img-preview-item:hover .wf-img-remove,
.wf-img-preview-item:focus-within .wf-img-remove {
  opacity: 1; transform: scale(1);
}
.wf-img-remove:hover { background: #dc2626; }

.wf-img-previews-sortable .wf-img-preview-item {
  cursor: grab;
  transition: transform .15s ease, box-shadow .15s ease, opacity .15s ease;
}
.wf-img-previews-sortable .wf-img-preview-item:active { cursor: grabbing; }
.wf-img-previews-sortable .wf-img-preview-item.dragging { opacity: .4; transform: scale(.95); }
.wf-img-previews-sortable .wf-img-preview-item.drag-over {
  box-shadow: 0 0 0 3px var(--linkC, #3b82f6);
}
.wf-img-preview-moves {
  position: absolute; bottom: 4px; inset-inline-end: 4px;
  display: none; gap: 3px; z-index: 2;
}
.wf-img-preview-moves .mv {
  width: 22px; height: 22px; border-radius: 6px;
  background: rgba(0,0,0,.65); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: .65rem; border: 0; cursor: pointer;
}

/* Touch devices: always show remove/move controls */
@media (hover: none) {
  .wf-img-previews-sortable .wf-img-preview-item { cursor: default; }
  .wf-img-preview-moves { display: flex; }
  .wf-img-remove { opacity: 1; transform: scale(1); }
}

/* ── Tags grid ─────────────────────────────────────────────────── */
.wf-tags-grid { display: flex; flex-wrap: wrap; gap: .5rem; }
.wf-tag-check input { display: none; }
.wf-tag-check label {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .4rem .85rem;
  background: var(--contentBs, #f3f4f6);
  border: 1px solid var(--contentL, #e5e7eb);
  color: var(--bodyCa, #6b7280);
  border-radius: 20px;
  font-size: .82rem; font-weight: 600;
  cursor: pointer; user-select: none; transition: .2s;
}
.wf-tag-check input:checked + label {
  background: var(--linkB, #3b82f6);
  border-color: transparent;
  color: #fff;
}

/* ── Buttons ───────────────────────────────────────────────────── */
.wf-btn-cancel {
  padding: .6rem 1.1rem;
  background: var(--contentBs, #f3f4f6);
  color: var(--bodyC, #374151);
  border-radius: 8px; border: 0; cursor: pointer;
  font-weight: 700; font-size: .88rem; transition: .2s;
}
.wf-btn-cancel:hover { background: var(--contentL, #e5e7eb); }
.wf-btn-save {
  padding: .6rem 1.25rem;
  background: var(--linkB, #3b82f6); color: #fff;
  border-radius: 8px; border: 0; cursor: pointer;
  font-weight: 700; font-size: .88rem;
  display: inline-flex; align-items: center; gap: .4rem;
  transition: .2s;
}
.wf-btn-save:hover { opacity: .9; }
.wf-btn-save:disabled { opacity: .55; cursor: not-allowed; }
.wf-btn-ghost {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .55rem .85rem; background: transparent;
  border: 1px solid var(--contentL, #e5e7eb);
  color: var(--bodyC, #374151);
  border-radius: 8px; font-weight: 700; font-size: .82rem;
  cursor: pointer; transition: .15s;
}
.wf-btn-ghost:hover,
.wf-btn-ghost[aria-pressed="true"] {
  background: var(--contentBs, #f3f4f6);
  border-color: var(--linkC, #3b82f6);
  color: var(--linkC, #3b82f6);
}

/* ── Edit modal (v2) frame ─────────────────────────────────────── */
.wf-edit-modal {
  max-width: 640px; padding: 0;
  display: flex; flex-direction: column;
  max-height: calc(100dvh - 2rem); overflow: hidden;
}
.wf-edit-modal-header {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: .6rem;
  padding: .85rem 1.05rem;
  background: var(--contentB, #fff);
  border-bottom: 1px solid var(--contentL, #e5e7eb);
}
.wf-edit-modal-title {
  display: inline-flex; align-items: center; gap: .5rem;
  font-size: 1.02rem; font-weight: 800;
  color: var(--headC, #111827);
}
.wf-edit-modal-status {
  flex: 1; text-align: center;
  font-size: .7rem; font-weight: 700;
  color: var(--bodyCa, #9ca3af);
  min-height: 14px; transition: color .2s;
}
.wf-edit-modal-status.saving { color: var(--linkC, #6366f1); }
.wf-edit-modal-status.saved  { color: #10b981; }
.wf-edit-modal-status.error  { color: #ef4444; }
.wf-edit-modal-status.dirty  { color: #f59e0b; }
.wf-edit-modal .wf-modal-x { position: static; margin-inline-start: auto; }
.wf-edit-modal-body {
  flex: 1 1 auto; overflow-y: auto;
  padding: .95rem 1.05rem; overscroll-behavior: contain;
}
.wf-edit-modal-body .wf-form-group { margin-bottom: 1rem; }
.wf-edit-modal-footer {
  position: sticky; bottom: 0; z-index: 5;
  display: flex; align-items: center; gap: .5rem;
  padding: .75rem 1.05rem;
  background: var(--contentB, #fff);
  border-top: 1px solid var(--contentL, #e5e7eb);
  box-shadow: 0 -4px 12px rgba(0,0,0,.04);
}
.wf-modal-footer-spacer { flex: 1; }

/* ── Preview pane ──────────────────────────────────────────────── */
.wf-edit-preview {
  margin-top: .5rem; padding: .9rem 1rem;
  background: var(--contentBs, #f9fafb);
  border: 1px dashed var(--contentL, #e5e7eb);
  border-radius: 10px;
}
.wf-edit-preview-head {
  font-size: .68rem; font-weight: 800;
  color: var(--bodyCa, #9ca3af);
  text-transform: uppercase; letter-spacing: .05em;
  margin-bottom: .4rem;
}
.wf-edit-preview-title {
  font-size: 1rem; font-weight: 800;
  color: var(--headC, #111827); margin: 0 0 .4rem;
}
.wf-edit-preview-body {
  font-size: .88rem; color: var(--bodyC, #374151);
  white-space: pre-wrap; word-break: break-word; line-height: 1.55;
}
.wf-edit-preview-tags {
  margin-top: .5rem; display: flex; flex-wrap: wrap; gap: .3rem;
}
.wf-edit-preview-tags .tag {
  background: var(--linkB, #3b82f6); color: #fff;
  font-size: .68rem; font-weight: 700;
  padding: 2px 8px; border-radius: 999px;
}

/* ── Draft banner (autosave restore) ───────────────────────────── */
.wf-draft-banner {
  display: flex; align-items: center; gap: .5rem;
  padding: .6rem .8rem;
  background: color-mix(in srgb, var(--linkC, #3b82f6) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--linkC, #3b82f6) 35%, transparent);
  color: var(--headC, #111827);
  border-radius: 10px; margin-bottom: .75rem;
  font-size: .8rem; line-height: 1.5;
}
.wf-draft-banner > i { color: var(--linkC, #3b82f6); }
.wf-draft-banner button {
  padding: .35rem .75rem; border-radius: 6px; border: 0;
  font-size: .72rem; font-weight: 700; cursor: pointer;
}
.wf-draft-banner .apply {
  background: var(--linkB, #3b82f6); color: #fff;
  margin-inline-start: auto;
}
.wf-draft-banner .apply:hover { opacity: .9; }
.wf-draft-banner .discard {
  background: transparent; color: var(--bodyCa, #6b7280);
}
.wf-draft-banner .discard:hover { color: #ef4444; }

/* ── Mobile ────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .wf-modal-backdrop { padding: 0; align-items: stretch; }
  .wf-edit-modal { max-width: 100%; max-height: 100dvh; border-radius: 0; }
  .wf-edit-modal-body { padding: .85rem .9rem; }
  .wf-edit-modal-header, .wf-edit-modal-footer { padding: .7rem .9rem; }
  .wf-btn-ghost span { display: none; }
  .wf-img-previews { grid-template-columns: repeat(3, 1fr); }
}
