/* =============================================
   Gallery - grid (default) + carousel + lightbox
   Под палитру «Янтарный уют»
   ============================================= */

.gallery-page {
  padding: 2rem 0 4rem;
}

@media (min-width: 640px) {
  .gallery-page {
    padding: 3rem 0 5rem;
  }
}

.gallery-page__intro {
  margin-bottom: 2rem;
}

@media (min-width: 640px) {
  .gallery-page__intro {
    margin-bottom: 2.5rem;
  }
}

.gallery-carousel {
  position: relative;
  max-width: 64rem;
  margin-inline: auto;
}

.gallery-empty {
  margin: 0;
  padding: 3rem 1rem;
  text-align: center;
  color: var(--ink-faint);
  font-size: 0.95rem;
  line-height: 1.6;
}

.gallery-empty code {
  color: var(--accent-deep);
  font-size: 0.85em;
}

.gallery-view-btn svg,
.gallery-nav svg,
.gallery-expand svg,
.gallery-thumbs-arrow svg,
.gallery-lightbox__close svg,
.gallery-lightbox__nav svg {
  display: block;
  flex: 0 0 auto;
  flex-shrink: 0;
  overflow: visible;
}

.gallery-view-btn svg {
  width: 1rem !important;
  height: 1rem !important;
  max-width: 1rem;
  max-height: 1rem;
}

.gallery-nav svg,
.gallery-expand svg {
  width: 1.25rem !important;
  height: 1.25rem !important;
  max-width: 1.25rem;
  max-height: 1.25rem;
}

.gallery-thumbs-arrow svg {
  width: 1rem !important;
  height: 1rem !important;
  max-width: 1rem;
  max-height: 1rem;
}

.gallery-lightbox__close svg,
.gallery-lightbox__nav svg {
  width: 1.5rem !important;
  height: 1.5rem !important;
  max-width: 1.5rem;
  max-height: 1.5rem;
}

.gallery-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin: 0 0 1.25rem;
}

.gallery-filter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.4rem;
  padding: 0 1.05rem;
  border-radius: 9999px;
  border: 1px solid var(--line);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1;
  color: var(--ink-muted);
  background: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.gallery-filter:hover {
  border-color: rgba(255, 90, 31, 0.35);
  color: var(--accent-deep);
  background: #fff;
}

.gallery-filter--active {
  background: #1a100c;
  border-color: #1a100c;
  color: #fff;
}

.gallery-filter--active:hover {
  background: #2a1c16;
  border-color: #2a1c16;
  color: #fff;
}

.gallery-filter-empty {
  text-align: center;
  color: var(--ink-muted);
  margin: 0 0 1.5rem;
  font-size: 0.95rem;
}

.gallery-grid-view.is-empty-filter,
.gallery-carousel-view.is-empty-filter {
  display: none !important;
}

.gallery-grid__item.is-filtered,
.gallery-slide.is-filtered,
.gallery-thumb.is-filtered {
  display: none !important;
}

.gallery-view-switch {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 2rem;
}

.gallery-view-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  box-sizing: border-box;
  min-height: 2.75rem;
  padding: 0 1.25rem;
  border-radius: 9999px;
  border: 1px solid var(--line);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1;
  color: var(--ink-muted);
  background: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.gallery-view-btn:hover {
  border-color: rgba(255, 90, 31, 0.35);
  color: var(--accent-deep);
  background: #fff;
}

.gallery-view-btn--active {
  background: linear-gradient(135deg, #ff7a3d 0%, var(--accent) 55%, var(--accent-deep) 100%);
  border-color: var(--accent-deep);
  color: #fff;
  box-shadow: 0 10px 24px -12px var(--accent-glow);
}

.gallery-view-btn--active:hover {
  color: #fff;
  border-color: var(--accent-deep);
  background: linear-gradient(135deg, #ff7a3d 0%, var(--accent) 55%, var(--accent-deep) 100%);
}

/* ── Grid view ── */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

@media (min-width: 640px) {
  .gallery-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
  }
}

@media (min-width: 1024px) {
  .gallery-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 1.1rem;
  }
}

.gallery-grid__item {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: 1.1rem;
  overflow: hidden;
  padding: 0;
  border: 1px solid rgba(255, 90, 31, 0.08);
  cursor: pointer;
  background: var(--mist);
  box-shadow: 0 12px 28px -22px rgba(28, 20, 16, 0.35);
  transition: transform 0.35s var(--ease-out), box-shadow 0.35s ease, border-color 0.25s ease;
}

.gallery-grid__item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.5s var(--ease-out), filter 0.35s ease;
  filter: saturate(1.06) contrast(1.02);
}

.gallery-grid__item.is-broken {
  display: none;
}

.gallery-grid__overlay {
  position: absolute;
  inset: 0;
  background: rgba(28, 20, 16, 0);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  pointer-events: none;
  transition: background 0.3s ease;
}

.gallery-grid__zoom {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 2.75rem;
  height: 2.75rem;
  max-width: 2.75rem;
  max-height: 2.75rem;
  border-radius: 999px;
  background: rgba(28, 20, 16, 0.45);
  box-shadow: 0 8px 20px -12px rgba(28, 20, 16, 0.55);
  opacity: 0;
  transform: scale(0.88);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.gallery-grid__zoom-icon,
.gallery-grid__zoom svg {
  display: block;
  flex: 0 0 auto;
  width: 1.25rem !important;
  height: 1.25rem !important;
  max-width: 1.25rem !important;
  max-height: 1.25rem !important;
  overflow: visible;
}

.gallery-grid__item:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 90, 31, 0.22);
  box-shadow: 0 20px 40px -22px rgba(255, 90, 31, 0.4);
}

.gallery-grid__item:hover img {
  transform: scale(1.05);
  filter: saturate(1.12) contrast(1.04);
}

.gallery-grid__item:hover .gallery-grid__overlay {
  background: rgba(28, 20, 16, 0.28);
}

.gallery-grid__item:hover .gallery-grid__zoom {
  opacity: 1;
  transform: scale(1);
}

/* ── Carousel stage ── */
.gallery-carousel__stage {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  min-height: 320px;
  position: relative;
}

@media (min-width: 640px) {
  .gallery-carousel__stage { min-height: 400px; }
}

@media (min-width: 768px) {
  .gallery-carousel__stage { min-height: 450px; }
}

.gallery-slide {
  width: 120px;
  height: 168px;
  border-radius: 16px;
  opacity: 0.45;
  transform: scale(0.88);
  z-index: 1;
  overflow: hidden;
  flex-shrink: 0;
  cursor: pointer;
  transition:
    width 0.45s cubic-bezier(0.4, 0, 0.2, 1),
    height 0.45s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.35s ease,
    transform 0.45s cubic-bezier(0.4, 0, 0.2, 1),
    border-radius 0.45s ease,
    box-shadow 0.45s ease;
  box-shadow: none;
}

.gallery-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  user-select: none;
}

.gallery-slide.slide-center {
  width: min(90vw, 500px) !important;
  height: 450px !important;
  border-radius: 24px !important;
  opacity: 1 !important;
  transform: scale(1) !important;
  z-index: 10 !important;
  box-shadow: 0 25px 50px -12px rgba(255, 90, 31, 0.35) !important;
  cursor: zoom-in;
}

.gallery-slide.slide-hidden {
  position: absolute;
  width: 0 !important;
  height: 0 !important;
  opacity: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  pointer-events: none !important;
}

.gallery-slide.is-broken {
  display: none !important;
}

@media (max-width: 768px) {
  .gallery-slide { width: 0; height: 0; opacity: 0; }
  .gallery-slide.slide-side {
    width: 100px !important;
    height: 140px !important;
    opacity: 0.5 !important;
  }
  .gallery-slide.slide-center {
    width: min(85vw, 400px) !important;
    height: 380px !important;
    opacity: 1 !important;
  }
}

@media (max-width: 480px) {
  .gallery-slide.slide-side { display: none !important; }
  .gallery-slide.slide-center {
    width: min(92vw, 340px) !important;
    height: 340px !important;
  }
}

.gallery-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid rgba(255, 90, 31, 0.12);
  box-shadow: 0 8px 22px -10px rgba(28, 20, 16, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  cursor: pointer;
  z-index: 20;
  transition: all 0.2s ease;
}

.gallery-nav:hover {
  background: var(--accent-soft);
  color: var(--accent-deep);
  box-shadow: 0 12px 28px -10px var(--accent-glow);
}

.gallery-nav--prev { left: 0; transform: translateY(-50%) translateX(-8px); }
.gallery-nav--next { right: 0; transform: translateY(-50%) translateX(8px); }

@media (max-width: 640px) {
  .gallery-nav { width: 38px; height: 38px; }
  .gallery-nav--prev { transform: translateY(-50%) translateX(0); }
  .gallery-nav--next { transform: translateY(-50%) translateX(0); }
}

.gallery-counter {
  position: absolute;
  bottom: -2.5rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--ink-muted);
  background: #fff;
  padding: 0.375rem 1rem;
  border-radius: 9999px;
  border: 1px solid rgba(255, 90, 31, 0.14);
  white-space: nowrap;
}

.gallery-counter__sep {
  color: var(--ink-faint);
  margin: 0 0.15rem;
}

#gallery-current {
  color: var(--accent);
}

.gallery-expand {
  position: absolute;
  bottom: -2.5rem;
  right: 0;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid rgba(255, 90, 31, 0.14);
  color: var(--ink-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.gallery-expand:hover {
  background: var(--accent-soft);
  color: var(--accent-deep);
  border-color: rgba(255, 90, 31, 0.28);
}

/* ── Thumbnail strip ── */
.gallery-thumbs-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  max-width: 64rem;
  margin: 1.5rem auto 0;
}

.gallery-thumbs {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--accent) transparent;
  padding: 0.5rem 0.25rem;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}

.gallery-thumbs::-webkit-scrollbar { height: 4px; }
.gallery-thumbs::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 4px;
}

.gallery-thumb {
  flex-shrink: 0;
  width: 72px;
  height: 54px;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid transparent;
  padding: 0;
  cursor: pointer;
  opacity: 0.55;
  transition: all 0.2s ease;
  background: var(--mist);
}

.gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gallery-thumb:hover { opacity: 0.85; }

.gallery-thumb--active {
  opacity: 1;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.gallery-thumb.is-broken { display: none; }

.gallery-thumbs-arrow {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.gallery-thumbs-arrow:hover {
  background: var(--accent-soft);
  color: var(--accent-deep);
  border-color: rgba(255, 90, 31, 0.25);
}

/* ── Lightbox ── */
.gallery-lightbox {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

.gallery-lightbox[aria-hidden="false"] {
  opacity: 1;
  visibility: visible;
}

.gallery-lightbox__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(26, 16, 12, 0.92);
  backdrop-filter: blur(8px);
}

.gallery-lightbox__content {
  position: relative;
  z-index: 2;
  max-width: min(95vw, 1200px);
  max-height: 85vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-lightbox__content img {
  max-width: 100%;
  max-height: 85vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
  user-select: none;
}

.gallery-lightbox__close {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 3;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease;
}

.gallery-lightbox__close:hover {
  background: rgba(255, 90, 31, 0.55);
}

.gallery-lightbox__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease;
}

.gallery-lightbox__nav:hover {
  background: rgba(255, 90, 31, 0.65);
}

.gallery-lightbox__nav--prev { left: 1rem; }
.gallery-lightbox__nav--next { right: 1rem; }

.gallery-lightbox__counter {
  position: absolute;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.875rem;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.35);
  padding: 0.375rem 1rem;
  border-radius: 9999px;
}

@media (max-width: 640px) {
  .gallery-lightbox__nav { width: 40px; height: 40px; }
  .gallery-lightbox__nav--prev { left: 0.5rem; }
  .gallery-lightbox__nav--next { right: 0.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  .gallery-grid__item,
  .gallery-grid__item img,
  .gallery-slide {
    transition: none;
  }
}
