/* Custom styles for Gallery */

/* iOS Safari scroll fix — address bar show/hide fires 20-30 viewport resize events
   per direction change, causing Safari to re-composite and flash black.
   Fix: make gallery-view its own scroll container sized with vh (layout viewport,
   which does NOT change with address bar). Body overflow hidden prevents body scroll. */
body.gallery-active {
    height: 100vh;
    overflow: hidden;
    margin: 0;
}
body.gallery-active #gallery-view {
    height: 100vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: none;
}

/* Column layout — JS distributes images into shortest-column-first */
.gallery-column {
    display: flex;
    gap: 6px;
}
.gallery-column .gallery-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.gallery-column .gallery-item {
    width: 100%;
}

/* Single column layout */
.gallery-single {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    max-width: 900px;
    margin: 0 auto;
}
.gallery-single .gallery-item {
    width: 100%;
}

/* Grid layout — uniform square thumbnails */
.gallery-grid {
    display: grid;
    gap: 6px;
    grid-template-columns: repeat(2, 1fr);
}
@media (min-width: 640px) { .gallery-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1024px) { .gallery-grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1440px) { .gallery-grid { grid-template-columns: repeat(5, 1fr); } }
.gallery-grid .gallery-item {
    aspect-ratio: 1 / 1;
    overflow: hidden;
}

/* Lightbox */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.95);
    z-index: 100;
    overflow: hidden;
}
.lb-slide {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.lb-slide img {
    max-width: 90vw;
    max-height: 80vh;
    object-fit: contain;
}
.lightbox-close {
    position: absolute;
    top: 16px;
    right: 16px;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    z-index: 101;
}
.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: white;
    font-size: 3rem;
    cursor: pointer;
    padding: 0 20px;
    z-index: 101;
    user-select: none;
}
.lightbox-prev { left: 0; }
.lightbox-next { right: 0; }
@media (max-width: 639px) {
    .lightbox-nav { display: none; }
}
.lightbox-ui {
    position: absolute;
    z-index: 101;
}
#lightbox-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
}

/* Upload drop zone */
.drop-zone {
    border: 2px dashed #4b5563;
    transition: all 0.2s;
}
.drop-zone.dragover {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.1);
}

/* Proofing badges */
.proof-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}
.proof-keep { background: #16a34a; color: white; }
.proof-maybe { background: #eab308; color: black; }
.proof-reject { background: #dc2626; color: white; }

/* Gallery cover hero */
.gallery-cover-overlay {
    background: linear-gradient(
        to bottom,
        transparent 80%,
        rgba(0, 0, 0, 0.5) 90%,
        rgba(0, 0, 0, 0.85) 100%
    );
}

/* Loading spinner */
.spinner {
    border: 3px solid rgba(255,255,255,0.1);
    border-top-color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 0.5; } 50% { opacity: 1; } }
