/*
 * Photo Gallery -- the gallery visitors see (inside the page's content).
 * Colors: --cpg-main / --cpg-second come from the Settings tab's Colors box (CPG_Branding prints
 * them after this file); the values below are the neutral defaults.
 * Everything is scoped to .cpg so it never touches the rest of the site.
 */
.cpg {
	--cpg-main: #2563EB;
	--cpg-main-dark: #1E51C1;
	--cpg-second: #6B7280;
	--cpg-second-dark: #585D69;
	--cpg-radius: 8px;
	box-sizing: border-box;
}
.cpg *, .cpg *::before, .cpg *::after { box-sizing: inherit; }
.cpg img { max-width: 100%; height: auto; display: block; }

/* Download protection: no selecting, dragging or long-press saving of photos (with cpg-gallery.js). */
.cpg-protect img { -webkit-user-drag: none; user-select: none; -webkit-touch-callout: none; }

.cpg-notice { padding: 10px 14px; border-radius: var(--cpg-radius); background: #FEF3C7; color: #78350F; margin: 0 0 16px; }
.cpg-empty { text-align: center; color: #6B7280; font-style: italic; padding: 32px 0; }

/* ── Hero ── */
.cpg-hero { position: relative; overflow: hidden; background: #1a1a1a; margin: 0 0 32px; }
.cpg-hero-img { width: 100%; max-height: 60vh; object-fit: cover; }
.cpg-hero-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, 0.35); padding: 16px; }
.cpg .cpg-hero-title { color: #fff; margin: 0; text-align: center; font-size: clamp(1.8rem, 5vw, 3.2rem); text-shadow: 0 2px 12px rgba(0, 0, 0, 0.4); }

/* ── Browse by category ── */
.cpg-browse { padding: 8px 0 32px; scroll-margin-top: 80px; }
.cpg-browse-heading { text-align: center; font-weight: 600; font-size: 1.2rem; margin: 0 0 20px; }
.cpg-card { display: block; text-decoration: none; color: inherit; background: #fff; border-radius: var(--cpg-radius); overflow: hidden; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12); transition: transform .15s ease, box-shadow .15s ease; }
.cpg-card:hover, .cpg-card:focus-visible { transform: translateY(-3px); box-shadow: 0 6px 16px rgba(0, 0, 0, 0.16); }
.cpg-card-cover { display: block; aspect-ratio: 4 / 3; background: #E5E7EB; overflow: hidden; }
.cpg-card-cover img { width: 100%; height: 100%; object-fit: cover; }
.cpg-card-label { display: block; padding: 10px 12px; border-top: 3px solid var(--cpg-main); }
.cpg-card-name { display: block; font-weight: 600; color: #1F2328; }
.cpg-card-count { display: inline-block; margin-top: 4px; font-size: 0.8rem; color: #fff; background: var(--cpg-second); border-radius: 999px; padding: 1px 10px; }

/* Grid layout: every category visible at once. */
.cpg-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px; }

/* Slider layout: 4 / 2 / 1 cards per page (cpg-gallery.js moves the track). */
.cpg-slider { display: flex; align-items: center; gap: 10px; }
.cpg-track-outer { flex: 1; overflow: hidden; min-width: 0; }
.cpg-track { display: flex; gap: 20px; transition: transform .35s ease; touch-action: pan-y; }
.cpg-track .cpg-card { flex: 0 0 calc((100% - 60px) / 4); }
@media (max-width: 900px) { .cpg-track .cpg-card { flex-basis: calc((100% - 20px) / 2); } }
@media (max-width: 560px) { .cpg-track .cpg-card { flex-basis: 100%; } }
.cpg-arrow { flex: none; width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer; background: var(--cpg-main); color: #fff; font-size: 26px; line-height: 1; display: flex; align-items: center; justify-content: center; padding: 0 0 3px; }
.cpg-arrow:hover { background: var(--cpg-main-dark); }
.cpg-arrow:disabled { background: #D1D5DB; cursor: default; }
.cpg-dots { display: flex; justify-content: center; gap: 8px; margin-top: 16px; }
.cpg-dot { width: 10px; height: 10px; border-radius: 50%; border: 0; padding: 0; background: #D1D5DB; cursor: pointer; }
.cpg-dot.is-active { background: var(--cpg-main); }

/* ── A category ── */
.cpg-catbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; background: var(--cpg-second); color: #fff; padding: 14px 18px; border-radius: var(--cpg-radius); margin: 0 0 20px; }
.cpg-catbar .cpg-back { color: #fff; opacity: .9; text-decoration: none; font-size: .9rem; }
.cpg-catbar .cpg-back:hover { opacity: 1; text-decoration: underline; }
.cpg .cpg-cat-title { flex: 1; margin: 0; color: #fff; font-size: 1.5rem; }
.cpg-badge { background: rgba(255, 255, 255, 0.2); border-radius: 999px; padding: 2px 12px; font-size: .85rem; }
.cpg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
@media (max-width: 680px) { .cpg-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } }
@media (max-width: 420px) { .cpg-grid { grid-template-columns: 1fr; } }
.cpg-item { display: flex; flex-direction: column; border: 0; padding: 0; margin: 0; background: #fff; border-radius: var(--cpg-radius); overflow: hidden; cursor: zoom-in; text-align: left; font: inherit; color: inherit; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12); }
.cpg-item:focus-visible { outline: 3px solid var(--cpg-main); outline-offset: 2px; }
.cpg-thumb { display: block; aspect-ratio: 4 / 3; overflow: hidden; background: #E5E7EB; }
.cpg-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .25s ease; }
.cpg-item:hover .cpg-thumb img { transform: scale(1.04); }
.cpg-caption { display: block; padding: 8px 10px; font-size: .9rem; color: #444; border-top: 2px solid var(--cpg-main); min-height: 2.4em; }
.cpg-captions-viewer .cpg-caption { display: none; }
.cpg-back-bottom { margin: 24px 0 0; }
.cpg-back-bottom .cpg-back { color: var(--cpg-main); font-weight: 600; text-decoration: none; }
.cpg-back-bottom .cpg-back:hover { text-decoration: underline; }

/* ── Photo viewer ── */
.cpg-viewer { position: fixed; inset: 0; z-index: 100000; background: rgba(0, 0, 0, 0.94); display: flex; align-items: center; justify-content: center; padding: 48px 56px; }
.cpg-viewer[hidden] { display: none; }
.cpg-viewer-figure { margin: 0; max-width: 100%; max-height: 100%; display: flex; flex-direction: column; align-items: center; }
.cpg-viewer .cpg-viewer-img { max-width: 100%; max-height: calc(100vh - 140px); width: auto; object-fit: contain; }
.cpg-viewer figcaption { color: #fff; text-align: center; margin-top: 12px; }
.cpg-viewer-caption { display: block; }
.cpg-viewer-counter { display: block; color: #9CA3AF; font-size: .85rem; margin-top: 4px; }
.cpg-viewer-close, .cpg-viewer-nav { position: absolute; background: none; border: 0; color: #fff; cursor: pointer; line-height: 1; opacity: .85; }
.cpg-viewer-close:hover, .cpg-viewer-nav:hover { opacity: 1; }
.cpg-viewer-close { top: 12px; right: 18px; font-size: 40px; }
.cpg-viewer-nav { top: 50%; transform: translateY(-50%); font-size: 56px; padding: 8px; }
.cpg-viewer-prev { left: 8px; }
.cpg-viewer-next { right: 8px; }
@media (max-width: 560px) { .cpg-viewer { padding: 48px 8px; } .cpg-viewer-nav { display: none; } }
