/**
 * rankin_top.css
 * 上位一気見ページ専用スタイル
 */

/* モバイル専用要素（デフォルトは非表示） */
.sidebar-mobile-header {
  display: none;
}

.mobile-filter-btn {
  display: none;
}

.page-top-btn {
  display: none;
}

.sidebar-overlay {
  display: none;
}

/* コンテナ */
.rankin-top-container {
  display: flex;
  gap: 2rem;
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem;
}

/* サイドバー */
.rankin-top-sidebar {
  flex: 0 0 220px;
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
}

.sidebar-section {
  margin-bottom: 2rem;
}

.sidebar-section h3 {
  font-size: 0.9rem;
  font-weight: bold;
  color: #333;
  margin-bottom: 0.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 2px solid #ddd;
}

/* 年選択リストの高さ制限 */
.sidebar-year-list {
  max-height: 200px;
  overflow-y: auto;
  overflow-x: hidden;
  /* スクロールバーのスタイル（Webkit系ブラウザ） */
  scrollbar-width: thin;
  scrollbar-color: #ccc #f5f5f5;
}

.sidebar-year-list::-webkit-scrollbar {
  width: 6px;
}

.sidebar-year-list::-webkit-scrollbar-track {
  background: #f5f5f5;
  border-radius: 3px;
}

.sidebar-year-list::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}

.sidebar-year-list::-webkit-scrollbar-thumb:hover {
  background: #999;
}

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

.sidebar-list li {
  margin-bottom: 0.3rem;
}

.sidebar-list a {
  display: block;
  padding: 0.5rem 0.8rem;
  color: #007bff;
  text-decoration: none;
  border-radius: 4px;
  transition: background 0.2s;
}

.sidebar-list a:hover {
  background: #f0f0f0;
}

.sidebar-list a.active {
  background: #007bff;
  color: #fff;
  font-weight: bold;
}

/* メインコンテンツ */
.rankin-top-main {
  flex: 1;
  min-width: 0;
}

.rankin-top-title {
  font-size: 1.8rem;
  margin-bottom: 1.5rem;
  color: #333;
}

/* 号ブロック */
.rankin-top-blocks {
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
}

.rankin-top-block {
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 1.5rem;
  background: #fff;
}

.block-header {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid #eee;
}

.block-title {
  font-size: 1.5rem;
  margin: 0 0 0.5rem 0;
  display: flex;
  align-items: baseline;
  gap: 0.8rem;
}

.block-num {
  font-weight: bold;
  color: #007bff;
}

.block-period {
  font-size: 1.2rem;
  color: #555;
}

.block-date {
  font-size: 0.9rem;
  color: #777;
  margin: 0.3rem 0;
}

.block-link {
  display: inline-block;
  margin-top: 0.5rem;
  color: #007bff;
  text-decoration: none;
  font-weight: bold;
  font-size: 0.95rem;
  transition: color 0.2s;
}

.block-link:hover {
  color: #0056b3;
  text-decoration: underline;
}

/* 動画カード（縦並び） */
.block-items {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.no-items {
  text-align: center;
  color: #999;
  padding: 2rem;
}

.rankin-card {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 0.8rem;
  background: #f9f9f9;
  border-radius: 6px;
  transition: background 0.2s;
}

.rankin-card:hover {
  background: #f0f0f0;
}

.rankin-card.deleted {
  opacity: 0.6;
}

/* 順位バッジ */
.card-rank {
  flex: 0 0 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #007bff;
  color: #fff;
  font-weight: bold;
  font-size: 1.1rem;
  border-radius: 50%;
}

/* サムネイル */
.card-thumb {
  flex: 0 0 160px;
  height: 90px;
  position: relative;
}

.card-thumb a {
  position: relative;
  display: block;
  width: 160px;
  height: 90px;
}

.thumb-placeholder {
  width: 160px;
  height: 90px;
  background: #f0f0f0;
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ccc;
  font-size: 0.85rem;
}

/* JSで挿入される画像用スタイル */
.card-thumb img,
.card-thumb a img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
}

.thumb-duration {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.75rem;
  font-weight: bold;
  z-index: 2;
}

.deleted-thumb {
  background: #ccc;
  color: #666;
}

/* カード情報 */
.card-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.card-main {
  flex: 1;
}

.card-title {
  font-size: 1rem;
  margin: 0 0 0.5rem 0;
  line-height: 1.4;
}

.card-title a {
  color: #333;
  text-decoration: none;
  transition: color 0.2s;
}

.card-title a:hover {
  color: #007bff;
  text-decoration: underline;
}

.card-title.deleted-title {
  color: #999;
  text-decoration: line-through;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.85rem;
  color: #777;
}

.meta-date {
  color: #999;
}

.meta-link {
  color: #007bff;
  text-decoration: none;
  font-weight: 500;
}

.meta-link:hover {
  text-decoration: underline;
}

/* 投稿者情報（カード右下） */
.card-uploader {
  margin-top: 0.8rem;
  padding-top: 0.8rem;
  border-top: 1px solid #eee;
}

.uploader-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: #555;
  text-decoration: none;
  font-size: 0.85rem;
  transition: color 0.2s;
}

.uploader-link:hover {
  color: #007bff;
}

.uploader-icon,
.uploader-icon-placeholder {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  background: #e0e0e0;
  flex-shrink: 0;
}

.uploader-name {
  font-weight: 500;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* レスポンシブ */
@media (max-width: 900px) {
  .rankin-top-container {
    flex-direction: column;
  }
  
  .rankin-top-sidebar {
    position: static;
    flex: none;
    max-height: none;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
  }
  
  .sidebar-section {
    flex: 1 1 200px;
    margin-bottom: 0;
  }
}

/* ===========================================
 * スマホ対応（768px以下）
 * =========================================== */
@media (max-width: 768px) {
  /* コンテナ */
  .rankin-top-container {
    flex-direction: column;
    padding: 0.5rem;
  }
  
  /* サイドバーをモーダル風に */
  .rankin-top-sidebar {
    position: fixed;
    top: 0;
    left: -100%;
    width: 320px;
    max-width: 85vw;
    height: 100vh;
    background: white;
    z-index: 1002;
    overflow-y: auto;
    transition: left 0.3s ease-in-out;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.15);
    padding: 1rem;
  }
  
  .rankin-top-sidebar.active {
    left: 0;
  }
  
  /* モバイル用：閉じるボタン */
  .sidebar-mobile-header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #ddd;
  }
  
  .sidebar-close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #666;
    cursor: pointer;
    padding: 0.5rem;
    line-height: 1;
  }
  
  .sidebar-close-btn:active {
    transform: scale(0.95);
  }
  
  /* オーバーレイ */
  .sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1001;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease-in-out;
  }
  
  .sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
  }
  
  /* ページ設定ボタン（右下） */
  .mobile-filter-btn {
    display: flex !important;
    position: fixed;
    bottom: 80px;
    right: 20px;
    z-index: 1000;
    background: #667eea;
    color: white;
    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;
    align-items: center;
    gap: 8px;
    transition: all 0.3s;
  }
  
  .mobile-filter-btn:hover {
    background: #5568d3;
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.5);
  }
  
  .mobile-filter-btn:active {
    transform: scale(0.95);
  }
  
  /* 上に戻るボタン（右下） */
  .page-top-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: rgba(0, 123, 255, 0.9);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s, background 0.2s;
    z-index: 999;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  }
  
  .page-top-btn.visible {
    opacity: 1;
    pointer-events: auto;
  }
  
  .page-top-btn:hover {
    background: rgba(0, 123, 255, 1);
  }
  
  /* メインコンテンツ */
  .rankin-top-main {
    width: 100%;
  }
  
  .rankin-top-title {
    font-size: 1.3rem;
    margin-bottom: 1rem;
  }
  
  /* 号ブロック */
  .rankin-top-block {
    padding: 1rem;
    margin-bottom: 1.5rem;
  }
  
  .block-title {
    font-size: 1.2rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
  
  .block-num {
    font-size: 1.3rem;
  }
  
  .block-period {
    font-size: 1rem;
  }
  
  /* カード */
  .rankin-card {
    flex-direction: column;
    align-items: stretch;
    gap: 0.8rem;
  }
  
  /* 順位バッジ：丸形に修正（横伸び解消） */
  .card-rank {
    width: 50px;
    height: 50px;
    flex: 0 0 50px;
    font-size: 1.3rem;
    align-self: center;
  }
  
  /* サムネイル */
  .card-thumb {
    flex: none;
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
  }
  
  .card-thumb a {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
  }
  
  .thumb-placeholder {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
  }
  
  /* カード情報 */
  .card-info {
    flex: 1;
  }
  
  .card-title {
    font-size: 1rem;
  }
  
  .card-meta {
    font-size: 0.85rem;
  }
  
  /* 投稿者情報 */
  .card-uploader {
    margin-top: 0.6rem;
    padding-top: 0.6rem;
  }
}

@media (max-width: 600px) {
  .rankin-card {
    flex-direction: column;
    align-items: stretch;
  }
  
  .card-thumb {
    flex: none;
  }
  
  .thumb-placeholder {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
  }
  
  .sidebar-section {
    flex: 1 1 100%;
  }
  
  /* モバイル時の投稿者情報調整 */
  .uploader-name {
    max-width: none;
  }
}
