.gallery-page {
  max-width: var(--max-width);
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

.gallery-title {
  font-size: 48px;
  font-weight: bold;
  margin-bottom: var(--padding-small);
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-align: center;
}

.gallery-subtitle {
  font-size: 20px;
  margin-bottom: var(--padding-large);
  line-height: 1.6;
  opacity: 0.9;
  text-align: center;
  color: var(--text-secondary);
}

.gallery-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  flex-wrap: wrap;
  gap: 15px;
}

.search-box {
  display: flex;
  flex: 1;
}

.search-box input {
  flex: 1;
  padding: 12px 15px;
  border: 1px solid var(--border-color);
  border-radius: 30px 0 0 30px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  font-size: 16px;
}

.search-box button {
  padding: 12px 20px;
  background: var(--gradient);
  color: white;
  border: none;
  border-radius: 0 30px 30px 0;
  cursor: pointer;
  transition: var(--transition);
}

.search-box button:hover {
  opacity: 0.9;
}

.gallery-stats {
  color: var(--text-secondary);
  font-size: 14px;
}


.gallery-container {
  position: relative;
  min-height: 500px;
}


.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 25px;
  margin-bottom: 50px;
  align-items: start;
}

.image-card {
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(20px);
  -webkit-background-filter: blur(20px);
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.3s ease;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  height: fit-content;
}

.image-card:hover {
  transform: translateY(-8px);
  box-shadow: 
    0 20px 40px rgba(0, 0, 0, 0.3),
    0 8px 25px rgba(155, 81, 224, 0.2);
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(155, 81, 224, 0.3);
}


.image-container {
  position: relative;
  width: 100%;
  aspect-ratio: 2/3;
  overflow: hidden;
  background: 
    linear-gradient(45deg, 
      rgba(155, 81, 224, 0.05) 0%, 
      rgba(48, 129, 237, 0.05) 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.gallery-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform 0.5s ease;
  opacity: 0;
  background: transparent;
}

.gallery-image.loaded {
  opacity: 1;
}

.image-card:hover .gallery-image {
  transform: scale(1.02);
}

.image-placeholder {
  width: 100%;
  height: 100%;
  background: 
    linear-gradient(45deg, 
      rgba(155, 81, 224, 0.1) 0%, 
      rgba(48, 129, 237, 0.1) 50%,
      rgba(155, 81, 224, 0.1) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 14px;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { opacity: 0.6; }
  50% { opacity: 0.8; }
  100% { opacity: 0.6; }
}

.image-info {
  padding: 20px;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.image-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-align: center;
}

.image-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.image-size {
  background: rgba(155, 81, 224, 0.2);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
}

.load-more-container {
  display: flex;
  justify-content: center;
  margin: 40px 0;
}

.gallery-loader {
  display: none;
  text-align: center;
  padding: 40px;
  color: var(--text-secondary);
}

.gallery-loader.active {
  display: block;
}

.loader-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top: 3px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 15px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.image-card {
  animation: fadeInUp 0.6s ease-out forwards;
  opacity: 0;
  transform: translateY(20px);
}

@keyframes fadeInUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1200px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
  }
}

@media (max-width: 768px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 15px;
  }
  
  .gallery-title {
    font-size: 36px;
  }
  
  .gallery-controls {
    flex-direction: column;
    align-items: stretch;
  }
  
  .search-box {
    max-width: 100%;
  }
  
  .image-info {
    padding: 15px;
  }
  
  .image-name {
    font-size: 15px;
  }
}

@media (max-width: 640px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
  }
  
  .image-container {
    aspect-ratio: 2/3;
  }
}

@media (max-width: 480px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
  }
  
  .gallery-title {
    font-size: 32px;
  }
  
  .image-info {
    padding: 12px;
  }
  
  .image-name {
    font-size: 14px;
    -webkit-line-clamp: 2;
  }
  
  .image-meta {
    flex-direction: column;
    gap: 5px;
    align-items: center;
    text-align: center;
  }
}

@media (max-width: 375px) {
  .gallery-grid {
    grid-template-columns: 1fr;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
  }
}


@media (max-width: 900px) and (orientation: landscape) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
}


@media (prefers-reduced-motion: reduce) {
  .image-card,
  .gallery-image,
  .loader-spinner {
    transition: none;
  }
  
  .image-card:hover {
    transform: none;
  }
}


@supports not (aspect-ratio: 2/3) {
  .image-container::before {
    content: '';
    display: block;
    padding-top: 150%; /* 1152/768 * 100% = 150% */
  }
  
  .image-container {
    height: 0;
    position: relative;
  }
  
  .gallery-image,
  .image-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
  }
}

.vertical-image {
  aspect-ratio: 2/3;
}


@media (prefers-contrast: high) {
  .image-card {
    border: 2px solid var(--text-primary);
    background: rgba(255, 255, 255, 0.15);
  }
  
  .image-placeholder {
    background: rgba(255, 255, 255, 0.2);
  }
}

/* Темная тема по умолчанию */
@media (prefers-color-scheme: dark) {
  .image-card {
    background: rgba(0, 0, 0, 0.3);
  }
  
  .image-placeholder {
    background: linear-gradient(45deg, 
      rgba(155, 81, 224, 0.15) 0%, 
      rgba(48, 129, 237, 0.15) 100%);
  }
}