/* =============================================================
   Property Gallery Widget
   Widget: Elem_Property_Gallery
   Source: app/modules/elementor/widgets/property-gallery/property-gallery.scss
   ============================================================= */

/* ── Widget wrapper ─────────────────────────────────────────── */
.elem-property-gallery {
  position: relative;
  width: 100%;
}

/* ── Property Selector ──────────────────────────────────────── */
.pg-selector-wrapper {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 14px;
}

.pg-selector-dropdown {
  position: relative;
}

.pg-selector-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  background-color: #1a1a1a;
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: 2px;
  transition: background-color 0.2s ease;
  user-select: none;
  border: 1px solid #C09F55 !important;
  border-radius: 8px;
}

.pg-selector-icon {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  transition: transform 0.22s ease;
}

.pg-selector-btn[aria-expanded='true'] .pg-selector-icon {
  transform: rotate(180deg);
}

.pg-selector-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 210px;
  background: #fff;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.14);
  list-style: none;
  margin: 0;
  padding: 6px 0;
  z-index: 200;
  border-radius: 3px;
}

.pg-selector-menu.open {
  display: block;
}

.pg-selector-item {
  padding: 11px 18px;
  cursor: pointer;
  font-size: 14px;
  color: #333;
  transition: background-color 0.15s;
}

.pg-selector-item:hover {
  background-color: #f5f5f5;
}

.pg-selector-item.active {
  font-weight: 600;
  color: #1a1a1a;
  background-color: #f0f0f0;
}

/* ── Gallery Panels ─────────────────────────────────────────── */
.pg-gallery-panel {
  display: none;
}

.pg-gallery-panel.active {
  display: block;
}

/* ── CSS Grid — exact 5-col × 4-row layout ─────────────────── */
.pg-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(4, 200px);
  grid-auto-rows: 200px;
  gap: 5px;
  padding: 5px;
  border-radius: 4px;
}

/*
  Exact positions (add images in this order in the widget):
   1  Bathroom         — wide top-left   (2 cols × 1 row)
   2  Bedroom          — top col 3
   3  Living room      — top col 4
   4  Kids shelf       — tall right      (1 col × 2 rows)
   5  Dark bedroom     — middle-left row 2
   6  Office / study   — tall            (1 col × 2 rows)
   7  House exterior   — hero center     (2 cols × 2 rows)
   8  Small house      — left row 3
   9  Kids toys        — tall right      (1 col × 2 rows)
  10  Coral bedroom    — bottom col 1
  11  Bathroom boho    — bottom col 2
  12  Living room      — bottom col 3
  13  Dining area      — bottom col 4
*/

.pg-item:nth-child(1)  { grid-column: 1 / 3; grid-row: 1 / 2; }
.pg-item:nth-child(2)  { grid-column: 3 / 4; grid-row: 1 / 2; }
.pg-item:nth-child(3)  { grid-column: 4 / 5; grid-row: 1 / 2; }
.pg-item:nth-child(4)  { grid-column: 5 / 6; grid-row: 1 / 3; }
.pg-item:nth-child(5)  { grid-column: 1 / 2; grid-row: 2 / 3; }
.pg-item:nth-child(6)  { grid-column: 2 / 3; grid-row: 2 / 4; }
.pg-item:nth-child(7)  { grid-column: 3 / 5; grid-row: 2 / 4; }
.pg-item:nth-child(8)  { grid-column: 1 / 2; grid-row: 3 / 4; }
.pg-item:nth-child(9)  { grid-column: 5 / 6; grid-row: 3 / 5; }
.pg-item:nth-child(10) { grid-column: 1 / 2; grid-row: 4 / 5; }
.pg-item:nth-child(11) { grid-column: 2 / 3; grid-row: 4 / 5; }
.pg-item:nth-child(12) { grid-column: 3 / 4; grid-row: 4 / 5; }
.pg-item:nth-child(13) { grid-column: 4 / 5; grid-row: 4 / 5; }

/* 14+ images auto-flow below the fixed layout */
.pg-item:nth-child(n+14) { grid-column: auto; grid-row: auto; }

/* ── Gallery Item ───────────────────────────────────────────── */
.pg-item {
  display: block;
  overflow: hidden;
  position: relative;
  cursor: pointer;
  background-color: #e0e0e0;
  text-decoration: none;
  outline-offset: 2px;
  border-radius: 10px;
}

.pg-item:focus-visible {
  outline: 2px solid #1a1a1a;
}

.pg-img {
  width: 100%;
  height: 100%!important;
  object-fit: cover;
  object-position: center;
  display: block;
  transition: transform 0.45s ease;
}

.pg-item:hover .pg-img {
  transform: scale(1.06);
}

.pg-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0);
  transition: background 0.3s ease;
  pointer-events: none;
}

.pg-item:hover .pg-overlay {
  background: rgba(0, 0, 0, 0.14);
}

/* ── Lightbox ───────────────────────────────────────────────── */
.pg-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  align-items: center;
  justify-content: center;
}

.pg-lightbox.open {
  display: flex;
}

.pg-lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.93);
  cursor: pointer;
}

.pg-lightbox-content {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 92vw;
  max-height: 90vh;
}

.pg-lightbox-img {
  display: block;
  max-width: 92vw;
  max-height: 88vh;
  object-fit: contain;
  transition: opacity 0.2s ease;
}

.pg-lightbox-img.pg-loading {
  opacity: 0.25;
}

.pg-lightbox-close,
.pg-lightbox-prev,
.pg-lightbox-next {
  position: fixed;
  z-index: 2;
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  line-height: 1;
  padding: 10px 16px;
  opacity: 0.75;
  transition: opacity 0.2s;
  font-weight: 300;
}

.pg-lightbox-close:hover,
.pg-lightbox-prev:hover,
.pg-lightbox-next:hover {
  opacity: 1;
}

.pg-lightbox-close:focus-visible,
.pg-lightbox-prev:focus-visible,
.pg-lightbox-next:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.pg-lightbox-close {
  top: 18px;
  right: 18px;
  font-size: 38px;
}

.pg-lightbox-prev,
.pg-lightbox-next {
  top: 50%;
  transform: translateY(-50%);
  font-size: 70px;
}

.pg-lightbox-prev {
  left: 12px;
}

.pg-lightbox-next {
  right: 12px;
}

.pg-lightbox-counter {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
  letter-spacing: 0.06em;
  z-index: 2;
}

body.pg-lightbox-open {
  overflow: hidden;
}

/* ── Responsive ─────────────────────────────────────────────── */

/* Tablet: collapse to 3 cols, reset explicit positions to auto */
@media (max-width: 1024px) {
  .pg-grid {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: none;
    grid-auto-rows: 190px;
    grid-auto-flow: dense;
  }

  /* Reset all explicit positions — let grid auto-place */
  .pg-item:nth-child(1)  { grid-column: span 2; grid-row: auto; }
  .pg-item:nth-child(2)  { grid-column: auto;   grid-row: auto; }
  .pg-item:nth-child(3)  { grid-column: auto;   grid-row: auto; }
  .pg-item:nth-child(4)  { grid-column: auto;   grid-row: span 2; }
  .pg-item:nth-child(5)  { grid-column: auto;   grid-row: auto; }
  .pg-item:nth-child(6)  { grid-column: auto;   grid-row: span 2; }
  .pg-item:nth-child(7)  { grid-column: span 2; grid-row: span 2; }
  .pg-item:nth-child(8)  { grid-column: auto;   grid-row: auto; }
  .pg-item:nth-child(9)  { grid-column: auto;   grid-row: span 2; }
  .pg-item:nth-child(10) { grid-column: auto;   grid-row: auto; }
  .pg-item:nth-child(11) { grid-column: auto;   grid-row: auto; }
  .pg-item:nth-child(12) { grid-column: auto;   grid-row: auto; }
  .pg-item:nth-child(13) { grid-column: auto;   grid-row: auto; }
}

/* Mobile: 2 cols, all items auto */
@media (max-width: 640px) {
  .pg-grid {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: none;
    grid-auto-rows: 150px;
    grid-auto-flow: dense;
  }

  .pg-item:nth-child(1),
  .pg-item:nth-child(7)  { grid-column: span 2; grid-row: auto; }

  .pg-item:nth-child(2),
  .pg-item:nth-child(3),
  .pg-item:nth-child(4),
  .pg-item:nth-child(5),
  .pg-item:nth-child(6),
  .pg-item:nth-child(8),
  .pg-item:nth-child(9),
  .pg-item:nth-child(10),
  .pg-item:nth-child(11),
  .pg-item:nth-child(12),
  .pg-item:nth-child(13) { grid-column: auto; grid-row: auto; }
}

