/**
 * Statistics view styles
 */

.stats-view {
  padding-bottom: var(--space-8);
}

/* Summary Cards */
.stats-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}

.stat-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  text-align: center;
  transition: var(--transition-base);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-icon {
  font-size: var(--font-size-3xl);
  margin-bottom: var(--space-3);
}

.stat-value {
  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-primary);
  line-height: 1;
  margin-bottom: var(--space-2);
}

.stat-label {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  font-weight: var(--font-weight-medium);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Stats Section */
.stats-section {
  margin-bottom: var(--space-8);
}

.stats-section h2 {
  font-size: var(--font-size-2xl);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 2px solid var(--border-color);
}

/* Stats Bars */
.stats-bars {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.stat-bar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-3);
  align-items: center;
}

.stat-bar-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  min-width: 150px;
}

.stat-bar-value {
  color: var(--text-tertiary);
  font-weight: var(--font-weight-semibold);
}

.stat-bar-track {
  flex: 1;
  height: 24px;
  background-color: var(--bg-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

.stat-bar-fill {
  height: 100%;
  background-color: var(--color-primary);
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
}

.stat-bar-percentage {
  font-size: var(--font-size-sm);
  color: var(--text-tertiary);
  font-weight: var(--font-weight-semibold);
  min-width: 50px;
  text-align: right;
}

/* Top List */
.top-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.top-item {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4);
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: var(--transition-fast);
}

.top-item:hover {
  background-color: var(--bg-hover);
}

.top-rank {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  color: var(--text-tertiary);
  min-width: 40px;
  text-align: center;
}

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

.top-title {
  font-weight: var(--font-weight-semibold);
  margin-bottom: var(--space-1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

.top-rating {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
}

/* Tag Cloud */
.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
}

.tag-cloud-item {
  display: inline-flex;
  align-items: baseline;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-weight: var(--font-weight-medium);
  transition: var(--transition-fast);
  cursor: default;
}

.tag-cloud-item:hover {
  background-color: var(--bg-hover);
  transform: scale(1.05);
}

.tag-count {
  font-size: 0.8em;
  color: var(--text-tertiary);
  font-weight: var(--font-weight-normal);
}

/* ─── View header display font ──────────────────────────────────────────────── */
.stats-view .view-header h1 {
  font-family: var(--font-display);
  font-style: italic;
}

/* ─── Summary strip (override the grid) ────────────────────────────────────── */
.stats-summary {
  display: flex;
  gap: var(--space-4);
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: var(--space-2);
  margin-bottom: var(--space-10);
}

.stats-summary::-webkit-scrollbar {
  display: none;
}

.stat-card {
  flex: 0 0 auto;
  min-width: 130px;
  text-align: left;
}

/* Display font for numbers */
.stat-value {
  font-family: var(--font-display);
}

/* ─── Type-colored bar fills ─────────────────────────────────────────────────  */
.stat-bar[data-type="book"]      .stat-bar-fill { background: var(--type-book); }
.stat-bar[data-type="film"]      .stat-bar-fill { background: var(--type-film); }
.stat-bar[data-type="series"]    .stat-bar-fill { background: var(--type-series); }
.stat-bar[data-type="videogame"] .stat-bar-fill { background: var(--type-videogame); }
.stat-bar[data-type="paper"]     .stat-bar-fill { background: var(--type-paper); }
.stat-bar[data-type="podcast"]   .stat-bar-fill { background: var(--type-podcast); }

/* ─── Rating histogram ───────────────────────────────────────────────────────  */
.rating-histogram {
  display: flex;
  align-items: flex-end;
  gap: var(--space-2);
  height: 80px;
  padding: 0 var(--space-1);
  overflow: hidden;
}

.histogram-bar-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  flex: 1;
}

.histogram-bar {
  width: 100%;
  background: var(--color-primary);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  min-height: 4px;
  transition: height var(--transition-slow);
}

.histogram-label {
  font-size: var(--font-size-xs);
  color: var(--text-tertiary);
  font-weight: var(--font-weight-medium);
}

/* ─── Top ranked: medal colors ───────────────────────────────────────────────  */
.top-rank[data-rank="1"] { color: #f59e0b; }
.top-rank[data-rank="2"] { color: #94a3b8; }
.top-rank[data-rank="3"] { color: #b45309; }

/* Display font for rank numbers */
.top-rank {
  font-family: var(--font-display);
}

/* ─── Currently in progress pills ───────────────────────────────────────────  */
.stats-in-progress {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.stats-active-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-full);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  max-width: 260px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stats-active-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--status-in-progress);
  flex-shrink: 0;
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* Responsive */
@media (max-width: 768px) {
  .stats-summary {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .stat-card {
    padding: var(--space-4);
  }
  
  .stat-icon {
    font-size: var(--font-size-2xl);
  }
  
  .stat-value {
    font-size: var(--font-size-2xl);
  }
  
  .stat-bar {
    grid-template-columns: 1fr;
  }
  
  .stat-bar-label {
    min-width: 0;
  }
  
  .stat-bar-percentage {
    text-align: left;
  }
  
  .top-item {
    gap: var(--space-3);
  }
  
  .top-rank {
    font-size: var(--font-size-xl);
    min-width: 32px;
  }
}

@media (max-width: 480px) {
  .rating-histogram {
    height: 60px;
  }

  .histogram-label {
    font-size: 0.625rem;
  }
}