/**
 * public/css/statistics.css
 * Calm Web Empirical Statistics Index — Two-Page Broadsheet Ledger
 */

/* ==========================================================================
   Spread Stage Mode for Statistics Index
   ========================================================================== */
.reading-desk:has(.magazine-spread.stats-mode),
#deskStage:has(.magazine-spread.stats-mode) {
  overflow-y: auto !important;
  max-height: 100dvh;
}

.magazine-spread.stats-mode {
  display: flex !important;
  flex-direction: row !important;
  align-items: stretch !important;
  justify-content: center !important;
  gap: 28px !important;
  max-width: 1440px !important;
  width: 100% !important;
  height: 100% !important;
  max-height: 100% !important;
  margin: 0 auto !important;
  padding: 14px 24px 16px !important;
  box-sizing: border-box !important;
  background: transparent !important;
  box-shadow: none !important;
  container-type: normal !important;
}

.magazine-spread.stats-mode::after {
  display: none !important;
}

@media (max-width: 1024px) {
  .reading-desk:has(.magazine-spread.stats-mode),
  #deskStage:has(.magazine-spread.stats-mode) {
    overflow-y: auto !important;
    height: auto !important;
    min-height: 100vh !important;
    align-items: flex-start !important;
  }

  .magazine-spread.stats-mode {
    flex-direction: column !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    gap: 20px !important;
    padding: 12px 12px 28px !important;
    height: auto !important;
    min-height: 0 !important;
    overflow-y: visible !important;
  }
}

/* ==========================================================================
   Page Sheet (Verso has header, Recto skips header to maximize data density)
   ========================================================================== */
.stats-page {
  flex: 1 1 50%;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  background: var(--paper-bg, #f7f3eb);
  border: 1px solid var(--rule-soft, rgba(0, 0, 0, 0.1));
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.03);
  padding: 14px 22px 12px;
  box-sizing: border-box;
  min-width: 0;
  max-height: 100%;
  border-radius: 2px;
  position: relative;
  overflow: hidden;
}

@media (max-width: 768px) {
  .stats-page {
    padding: 16px 14px 14px;
  }
}

/* ==========================================================================
   Page Header (Verso only; Recto skips header)
   ========================================================================== */
.stats-page-header {
  margin-bottom: 6px;
}

.stats-page-header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-sans, system-ui, sans-serif);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-muted, #7c776e);
  padding-bottom: 5px;
  border-bottom: 1px solid var(--rule-soft, rgba(0, 0, 0, 0.12));
  margin-bottom: 7px;
}

@media (max-width: 480px) {
  .stats-page-header-top {
    font-size: 8.5px;
    letter-spacing: 0.05em;
    gap: 4px;
  }
}

.stats-header-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.stats-folio-vol {
  color: var(--accent-crimson, #8b261d);
  font-weight: 800;
}

.stats-folio-dot {
  color: var(--ink-muted, #7c776e);
  font-size: 10px;
}

.stats-folio-date {
  font-family: var(--font-sans, system-ui, sans-serif);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--ink-muted, #7c776e);
}

.stats-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.stats-header-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  background: transparent;
  border: 1px solid var(--rule-soft, rgba(0, 0, 0, 0.15));
  border-radius: 3px;
  font-family: var(--font-sans, system-ui, sans-serif);
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-secondary, #524e47);
  cursor: pointer;
  transition: all 0.12s ease;
  line-height: 1;
  text-transform: none;
  letter-spacing: 0.02em;
}

.stats-header-btn:hover {
  background: var(--paper-bg-alt, #eee9dd);
  color: var(--ink-primary, #191816);
  border-color: var(--ink-primary, #191816);
}

.stats-header-btn svg {
  display: block;
  opacity: 0.75;
}

.stats-header-btn:hover svg {
  opacity: 1;
}

.stats-page-title {
  font-family: var(--font-serif-display, 'Fraunces', 'DM Serif Display', Georgia, serif);
  font-size: 22px;
  font-weight: 600;
  line-height: 1.15;
  color: var(--ink-primary, #191816);
  margin: 0 0 2px 0;
  letter-spacing: -0.02em;
}

.stats-page-subtitle {
  font-family: var(--font-serif-body, 'Newsreader', 'Cormorant Garamond', Georgia, serif);
  font-style: italic;
  font-size: 12.5px;
  line-height: 1.35;
  color: var(--ink-secondary, #524e47);
  margin: 0;
}

.stats-categories-bar {
  display: flex;
  gap: 5px;
  margin: 6px 0 2px 0;
  flex-wrap: wrap;
}

.stats-cat-chip {
  background: var(--paper-bg-alt, rgba(0, 0, 0, 0.04));
  border: 1px solid var(--rule-soft, rgba(0, 0, 0, 0.12));
  color: var(--ink-secondary, #524e47);
  font-family: var(--font-sans, system-ui, sans-serif);
  font-size: 10px;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.12s ease;
  line-height: 1.2;
}

.stats-cat-chip:hover {
  border-color: var(--ink-primary, #191816);
  color: var(--ink-primary, #191816);
  background: var(--paper-bg, #fbf7ee);
}

.stats-cat-chip.is-active {
  background: var(--ink-primary, #191816);
  color: var(--paper-bg, #fbf7ee);
  border-color: var(--ink-primary, #191816);
}

.stats-cat-count {
  font-size: 8.5px;
  opacity: 0.75;
}

.stats-header-rule {
  height: 2px;
  border-top: 1px solid var(--rule-strong, rgba(0, 0, 0, 0.2));
  border-bottom: 1px solid var(--rule-hairline, rgba(0, 0, 0, 0.06));
  margin-top: 6px;
}

/* ==========================================================================
   Stats Item List & Typographic Dot-Leader Entries (Comparative Pairs)
   ========================================================================== */
.stats-items-list {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  justify-content: flex-start;
  gap: 0;
  margin: 2px 0 0 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
}

.stats-items-list::-webkit-scrollbar {
  width: 4px;
}

.stats-items-list::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 2px;
}

.stats-pair {
  display: flex;
  flex-direction: column;
  padding: 3px 0 4px;
  border-bottom: 1px solid var(--rule-soft, rgba(0, 0, 0, 0.08));
}

.stats-pair:first-child {
  padding-top: 0;
}

.stats-pair:last-child {
  border-bottom: none;
}

.stats-pair-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
}

.stats-row-baseline {
  margin-bottom: 2px;
}

.stats-row-contrast {
  margin-bottom: 2px;
}

.stats-item {
  display: flex;
  flex-direction: column;
  padding: 4px 0;
  border-bottom: 1px solid var(--rule-hairline, rgba(0, 0, 0, 0.05));
  transition: background-color 0.15s ease;
}

.stats-item:first-child {
  padding-top: 0;
}

.stats-item:last-child {
  border-bottom: none;
}

.stats-item-main {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
}

.stats-item-text {
  font-family: var(--font-serif-body, 'Newsreader', 'Literata', Georgia, serif);
  font-size: 13px;
  line-height: 1.35;
  color: var(--ink-primary, #191816);
  flex-shrink: 1;
}

.stats-row-baseline .stats-item-text,
.stats-row-contrast .stats-item-text {
  color: var(--ink-primary, #191816);
  font-weight: 500;
}

/* Typographic Dot-Leader bridging explainer to stat */
.stats-item-dots {
  flex-grow: 1;
  border-bottom: 1.5px dotted var(--rule-soft, #cfc9be);
  margin: 0 6px 3px 6px;
  min-width: 18px;
  opacity: 0.75;
}

/* Both numbers in exact same font style and reddish accent color */
.stats-item-value,
.stats-value-baseline,
.stats-value-contrast {
  flex-shrink: 0;
  font-family: var(--font-serif-display, 'Fraunces', Georgia, serif);
  font-variant-numeric: tabular-nums;
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  text-align: right;
  line-height: 1.25;
  color: var(--accent-crimson, #8b261d);
}

.stats-item-source {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-sans, system-ui, sans-serif);
  font-size: 9.5px;
  font-weight: 500;
  color: var(--ink-muted, #7c776e);
  margin-top: 1px;
  letter-spacing: 0.03em;
}

.stats-source-link {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dotted transparent;
  transition: all 0.12s ease;
}

.stats-source-link:hover {
  color: var(--ink-primary, #191816);
  border-bottom-color: var(--ink-muted, #7c776e);
}

.stats-source-arrow {
  font-size: 9px;
  opacity: 0.6;
}

