@import "../css/common.css";

/* 基本スタイル */
.gallery-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 20px 20px;
}

.button-row {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 24px;
    flex-wrap: wrap;
}

.my-button,
.outline-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 260px;
    padding: 18px 28px;
    border-radius: 999px;
    font-size: 1.1rem;
    font-weight: 700;
    text-decoration: none;
    transition: transform 0.2s ease, background-color 0.2s ease;
}

.my-button {
    background-color: #4cafef;
    color: #ffffff;
    border: 1px solid transparent;
}

.my-button:hover {
    background-color: #3a94f1;
    transform: translateY(-2px);
}

.outline-button {
    background-color: transparent;
    color: #4cafef;
    border: 1px solid #4cafef;
}

.outline-button:hover {
    background-color: #4cafef;
    color: #ffffff;
    transform: translateY(-2px);
}

.back-link-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: 160px;
    left: 16px;
    right: auto;
    z-index: 1200;
    margin: 0;
    padding: 10px 16px;
    background-color: #007bff;
    color: white;
    border-radius: 999px;
    text-decoration: none;
    font-weight: 600;
}

.back-link-btn:hover {
    background-color: #0056b3;
}

html.modal-open,
body.modal-open {
    overflow: hidden;
}

body.modal-open {
    position: fixed;
    width: 100%;
}

body.modal-open .back-link-btn {
    display: none;
}

.page-title {
    font-size: 2rem;
    font-weight: bold;
    text-align: center;
    margin: 0;
    line-height: 1.5;
    color: #333;
}

.page-description {
    text-align: center;
    color: #666;
    margin: 0;
    line-height: 1.7;
    font-size: 1rem;
}

.page-intro {
    margin-bottom: 32px;
}

.page-intro .page-description + .page-description {
    margin-top: 2px;
}

/* フィルターセクション */
.filter-section {
    background-color: #f5f5f5;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 40px;
    border: 1px solid #e0e0e0;
}

.filter-title {
    font-size: 1.3rem;
    font-weight: bold;
    margin-bottom: 20px;
    color: #333;
}

.filter-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.filter-group label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #333;
}

.filter-input,
.filter-select {
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color 0.3s ease;
}

.filter-input:focus,
.filter-select:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.btn-clear {
    padding: 10px 20px;
    background-color: #666;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.btn-clear:hover {
    background-color: #444;
}

.btn-clear:active {
    transform: scale(0.98);
}

/* 作品一覧 */
.artworks-section {
    position: relative;
}

.artworks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 25px;
    margin-bottom: 40px;
}

/* 作品カード */
.artwork-card {
    background-color: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.artwork-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.artwork-image-container {
    width: 100%;
    height: 250px;
    background-color: #f5f5f5;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.artwork-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-placeholder {
    color: #999;
    font-size: 1rem;
    text-align: center;
}

.artwork-info {
    padding: 15px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.artwork-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.field-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.field-value {
    font-size: 0.95rem;
    color: #333;
    word-break: break-word;
}

.category-tag {
    display: inline-block;
    background-color: #007bff;
    color: white;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    width: fit-content;
}

.artwork-message {
    flex-grow: 1;
}

.message-text {
    font-style: italic;
    color: #555;
    line-height: 1.4;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    z-index: 1000;
}

.modal-backdrop.hidden {
    display: none;
}

.modal-backdrop .modal-card {
    width: calc(100vw - 24px);
    max-width: 480px;
    background: white;
    border-radius: 16px;
    padding: 14px;
    box-sizing: border-box;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    max-height: calc(100vh - 20px) !important;
    overflow-y: auto !important;
}

.modal-backdrop .modal-close-btn {
    position: sticky;
    top: 8px !important;
    right: 10px;
    border: none;
    width: 48px;
    height: 48px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.9);
    font-size: 2rem;
    line-height: 1;
    z-index: 2;
    cursor: pointer;
    margin-left: auto;
    display: block !important;
    flex-shrink: 0;
}

.detail-modal-gallery {
    margin-bottom: 16px;
}

.detail-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 3;
    border: none;
    background: rgba(15, 23, 42, 0.72);
    color: white;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.4rem;
}

#detailModalPrev {
    left: 10px;
}

#detailModalNext {
    right: 10px;
}

.detail-nav-btn:disabled {
    background: #94a3b8;
    cursor: not-allowed;
}

.detail-modal-images {
    position: relative;
    min-height: min(42vh, 300px);
    max-height: min(42vh, 300px);
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f4f6f8;
    border-radius: 12px;
    overflow: hidden;
}

.detail-modal-image {
    width: 100%;
    height: 100%;
    max-height: min(42vh, 300px);
    object-fit: contain;
}

.detail-placeholder {
    color: #999;
}

.detail-image-index {
    text-align: center;
    margin: 0 0 8px;
    color: #64748b;
    font-size: 0.9rem;
}

.modal-title {
    font-size: 1.3rem;
    margin-bottom: 8px;
}

.modal-meta {
    margin: 4px 0;
    color: #555;
}

.modal-backdrop .modal-message {
    margin-top: 10px;
    white-space: pre-wrap;
    line-height: 1.6;
    color: #333;
    min-height: calc(1.6em * 5) !important;
    max-height: calc(1.6em * 5) !important;
    overflow-y: auto !important;
    padding-right: 6px;
}

.scroll-hint {
    display: block;
    width: 100%;
    margin: 6px 0 0;
    height: 1.4em;
    line-height: 1.4;
    white-space: nowrap;
    text-align: left;
    color: #64748b;
    font-size: 0.84rem;
}

.scroll-hint.hidden {
    visibility: hidden;
}

.no-results {
    text-align: center;
    padding: 60px 20px;
    font-size: 1.2rem;
    color: #999;
    display: none;
}

.no-results.show {
    display: block;
}

.loading-message {
    text-align: center;
    padding: 40px 20px;
    font-size: 1rem;
    color: #666;
}

.loading-message.error {
    color: #d32f2f;
    font-weight: bold;
}

/* レスポンシブデザイン */
@media (max-width: 768px) {
    .gallery-container {
        padding: 184px 15px 15px;
    }

    .back-link-btn {
        top: 104px;
        left: 12px;
        right: auto;
    }

    .page-title {
        font-size: 1.5rem;
    }

    .filter-controls {
        grid-template-columns: 1fr;
    }

    .artworks-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 15px;
    }

    .artwork-image-container {
        height: 200px;
    }

    .artwork-info {
        padding: 12px;
        gap: 8px;
    }

    .artwork-field {
        gap: 3px;
    }

    .field-value {
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .gallery-container {
        padding: 192px 10px 10px;
    }

    .back-link-btn {
        top: 104px;
        left: 10px;
        right: auto;
    }

    .page-title {
        font-size: 1.3rem;
        margin-bottom: 5px;
    }

    .page-description {
        margin-bottom: 20px;
        font-size: 0.95rem;
    }

    .filter-section {
        padding: 15px;
        margin-bottom: 20px;
    }

    .filter-title {
        font-size: 1.1rem;
        margin-bottom: 15px;
    }

    .artworks-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .artwork-image-container {
        height: 180px;
    }

    .artwork-info {
        padding: 10px;
    }

    .field-label {
        font-size: 0.8rem;
    }

    .field-value {
        font-size: 0.85rem;
    }
}
