/*
 * Apartment photos (MPA-3): the page strip and the full-screen viewer.
 * The viewer is ported from Atlantic Prestige's Gallery.astro (one gallery, no tabs,
 * no captions). Plain CSS on purpose: the theme's gulp build has not run since 2017.
 */
.mp-gal { --mp-yellow: #F3BB00; --mp-radius: .25rem; }

/*
 * On the page: one photo at 16:10 that swipes through the set (touch and trackpad
 * natively, a mouse by dragging, arrows on hover), the thumbnails under it. A tap
 * opens the viewer on that photo.
 */
.mp-gal__stage { position: relative; }
.mp-gal__frame {
  display: flex; overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x mandatory;
  scrollbar-width: none; aspect-ratio: 16 / 10; background: #2C2C2C;
}
.mp-gal__frame::-webkit-scrollbar { display: none; }
.mp-gal__slide { flex: 0 0 100%; scroll-snap-align: center; scroll-snap-stop: always; display: block; }
.mp-gal__slide img { display: block; width: 100%; height: 100%; max-width: none; object-fit: cover; -webkit-user-drag: none; }
/* Portrait photos (bathrooms, kitchenettes) are shown whole on the dark frame, not cropped to a band. */
.mp-gal__slide.is-tall img { object-fit: contain; }
@media (pointer: fine) {
  .mp-gal__frame { cursor: grab; user-select: none; -webkit-user-select: none; }
  .mp-gal__frame[data-dragging] { cursor: grabbing; }
  .mp-gal__frame[data-dragging] a { pointer-events: none; }
}
.mp-gal__count {
  position: absolute; right: 12px; bottom: 12px; padding: 4px 10px; border-radius: var(--mp-radius);
  background: rgba(44, 44, 44, .8); color: #fff; font-size: 12px; font-weight: 600; letter-spacing: .04em; pointer-events: none;
}
/* The page arrows: the theme's buttons (square, 4px corners, yellow on hover), shown on hover. */
.ap-gal__arrow.mp-gal__arrow {
  width: 44px; height: 44px; margin-top: -22px; border: 0; background: rgba(255, 255, 255, .92); color: #2C2C2C;
  opacity: 0; transition: opacity .2s, background-color .2s;
}
.mp-gal__arrow[data-dir='prev'] { left: 12px; }
.mp-gal__arrow[data-dir='next'] { right: 12px; }
.mp-gal__stage:hover .mp-gal__arrow, .mp-gal__arrow:focus-visible { opacity: 1; }
.ap-gal__arrow.mp-gal__arrow:hover, .ap-gal__arrow.mp-gal__arrow:focus-visible { background: var(--mp-yellow); color: #000; }
@media (hover: none) { .mp-gal__arrow { display: none !important; } }

/* Up to 7 thumbnails share the width (--n is the count, set by the template). */
.mp-gal__thumbs { position: relative; margin-top: 10px; }
.mp-gal__strip { display: grid; grid-template-columns: repeat(var(--n, 7), 1fr); gap: 10px; }
/* More than 7: one row at a seventh of the width each, scrolled by the arrows (or a swipe). */
.mp-gal__thumbs.is-scroll .mp-gal__strip {
  display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; scroll-behavior: smooth;
}
.mp-gal__thumbs.is-scroll .mp-gal__strip::-webkit-scrollbar { display: none; }
.mp-gal__thumbs.is-scroll .mp-gal__thumb { flex: 0 0 calc((100% - 60px) / 7); scroll-snap-align: start; }
.mp-gal__tarrow {
  position: absolute; top: 50%; z-index: 1; width: 32px; height: 32px; margin-top: -16px; padding: 0;
  display: flex; align-items: center; justify-content: center; border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, .95); color: #2C2C2C; box-shadow: 0 0 10px rgba(153, 153, 153, .34); cursor: pointer;
  transition: opacity .2s, background-color .2s;
}
.mp-gal__tarrow svg { width: 16px; height: 16px; }
.mp-gal__tarrow[data-tscroll="-1"] { left: 6px; }
.mp-gal__tarrow[data-tscroll="1"] { right: 6px; }
.mp-gal__tarrow:hover { background: #F3BB00; color: #000; }
.mp-gal__tarrow:disabled { opacity: 0; pointer-events: none; }
.mp-gal__thumb { display: block; padding: 0; border: 0; background: none; cursor: pointer; opacity: .6; transition: opacity .2s; position: relative; }
.mp-gal__thumb img { display: block; width: 100%; height: auto; aspect-ratio: 3 / 2; object-fit: cover; }
.mp-gal__thumb:hover, .mp-gal__thumb:focus-visible { opacity: 1; }
.mp-gal__thumb[aria-current] { opacity: 1; }
.mp-gal__thumb[aria-current]::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--mp-yellow); }

/* Phone: the photo runs edge to edge (the column has 15px gutters), thumbnails scroll in a row. */
@media (max-width: 767px) {
  .apartment-gallery .mp-gal__stage { margin: 0 -15px; } /* the apartment column has 15px gutters; facilities have none */
  .mp-gal__frame { aspect-ratio: 4 / 3; }
  .mp-gal__thumbs { margin-top: 6px; }
  .mp-gal__strip, .mp-gal__thumbs.is-scroll .mp-gal__strip { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity; }
  .mp-gal__thumbs.is-scroll .mp-gal__thumb { flex: 0 0 72px; }
  .mp-gal__tarrow { display: none; }
  .mp-gal__strip::-webkit-scrollbar { display: none; }
  .mp-gal__thumb { flex: 0 0 72px; scroll-snap-align: start; }
}

/* The viewer. */
.ap-gal { --ink: #111; --white-rgb: 255, 255, 255; position: fixed; inset: 0; z-index: 2000; background: var(--ink); color: #fff; overflow: hidden; }
.ap-gal[hidden] { display: none; }
.ap-gal__top { height: 80px; padding: 0 40px; display: flex; align-items: center; justify-content: space-between; }
.ap-gal__title { display: flex; align-items: baseline; gap: 16px; }
.ap-gal__title strong { font-weight: 600; font-size: 22px; text-transform: uppercase; letter-spacing: .02em; }
.ap-gal__count { font-size: 14px; color: rgba(var(--white-rgb), .7); }
.ap-gal__tools { display: flex; gap: 10px; }
.ap-gal__btn {
  display: inline-flex; align-items: center; justify-content: center; height: 44px; cursor: pointer;
  border: 0; border-radius: .25rem; background: rgba(var(--white-rgb), .12); color: #fff; padding: 0;
  transition: background-color .2s, color .2s;
}
.ap-gal__close { width: 44px; }
.ap-gal__btn:hover, .ap-gal__btn:focus-visible { background: #F3BB00; color: #000; }
.ap-gal__stage { position: relative; height: 620px; display: flex; justify-content: center; }
.ap-gal__frame {
  height: 100%; width: 930px; display: flex; overflow-x: auto; overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory; scrollbar-width: none;
}
.ap-gal__frame::-webkit-scrollbar { display: none; }
@media (pointer: fine) {
  .ap-gal__frame { cursor: grab; user-select: none; -webkit-user-select: none; }
  .ap-gal__frame[data-dragging] { cursor: grabbing; }
}
.ap-gal__frame .ap-gal__img { flex: 0 0 100%; width: 100%; height: 100%; max-width: none; object-fit: cover; display: block; scroll-snap-align: center; scroll-snap-stop: always; }
.ap-gal__arrow {
  width: 52px; height: 52px; display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0;
  border: 0; border-radius: .25rem; background: rgba(var(--white-rgb), .12); color: #fff;
  position: absolute; transition: background-color .2s, color .2s; top: 50%; margin-top: -26px;
}
.ap-gal__arrow[data-dir='prev'] { left: 40px; }
.ap-gal__arrow[data-dir='next'] { right: 40px; }
.ap-gal__arrow:hover, .ap-gal__arrow:focus-visible { background: #F3BB00; color: #000; }
.ap-gal__thumbs { display: flex; justify-content: safe center; gap: 8px; margin: 16px auto 0; max-width: 930px; overflow-x: auto; scrollbar-width: none; padding: 2px; }
.ap-gal__thumb { flex: none; padding: 0; border: 0; background: none; cursor: pointer; opacity: .5; }
.ap-gal__thumb[aria-current] { opacity: 1; outline: 2px solid #F3BB00; }
.ap-gal__thumb img { width: 96px; height: 64px; object-fit: cover; display: block; }
.ap-gal__bar {
  position: absolute; left: 0; right: 0; bottom: 0; height: 72px; padding: 0 40px;
  display: flex; align-items: center; justify-content: flex-end;
  border-top: 1px solid rgba(var(--white-rgb), .14);
}
/* The booking link is the theme's .btn.btn-secondary (white, yellow on hover); only its size here. */
.ap-gal__act.btn { display: inline-flex; align-items: center; justify-content: center; min-width: 220px; height: 48px; padding: 0 30px; }
.ap-gal__act.btn:hover, .ap-gal__act.btn:focus { text-decoration: none; color: #000; }

/*
 * Desktop: the photo takes the height the screen has, at 3:2, and photo and
 * thumbnails sit as one block between the title row and the bar. --gal-chrome is
 * everything that is not the photo: top 80, thumbnails 84, bar 72, breathing 48.
 * The width keeps room for the arrows (2 x 116).
 */
@media (min-width: 1024px) {
  .ap-gal {
    --gal-chrome: 284px;
    --gal-h: max(240px, min(calc(100dvh - var(--gal-chrome)), calc((100vw - 232px) / 1.5)));
    display: flex; flex-direction: column; padding-bottom: 72px;
  }
  .ap-gal[hidden] { display: none; } /* display: flex would show a closed dialog */
  .ap-gal > * { flex: none; }
  .ap-gal__stage { height: var(--gal-h); margin-top: auto; }
  .ap-gal__frame { width: calc(var(--gal-h) * 1.5); }
  .ap-gal__thumbs { width: calc(var(--gal-h) * 1.5); max-width: none; margin-bottom: auto; }
}

/*
 * Phone and tablet: swipe; the photo is shown whole (no crop) in the height the screen
 * has, with a thumbnail row under it and the booking button across the bottom.
 */
@media (max-width: 1023px) {
  .ap-gal { display: flex; flex-direction: column; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  .ap-gal[hidden] { display: none; }
  .ap-gal > * { flex: none; }
  .ap-gal__top { height: 60px; padding: 0 12px 0 16px; }
  .ap-gal__title { min-width: 0; gap: 10px; }
  .ap-gal__title strong { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .ap-gal__count { flex: none; }
  .ap-gal__stage { flex: 1 1 auto; height: auto; min-height: 0; }
  .ap-gal__frame { width: 100%; }
  .ap-gal__frame .ap-gal__img { object-fit: contain; }
  .ap-gal__arrow { display: none; }
  .ap-gal__thumbs { width: 100%; max-width: none; margin: 10px 0 12px; padding: 2px 12px; justify-content: flex-start; gap: 6px; }
  .ap-gal__thumb img { width: 64px; height: 44px; }
  .ap-gal__bar { height: auto; padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); }
  .ap-gal__act.btn { flex: 1; min-width: 0; }
}

/* A phone on its side: no room for thumbnails; the photo gets the height. */
@media (max-width: 1023px) and (max-height: 520px) {
  .ap-gal { padding-bottom: 0; }
  .ap-gal__top { height: 48px; }
  .ap-gal__thumbs { display: none; }
  .ap-gal__bar { position: absolute; top: 0; bottom: auto; right: 64px; left: auto; height: 48px; padding: 0; border: 0; }
  .ap-gal__act.btn { height: 36px; min-width: 0; padding: 0 16px; font-size: 12px; }
}

/* Facilities (template-facilities.php): the photo keeps the old slider's 2:1 beside its description card. */
.facility-section .mp-gal__frame { aspect-ratio: 2 / 1; }
