/* Widget layout: isolated selectors, no frameworks or font assets. */
.leg-gallery {
  --leg-columns: 4;
  --leg-gap: 12px;
  --leg-radius: 0px;
  display: grid;
  grid-template-columns: repeat(var(--leg-columns), minmax(0, 1fr));
  gap: var(--leg-gap);
  min-width: 0;
  width: 100%;
}

.leg-gallery .leg-item {
  position: relative;
  min-width: 0;
  width: 100%;
  margin: 0;
  overflow: hidden;
  border-radius: var(--leg-radius);
  aspect-ratio: 1 / 1;
}

.leg-gallery[data-leg-shape="landscape"] .leg-item { aspect-ratio: 4 / 3; }
.leg-gallery[data-leg-shape="portrait"] .leg-item { aspect-ratio: 3 / 4; }

.leg-gallery .leg-image,
.leg-gallery .leg-lightbox-trigger,
.leg-gallery .leg-lightbox-link {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.leg-gallery .leg-image {
  object-fit: cover;
  object-position: center;
}

.leg-gallery[data-leg-focus="top"] .leg-image { object-position: center top; }
.leg-gallery[data-leg-focus="bottom"] .leg-image { object-position: center bottom; }
.leg-gallery[data-leg-focus="left"] .leg-image { object-position: left center; }
.leg-gallery[data-leg-focus="right"] .leg-image { object-position: right center; }

/* Reset theme button styles and keep older cached anchor markup supported. */
.leg-gallery .leg-lightbox-trigger,
.leg-gallery .leg-lightbox-trigger:hover,
.leg-gallery .leg-lightbox-trigger:focus,
.leg-gallery .leg-lightbox-trigger:active {
  box-sizing: border-box;
  appearance: none;
  -webkit-appearance: none;
  padding: 0;
  margin: 0;
  min-width: 0;
  min-height: 0;
  border: 0;
  border-radius: inherit;
  background: transparent;
  background-image: none;
  box-shadow: none;
  color: inherit;
  font: inherit;
  text-transform: none;
  text-decoration: none;
  line-height: normal;
  cursor: zoom-in;
}

.leg-gallery .leg-lightbox-link {
  cursor: zoom-in;
  color: inherit;
}

.leg-gallery .leg-lightbox-trigger:focus-visible,
.leg-gallery .leg-lightbox-link:focus-visible {
  z-index: 1;
  outline: 3px solid currentColor;
  outline-offset: -3px;
}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .leg-gallery--zoom .leg-image { transition: transform 220ms ease; }
  .leg-gallery--zoom .leg-item:hover .leg-image { transform: scale(1.045); }
}

.leg-placeholder {
  padding: 20px;
  border: 1px dashed #a8a8a8;
  margin: 0;
  color: #777;
  font-size: 14px;
}

/* Borderless lightbox: image sits directly on a darkened full-screen overlay. */
html.leg-lightbox-open,
html.leg-lightbox-open body { overflow: hidden; }

.leg-dialog {
  box-sizing: border-box;
  position: fixed;
  inset: 0;
  width: 100vw;
  max-width: none;
  height: 100vh;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  overflow: hidden;
  background: rgba(6, 7, 10, .975);
  color: #fff;
  box-shadow: none;
  overscroll-behavior: contain;
}

.leg-dialog:not([open]) { display: none; }
.leg-dialog[open] { display: flex; flex-direction: column; }
.leg-dialog::backdrop { background: rgba(4, 5, 8, .94); }
.leg-dialog [hidden] { display: none !important; }

.leg-dialog__stage {
  position: relative;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  padding: 68px 90px 30px;
}

.leg-dialog__image {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  min-width: 0;
  min-height: 0;
  flex: 0 1 auto;
  object-fit: contain;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  opacity: 0;
  transform: translateY(4px) scale(.995);
  transition: opacity 180ms ease, transform 200ms ease;
}

.leg-dialog__image--ready {
  opacity: 1;
  transform: none;
}

.leg-dialog__loader {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
  border: 2px solid rgba(255, 255, 255, .2);
  border-top-color: rgba(255, 255, 255, .86);
  border-radius: 50%;
  animation: leg-spinner .85s linear infinite;
  pointer-events: none;
}

@keyframes leg-spinner { to { transform: rotate(360deg); } }

.leg-dialog__error {
  position: absolute;
  inset: 50% auto auto 50%;
  width: max-content;
  max-width: 80vw;
  margin: 0;
  color: rgba(255, 255, 255, .8);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  transform: translate(-50%, -50%);
}

.leg-dialog__info {
  box-sizing: border-box;
  flex: 0 0 auto;
  width: 100%;
  max-height: min(26vh, 180px);
  overflow: auto;
  margin-top: 18px;
  padding: 0;
  text-align: center;
  overflow-wrap: anywhere;
  scrollbar-width: thin;
}

.leg-dialog__title,
.leg-dialog__caption {
  max-width: 820px;
  margin-left: auto;
  margin-right: auto;
  white-space: pre-line;
}

.leg-dialog__title {
  margin-top: 0;
  margin-bottom: 4px;
  color: rgba(255, 255, 255, .95);
  font: 600 clamp(15px, 1.4vw, 18px)/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.leg-dialog__caption {
  margin-top: 0;
  margin-bottom: 0;
  color: rgba(255, 255, 255, .73);
  font: 400 13px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.leg-dialog__counter {
  position: absolute;
  z-index: 2;
  top: max(21px, env(safe-area-inset-top));
  left: max(24px, env(safe-area-inset-left));
  margin: 0;
  color: rgba(255, 255, 255, .64);
  font: 500 12px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: .12em;
  font-variant-numeric: tabular-nums;
}

.leg-dialog__button {
  position: absolute;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: rgba(255, 255, 255, .88);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 150ms ease, color 150ms ease;
}

.leg-dialog__button svg {
  display: block;
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.leg-dialog__button:hover,
.leg-dialog__button:active { background: rgba(255, 255, 255, .13); color: #fff; }
.leg-dialog__button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

.leg-dialog__close {
  top: max(9px, calc(env(safe-area-inset-top) - 12px));
  right: max(12px, env(safe-area-inset-right));
}
.leg-dialog__prev { top: 50%; left: 16px; transform: translateY(-50%); }
.leg-dialog__next { top: 50%; right: 16px; transform: translateY(-50%); }

@media (max-width: 600px) {
  .leg-dialog__stage { padding: 62px 14px max(40px, env(safe-area-inset-bottom)); }
  .leg-dialog__info { margin-top: 16px; max-height: 28vh; }
  .leg-dialog__title { font-size: 15px; }
  .leg-dialog__caption { font-size: 12px; }
  .leg-dialog__prev { left: 3px; }
  .leg-dialog__next { right: 3px; }
  .leg-dialog__button { width: 42px; height: 42px; background: rgba(0, 0, 0, .22); }
  .leg-dialog__close { top: max(9px, env(safe-area-inset-top)); right: max(10px, env(safe-area-inset-right)); }
  .leg-dialog__counter { top: max(17px, env(safe-area-inset-top)); left: max(16px, env(safe-area-inset-left)); }
}

@media (prefers-reduced-motion: reduce) {
  .leg-dialog__image,
  .leg-dialog__button { transition: none; transform: none; }
  .leg-dialog__loader { animation-duration: 1.5s; }
}
