/* The Stats tab: rank, badges and the numbers. Metals and mode hues are the
   app's own (dark stops), on the shared navy canvas and champagne accent. */
:root {
  --stats-copper: #F0B57E;
  --stats-copper-deep: #C9803F;
  --stats-silver: #F4F7FA;
  --stats-silver-deep: #C5CED8;
  --stats-gold: #C6AC76;
  --stats-gold-deep: #A98A4C;
  --stats-platinum: #E4FBFC;
  --stats-platinum-deep: #8FE0E3;
  --stats-obsidian: #D9DCE2;
  --stats-obsidian-deep: #8E939C;
}

.stats-page { display: grid; gap: 26px; padding-top: 8px; }

/* Metals: a card class sets the pair, and text inside can wear it. */
.stats-metal-copper { --metal: var(--stats-copper); --metal-deep: var(--stats-copper-deep); }
.stats-metal-silver { --metal: var(--stats-silver); --metal-deep: var(--stats-silver-deep); }
.stats-metal-gold { --metal: var(--stats-gold); --metal-deep: var(--stats-gold-deep); }
.stats-metal-platinum { --metal: var(--stats-platinum); --metal-deep: var(--stats-platinum-deep); }
.stats-metal-obsidian { --metal: var(--stats-obsidian); --metal-deep: var(--stats-obsidian-deep); }
.stats-metal-text {
  background: linear-gradient(135deg, var(--metal-deep), var(--metal) 55%, var(--metal-deep));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* Section anatomy */
.stats-section { display: grid; gap: 12px; }
.stats-section-head { display: grid; gap: 2px; }
.stats-eyebrow { font-size: 12px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; color: var(--faint); }
.stats-subtitle { color: var(--muted); font-size: 14.5px; }
.stats-card {
  background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius); padding: 18px;
}
.stats-divider { height: 1px; background: rgba(255,255,255,0.06); margin: 16px 0; }
.stats-muted { margin: 0; color: var(--muted); font-size: 14.5px; }

/* Rank card */
.stats-rank {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius); padding: 20px;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--metal) 14%, transparent), 0 24px 60px -30px color-mix(in srgb, var(--metal) 45%, transparent);
}
.stats-rank::before {
  content: ""; position: absolute; inset: -40% -20% auto auto; width: 60%; height: 120%; pointer-events: none;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--metal) 16%, transparent), transparent 70%);
}
.stats-rank-top { display: flex; align-items: center; gap: 16px; position: relative; }
.stats-medal {
  flex: none; width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; font-size: 30px;
  background: radial-gradient(circle at 30% 30%, var(--metal), var(--metal-deep) 70%);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.18), 0 8px 24px -8px var(--metal-deep);
}
.stats-rank-title { flex: 1; min-width: 0; }
.stats-rank-name { font-size: 32px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.stats-rank-xp { text-align: right; flex: none; }
.stats-rank-xp strong { display: block; font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stats-xpbar { margin-top: 18px; height: 10px; }
.stats-xpbar > div { background: linear-gradient(90deg, var(--metal-deep), var(--metal)); }
.stats-rank-line { display: flex; justify-content: space-between; gap: 12px; margin-top: 8px; font-size: 14px; color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.stats-rank-next { font-weight: 600; }

.stats-figures { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.stats-figure { border-left: 1px solid rgba(255,255,255,0.06); padding-left: 12px; min-width: 0; }
.stats-figure:first-child { border-left: none; padding-left: 0; }
.stats-figure strong { display: block; font-size: 21px; font-weight: 600; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stats-figure span { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); }

.stats-points { margin-top: 16px; position: relative; }
.stats-points summary { cursor: pointer; color: var(--muted); font-size: 14px; font-weight: 500; list-style: none; }
.stats-points summary::-webkit-details-marker { display: none; }
.stats-points summary::after { content: " ›"; display: inline-block; transition: transform 0.15s; }
.stats-points[open] summary::after { transform: rotate(90deg); }
.stats-points-list { margin-top: 10px; display: grid; }
.stats-points-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-top: 1px solid var(--hairline); }
.stats-points-row strong { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stats-points-title { font-size: 15px; font-weight: 500; }
.stats-points-detail { font-size: 12.5px; color: var(--faint); }
.stats-ranks { margin-top: 12px; border-top: 1px solid var(--hairline); }
.stats-ranks-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--hairline); color: var(--faint); font-size: 14.5px; }
.stats-ranks-row.is-reached { color: var(--text); }
.stats-ranks-row.is-reached::after { content: "✓"; color: var(--metal); font-size: 12px; }
.stats-ranks-title { flex: 1; }
.stats-ranks-xp { font-size: 12.5px; color: var(--faint); font-variant-numeric: tabular-nums; }

/* Badges */
.stats-tiers { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 18px; }
.stats-tier { text-align: center; padding: 8px 4px; border-radius: 10px; background: var(--elevated); }
.stats-tier strong { display: block; font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stats-tier span { font-size: 11.5px; color: var(--faint); white-space: nowrap; }
.stats-badges { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px 8px; }
.stats-badge { display: grid; justify-items: center; text-align: center; gap: 4px; min-width: 0; }
.stats-badge-art { position: relative; width: 64px; height: 64px; display: grid; place-items: center; }
.stats-badge-art .stats-ring { position: absolute; inset: 0; }
.stats-badge-icon { font-size: 26px; line-height: 1; position: relative; }
.stats-badge.is-earned .stats-badge-art::before {
  content: ""; position: absolute; inset: 6px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--metal) 40%, transparent), color-mix(in srgb, var(--metal-deep) 22%, transparent));
}
.stats-badge.is-progress .stats-badge-icon { filter: grayscale(0.6); opacity: 0.85; }
.stats-badge.is-locked .stats-badge-icon { filter: grayscale(1); opacity: 0.35; }
.stats-badge.is-locked .stats-badge-title { color: var(--faint); }
.stats-badge-title { font-size: 12px; font-weight: 600; color: var(--muted); line-height: 1.25; }
.stats-badge.is-earned .stats-badge-title { color: var(--text); }
.stats-badge-tier { font-size: 10.5px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.stats-badge-progress { font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; line-height: 1.2; }

/* Total travel */
.stats-total-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.stats-hero { font-size: 46px; font-weight: 700; letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums; margin-bottom: 6px; }
.stats-total-globe { font-size: 34px; line-height: 1; }
.stats-pill {
  display: inline-block; margin-top: 14px; padding: 6px 11px; border-radius: 999px; font-size: 13px; font-weight: 600;
  color: var(--accent); background: var(--elevated); border: 1px solid rgba(255,255,255,0.05);
}

/* Bars and ranked rows */
.stats-bar { height: 5px; border-radius: 999px; background: var(--elevated); overflow: hidden; }
.stats-bar > div { height: 100%; border-radius: 999px; background: var(--accent); opacity: 0.45; min-width: 4px; }
.stats-bar.is-first > div { opacity: 0.9; }
.stats-bar.stats-bar-mode { height: 6px; }
.stats-bar.stats-bar-mode > div { opacity: 0.8; }
.stats-ranked-list { display: grid; gap: 14px; }
.stats-ranked { display: flex; align-items: center; gap: 12px; }
.stats-ranked-n { flex: none; width: 14px; font-size: 12px; font-weight: 700; color: var(--faint); font-variant-numeric: tabular-nums; }
.stats-ranked-n.is-first { color: var(--accent); }
.stats-ranked-lead { flex: none; width: 28px; display: grid; place-items: center; }
.stats-ranked-body { flex: 1; min-width: 0; display: grid; gap: 6px; }
.stats-ranked-line { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.stats-ranked-title { font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stats-ranked-detail { font-size: 12.5px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stats-ranked-value { margin-left: auto; flex: none; font-size: 15px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.stats-ranked-value.is-strong { color: var(--text); margin-left: auto; }
.stats-ranked-value.is-strong + .stats-ranked-detail { flex: none; }
.stats-month-dot { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--elevated); font-size: 12px; font-weight: 700; color: var(--muted); }
.stats-flag { font-size: 20px; line-height: 1; }
.stats-airline-code { font-size: 11px; font-weight: 800; letter-spacing: 0.04em; padding: 5px 0; width: 28px; text-align: center; border-radius: 7px; background: var(--elevated); color: var(--muted); }
.stats-plus-row { margin-top: 14px; text-align: center; font-size: 14.5px; font-weight: 500; color: var(--accent); }

/* Transportation */
.stats-transport { display: grid; gap: 16px; }
.stats-transport-row { display: flex; align-items: center; gap: 13px; }
.stats-transport-icon { flex: none; width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--elevated); font-size: 16px; }

/* Distance by mode */
.stats-mode-share { display: flex; align-items: center; gap: 20px; }
.stats-donut { flex: none; }
.stats-donut-total { fill: var(--text); font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stats-donut-unit { fill: var(--faint); font-size: 11px; }
.stats-legend { flex: 1; display: grid; gap: 9px; min-width: 0; }
.stats-legend-row { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.stats-swatch { flex: none; width: 8px; height: 8px; border-radius: 50%; }
.stats-legend-icon { font-size: 14px; }
.stats-legend-label { font-weight: 500; }
.stats-legend-value { margin-left: auto; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Highlights and averages */
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.stats-highlight, .stats-stat {
  background: var(--surface); border: 1px solid var(--hairline); border-radius: 14px; padding: 14px; min-width: 0;
}
.stats-highlight-icon { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: rgba(233,220,195,0.14); font-size: 14px; margin-bottom: 10px; }
.stats-highlight-value { font-size: 20px; font-weight: 600; letter-spacing: -0.015em; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stats-highlight-headline { font-size: 15px; font-weight: 500; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stats-highlight-detail { font-size: 12.5px; color: var(--muted); margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.stats-stat-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.stats-stat-icon { font-size: 13px; }
.stats-stat-value { font-size: 22px; font-weight: 600; letter-spacing: -0.015em; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stats-stat-detail { font-size: 12.5px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* By year */
.stats-year-chart { display: flex; align-items: stretch; gap: 8px; height: 150px; margin-top: 4px; }
.stats-year-col { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; }
.stats-year-plot { flex: 1; width: 50%; display: flex; align-items: flex-end; border-bottom: 1px solid rgba(255,255,255,0.08); }
.stats-year-bar { width: 100%; border-radius: 4px 4px 0 0; background: var(--accent); opacity: 0.4; }
.stats-year-bar.is-max { opacity: 0.95; }
.stats-year-value { color: var(--muted); font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; margin-bottom: 4px; }
.stats-year-label { color: var(--faint); font-size: 11px; font-weight: 500; margin-top: 6px; }
.stats-table { width: 100%; border-collapse: collapse; margin-top: 14px; font-size: 14.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.stats-table th { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); text-align: right; padding: 0 0 6px; }
.stats-table th:first-child, .stats-table td:first-child { text-align: left; }
.stats-table td { text-align: right; padding: 8px 0; border-top: 1px solid var(--hairline); }
.stats-table td:first-child { color: var(--text); font-weight: 600; }
.stats-table td.is-max { color: var(--accent); }

/* Empty */
.stats-empty { text-align: center; padding: 40px 24px; }
.stats-empty-icon { font-size: 40px; margin-bottom: 10px; }
.stats-empty h3 { margin: 0 0 6px; font-size: 20px; }
.stats-empty p { margin: 0 auto; max-width: 380px; color: var(--muted); font-size: 15px; }

/* Narrow screens */
@media (max-width: 520px) {
  .stats-rank-name { font-size: 26px; }
  .stats-hero { font-size: 38px; }
  .stats-figures { grid-template-columns: repeat(2, 1fr); gap: 12px 10px; }
  .stats-figure:nth-child(3) { border-left: none; padding-left: 0; }
  .stats-badges { grid-template-columns: repeat(3, 1fr); }
  .stats-tier span { font-size: 10.5px; }
  .stats-mode-share { flex-direction: column; align-items: stretch; }
  .stats-donut { align-self: center; }
}
@media (max-width: 380px) {
  .stats-grid { grid-template-columns: 1fr; }
}
