/* ギャラリーコンテナ */
.gallery-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 60px 20px;
    background-color: #ffffff;
    width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}

* {
    box-sizing: border-box;
}

/* フィルターコントロール */
.filter-controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 40px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 10px 25px;
    background-color: #f5f5f5;
    border: 2px solid transparent;
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.filter-btn:hover {
    background-color: #e0e0e0;
}

.filter-btn.active {
    background-color: #333;
    color: #fff;
    border-color: #333;
}

/* ギャラリーグリッド */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    grid-auto-flow: dense;
    width: 100%;
    align-items: center;
}

@media (max-width: 768px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: 15px;
    }
}

@media (max-width: 480px) {
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
}

@media (max-width: 360px) {
    .gallery-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
}

/* ギャラリーアイテム */
.gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    aspect-ratio: 3/4;
    width: 100%;
    height: auto;
}

.gallery-item.landscape {
    aspect-ratio: 4/3;
}

.gallery-item.zine {
    aspect-ratio: 1/1.4;
}

.gallery-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
    border-radius: 4px;
}

.gallery-item:hover img {
    transform: scale(1.05);
}

@media (max-width: 768px) {
    .gallery-item {
        aspect-ratio: auto;
        height: auto;
        min-height: 200px;
    }

    .gallery-item img {
        width: 100%;
        height: auto;
        max-width: 100%;
        object-fit: contain;
        max-height: 400px;
    }
}

@media (max-width: 480px) {
    .gallery-item {
        min-height: 150px;
    }

    .gallery-item img {
        max-height: 250px;
        max-width: 100%;
    }
}

@media (max-width: 360px) {
    .gallery-item {
        min-height: 200px;
    }

    .gallery-item img {
        max-height: 300px;
    }
}

/* Zineバッジ */
.gallery-item.zine::before {
    content: 'ZINE';
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 5px 12px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    z-index: 2;
}

/* EPUBバッジ */
.gallery-item.epub::before {
    content: 'EPUB';
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 5px 12px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    z-index: 2;
}

/* EPUBアイテムのアスペクト比 */
.gallery-item.epub {
    aspect-ratio: 1/1.4;
}

/* リンクアイコン */
.gallery-link {
    position: absolute;
    top: 10px;
    left: 10px;
    background-color: rgba(255, 255, 255, 0.9);
    color: #333;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    text-decoration: none;
    z-index: 3;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.gallery-link:hover {
    background-color: #fff;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Lightbox（画像用） */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.lightbox.active {
    display: flex;
}

.lightbox-image {
    max-width: calc(100% - 120px);
    max-height: calc(100vh - 100px);
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 4px;
}

.lightbox-close,
.lightbox-prev,
.lightbox-next {
    position: absolute;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 30px;
    cursor: pointer;
    padding: 10px 20px;
    border-radius: 5px;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
}

.lightbox-close {
    top: 20px;
    right: 20px;
}

.lightbox-prev {
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
}

.lightbox-next {
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
}

.lightbox-caption {
    display: none;
}

/* Book Viewer（Zine用 - 見開き形式） */
.book-viewer {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    z-index: 1000;
    flex-direction: column;
}

.book-viewer.active {
    display: flex;
}

.book-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background-color: rgba(0, 0, 0, 0.9);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-wrap: wrap;
    gap: 15px;
}

.book-close {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 30px;
    cursor: pointer;
    padding: 5px 15px;
    border-radius: 5px;
    transition: all 0.3s ease;
    line-height: 1;
}

.book-close:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
}

.book-navigation {
    display: flex;
    align-items: center;
    gap: 15px;
}

.book-prev,
.book-next {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 8px 15px;
    border-radius: 5px;
    transition: all 0.3s ease;
}

.book-prev:hover,
.book-next:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
}

.book-prev:disabled,
.book-next:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.book-page-info {
    color: white;
    font-size: 16px;
    font-weight: 500;
    min-width: 100px;
    text-align: center;
}

.book-content {
    flex: 1;
    overflow: auto;
    -webkit-overflow-scrolling: touch; /* スムーズスクロール（iOS） */
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
    height: calc(100vh - 71px);
}

.book-spread {
    display: flex;
    gap: 0;
    align-items: center;
    justify-content: center;
    perspective: 1500px;
    max-width: calc(100vw - 20px);
    max-height: calc(100vh - 91px);
    width: 100%;
    height: 100%;
}

.book-page {
    background: white;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.book-page-left {
    border-right: none;
    box-shadow: -5px 0 15px rgba(0, 0, 0, 0.3);
}

.book-page-right {
    border-left: none;
    box-shadow: 5px 0 15px rgba(0, 0, 0, 0.3);
}

.book-spine {
    width: 2px;
    height: 100%;
    background: linear-gradient(to right,
        rgba(0, 0, 0, 0.4),
        rgba(0, 0, 0, 0.2),
        rgba(0, 0, 0, 0.4));
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    z-index: 10;
}

#bookCanvasLeft,
#bookCanvasRight {
    display: block;
    max-width: calc(50vw - 15px);
    max-height: calc(100vh - 95px);
    width: auto;
    height: auto;
    object-fit: contain;
}

.book-caption {
    display: none;
}

/* アニメーション */
.gallery-item.hidden {
    display: none;
}

.gallery-item.fade-in {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* EPUB Viewer（電子書籍用） */
.epub-viewer {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    z-index: 1000;
    flex-direction: column;
}

.epub-viewer.active {
    display: flex;
}

.epub-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background-color: rgba(0, 0, 0, 0.9);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-wrap: wrap;
    gap: 15px;
}

.epub-close {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 30px;
    cursor: pointer;
    padding: 5px 15px;
    border-radius: 5px;
    transition: all 0.3s ease;
    line-height: 1;
}

.epub-close:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
}

.epub-navigation {
    display: flex;
    align-items: center;
    gap: 15px;
}

.epub-prev,
.epub-next {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 8px 15px;
    border-radius: 5px;
    transition: all 0.3s ease;
}

.epub-prev:hover,
.epub-next:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
}

.epub-prev:disabled,
.epub-next:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.epub-page-info {
    color: white;
    font-size: 16px;
    font-weight: 500;
    min-width: 100px;
    text-align: center;
}

.epub-content {
    flex: 1;
    overflow: auto;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    background-color: rgba(0, 0, 0, 0.95);
}

.epub-content > div {
    max-width: 90vw;
    max-height: 80vh;
    width: 100%;
    height: 100%;
    background: white;
    border-radius: 4px;
}

.epub-caption {
    display: none;
}

@media (min-width: 481px) and (max-width: 768px) {
    .epub-controls {
        padding: 12px 15px;
    }

    .epub-content {
        padding: 10px;
    }

    .epub-content > div {
        max-width: calc(100vw - 40px);
        max-height: calc(100vh - 100px);
    }
}

@media (max-width: 480px) {
    .epub-controls {
        padding: 8px 10px;
    }

    .epub-close {
        font-size: 20px;
        padding: 3px 10px;
    }

    .epub-prev,
    .epub-next {
        font-size: 16px;
        padding: 5px 10px;
    }

    .epub-content {
        padding: 5px;
    }

    .epub-content > div {
        max-width: calc(100vw - 10px);
        max-height: calc(100vh - 80px);
    }
}

/* Iframe Zine Viewer */
.iframe-viewer {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    z-index: 1000;
    flex-direction: column;
}

.iframe-viewer.active {
    display: flex;
}

.iframe-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background-color: rgba(0, 0, 0, 0.9);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.iframe-close {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 30px;
    cursor: pointer;
    padding: 5px 15px;
    border-radius: 5px;
    transition: all 0.3s ease;
    line-height: 1;
}

.iframe-close:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
}

.iframe-title {
    color: white;
    font-size: 18px;
    font-weight: 500;
}

.iframe-content {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
    overflow: auto;
    height: calc(100vh - 71px);
}

#zineIframe {
    width: 792px;
    height: 612px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
    border: 0;
}

/* タブレット対応 (769px以上1024px以下) */
@media (min-width: 769px) and (max-width: 1024px) {
    .gallery-container {
        padding: 50px 20px;
    }

    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 18px;
    }

    .lightbox-image {
        max-width: calc(100% - 100px);
        max-height: calc(100vh - 100px);
    }

    #bookCanvasLeft,
    #bookCanvasRight {
        max-width: calc(45vw - 40px);
        max-height: calc(100vh - 140px);
    }

}

/* タブレット対応 (481px以上768px以下) */
@media (min-width: 481px) and (max-width: 768px) {
    .gallery-container {
        padding: 40px 15px;
    }

    .filter-btn {
        padding: 8px 16px;
        font-size: 13px;
    }

    .lightbox {
        padding: 15px;
    }

    .lightbox-image {
        max-width: calc(100vw - 100px) !important;
        max-height: calc(100vh - 100px) !important;
    }

    .lightbox-close {
        top: 10px;
        right: 10px;
        font-size: 24px;
        padding: 5px 12px;
    }

    .lightbox-prev,
    .lightbox-next {
        font-size: 20px;
        padding: 8px 12px;
        bottom: 20px;
        top: auto;
        transform: none;
    }

    .lightbox-prev {
        left: 10px;
    }

    .lightbox-next {
        right: 10px;
    }

    .book-controls {
        padding: 10px 15px;
    }

    .book-close {
        font-size: 24px;
        padding: 4px 12px;
    }

    .book-prev,
    .book-next {
        font-size: 18px;
        padding: 6px 12px;
    }

    .book-content {
        padding: 10px;
        height: calc(100vh - 61px);
    }

    .book-spread {
        flex-direction: column;
        gap: 10px;
        max-width: calc(100vw - 20px);
        max-height: calc(100vh - 81px);
    }

    .book-spine {
        width: 100%;
        height: 2px;
    }

    #bookCanvasLeft,
    #bookCanvasRight {
        max-width: calc(100vw - 30px);
        max-height: calc(50vh - 50px);
    }

    .iframe-controls {
        padding: 10px 15px;
    }

    .iframe-close {
        font-size: 24px;
        padding: 4px 12px;
    }

    .iframe-title {
        font-size: 16px;
    }

    .iframe-content {
        padding: 10px;
        height: calc(100vh - 61px);
    }

}

/* スマホ対応 (480px以下) */
@media (max-width: 480px) {
    .gallery-container {
        padding: 30px 10px;
        background-color: #ffffff;
    }

    .gallery-item {
        display: block;
        opacity: 1;
        visibility: visible;
    }

    .filter-controls {
        gap: 6px;
        padding: 0 5px;
        margin-bottom: 20px;
    }

    .filter-btn {
        padding: 6px 10px;
        font-size: 11px;
        letter-spacing: 0.5px;
    }

    .lightbox {
        padding: 5px;
    }

    .lightbox-image {
        max-width: calc(100vw - 20px) !important;
        max-height: calc(100vh - 100px) !important;
    }

    .lightbox-close {
        top: 5px;
        right: 5px;
        font-size: 20px;
        padding: 3px 10px;
    }

    .lightbox-prev,
    .lightbox-next {
        font-size: 18px;
        padding: 6px 10px;
        bottom: 10px;
    }

    .lightbox-prev {
        left: 5px;
    }

    .lightbox-next {
        right: 5px;
    }

    /* Iframe Viewer - スマホ最適化 */
    .iframe-controls {
        padding: 8px 10px;
    }

    .iframe-close {
        font-size: 20px;
        padding: 3px 10px;
    }

    .iframe-title {
        font-size: 13px;
    }

    .iframe-content {
        padding: 5px;
        height: calc(100vh - 53px);
    }


    /* Book Viewer - スマホ最適化 */
    .book-controls {
        padding: 8px 10px;
        gap: 10px;
    }

    .book-close {
        font-size: 20px;
        padding: 3px 10px;
    }

    .book-prev,
    .book-next {
        font-size: 16px;
        padding: 5px 10px;
    }

    .book-content {
        padding: 5px;
        height: calc(100vh - 53px);
    }

    .book-spread {
        max-width: calc(100vw - 10px);
        max-height: calc(100vh - 63px);
        gap: 8px;
    }

    #bookCanvasLeft,
    #bookCanvasRight {
        max-width: calc(100vw - 20px);
        max-height: calc(48vh - 40px);
    }

    /* ギャラリーアイテム - タッチ操作改善 */
    .gallery-item {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    }

    .gallery-item:active {
        transform: scale(0.98);
    }
}

/* 超小型デバイス (360px以下) */
@media (max-width: 360px) {
    .gallery-container {
        padding: 30px 5px;
    }

    .filter-controls {
        gap: 4px;
    }

    .filter-btn {
        padding: 5px 8px;
        font-size: 10px;
    }

    .lightbox-image {
        max-width: calc(100vw - 10px);
        max-height: calc(100vh - 70px);
    }

    .book-controls {
        padding: 6px 8px;
        gap: 8px;
    }

    .book-close {
        font-size: 18px;
        padding: 2px 8px;
    }

    .book-prev,
    .book-next {
        font-size: 14px;
        padding: 4px 8px;
    }

    .book-content {
        padding: 5px;
        height: calc(100vh - 47px);
    }

    .book-spread {
        max-width: calc(100vw - 10px);
        max-height: calc(100vh - 57px);
    }

    #bookCanvasLeft,
    #bookCanvasRight {
        max-width: calc(100vw - 15px);
        max-height: calc(45vh - 35px);
    }

    .iframe-controls {
        padding: 6px 8px;
    }

    .iframe-close {
        font-size: 18px;
        padding: 2px 8px;
    }

    .iframe-title {
        font-size: 12px;
    }

    .iframe-content {
        padding: 5px;
        height: calc(100vh - 47px);
    }


    h1 {
        font-size: 18px;
    }
}