/* Editorial image gallery — shared across templates (scope: .editorial-gallery-scope) */
.editorial-gallery-scope {
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-soft: cubic-bezier(0.22, 1, 0.36, 1);
  --radius-lg: 20px;
  --slate-100: #f1f5f9;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --trust-teal: #0d9488;
}

/* Layout: first row = up to 4 tiles; additional images = horizontal scroll carousel */
.editorial-gallery-scope .clinic-gallery--editorial {
  display: flex;
  flex-direction: column;
  gap: clamp(0.85rem, 2.2vw, 1.35rem);
  list-style: none;
  margin: 0;
  padding: 0;
  border-radius: 0;
  background: transparent;
  border: none;
  box-shadow: none;
}

.editorial-gallery-scope .editorial-gallery__row--primary {
  display: grid;
  gap: clamp(0.75rem, 2vw, 1.25rem);
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  width: 100%;
}

/* Primary row column counts (1–4 visible images) */
.editorial-gallery-scope .editorial-gallery__row--primary.editorial-gallery__row--count-1 {
  max-width: min(720px, 100%);
  margin-inline: auto;
}

.editorial-gallery-scope .editorial-gallery__row--primary.editorial-gallery__row--count-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.editorial-gallery-scope .editorial-gallery__row--primary.editorial-gallery__row--count-3 {
  grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 520px) {
  .editorial-gallery-scope .editorial-gallery__row--primary.editorial-gallery__row--count-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.editorial-gallery-scope .editorial-gallery__row--primary.editorial-gallery__row--count-4 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (min-width: 900px) {
  .editorial-gallery-scope .editorial-gallery__row--primary.editorial-gallery__row--count-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.editorial-gallery-scope .clinic-gallery__cell--primary {
  min-height: 0;
}

/* Carousel (2+ images): several equal tiles per view (up to 4), side arrows — editorial-gallery-lightbox.js sets widths */
.editorial-gallery-scope .editorial-carousel {
  position: relative;
  width: 100%;
}

.editorial-gallery-scope .editorial-carousel__viewport {
  overflow: hidden;
  width: 100%;
  min-width: 0;
  border-radius: var(--radius-lg);
  background: var(--slate-100);
  box-shadow: 0 14px 36px -20px rgba(15, 23, 42, 0.2);
}

.editorial-gallery-scope .editorial-carousel__track {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 12px;
  transition: transform 0.45s var(--ease-soft);
  will-change: transform;
  width: auto;
}

@media (prefers-reduced-motion: reduce) {
  .editorial-gallery-scope .editorial-carousel__track {
    transition: none !important;
  }
}

.editorial-gallery-scope .editorial-carousel__slide {
  flex-shrink: 0;
  min-width: 0;
  box-sizing: border-box;
}

/* Each tile keeps a fixed aspect ratio; image fills the tile (no full-viewport stretch). */
.editorial-gallery-scope .clinic-gallery--carousel .editorial-carousel__slide .clinic-gallery__frame {
  aspect-ratio: 4 / 3;
  width: 100%;
  height: auto;
  max-height: min(220px, 28vw);
}

@media (min-width: 900px) {
  .editorial-gallery-scope .clinic-gallery--carousel .editorial-carousel__slide .clinic-gallery__frame {
    max-height: min(260px, 24vw);
  }
}

.editorial-gallery-scope .editorial-carousel__btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: rgba(255, 255, 255, 0.94);
  color: #0f172a;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.25s ease,
    border-color 0.25s ease,
    transform 0.2s ease,
    box-shadow 0.25s ease;
  box-shadow: 0 10px 28px -18px rgba(15, 23, 42, 0.35);
  -webkit-tap-highlight-color: transparent;
}

.editorial-gallery-scope .editorial-carousel__btn:hover {
  border-color: rgba(13, 148, 136, 0.4);
  box-shadow: 0 14px 34px -16px rgba(15, 23, 42, 0.4);
}

.editorial-gallery-scope .editorial-carousel__btn:focus-visible {
  outline: 2px solid var(--trust-teal);
  outline-offset: 3px;
}

.editorial-gallery-scope .editorial-carousel__btn--prev {
  left: clamp(8px, 2vw, 16px);
}

.editorial-gallery-scope .editorial-carousel__btn--next {
  right: clamp(8px, 2vw, 16px);
}

.editorial-gallery-scope .clinic-gallery--carousel:focus-visible {
  outline: 2px solid var(--trust-teal);
  outline-offset: 4px;
  border-radius: 12px;
}

/* Legacy: paginate (4 per page) — kept for older generated pages */
.editorial-gallery-scope .editorial-gallery__paged-viewport {
  overflow: hidden;
  width: 100%;
  min-width: 0;
  border-radius: var(--radius-lg);
}

.editorial-gallery-scope .editorial-gallery__paged-track {
  display: flex;
  will-change: transform;
}

.editorial-gallery-scope .editorial-gallery__page {
  flex-shrink: 0;
  min-width: 0;
  box-sizing: border-box;
  padding: 0 1px;
}

.editorial-gallery-scope .editorial-gallery__toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: clamp(0.75rem, 2vw, 1.1rem);
  flex-wrap: wrap;
}

.editorial-gallery-scope .editorial-gallery__pager {
  font-size: 0.9rem;
  font-weight: 600;
  color: rgba(15, 23, 42, 0.55);
  min-width: 4rem;
  text-align: center;
}

.editorial-gallery-scope .editorial-gallery__btn {
  margin: 0;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.14);
  background: rgba(255, 255, 255, 0.92);
  color: #0f172a;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.25s ease,
    border-color 0.25s ease,
    transform 0.2s ease;
  box-shadow: 0 10px 28px -18px rgba(15, 23, 42, 0.35);
}

.editorial-gallery-scope .editorial-gallery__btn:hover:not(:disabled) {
  border-color: rgba(13, 148, 136, 0.45);
  transform: translateY(-1px);
}

.editorial-gallery-scope .editorial-gallery__btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.editorial-gallery-scope .editorial-gallery--paged:focus-visible {
  outline: 2px solid var(--trust-teal);
  outline-offset: 4px;
  border-radius: 12px;
}

.editorial-gallery-scope .clinic-gallery__frame {
  position: relative;
  width: 100%;
  height: auto;
  min-height: 0;
  aspect-ratio: 4 / 3;
  border-radius: 0;
  overflow: hidden;
  background: var(--slate-100);
  box-shadow: none;
  isolation: isolate;
}

/* One rounded surface + one shadow per photo (the link is `.clinic-gallery__cell`). */
.editorial-gallery-scope .clinic-gallery__cell {
  display: block;
  text-decoration: none;
  color: inherit;
  cursor: zoom-in;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  z-index: 0;
  min-height: 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  transform: translateZ(0);
  box-shadow: 0 14px 36px -20px rgba(15, 23, 42, 0.2);
  transition:
    opacity 0.75s var(--ease-out-expo),
    filter 0.75s var(--ease-out-expo),
    transform 0.75s var(--ease-out-expo),
    box-shadow 0.75s var(--ease-out-expo);
}

.editorial-gallery-scope .clinic-gallery__cell img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 38%;
  transform: scale(1.001);
  transform-origin: center center;
  transition:
    transform 0.78s var(--ease-out-expo),
    filter 0.78s var(--ease-out-expo);
}

.editorial-gallery-scope .clinic-gallery__veil {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    165deg,
    rgba(15, 23, 42, 0.06) 0%,
    transparent 38%,
    transparent 52%,
    rgba(15, 23, 42, 0.38) 100%
  );
  opacity: 0.62;
  transition: opacity 0.7s var(--ease-out-expo);
}

/* Thumbnail captions removed — use img alt + link aria-label only */
.editorial-gallery-scope .clinic-gallery__label {
  display: none !important;
}

@media (min-width: 1024px) {
  .editorial-gallery-scope .clinic-gallery__cell--primary .clinic-gallery__frame {
    max-height: 280px;
  }
}

html.clinic-motion .editorial-gallery-scope #gallery:not(.is-inview) .clinic-gallery__cell {
  opacity: 0;
  transform: translateY(22px);
}

html.clinic-motion .editorial-gallery-scope #gallery.is-inview .clinic-gallery__cell {
  opacity: 1;
  transform: translateY(0);
  transition:
    opacity 0.75s var(--ease-out-expo),
    transform 0.75s var(--ease-out-expo),
    filter 0.55s var(--ease-soft),
    box-shadow 0.75s var(--ease-out-expo);
}

html.clinic-motion .editorial-gallery-scope #gallery.is-inview .editorial-gallery__page .clinic-gallery__cell:nth-child(1) {
  transition-delay: 0.06s;
}
html.clinic-motion .editorial-gallery-scope #gallery.is-inview .editorial-gallery__page .clinic-gallery__cell:nth-child(2) {
  transition-delay: 0.12s;
}
html.clinic-motion .editorial-gallery-scope #gallery.is-inview .editorial-gallery__page .clinic-gallery__cell:nth-child(3) {
  transition-delay: 0.18s;
}
html.clinic-motion .editorial-gallery-scope #gallery.is-inview .editorial-gallery__page .clinic-gallery__cell:nth-child(4) {
  transition-delay: 0.24s;
}
html.clinic-motion .editorial-gallery-scope #gallery.is-inview .editorial-gallery__row--primary .clinic-gallery__cell:nth-child(1) {
  transition-delay: 0.06s;
}
html.clinic-motion .editorial-gallery-scope #gallery.is-inview .editorial-gallery__row--primary .clinic-gallery__cell:nth-child(2) {
  transition-delay: 0.12s;
}
html.clinic-motion .editorial-gallery-scope #gallery.is-inview .editorial-gallery__row--primary .clinic-gallery__cell:nth-child(3) {
  transition-delay: 0.18s;
}
html.clinic-motion .editorial-gallery-scope #gallery.is-inview .editorial-gallery__row--primary .clinic-gallery__cell:nth-child(4) {
  transition-delay: 0.24s;
}

.editorial-gallery-scope .clinic-gallery__cell:focus {
  outline: none;
}

.editorial-gallery-scope .clinic-gallery__cell:focus-visible {
  outline: 2px solid var(--trust-teal);
  outline-offset: 3px;
}

@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  .editorial-gallery-scope .clinic-gallery--editorial:has(.clinic-gallery__cell:hover)
    .clinic-gallery__cell:not(.clinic-gallery__cell--carousel-clone):not(:hover),
  .editorial-gallery-scope .clinic-gallery--editorial:has(.clinic-gallery__cell:focus-within)
    .clinic-gallery__cell:not(.clinic-gallery__cell--carousel-clone):not(:focus-within) {
    opacity: 0.38;
    transform: scale(0.988);
    box-shadow: 0 8px 22px -16px rgba(15, 23, 42, 0.14);
  }

  .editorial-gallery-scope .clinic-gallery--editorial:has(.clinic-gallery__cell:hover)
    .clinic-gallery__cell:not(.clinic-gallery__cell--carousel-clone):not(:hover)
    img,
  .editorial-gallery-scope .clinic-gallery--editorial:has(.clinic-gallery__cell:focus-within)
    .clinic-gallery__cell:not(.clinic-gallery__cell--carousel-clone):not(:focus-within)
    img {
    filter: blur(4px) saturate(0.78) brightness(0.9);
    transform: scale(1);
  }

  .editorial-gallery-scope .clinic-gallery--editorial:has(.clinic-gallery__cell:hover)
    .clinic-gallery__cell:not(.clinic-gallery__cell--carousel-clone):not(:hover)
    .clinic-gallery__veil,
  .editorial-gallery-scope .clinic-gallery--editorial:has(.clinic-gallery__cell:focus-within)
    .clinic-gallery__cell:not(.clinic-gallery__cell--carousel-clone):not(:focus-within)
    .clinic-gallery__veil {
    opacity: 0.82;
  }

  .editorial-gallery-scope .clinic-gallery--editorial .clinic-gallery__cell:not(.clinic-gallery__cell--carousel-clone):hover,
  .editorial-gallery-scope .clinic-gallery--editorial .clinic-gallery__cell:not(.clinic-gallery__cell--carousel-clone):focus-within {
    z-index: 3;
    transform: translateY(-4px);
    box-shadow: 0 28px 56px -22px rgba(15, 23, 42, 0.28);
  }

  .editorial-gallery-scope .clinic-gallery--editorial .clinic-gallery__cell:not(.clinic-gallery__cell--carousel-clone):hover img,
  .editorial-gallery-scope .clinic-gallery--editorial .clinic-gallery__cell:not(.clinic-gallery__cell--carousel-clone):focus-within img {
    filter: blur(0) saturate(1.07) contrast(1.04) brightness(1.02);
    transform: scale(1.035);
  }

  .editorial-gallery-scope .clinic-gallery--editorial .clinic-gallery__cell:not(.clinic-gallery__cell--carousel-clone):hover .clinic-gallery__veil,
  .editorial-gallery-scope .clinic-gallery--editorial .clinic-gallery__cell:not(.clinic-gallery__cell--carousel-clone):focus-within .clinic-gallery__veil {
    opacity: 0.28;
  }
}

@media (prefers-reduced-motion: reduce) {
  .editorial-gallery-scope .clinic-gallery--editorial .clinic-gallery__cell,
  .editorial-gallery-scope .clinic-gallery--editorial .clinic-gallery__cell img,
  .editorial-gallery-scope .clinic-gallery--editorial .clinic-gallery__frame,
  .editorial-gallery-scope .clinic-gallery--editorial .clinic-gallery__veil {
    transition: none !important;
    animation: none !important;
  }

  html.clinic-motion .editorial-gallery-scope #gallery:not(.is-inview) .clinic-gallery__cell {
    opacity: 1;
    transform: none;
  }

  html.clinic-motion .editorial-gallery-scope #gallery.is-inview .clinic-gallery__cell {
    transition-delay: 0s !important;
  }
}

.editorial-gallery-scope .clinic-gallery__cell.is-broken .clinic-gallery__frame {
  min-height: 12rem;
}

.editorial-gallery-scope .clinic-gallery__cell.is-broken img {
  display: none;
}

/* Full-screen lightbox (editorial-gallery-lightbox.js) */
.eg-lightbox {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: min(4vw, 1.5rem);
  background: rgba(0, 0, 0, 0.9);
  box-sizing: border-box;
}

.eg-lightbox[hidden] {
  display: none !important;
}

.eg-lightbox__img {
  position: relative;
  z-index: 1;
  max-width: 90vw;
  max-height: 80vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 14px;
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.55);
}

.eg-lightbox--anim .eg-lightbox__img {
  animation: eg-lb-in 0.38s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes eg-lb-in {
  from {
    opacity: 0;
    transform: scale(0.94);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .eg-lightbox--anim .eg-lightbox__img {
    animation: none !important;
  }
}

.eg-lightbox__close,
.eg-lightbox__prev,
.eg-lightbox__next {
  position: absolute;
  z-index: 2;
  margin: 0;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(20, 20, 20, 0.75);
  color: #fff;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.25s ease,
    transform 0.2s ease,
    border-color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.eg-lightbox__close {
  top: min(1.25rem, 4vw);
  right: min(1.25rem, 4vw);
  width: 48px;
  height: 48px;
  font-size: 1.65rem;
  line-height: 1;
  font-weight: 300;
}

.eg-lightbox__prev,
.eg-lightbox__next {
  top: 50%;
  transform: translateY(-50%);
  width: 52px;
  height: 52px;
  font-size: 1.75rem;
  line-height: 1;
  font-weight: 400;
}

.eg-lightbox__prev {
  left: min(1rem, 3vw);
}

.eg-lightbox__next {
  right: min(1rem, 3vw);
}

.eg-lightbox__close:hover,
.eg-lightbox__prev:hover,
.eg-lightbox__next:hover {
  background: rgba(40, 40, 40, 0.92);
  border-color: rgba(255, 255, 255, 0.28);
}

.eg-lightbox__close:focus-visible,
.eg-lightbox__prev:focus-visible,
.eg-lightbox__next:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.85);
  outline-offset: 3px;
}

.eg-lightbox__prev:hover,
.eg-lightbox__next:hover {
  transform: translateY(-50%) scale(1.05);
}

.eg-lightbox__prev[hidden],
.eg-lightbox__next[hidden] {
  display: none !important;
}

