/**
 * Interactive Photo Gallery - Main Styles
 * 
 * A responsive, accessible photo gallery with search and lightbox features.
 * Uses CSS Grid for layout and modern CSS features for smooth interactions.
 * 
 * @author Brian Walker
 * @version 1.0.0
 */

/* ==========================================
   Base Styles
   ========================================== */

* {
  box-sizing: border-box;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding: 2rem;
  max-width: 1400px;
  margin: 0 auto;
  background-color: #f9f9f9;
  color: #333;
  font-size: 16px;
  line-height: 1.5;
}

/* Screen reader only content */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ==========================================
   Header & Search
   ========================================== */

header {
  margin-bottom: 2rem;
}

.search-container {
  display: flex;
  justify-content: center;
  align-items: center;
}

#searchInput {
  background-image: url("../photos/searchicon.png");
  background-position: 12px center;
  background-repeat: no-repeat;
  background-size: 20px;
  width: 100%;
  max-width: 600px;
  font-size: 1.0625rem;
  padding: 0.875rem 1.25rem 0.875rem 2.75rem;
  border: 2px solid #ddd;
  border-radius: 25px;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
  font-family: inherit;
}

#searchInput:focus {
  outline: none;
  border-color: #007bff;
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

#searchInput::placeholder {
  color: #999;
}

/* ==========================================
   Gallery Grid
   ========================================== */

.container {
  width: 100%;
}

.gallery {
  list-style-type: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

.gallery li {
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.gallery li a {
  display: block;
  background-color: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  overflow: hidden;
  text-decoration: none;
  color: #333;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  height: 100%;
}

.gallery li a:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
}

.gallery li a:focus {
  box-shadow: 0 0 0 4px rgba(0, 123, 255, 0.25);
  outline: 2px solid #007bff;
  outline-offset: 2px;
}

.gallery li img {
  width: 100%;
  height: 220px;
  object-fit: cover;
  display: block;
}

.gallery li a::after {
  content: attr(title);
  display: block;
  padding: 1rem;
  font-size: 1.0625rem;
  font-weight: 500;
  text-align: center;
  background-color: #fff;
  color: #1a1a1a;
  letter-spacing: -0.01em;
}

/* ==========================================
   Responsive Design
   ========================================== */

@media (max-width: 768px) {
  body {
    padding: 1rem;
  }

  .gallery {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
  }

  #searchInput {
    font-size: 1rem;
    padding: 0.75rem 1rem 0.75rem 2.5rem;
  }

  .gallery li a::after {
    font-size: 1rem;
    padding: 0.875rem;
  }
}

@media (max-width: 480px) {
  .gallery {
    grid-template-columns: 1fr;
  }

  .gallery li img {
    height: 200px;
  }
}

/* ==========================================
   Lightbox Overlay
   ========================================== */

.lightbox-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.95);
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.lightbox-overlay.active {
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
}

.lightbox-content {
  position: relative;
  max-width: 90%;
  max-height: 90%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.lightbox-image {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.lightbox-caption {
  color: #fff;
  text-align: center;
  margin-top: 1.5rem;
  margin-bottom: 2rem;
  padding: 0 1rem;
  max-width: 800px;
  font-size: 1rem;
  line-height: 1.6;
}

.lightbox-caption strong {
  font-size: 1.25rem;
  font-weight: 600;
  display: block;
  margin-bottom: 0.25rem;
}

.lightbox-close,
.lightbox-prev,
.lightbox-next {
  position: fixed;
  background-color: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.3);
  font-size: 2rem;
  cursor: pointer;
  padding: 0.5rem 1rem;
  transition: background-color 0.3s ease, border-color 0.3s ease;
  border-radius: 4px;
  z-index: 10000;
}

.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover {
  background-color: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.6);
}

.lightbox-close:focus,
.lightbox-prev:focus,
.lightbox-next:focus {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.lightbox-close {
  top: 1rem;
  right: 1rem;
  font-size: 2.5rem;
  padding: 0.25rem 0.75rem;
  line-height: 1;
}

.lightbox-prev {
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
}

.lightbox-next {
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
}

@media (max-width: 768px) {
  .lightbox-prev,
  .lightbox-next {
    font-size: 1.5rem;
    padding: 0.5rem 0.75rem;
  }
  
  .lightbox-close {
    font-size: 2rem;
  }
  
  .lightbox-caption {
    font-size: 0.875rem;
    margin-top: 1rem;
  }
  
  .lightbox-caption strong {
    font-size: 1rem;
  }
}

/* ==========================================
   Accessibility & Motion
   ========================================== */

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