/* YouTube の軽量埋め込み（ファサード）。最初はサムネイル画像と再生ボタンだけを出し、
   押されたときに初めて YouTube のプレイヤー（iframe）を読み込み、モーダルで再生する。.video-frame の中に置く */
.yt-lite {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: #111;
    cursor: pointer;
}

/* サムネイル（4:3 の上下の黒帯は、16:9 の枠に合わせて切り落とす） */
.yt-lite img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: filter 0.2s;
}

/* 再生ボタン：YouTube と同じ形の赤い角丸に白い三角 */
.yt-lite-play {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 68px;
    height: 48px;
    border-radius: 14px;
    background: rgba(33, 33, 33, 0.8);
    transform: translate(-50%, -50%);
    transition: background-color 0.2s;
}

.yt-lite-play::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    border-style: solid;
    border-width: 11px 0 11px 19px;
    border-color: transparent transparent transparent #fff;
    transform: translate(-40%, -50%);
}

.yt-lite:hover .yt-lite-play,
.yt-lite:focus-visible .yt-lite-play {
    background: #f00;
}

.yt-lite:hover img {
    filter: brightness(0.92);
}

.yt-lite:focus-visible {
    outline: 3px solid var(--miku);
    outline-offset: -3px;
}

@media (prefers-reduced-motion: reduce) {
    .yt-lite img,
    .yt-lite-play {
        transition: none;
    }
}

/* --- モーダル（動画をページの上に大きく表示する） --- */
/* 開いている間は、後ろのページをスクロールさせない */
html.yt-modal-open {
    overflow: hidden;
}

.yt-modal {
    /* 画面の幅と高さの両方に収まる 16:9 の大きさ（上の閉じるボタンと下の題名の分を高さから引く） */
    width: min(92vw, 1100px, calc((100svh - 150px) * 16 / 9));
    max-width: none;
    max-height: none;
    margin: auto;
    padding: 0;
    border: 0;
    background: transparent;
    overflow: visible;
}

.yt-modal::backdrop {
    background: rgba(10, 12, 16, 0.86);
}

.yt-modal[open] {
    animation: ytModalIn 0.25s ease-out;
}

.yt-modal-frame {
    position: relative;
    outline: none;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-radius: var(--radius-sm);
    background: #000;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.yt-modal-frame iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.yt-modal-title {
    margin-top: 12px;
    color: #fff;
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.5;
}

/* 閉じるボタン：動画の右上の外側に、白い丸に×印 */
.yt-modal-close {
    position: absolute;
    right: 0;
    bottom: calc(100% + 12px);
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    transition: transform 0.2s;
}

.yt-modal-close::before,
.yt-modal-close::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 18px;
    height: 2px;
    border-radius: 1px;
    background: var(--ink);
    transform: translate(-50%, -50%) rotate(45deg);
}

.yt-modal-close::after {
    transform: translate(-50%, -50%) rotate(-45deg);
}

/* キーボードで選んだときもリングは出さず、マウスを乗せたときと同じく少し大きくする */
.yt-modal-close:hover,
.yt-modal-close:focus-visible {
    outline: none;
    transform: scale(1.08);
}

@keyframes ytModalIn {
    from {
        opacity: 0;
        transform: scale(0.96);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .yt-modal[open] {
        animation: none;
    }

    .yt-modal-close {
        transition: none;
    }
}
