/* ════════════════════════════════════════════════════════
   post-gallery.css
   Front-end rendering for in-post Gallery and PDF blocks
   inserted via the TinyMCE "Insert Gallery" / "Insert PDF"
   toolbar buttons. Reuses GLightbox (loaded site-wide).
   ════════════════════════════════════════════════════════ */

.post-gallery-block { margin: 24px 0; }
.post-gallery-block a { display: block; cursor: zoom-in; }
.post-gallery-block img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ── Thumbnails: simple even grid ───────────────────────── */
.pg-thumbnails {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px;
}
.pg-thumbnails a { aspect-ratio: 1; border-radius: 6px; overflow: hidden; }

/* ── Masonry: variable height columns ───────────────────── */
.pg-masonry {
    column-count: 3; column-gap: 8px;
}
.pg-masonry a { display: block; margin-bottom: 8px; border-radius: 6px; overflow: hidden; break-inside: avoid; }
.pg-masonry img { width: 100%; height: auto; object-fit: unset; }
@media (max-width: 700px) { .pg-masonry { column-count: 2; } }

/* ── Mosaic: first image large, rest smaller in a grid ──── */
.pg-mosaic {
    display: grid; grid-template-columns: repeat(4, 1fr); grid-auto-rows: 110px; gap: 8px;
}
.pg-mosaic a { border-radius: 6px; overflow: hidden; }
.pg-mosaic a:first-child { grid-column: span 2; grid-row: span 2; }
@media (max-width: 700px) { .pg-mosaic { grid-template-columns: repeat(3, 1fr); grid-auto-rows: 80px; } }

/* ── Slideshow: one large image, auto-advance, dots below ── */
.pg-slideshow { position: relative; border-radius: 8px; overflow: hidden; background: #000; }
.pg-slideshow .pg-slide-track { position: relative; aspect-ratio: 16/9; }
.pg-slideshow .pg-slide {
    position: absolute; inset: 0; opacity: 0; transition: opacity .5s ease; cursor: zoom-in;
}
.pg-slideshow .pg-slide.active { opacity: 1; z-index: 1; }
.pg-slideshow .pg-slide img { width: 100%; height: 100%; object-fit: contain; background: #111; }
.pg-slideshow .pg-dots {
    position: absolute; bottom: 10px; left: 0; right: 0; display: flex; justify-content: center; gap: 6px; z-index: 2;
}
.pg-slideshow .pg-dot {
    width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,0.5); cursor: pointer; border: none; padding: 0;
}
.pg-slideshow .pg-dot.active { background: #fff; }
.pg-slideshow .pg-arrow {
    position: absolute; top: 50%; transform: translateY(-50%); background: rgba(0,0,0,0.4); color: #fff;
    border: none; width: 36px; height: 36px; border-radius: 50%; cursor: pointer; z-index: 2; font-size: 1rem;
}
.pg-slideshow .pg-arrow-prev { left: 10px; }
.pg-slideshow .pg-arrow-next { right: 10px; }
.pg-slideshow .pg-arrow:hover { background: rgba(0,0,0,0.65); }

/* ── Image Browser: large viewer + filmstrip thumbnails ──── */
.pg-browser { border-radius: 8px; overflow: hidden; }
.pg-browser .pg-browser-main { position: relative; aspect-ratio: 16/9; background: #111; cursor: zoom-in; }
.pg-browser .pg-browser-main img { width: 100%; height: 100%; object-fit: contain; transition: opacity .25s ease; }
.pg-browser .pg-browser-strip {
    display: flex; gap: 6px; overflow-x: auto; padding: 8px 0; margin-top: 8px;
}
.pg-browser .pg-browser-thumb {
    flex: 0 0 70px; height: 56px; border-radius: 4px; overflow: hidden; cursor: pointer;
    opacity: 0.6; border: 2px solid transparent; transition: opacity .15s, border-color .15s;
}
.pg-browser .pg-browser-thumb.active { opacity: 1; border-color: #1a3e72; }
.pg-browser .pg-browser-thumb img { width: 100%; height: 100%; object-fit: cover; }

/* ── Blog Style: full-width stacked images with spacing ──── */
.pg-blog { display: flex; flex-direction: column; gap: 16px; }
.pg-blog a { border-radius: 8px; overflow: hidden; }
.pg-blog img { width: 100%; height: auto; object-fit: unset; }

/* ── Carousel: horizontal scroll-snap strip ─────────────── */
.pg-carousel-wrap { position: relative; }
.pg-carousel {
    display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 4px;
    scrollbar-width: thin;
}
.pg-carousel a {
    flex: 0 0 70%; scroll-snap-align: start; border-radius: 8px; overflow: hidden; aspect-ratio: 4/3;
}
@media (min-width: 700px) { .pg-carousel a { flex-basis: 38%; } }
.pg-carousel-wrap .pg-arrow {
    position: absolute; top: 50%; transform: translateY(-50%); background: rgba(0,0,0,0.45); color: #fff;
    border: none; width: 34px; height: 34px; border-radius: 50%; cursor: pointer; z-index: 2; font-size: 0.95rem;
}
.pg-carousel-wrap .pg-arrow-prev { left: 4px; }
.pg-carousel-wrap .pg-arrow-next { right: 4px; }

/* ════════════════════════════════════════════════════════
   PDF block — collapsed-by-default inline preview
   ════════════════════════════════════════════════════════ */
.post-pdf-block {
    margin: 24px 0; border: 1px solid #e5e7eb; border-radius: 10px; overflow: hidden; background: #fafbfc;
}
.post-pdf-toggle {
    display: flex; align-items: center; gap: 10px; padding: 12px 16px; cursor: pointer;
    background: #fff; border: none; width: 100%; text-align: left; font-size: 0.88rem;
}
.post-pdf-toggle i.fa-file-pdf { color: #dc2626; font-size: 1.3rem; }
.post-pdf-toggle .post-pdf-name { flex: 1; font-weight: 600; color: #1e293b; }
.post-pdf-toggle .post-pdf-chevron { color: #94a3b8; transition: transform .2s; }
.post-pdf-toggle[aria-expanded="true"] .post-pdf-chevron { transform: rotate(180deg); }
.post-pdf-toggle .post-pdf-hint { font-size: 0.74rem; color: #94a3b8; margin-right: 6px; }

.post-pdf-frame-wrap { display: none; border-top: 1px solid #e5e7eb; }
.post-pdf-frame-wrap.open { display: block; }
.post-pdf-pages {
    max-height: 600px; overflow-y: auto; background: #525659; padding: 16px 0; text-align: center;
}
.post-pdf-page-canvas {
    display: block; margin: 0 auto 14px; max-width: 100%; height: auto !important; box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.post-pdf-loading, .post-pdf-error {
    color: #f1f5f9; font-size: 0.85rem; padding: 24px; margin: 0;
}
.post-pdf-fallback {
    display: none; padding: 14px 16px; font-size: 0.82rem; color: #64748b; text-align: center;
}
.post-pdf-fallback.always-show { display: block; }
.post-pdf-fallback a { color: #1a3e72; font-weight: 600; }

@media (max-width: 600px) {
    .post-pdf-pages { max-height: 420px; }
}
