/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  line-height: 1.6;
  color: #333;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  min-height: 100vh;
}

/* Gallery container */
.gallery-container {
  width: 100%;
  max-width: 95vw;
  margin: 0 auto;
  padding: 2rem 1rem;
}

/* Header styles */
.gallery-header {
  text-align: center;
  margin-bottom: 3rem;
}

.gallery-header h1 {
  font-size: 2.5rem;
  font-weight: 700;
  color: #2d3748;
  margin-bottom: 1rem;
}

.gallery-header p {
  font-size: 1.125rem;
  color: #4a5568;
  max-width: 600px;
  margin: 0 auto;
}

/* Masonry gallery styles */
.masonry-gallery {
  column-count: 1;
  column-gap: 1rem;
  column-fill: balance;
}

@media (min-width: 640px) {
  .masonry-gallery {
    column-count: 2;
    column-gap: 1.5rem;
  }
}

@media (min-width: 1024px) {
  .masonry-gallery {
    column-count: 3;
    column-gap: 2rem;
  }
}

/* Photo item styles */
.photo-item {
  display: inline-block;
  width: 100%;
  margin-bottom: 1rem;
  break-inside: avoid;
  cursor: pointer;
  transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
  opacity: 0;
  animation: fadeInUp 0.6s ease-out forwards;
}

.photo-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}

.photo-item:focus {
  outline: 2px solid #3182ce;
  outline-offset: 4px;
  border-radius: 8px;
}

.photo-item.loaded {
  opacity: 1;
}

@media (min-width: 640px) {
  .photo-item {
    margin-bottom: 1.5rem;
  }
}

@media (min-width: 1024px) {
  .photo-item {
    margin-bottom: 2rem;
  }
}

/* Image container */
.image-container {
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  background: linear-gradient(135deg, #f3f4f6, #e5e7eb);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
}

.image-container img {
  width: 100%;
  height: auto;
  display: block;
  transition: transform 0.3s ease;
}

.photo-item:hover .image-container img {
  transform: scale(1.05);
}

/* Loading skeleton */
.image-skeleton {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    #f0f0f0 25%,
    #e0e0e0 50%,
    #f0f0f0 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 12px;
}

@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

/* Image overlay */
.image-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0%,
    rgba(0, 0, 0, 0.1) 50%,
    rgba(0, 0, 0, 0.7) 100%
  );
  opacity: 0;
  transition: opacity 0.3s ease;
  display: flex;
  align-items: flex-end;
  padding: 1rem;
  border-radius: 12px;
}

.photo-item:hover .image-overlay {
  opacity: 1;
}

.overlay-content {
  color: white;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.overlay-content span {
  font-size: 0.875rem;
  font-weight: 500;
}

/* Fullscreen modal */
.fullscreen-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.fullscreen-modal.active {
  display: flex;
  animation: fadeIn 0.2s ease-out;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(4px);
}

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

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 10;
  background: rgba(0, 0, 0, 0.5);
  border: none;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  color: white;
  cursor: pointer;
  transition: background-color 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  background: rgba(0, 0, 0, 0.7);
}

.modal-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  background: rgba(0, 0, 0, 0.5);
  border: none;
  border-radius: 50%;
  width: 56px;
  height: 56px;
  color: white;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.8;
}

.modal-nav:hover {
  background: rgba(0, 0, 0, 0.7);
  opacity: 1;
  transform: translateY(-50%) scale(1.1);
}

.modal-nav:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: translateY(-50%);
}

.modal-nav:disabled:hover {
  background: rgba(0, 0, 0, 0.5);
  transform: translateY(-50%);
}

.modal-prev {
  left: 2rem;
}

.modal-next {
  right: 2rem;
}

.modal-image {
  max-width: calc(100% - 200px);
  max-height: calc(100% - 120px);
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  animation: zoomIn 0.3s ease-out;
  transition: opacity 0.2s ease;
}

.modal-info {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  color: white;
  background: rgba(0, 0, 0, 0.7);
  padding: 1rem 2rem;
  border-radius: 8px;
  backdrop-filter: blur(8px);
  max-width: 80%;
}

.modal-counter {
  font-size: 0.875rem;
  opacity: 0.8;
  margin-bottom: 0.5rem;
}

.modal-description {
  font-size: 1rem;
  font-weight: 500;
}

/* Animations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes zoomIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Staggered animation delay for items */
.photo-item:nth-child(1) { animation-delay: 0.1s; }
.photo-item:nth-child(2) { animation-delay: 0.2s; }
.photo-item:nth-child(3) { animation-delay: 0.3s; }
.photo-item:nth-child(4) { animation-delay: 0.4s; }
.photo-item:nth-child(5) { animation-delay: 0.5s; }
.photo-item:nth-child(6) { animation-delay: 0.6s; }
.photo-item:nth-child(7) { animation-delay: 0.7s; }
.photo-item:nth-child(8) { animation-delay: 0.8s; }
.photo-item:nth-child(9) { animation-delay: 0.9s; }
.photo-item:nth-child(10) { animation-delay: 1.0s; }
.photo-item:nth-child(11) { animation-delay: 1.1s; }
.photo-item:nth-child(12) { animation-delay: 1.2s; }
.photo-item:nth-child(13) { animation-delay: 1.3s; }
.photo-item:nth-child(14) { animation-delay: 1.4s; }
.photo-item:nth-child(15) { animation-delay: 1.5s; }
.photo-item:nth-child(16) { animation-delay: 1.6s; }

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
  .photo-item:hover {
    transform: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  }
  
  .photo-item:active {
    transform: scale(0.98);
  }
  
  .image-overlay {
    opacity: 1;
    background: linear-gradient(
      to bottom,
      rgba(0, 0, 0, 0) 0%,
      rgba(0, 0, 0, 0.05) 50%,
      rgba(0, 0, 0, 0.3) 100%
    );
  }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Responsive adjustments */
@media (max-width: 640px) {
  .gallery-header h1 {
    font-size: 2rem;
  }
  
  .gallery-header p {
    font-size: 1rem;
  }
  
  .gallery-container {
    padding: 1rem;
  }
  
  .modal-nav {
    width: 48px;
    height: 48px;
  }
  
  .modal-prev {
    left: 1rem;
  }
  
  .modal-next {
    right: 1rem;
  }
  
  .modal-image {
    max-width: calc(100% - 140px);
    max-height: calc(100% - 120px);
  }
  
  .modal-info {
    bottom: 1rem;
    padding: 0.75rem 1.5rem;
    max-width: 90%;
  }
}