/* ==========================================================================
   リアルタイムランキング（/ranking/real-time）専用スタイル
   週刊ランキングページ（/ranking/weekly）の使い勝手に寄せる。
   ファイル・クラス名（rtr-）は既存ページと完全分離。配色は base.css の変数を利用。
   構成: PC = 左サイドバー（期間・ジャンル）＋リスト
         スマホ = 右下「ページ設定」ボタン → ボトムシート、カードは「詳細」折り畳みでコンパクト化
   ========================================================================== */

.rtr-shell {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 10px 40px;
}

/* ---- レイアウト（サイドバー＋コンテンツ） ---- */
.rtr-layout {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.rtr-content {
  flex: 1 1 auto;
  min-width: 0;
}

/* ---- サイドバー（週刊ランキングのサイドバーと同デザイン） ---- */
.rtr-sidebar {
  flex: 0 0 230px;
  position: sticky;
  top: 70px;
  max-height: calc(100vh - 90px);
  overflow-y: auto;
}

.rtr-sidebar-mobile-head {
  display: none;
}

.rtr-side-section {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 4px;
  margin-bottom: 12px;
  overflow: hidden;
}

.rtr-side-title {
  background: #f0f0f0;
  padding: 8px 12px;
  font-weight: bold;
  font-size: 13px;
  border-bottom: 1px solid #ddd;
  margin: 0;
}

.rtr-side-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.rtr-side-list-scroll {
  max-height: 400px;
  overflow-y: auto;
}

.rtr-side-list li {
  border-bottom: 1px solid #eee;
}

.rtr-side-list li:last-child {
  border-bottom: none;
}

.rtr-side-list a {
  display: block;
  padding: 7px 12px;
  font-size: 13px;
  color: var(--text-color, #333);
  text-decoration: none;
  transition: background 0.15s;
}

.rtr-side-list a:hover {
  background: #f5f5f5;
}

.rtr-side-list a.is-active {
  background: #4a90d9;
  color: #fff;
  pointer-events: none;
}

/* ---- 検索・絞り込み（サイドバー内） ---- */
.rtr-filter-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
}

.rtr-filter-mode-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.rtr-filter-mode-option {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border: 1px solid #cfe3fb;
  border-radius: 6px;
  background: #f8fbff;
  color: #1d4f8c;
  font-size: 12px;
  line-height: 1.4;
  cursor: pointer;
}

.rtr-filter-mode-option input {
  margin: 0;
  flex-shrink: 0;
}

.rtr-filter-mode-option span {
  font-weight: 600;
}

.rtr-filter-input {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 13px;
  box-sizing: border-box;
}

.rtr-filter-actions {
  display: flex;
  gap: 8px;
}

.rtr-filter-btn {
  flex: 1;
  padding: 7px 10px;
  border: none;
  border-radius: 4px;
  background: #007bff;
  color: #fff;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.rtr-filter-btn:hover {
  background: #0056b3;
}

.rtr-filter-btn-secondary {
  background: #6c757d;
}

.rtr-filter-btn-secondary:hover {
  background: #5a6268;
}

.rtr-filter-btn-secondary:disabled {
  background: #c3c9cf;
  cursor: not-allowed;
}

.rtr-filter-help {
  margin: 0;
  color: #666;
  font-size: 11px;
  line-height: 1.5;
}

.rtr-filter-busy-help {
  margin: 0;
  color: #1d4f8c;
  font-size: 11px;
  line-height: 1.5;
}

.rtr-filter-busy-help[hidden] {
  display: none !important;
}

/* ---- 検索・絞り込みの状態バー（コンテンツ上部） ---- */
.rtr-filter-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  margin-bottom: 10px;
  background: #eef6ff;
  border: 1px solid #cfe3fb;
  border-radius: 6px;
}

.rtr-filter-status[hidden],
.rtr-filter-empty[hidden] {
  display: none !important;
}

.rtr-filter-status-text {
  color: #1d4f8c;
  font-size: 13px;
  font-weight: 600;
}

.rtr-filter-status-clear {
  flex-shrink: 0;
  padding: 5px 12px;
  border: none;
  border-radius: 4px;
  background: #1d4f8c;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.rtr-filter-status-clear:hover {
  background: #163c6a;
}

.rtr-filter-empty {
  margin-bottom: 10px;
  padding: 14px;
  background: #fff5f5;
  border: 1px solid #f1c6c6;
  border-radius: 6px;
  color: #a33;
  font-size: 13px;
  text-align: center;
}

/* ---- メタデータ（折り畳み。週刊ランキングの「メタデータを表示」と同デザイン） ---- */
.rtr-meta-details {
  margin: 0 0 12px;
  padding: 0.75rem 1rem;
  background: #e7f3ff;
  border-left: 4px solid #007bff;
  font-size: 0.875rem;
}

.rtr-meta-details summary {
  cursor: pointer;
  font-weight: bold;
  outline: none;
}

.rtr-meta-body {
  margin-top: 0.75rem;
}

.rtr-meta-body p {
  margin: 0 0 6px;
  line-height: 1.6;
}

.rtr-ago {
  color: #777;
  margin-left: 4px;
}

.rtr-meta-status {
  font-size: 12px;
  color: #b26a00;
}

/* ---- スマホ用ページ設定ボタン・オーバーレイ（PCでは非表示） ---- */
.rtr-mobile-settings-btn {
  display: none;
}

.rtr-sidebar-overlay {
  display: none;
}

/* ---- ランキングリスト ---- */
.rtr-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rtr-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 8px 10px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.rtr-item.rtr-top1 { border-left: 4px solid #d4af37; }
.rtr-item.rtr-top2 { border-left: 4px solid #9fa8b5; }
.rtr-item.rtr-top3 { border-left: 4px solid #b0793f; }

/* 順位 + 変動バッジ */
.rtr-rank {
  flex: 0 0 52px;
  text-align: center;
}

.rtr-rank-num {
  font-size: 20px;
  font-weight: 800;
  color: var(--primary-dark, #004499);
  line-height: 1.1;
}

.rtr-top1 .rtr-rank-num { color: #b8860b; }
.rtr-top2 .rtr-rank-num { color: #6e7b8b; }
.rtr-top3 .rtr-rank-num { color: #8b5a2b; }

.rtr-rank-unit {
  font-size: 11px;
  font-weight: 600;
  margin-left: 1px;
}

.rtr-delta {
  margin-top: 2px;
  font-size: 11.5px;
  font-weight: 700;
}

.rtr-delta.rtr-up,
.rtr-up-inline { color: var(--success-color, #28a745); }
.rtr-delta.rtr-down,
.rtr-down-inline { color: #999; }
.rtr-delta.rtr-stay { color: #666; }
.rtr-delta.rtr-new { color: var(--new-color, #ff3333); }

/* サムネイル */
.rtr-thumb {
  flex: 0 0 96px;
  height: 54px;
  border-radius: 4px;
  overflow: hidden;
  background: #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rtr-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.rtr-thumb-none {
  font-size: 10px;
  color: #aaa;
}

/* メイン情報 */
.rtr-main {
  flex: 1 1 auto;
  min-width: 0;
}

.rtr-title {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
  margin-bottom: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.rtr-title a {
  color: #1a1a1a;
  text-decoration: none;
}

.rtr-title a:hover {
  color: var(--primary-color, #0066cc);
  text-decoration: underline;
}

.rtr-external {
  font-size: 11px;
  color: #999;
  margin-left: 3px;
}

.rtr-uploader {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  margin-bottom: 3px;
  min-width: 0;
}

/* 投稿者アイコン（JSで取得後に表示。未取得・失敗時は非表示のまま） */
.rtr-uploader-icon {
  display: none;
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  overflow: hidden;
  background: #e8eef5;
}

.rtr-uploader-icon.is-loaded {
  display: inline-block;
}

.rtr-uploader-icon-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.rtr-uploader a,
.rtr-uploader-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rtr-uploader a {
  color: var(--primary-color, #0066cc);
  text-decoration: none;
}

.rtr-uploader a:hover {
  text-decoration: underline;
}

.rtr-uploader-name {
  color: #666;
}

/* 投稿日（JSで取得後に表示。24時間以内は赤で強調） */
.rtr-date {
  flex: 0 0 auto;
  font-size: 11px;
  color: #888;
  margin-left: 6px;
  white-space: nowrap;
}

.rtr-date.rtr-date-new {
  color: var(--new-color, #ff3333);
  font-weight: 700;
}

.rtr-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  font-size: 12px;
  color: #444;
}

.rtr-stat-icon {
  font-size: 11px;
  margin-right: 3px;
}

.rtr-icon-play { color: #2f855a; }
.rtr-icon-comment { color: #dd6b20; }
.rtr-icon-mylist { color: #b7791f; }
.rtr-icon-like { color: #e53e3e; }
.rtr-icon-nicoad { color: #b26a00; }
/* 広告ポイントの数値は他の統計（再生・コメント等）と同じ文字色（#444）で表示する */

.rtr-sub {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: 3px;
  font-size: 11.5px;
  color: #777;
}

/* カード内タグ（表示のみ） */
.rtr-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 5px;
}

.rtr-tag {
  display: inline-block;
  max-width: 100%;
  padding: 1px 8px;
  border: 1px solid #d6e0ec;
  border-radius: 11px;
  background: #f2f6fb;
  color: #3a5069;
  font-size: 11px;
  line-height: 1.7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.rtr-tag:hover {
  background: #e4edf8;
}

.rtr-tag.is-active {
  background: var(--primary-color, #0066cc);
  border-color: var(--primary-color, #0066cc);
  color: #fff;
}

/* アクション（詳細トグルはスマホ専用）。
   PCでは右側にコンパクトに配置（ジャンルチップ＋解析ボタンを縦に積む）。
   カード高さはメイン情報側で決まり、右側は余白なく上寄せで収まる。 */
.rtr-actions {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

/* 表示中ジャンル（今見ているボード名、または動画本来のジャンル。タップでジャンル切替へ） */
.rtr-genre-chip {
  display: inline-block;
  max-width: 200px;
  padding: 3px 10px;
  border: 1px solid #cfe3fb;
  border-radius: 11px;
  background: #f2f6fb;
  color: #1d4f8c;
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rtr-genre-chip:hover {
  background: #e4edf8;
}

.rtr-detail-toggle {
  display: none;
}

.rtr-analyze-btn {
  display: inline-block;
  padding: 6px 12px;
  border: 1px solid #007bff;
  border-radius: 4px;
  background: #007bff;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.rtr-analyze-btn:hover {
  background: #0056b3;
  border-color: #0056b3;
  color: #fff;
}

/* ---- もっと見る ---- */
.rtr-more-wrap {
  margin: 16px 0 0;
  text-align: center;
}

.rtr-more-btn {
  display: inline-block;
  min-width: 240px;
  padding: 11px 24px;
  border: 1px solid var(--primary-color, #0066cc);
  border-radius: 22px;
  background: #fff;
  color: var(--primary-color, #0066cc);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}

.rtr-more-btn:hover:not(:disabled) {
  background: #eef4fb;
}

.rtr-more-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.rtr-about {
  margin-top: 26px;
  padding: 14px 16px;
  background: #fafafa;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
}

.rtr-about h2 {
  margin: 0 0 8px;
  font-size: 14px;
  color: #333;
}

.rtr-about ul {
  margin: 0;
  padding-left: 18px;
  font-size: 12.5px;
  color: #555;
  line-height: 1.7;
}

.rtr-error {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 30px 20px;
  text-align: center;
  color: #444;
}

.rtr-error h2 {
  margin: 0 0 12px;
  font-size: 18px;
  color: var(--primary-dark, #004499);
}

.rtr-error-note {
  font-size: 12px;
  color: #888;
}

/* ==========================================================================
   スマホ・タブレット（1024px以下）
   サイドバー → 右下「ページ設定」ボタンで開くドロワー
   ※閾値は週刊ランキング（responsive.css の .sidebar / .main-container = 1024px）と揃える。
     片方だけタブレット表示にならないよう、両ページで同じ幅で切り替わるようにする。
   ========================================================================== */
@media (max-width: 1024px) {
  .rtr-layout {
    display: block;
  }

  /* ページ設定ボタン（週刊ランキングの mobile-filter-btn と同デザイン） */
  .rtr-mobile-settings-btn {
    display: flex;
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    background: #667eea;
    color: #fff;
    border: none;
    border-radius: 50px;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    cursor: pointer;
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
    max-width: calc(100vw - 40px);
  }

  .rtr-mobile-settings-label {
    font-size: 13.5px;
    line-height: 1.2;
  }

  .rtr-mobile-settings-summary {
    font-size: 10.5px;
    font-weight: 400;
    opacity: 0.9;
    line-height: 1.2;
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* オーバーレイ */
  .rtr-sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1001;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
  }

  .rtr-sidebar-overlay.is-active {
    opacity: 1;
    pointer-events: auto;
  }

  /* サイドバー → 左からのドロワー化（週刊ランキングページの .sidebar と同デザイン） */
  .rtr-sidebar {
    position: fixed;
    top: 0;
    left: -100%;
    right: auto;
    bottom: 0;
    width: 320px;
    max-width: 85vw;
    height: 100vh;
    max-height: none;
    z-index: 1002;
    overflow-y: auto;
    background: #fff;
    border-radius: 0;
    padding: 0 12px 16px;
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.2);
    transition: left 0.3s ease-in-out;
  }

  .rtr-sidebar.is-open {
    left: 0;
  }

  body.rtr-sidebar-open {
    overflow: hidden;
  }

  .rtr-sidebar-mobile-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    background: #667eea;
    margin: 0 -12px 8px;
    padding: 16px;
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    z-index: 1;
  }

  .rtr-sidebar-close {
    border: none;
    background: transparent;
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
  }

  .rtr-sidebar-close:hover {
    opacity: 0.8;
  }

  .rtr-side-list a {
    padding: 10px 12px; /* タップしやすく */
  }

  .rtr-side-list-scroll {
    max-height: none;
  }

  .rtr-filter-mode-group {
    grid-template-columns: 1fr;
  }

  .rtr-filter-actions {
    flex-direction: column;
  }

  .rtr-filter-status {
    flex-direction: column;
    align-items: stretch;
  }

  .rtr-filter-status-clear {
    width: 100%;
  }
}

/* ==========================================================================
   スマホ（600px以下）: カードのコンパクト化
   統計・比較順位・タグは「詳細」で折り畳み、一覧の視認性を優先する
   ========================================================================== */
@media (max-width: 600px) {
  .rtr-shell {
    padding: 10px 8px 32px;
  }

  /* 狭幅では週刊ランキングと同様にドロワーを全幅表示 */
  .rtr-sidebar {
    width: 100vw;
    max-width: 100vw;
  }

  .rtr-item {
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 8px;
  }

  .rtr-rank {
    flex: 0 0 42px;
  }

  .rtr-rank-num {
    font-size: 16px;
  }

  .rtr-thumb {
    flex: 0 0 84px;
    height: 47px;
  }

  .rtr-main {
    flex: 1 1 calc(100% - 145px);
  }

  .rtr-title {
    font-size: 12.5px;
    margin-bottom: 1px;
  }

  .rtr-uploader {
    flex-wrap: wrap;
    margin-bottom: 0;
    font-size: 11px;
  }

  .rtr-uploader-icon {
    width: 15px;
    height: 15px;
  }

  .rtr-date {
    margin-left: 0;
    font-size: 10.5px;
  }

  /* 統計・比較順位・タグは折り畳み（詳細を開いたら表示） */
  .rtr-stats,
  .rtr-sub,
  .rtr-tags {
    display: none;
  }

  .rtr-item.is-open .rtr-stats {
    display: flex;
    flex: 1 1 100%;
    order: 10;
    padding-top: 6px;
    border-top: 1px dashed #e5e9f0;
    gap: 4px 10px;
    font-size: 11.5px;
  }

  .rtr-item.is-open .rtr-sub {
    display: flex;
    flex: 1 1 100%;
    order: 11;
    margin-top: 0;
  }

  .rtr-item.is-open .rtr-tags {
    display: flex;
    flex: 1 1 100%;
    order: 12;
    margin-top: 0;
  }

  .rtr-item.is-open .rtr-tags[hidden] {
    display: none;
  }

  /* スマホではアクションを全幅の下段行に戻す（ジャンルチップ左・詳細/解析ボタン右） */
  .rtr-actions {
    flex: 1 1 100%;
    flex-direction: row;
    align-items: center;
    order: 20;
    justify-content: flex-end;
    margin-top: 2px;
  }

  .rtr-genre-chip {
    margin-right: auto;
  }

  .rtr-detail-toggle {
    display: inline-block;
    padding: 4px 12px;
    border: 1px solid #c5ccd6;
    border-radius: 4px;
    background: #fff;
    color: #556;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
  }

  .rtr-analyze-btn {
    padding: 4px 14px;
    font-size: 11.5px;
  }
}
