/* ===== Fullscreen Gallery (#20 Immersive) ===== */

.gallery-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.75);
    flex-direction: column;
}
.gallery-overlay.open {
    display: flex;
}

/* Main photo area */
.gallery-main {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    overflow: hidden;
    cursor: pointer;
}

/* Polaroid frame */
.gallery-polaroid {
    background: white;
    padding: 12px 12px 48px;
    border-radius: 3px;
    box-shadow:
        0 4px 20px rgba(0,0,0,0.4),
        0 0 0 1px rgba(0,0,0,0.05);
    transform: rotate(-1.5deg);
    position: relative;
    display: inline-block;
    max-width: min(90vw, 924px);
    max-height: calc(80vh + 60px);
}
.gallery-polaroid img {
    max-height: 70vh;
    max-width: min(85vw, 900px);
    width: auto;
    height: auto;
    display: block;
    user-select: none;
    -webkit-user-drag: none;
}
.gallery-polaroid-caption {
    position: absolute;
    bottom: 10px;
    left: 16px;
    right: 16px;
    font-family: 'Noto Serif TC', Georgia, serif;
    font-size: 14px;
    color: #555;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Controls - hidden by default, shown on hover/touch */
.gallery-controls {
    position: absolute;
    inset: 0;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}
.gallery-overlay.controls-visible .gallery-controls {
    opacity: 1;
}
.gallery-controls > * {
    pointer-events: auto;
}

/* Top bar */
.gallery-top {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 56px;
    background: linear-gradient(rgba(0,0,0,0.6), transparent);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
}
.gallery-back {
    background: rgba(255,255,255,0.12);
    border: none;
    color: white;
    width: 36px; height: 36px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.gallery-back:hover { background: rgba(255,255,255,0.25); }
.gallery-loc-name {
    font-size: 15px;
    font-weight: 600;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.gallery-counter {
    margin-left: auto;
    font-size: 13px;
    color: rgba(255,255,255,0.5);
    white-space: nowrap;
}

/* Bottom bar */
.gallery-bottom {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
    padding: 20px 12px 12px;
}

/* Progress bar */
.gallery-progress {
    height: 3px;
    background: rgba(255,255,255,0.15);
    border-radius: 2px;
    margin-bottom: 8px;
    overflow: hidden;
}
.gallery-progress-fill {
    height: 100%;
    background: #60a5fa;
    width: 0%;
    transition: width 0.1s linear;
    border-radius: 2px;
}

/* Thumbnail strip */
.gallery-thumbs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.gallery-thumbs::-webkit-scrollbar { display: none; }

.gallery-thumb {
    flex: 0 0 104px;
    height: 80px;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    opacity: 0.4;
    border: 2px solid transparent;
    transition: opacity 0.2s, border-color 0.2s;
}
.gallery-thumb.active {
    opacity: 1;
    border-color: white;
}
.gallery-thumb[draggable="true"] {
    cursor: grab;
}
.gallery-thumb[draggable="true"]:active {
    cursor: grabbing;
}
.gallery-thumb.drag-over-left {
    border-left: 3px solid #60a5fa;
}
.gallery-thumb.drag-over-right {
    border-right: 3px solid #60a5fa;
}
.gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
}

/* Navigation arrows */
.gallery-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px; height: 44px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    z-index: 3;
}
.gallery-arrow:hover { background: rgba(255,255,255,0.25); }
.gallery-arrow.prev { left: 16px; }
.gallery-arrow.next { right: 16px; }

/* Delete button */
.gallery-delete {
    position: absolute;
    top: 12px;
    right: 64px;
    width: 40px; height: 40px;
    border-radius: 50%;
    background: rgba(220, 38, 38, 0.7);
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    z-index: 5;
}

/* ===== Info card album thumbnails ===== */

.info-card-album {
    display: flex;
    gap: 4px;
    padding: 8px 0 0;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.info-card-album::-webkit-scrollbar { display: none; }

.info-card-album-thumb {
    flex: 0 0 96px;
    height: 72px;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.15s, transform 0.15s;
}
.info-card-album-thumb:hover {
    border-color: var(--batch-color, #2563eb);
    transform: scale(1.05);
}
.info-card-album-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Owner: add photo button in album strip */
.info-card-album-add {
    flex: 0 0 96px;
    height: 72px;
    border-radius: 6px;
    border: 2px dashed rgba(0,0,0,0.15);
    background: rgba(0,0,0,0.03);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 18px;
    transition: border-color 0.15s, background 0.15s;
}
.info-card-album-add:hover {
    border-color: var(--batch-color, #2563eb);
    background: rgba(0,0,0,0.06);
    color: var(--batch-color, #2563eb);
}

/* Mobile adjustments */
@media (max-width: 600px) {
    .gallery-polaroid {
        padding: 6px 6px 32px;
        transform: rotate(-0.8deg);
    }
    .gallery-polaroid img {
        height: auto;
        max-height: 55vh;
        max-width: 85vw;
    }
    .gallery-polaroid-caption {
        bottom: 6px;
        left: 10px;
        right: 10px;
        font-size: 12px;
    }
    .gallery-arrow { width: 36px; height: 36px; font-size: 16px; }
    .gallery-arrow.prev { left: 8px; }
    .gallery-arrow.next { right: 8px; }
    .gallery-thumb { flex: 0 0 80px; height: 60px; }
    .gallery-top { height: 48px; padding: 0 12px; }
    .gallery-loc-name { font-size: 14px; }
}

/* Landscape: constrain image height so it fits */
@media (max-width: 768px) and (orientation: landscape) {
    .gallery-polaroid img {
        max-height: 45vh;
    }
}
