/**
 * rankin_count.css
 * ランクイン回数ページ専用スタイル
 * rankin_top.cssをベースに調整
 */

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

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

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

.sidebar-overlay {
  display: none;
}

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

/* サイドバー */
.rankin-count-sidebar {
  flex: 0 0 240px;
  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-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

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

.sidebar-list a {
  display: block;
  padding: 0.6rem 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;
}

.sidebar-list a.active .sidebar-note {
  color: rgba(255, 255, 255, 0.8);
}

.sidebar-note {
  display: block;
  font-size: 0.75rem;
  color: #777;
  margin-top: 0.2rem;
}

.sidebar-description {
  font-size: 0.85rem;
  color: #666;
  line-height: 1.6;
  margin: 0 0 0.8rem 0;
}

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

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

.rankin-count-description {
  font-size: 0.95rem;
  color: #666;
  margin-bottom: 1rem;
}

.rankin-count-stats {
  font-size: 0.9rem;
  color: #777;
  margin-bottom: 1.5rem;
}

.no-data-message {
  text-align: center;
  color: #999;
  padding: 3rem;
  background: #f9f9f9;
  border-radius: 8px;
}

/* カード一覧 */
.rankin-count-items {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* 個別カード */
.rankin-count-card {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  transition: box-shadow 0.2s;
}

.rankin-count-card:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.rankin-count-card.deleted {
  opacity: 0.6;
  background: #f5f5f5;
}

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

/* ランクイン回数（大きく表示） */
.card-count {
  flex: 0 0 70px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 8px;
  color: #fff;
}

.count-number {
  font-size: 1.8rem;
  font-weight: bold;
  line-height: 1;
}

.count-label {
  font-size: 0.75rem;
  margin-top: 0.2rem;
}

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

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

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

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

.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;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.8rem;
  font-size: 0.85rem;
  color: #777;
}

.meta-date {
  color: #999;
}

.meta-latest {
  color: #555;
}

.meta-latest a {
  color: #007bff;
  text-decoration: none;
}

.meta-latest a:hover {
  text-decoration: underline;
}

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

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

/* 投稿者情報 */
.card-uploader {
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  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;
}

/* ページネーション */
.rankin-count-pagination {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid #eee;
}

.pagination-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 0.8rem;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 4px;
  color: #007bff;
  text-decoration: none;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.pagination-link:hover {
  background: #f0f0f0;
  border-color: #ccc;
}

.pagination-current {
  background: #007bff;
  border-color: #007bff;
  color: #fff;
  font-weight: bold;
}

.pagination-ellipsis {
  padding: 0 0.3rem;
  color: #999;
}

/* レスポンシブ */
@media (max-width: 900px) {
  .rankin-count-container {
    flex-direction: column;
  }
  
  .rankin-count-sidebar {
    position: static;
    flex: none;
    max-height: none;
  }
}

/* ===========================================
 * スマホ対応（768px以下）
 * =========================================== */
@media (max-width: 768px) {
  /* コンテナ */
  .rankin-count-container {
    flex-direction: column;
    padding: 0.5rem;
  }
  
  /* サイドバーをモーダル風に */
  .rankin-count-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-count-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-count-main {
    width: 100%;
  }
  
  .rankin-count-title {
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
  }
  
  .rankin-count-description {
    font-size: 0.9rem;
  }
  
  /* カード */
  .rankin-count-card {
    flex-wrap: wrap;
    gap: 0.8rem;
    padding: 0.8rem;
  }
  
  /* 表示順位（スマホで小さく） */
  .card-display-rank {
    flex: 0 0 28px;
    height: 28px;
    font-size: 0.8rem;
  }
  
  /* ランクイン回数（スマホで小さく） */
  .card-count {
    flex: 0 0 55px;
    padding: 0.4rem;
  }
  
  .count-number {
    font-size: 1.4rem;
  }
  
  .count-label {
    font-size: 0.65rem;
  }
  
  /* サムネイル */
  .card-thumb {
    flex: 0 0 100px;
    height: 56px;
  }
  
  .card-thumb a {
    width: 100px;
    height: 56px;
  }
  
  .thumb-placeholder {
    width: 100px;
    height: 56px;
    font-size: 0.7rem;
  }
  
  /* カード情報 */
  .card-info {
    flex: 1 1 100%;
    min-width: 0;
  }
  
  .card-title {
    font-size: 0.95rem;
  }
  
  .card-meta {
    font-size: 0.8rem;
    gap: 0.5rem;
  }
  
  /* 投稿者情報 */
  .card-uploader {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
  }
  
  .uploader-name {
    max-width: none;
  }
  
  /* ページネーション */
  .rankin-count-pagination {
    gap: 0.3rem;
  }
  
  .pagination-link {
    min-width: 32px;
    height: 32px;
    padding: 0 0.5rem;
    font-size: 0.85rem;
  }
}

@media (max-width: 480px) {
  /* カードを縦並びに */
  .rankin-count-card {
    flex-direction: column;
    align-items: stretch;
  }
  
  /* 上段：順位とランクイン回数を横並び */
  .card-display-rank,
  .card-count {
    display: inline-flex;
  }
  
  /* サムネイルを横幅いっぱいに */
  .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;
  }
}
