/*
* -video_player (modal_player.css)
* video_player.htmlと同期
*/
#video-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 1rem;
    box-sizing: border-box;
}

video {
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-user-drag: none;
    pointer-events: auto;
}

a,
video {
    text-decoration: none;
}


#video-modal {
    width: 100%;
    max-width: 1280px;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* -------------------------------------- */
/* 【重要】自動非表示の設定*/
/* -------------------------------------- */

.video-controls {
    transition: opacity 0.3s ease-in-out;
    -webkit-transition: opacity 0.3s ease-in-out;
    -moz-transition: opacity 0.3s ease-in-out;
    -ms-transition: opacity 0.3s ease-in-out;
    -o-transition: opacity 0.3s ease-in-out;
}

#video-modal.is-inactive .video-controls {
    opacity: 0;
    pointer-events: none;
}

/* -------------------------------------- */
/* ヘッダー */
/* -------------------------------------- */
#player-header {
    position: absolute;
    top: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0em 0rem 0em;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0));
    color: #fff;
    font-size: 1rem;
    z-index: 2;
    height: 1.8em;
    box-sizing: content-box;
    transition: opacity 0.3s ease-in-out;
    pointer-events: auto;
}

#player-header button {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0em 1em 0em 0em;
}

#video-title {
    padding: 0em 0em 0em 1em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 動画コンテナ */
#player-container {
    flex: 1;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #000;
    position: relative;
    color: crimson;
}

#youtube-player {
    position: relative;
    overflow: hidden;
}

.youtube-guard {
    position: absolute;
    inset: 0;
    z-index: 9999;
    pointer-events: auto;
    background: transparent;
}


#player-container video,
#player-container iframe {
    width: 100%;
    height: 100%;
    object-fit: contain;
    aspect-ratio: 16/9;
}

/* -------------------------------------- */
/* コントロールバー */
/* -------------------------------------- */
.video-controls {
    position: absolute;
    bottom: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.6);
    /* 初期表示時の背景 */
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.3rem 0.5rem;
    box-sizing: border-box;
    /* transition: opacity 0.3s ease-in-out; は上に移動済み */
    z-index: 3;
    /* ヘッダーより上に配置 */
}

.left-controls,
.right-controls {
    display: flex;
    align-items: center;
}

.time-display {
    color: #fff;
    font-size: 0.85rem;
    margin-left: 0.3rem;
}

.seek-wrapper {
    flex: 1;
    margin: 0 0.5rem;
    position: relative;
}

#seek-bar {
    width: 100%;
    cursor: pointer;
}

#buffer-bar {
    position: absolute;
    top: 50%;
    left: 0;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    pointer-events: none;
    transform: translateY(-50%);
    width: 0;
}

/* ボタン類 */
.video-controls button {
    background: transparent;
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 1.2rem;
    margin: 0 0.2rem;
    padding: 0px 0px 5px 0px;
}

.vol-container {
    position: absolute;
    bottom: 40px;
    right: 0.5rem;
    background: rgba(0, 0, 0, 0.9);
    color: #fff;
    padding: 0.5rem 1em;
    border-radius: 4px;
    font-size: 0.85rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    z-index: 4;
}

#volume-bar {
    writing-mode: vertical-lr;
    direction: rtl;
    height: 150px;
    width: 8px;
}

#settings-btn {
    padding: 0px 0px 5px 9px;
}

#pip-btn {
    padding: 5px 0px 0px 0px;
}

#fullscreen-btn {
    padding-bottom: 3px;
}

/* 設定メニュー */
.video-settings-menu {
    position: absolute;
    bottom: 40px;
    right: 0.5rem;
    background: rgba(0, 0, 0, 0.9);
    color: #fff;
    padding: 0.5rem 1em;
    border-radius: 4px;
    font-size: 0.85rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    z-index: 4;
    /* コントロールバーより上に配置 */
}

.label-st {
    padding: 1em 0.5em;
    text-align: center;
}

.video-settings-menu label {
    margin-right: 0.3rem;
}

.video-settings-menu select {
    background: #222;
    color: #fff;
    border: none;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
}

/* -------------------------------------- */
/* モバイル対応 */
/* -------------------------------------- */
@media screen and (max-width: 768px) {
    #video-modal {
        width: 100%;
        max-width: 100%;
    }

    #volume-bar {
        display: none;
    }

    .video-controls {
        padding: 0.2rem 0.3rem;
    }

    .time-display {
        font-size: 0.75rem;
    }

    .video-settings-menu {
        font-size: 0.75rem;
    }
}

/* 新しく追加するボタンのスタイルを調整 (ここではインラインで定義) */
.back-to-detail {
    display: block;
    width: fit-content;
    margin: 20px auto;
    padding: 10px 20px;
    background-color: #3f51b5;
    /* 主要な色 */
    color: white;
    text-decoration: none;
    border-radius: 5px;
    font-size: 16px;
    text-align: center;
    transition: background-color 0.3s;
}

.back-to-detail:hover {
    background-color: #303f9f;
}

/* =======================
   🎬 YouTube風エラーデザイン
   ======================= */
.error-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    flex-direction: column;
    animation: fadeIn 0.3s ease-in;
}

.error-box {
    background: rgba(18, 18, 18, 0.95);
    color: #fff;
    text-align: center;
    padding: 30px 40px;
    border-radius: 10px;
    border: 1px solid #333;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6);
    max-width: 400px;
}

.error-icon {
    font-size: 3rem;
    color: #ff4d4d;
    margin-bottom: 10px;
    text-shadow: 0 0 10px rgba(255, 50, 50, 0.6);
}

.error-box h2 {
    font-size: 1.3em;
    margin-bottom: 10px;
    color: #fff;
}

.error-box p {
    font-size: 0.95em;
    margin: 8px 0;
    color: #ccc;
}

.tech-info {
    font-size: 0.85em;
    color: #999;
    margin-top: 10px;
    border-top: 1px solid #333;
    padding-top: 8px;
}

.close-button {
    margin-top: 15px;
    padding: 10px 25px;
    font-size: 1em;
    background: #cc0000;
    border: none;
    border-radius: 6px;
    color: #fff;
    cursor: pointer;
    transition: 0.2s;
}

.close-button:hover {
    background: #ff3333;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}