/* =============================================================================
   stats.css - Statistics panels and native progress bars.

   Reference: `.docs/steps/5.md` point 3. Bars are plain `div` widths (no canvas,
   no dependency). Colors come exclusively from `css/themes.css`.
   ============================================================================= */

.stats {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.stats__title {
  margin: 0 0 var(--space-3) 0;
  font-size: var(--font-size-md);
}

/* A secondary heading inside a panel (the two blocks of the Mine panel): same weight as the title
   of the panel, quieter, and close to what it introduces. */
.stats__title--sub {
  margin: var(--space-2) 0 var(--space-1) 0;
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--color-text-muted);
}

.stats__big {
  margin: 0;
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--color-accent);
}

.stats__line {
  margin: 0 0 var(--space-3) 0;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.stats__bars {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.stats__bar-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-1);
  font-size: var(--font-size-sm);
}

.stats__bar-label {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats__bar-value {
  font-variant-numeric: tabular-nums;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.stats__track {
  height: 0.75rem;
  border-radius: var(--radius-pill);
  background-color: var(--color-surface-alt);
  overflow: hidden;
}

.stats__fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background-color: var(--color-accent);
  transition: width var(--duration-base) var(--easing-standard);
}

.stats__top-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  text-align: center;
}

.stats__top-image {
  width: min(100%, 12rem);
  border-radius: var(--radius-md);
  background-color: var(--color-surface-alt);
}

.stats__top-name {
  margin: 0;
  font-weight: 700;
}

.stats__top-count {
  margin: 0;
  color: var(--color-accent);
  font-weight: 700;
}

/* --- Last openings --------------------------------------------------------- */

.stats__panel--history {
  grid-column: 1 / -1;
}

.stats__history {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.stats__history-entry {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background-color: var(--color-surface-alt);
}

.stats__history-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.stats__history-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-2);
  margin: 0;
}

.stats__history-set {
  font-weight: 700;
}

.stats__history-date {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}

.stats__history-badge {
  padding: 0 var(--space-2);
  border-radius: var(--radius-pill);
  background-color: var(--color-accent);
  color: var(--color-accent-contrast);
  font-size: var(--font-size-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.stats__history-code {
  align-self: flex-start;
  max-width: 100%;
  padding: var(--space-1) var(--space-2);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-sm);
  background-color: transparent;
  color: var(--color-text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: var(--font-size-xs);
  text-align: left;
  overflow-wrap: anywhere;
  cursor: pointer;
  touch-action: manipulation;
}

.stats__history-code:hover:not(:disabled) {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.stats__history-code:disabled {
  cursor: default;
  opacity: 0.6;
}

.stats__history-cards {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--space-2);
}

.stats__history-card {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: var(--card-ratio);
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background-color: var(--color-surface);
  overflow: hidden;
  cursor: pointer;
  touch-action: manipulation;
}

.stats__history-card:hover {
  border-color: var(--color-accent);
}

.stats__history-card--r4 {
  border-color: rgba(120, 200, 255, 0.6);
}

.stats__history-card--r5 {
  border-color: rgba(255, 200, 90, 0.7);
}

.stats__history-card--fullart {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.stats__history-card--missing {
  color: var(--color-text-muted);
  font-weight: 700;
  cursor: default;
}

.stats__history-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.stats__history-cards-empty {
  grid-column: 1 / -1;
  margin: 0;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

/* --- Mine Pick history ---------------------------------------------------- */

/* A pick is ONE card, not a pack: its history is a list of compact rows whose card is a miniature.
   Displayed at the size of a card of the openings, ten picks would take the whole page. */
.stats__minepick-pick {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.stats__minepick-pick .stats__history-card {
  flex: 0 0 auto;
  width: 2.75rem;
  cursor: default;
}

.stats__minepick-name {
  margin: 0;
  min-width: 0;
  font-size: var(--font-size-sm);
  color: var(--color-text);
  overflow-wrap: anywhere;
}

@media (min-width: 768px) {
  .stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }
}

@media (prefers-reduced-motion: reduce) {
  .stats__fill {
    transition: none;
  }
}
