/* Post Gallery Carousel (pg-*) — standalone */

/* Shell */
.pg-carousel {
  position: relative;
  width: 100%;
  max-width: 1600px;
  margin: 24px auto;
}

/* Viewport/frame (side gutters keep arrows off the images) */
.pg-viewport {
  box-sizing: border-box;
  overflow: hidden;
  padding: 0 48px;      /* ← gutters; adjust if you want arrows farther/closer */
  width: 100%;
  max-width: 1400px;    /* ← widen/narrow overall frame cap */
  margin: 0 auto;
  position: relative;
}

/* Track (multi-visible grid) */
.pg-track {
  --gap: 14px;          /* small gap between slides */
  --visible: 2;         /* default number of visible slides */
  --scale: 1.7;           /* 1.00 = current size; e.g. 1.06 ≈ +6% taller */

  display: grid;
  grid-auto-flow: column;
  gap: var(--gap);
  align-items: stretch;
  will-change: transform;
  transform: translateX(0) translateZ(0);
  backface-visibility: hidden;

  /* split width across columns, apply scale, and shave 1px to avoid edge spill */
  grid-auto-columns:
    calc( ((100% - (var(--visible) - 1) * var(--gap)) / var(--visible)) * var(--scale) - 1px );
}

/* Slide/card */
.pg-card {
  box-sizing: border-box;
  display: block;
  width: 100%;
  user-select: none;
  text-decoration: none;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.08);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  position: relative;
  z-index: 0;
  opacity: 1;
  visibility: visible;
}

.pg-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 14px 35px rgba(0,0,0,0.18);
}

/* ===== Image wrapper: strict 16:9 with fallback ===== */

/* Base */
.pg-imgwrap {
  width: 100%;
  background: #f5f5f5;
  overflow: hidden;
  border-radius: 8px;
  position: relative; /* needed for fallback */
}

.pg-imgwrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 1;
  visibility: visible;
  backface-visibility: hidden;
  transform: translateZ(0);
}

/* Prefer native aspect-ratio when available */
@supports (aspect-ratio: 16 / 9) {
  .pg-imgwrap { aspect-ratio: 16 / 9; position: static; }
  .pg-imgwrap img { position: static; }
}

/* Fallback for engines/tools without aspect-ratio */
@supports not (aspect-ratio: 16 / 9) {
  .pg-imgwrap::before {
    content: "";
    display: block;
    padding-top: 56.25%; /* 16:9 */
  }
  .pg-imgwrap img {
    position: absolute;
    inset: 0;
  }
}

/* Arrows (kept outside the images, in the gutters) */
.pg-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.9);
  color: #222;
  box-shadow: 0 4px 12px rgba(0,0,0,0.18);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;           /* above slides */
}
.pg-nav:focus { outline: 2px solid #1a73e8; outline-offset: 2px; }
.pg-nav:hover { background: #fff; }
.pg-nav:active { transform: translateY(-50%) scale(0.96); }

/* You said these positions work best for your layout */
.pg-nav--prev { left: -25px; }
.pg-nav--next { right: -25px; }

/* ===== Lightbox ===== */
.pg-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}
.pg-lightbox--open { display: flex; }
.pg-lightbox__imgwrap { max-width: 92vw; max-height: 92vh; }
.pg-lightbox__imgwrap img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.pg-lightbox__nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 48px; height: 48px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.35);
  background: rgba(255,255,255,0.12); color: #fff;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.pg-lightbox__nav--prev { left: 24px; }
.pg-lightbox__nav--next { right: 24px; }
.pg-lightbox__close {
  position: absolute; top: 18px; right: 18px;
  width: 40px; height: 40px; border-radius: 50%;
  border: none; background: rgba(255,255,255,0.2); color: #fff; cursor: pointer;
}

/* ===== Responsive visible slides ===== */
@media (max-width: 640px) {
  .pg-track { --visible: 1; --gap: 12px; --scale: 1; }
}
@media (min-width: 641px) and (max-width: 960px) {
  .pg-track { --visible: 2; --gap: 14px; --scale: 1; }
}
@media (min-width: 961px) and (max-width: 1280px) {
  .pg-track { --visible: 3; --gap: 14px; --scale: 1; }
}
@media (min-width: 1281px) {
  .pg-track { --visible: 4; --gap: 12px; --scale: 1.7; }
}

/* Optional: modern overflow clip hardening (if supported) */
@supports (overflow: clip) {
  .pg-viewport { overflow: clip; }
}
