/* =========================================================================
   In-page editor (admin) — visual layer that appears only when edit mode is on.
   ========================================================================= */

body.edit-mode { padding-top: 0; }

/* --- toolbar (top floating) --------------------------------------------- */
.edit-bar {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 200;
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px 10px 8px 16px;
  background: #0B0B0B;
  color: #FAF8F2;
  border-radius: 999px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.edit-bar__dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

.edit-bar__btn {
  border: 1px solid rgba(250, 248, 242, 0.18);
  color: #FAF8F2;
  padding: 6px 12px;
  border-radius: 999px;
  font: inherit;
  cursor: pointer;
  transition: background 180ms ease, color 180ms ease;
}

.edit-bar__btn:hover { background: var(--accent); border-color: var(--accent); }
.edit-bar__btn.danger:hover { background: #B23A2D; border-color: #B23A2D; }

/* --- login modal -------------------------------------------------------- */
.edit-login {
  position: fixed;
  inset: 0;
  z-index: 250;
  background: rgba(11, 11, 11, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
}
.edit-login.is-open { display: flex; }

.edit-login__card {
  background: var(--paper);
  border-radius: 4px;
  padding: 40px;
  width: 380px;
  max-width: 92vw;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.3);
}

.edit-login__card h3 {
  margin-bottom: 6px;
  font-size: 1.75rem;
}

.edit-login__card p {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 24px;
}

.edit-login__card input {
  width: 100%;
  padding: 14px 16px;
  font: inherit;
  font-family: var(--sans);
  border: 1px solid var(--line);
  background: white;
  border-radius: 2px;
  margin-bottom: 16px;
  outline: none;
  transition: border-color 200ms ease;
}

.edit-login__card input:focus { border-color: var(--accent); }

.edit-login__card .err {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin: -10px 0 14px;
  min-height: 14px;
}

.edit-login__card button {
  width: 100%;
  padding: 14px;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 500;
  border-radius: 999px;
  cursor: pointer;
  transition: background 200ms ease;
}

.edit-login__card button:hover { background: var(--accent); }
.edit-login__card button:disabled { opacity: 0.5; cursor: wait; }

/* --- editable text indicators ------------------------------------------- */
body.edit-mode [data-edit] {
  outline: 1px dashed transparent;
  outline-offset: 4px;
  border-radius: 1px;
  transition: outline-color 160ms ease, background 160ms ease;
  cursor: text;
  position: relative;
}

body.edit-mode [data-edit]:hover {
  outline-color: var(--accent);
  background: rgba(196, 69, 54, 0.04);
}

body.edit-mode [data-edit][contenteditable="true"] {
  outline: 1.5px solid var(--accent);
  background: rgba(196, 69, 54, 0.06);
  cursor: text;
}

body.edit-mode [data-edit]::after {
  content: "✎";
  position: absolute;
  top: -16px; right: -16px;
  font-size: 11px;
  color: var(--accent);
  opacity: 0;
  transition: opacity 160ms ease;
  pointer-events: none;
}
body.edit-mode [data-edit]:hover::after { opacity: 1; }

/* In edit mode we KEEP pointer-events enabled on the link so the editor
   controls work, then suppress navigation by preventDefault'ing the click
   in JS. (The old approach of pointer-events:none on the <a> broke every
   child that wasn't [data-edit] — pills, handles, etc.) */

/* --- gallery item editor controls --------------------------------------- */
body.edit-mode .gallery__item {
  cursor: grab !important;
  outline: 1px dashed transparent;
  outline-offset: 0;
  transition: outline-color 160ms ease;
}

body.edit-mode .gallery__item:hover {
  outline-color: var(--accent);
}

body.edit-mode .gallery__item.dragging {
  cursor: grabbing !important;
  opacity: 0.4;
}

body.edit-mode .gallery__item.drop-target {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

body.edit-mode .gallery__item.is-cover {
  outline: 2px solid var(--accent);
}

.gi-controls {
  position: absolute;
  top: 8px; left: 8px; right: 8px;
  display: none;
  gap: 6px;
  z-index: 5;
}

body.edit-mode .gallery__item:hover .gi-controls {
  display: flex;
}

.gi-btn {
  padding: 6px 10px;
  background: rgba(11, 11, 11, 0.85);
  color: #FAF8F2;
  border: 0;
  border-radius: 2px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: background 160ms ease;
}

.gi-btn:hover { background: var(--accent); }
.gi-btn.is-active { background: var(--accent); }

.gi-resize-handle {
  position: absolute;
  bottom: 8px; right: 8px;
  width: 24px; height: 24px;
  background: rgba(11, 11, 11, 0.85);
  color: #FAF8F2;
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
  cursor: ew-resize;
  font-size: 14px;
  z-index: 5;
  user-select: none;
}

body.edit-mode .gallery__item:hover .gi-resize-handle {
  display: flex;
}

.gi-span-pill {
  position: absolute;
  bottom: 8px; left: 8px;
  padding: 4px 8px;
  background: rgba(11, 11, 11, 0.85);
  color: #FAF8F2;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  border-radius: 2px;
  display: none;
  z-index: 5;
}

body.edit-mode .gallery__item:hover .gi-span-pill,
body.edit-mode .gallery__item.resizing .gi-span-pill {
  display: block;
}

/* --- toast -------------------------------------------------------------- */
.edit-toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #0B0B0B;
  color: #FAF8F2;
  padding: 12px 20px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0;
  transition: opacity 200ms ease, transform 200ms ease;
  z-index: 300;
  pointer-events: none;
}

.edit-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.edit-toast.error { background: #B23A2D; }
.edit-toast.success::before { content: "✓ "; color: #7FDF8A; }

/* --- hidden gallery item (visible:false) -------------------------------- */
body.edit-mode .gallery__item.is-hidden {
  opacity: 0.35;
  outline-color: var(--muted-2);
}

body.edit-mode .gallery__item.is-hidden::after {
  content: "HIDDEN";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(11, 11, 11, 0.4);
  color: var(--paper);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.2em;
  pointer-events: none;
}

/* When edit mode is ON, hide the lightbox-on-click affordance. */
body.edit-mode .gallery__item { cursor: grab !important; }

/* ---- Project card controls (home + projects pages) ------------------ */
body.edit-mode .card[data-slug] {
  outline: 1px dashed transparent;
  transition: outline-color 160ms ease, transform 200ms ease, box-shadow 200ms ease;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
}

body.edit-mode .card[data-slug] .card__media {
  cursor: grab;
}

body.edit-mode .card[data-slug].dragging .card__media,
body.edit-mode .card[data-slug] .card__media:active {
  cursor: grabbing;
}

body.edit-mode .card[data-slug] img {
  -webkit-user-drag: none;
  user-select: none;
  -webkit-user-select: none;
  /* still receive pointer events so .card__media gets drag events */
}

body.edit-mode .card[data-slug]:hover {
  outline-color: var(--accent);
  outline-offset: 4px;
}

body.edit-mode .card[data-slug].dragging {
  opacity: 0.92;
  cursor: grabbing;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
  transition: none;  /* JS controls transform directly */
  pointer-events: none;  /* let elementsFromPoint see what's under */
}

body.edit-mode .card[data-slug].drop-target {
  outline: 2px solid var(--accent);
  outline-offset: 6px;
}

body.edit-mode .card[data-slug].drop-target::after {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 2px;
  background: rgba(196, 69, 54, 0.08);
  pointer-events: none;
  z-index: 1;
}

body.edit-mode .card[data-slug].resizing {
  outline: 2px solid var(--accent);
  outline-offset: 6px;
}

/* While dragging a card, suppress text selection and tweak cursor globally */
body.is-card-dragging,
body.is-card-dragging * {
  user-select: none !important;
  -webkit-user-select: none !important;
  cursor: grabbing !important;
}

/* Index pill — lives in the BODY area below the image (not on top of it),
   so double-click / drag never grabs the picture. */
.card-index-pill {
  display: none;
  width: fit-content;
  margin: 14px 0 0;
  padding: 6px 12px;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
  border-radius: 2px;
  cursor: pointer;
  user-select: none;
  transition: background 180ms ease, color 180ms ease;
  align-self: flex-start;
}

.card-index-pill:hover {
  background: var(--accent);
}

body.edit-mode .card-index-pill {
  display: inline-block;
}

.card-index-input {
  display: inline-block;
  width: 72px;
  margin: 14px 0 0;
  padding: 6px 10px;
  background: var(--accent);
  color: var(--paper);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.1em;
  border: 0;
  border-radius: 2px;
  outline: 0;
}

.card-resize-handle {
  position: absolute;
  bottom: 8px; right: 8px;
  z-index: 6;
  width: 28px; height: 28px;
  background: var(--ink);
  color: var(--paper);
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
  cursor: ew-resize;
  font-size: 14px;
  user-select: none;
}

body.edit-mode .card[data-slug]:hover .card-resize-handle,
body.edit-mode .card[data-slug].resizing .card-resize-handle {
  display: flex;
}

.card-span-pill {
  position: absolute;
  bottom: 12px; left: 12px;
  z-index: 6;
  padding: 4px 9px;
  background: rgba(11, 11, 11, 0.85);
  color: var(--paper);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  border-radius: 2px;
  display: none;
}

body.edit-mode .card[data-slug]:hover .card-span-pill,
body.edit-mode .card[data-slug].resizing .card-span-pill {
  display: block;
}

/* ---- New Project modal ---------------------------------------------- */
.np-label {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 12px 0 6px;
}

.edit-login__card textarea {
  width: 100%;
  padding: 12px 14px;
  font: inherit;
  font-family: var(--sans);
  border: 1px solid var(--line);
  background: white;
  border-radius: 2px;
  margin-bottom: 4px;
  outline: none;
  resize: vertical;
  transition: border-color 200ms ease;
}

.edit-login__card textarea:focus { border-color: var(--accent); }

.np-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.np-row input { margin-bottom: 4px; }

.np-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 14px 0 4px;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
}

.np-checkbox input { width: auto; margin: 0; }

.np-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.edit-login__card .np-btn-ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  flex: 0 0 auto;
  padding: 14px 24px;
}

.edit-login__card .np-btn-ghost:hover {
  background: var(--bg-deep);
  color: var(--ink);
}

.edit-login__card .np-actions button[data-act="create"] {
  flex: 1;
}
