/*
 * Gallery (revamped 2026-10-06)
 * Used by: gallery.php (mosaic grid) and index.php (carousel).
 * All classes are prefixed "cwg-" so nothing else on those pages is affected.
 * Behaviour lives in assets/js/gallery.js, photos in gallery-data.php.
 */

/* ---------- Section, blobs and doodles ---------- */
.cwg-section {
  position: relative;
  overflow: hidden;
}

.cwg-section > .container,
.cwg-section > .cwg-carousel {
  position: relative;
  z-index: 2;
}

.cwg-section--home {
  padding-bottom: 90px;
}

.cwg-blob {
  position: absolute;
  bottom: -120px;
  width: 520px;
  height: 300px;
  border-radius: 50%;
  z-index: 0;
  pointer-events: none;
}

.cwg-blob--left {
  left: -160px;
  background: rgba(255, 214, 120, 0.28);
}

.cwg-blob--right {
  right: -160px;
  background: rgba(62, 124, 89, 0.14);
}

.cwg-doodle {
  position: absolute;
  z-index: 1;
  pointer-events: none;
}

.cwg-doodle svg {
  display: block;
  width: 100%;
  height: auto;
}

.cwg-doodle--sun { top: 40px; left: 7%; width: 110px; }
.cwg-doodle--heart { top: 120px; right: 9%; width: 84px; }
.cwg-doodle--plane { bottom: 40px; left: 4%; width: 210px; }
.cwg-doodle--star { bottom: 40px; right: 5%; width: 170px; }

@media (max-width: 1199px) {
  .cwg-doodle--sun { width: 80px; left: 3%; }
  .cwg-doodle--heart { width: 64px; right: 3%; }
}

@media (max-width: 991px) {
  .cwg-doodle { display: none; }
  .cwg-blob { width: 320px; height: 200px; bottom: -90px; }
}

/* ---------- Heading ---------- */
.cwg-head {
  text-align: center;
  max-width: 680px;
  margin: 0 auto 30px;
}

.cwg-head__sub {
  display: inline-block;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--vs-title-color);
  position: relative;
  padding-bottom: 14px;
  margin-bottom: 12px;
}

.cwg-head__sub::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 44px;
  height: 3px;
  border-radius: 3px;
  transform: translateX(-50%);
  background: #F2B544;
}

.cwg-head__title {
  font-size: 52px;
  line-height: 1.1;
  margin: 0 0 14px;
  color: var(--vs-title-color);
}

.cwg-head__title span {
  color: var(--vs-theme-color2);
}

.cwg-head__text {
  font-size: 17px;
  line-height: 1.6;
  margin: 0;
}

@media (max-width: 767px) {
  .cwg-head__sub { font-size: 12px; }
  .cwg-head__title { font-size: 34px; }
  .cwg-head__text { font-size: 15px; }
}

/* ---------- Category tabs ---------- */
.cwg-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin: 0 auto 36px;
}

.cwg-tab {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  border: 0;
  border-radius: 40px;
  padding: 11px 22px;
  background: var(--vs-white-color);
  color: var(--vs-title-color);
  font-weight: 600;
  font-size: 15px;
  box-shadow: 0 6px 18px rgba(37, 40, 62, 0.08);
  transition: background-color 0.25s, color 0.25s, transform 0.25s;
  white-space: nowrap;
}

.cwg-tab:hover { transform: translateY(-2px); }
.cwg-tab i { font-size: 16px; color: var(--vs-theme-color2); transition: color 0.25s; }
.cwg-tab--classroom i { color: #F28C28; }
.cwg-tab--activities i { color: #3E7C59; }
.cwg-tab--events i { color: #E5566B; }
.cwg-tab--arts i { color: #8E5BC9; }
.cwg-tab--outdoor i { color: #2F9E5B; }

.cwg-tab.is-active {
  background: var(--vs-theme-color2);
  color: var(--vs-white-color);
}

.cwg-tab.is-active i { color: var(--vs-white-color); }

@media (max-width: 767px) {
  /* one swipeable row on phones */
  .cwg-tabs {
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    padding: 4px 4px 12px;
    margin-bottom: 24px;
    scrollbar-width: none;
  }
  .cwg-tabs::-webkit-scrollbar { display: none; }
  .cwg-tab { padding: 9px 16px; font-size: 14px; }
}

/* ---------- Gallery page: mosaic grid ---------- */
.cwg-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: 210px;
  grid-auto-flow: dense;
  gap: 14px;
}

.cwg-item {
  position: relative;
  display: block;
  border-radius: 18px;
  overflow: hidden;
  background: #e9e3d3;
  box-shadow: 0 8px 22px rgba(37, 40, 62, 0.08);
  cursor: zoom-in;
}

.cwg-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 30%; /* keep faces (usually in the upper part) in view when cropping */
  transition: transform 0.5s ease;
}

.cwg-item:hover img { transform: scale(1.06); }

/* mosaic sizes (assigned by gallery.js based on position) */
.cwg-item--wide { grid-column: span 2; }
.cwg-item--tall { grid-row: span 2; }
.cwg-item--full { grid-column: 1 / -1; }

.cwg-item__zoom {
  position: absolute;
  right: 14px;
  bottom: 14px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.92);
  color: var(--vs-title-color);
  font-size: 17px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.3s, transform 0.3s;
}

.cwg-item:hover .cwg-item__zoom,
.cwg-item:focus-visible .cwg-item__zoom {
  opacity: 1;
  transform: translateY(0);
}

.cwg-item.is-hidden { display: none; }
.cwg-item.is-entering { animation: cwgFadeIn 0.45s ease both; }

@keyframes cwgFadeIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

@media (max-width: 991px) {
  .cwg-grid { grid-template-columns: repeat(3, 1fr); grid-auto-rows: 180px; }
}

@media (max-width: 767px) {
  .cwg-grid { grid-template-columns: repeat(2, 1fr); grid-auto-rows: 150px; gap: 10px; }
  .cwg-item { border-radius: 14px; }
  .cwg-item__zoom { opacity: 1; transform: none; width: 36px; height: 36px; font-size: 14px; right: 10px; bottom: 10px; }
}

/* "Load More" / "View Full Gallery" button row */
.cwg-more {
  text-align: center;
  margin-top: 40px;
}

.cwg-more.is-done { display: none; }

/* ---------- Home page: carousel ---------- */
.cwg-carousel {
  position: relative;
}

.cwg-main {
  padding: 10px 0 20px;
}

/* ".cwg-main.swiper" makes these win over Swiper's own generic slide rules
   (.swiper-backface-hidden / .swiper-ios / .swiper-android .swiper-slide { transform: ... }),
   which otherwise cancel the side-photo shrink in small categories and on phones. */
.cwg-main.swiper .cwg-slide {
  width: 560px;
  transition: transform 0.4s ease, opacity 0.4s ease;
  transform: scale(0.84);
  opacity: 0.85;
}

.cwg-main.swiper .cwg-slide.swiper-slide-active {
  transform: scale(1);
  opacity: 1;
}

.cwg-slide__link {
  display: block;
  aspect-ratio: 4 / 3;
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 14px 34px rgba(37, 40, 62, 0.14);
  cursor: zoom-in;
}

.cwg-slide__link img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cwg-nav,
.cwg-thumbs-nav {
  border: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--vs-white-color);
  color: var(--vs-title-color);
  box-shadow: 0 6px 18px rgba(37, 40, 62, 0.15);
  transition: background-color 0.25s, color 0.25s;
}

.cwg-nav:hover,
.cwg-thumbs-nav:hover {
  background: var(--vs-theme-color2);
  color: var(--vs-white-color);
}

.cwg-nav {
  position: absolute;
  top: 46%;
  z-index: 5;
  width: 54px;
  height: 54px;
  font-size: 18px;
  transform: translateY(-50%);
}

.cwg-nav--prev { left: calc(50% - 400px); }
.cwg-nav--next { right: calc(50% - 400px); }

.cwg-thumbs-wrap {
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: 1100px;
  margin: 18px auto 0;
}

.cwg-thumbs {
  flex: 1;
  min-width: 0;
  padding: 4px 2px;
}

.cwg-thumb {
  width: 120px;
  aspect-ratio: 4 / 3;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  opacity: 0.75;
  border: 3px solid transparent;
  transition: opacity 0.25s, border-color 0.25s;
}

.cwg-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cwg-thumb:hover { opacity: 1; }

.cwg-thumb.swiper-slide-thumb-active {
  opacity: 1;
  border-color: var(--vs-theme-color2);
}

.cwg-thumbs-nav {
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  font-size: 14px;
  background: #F1ECDF;
  box-shadow: none;
}

.cwg-thumbs-nav.swiper-button-disabled,
.cwg-nav.swiper-button-disabled {
  opacity: 0.4;
  pointer-events: none;
}

@media (max-width: 991px) {
  .cwg-main.swiper .cwg-slide { width: 460px; }
  .cwg-nav--prev { left: 16px; }
  .cwg-nav--next { right: 16px; }
}

@media (max-width: 767px) {
  .cwg-section--home { padding-bottom: 60px; }
  .cwg-main.swiper .cwg-slide { width: 78vw; transform: scale(0.88); }
  .cwg-slide__link { border-radius: 16px; }
  .cwg-nav { width: 42px; height: 42px; font-size: 15px; }
  .cwg-thumbs-nav { display: none; }
  .cwg-thumb { width: 82px; border-radius: 9px; border-width: 2px; }
  .cwg-more { margin-top: 30px; }
}
