/* Gallery widget — brand-neutral. Override the custom properties on .gyg
   (or on any ancestor) to match the host site; nothing else needs editing.
   Deliberately independent of Tailwind so the folder drops into any project. */

.gyg {
  --gyg-cols: 3;
  --gyg-gap: 8px;
  --gyg-radius: 4px;
  --gyg-window: none;
  --gyg-placeholder: #e9ecf1;
  --gyg-heading: inherit;
  --gyg-scrollbar: rgba(0, 0, 0, .25);

  display: block;
  max-width: 100%;
}

.gyg-title {
  margin: 0 0 12px;
  color: var(--gyg-heading);
  font-size: 1.15em;
  line-height: 1.3;
}

/* The scroll window. When scrolling is off, max-height stays `none` and the
   grid simply flows with the page. */
.gyg-window {
  max-height: var(--gyg-window);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.gyg-window::-webkit-scrollbar { width: 8px; }
.gyg-window::-webkit-scrollbar-thumb {
  background: var(--gyg-scrollbar);
  border-radius: 4px;
}

/* Reading order: CSS Grid fills left to right across each row, then down —
   which is exactly the Instagram arrangement asked for. */
.gyg-grid {
  display: grid;
  grid-template-columns: repeat(var(--gyg-cols), minmax(0, 1fr));
  gap: var(--gyg-gap);
}

.gyg-tile {
  display: block;
  position: relative;
  overflow: hidden;
  border-radius: var(--gyg-radius);
  background: var(--gyg-placeholder);
  padding: 0;
  border: 0;
  cursor: default;
  width: 100%;
}
.gyg--clickable .gyg-tile { cursor: zoom-in; }

.gyg-tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transition: transform .35s ease, opacity .3s ease;
}
.gyg-tile img.gyg-in { opacity: 1; }
.gyg--clickable .gyg-tile:hover img { transform: scale(1.04); }

/* Square tiles: mixed aspect ratios crop to a uniform grid. */
.gyg--square .gyg-tile { aspect-ratio: 1 / 1; }

/* Natural tiles: each image keeps its own shape. Rows stay aligned to the
   grid, so tall images letterbox rather than pushing the row out of line. */
.gyg--natural .gyg-tile { aspect-ratio: auto; }
.gyg--natural .gyg-tile img { height: auto; object-fit: contain; }

/* Fallback for browsers without aspect-ratio. */
@supports not (aspect-ratio: 1 / 1) {
  .gyg--square .gyg-tile { height: 0; padding-bottom: 100%; }
  .gyg--square .gyg-tile img { position: absolute; inset: 0; }
}

.gyg-cap {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 18px 10px 8px;
  font-size: 12px;
  line-height: 1.35;
  color: #fff;
  background: linear-gradient(to top, rgba(0, 0, 0, .68), rgba(0, 0, 0, 0));
  text-align: left;
  pointer-events: none;
}

.gyg-sentinel { height: 1px; grid-column: 1 / -1; }

.gyg-empty,
.gyg-error {
  padding: 20px 0;
  font-size: 14px;
  opacity: .65;
}

/* --------------------------------------------------------------- lightbox */

.gyg-lb {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(8, 11, 16, .93);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.gyg-lb[hidden] { display: none; }
.gyg-lb img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 4px;
  object-fit: contain;
}
.gyg-lb button {
  position: absolute;
  background: rgba(255, 255, 255, .1);
  border: 0;
  color: #fff;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.gyg-lb button:hover { background: rgba(255, 255, 255, .2); }
.gyg-lb-close { top: 18px; right: 18px; }
.gyg-lb-prev { left: 18px; top: 50%; transform: translateY(-50%); }
.gyg-lb-next { right: 18px; top: 50%; transform: translateY(-50%); }

@media (max-width: 640px) {
  .gyg-lb-prev, .gyg-lb-next { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .gyg-tile img { transition: none; }
  .gyg--clickable .gyg-tile:hover img { transform: none; }
}
