/* ============================================================
   Image to PDF — gallery.css
   Step 2: draggable thumbnail grid — each selected image becomes
   a PDF page. Cards show page order, and can be reordered by
   drag, rotated, or removed.
   ============================================================ */


/* ══════════════════════════════════════════
   0. HINT LINE (above the grid)
   ══════════════════════════════════════════ */
.ip-img2pdf-gallery__hint {
  margin: 0 0 12px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ip-ink-soft);
  text-align: center;
}


/* ══════════════════════════════════════════
   1. GRID
   ══════════════════════════════════════════ */
.ip-img2pdf-gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 4px;
}


/* ══════════════════════════════════════════
   2. CARD
   ══════════════════════════════════════════ */
.ip-img2pdf-card {
  position: relative;
  display: flex;
  flex-direction: column;
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
  border: 1.5px solid var(--ip-line);
  cursor: grab;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  animation: ipCardIn 0.22s ease both;
  transition: opacity 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
}

@keyframes ipCardIn {
  from { opacity: 0; transform: scale(0.94); }
  to   { opacity: 1; transform: scale(1); }
}

/* Card actively being dragged (mouse, touch or pen) — lifts above the
   grid and follows the pointer via an inline transform set in gallery.js */
.ip-img2pdf-card.is-dragging {
  position: relative;
  z-index: 50;
  cursor: grabbing;
  border-color: var(--ip-brand);
  box-shadow: 0 14px 28px rgba(26,26,34,0.24), 0 0 0 3px var(--ip-brand-soft);
}

/* While any card is mid-drag, stop the page itself from scrolling —
   this is what makes touch drag-to-reorder possible on mobile */
body.ip-img2pdf-drag-lock {
  overscroll-behavior: none;
}

.ip-img2pdf-card__thumbwrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background:
    linear-gradient(45deg, #e9e9ef 25%, transparent 25%) -8px 0/ 16px 16px,
    linear-gradient(-45deg, #e9e9ef 25%, transparent 25%) -8px 0/ 16px 16px,
    linear-gradient(45deg, transparent 75%, #e9e9ef 75%) -8px 0/ 16px 16px,
    linear-gradient(-45deg, transparent 75%, #e9e9ef 75%) -8px 0/ 16px 16px,
    #fafafd;
  overflow: hidden;
}

.ip-img2pdf-card__thumb {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform 0.2s ease;
}

/* ── Page-order badge — top-left, updates live as cards are dragged ── */
.ip-img2pdf-card__page {
  position: absolute;
  top: 6px;
  left: 6px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 9999px;
  background: var(--ip-brand);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  pointer-events: none;
}

/* ── Overlay controls: remove (top-right) + rotate (bottom-right) ── */
.ip-img2pdf-card__remove,
.ip-img2pdf-card__rotate {
  position: absolute;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(26,26,34,0.55);
  color: #fff;
  cursor: pointer;
  backdrop-filter: blur(2px);
  transition: background 0.15s ease, transform 0.15s ease;
}

.ip-img2pdf-card__remove svg,
.ip-img2pdf-card__rotate svg {
  width: 15px;
  height: 15px;
}

.ip-img2pdf-card__remove {
  top: 6px;
  right: 6px;
}

.ip-img2pdf-card__remove:active,
.ip-img2pdf-card__rotate:active {
  transform: scale(0.9);
}

.ip-img2pdf-card__remove:hover {
  background: var(--ip-error);
}

.ip-img2pdf-card__rotate {
  bottom: 6px;
  right: 6px;
}

.ip-img2pdf-card__rotate:hover {
  background: var(--ip-brand);
}

/* ── File name / meta ── */
.ip-img2pdf-card__name {
  margin: 8px 8px 0;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ip-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ip-img2pdf-card__meta {
  margin: 2px 8px 8px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--ip-ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}


/* ══════════════════════════════════════════
   3. "ADD MORE" TILE — lives inside the same grid
   ══════════════════════════════════════════ */
.ip-img2pdf-gallery__add {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  border: 1.5px dashed var(--ip-line-strong);
  background: var(--ip-bg);
  color: var(--ip-brand-dark);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.ip-img2pdf-gallery__add svg {
  width: 22px;
  height: 22px;
  color: var(--ip-brand);
}

.ip-img2pdf-gallery__add span {
  font-size: 11px;
  font-weight: 700;
}

.ip-img2pdf-gallery__add:hover,
.ip-img2pdf-gallery__add:active {
  border-color: var(--ip-brand);
  background: var(--ip-brand-soft);
}


/* ══════════════════════════════════════════
   4. DESKTOP ENHANCEMENTS (≥768px)
   ══════════════════════════════════════════ */
@media (min-width: 768px) {
  .ip-img2pdf-gallery {
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
  }

  .ip-img2pdf-card__remove:hover,
  .ip-img2pdf-card__rotate:hover {
    transform: scale(1.08);
  }
}


/* ══════════════════════════════════════════
   5. ACCESSIBILITY
   ══════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  .ip-img2pdf-card {
    animation: none;
  }
}
