/**
 * KAC Vimeo Player Styles
 * 建設安全教育向け高機能動画プレーヤー
 */

/* コンテナ */
.kac-vimeo-container {
    margin-bottom: 30px;
}

/* プレーヤーラッパー */
.kac-vimeo-wrapper {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

/* プレーヤー本体 */
.kac-vimeo-player {
    width: 100%;
}

.kac-vimeo-player iframe {
    width: 100%;
    aspect-ratio: 16 / 9;
    border: none;
}

/* オーバーレイ（警告メッセージなど） */
.kac-vimeo-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: overlayFadeIn 0.3s ease;
}

@keyframes overlayFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.kac-vimeo-message {
    padding: 20px 40px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    text-align: center;
    max-width: 80%;
}

.kac-vimeo-message.info {
    background: #2A2E39;
    color: white;
}

.kac-vimeo-message.warning {
    background: #D97706;
    color: white;
}

.kac-vimeo-message.error {
    background: #DC2626;
    color: white;
}

.kac-vimeo-message.success {
    background: #059669;
    color: white;
}

/* 進捗バー */
.kac-vimeo-progress-container {
    margin-top: 15px;
}

.kac-vimeo-progress-bar {
    position: relative;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

.kac-vimeo-progress-watched {
    height: 100%;
    background: linear-gradient(90deg, #059669, #4C837A);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.kac-vimeo-progress-required {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #D97706;
    z-index: 1;
}

.kac-vimeo-progress-required::after {
    content: '';
    position: absolute;
    top: -4px;
    left: -3px;
    width: 8px;
    height: 8px;
    background: #D97706;
    border-radius: 50%;
}

.kac-vimeo-progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    font-size: 13px;
    color: #666;
}

.kac-vimeo-current-time,
.kac-vimeo-duration {
    font-family: monospace;
    font-size: 14px;
}

.kac-vimeo-status .completed {
    color: #059669;
    font-weight: 600;
}

.kac-vimeo-status .in-progress {
    color: #666;
}

/* 完了メッセージ */
.kac-vimeo-completion-message {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 15px 20px;
    margin-top: 15px;
    background: linear-gradient(135deg, #059669, #4C837A);
    color: white;
    border-radius: 8px;
    font-weight: 600;
    animation: completionSlideIn 0.5s ease;
}

@keyframes completionSlideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.kac-vimeo-completion-message .material-icons {
    font-size: 24px;
}

/* エラー表示 */
.kac-video-error {
    padding: 40px;
    background: #FEF2F2;
    border: 1px solid #FECACA;
    border-radius: 8px;
    color: #DC2626;
    text-align: center;
    font-weight: 500;
}

/* 完了ボタンの状態 */
#complete-lesson-btn {
    opacity: 0.5;
    cursor: not-allowed;
}

#complete-lesson-btn.ready {
    opacity: 1;
    cursor: pointer;
    animation: buttonPulse 2s infinite;
}

@keyframes buttonPulse {
    0%, 100% {
        box-shadow: 0 4px 15px rgba(5, 150, 105, 0.3);
    }
    50% {
        box-shadow: 0 4px 25px rgba(5, 150, 105, 0.6);
    }
}

/* レスポンシブ */
@media (max-width: 768px) {
    .kac-vimeo-message {
        padding: 15px 20px;
        font-size: 14px;
        max-width: 90%;
    }

    .kac-vimeo-progress-info {
        font-size: 12px;
    }

    .kac-vimeo-completion-message {
        padding: 12px 15px;
        font-size: 14px;
    }
}

/* ==============================================
   スマートフォン横表示・フルスクリーン対応
   ============================================== */

/* フルスクリーンボタン - デフォルト非表示（モバイルのみ表示） */
.kac-vimeo-fullscreen-btn {
    position: absolute;
    bottom: 12px;
    right: 12px;
    width: 44px;
    height: 44px;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: none; /* デフォルト非表示 */
    align-items: center;
    justify-content: center;
    z-index: 50;
    transition: all 0.2s;
}

.kac-vimeo-fullscreen-btn:hover {
    background: rgba(0, 0, 0, 0.9);
}

.kac-vimeo-fullscreen-btn .material-icons {
    font-size: 24px;
    color: white;
}

/* モバイルでのみフルスクリーンボタンを表示 */
@media (max-width: 768px) {
    .kac-vimeo-fullscreen-btn {
        display: flex;
    }
}

/* 横向き案内バナー */
.kac-vimeo-rotate-hint {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    margin-top: 10px;
    background: linear-gradient(135deg, #4C837A 0%, #4C837A 100%);
    color: white;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    animation: rotateHintPulse 3s ease-in-out infinite;
}

@keyframes rotateHintPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.kac-vimeo-rotate-hint .material-icons {
    font-size: 20px;
    animation: rotateIcon 2s ease-in-out infinite;
}

@keyframes rotateIcon {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(90deg); }
    75% { transform: rotate(90deg); }
}

.kac-vimeo-rotate-hint-close {
    background: none;
    border: none;
    color: white;
    padding: 4px;
    margin-left: 8px;
    cursor: pointer;
    opacity: 0.7;
}

.kac-vimeo-rotate-hint-close:hover {
    opacity: 1;
}

/* モバイル縦向き時に横向き案内を表示 */
@media (max-width: 768px) and (orientation: portrait) {
    .kac-vimeo-rotate-hint {
        display: flex;
    }

    .kac-vimeo-fullscreen-btn {
        width: 48px;
        height: 48px;
    }
}

/* モバイル横向き時 */
@media (max-width: 926px) and (orientation: landscape) {
    .kac-vimeo-rotate-hint {
        display: none;
    }

    /* 横向き時はプレーヤーを大きく */
    .kac-vimeo-container {
        margin-bottom: 15px;
    }

    .kac-vimeo-progress-container {
        margin-top: 8px;
    }

    .kac-vimeo-progress-info {
        font-size: 11px;
    }
}

/* フルスクリーンモード */
.kac-vimeo-container.fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 999999 !important;
    background: black !important;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 0 !important;
}

.kac-vimeo-container.fullscreen .kac-vimeo-wrapper {
    height: 100%;
    border-radius: 0;
    box-shadow: none;
}

.kac-vimeo-container.fullscreen .kac-vimeo-player {
    height: 100%;
}

.kac-vimeo-container.fullscreen .kac-vimeo-player iframe {
    height: 100%;
    aspect-ratio: auto;
}

.kac-vimeo-container.fullscreen .kac-vimeo-progress-container {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.8);
    padding: 10px 15px;
    margin: 0;
}

.kac-vimeo-container.fullscreen .kac-vimeo-progress-info {
    color: white;
}

.kac-vimeo-container.fullscreen .kac-vimeo-fullscreen-btn {
    bottom: 70px;
}

.kac-vimeo-container.fullscreen .kac-vimeo-fullscreen-btn .material-icons::before {
    content: 'fullscreen_exit';
}

.kac-vimeo-container.fullscreen .kac-vimeo-completion-message,
.kac-vimeo-container.fullscreen .kac-vimeo-rotate-hint {
    display: none;
}

/* iOS Safari用の追加対応 */
@supports (-webkit-touch-callout: none) {
    .kac-vimeo-container.fullscreen {
        height: -webkit-fill-available;
    }
}

/* フルスクリーン時の閉じるボタン */
.kac-vimeo-fullscreen-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 44px;
    height: 44px;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.kac-vimeo-container.fullscreen .kac-vimeo-fullscreen-close {
    display: flex;
}

.kac-vimeo-fullscreen-close .material-icons {
    font-size: 24px;
    color: white;
}

/* ダークモード対応 */
@media (prefers-color-scheme: dark) {
    .kac-vimeo-progress-bar {
        background: #424242;
    }

    .kac-vimeo-progress-info {
        color: #bbb;
    }
}

/* 印刷時は非表示 */
@media print {
    .kac-vimeo-container {
        display: none;
    }
}
