/* 漫画ページネーション機能 CSS */

/* メインコンテナ */
.manga-pagination-container {
    margin: 20px 0;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* ページ表示エリア */
.manga-pages {
    position: relative;
    min-height: 400px;
}

.manga-page {
    display: none;
    padding: 20px;
    text-align: center;
}

.manga-page.active {
    display: block;
}

.manga-page img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* ページネーションコントロール */
.pagination-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #f8f9fa;
    border-top: 1px solid #e0e0e0;
}

.pagination-controls button {
    padding: 8px 16px;
    border: 1px solid #007cba;
    background: #007cba;
    color: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
}

.pagination-controls button:hover:not(:disabled) {
    background: #005a87;
    border-color: #005a87;
}

.pagination-controls button:disabled {
    background: #ccc;
    border-color: #ccc;
    cursor: not-allowed;
}

.page-info {
    font-weight: bold;
    color: #333;
    font-size: 14px;
}

/* AMP用スタイル */
.manga-pages-amp {
    margin: 20px 0;
}

.manga-page-amp {
    margin-bottom: 30px;
    padding: 20px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #fff;
}

.manga-page-amp h3 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 18px;
    border-bottom: 2px solid #007cba;
    padding-bottom: 8px;
}

/* 広告モーダル（スマホのみ） */
.manga-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    position: relative;
    background: white;
    border-radius: 8px;
    max-width: 90%;
    max-height: 80%;
    overflow: auto;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 24px;
    font-weight: bold;
    color: #666;
    cursor: pointer;
    z-index: 10000;
    line-height: 1;
}

.modal-close:hover {
    color: #000;
}

.ad-content {
    padding: 20px;
    text-align: center;
}

/* 広告プレースホルダー */
.manga-ad-placeholder {
    text-align: center;
    padding: 20px;
}

.manga-ad-placeholder h4 {
    margin: 0 0 10px 0;
    color: #333;
    font-size: 18px;
}

.manga-ad-placeholder p {
    margin: 0 0 20px 0;
    color: #666;
    font-size: 14px;
}

.ad-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.ad-button {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 5px;
    text-decoration: none;
    font-weight: bold;
    transition: all 0.3s ease;
    min-width: 120px;
}

.ad-button.primary {
    background: #007cba;
    color: white;
    border: 1px solid #007cba;
}

.ad-button.primary:hover {
    background: #005a87;
    border-color: #005a87;
}

.ad-button.secondary {
    background: transparent;
    color: #007cba;
    border: 1px solid #007cba;
}

.ad-button.secondary:hover {
    background: #007cba;
    color: white;
}

/* レスポンシブ対応 */
@media (min-width: 769px) {
    /* デスクトップでは広告モーダルを非表示 */
    .manga-modal {
        display: none !important;
    }
    
    .manga-pagination-container {
        max-width: 800px;
        margin: 20px auto;
    }
    
    .manga-page {
        padding: 30px;
    }
}

@media (max-width: 768px) {
    /* スマホ用スタイル */
    .manga-pagination-container {
        margin: 10px 0;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
    
    .manga-page {
        padding: 15px;
    }
    
    .pagination-controls {
        padding: 12px 15px;
    }
    
    .pagination-controls button {
        padding: 10px 16px;
        font-size: 16px;
        min-width: 80px;
    }
    
    .page-info {
        font-size: 16px;
    }
    
    .modal-content {
        max-width: 95%;
        margin: 10px;
    }
    
    .ad-content {
        padding: 15px;
    }
}

/* Cocoonテーマとの調和 */
.manga-pagination-container {
    font-family: inherit;
}

.manga-pagination-container * {
    box-sizing: border-box;
}

/* 読み込み状態 */
.manga-page.loading {
    position: relative;
}

.manga-page.loading::after {
    content: "読み込み中...";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #666;
    font-size: 14px;
}

/* 遅延読み込み */
.manga-page.lazy-load img[data-src] {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.manga-page.lazy-load img[data-src].loaded {
    opacity: 1;
}

/* 画像読み込みエラー */
.manga-page img.error {
    border: 2px dashed #ccc;
    background: #f9f9f9;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 14px;
}

.manga-page img.error::after {
    content: "画像の読み込みに失敗しました";
}

/* アニメーション */
.manga-page {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.manga-page.active {
    opacity: 1;
}

.pagination-controls button {
    transform: scale(1);
    transition: transform 0.2s ease;
}

.pagination-controls button:active {
    transform: scale(0.95);
}
