/*
 * ShopLeaf public galleries (/gallery and /gallery/slug). Fonts and colours inherit from
 * the site; set these in a template to change them:
 *   --slg-text, --slg-muted, --slg-accent (buttons), --slg-gap (space between tiles)
 * --sl-header-offset is the height of the site's fixed header (set by the page's script).
 */
.slg, .slg-index {
    --slg-text: #1f1f1f;
    --slg-muted: #6b6b6b;
    --slg-accent: var(--primary, #1f1f1f);
    --slg-gap: 12px;
    max-width: 1200px;
    margin: 0 auto;
    padding: calc(var(--sl-header-offset, 0px) + 48px) 20px 80px;
    box-sizing: border-box;
    color: var(--slg-text);
    text-align: left;
}
.slg *, .slg-index *, .slg-lb *, .slg-show-full * { box-sizing: border-box; }

/* Templates style buttons globally; gallery controls start from a clean slate */
.slg button, .slg-lb button, .slg-show-full button {
    all: unset;
    box-sizing: border-box;
    cursor: pointer;
    font: inherit;
    color: inherit;
}
.slg button:focus-visible, .slg-lb button:focus-visible, .slg-show-full button:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }

.slg-preview { background: #fff4e0; padding: 10px; text-align: center; font: 14px sans-serif; color: #333; }

/* Heading */
.slg-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 28px; flex-wrap: wrap; }
.slg-head h1, .slg-index h1 { font-size: 40px; line-height: 1.15; font-weight: 800; margin: 0 0 10px; padding: 0; border: 0; text-transform: none; letter-spacing: -0.01em; }
.slg-head p { margin: 0 0 8px; max-width: 760px; font-size: 18px; line-height: 1.6; color: var(--slg-muted); }
.slg .slg-play {
    display: inline-flex; align-items: center; gap: 10px; padding: 14px 26px; border-radius: 999px;
    background: var(--slg-accent); color: #fff; font-weight: 700; font-size: 16px; white-space: nowrap;
    box-shadow: 0 8px 24px rgba(0,0,0,0.18); transition: transform 0.15s;
}
.slg .slg-play:hover { transform: translateY(-2px); }
.slg-back { display: inline-block; margin-top: 36px; font-size: 15px; color: var(--slg-muted); }

/* Tiles shared by every style */
/* .slg prefix so this outranks the button reset above */
.slg .slg-open { display: block; position: relative; width: 100%; height: 100%; overflow: hidden; background: #eee; }
.slg-open img, .slg-open video { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform 0.4s ease; }
.slg-open:hover img, .slg-open:hover video { transform: scale(1.04); }
.slg-badge {
    position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%;
    background: rgba(0,0,0,0.55); color: #fff; font-size: 20px; line-height: 56px; text-align: center; padding-left: 4px; pointer-events: none;
}

/* Classic: grid with titles and descriptions */
.slg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 28px var(--slg-gap); }
.slg-grid .slg-tile { margin: 0; }
.slg-grid .slg-open { aspect-ratio: 4 / 3; border-radius: 10px; }
.slg-tile figcaption { padding: 12px 2px 0; }
.slg-tile figcaption h2 { font-size: 18px; line-height: 1.35; margin: 0 0 4px; padding: 0; border: 0; text-transform: none; }
.slg-tile figcaption p { margin: 0; font-size: 15px; line-height: 1.55; color: var(--slg-muted); }

/* Slideshow: one large item and a strip of thumbnails */
.slg-stage { position: relative; aspect-ratio: 16 / 9; background: #111; border-radius: 12px; overflow: hidden; }
.slg .slg-stage .slg-open { background: #111; }
.slg-stage .slg-open img, .slg-stage .slg-open video { object-fit: contain; }
.slg-stage .slg-open:hover img, .slg-stage .slg-open:hover video { transform: none; }
.slg .slg-prev, .slg .slg-next, .slg .slg-auto {
    position: absolute; top: 50%; width: 48px; height: 48px; margin-top: -24px; border-radius: 50%;
    background: rgba(255,255,255,0.85); color: #111; font-size: 30px; line-height: 46px; text-align: center; z-index: 2;
    opacity: 0; transition: opacity 0.2s;
}
.slg .slg-prev { left: 14px; }
.slg .slg-next { right: 14px; }
.slg .slg-auto { top: auto; bottom: 14px; right: 14px; margin: 0; width: 40px; height: 40px; font-size: 14px; line-height: 40px; }
.slg .slg-auto.on { background: var(--slg-accent); color: #fff; }
.slg-stage:hover .slg-prev, .slg-stage:hover .slg-next, .slg-stage:hover .slg-auto, .slg .slg-auto.on { opacity: 1; }
@media (hover: none) { .slg .slg-prev, .slg .slg-next, .slg .slg-auto { opacity: 1; } }
.slg-caption { min-height: 28px; padding: 14px 2px 0; }
.slg-caption h2 { font-size: 20px; margin: 0 0 4px; padding: 0; border: 0; text-transform: none; }
.slg-caption p { margin: 0; font-size: 15px; line-height: 1.55; color: var(--slg-muted); }
.slg-strip { display: flex; gap: 8px; overflow-x: auto; padding: 16px 2px 6px; scroll-snap-type: x proximity; }
.slg .slg-thumb { position: relative; flex: 0 0 120px; height: 80px; border-radius: 8px; overflow: hidden; opacity: 0.55; transition: opacity 0.2s; scroll-snap-align: start; background: #ddd; }
.slg .slg-thumb.active, .slg .slg-thumb:hover { opacity: 1; }
.slg .slg-thumb.active { outline: 3px solid var(--slg-accent); outline-offset: -3px; }
.slg-thumb img, .slg-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.slg-thumb .slg-badge { width: 30px; height: 30px; margin: -15px 0 0 -15px; line-height: 30px; font-size: 11px; padding-left: 2px; }

/* Collage: mixed tile sizes */
.slg-collage { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); grid-auto-rows: 160px; grid-auto-flow: dense; gap: var(--slg-gap); }
.slg-collage .slg-tile { margin: 0; border-radius: 8px; overflow: hidden; }
.slg-collage .slg-w2 { grid-column: span 2; }
.slg-collage .slg-h2 { grid-row: span 2; }
.slg-collage .slg-h3 { grid-row: span 3; }
@media (max-width: 520px) {
    .slg-collage { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 120px; }
    .slg-collage .slg-h3 { grid-row: span 2; }
}

/* Audio list (classic and slideshow) */
.slg-audio { margin-top: 44px; }
.slg-audio h2 { font-size: 24px; margin: 0 0 14px; padding: 0; border: 0; text-transform: none; }
.slg-track { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 14px 0; border-top: 1px solid rgba(0,0,0,0.1); flex-wrap: wrap; }
.slg-track-text p { margin: 4px 0 0; font-size: 14px; color: var(--slg-muted); }
.slg-track audio { width: 340px; max-width: 100%; }

/* Gallery list (/gallery) */
.slg-index .slg-lead { font-size: 18px; color: var(--slg-muted); margin: 0 0 30px; }
.slg-index .slg-empty { color: var(--slg-muted); }
.slg-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 28px 20px; }
.slg-card { display: block; color: inherit; text-decoration: none; }
.slg-card img, .slg-card-blank { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 10px; background: #e9e9e9; transition: transform 0.3s; }
.slg-card:hover img { transform: translateY(-3px); }
.slg-card h2 { font-size: 20px; margin: 12px 0 4px; padding: 0; border: 0; text-transform: none; }
.slg-card .slg-meta { font-size: 14px; color: var(--slg-muted); }

/* Lightbox (click any tile) */
.slg-lb {
    position: fixed; inset: 0; z-index: 2147483000; background: rgba(8,8,8,0.96); color: #fff;
    display: flex; flex-direction: column; opacity: 0; transition: opacity 0.25s; font-family: inherit;
}
.slg-lb.open { opacity: 1; }
.slg-lb-top { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; font-size: 14px; color: rgba(255,255,255,0.7); }
.slg-lb .slg-lb-close { font-size: 30px; line-height: 1; padding: 4px 10px; color: #fff; }
.slg-lb-stage { position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 0 70px; }
.slg-lb-stage img, .slg-lb-stage video { max-width: 100%; max-height: 100%; object-fit: contain; display: block; border-radius: 4px; }
.slg-lb .slg-lb-prev, .slg-lb .slg-lb-next {
    position: absolute; top: 50%; margin-top: -28px; width: 56px; height: 56px; border-radius: 50%;
    background: rgba(255,255,255,0.12); color: #fff; font-size: 34px; line-height: 52px; text-align: center;
}
.slg-lb .slg-lb-prev:hover, .slg-lb .slg-lb-next:hover { background: rgba(255,255,255,0.25); }
.slg-lb .slg-lb-prev { left: 10px; }
.slg-lb .slg-lb-next { right: 10px; }
.slg-lb-caption { padding: 16px 24px 24px; text-align: center; min-height: 64px; }
.slg-lb-caption h2 { font-size: 20px; margin: 0 0 4px; color: #fff; border: 0; padding: 0; text-transform: none; }
.slg-lb-caption p { margin: 0 auto; max-width: 760px; font-size: 15px; line-height: 1.55; color: rgba(255,255,255,0.75); }
@media (max-width: 700px) {
    .slg-lb-stage { padding: 0 8px; }
    .slg-lb .slg-lb-prev, .slg-lb .slg-lb-next { top: auto; bottom: -64px; margin: 0; }
    .slg-head h1, .slg-index h1 { font-size: 30px; }
}

/* Collage Play show: full screen, fading between items with background audio */
.slg-show-full { position: fixed; inset: 0; z-index: 2147483000; background: #000; color: #fff; opacity: 0; transition: opacity 0.6s; overflow: hidden; }
.slg-show-full.open { opacity: 1; }
.slg-layer { position: absolute; inset: 0; opacity: 0; transition: opacity 1.4s ease; display: flex; align-items: center; justify-content: center; }
.slg-layer.on { opacity: 1; }
.slg-layer img, .slg-layer video { width: 100%; height: 100%; object-fit: contain; }
.slg-layer.cover img, .slg-layer.cover video { object-fit: cover; }
.slg-layer.on.zoom img { animation: slg-zoom var(--slg-zoom-time, 6s) ease-out forwards; }
@keyframes slg-zoom { from { transform: scale(1); } to { transform: scale(1.08); } }
.slg-show-caption { position: absolute; left: 0; right: 0; bottom: 0; padding: 60px 32px 32px; background: linear-gradient(transparent, rgba(0,0,0,0.65)); opacity: 0; transition: opacity 0.8s; }
.slg-show-caption.on { opacity: 1; }
.slg-show-caption h2 { margin: 0 0 4px; font-size: 26px; color: #fff; border: 0; padding: 0; text-transform: none; }
.slg-show-caption p { margin: 0; max-width: 760px; font-size: 16px; line-height: 1.5; color: rgba(255,255,255,0.85); }
.slg-show-bar { position: absolute; top: 0; left: 0; right: 0; display: flex; justify-content: flex-end; gap: 6px; padding: 14px; opacity: 0; transition: opacity 0.3s; z-index: 3; }
.slg-show-full:hover .slg-show-bar, .slg-show-full.idle-off .slg-show-bar { opacity: 1; }
.slg-show-bar button { width: 44px; height: 44px; border-radius: 50%; background: rgba(0,0,0,0.45); color: #fff; font-size: 18px; line-height: 44px; text-align: center; }
.slg-show-bar button:hover { background: rgba(255,255,255,0.25); }
@media (hover: none) { .slg-show-bar { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
    .slg-layer { transition-duration: 0.3s; }
    .slg-layer.on.zoom img { animation: none; }
}
