/* ============================================
   DOWNLOAD GALLERY PAGE (Standesamt / Kennenlernen)
   ============================================ */

/* Header (fixed) */
.photo-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-sm) var(--space-md);
    background: rgba(250, 249, 246, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--color-border);
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--color-text-light);
    transition: color 0.3s ease;
}

.back-link:hover {
    color: var(--color-blue-dark);
}

.header-title {
    text-align: center;
    flex: 1;
}

.header-title h1 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 300;
    font-style: italic;
    color: var(--color-text);
    margin: 0;
}

.header-subtitle {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    letter-spacing: 0.1em;
    margin-top: 0.25rem;
}

/* Intro */
.gallery-section {
    padding: var(--space-md);
    padding-top: calc(80px + var(--space-md));
    background: var(--color-bg);
    min-height: 70vh;
}

.gallery-section .container {
    max-width: 1200px;
}

.gallery-lead {
    text-align: center;
    max-width: 640px;
    margin: 0 auto var(--space-md);
}

.gallery-lead h2 {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 300;
    font-style: italic;
    margin-bottom: var(--space-xs);
}

.gallery-lead p {
    color: var(--color-text-light);
}

/* Toolbar (static, sits above the grid) */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-sm);
    justify-content: space-between;
    padding: 0.75rem var(--space-sm);
    margin-bottom: var(--space-md);
    background: var(--color-blue-bg);
    border: 1px solid var(--color-border);
    border-radius: 10px;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

#photo-count {
    font-size: 0.9rem;
    color: var(--color-text-light);
}

/* Text buttons */
.text-btn {
    border: none;
    background: transparent;
    color: var(--color-blue-dark);
    font-family: var(--font-body);
    font-size: 0.82rem;
    cursor: pointer;
    padding: 0.4rem 0.5rem;
    border-radius: 6px;
    transition: background 0.2s ease;
}

.text-btn:hover {
    background: rgba(122, 141, 154, 0.12);
}

/* Gallery grid */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--space-sm);
}

.gallery-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    background: var(--color-bg-alt);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: pointer;
    transition: transform 0.5s ease;
}

.gallery-item:hover {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.gallery-item:hover img {
    transform: scale(1.05);
}

.gallery-item.selected {
    outline: 3px solid var(--color-blue);
    outline-offset: -3px;
}

/* Tile buttons */
.g-select,
.g-download {
    position: absolute;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
}

.g-select svg,
.g-download svg {
    width: 18px;
    height: 18px;
}

.g-select {
    top: 8px;
    left: 8px;
    background: rgba(255, 255, 255, 0.9);
    color: transparent;
    border: 2px solid rgba(255, 255, 255, 0.95);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

.g-select:hover {
    background: white;
}

.gallery-item.selected .g-select {
    background: var(--color-blue);
    border-color: var(--color-blue);
    color: white;
}

.g-download {
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.45);
    color: white;
    opacity: 0;
}

.gallery-item:hover .g-download {
    opacity: 1;
}

.g-download:hover {
    background: var(--color-blue-dark);
}

/* Loading / empty states */
.gallery-loading,
.gallery-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-xl);
    color: var(--color-text-muted);
    text-align: center;
}

.gallery-empty svg {
    opacity: 0.3;
}

.gallery-empty h3 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 300;
    font-style: italic;
    color: var(--color-text-light);
    margin: 0;
}

.spinner {
    width: 28px;
    height: 28px;
    animation: spin 1s linear infinite;
    color: var(--color-blue);
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Sticky selection bar */
.selection-bar {
    position: fixed;
    left: 50%;
    bottom: -100px;
    transform: translateX(-50%);
    z-index: 90;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 0.75rem 1.25rem;
    background: var(--color-text);
    color: white;
    border-radius: 999px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
    transition: bottom 0.35s var(--ease);
    max-width: calc(100vw - 2rem);
}

.selection-bar.visible {
    bottom: var(--space-md);
}

#selection-count {
    font-size: 0.9rem;
    white-space: nowrap;
}

.btn-download-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    background: var(--color-blue);
    color: white;
    border: none;
    border-radius: 999px;
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.25s ease;
    white-space: nowrap;
}

.btn-download-primary:hover:not(:disabled) {
    background: var(--color-blue-dark);
}

.btn-download-primary:disabled {
    opacity: 0.85;
    cursor: progress;
}

.btn-download-primary svg {
    width: 18px;
    height: 18px;
}

/* Size choice dialog */
.size-dialog-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1100;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    padding: var(--space-md);
}

.size-dialog-backdrop.visible {
    display: flex;
}

.size-dialog {
    position: relative;
    width: 100%;
    max-width: 380px;
    background: var(--color-bg);
    border-radius: 16px;
    padding: var(--space-md);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: dialog-in 0.25s var(--ease);
}

@keyframes dialog-in {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.size-dialog-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--color-text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.size-dialog-close:hover {
    background: var(--color-bg-alt);
}

.size-dialog h3 {
    font-family: var(--font-display);
    font-size: 1.6rem;
    font-style: italic;
    font-weight: 300;
    margin-bottom: 0.25rem;
    padding-right: 2rem;
}

.size-dialog-sub {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin-bottom: var(--space-sm);
}

.size-choice {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.9rem 1rem;
    margin-bottom: 0.6rem;
    border: 1.5px solid var(--color-border);
    border-radius: 10px;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.size-choice:hover {
    border-color: var(--color-blue-light);
}

.size-choice input {
    margin-top: 0.2rem;
    width: 18px;
    height: 18px;
    accent-color: var(--color-blue);
    flex-shrink: 0;
}

.size-choice:has(input:checked) {
    border-color: var(--color-blue);
    background: var(--color-blue-bg);
}

.size-choice-text {
    display: flex;
    flex-direction: column;
}

.size-choice-main {
    font-size: 0.95rem;
    color: var(--color-text);
}

.size-choice-hint {
    font-size: 0.78rem;
    color: var(--color-text-muted);
    line-height: 1.4;
}

.size-dialog-confirm {
    width: 100%;
    margin-top: var(--space-xs);
    padding: 0.8rem;
    font-size: 0.9rem;
}

.btn-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: white;
    border-radius: 50%;
    display: inline-block;
    animation: spin 0.8s linear infinite;
}

/* Lightbox */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.95);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.lightbox.active {
    display: flex;
}

.lightbox-close,
.lightbox-nav {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease;
}

.lightbox-close {
    top: var(--space-md);
    right: var(--space-md);
    width: 44px;
    height: 44px;
}

.lightbox-nav {
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
}

.lightbox-close:hover,
.lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.2);
}

.lightbox-prev { left: var(--space-md); }
.lightbox-next { right: var(--space-md); }

.lightbox-content {
    max-width: 90vw;
    max-height: 75vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-content img {
    max-width: 100%;
    max-height: 75vh;
    object-fit: contain;
    border-radius: 4px;
}

.lightbox-footer {
    position: absolute;
    bottom: var(--space-md);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    color: white;
}

.lightbox-filename {
    font-size: 0.85rem;
    opacity: 0.7;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-download {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: var(--color-blue);
    color: white;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-download:hover {
    background: var(--color-blue-dark);
    transform: translateY(-2px);
}

/* Footer */
.footer {
    text-align: center;
    padding: var(--space-lg) var(--space-md);
    background: var(--color-bg-alt);
}

.footer-names {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-style: italic;
}

.footer-date {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    letter-spacing: 0.1em;
}

/* Responsive */
@media (max-width: 768px) {
    .photo-header { padding: var(--space-sm); }
    .header-title h1 { font-size: 1.25rem; }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar-group {
        justify-content: space-between;
    }

    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-xs);
    }

    /* Always show the per-photo download button on touch devices */
    .g-download { opacity: 1; }

    .lightbox-nav { width: 40px; height: 40px; }
    .lightbox-prev { left: var(--space-xs); }
    .lightbox-next { right: var(--space-xs); }

    .lightbox-footer {
        flex-direction: column;
        gap: var(--space-sm);
    }
}
