/* --- 1. 基本レイアウトとコンテナ --- */
.pkvs-container {
    position: relative;
    margin-top: 20px;
    /* 既存テーマとの干渉を避けるため、可能な限り詳細度を高める */
}

/* 既存テーマの見出しスタイル調整（テンプレートでクラス適用済み） */
/* 既存のテーマCSSがこれを上書きする可能性があるため、必要に応じて!importantを使用 */
.pkvs-division-section .pkvs-division-title {
    margin-top: 50px !important;
}
.pkvs-division-section .pkvs-division-title .sgb-heading__inner {
    /* 提供されたHTMLソースにあるスタイルを再現 */
    background-color: #5ba9f7 !important;
    border-color: #FFF !important;
    font-size: 1.2em !important;
    margin-bottom: 15px;
}
.pkvs-division-section .pkvs-division-title .sgb-heading__text {
    color: #FFF !important;
}
.pkvs-division-section {
    margin-bottom: 60px;
}

/* コンテスト概要エリア */
.pkvs-intro {
    background-color: #f8f9fa;
    padding: 25px;
    border-radius: 8px;
    margin-bottom: 40px;
    border-left: 6px solid #5ba9f7;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.pkvs-intro p {
    line-height: 1.7;
}
.pkvs-voting-rules ol {
    padding-left: 20px;
    margin-top: 10px;
}
.pkvs-voting-rules li {
    margin-bottom: 8px;
    line-height: 1.6;
}


/* --- 2. ローディングオーバーレイ --- */
#pkvs-loading-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10000; /* 他の要素より前面に */
    transition: opacity 0.5s ease-out;
    text-align: center;
}
.pkvs-spinner {
    border: 5px solid #f3f3f3;
    border-top: 5px solid #5ba9f7;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: pkvs-spin 1s linear infinite;
    margin-bottom: 20px;
}
@keyframes pkvs-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* --- 3. 作品グリッドとアイテム（レスポンシブ） --- */
.pkvs-artworks-grid {
    display: grid;
    /* PCでは2列、スマホでは1列。最小幅300px程度を確保し、利用可能なスペースを均等に分割 */
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 40px 30px; /* 行間と列間のスペース */
}
.pkvs-artwork-item {
    background-color: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column; /* カードの高さを揃えるためflexboxを使用 */
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    overflow: hidden; /* 角丸からはみ出さないように */
}
.pkvs-artwork-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 25px rgba(0, 0, 0, 0.1);
}

/* 投票済み状態の強調表示 */
.pkvs-artwork-item.is-voted {
    border: 2px solid #28a745; /* 成功を示す緑色 */
    box-shadow: 0 8px 20px rgba(40, 167, 69, 0.2);
}
/* 投票不可状態（他作品に投票済み） */
.pkvs-artwork-item.is-disabled {
    opacity: 0.65;
   /* pointer-events: none;ホバー効果やクリックを無効化 動画は見れるようにする*/
   box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    transform: none;
}
/* 投票後も動画は見れるようにするため、投稿のみ押せない仕様にします*/
.pkvs-artwork-item.is-disabled .pkvs-vote-button {
    pointer-events: none;
    background-color: #ccc;
    cursor: not-allowed;
}

/* --- 4. 動画プレイヤーとプレースホルダー --- */
.pkvs-video-wrapper {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 アスペクト比 */
    background-color: #000;
    height: 0;
}
.pkvs-video-placeholder, .pkvs-youtube-player {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
}
.pkvs-video-placeholder {
    background-size: cover;
    background-position: center;
    cursor: pointer;
    opacity: 0; /* 初期状態は非表示（JSでロード後に表示） */
    transition: opacity 0.5s ease;
}
/* サムネイルロード完了後のフェードイン */
.pkvs-video-placeholder.loaded {
    opacity: 1;
}

.pkvs-play-button {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 68px; height: 48px;
    background: none; border: none;
    cursor: pointer;
    transition: transform 0.2s ease;
}
.pkvs-play-button:hover {
    transform: translate(-50%, -50%) scale(1.1);
}
.pkvs-play-button:hover .youtube-play-button-bg {
    fill: #f00; /* YouTubeレッド */
    fill-opacity: 1;
}

/* --- 5. 作品情報とコメント --- */
.pkvs-caption {
    padding: 20px;
    flex-grow: 1; /* 作品情報エリアが伸びてカードの高さを確保 */
}
.pkvs-entry-title {
    font-size: 1.1em;
    font-weight: bold;
    margin: 0 0 10px 0 !important; /* テーマのmarginを上書き */
    line-height: 1.4;
}
.pkvs-artist-info {
    font-size: 0.9em;
    color: #666;
}

.pkvs-author-comment {
    padding: 0 20px 20px 20px;
    margin-top: 10px;
}
.pkvs-author-comment summary {
    cursor: pointer;
    color: #5ba9f7;
    font-weight: bold;
    /* list-style: disc; テーマによっては矢印が消えるため、必要なら指定 */
}
.pkvs-author-comment summary:hover {
    text-decoration: underline;
}
.pkvs-comment-content {
    font-size: 0.85em;
    margin-top: 10px;
    padding: 15px;
    background-color: #f9f9f9;
    border-radius: 5px;
    line-height: 1.6;
}

/* --- 6. 投票ボタンとUX（最重要） --- */
.pkvs-vote-area {
    padding: 15px 20px;
    margin-top: auto; /* flexboxで下部に固定 */
    text-align: center;
    border-top: 1px solid #f0f0f0;
    background-color: #fafafa;
}
.pkvs-vote-button {
    width: 100%;
    padding: 14px 20px;
    font-size: 1.05em;
    font-weight: bold;
    color: white;
    border: none;
    border-radius: 50px; /* 丸みを持たせる */
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}
.pkvs-vote-button .dashicons {
    margin-right: 8px;
    transition: transform 0.3s ease;
    font-size: 1.2em;
}

/* ボタンの状態管理 */
.pkvs-vote-button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
    opacity: 1; /* iOSでのデフォルトopacity変更を無効化 */
}

/* 投票可能状態（感動を表現するカラーとアニメーション） */
.pkvs-vote-button.is-ready {
    /* 情熱的な赤のグラデーション */
    background: linear-gradient(45deg, #ff4757, #e63946);
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(255, 71, 87, 0.4);
}
.pkvs-vote-button.is-ready:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 71, 87, 0.6);
}
.pkvs-vote-button.is-ready:hover .dashicons {
    /* ハートがドキドキするような動き */
    transform: scale(1.2) rotate(-10deg);
}

/* 視聴完了後のアピールアニメーション（パルス効果） */
.pkvs-vote-button.glow-animation {
    animation: pkvs-pulseGlow 2s infinite alternate;
}
@keyframes pkvs-pulseGlow {
    from { box-shadow: 0 0 5px rgba(233, 30, 99, 0.5), 0 4px 15px rgba(255, 71, 87, 0.4); }
    to { box-shadow: 0 0 20px rgba(233, 30, 99, 1), 0 4px 15px rgba(255, 71, 87, 0.4); }
}

/* 投票済み状態 */
.pkvs-vote-button.voted-button {
    background: linear-gradient(45deg, #28a745, #218838);
    box-shadow: 0 4px 15px rgba(40, 167, 69, 0.4);
}

/* 投票プロンプトメッセージ */
.pkvs-vote-prompt {
    font-size: 0.85em;
    color: #888;
    margin-top: 8px;
    margin-bottom: 0;
}
.pkvs-vote-prompt.is-ready {
    color: #e63946;
    font-weight: bold;
}

/* --- 7. モーダルウィンドウ --- */
#pkvs-vote-modal {
    position: fixed; z-index: 10001;
    top: 0; left: 0; width: 100%; height: 100%;
    display: none; /* JSで制御 */
    align-items: center; justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.pkvs-modal-backdrop {
    position: absolute;
    width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.7);
}
.pkvs-modal-content {
    background: white; padding: 30px; border-radius: 12px;
    max-width: 500px; width: 90%;
    z-index: 1;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    position: relative;
    text-align: center;
}
#pkvs-modal-close-x {
    position: absolute; top: 10px; right: 15px;
    font-size: 2em; background: none; border: none; cursor: pointer; color: #999;
}
#pkvs-modal-close-x:hover {
    color: #333;
}
.pkvs-modal-content .modal-title {
    font-weight: bold; margin: 20px 0; font-size: 1.1em;
    background-color: #f7f7f7; padding: 15px; border-radius: 5px;
    line-height: 1.4;
}
.pkvs-modal-comment-area {
    text-align: left; margin-bottom: 25px;
}
#pkvs-modal-comment {
    width: 100%; height: 90px; margin-top: 8px; padding: 10px;
    border: 1px solid #ccc; border-radius: 5px; box-sizing: border-box;
    resize: vertical;
    font-size: 0.95em;
}
.pkvs-modal-actions {
    display: flex; justify-content: space-between; gap: 15px;
}
.pkvs-modal-actions button {
    width: 100%;
    padding: 12px 10px;
}
/* WordPress標準ボタンクラスのスタイル調整（テーマに合わせて適宜変更） */
.button.button-primary {
    background-color: #5ba9f7; border-color: #5ba9f7; color: white;
    text-shadow: none; box-shadow: none;
}
.button.button-primary:hover {
    background-color: #3c90e8;
}
.button.button-secondary {
    background-color: #f0f0f1; color: #1d2327; border-color: #dcdcde;
}


/* --- 8. メッセージエリア --- */
.pkvs-success-message {
    background-color: #d4edda;
    color: #155724;
    padding: 15px;
    border-radius: 5px;
    text-align: center;
    font-weight: bold;
    border-left: 5px solid #28a745;
    margin-bottom: 30px;
}
.pkvs-status-message {
    padding: 25px;
    text-align: center;
    border-radius: 8px;
    font-size: 1.1em;
    margin: 30px 0;
}
.pkvs-info-message {
    background-color: #cce5ff; color: #004085;
}
.pkvs-error-message {
    background-color: #f8d7da; color: #721c24;
}

/* 16:9 レスポンシブ埋め込み */
.pkvs-video-embed {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;        /* 近代ブラウザ用 */
  background: #000;
}
.pkvs-video-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
