/*
================================================================================
   UI-COMPONENTS.CSS - UIコンポーネント・特殊機能
================================================================================
   
   役割：
   - シーズン軌跡可視化コンポーネント
   - AI解説セクションのスタイル
   - ローディング表示とアニメーション
   - 特殊なUI要素とインタラクション
   - アクセシビリティユーティリティ
   
   対象ページ：index.html, player.html
   依存関係：base.css, layout.css
   
================================================================================
*/

/* ===============================
     シーズン軌跡可視化
     =============================== */
.season-form-content {
  width: 100%; /* 80%から100%に変更してチームサマリーテーブルと揃える */
  margin: 0 auto;
}

.season-form-visualization {
  display: flex;
  flex-wrap: nowrap;
  gap: 0; /* セル間隔を0に */
  height: 60px; /* 高さを60pxに変更 */
  overflow-x: auto;
  padding: 10px 0;
  min-height: 60px;
  background-color: #f0f0f0; /* デバッグ用背景色 */
}

.season-form-cell {
  flex: 0 0 auto;
  width: 20px;
  min-width: 20px;
  height: 60px; /* 高さを60pxに変更 */
  border-radius: 0; /* 角丸を削除 */
  cursor: pointer;
  transition: transform 0.2s ease;
  position: relative;
  border: none; /* 枠線を削除 */
  display: block;
  background-color: var(--form-cell-bg, #ccc);
}

.season-form-cell:hover {
  transform: scale(1.1);
  z-index: 10;
}

/* 勝敗の色分け - より強力なセレクタ */
.season-form-visualization .season-form-cell.win {
  background: linear-gradient(
    135deg,
    var(--form-win-dark, #1e3a8a),
    var(--form-win, #3b82f6)
  );
  background-color: var(--form-win, #3b82f6);
}

.season-form-visualization .season-form-cell.draw {
  background: linear-gradient(
    135deg,
    var(--form-draw-light, #f8fafc),
    var(--form-draw, #e2e8f0)
  );
  background-color: var(--form-draw, #e2e8f0);
}

.season-form-visualization .season-form-cell.loss {
  background: linear-gradient(
    135deg,
    var(--form-loss-light, #fecaca),
    var(--form-loss, #dc2626)
  );
  background-color: var(--form-loss, #dc2626);
}

/* ホバー時のツールチップ */
.season-form-cell::after {
  content: attr(data-score);
  position: absolute;
  bottom: 65px; /* 60pxの高さに合わせて調整 */
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.season-form-cell:hover::after {
  opacity: 1;
}

/* ===============================
                 シーズン軌跡可視化（サーモグラフィ風）
                 =============================== */

.season-form-controls {
  margin-bottom: 16px;
}

.control-row {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.control-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--color-text);
  cursor: pointer;
}

.control-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--color-primary);
}

.sigma-control {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.sigma-label {
  font-size: 11px;
  color: var(--color-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

#sigmaSlider {
  width: 100%;
  accent-color: var(--color-primary);
}

#sigmaValue {
  font-size: 11px;
  color: var(--color-muted);
  min-width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.season-form-canvases {
  margin-bottom: 16px;
}

#mainCanvas {
  width: 100%;
  height: 120px; /* 80pxから120pxに変更 */
  display: block;
  background: var(--color-bg);
  border-radius: 12px;
  margin-bottom: 8px;
  border: 1px solid #ddd; /* 枠線を追加 */
}

#cellsCanvas {
  width: 100%;
  height: 24px;
  display: block;
  background: var(--color-bg);
  border-radius: 6px;
  border: 1px solid #ddd; /* 枠線を追加 */
}

.season-form-legend {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding: 4px 0;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: var(--color-panel);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  font-size: 11px;
  color: var(--color-text);
  white-space: nowrap;
  flex-shrink: 0;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.legend-dot.blue {
  background: #0a74ff;
}

.legend-dot.white {
  background: #ffffff;
  border: 1px solid #cbd5e1;
}

.legend-dot.red {
  background: #ff2a2a;
}

/* ===============================
AI解説セクション（選手ページ用）
=============================== */
.ai-comment-section {
  background-color: #f5f8fc;
  border: 1px solid #d0d8e8;
  border-radius: 10px;
  padding: 1rem 1.25rem; /* ← 上下・左右とも少しだけ狭くしたよ♪ */
  margin: 1.5rem 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.ai-comment-header {
  font-size: var(--font-lg);
  font-weight: 600;
  color: var(--color-primary);
  margin-bottom: 0.75rem;
  border-bottom: 2px solid #d0d8e8;
  padding-bottom: 0.3rem;
}

.ai-comment-text {
  font-size: var(--font-md);
  line-height: 1.6;
  color: var(--color-text);
}

/* ===== Loading UI (common) ===== */
.loading-wrap {
  display: flex;
  flex-direction: column; /* ← 改行して縦積み */
  align-items: center; /* ← 水平中央 */
  justify-content: center; /* ← 垂直中央 */
  gap: 0.4rem;
  min-height: 72px; /* レイアウトジャンプ防止 */
  width: 100%;
  text-align: center;
}

.loading-icon {
  width: 48px;
  height: 48px;
  display: inline-block;
}

.loading-text {
  font-size: var(--font-md);
  color: var(--color-text);
  line-height: 1.2;
}

/* 三点リーダを点滅 */
.loading-dots {
  display: inline-block;
}
.loading-dots span {
  display: inline-block;
  animation: loading-blink 1.2s infinite steps(1, end);
}
.loading-dots span:nth-child(2) {
  animation-delay: 0.2s;
}
.loading-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes loading-blink {
  0% {
    opacity: 0;
  }
  33% {
    opacity: 1;
  }
  66% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@media (max-width: 600px) {
  .loading-icon {
    width: 36px;
    height: 36px;
  }
}

/* 動きを減らすユーザー設定への配慮 */
@media (prefers-reduced-motion: reduce) {
  .loading-icon {
    display: none;
  }
  .loading-dots span {
    animation: none;
  }
}

/* スクリーンリーダー向けユーティリティ */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 1, 1);
  white-space: nowrap;
  border: 0;
}
