.phd-gallery {
  --phd-navy: #11283f;
  --phd-blue: #0d7491;
  --phd-cyan: #17a9c0;
  --phd-text: #263b4d;
  --phd-radius: 18px;
  width: 100%;
  color: var(--phd-text);
}

.phd-gallery *,
.phd-gallery-lightbox * { box-sizing: border-box; }

.phd-gallery__grid {
  display: grid;
  grid-template-columns: repeat(var(--phd-gallery-columns, 4), minmax(0, 1fr));
  gap: 20px;
}

.phd-gallery__item {
  appearance: none;
  display: block;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(17, 40, 63, .1);
  border-radius: var(--phd-radius);
  background: #fff;
  color: var(--phd-text);
  font: inherit;
  text-align: left;
  cursor: zoom-in;
  box-shadow: 0 10px 30px rgba(17, 40, 63, .08);
  transition: transform .35s cubic-bezier(.2,.75,.25,1), box-shadow .35s ease, border-color .35s ease;
  animation: phd-gallery-in .55s both;
}

.phd-gallery__item:nth-child(4n+2) { animation-delay: .06s; }
.phd-gallery__item:nth-child(4n+3) { animation-delay: .12s; }
.phd-gallery__item:nth-child(4n+4) { animation-delay: .18s; }

.phd-gallery__item:hover {
  transform: translateY(-6px);
  border-color: rgba(23, 169, 192, .42);
  box-shadow: 0 18px 44px rgba(17, 40, 63, .15);
}

.phd-gallery__item:focus-visible {
  outline: 3px solid rgba(23, 169, 192, .4);
  outline-offset: 4px;
}

.phd-gallery__image-wrap {
  position: relative;
  display: block;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: #edf4f6;
}

.phd-gallery__image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .65s cubic-bezier(.2,.75,.25,1), filter .35s ease;
}

.phd-gallery__item:hover .phd-gallery__image {
  transform: scale(1.06);
  filter: saturate(1.05);
}

.phd-gallery__zoom {
  position: absolute;
  right: 14px;
  bottom: 14px;
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 50%;
  background: rgba(255,255,255,.94);
  color: var(--phd-navy);
  box-shadow: 0 8px 24px rgba(17,40,63,.2);
  transform: translateY(6px) scale(.94);
  transition: transform .3s ease, background .3s ease, color .3s ease;
}

.phd-gallery__zoom svg { fill: currentColor; }
.phd-gallery__item:hover .phd-gallery__zoom { transform: translateY(0) scale(1); background: var(--phd-cyan); color: #fff; }

.phd-gallery__caption {
  display: block;
  padding: 15px 17px 17px;
  font-size: 15px;
  font-weight: 650;
  line-height: 1.4;
}

.phd-gallery-lightbox {
  --phd-cyan: #17a9c0;
  position: fixed;
  z-index: 999999;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 30px 72px;
  visibility: hidden;
  background: rgba(6, 19, 31, .92);
  backdrop-filter: blur(10px);
  opacity: 0;
  transition: opacity .25s ease, visibility .25s ease;
}

.phd-gallery-lightbox.is-open { visibility: visible; opacity: 1; }
.phd-gallery-lightbox__figure { max-width: min(1180px, 100%); margin: 0; text-align: center; }
.phd-gallery-lightbox__image {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 130px);
  margin: auto;
  border-radius: 14px;
  box-shadow: 0 25px 80px rgba(0,0,0,.45);
  transform: scale(.96);
  transition: transform .3s cubic-bezier(.2,.75,.25,1);
}
.phd-gallery-lightbox.is-open .phd-gallery-lightbox__image { transform: scale(1); }
.phd-gallery-lightbox__caption { min-height: 24px; margin-top: 14px; color: #fff; font: 500 15px/1.5 system-ui, sans-serif; }
.phd-gallery-lightbox__count { position: absolute; top: 22px; left: 24px; color: rgba(255,255,255,.8); font: 600 14px/1 system-ui, sans-serif; }
.phd-gallery-lightbox__button {
  appearance: none;
  position: absolute;
  display: grid;
  width: 48px;
  height: 48px;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 50%;
  background: rgba(255,255,255,.1);
  color: #fff;
  cursor: pointer;
  transition: background .25s ease, transform .25s ease;
}
.phd-gallery-lightbox__button:hover { background: var(--phd-cyan); transform: scale(1.06); }
.phd-gallery-lightbox__button:focus-visible { outline: 3px solid rgba(23,169,192,.6); outline-offset: 3px; }
.phd-gallery-lightbox__button svg { width: 25px; height: 25px; fill: currentColor; }
.phd-gallery-lightbox__close { top: 20px; right: 22px; }
.phd-gallery-lightbox__prev { left: 18px; top: 50%; transform: translateY(-50%); }
.phd-gallery-lightbox__next { right: 18px; top: 50%; transform: translateY(-50%); }
.phd-gallery-lightbox__prev:hover,
.phd-gallery-lightbox__next:hover { transform: translateY(-50%) scale(1.06); }
body.phd-gallery-lock { overflow: hidden; }

@keyframes phd-gallery-in {
  from { opacity: .01; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 980px) {
  .phd-gallery__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .phd-gallery__grid { grid-template-columns: 1fr; gap: 14px; }
  .phd-gallery-lightbox { padding: 66px 12px 86px; }
  .phd-gallery-lightbox__image { max-height: calc(100vh - 170px); }
  .phd-gallery-lightbox__prev,
  .phd-gallery-lightbox__next { top: auto; bottom: 20px; transform: none; }
  .phd-gallery-lightbox__prev { left: calc(50% - 58px); }
  .phd-gallery-lightbox__next { right: calc(50% - 58px); }
  .phd-gallery-lightbox__prev:hover,
  .phd-gallery-lightbox__next:hover { transform: scale(1.06); }
}

@media (prefers-reduced-motion: reduce) {
  .phd-gallery__item,
  .phd-gallery__image,
  .phd-gallery__zoom,
  .phd-gallery-lightbox,
  .phd-gallery-lightbox__image { animation: none; transition: none; }
}
