/* =========================================================
   Wedding Gallery Styles
   ========================================================= */

/* -------------------------
   Variables
------------------------- */
:root {
    /* Palette */
    --bg-cream: #F7F5F2;
    --bg-white: #FFFFFF;

    --text-primary: #5A5957;   /* Grey 700 */
    --text-secondary: #84827E; /* Grey 500 */
    --border-color: #DFDDDA;   /* Grey 200 */

    --gold-main: #E2C670;
    --gold-deep: #C9AC4E;

    --shadow-soft: 0 10px 30px rgba(0,0,0,0.06);
    --shadow-hover: 0 15px 35px rgba(0,0,0,0.10);
}

/* -------------------------
   Basic layout
------------------------- */
body {
    margin: 0;
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-cream);
    color: var(--text-primary);
    min-height: 100vh;
}

.page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
}

/* -------------------------
   Header
------------------------- */
header {
    text-align: center;
    margin-bottom: 60px;
    position: relative;
}

/* Event branding is populated by gallery.js from the public event projection. */
.event-name {
    display: block;
    font-family: 'Playfair Display', serif;
    font-size: 0.8rem;
    letter-spacing: 2px;
    color: var(--gold-deep);
    margin-bottom: 16px;
}

header h1 {
    margin: 0 0 12px 0;
    font-family: 'Playfair Display', serif;
    font-size: 3rem;
    font-weight: 500;
    color: var(--text-primary);
}

header p {
    font-weight: 300;
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin: 0;
}

/* Header controls (Uploader filter) */
.controls {
    margin-top: 18px;
    display: inline-flex;
    gap: 10px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
}

.controls label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 300;
}

#uploaderFilter {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-white);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    outline: none;
}

#uploaderFilter:focus {
    border-color: var(--gold-main);
}

/* -------------------------
   Status / Loading
------------------------- */
#status {
    margin: 40px 0;
    font-size: 1rem;
    color: var(--text-secondary);
    text-align: center;
    font-style: italic;
}

/* -------------------------
   Grid System
------------------------- */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
}

/* Keep the host route discoverable without competing with the photo grid. */
.gallery-footer {
    margin-top: 64px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.gallery-footer a {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.gallery-footer a:hover,
.gallery-footer a:focus-visible {
    color: var(--text-primary);
}

/* -------------------------
   Photo thumbnail card
------------------------- */
.thumbWrapper {
    position: relative;
    width: 100%;
    padding-bottom: 100%; /* Square aspect ratio */
    overflow: hidden;
    background: var(--bg-white);
    border-radius: 4px;
    box-shadow: var(--shadow-soft);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
}

.thumbWrapper:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
}

/* Thumbnail image */
.thumbWrapper img.thumb {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.thumbWrapper:hover img.thumb {
    transform: scale(1.05);
}

/* Download Button on Thumbnail (Generated by JS) */
.downloadBtn {
    position: absolute;
    bottom: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.9);
    color: var(--text-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: 18px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.10);
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
    z-index: 2;
}

.thumbWrapper:hover .downloadBtn {
    opacity: 1;
    transform: translateY(0);
}

.downloadBtn:hover {
    background: var(--gold-main);
    color: white;
}

/* -------------------------
   Modal / Lightbox
------------------------- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-backdrop.open {
    display: flex;
    opacity: 1;
}

.modal {
    background: var(--bg-white);
    width: 90%;
    max-width: 1000px;
    max-height: 90vh;
    border-radius: 4px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0);  opacity: 1; }
}

.modal-header {
    padding: 24px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-white);
    gap: 16px;
}

.modal-header h2 {
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
    color: var(--text-primary);
    margin: 0;
    font-weight: 500;
    white-space: nowrap;
}

/* Actions row in modal header */
.modal-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* Prev/Next buttons (new) */
button#prevPhotoBtn,
button#nextPhotoBtn {
    border: 1px solid var(--border-color);
    background: var(--bg-white);
    color: var(--text-primary);
    border-radius: 4px;
    height: 40px;
    width: 44px;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease, border-color 0.3s ease;
}

button#prevPhotoBtn:hover,
button#nextPhotoBtn:hover {
    background: var(--bg-cream);
    border-color: var(--gold-main);
}

button#prevPhotoBtn:disabled,
button#nextPhotoBtn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Styled Download Button in Modal */
a#downloadBtn {
    padding: 10px 24px;
    background: var(--gold-main);
    color: var(--text-primary);
    border-radius: 4px;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.3s ease;
    font-family: 'Inter', sans-serif;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    box-sizing: border-box;
}

a#downloadBtn:hover {
    background: var(--gold-deep);
}

/* Close Button */
button#closeModalBtn {
    border: none;
    background: none;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    transition: color 0.3s ease;
    font-weight: 300;
    height: 40px;
    width: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

button#closeModalBtn:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 32px;
    overflow: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #FAFAF7;
}

.modal-img-wrapper {
    width: 100%;
    text-align: center;
    margin-bottom: 24px;
}

.modal-img-wrapper img {
    max-width: 100%;
    max-height: 70vh;
    border-radius: 2px;
    box-shadow: var(--shadow-soft);
}

.modal-meta {
    width: 100%;
    max-width: 600px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
    display: flex;
    justify-content: space-between;
    gap: 20px;
}

.modal-meta p {
    margin: 0;
}

.modal-meta strong {
    color: var(--text-primary);
    font-weight: 500;
}

/* -------------------------
   Mobile adjustments
------------------------- */
@media (max-width: 600px) {
    header h1 {
        font-size: 2rem;
    }

    .grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .gallery-footer {
        margin-top: 44px;
    }

    /* Always show thumbnail download button on mobile */
    .downloadBtn {
        opacity: 1;
        transform: translateY(0);
    }

    /* Header controls: make dropdown easier to tap */
    .controls {
        margin-top: 14px;
    }

    #uploaderFilter {
        width: 100%;
        max-width: 280px;
    }

    .modal-header {
        padding: 16px;
    }

    .modal-body {
        padding: 16px;
    }

    a#downloadBtn {
        padding: 8px 16px;
        font-size: 0.8rem;
        height: 36px;
    }

    button#prevPhotoBtn,
    button#nextPhotoBtn {
        height: 36px;
        width: 40px;
    }

    button#closeModalBtn {
        height: 36px;
        width: 36px;
        font-size: 1.8rem;
    }
}
