/* Основная сетка галереи */
.gallery {
  display: grid;
  grid-template-columns: repeat(3, minmax(min(437px, 100%), 1fr));
  gap: 24px;
  max-width: 1358px;
  margin: 0 auto;
  padding: 0;
}

/* Элемент галереи */
.gallery-item {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 1/1;
  background-color: var(--card-bg);
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  width: 100%;
  min-width: 0;
}

.gallery-item:hover {
  transform: translateY(-8px);
  box-shadow: 0 12px 20px rgba(0, 0, 0, 0.3);
}

/* Ссылка и изображение */
.gallery-item a {
  display: block;
  width: 100%;
  height: 100%;
  position: relative;
  z-index: 1;
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Взрослый контент */
.gallery-item[data-adult="true"] {
  position: relative;
}

.gallery-item[data-adult="true"]:not(.adult-hidden):hover img {
  filter: blur(0) brightness(1) !important;
}

.gallery-item.adult-content::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.3);
  z-index: 2;
  transition: opacity 0.4s ease;
  pointer-events: none;
}

.gallery-item.adult-content:hover::before {
  opacity: 0;
}

.adult-warning {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 1.5rem;
  font-weight: bold;
  text-align: center;
  background-color: rgba(211, 47, 47, 0.9);
  padding: 12px 24px;
  border-radius: 8px;
  z-index: 2;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  transition: all 0.4s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

/* Заголовок работы */
.work-title {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 20px;
  font-size: 1.2rem;
  font-weight: 300;
  font-family: 'Huninn', sans-serif;
  color: white;
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.8) 0%, transparent 100%);
  z-index: 2;
  letter-spacing: 0.8px;
  line-height: 1.4;
  text-transform: uppercase;
  opacity: 0.95;
  transition: all 0.3s ease;
  pointer-events: none;
}

.gallery-item:hover .work-title {
  opacity: 1;
  padding-bottom: 24px;
}

/* Иконка типа работы */
.work-type {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(30, 30, 30, 0.9);
  border-radius: 50%;
  color: white;
  font-size: 1rem;
  z-index: 3;
  backdrop-filter: blur(4px);
  transition: all 0.3s ease;
  pointer-events: none;
}

/* Hover-эффект ТОЛЬКО для десктопов */
@media (min-width: 1025px) {
  .gallery-item:hover .work-type {
    background-color: var(--red-color);
    transform: scale(1.1);
  }
}

/* Красный цвет для мобильных устройств (все экраны ≤1024px) */
@media (max-width: 1024px) {
  .work-type {
    background-color: var(--red-color) !important;
    color: white !important;
  }
}

/* Метка внешней ссылки */
.external-link-label {
  position: absolute;
  top: 16px;
  left: 16px;
  background-color: rgba(211, 47, 47, 0.9);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 500;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 4px;
  pointer-events: none;
}

/* RTL-поддержка (арабский язык) */
body[lang="ar"] .gallery-item {
  direction: rtl;
}

body[lang="ar"] .work-title {
  font-family: 'Roboto', sans-serif;
  text-align: right;
}

body[lang="ar"] .work-type {
  right: auto;
  left: 16px;
}

body[lang="ar"] .external-link-label {
  left: auto;
  right: 16px;
}

/* Адаптивность */
@media (max-width: 1440px) {
  .gallery {
    grid-template-columns: repeat(3, minmax(380px, 1fr));
  }
}

@media (max-width: 1280px) {
  .gallery {
    grid-template-columns: repeat(3, minmax(340px, 1fr));
  }
}

@media (max-width: 1024px) {
  .gallery {
    grid-template-columns: repeat(2, minmax(380px, 1fr));
    gap: 20px;
  }
  
  .work-title {
    font-size: 1.1rem;
    padding: 16px;
  }
  
  .adult-warning {
    font-size: 1.3rem;
    padding: 10px 20px;
  }
}

@media (max-width: 880px) {
  .gallery {
    grid-template-columns: repeat(2, minmax(340px, 1fr));
  }
}

@media (max-width: 768px) {
  .gallery {
    grid-template-columns: repeat(2, minmax(280px, 1fr));
    gap: 16px;
    padding: 20px 16px 40px;
  }
  
  .adult-warning {
    font-size: 1.2rem;
    padding: 8px 16px;
  }
}

@media (max-width: 640px) {
  .gallery {
    grid-template-columns: 1fr;
  }
  
  .work-title {
    font-size: 1rem;
    padding: 12px;
  }
  
  .adult-warning {
    font-size: 1.1rem;
    padding: 6px 12px;
  }
}