/* ============================================
   PHOTO MODAL COMPONENT
   Full-screen modal for viewing photos
   ============================================ */

/* Body scroll lock when modal is open */
body.photo-modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
    touch-action: none;
}

/* Modal Overlay */
.photo-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.95);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease-out;
    /* Prevent background scrolling on mobile */
    touch-action: none;
    overscroll-behavior: contain;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Modal Container */
.photo-modal {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

/* Modal Header */
.photo-modal-header {
    position: fixed;
    top: 1.5rem;
    right: 1rem;
    z-index: 2100;
}

/* Close Button */
.photo-modal-close {
    background: transparent;
    color: #ef4444;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
}

.photo-modal-close:hover {
    color: #dc2626;
}

/* Navigation Buttons */
.photo-modal-nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    color: #ffffff;
    border: none;
    padding: 1rem;
    cursor: pointer;
    transition: color 0.2s ease;
    z-index: 2100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.photo-modal-prev {
    left: 1rem;
}

.photo-modal-next {
    right: 1rem;
}

.photo-modal-nav:hover {
    color: #9ca3af;
}

.photo-modal-nav:active {
    color: #6b7280;
}

/* Image Container */
.photo-modal-image-container {
    max-width: 80vw;
    max-height: 70vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg);
    padding: 0.5rem;
}

.photo-modal-image {
    max-width: 100%;
    max-height: 80vh;
    width: auto;
    height: auto;
    display: block;
    object-fit: contain;
    /* GPU acceleration to prevent artifacts during zoom/pan */
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform-origin: center center;
    /* Force GPU layer to prevent sub-pixel rendering issues */
    transform: translateZ(0);
}

/* Metadata Panel */
.photo-modal-metadata {
    background: var(--color-bg);
    border: 3px solid var(--color-primary);
    padding: 1rem;
    min-width: 400px;
    font-family: var(--font-mono);
    color: var(--color-primary);
}

.metadata-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.metadata-row:last-child {
    margin-bottom: 0;
}

.metadata-label {
    font-weight: bold;
    color: var(--color-yellow);
}

.metadata-value {
    color: var(--color-white);
    text-align: right;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .photo-modal-metadata {
        min-width: 300px;
        font-size: 0.85rem;
    }
}

@media (max-width: 768px) {
    .photo-modal {
        max-width: 100vw;
        max-height: 100vh;
        width: 100vw;
        height: 100vh;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }

    /* Close button - make larger and more visible on mobile */
    .photo-modal-header {
        top: 1rem;
        right: 1rem;
        z-index: 2100;
    }

    .photo-modal-close {
        padding: 0.5rem;
        background: rgba(0, 0, 0, 0.5);
        border-radius: 50%;
    }

    .photo-modal-close svg {
        width: 28px;
        height: 28px;
    }

    /* Hide navigation arrows on phones */
    .photo-modal-nav {
        display: none;
    }

    .photo-modal-prev {
        left: 0.5rem;
    }

    .photo-modal-next {
        right: 0.5rem;
    }

    .photo-modal-image-container {
        max-width: 90vw;
        max-height: 70vh;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .photo-modal-image {
        max-width: 100%;
        max-height: 70vh;
        object-fit: contain;
    }

    /* When zoomed: expand image container */
    .photo-modal--zoomed .photo-modal-image-container {
        max-width: 95vw;
        max-height: 85vh;
    }

    .photo-modal--zoomed .photo-modal-image {
        max-height: 85vh;
    }

    .photo-modal-metadata {
        min-width: 0;
        width: 100%;
        max-width: 95vw;
        padding: 0.75rem;
        border-width: 2px;
    }

    .metadata-row {
        font-size: 0.75rem;
        flex-direction: column;
        gap: 0.25rem;
    }

    .metadata-value {
        text-align: left;
    }
}

/* Show navigation arrows on tablets (600px+) */
@media (min-width: 600px) and (max-width: 768px) {
    .photo-modal-nav {
        display: flex;
        position: fixed;
        top: 50%;
        transform: translateY(-50%);
        padding: 0.75rem;
    }
}

/* Loading state for images */
.photo-modal-image:not([src]) {
    min-width: 200px;
    min-height: 200px;
    background: repeating-linear-gradient(
        45deg,
        var(--color-bg),
        var(--color-bg) 10px,
        var(--color-gray) 10px,
        var(--color-gray) 20px
    );
}

/* Photo Info Overlay */
.photo-modal-info {
    position: fixed;
    bottom: 2rem;
    left: 2rem;
    z-index: 2100;
}

.photo-modal-info-city {
    font-family: var(--font-mono);
    font-size: 16px;
    font-weight: 300;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #ffffff;
    margin: 0 0 0.5rem 0;
}

.photo-modal-info-date {
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 300;
    letter-spacing: 1px;
    color: #6b7280;
    margin: 0;
}

@media (max-width: 768px) {
    .photo-modal-info {
        bottom: 1rem;
        left: 1rem;
    }

    .photo-modal-info-city {
        font-size: 14px;
    }

    .photo-modal-info-date {
        font-size: 12px;
    }
}

/* Mobile Landscape View */
@media screen and (max-height: 450px) and (orientation: landscape) {
    .photo-modal {
        max-width: 100vw;
        max-height: 100vh;
        width: 100vw;
        height: 100vh;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: flex-start;
        padding-top: 2.25rem;
        box-sizing: border-box;
    }

    .photo-modal-header {
        top: 2.5rem;
        right: 0.25rem;
    }

    .photo-modal-nav {
        position: fixed;
        top: 40%;
        transform: translateY(-50%);
        padding: 0.5rem;
        display: flex !important; /* Override mobile hiding */
    }

    .photo-modal-prev {
        left: 0.25rem;
    }

    .photo-modal-next {
        right: 0.25rem;
    }

    .photo-modal-image-container {
        max-width: 90vw;
        max-height: 60vh;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .photo-modal-image {
        max-width: 100%;
        max-height: 60vh;
        object-fit: contain;
    }

    .photo-modal-info {
        position: fixed;
        bottom: 0.5rem;
        left: 0.5rem;
        text-align: left;
    }

    .photo-modal-info-city {
        font-size: 12px;
        margin-bottom: 0.25rem;
    }

    .photo-modal-info-date {
        font-size: 10px;
    }
}
