/* ============================================
   GALLERY COMPONENT
   Photo gallery with header and flexbox layout
   ============================================ */

/* Gallery Container */
.gallery-container {
    width: 100%;
    min-height: 100vh;
    background-color: var(--color-bg);
}

/* Gallery Header with Featured Photo */
.gallery-header {
    position: relative;
    width: 100%;
    height: 85vh;
    max-height: calc(100vh - 120px);
    min-height: 300px;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

/* Constrain proportions on ultra-wide displays */
@media (min-width: 1800px) {
    .gallery-header {
        height: 88vh;
        min-height: 600px;
        max-height: calc(100vh - 100px);
    }
}

@media (min-width: 2400px) {
    .gallery-header {
        height: 90vh;
        min-height: 700px;
        max-height: calc(100vh - 80px);
    }
}

/* Dark overlay for text readability */
.gallery-header-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0.3),
        rgba(0, 0, 0, 0.7)
    );
}

/* Header Content */
.gallery-header-content {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 2rem;
    padding-bottom: 10rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.gallery-title {
    font-family: var(--font-retro);
    font-size: clamp(1rem, 6vw, 3rem);
    color: var(--color-white);
    margin: 0;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    max-width: 90vw;
    margin-left: auto;
    margin-right: auto;
}

/* Country Navigation */
.gallery-country-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0 2rem;
    box-sizing: border-box;
    position: absolute;
    bottom: 2rem;
    left: 0;
}

.gallery-nav-link {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: color 0.2s ease;
    user-select: none;
}

.gallery-nav-link:hover {
    color: rgba(255, 255, 255, 1);
}

.gallery-nav-country {
    font-family: var(--font-retro);
    font-size: 1rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    line-height: 1;
}

.gallery-nav-chevron {
    font-family: var(--font-retro);
    font-size: 1.5rem;
    line-height: 1;
    transform: translateY(-10%);
}

.gallery-nav-placeholder {
    width: 100px;
}

/* Loading Indicator */
.gallery-loading {
    display: none;
    text-align: center;
    padding: 4rem 2rem;
    font-family: var(--font-mono);
    font-size: 1.5rem;
    color: var(--color-primary);
}

/* ============================================
   PHOTO GRID - CSS Columns Masonry Layout
   ============================================ */

.gallery-grid {
    -webkit-column-count: 3;
    -moz-column-count: 3;
    column-count: 3;
    -webkit-column-gap: 11px;
    -moz-column-gap: 11px;
    column-gap: 11px;
    padding: 11px;
    width: 100%;
    box-sizing: border-box;
}

/* Gallery Item */
.gallery-item {
    position: relative;
    cursor: pointer;
    background: var(--color-bg);
    overflow: hidden;
    -webkit-column-break-inside: avoid;
    page-break-inside: avoid;
    break-inside: avoid;
    margin-bottom: 11px;
    display: inline-block;
    width: 100%;
}

/* Panoramic images - full width */
.gallery-item--panoramic {
    -webkit-column-span: all;
    column-span: all;
}

/* Gallery Item Image - maintain natural aspect ratio */
.gallery-item-image {
    width: 100%;
    height: auto;
    display: block;
}

/* Tablet: 2 columns */
@media (max-width: 1024px) {
    .gallery-grid {
        -webkit-column-count: 2;
        -moz-column-count: 2;
        column-count: 2;
        -webkit-column-gap: 11px;
        -moz-column-gap: 11px;
        column-gap: 11px;
        padding: 11px;
    }
}

/* ============================================
   MOBILE LAYOUT - Single Column
   ============================================ */

@media (max-width: 768px) {
    .gallery-grid {
        -webkit-column-count: 1;
        -moz-column-count: 1;
        column-count: 1;
        -webkit-column-gap: 11px;
        -moz-column-gap: 11px;
        column-gap: 11px;
        padding: 11px;
    }

    .gallery-header {
        height: 50vh;
        max-height: calc(100vh - 100px);
        min-height: 300px;
    }

    .gallery-header-content {
        padding-bottom: 5rem;
    }

    .gallery-title {
        font-size: clamp(0.9rem, 4.5vw, 2rem);
    }

    .gallery-country-nav {
        padding: 0 1.5rem;
        bottom: 1.5rem;
    }

    .gallery-nav-country {
        font-size: 0.85rem;
    }

    .gallery-nav-chevron {
        font-size: 1.25rem;
    }

    .gallery-nav-placeholder {
        width: 60px;
    }
}

@media (max-width: 480px) {
    .gallery-header {
        height: 40vh;
        max-height: calc(100vh - 80px);
        min-height: 280px;
    }

    .gallery-header-content {
        padding: 1rem;
        padding-bottom: 3rem;
    }

    .gallery-title {
        font-size: clamp(0.75rem, 4vw, 1.5rem);
        letter-spacing: 0.05em;
    }

    .gallery-country-nav {
        padding: 0 1rem;
        bottom: 1rem;
    }

    .gallery-nav-country {
        font-size: 0.7rem;
        max-width: 80px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .gallery-nav-chevron {
        font-size: 1.1rem;
    }

    .gallery-nav-placeholder {
        width: 40px;
    }
}

/* Mobile Landscape View */
@media screen and (max-height: 450px) and (orientation: landscape) {
    .gallery-grid {
        -webkit-column-count: 1;
        -moz-column-count: 1;
        column-count: 1;
        -webkit-column-gap: 11px;
        -moz-column-gap: 11px;
        column-gap: 11px;
        padding: 11px;
    }

    .gallery-header {
        height: 70vh;
        min-height: 200px;
        max-height: calc(100vh - 50px);
    }

    .gallery-header-content {
        padding: 0.5rem;
        padding-bottom: 2.5rem;
    }

    .gallery-title {
        font-size: clamp(0.7rem, 3vw, 1.2rem);
    }

    .gallery-country-nav {
        padding: 0 0.75rem;
        bottom: 0.75rem;
    }

    .gallery-nav-country {
        font-size: 0.65rem;
    }

    .gallery-sort-controls {
        padding: 0.75rem 1rem;
    }
}

/* ============================================
   STATES
   ============================================ */

/* Empty State */
.gallery-empty {
    width: 100%;
    text-align: center;
    padding: 4rem 2rem;
    font-family: var(--font-mono);
    color: var(--color-gray);
}

.gallery-empty p {
    font-size: 1.2rem;
    margin: 0;
}

/* Error State */
.gallery-error {
    width: 100%;
    text-align: center;
    padding: 4rem 2rem;
    font-family: var(--font-mono);
    color: var(--color-accent);
}

.gallery-error p {
    font-size: 1.2rem;
    margin: 0;
}

/* ============================================
   ADMIN CONTROLS
   ============================================ */

/* Admin Delete Button */
.gallery-delete-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    padding: 0;
}

.gallery-item:hover .gallery-delete-btn {
    opacity: 1;
}

.gallery-delete-btn:hover svg {
    stroke: #b91c1c;
}

.gallery-delete-btn svg {
    width: 20px;
    height: 20px;
    stroke: #dc2626;
    stroke-width: 2;
    fill: none;
}

/* Admin Star Button (Featured Toggle) */
.gallery-star-btn {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 32px;
    height: 32px;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    padding: 0;
}

.gallery-item:hover .gallery-star-btn {
    opacity: 1;
}

/* Always show star if featured */
.gallery-star-btn.featured {
    opacity: 1;
}

.gallery-star-btn:hover svg {
    stroke: #ca8a04;
}

.gallery-star-btn svg {
    width: 20px;
    height: 20px;
    stroke: #eab308;
    stroke-width: 2;
}

/* Filled star when featured */
.gallery-star-btn.featured svg {
    fill: #eab308;
    stroke: #eab308;
}

/* ============================================
   SORT CONTROLS
   ============================================ */

.gallery-sort-controls {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 1.25rem 1rem;
}

.gallery-sort {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.gallery-sort label {
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 300;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #6b7280;
}

.gallery-sort select {
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #ffffff;
    background: transparent;
    border: 1px solid #374151;
    border-radius: 4px;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    outline: none;
}

.gallery-sort select:hover {
    border-color: #6b7280;
}

.gallery-sort select:focus {
    border-color: #ffffff;
}

.gallery-sort select option {
    background: #111;
    color: #ffffff;
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    .gallery-item-image {
        transition: none;
    }
}
