/* ============================================================
   PDF to Image — gallery.css
   Step 2: thumbnail grid of every PDF page, in document order.
   No drag-reorder here (page order is fixed by the PDF itself) —
   each card is a simple tap-to-toggle "include this page" tile,
   plus a page-number badge so it's obvious which page is which.
   ============================================================ */


/* ══════════════════════════════════════════
   0. HINT LINE + QUICK ACTIONS (above the grid)
   ══════════════════════════════════════════ */
.ip-pdf2img-gallery__hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 0 12px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ip-ink-soft);
}

.ip-pdf2img-gallery__quickactions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.ip-pdf2img-linkbtn {
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ip-brand-dark);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.ip-pdf2img-linkbtn:active {
  opacity: 0.7;
}


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


/* ══════════════════════════════════════════
   2. CARD
   ══════════════════════════════════════════ */
.ip-pdf2img-card {
  position: relative;
  display: flex;
  flex-direction: column;
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
  border: 1.5px solid var(--ip-line);
  cursor: pointer;
  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, border-color 0.15s ease, box-shadow 0.15s ease;
}

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

/* Deselected pages fade back and lose the brand border, so a scan
   of the grid instantly shows what will/won't be exported. */
.ip-pdf2img-card.is-selected {
  border-color: var(--ip-brand);
  box-shadow: 0 0 0 2px var(--ip-brand-soft);
}

.ip-pdf2img-card:not(.is-selected) {
  opacity: 0.5;
}

.ip-pdf2img-card__thumbwrap {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  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-pdf2img-card__thumb {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Skeleton shimmer shown in each thumbwrap until its page has
   actually been rasterized by pdf.js */
.ip-pdf2img-card__thumbwrap.is-loading::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(255,255,255,0.55) 50%, transparent 70%);
  background-size: 200% 100%;
  animation: ipShimmer 1.3s ease-in-out infinite;
}

@keyframes ipShimmer {
  from { background-position: 140% 0; }
  to   { background-position: -40% 0; }
}

/* ── Page-order badge — top-left ── */
.ip-pdf2img-card__page {
  position: absolute;
  top: 6px;
  left: 6px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 9999px;
  background: rgba(26,26,34,0.6);
  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;
  backdrop-filter: blur(2px);
}

.ip-pdf2img-card.is-selected .ip-pdf2img-card__page {
  background: var(--ip-brand);
}

/* ── Select/deselect checkmark — top-right ── */
.ip-pdf2img-card__check {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.85);
  background: rgba(26,26,34,0.35);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.ip-pdf2img-card__check svg {
  width: 13px;
  height: 13px;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.ip-pdf2img-card.is-selected .ip-pdf2img-card__check {
  background: var(--ip-brand);
  border-color: var(--ip-brand);
}

.ip-pdf2img-card.is-selected .ip-pdf2img-card__check svg {
  opacity: 1;
  transform: scale(1);
}

/* ── File name / meta ── */
.ip-pdf2img-card__meta {
  margin: 8px 8px 8px;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--ip-ink-soft);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}


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

  .ip-pdf2img-card:hover {
    border-color: var(--ip-brand);
  }

  .ip-pdf2img-linkbtn:hover {
    color: var(--ip-brand);
  }
}


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

  .ip-pdf2img-card__thumbwrap.is-loading::after {
    animation: none;
  }
}
