/**
 * Tapetis — project gallery page (template-project-gallery.php only).
 */

.tapetis-project-gallery-page {
  background: #fffaf7;
  min-height: 60vh;
  padding-bottom: 24px;
}

.tapetis-project-gallery-hero {
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(40px, 6vw, 70px) 20px 34px;
  text-align: left;
}

.tapetis-project-gallery-hero h1 {
  font-family: "Commissioner", system-ui, sans-serif;
  font-size: clamp(32px, 5vw, 72px);
  line-height: 1.05;
  margin: 0 0 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #2c2622;
}

.tapetis-project-gallery-hero p {
  max-width: 820px;
  margin: 0;
  font-size: clamp(16px, 1.5vw, 18px);
  line-height: 1.7;
  color: #5c534c;
}

.tapetis-project-gallery-empty {
  max-width: 720px;
  margin: 40px auto;
  padding: 32px 28px;
  text-align: center;
  border-radius: 22px;
  border: 1px solid rgba(201, 111, 118, 0.22);
  background: #fff;
  box-shadow: 0 16px 40px rgba(50, 30, 25, 0.07);
  color: #4a433c;
  font-size: 17px;
}

/* Filters */
.tapetis-gallery-filter {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  max-width: 1180px;
  margin: 0 auto 28px;
  padding: 0 20px;
}

.tapetis-gallery-filter__button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 22px;
  border-radius: 999px;
  border: 1px solid rgba(45, 36, 36, 0.12);
  background: #fff;
  color: #3a342f;
  font-family: "Commissioner", system-ui, sans-serif;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.tapetis-gallery-filter__button:hover {
  border-color: rgba(201, 111, 118, 0.45);
  box-shadow: 0 10px 28px rgba(50, 30, 25, 0.08);
}

.tapetis-gallery-filter__button.is-active {
  border-color: rgba(201, 111, 118, 0.55);
  background: linear-gradient(135deg, #fff 0%, #fff5f3 100%);
  color: #c96f76;
  box-shadow: 0 12px 32px rgba(201, 111, 118, 0.18);
}

.tapetis-gallery-filter__count {
  font-size: 12px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(201, 111, 118, 0.12);
  color: #8a5a5f;
}

.tapetis-gallery-filter__button.is-active .tapetis-gallery-filter__count {
  background: rgba(201, 111, 118, 0.22);
  color: #7a3e45;
}

/* Grid */
.tapetis-project-gallery {
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
}

.tapetis-project-gallery__grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 12px;
  padding: 0 20px 28px;
  align-items: stretch;
}

.tapetis-project-gallery__item {
  grid-column: span 3;
  aspect-ratio: 1 / 1;
  border-radius: 22px;
  overflow: hidden;
  background: #f3ece7;
  cursor: pointer;
  position: relative;
  border: 0;
  padding: 0;
  display: block;
  width: 100%;
  text-align: left;
  transition: transform 0.22s ease, box-shadow 0.22s ease;
}

.tapetis-project-gallery__item:hover {
  transform: translateY(-3px);
  box-shadow: 0 18px 44px rgba(50, 30, 25, 0.12);
  z-index: 1;
}

.tapetis-project-gallery__item:focus-visible {
  outline: 3px solid rgba(201, 111, 118, 0.55);
  outline-offset: 3px;
}

.tapetis-project-gallery__item--large {
  grid-column: span 6;
  grid-row: span 2;
  aspect-ratio: 1 / 1;
}

.tapetis-project-gallery__item--wide {
  grid-column: span 6;
  aspect-ratio: 2 / 1;
}

.tapetis-project-gallery__item--tall {
  grid-column: span 3;
  grid-row: span 2;
  aspect-ratio: 1 / 2;
}

.tapetis-project-gallery__item img,
.tapetis-project-gallery__item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.tapetis-project-gallery__video-wrap {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
}

.tapetis-project-gallery__video {
  pointer-events: none;
}

.tapetis-project-gallery__play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  background: radial-gradient(circle at center, rgba(0, 0, 0, 0.08) 0%, rgba(0, 0, 0, 0.35) 100%);
  color: #fff;
}

.tapetis-project-gallery__play svg {
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.35));
  width: clamp(28px, 5vw, 44px);
  height: clamp(28px, 5vw, 44px);
}

.tapetis-project-gallery__actions {
  display: flex;
  justify-content: center;
  padding: 8px 20px 70px;
}

.tapetis-project-gallery__load-more {
  min-height: 52px;
  padding: 0 32px;
  border-radius: 999px;
  border: 0;
  background: #c96f76;
  color: #fff;
  font-family: "Commissioner", system-ui, sans-serif;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 14px 34px rgba(201, 111, 118, 0.28);
  transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.tapetis-project-gallery__load-more:hover:not(:disabled) {
  background: #b95f68;
  transform: translateY(-2px);
}

.tapetis-project-gallery__load-more:disabled {
  opacity: 0.65;
  cursor: wait;
}

@media (max-width: 1024px) {
  .tapetis-project-gallery__grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .tapetis-project-gallery__item {
    grid-column: span 3;
  }

  .tapetis-project-gallery__item--large,
  .tapetis-project-gallery__item--wide {
    grid-column: span 6;
  }
}

@media (max-width: 640px) {
  .tapetis-gallery-filter {
    justify-content: stretch;
  }

  .tapetis-gallery-filter__button {
    flex: 1 1 calc(50% - 6px);
    justify-content: center;
  }

  .tapetis-project-gallery__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 0 10px 20px;
  }

  .tapetis-project-gallery__item,
  .tapetis-project-gallery__item--tall {
    grid-column: span 1;
    grid-row: span 1;
    aspect-ratio: 1 / 1.25;
    border-radius: 14px;
  }

  .tapetis-project-gallery__item--large,
  .tapetis-project-gallery__item--wide {
    grid-column: span 2;
    grid-row: span 1;
    aspect-ratio: 1.35 / 1;
  }
}

/* Lightbox */
body.tapetis-gallery-lb-open {
  overflow: hidden;
}

.tapetis-gallery-lightbox {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
}

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

.tapetis-gallery-lightbox__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 14, 12, 0.72);
  backdrop-filter: blur(6px);
}

.tapetis-gallery-lightbox__dialog {
  position: relative;
  width: min(1120px, 100%);
  max-height: min(92vh, 900px);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  z-index: 1;
}

.tapetis-gallery-lightbox__close {
  position: absolute;
  top: -6px;
  right: -6px;
  z-index: 5;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 0;
  background: #fff;
  color: #2c2622;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.tapetis-gallery-lightbox__arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  width: 48px;
  height: 48px;
  border-radius: 999px;
  border: 0;
  background: rgba(255, 255, 255, 0.95);
  color: #2c2622;
  font-size: 28px;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.15);
}

.tapetis-gallery-lightbox__arrow--prev {
  left: 8px;
}

.tapetis-gallery-lightbox__arrow--next {
  right: 8px;
}

.tapetis-gallery-lightbox.is-single .tapetis-gallery-lightbox__arrow {
  display: none !important;
}

.tapetis-gallery-lightbox.is-video-mode .tapetis-gallery-lightbox__toolbar {
  display: none;
}

.tapetis-gallery-lightbox__stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 20px;
  overflow: hidden;
  background: #0d0a09;
  touch-action: none;
}

.tapetis-gallery-lightbox__zoom-wrap {
  max-width: 100%;
  max-height: min(78vh, 760px);
  transform-origin: center center;
  transition: transform 0.08s ease-out;
  will-change: transform;
}

.tapetis-gallery-lightbox__media {
  max-width: 100%;
  max-height: min(78vh, 760px);
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

.tapetis-gallery-lightbox__media--video {
  width: min(100%, 960px);
  max-height: min(78vh, 760px);
}

.tapetis-gallery-lightbox__toolbar {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
}

.tapetis-gallery-lightbox__zoom-btn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
}

.tapetis-gallery-lightbox__counter {
  margin: 10px 0 0;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: rgba(255, 250, 247, 0.85);
}

@media (max-width: 640px) {
  .tapetis-gallery-lightbox__arrow {
    width: 40px;
    height: 40px;
    font-size: 22px;
  }

  .tapetis-gallery-lightbox__arrow--prev {
    left: 4px;
  }

  .tapetis-gallery-lightbox__arrow--next {
    right: 4px;
  }
}
