/* 離脱ポップアップ用CSS */

/* スクロール無効化 */
body.exit-popup-scroll-disabled {
    overflow: hidden;
}

/* オーバーレイ */
.exit-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 9999;
    display: none; /* 初期状態は完全に非表示 */
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.exit-popup-overlay.show {
    opacity: 1;
    visibility: visible;
}

/* ポップアップコンテナ */
.exit-popup-container {
    position: relative;
    max-width: 450px;
    max-height: 575px;
    min-width: 200px; /* 最小幅を設定 */
    min-height: 200px; /* 最小高さを設定 */
    transform: scale(0.8);
    transition: transform 0.3s ease;
    /* アスペクト比を保持しつつ、コンテナ内に収める */
    display: flex;
    align-items: center;
    justify-content: center;
}

.exit-popup-overlay.show .exit-popup-container {
    transform: scale(1);
}

/* 閉じるボタン */
.exit-popup-close {
    position: absolute;
    top: -15px;
    right: -15px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background-color: #fff;
    border: 2px solid #ddd;
    font-size: 18px;
    font-weight: bold;
    color: #666;
    cursor: pointer;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.exit-popup-close:hover {
    background-color: #f5f5f5;
    border-color: #999;
    color: #333;
    transform: scale(1.1);
}

.exit-popup-close:active {
    transform: scale(0.95);
}

/* バナー画像 */
.exit-popup-banner {
    display: block;
    width: 100%;
    height: 100%;
    text-decoration: none;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease;
}

.exit-popup-banner:hover {
    transform: scale(1.02);
}

.exit-popup-banner img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain; /* アスペクト比を保持してコンテナ内に収める */
    display: block;
    border-radius: 8px;
    /* 画像の品質を保持 */
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .exit-popup-container {
        max-width: 95%;
        max-height: 95%;
    }
    
    .exit-popup-close {
        width: 35px;
        height: 35px;
        font-size: 20px;
        top: -15px;
        right: -15px;
        line-height: 35px;
    }
}

@media (max-width: 480px) {
    .exit-popup-container {
        max-width: 98%;
        max-height: 98%;
    }
    
    .exit-popup-close {
        width: 30px;
        height: 30px;
        font-size: 18px;
        top: -12px;
        right: -12px;
        line-height: 30px;
    }
}

/* アニメーション用のキーフレーム */
@keyframes exitPopupFadeIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes exitPopupFadeOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.8);
    }
}

/* アクセシビリティ対応 */
.exit-popup-close:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

.exit-popup-banner:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* プリローダー用（画像読み込み中） */
.exit-popup-loading {
    position: relative;
}

.exit-popup-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007cba;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
