/**
 * Blog Image Gallery Styles
 * Styling for thumbnail gallery and modal view functionality
 */

/* Gallery Container */
.blog-image-gallery {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 1.5rem;
    background-color: #f8f9fa;
    margin: 2rem 0;
}

.gallery-title {
    color: #495057;
    font-weight: 600;
    margin-bottom: 1rem;
    text-align: center;
}

/* Thumbnails Grid */
.gallery-thumbnails {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
    justify-items: center;
}

.gallery-thumbnail {
    position: relative;
    width: 150px;
    height: 150px;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.gallery-thumbnail:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    border-color: #007bff;
}

.gallery-thumbnail:active {
    transform: translateY(0);
}

.thumbnail-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.gallery-thumbnail:hover .thumbnail-image {
    transform: scale(1.05);
}

/* Modal Styles */
.image-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(3px);
}

.image-modal.show {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

.modal-content {
    background-color: #fff;
    margin: 2% auto;
    padding: 0;
    border-radius: 12px;
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e0e0e0;
    background-color: #f8f9fa;
}

.modal-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #495057;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

.modal-close:hover {
    background-color: #e0e0e0;
}

.modal-body {
    padding: 0;
    text-align: center;
    position: relative;
}

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

/* Modal Navigation */
.modal-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background-color: #f8f9fa;
    border-top: 1px solid #e0e0e0;
}

.nav-btn {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background-color 0.2s ease;
    min-width: 80px;
}

.nav-btn:hover:not(:disabled) {
    background-color: #0056b3;
}

.nav-btn:disabled {
    background-color: #6c757d;
    cursor: not-allowed;
    opacity: 0.6;
}

.image-counter {
    font-weight: 600;
    color: #495057;
    font-size: 0.9rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .gallery-thumbnails {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 0.75rem;
    }
    
    .gallery-thumbnail {
        width: 120px;
        height: 120px;
    }
    
    .modal-content {
        width: 95%;
        margin: 1% auto;
        max-height: 95vh;
    }
    
    .modal-header,
    .modal-navigation {
        padding: 0.75rem 1rem;
    }
    
    .modal-title {
        font-size: 1rem;
    }
    
    .nav-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
        min-width: 70px;
    }
    
    .image-counter {
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .gallery-thumbnails {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 0.5rem;
    }
    
    .gallery-thumbnail {
        width: 100px;
        height: 100px;
    }
    
    .blog-image-gallery {
        padding: 1rem;
        margin: 1rem 0;
    }
    
    .gallery-title {
        font-size: 1rem;
    }
    
    .nav-btn {
        padding: 0.3rem 0.6rem;
        font-size: 0.75rem;
        min-width: 60px;
    }
    
    .modal-navigation {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .modal-navigation .nav-btn {
        width: 100%;
        max-width: 120px;
    }
}

/* Loading and Error States */
.thumbnail-image[src=""],
.thumbnail-image:not([src]) {
    background-color: #e9ecef;
    position: relative;
}

.thumbnail-image[src=""]:before,
.thumbnail-image:not([src]):before {
    content: "画像を読み込み中...";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #6c757d;
    font-size: 0.8rem;
}

/* Accessibility */
.gallery-thumbnail:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

.modal-close:focus,
.nav-btn:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .image-modal {
        display: none !important;
    }
    
    .blog-image-gallery {
        break-inside: avoid;
    }
}