/* DWB CMS — public gallery grid, file list and lightbox. Everything is namespaced (.dwb-…)
 * and kept at low specificity so a site's own stylesheet can override it. */

/* ---------- gallery thumbnails ---------- */
.dwb-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin: 1.5em 0; padding: 0; }
.dwb-gallery-item { margin: 0; min-width: 0; }
.dwb-gallery-item a { display: block; overflow: hidden; border-radius: 6px; background: #e9ecef; aspect-ratio: 4 / 3; cursor: zoom-in; }
.dwb-gallery-item a:focus-visible { outline: 3px solid #1a73e8; outline-offset: 2px; }
.dwb-gallery-item img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .25s ease; }
.dwb-gallery-item a:hover img { transform: scale(1.04); }
.dwb-gallery-item figcaption { margin-top: 6px; font-size: .875em; line-height: 1.35; color: #555; }

/* ---------- document list ---------- */
.dwb-files { list-style: none; margin: 1.5em 0; padding: 0; }
.dwb-file + .dwb-file { margin-top: 8px; }
.dwb-file a { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border: 1px solid #d9dde2; border-radius: 6px; text-decoration: none; color: inherit; }
.dwb-file a:hover { border-color: #8a94a0; background: #f7f8f9; }
.dwb-file-ext { flex: none; min-width: 44px; padding: 3px 6px; border-radius: 4px; background: #2d3748; color: #fff; font-size: .72em; font-weight: 700; letter-spacing: .05em; text-align: center; }
.dwb-file-label { flex: 1; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.dwb-file-size { flex: none; font-size: .85em; color: #666; white-space: nowrap; }

/* ---------- lightbox ---------- */
.dwb-lightbox-lock { overflow: hidden !important; }
.dwb-lightbox { position: fixed; inset: 0; z-index: 2147483000; display: flex; flex-direction: column; background: rgba(10, 12, 16, .94); color: #fff; font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; opacity: 0; transition: opacity .2s ease; touch-action: pan-y pinch-zoom; }
.dwb-lightbox[hidden] { display: none; }
.dwb-lightbox.is-open { opacity: 1; }
.dwb-lightbox-bar { display: flex; align-items: center; gap: 4px; padding: 8px 8px 8px 16px; flex: none; }
.dwb-lightbox-counter { flex: 1; font-variant-numeric: tabular-nums; color: #d5d9df; }
.dwb-lightbox-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: #fff; cursor: pointer; }
.dwb-lightbox-btn:hover { background: rgba(255, 255, 255, .16); }
.dwb-lightbox-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.dwb-lightbox-btn[hidden] { display: none; }
.dwb-lightbox-btn svg { width: 24px; height: 24px; display: block; }
.dwb-lightbox-stage { position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 0 56px; }
.dwb-lightbox-img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; display: block; user-select: none; -webkit-user-drag: none; opacity: 1; transition: opacity .18s ease; }
.dwb-lightbox-img.is-loading { opacity: 0; }
.dwb-lightbox-spinner { position: absolute; top: 50%; left: 50%; width: 34px; height: 34px; margin: -17px 0 0 -17px; border: 3px solid rgba(255, 255, 255, .25); border-top-color: #fff; border-radius: 50%; animation: dwb-lightbox-spin .8s linear infinite; }
.dwb-lightbox-spinner[hidden] { display: none; }
.dwb-lightbox-error { color: #ffd7d2; text-align: center; padding: 0 16px; }
.dwb-lightbox-error[hidden] { display: none; }
.dwb-lightbox-nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(0, 0, 0, .35); }
.dwb-lightbox-prev { left: 8px; }
.dwb-lightbox-next { right: 8px; }
.dwb-lightbox-caption { flex: none; min-height: 20px; max-height: 30vh; overflow-y: auto; padding: 10px 16px 16px; text-align: center; color: #eef0f3; }
.dwb-lightbox-caption:empty { padding-bottom: 8px; }
@keyframes dwb-lightbox-spin { to { transform: rotate(360deg); } }

@media (max-width: 600px) {
  .dwb-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .dwb-lightbox-stage { padding: 0; }
  .dwb-lightbox-nav { background: rgba(0, 0, 0, .5); }
  .dwb-lightbox-prev { left: 4px; }
  .dwb-lightbox-next { right: 4px; }
  .dwb-file a { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
  .dwb-lightbox, .dwb-lightbox-img, .dwb-gallery-item img { transition: none; }
  .dwb-gallery-item a:hover img { transform: none; }
  .dwb-lightbox-spinner { animation-duration: 2.4s; }
}
