/* ═══════════════════════════════════════════════════
   gallery.css — стили страницы галереи
   ai-melissa.space / gallery.html
   ═══════════════════════════════════════════════════ */

/* ─── BODY (галерея — тёмный фон) ─── */
body {
  background: var(--charcoal);
  color: var(--warm-white);
  padding-top: 64px;
}

/* ─── NAV — специфика галереи ─── */
.site-nav {
  z-index: 200;
  /* Чуть более непрозрачный фон, чем на главной */
  background: rgba(28, 26, 24, 0.96);
}

.nav-back {
  font-size: 13px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.45);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: color 0.2s;
  white-space: nowrap;
}

.nav-back:hover {
  color: var(--gold-light);
}

/* ─── HERO ГАЛЕРЕИ ─── */
.gallery-hero {
  padding: 72px 60px 48px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.gallery-label {
  font-size: 12px;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 500;
  margin-bottom: 16px;
}

.gallery-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: clamp(40px, 5vw, 72px);
  font-weight: 300;
  line-height: 1.05;
  margin-bottom: 20px;
}

.gallery-title em {
  font-style: italic;
  color: var(--gold-light);
}

.gallery-desc {
  font-size: 18px;
  color: rgba(255, 255, 255, 0.45);
  max-width: 560px;
  line-height: 1.8;
}

/* ─── ТАБЫ КАТЕГОРИЙ ─── */
.tabs-bar {
  position: sticky;
  top: 64px;
  z-index: 100;
  background: rgba(28, 26, 24, 0.97);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding: 0 60px;
  display: flex;
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
  /* FIX: fade-маска справа — визуальный намёк на горизонтальный скролл */
  -webkit-mask-image: linear-gradient(to right, black 85%, transparent 100%);
  mask-image: linear-gradient(to right, black 85%, transparent 100%);
}

.tabs-bar::-webkit-scrollbar {
  display: none;
}

.tab {
  padding: 20px 28px;
  font-size: 13px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.35);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: all 0.25s;
  /* FIX: добавлен webkit-вариант для Safari < 15.4 */
  -webkit-user-select: none;
  user-select: none;
}

.tab:hover {
  color: rgba(255, 255, 255, 0.7);
}

.tab.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}

.tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  background: rgba(184, 149, 90, 0.15);
  color: var(--gold);
  font-size: 10px;
  border-radius: 50%;
  margin-left: 8px;
}

/* ─── КОНТЕНТ ГАЛЕРЕИ ─── */
.gallery-content {
  padding: 48px 60px;
}

/* Masonry через CSS columns */
.masonry-grid {
  columns: 4;
  column-gap: 12px;
}

.masonry-item {
  break-inside: avoid;
  margin-bottom: 12px;
  position: relative;
  cursor: pointer;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  transition: transform 0.3s ease, border-color 0.3s;
}

.masonry-item:hover {
  transform: translateY(-3px);
  border-color: rgba(184, 149, 90, 0.4);
}

.masonry-item img {
  width: 100%;
  display: block;
  transition: transform 0.4s ease;
  background: rgba(255, 255, 255, 0.03);
}

.masonry-item:hover img {
  transform: scale(1.03);
}

.item-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(28, 26, 24, 0.85) 0%, transparent 50%);
  opacity: 0;
  transition: opacity 0.3s;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 20px;
}

.masonry-item:hover .item-overlay {
  opacity: 1;
}

.item-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 16px;
  font-weight: 400;
  color: var(--warm-white);
  margin-bottom: 6px;
  line-height: 1.3;
}

.item-hint {
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--gold);
}

/* Placeholder (когда нет изображения) */
.img-placeholder {
  width: 100%;
  display: block;
  background: rgba(255, 255, 255, 0.04);
  position: relative;
  overflow: hidden;
}

/* ─── МОДАЛЬНОЕ ОКНО ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  /* FIX: нестандартное all → auto */
  pointer-events: none;
  transition: opacity 0.3s;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  overflow-y: auto;
  /* FIX: -webkit-overflow-scrolling убран (устарело с iOS 13),
     заменён на современный overscroll-behavior */
  overscroll-behavior: contain;
}

.modal-overlay.open {
  opacity: 1;
  /* FIX: нестандартное all → auto */
  pointer-events: auto;
}

.modal {
  background: var(--charcoal);
  border: 1px solid rgba(184, 149, 90, 0.2);
  max-width: 900px;
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  transform: scale(0.96) translateY(12px);
  transition: transform 0.3s ease;
  margin: auto;
  flex-shrink: 0;
}

.modal-overlay.open .modal {
  transform: scale(1) translateY(0);
}

.modal-img-side {
  position: relative;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
}

.modal-img-side img {
  width: 100%;
  height: auto;
  display: block;
  /* pointer-events: none — клик на img не мешает открытию лайтбокса */
  pointer-events: none;
}

.modal-img-placeholder {
  width: 100%;
  height: 100%;
  min-height: 300px;
  background: rgba(255, 255, 255, 0.04);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 64px;
  opacity: 0.3;
  pointer-events: none;
}

.modal-info-side {
  padding: 40px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  background: rgba(28, 26, 24, 0.7);
  border: none;
  color: var(--warm-white);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: background 0.2s;
}

.modal-close:hover {
  background: rgba(184, 149, 90, 0.3);
}

.modal-category {
  font-size: 11px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 12px;
}

.modal-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 28px;
  font-weight: 300;
  line-height: 1.2;
  margin-bottom: 20px;
  color: var(--warm-white);
}

.modal-desc {
  font-size: 16px;
  color: rgba(255, 255, 255, 0.5);
  line-height: 1.8;
  margin-bottom: 28px;
  flex: 1;
}

.prompt-block {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(184, 149, 90, 0.2);
  border-left: 3px solid var(--gold);
  padding: 16px 20px;
  margin-bottom: 16px;
  position: relative;
}

.prompt-label {
  font-size: 10px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 10px;
}

.prompt-text {
  font-family: 'Courier New', monospace;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
  line-height: 1.7;
  word-break: break-word;
}

.copy-btn {
  width: 100%;
  padding: 12px 20px;
  background: transparent;
  border: 1px solid rgba(184, 149, 90, 0.4);
  color: var(--gold);
  font-family: 'Jost', sans-serif;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 2px;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.25s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.copy-btn:hover {
  background: var(--gold);
  color: var(--charcoal);
  border-color: var(--gold);
}

.copy-btn.copied {
  background: rgba(184, 149, 90, 0.15);
  color: var(--gold-light);
}

/* ─── ЛАЙТБОКС ─── */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.95);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  padding: 20px;
  cursor: zoom-out;
}

.lightbox-overlay.open {
  opacity: 1;
  /* FIX: нестандартное all → auto */
  pointer-events: auto;
}

.lightbox-content {
  max-width: 90vw;
  max-height: 90vh;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-content img {
  max-width: 100%;
  max-height: 90vh;
  width: auto;
  height: auto;
  display: block;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(184, 149, 90, 0.2);
}

.lightbox-close {
  position: absolute;
  top: -40px;
  right: 0;
  width: 40px;
  height: 40px;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  font-size: 32px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
  z-index: 10;
}

.lightbox-close:hover {
  color: var(--gold);
}

/* ─── FOOTER ГАЛЕРЕИ ─── */
.gallery-footer {
  padding: 48px 60px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.gallery-footer-text {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.2);
  letter-spacing: 1px;
}

.gallery-footer-link {
  font-size: 13px;
  color: var(--gold);
  text-decoration: none;
  letter-spacing: 1px;
  transition: color 0.2s;
}

.gallery-footer-link:hover {
  color: var(--gold-light);
}

/* ─── АНИМАЦИЯ ПОЯВЛЕНИЯ КАРТОЧЕК ─── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}

/* ═══════════════════════════════════════════════════
   АДАПТИВ — ПЛАНШЕТ (≤ 1200px / ≤ 800px)
   ═══════════════════════════════════════════════════ */
@media (max-width: 1200px) { .masonry-grid { columns: 3; } }
@media (max-width: 800px)  { .masonry-grid { columns: 2; } }

@media (max-width: 800px) {
  .gallery-hero    { padding: 48px 28px 32px; }
  .gallery-content { padding: 32px 28px; }
  .tabs-bar        { padding: 0 28px; }
  .gallery-footer  { padding: 32px 28px; flex-direction: column; gap: 16px; }
}

/* ═══════════════════════════════════════════════════
   АДАПТИВ — МОБИЛЬНЫЙ (≤ 700px)
   ═══════════════════════════════════════════════════ */
@media (max-width: 700px) {
  .site-nav { padding: 0 16px; gap: 12px; }
  .nav-logo { font-size: 17px; letter-spacing: 2px; }
  .nav-back { font-size: 11px; letter-spacing: 1px; }
  .nav-back .full { display: none; }
  .nav-back .short { display: inline; }

  .modal-overlay { padding: 12px 8px 40px; align-items: flex-start; }
  .modal {
    grid-template-columns: 1fr;
    margin: 0;
    /* FIX: ограничение высоты для очень узких экранов */
    max-height: 95dvh;
    max-height: 95vh;
    overflow-y: auto;
  }
  .modal-img-side { max-height: none; }

  .lightbox-close {
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    font-size: 24px;
  }

  .lightbox-content { max-width: 95vw; }
}

@media (max-width: 480px) {
  .masonry-grid { columns: 1; }
  .gallery-hero { padding: 40px 20px 28px; }
  .gallery-content { padding: 24px 20px; }
  .tabs-bar { padding: 0 20px; }
}

/* Показываем full/short текст в nav-back: скрыто по умолчанию, показываем ≥ 601px */
@media (min-width: 701px) {
  .nav-back .short { display: none; }
  .nav-back .full  { display: inline; }
}
