/* Core gallery styles for justified + grid */
.dmg-wrapper { position: relative; width: 100%; margin: 0; padding: 0; }
.dmg-gallery { position: relative; width: 100%; margin: 0; padding: 0; }
.dmg-wrapper:not(.is-ready) .dmg-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: var(--dmg-gutter, 0px); }
.dmg-wrapper:not(.is-ready) .dmg-row-ssr { display: contents; }
.dmg-wrapper:not(.is-ready) .dmg-item { display: block; }
.dmg-wrapper:not(.is-ready) .dmg-gallery img { width: 100%; height: auto; object-fit: cover; display: block; }

/* Justified */
.dmg-row { display: flex; flex-wrap: nowrap; align-items: stretch; margin-bottom: var(--dmg-gutter, 0px); }
.dmg-row:last-child { margin-bottom: 0; }
.dmg-item { display: block; position: relative; line-height: 0; background-size: cover; background-position: center; background-repeat: no-repeat; }
.dmg-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dmg-item:not(:last-child) { margin-right: var(--dmg-gutter, 0px); }

/* Grid */
.dmg-gallery.grid { display: grid; gap: var(--dmg-gutter, 0px); grid-template-columns: repeat(var(--dmg-cols-lg, 4), 1fr); }
@media (max-width: 900px){ .dmg-caption h2, .dmg-caption p {text-align: left;} .dmg-gallery.grid { grid-template-columns: repeat(var(--dmg-cols-md, 3), 1fr); } }
@media (max-width: 600px){ .dmg-caption h2, .dmg-caption p {text-align: left;} .dmg-gallery.grid { grid-template-columns: repeat(var(--dmg-cols-sm, 2), 1fr); } }

.dmg-card { display: flex; flex-direction: column; margin: 0; }
.dmg-thumb { width: 100%; text-decoration: none; }
.dmg-thumb-media { position: relative; width: 100%; aspect-ratio: var(--dmg-aspect, 2 / 3); overflow: hidden; border-radius: 6px; background: #111; }
.dmg-thumb-media img { width: 100%; height: 100%; object-fit: cover; object-position: center; display: block; }
.dmg-thumb-meta { padding: 8px 2px 0; line-height: 1.35; color: inherit; }
.dmg-thumb-meta-line { font-size: 15px; color: inherit; }
.dmg-thumb-meta-line:first-child { font-weight: 700; }
.dmg-thumb-meta-line + .dmg-thumb-meta-line { margin-top: 2px; font-size: 14px; }
.dmg-thumb-title { font-weight: 700; font-size: 15px; color: inherit; }
.dmg-thumb-sub { font-size: 14px; margin-top: 2px; color: inherit; }

/* Masonry */
.dmg-gallery.masonry { column-count: var(--dmg-cols-lg, 3); column-gap: var(--dmg-gutter, 16px); }
@media (max-width: 900px){ .dmg-gallery.masonry { column-count: var(--dmg-cols-md, 2); } }
@media (max-width: 600px){ .dmg-gallery.masonry { column-count: var(--dmg-cols-sm, 1); } }
.dmg-masonry-card { break-inside: avoid; margin: 0 0 var(--dmg-gutter, 16px); }
.dmg-masonry-card img { width: 100%; height: auto; display: block; }

/* Lightbox */
.dmg-lightbox[hidden]{display:none;}
.dmg-lightbox{ position:fixed; inset:0; z-index:2147483647; }
.dmg-lightbox-backdrop{position:absolute; inset:0; background:rgba(0,0,0,.88);}
.dmg-lightbox-inner{ position:relative; display:flex; flex-direction:column; height:100vh; padding:40px 0; color:#fff; }
.dmg-stage{ flex:1 1 auto; min-height:0; display:flex; align-items:center; justify-content:center; overflow: visible; text-align:center; }
.dmg-figure{ position:relative; display:inline-block; max-width:100vw; max-height:100%; }
.dmg-figure img{object-fit:contain; max-width:100%; max-height:100%;}
.dmg-lightbox .dmg-close{ position:absolute; top: 0; right: 8px; font-size:32px; background:transparent; border:0; color:#fff; cursor:pointer; }
.dmg-nav{ position:absolute; top:50%; transform:translateY(-50%); background:rgba(0,0,0,.35); border:0; color:#fff; font-size:44px; width:48px; height:64px; cursor:pointer; z-index:2; }
.dmg-nav.prev{left:6px;} .dmg-nav.next{right:6px;}
.dmg-caption{ flex:0 0 auto; margin:8px auto 0; padding:0; font-size:15px; line-height:1.5; color:inherit; text-align:left; max-height:min(40vh, 360px); overflow-y:auto; -webkit-overflow-scrolling:touch; overscroll-behavior:contain; scrollbar-gutter:stable both-edges; }
.dmg-caption h2{font-weight:800; font-size:18px; color:inherit; padding:0 8px 0 0; max-width: 100%; text-align: left;}
.dmg-caption p{margin: 8px 8px 0 0; white-space:pre-line; color:inherit;}
.dmg-caption--center{ text-align: center; }
.dmg-caption--center h2,.dmg-caption--center p{ text-align: center; padding: 0 8px; }
