/**
 * Flickr Random Gallery - Main Stylesheet
 * Version: 1.3
 */

/* ==========================================================================
   Placeholder Styles
   ========================================================================== */
.placeholder-wrapper {
  background-color: #e0e0e0;
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.placeholder-shimmer {
  position: absolute;
  top: 0;
  left: -100%;
  width: 50%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(0); }
  100% { transform: translateX(400%); }
}

.image-wrapper img {
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
  will-change: opacity;
}

.image-wrapper img.loaded {
  opacity: 1;
}

.flickr-random-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 4px;
  width: 100%;
  background-color: transparent;
}

.gallery-item {
  position: relative;
  aspect-ratio: 1; /* Forces square aspect ratio for container */
  overflow: hidden;
}

.image-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.image-wrapper a {
  display: block;
  width: 100%;
  height: 100%;
}

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

.image-wrapper .overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease;
}

.image-wrapper:hover .overlay {
  opacity: 1;
}

.image-wrapper .view-on-flickr {
  color: white;
  font-size: 14px;
  padding: 8px 16px;
  border: 2px solid white;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.5);
}

/* Loading and error states */
.frg-loading,
.frg-error {
  grid-column: 1 / -1;
  text-align: center;
  padding: 20px;
}

.frg-spinner {
  display: inline-block;
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #3498db;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
/* ==========================================================================
   Gallery Overlay
   ========================================================================== */
.overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.7);
  padding: 10px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

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

.view-on-flickr {
  color: white;
  text-align: center;
  display: block;
  font-size: 14px;
  font-weight: 500;
}

/* ==========================================================================
   Error States
   ========================================================================== */
.frg-error {
  text-align: center;
  padding: 20px;
  background: #fff5f5;
  border: 1px solid #feb2b2;
  border-radius: 4px;
  color: #c53030;
  grid-column: 1 / -1;
}

.frg-retry-button {
  background: #2271b1;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  margin-top: 10px;
  transition: background-color 0.2s ease;
}

.frg-retry-button:hover {
  background: #135e96;
}
