/**
 * モーダル表示用のスタイル
 *
 * @package collemi
 */

/* モーダルの基本スタイル */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* iOSでのスクロール改善 */
    overscroll-behavior: contain; /* スクロール慣性を制御 */
}

/* モーダル表示中のスタイル */
.modal.show {
    display: flex;
    align-items: flex-start; /* 上部寄せに変更して閉じるボタンにアクセスしやすく */
    justify-content: center;
    opacity: 1;
    padding-top: 40px; /* 上部に余白を追加 */
}

/* モーダルコンテンツ */
.modal-content {
    background-color: #fff;
    position: relative;
    width: 85%;
    max-width: 540px; /* 600pxから90%に縮小 */
    padding: 40px 20px 20px; /* 上部のパディングを調整 */
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    margin: 20px auto;
    transition: transform 0.3s ease;
    transform: scale(0.9);
    max-height: 90vh; /* 画面の90%までの高さに制限 */
    overflow-y: auto; /* 高さが超えたらスクロール */
    overscroll-behavior: contain; /* スクロール慣性を制御 */
}

.modal.show .modal-content {
    transform: scale(0.95); /* 少し小さく表示して全体が見やすくなるように */
}

/* 閉じるボタン */
.close-modal {
    position: absolute;
    top: 5px;
    right: 5px;
    font-size: 24px;
    cursor: pointer;
    color: #333; /* より濃い色で視認性向上 */
    transition: all 0.2s;
    z-index: 100; /* より高いz-indexを設定 */
    width: 32px; /* やや大きく */
    height: 32px; /* やや大きく */
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(255, 255, 255, 0.9); /* より不透明に */
    border-radius: 50%; /* 円形にする */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25); /* シャドウを強調 */
}

.close-modal:hover {
    color: #000;
    background-color: #ffffff;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

/* 埋め込みコンテナ */
#embed-container {
    width: 100%;
    overflow: hidden;
    min-height: 200px; /* 高さを増加 */
    padding: 10px 0; /* 余白を調整 */
    position: relative; /* 位置関係を明確に */
    display: flex;
    justify-content: center;
    align-items: center;
}

#embed-container iframe {
    max-width: 100% !important;
    margin: 0 auto !important;
    display: block !important;
    position: relative !important;
    z-index: 1;
}

/* モーダル表示ボタン */
.embed-modal-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: 4px;
    background-color: #f8f8f8;
    border: 1px solid #ddd;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
    margin-right: 8px;
    margin-bottom: 8px;
}

/* .embed-modal-btn:hover {
    background-color: #eee;
    transform: translateY(-2px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
} */

.embed-modal-btn svg {
    width: 16px;
    height: 16px;
}

/* レスポンシブ調整 */
@media (max-width: 767px) {
    .modal-content {
        width: 90%; /* モバイルでは少し広めに */
        max-width: 460px;
        padding: 35px 15px 15px;
        max-height: 85vh; /* モバイルでは少し小さめにして操作性向上 */
    }
    
    .close-modal {
        top: 5px;
        right: 5px;
        width: 36px; /* モバイルでは少し大きく */
        height: 36px;
    }
    
    .embed-modal-btn {
        width: 100%;
        margin-bottom: 10px;
    }
    
    .modal.show {
        padding-top: 40px; /* モバイルでは少し余白を調整 */
    }
    
    /* モバイルでのスクロール体験を向上させる */
    #embed-container {
        -webkit-overflow-scrolling: touch;
    }
}
