← back to Jill Website
public/css/gallery.css
385 lines
/**
* Responsive Image Gallery Component Styles
* Features: Grid layout, lazy loading states, lightbox modal, responsive design
*/
/* ==================== Gallery Container ==================== */
.image-gallery {
width: 100%;
max-width: 1400px;
margin: 0 auto;
padding: 2rem 1rem;
}
.gallery-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 1.5rem;
margin: 0;
padding: 0;
list-style: none;
}
/* Column variations */
.gallery-grid-2 {
grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
}
.gallery-grid-3 {
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}
.gallery-grid-4 {
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}
/* ==================== Gallery Items ==================== */
.gallery-item {
position: relative;
overflow: hidden;
border-radius: 12px;
background: #f5f5f5;
cursor: pointer;
aspect-ratio: 4 / 3;
transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.gallery-item:hover {
transform: translateY(-5px);
box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
}
.gallery-item:focus {
outline: 3px solid var(--primary-color, #2c5f8d);
outline-offset: 2px;
}
.gallery-item img {
width: 100%;
height: 100%;
object-fit: cover;
transition: opacity 0.3s ease, transform 0.3s ease;
opacity: 0;
}
.gallery-item img.loaded {
opacity: 1;
}
.gallery-item:hover img {
transform: scale(1.05);
}
/* ==================== Loading States ==================== */
.gallery-item.loading::before {
content: '';
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 40px;
height: 40px;
border: 4px solid #f3f3f3;
border-top: 4px solid var(--primary-color, #2c5f8d);
border-radius: 50%;
animation: gallery-spinner 1s linear infinite;
}
@keyframes gallery-spinner {
0% { transform: translate(-50%, -50%) rotate(0deg); }
100% { transform: translate(-50%, -50%) rotate(360deg); }
}
.gallery-item.error::after {
content: '⚠️ Failed to load';
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
color: #e74c3c;
font-size: 14px;
text-align: center;
}
/* ==================== Gallery Overlay ==================== */
.gallery-item::after {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: linear-gradient(to top, rgba(0, 0, 0, 0.6) 0%, transparent 50%);
opacity: 0;
transition: opacity 0.3s ease;
}
.gallery-item:hover::after {
opacity: 1;
}
/* ==================== Gallery Caption ==================== */
.gallery-caption {
position: absolute;
bottom: 0;
left: 0;
right: 0;
padding: 1rem;
color: white;
font-size: 0.9rem;
font-weight: 500;
transform: translateY(100%);
transition: transform 0.3s ease;
z-index: 2;
}
.gallery-item:hover .gallery-caption {
transform: translateY(0);
}
/* ==================== Lightbox Modal ==================== */
.gallery-lightbox {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.95);
z-index: 9999;
display: flex;
align-items: center;
justify-content: center;
opacity: 0;
visibility: hidden;
transition: opacity 0.3s ease, visibility 0.3s ease;
}
.gallery-lightbox.active {
opacity: 1;
visibility: visible;
}
/* ==================== Lightbox Controls ==================== */
.lightbox-close,
.lightbox-prev,
.lightbox-next {
position: absolute;
background: rgba(255, 255, 255, 0.1);
border: 2px solid rgba(255, 255, 255, 0.3);
color: white;
width: 50px;
height: 50px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
transition: all 0.3s ease;
z-index: 10001;
backdrop-filter: blur(10px);
}
.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover {
background: rgba(255, 255, 255, 0.2);
border-color: rgba(255, 255, 255, 0.5);
transform: scale(1.1);
}
.lightbox-close {
top: 20px;
right: 20px;
}
.lightbox-prev {
left: 20px;
top: 50%;
transform: translateY(-50%);
}
.lightbox-prev:hover {
transform: translateY(-50%) scale(1.1);
}
.lightbox-next {
right: 20px;
top: 50%;
transform: translateY(-50%);
}
.lightbox-next:hover {
transform: translateY(-50%) scale(1.1);
}
.lightbox-close i,
.lightbox-prev i,
.lightbox-next i {
font-size: 1.5rem;
}
/* ==================== Lightbox Content ==================== */
.lightbox-content {
position: relative;
max-width: 90vw;
max-height: 90vh;
display: flex;
flex-direction: column;
align-items: center;
animation: lightbox-zoom-in 0.3s ease;
}
@keyframes lightbox-zoom-in {
from {
opacity: 0;
transform: scale(0.9);
}
to {
opacity: 1;
transform: scale(1);
}
}
.lightbox-image {
max-width: 100%;
max-height: 80vh;
object-fit: contain;
border-radius: 8px;
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.lightbox-caption {
margin-top: 1.5rem;
color: white;
font-size: 1.1rem;
text-align: center;
max-width: 600px;
line-height: 1.6;
}
.lightbox-counter {
position: absolute;
top: -40px;
right: 0;
color: rgba(255, 255, 255, 0.8);
font-size: 0.9rem;
font-weight: 500;
}
/* ==================== Responsive Design ==================== */
/* Tablet (768px and below) */
@media (max-width: 768px) {
.gallery-grid {
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 1rem;
}
.lightbox-close {
top: 10px;
right: 10px;
width: 40px;
height: 40px;
}
.lightbox-prev,
.lightbox-next {
width: 40px;
height: 40px;
}
.lightbox-prev {
left: 10px;
}
.lightbox-next {
right: 10px;
}
.lightbox-close i,
.lightbox-prev i,
.lightbox-next i {
font-size: 1.2rem;
}
.lightbox-caption {
font-size: 1rem;
padding: 0 1rem;
}
}
/* Mobile (480px and below) */
@media (max-width: 480px) {
.image-gallery {
padding: 1rem 0.5rem;
}
.gallery-grid {
grid-template-columns: 1fr;
gap: 0.75rem;
}
.gallery-item {
aspect-ratio: 16 / 9;
}
.lightbox-content {
max-width: 95vw;
max-height: 85vh;
}
.lightbox-image {
max-height: 70vh;
}
.lightbox-caption {
font-size: 0.9rem;
margin-top: 1rem;
}
.lightbox-counter {
font-size: 0.8rem;
top: -30px;
}
}
/* ==================== Accessibility ==================== */
.gallery-item:focus-visible {
outline: 3px solid var(--primary-color, #2c5f8d);
outline-offset: 3px;
}
.lightbox-close:focus-visible,
.lightbox-prev:focus-visible,
.lightbox-next:focus-visible {
outline: 3px solid white;
outline-offset: 2px;
}
/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
.gallery-item,
.gallery-item img,
.gallery-lightbox,
.lightbox-content,
.gallery-caption {
transition: none;
animation: none;
}
}
/* ==================== Print Styles ==================== */
@media print {
.gallery-lightbox,
.lightbox-close,
.lightbox-prev,
.lightbox-next {
display: none;
}
.gallery-item {
break-inside: avoid;
page-break-inside: avoid;
}
}