/*
 * Tartu Seikluspark – Foto Gallery
 * Kategooriate filtrid + fotomosaiik.
 * Maksimaalne sisulaius 1440px.
 *
 * 1–2 fotot: väikesed kaardid vasakul.
 * 3+ fotot: mosaiikpaigutus.
 *
 * Muudatused piiratud galerii komponendiga.
 */

.ts-gallery {
  --ts-gallery-green: #104418;
  --ts-gallery-green-hover: #156120;
  --ts-gallery-text: #143e1d;
  --ts-gallery-border: #d5e6d3;
  --ts-gallery-radius: 22px;

  box-sizing: border-box;
  width: 100%;
  max-width: 1440px;
  margin-inline: auto;

  padding:
    clamp(32px, 4vw, 62px)
    clamp(16px, 2.5vw, 32px)
    clamp(48px, 6vw, 90px);

  color: var(--ts-gallery-text);
}

/* Elementor Shortcode widget püsib täislaiuses. */

.elementor-widget-shortcode:has(.ts-gallery) {
  width: 100% !important;
  max-width: 100% !important;
  align-self: stretch !important;
  min-width: 0;
}

.elementor-widget-shortcode:has(.ts-gallery) > .elementor-widget-container,
.elementor-widget-shortcode:has(.ts-gallery) .elementor-shortcode {
  width: 100%;
}

/* Box sizing */

.ts-gallery *,
.ts-gallery *::before,
.ts-gallery *::after {
  box-sizing: border-box;
}

/* ==========================================
   KATEGOORIAFILTRID
========================================== */

.ts-gallery .ts-gallery__filters {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-items: center;

  gap: 10px;

  width: 100%;
  max-width: none;

  margin: 0 0 22px;
}

/* Filtrinupp */

.ts-gallery .ts-gallery__filter {
  -webkit-appearance: none;
  appearance: none;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  flex: 0 0 auto;

  min-height: 40px;
  padding: 9px 20px !important;

  border: 1px solid var(--ts-gallery-border) !important;
  border-radius: 999px !important;

  background: transparent !important;
  box-shadow: none !important;

  color: var(--ts-gallery-text) !important;

  font-family: inherit;
  font-size: 14px !important;
  font-weight: 500 !important;
  line-height: 1.35 !important;
  letter-spacing: 0;

  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;

  transition:
    background-color .2s ease,
    border-color .2s ease,
    color .2s ease;
}

/* Hover */

.ts-gallery .ts-gallery__filter:not(.is-active):hover {
  background: #eaf5e7 !important;
  border-color: #aacfac !important;
  color: var(--ts-gallery-green) !important;
}

/* Aktiivne filter */

.ts-gallery .ts-gallery__filter.is-active,
.ts-gallery .ts-gallery__filter.is-active:hover {
  background: var(--ts-gallery-green) !important;
  border-color: var(--ts-gallery-green) !important;
  color: #ffffff !important;
}

/* Klaviatuuriga navigeerimine */

.ts-gallery .ts-gallery__filter:focus-visible,
.ts-gallery .ts-gallery__image-link:focus-visible,
.ts-gallery .ts-gallery__close:focus-visible {
  outline: 3px solid #f2a72e;
  outline-offset: 3px;
}

/* ==========================================
   GALERII GRID
========================================== */

.ts-gallery .ts-gallery__grid {
  display: grid;

  grid-template-columns: repeat(12, minmax(0, 1fr));

  grid-auto-rows: clamp(48px, 5.1vw, 74px);
  grid-auto-flow: dense;

  gap: 12px;

  width: 100%;
  max-width: none;

  margin: 0;

  align-items: stretch;
  justify-content: start;
}

/* Vaikimisi pildikaart */

.ts-gallery .ts-gallery__item {
  grid-column: span 4;
  grid-row: span 3;

  display: block;

  min-width: 0;
  min-height: 0;

  margin: 0;
  padding: 0;

  overflow: hidden;

  border-radius: var(--ts-gallery-radius);

  background: #dcebdd;
  border: 1px solid rgba(16, 68, 24, .045);
}

/* ==========================================
   PILDIMÕÕTMED
   JavaScript määrab data-ts-cols
   ja data-ts-rows väärtused.
========================================== */

/* Veergude arv */

.ts-gallery .ts-gallery__item[data-ts-cols="2"] {
  grid-column: span 2;
}

.ts-gallery .ts-gallery__item[data-ts-cols="3"] {
  grid-column: span 3;
}

.ts-gallery .ts-gallery__item[data-ts-cols="4"] {
  grid-column: span 4;
}

.ts-gallery .ts-gallery__item[data-ts-cols="6"] {
  grid-column: span 6;
}

/*
 * Kaitse vana JS-i või vahemällu jäänud
 * paigutuse vastu: üksik pilt ei veni
 * kunagi 12 veeru laiuseks.
 */

.ts-gallery .ts-gallery__item[data-ts-cols="12"] {
  grid-column: span 3;
}

/* Ridade arv */

.ts-gallery .ts-gallery__item[data-ts-rows="3"] {
  grid-row: span 3;
}

.ts-gallery .ts-gallery__item[data-ts-rows="4"] {
  grid-row: span 4;
}

/* Peidetud pildid */

.ts-gallery .ts-gallery__item[hidden],
.ts-gallery .ts-gallery__empty[hidden] {
  display: none !important;
}

/* ==========================================
   PILDID
========================================== */

.ts-gallery .ts-gallery__image-link {
  display: block;

  width: 100%;
  height: 100%;

  overflow: hidden;

  text-decoration: none;
}

.ts-gallery .ts-gallery__image,
.ts-gallery .ts-gallery__image-link img {
  display: block;

  width: 100% !important;
  height: 100% !important;

  max-width: none !important;
  max-height: none !important;

  margin: 0 !important;

  object-fit: cover;
  object-position: center;

  transition: transform .35s ease;
}

/* Pildi kerge suurendamine hoveril */

.ts-gallery .ts-gallery__image-link:hover .ts-gallery__image {
  transform: scale(1.035);
}

/* ==========================================
   TÜHI KATEGOORIA
========================================== */

.ts-gallery .ts-gallery__empty {
  width: 100%;
  max-width: none;

  margin: 0;

  padding: 45px 15px;

  color: var(--ts-gallery-text);

  text-align: center;
}

/* ==========================================
   LIGHTBOX
========================================== */

.ts-gallery .ts-gallery__lightbox {
  box-sizing: border-box;

  position: fixed;

  width: auto;
  max-width: min(1300px, 94vw);
  max-height: 94vh;

  margin: auto;
  padding: 42px;

  overflow: visible;

  border: 0;

  background: transparent;
}

/* Taust */

.ts-gallery .ts-gallery__lightbox::backdrop {
  background: rgba(4, 16, 8, .92);
}

/* Avatud pilt */

.ts-gallery .ts-gallery__lightbox-image {
  display: block;

  width: auto;
  height: auto;

  max-width: 100%;
  max-height: calc(94vh - 84px);

  margin: auto;

  border-radius: 10px;

  object-fit: contain;
}

/* Sulgemisnupp */

.ts-gallery .ts-gallery__close {
  position: absolute;

  top: 0;
  right: 0;

  display: grid;
  place-items: center;

  width: 38px;
  height: 38px;

  padding: 0;

  border: 0;
  border-radius: 50%;

  background: #ffffff;
  color: var(--ts-gallery-green);

  font: 28px/1 Arial, sans-serif;

  cursor: pointer;
}

/* ==========================================
   TABLET
========================================== */

@media (max-width: 1099px) {

  .ts-gallery .ts-gallery__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: auto;

    gap: 14px;
  }

  .ts-gallery .ts-gallery__item,
  .ts-gallery .ts-gallery__item[data-ts-cols],
  .ts-gallery .ts-gallery__item[data-ts-rows] {
    grid-column: auto;
    grid-row: auto;

    aspect-ratio: 4 / 3;
  }

}

/* ==========================================
   MOBILE
========================================== */

@media (max-width: 639px) {

  .ts-gallery {
    padding: 27px 16px 50px;
  }

  /* Filtrid horisontaalselt keritavad */

  .ts-gallery .ts-gallery__filters {
    flex-wrap: nowrap;
    justify-content: flex-start;

    overflow-x: auto;

    overscroll-behavior-x: contain;
    scrollbar-width: thin;

    gap: 9px;

    margin-bottom: 18px;
    padding: 2px 1px 10px;
  }

  .ts-gallery .ts-gallery__filter {
    min-height: 37px;

    padding: 8px 15px !important;

    font-size: 13px !important;
  }

  /* Üks veerg */

  .ts-gallery .ts-gallery__grid {
    grid-template-columns: minmax(0, 1fr);

    gap: 14px;
  }

  .ts-gallery .ts-gallery__item,
  .ts-gallery .ts-gallery__item[data-ts-cols],
  .ts-gallery .ts-gallery__item[data-ts-rows] {
    aspect-ratio: 4 / 3;
    border-radius: 18px;
  }

  /* Lightbox */

  .ts-gallery .ts-gallery__lightbox {
    max-width: 100vw;
    padding: 40px 12px;
  }

  .ts-gallery .ts-gallery__lightbox-image {
    max-height: calc(94vh - 80px);
  }

  .ts-gallery .ts-gallery__close {
    right: 12px;
  }

}

/* ==========================================
   VÄHENDATUD ANIMATSIOONID
========================================== */

@media (prefers-reduced-motion: reduce) {

  .ts-gallery .ts-gallery__image,
  .ts-gallery .ts-gallery__filter {
    transition: none;
  }

}