world-2026-hub/assets/css/stats.css
Lucas Kalil 387fab3c8b feat(stats): degradation engine + scrollspy sub-nav (Stage A)
Scaffold the post-Cup stats screen (.agents/stats-screen-plan.md) on the
feature/stats-final-screen branch.

- loadData(): fault-tolerant optional data layers (players, player-events,
  awards, keeper-stats, curiosities, all-time-baselines) via loadOptional() —
  an absent/404 file defaults to empty SILENTLY (graceful degradation, keeps
  the console clean), warning only on a present-but-malformed file. The 6 core
  files still throw on failure.
- stats.js SECTIONS registry: a section and its sub-nav chip render only when
  available(model) holds, else they are omitted from the DOM entirely (no
  placeholder / no coming-soon). Overview/Teams live; the 4 future sections
  stay dark until later stages.
- Sticky scrollspy sub-nav: hash-safe anchor chips (preventDefault +
  scrollIntoView, never touch location.hash so the tab router does not bounce
  to Home); position-based scrollspy with an explicit page-bottom -> last
  section rule (robust on short pages). --header-h kept live via a
  ResizeObserver so the nav sticks correctly under the variable-height header.
- flagImg() monogram fallback: a broken flag SVG becomes a 3-letter code span,
  never a broken-image icon.
- i18n stats.nav* keys (EN/PT); stats.css for sub-nav / section / fallback.

No DATA_VERSION bump (no deployed data changed). No index.html change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-16 19:36:32 -03:00

463 lines
9.8 KiB
CSS

/* stats.css — "Stats" tab: tournament-to-date hero, overview cards and the
goals-by-stage chart. Reuses the global tokens and the .stat-card pattern.
Repeated tiles use a flat translucent fill (no backdrop-filter) per the
project's perf rule; blur is reserved for the few large .glass surfaces. */
/* --------------------------------------------------------- hero "pulse" */
.stats-hero {
padding: clamp(1.4rem, 4vw, 2.4rem);
text-align: center;
}
.stats-hero .hero-label {
flex-direction: column;
gap: 0.4rem;
margin-bottom: 1.5rem;
}
.stats-hero-tiles {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 0.85rem;
}
.stats-tile {
display: flex;
flex-direction: column;
align-items: center;
gap: 0.35rem;
padding: 1rem 0.6rem;
background: var(--glass-bg);
border: 1px solid var(--glass-border);
border-radius: var(--radius-sm);
}
.stats-tile-value {
font-size: clamp(1.5rem, 4.5vw, 2.1rem);
font-weight: 700;
color: var(--accent-gold-soft);
font-variant-numeric: tabular-nums;
line-height: 1;
}
.stats-tile-label {
font-size: 0.72rem;
text-transform: uppercase;
letter-spacing: 0.06em;
color: var(--text-secondary);
}
/* ----------------------------------------------------------- overview */
.stats-overview-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
gap: 1rem;
}
.stats-overview-grid .stat-value {
display: inline-flex;
align-items: baseline;
gap: 0.3rem;
}
.stat-sub {
font-size: 1rem;
font-weight: 400;
color: var(--text-secondary);
}
/* ------------------------------------------------- goals-by-stage chart */
.stats-chart {
display: grid;
gap: 0.85rem;
padding: 1.25rem 1.4rem;
}
.chart-row {
display: grid;
grid-template-columns: clamp(86px, 22vw, 150px) 1fr auto;
align-items: center;
gap: 0.8rem;
}
.chart-bar-label {
font-size: 0.85rem;
color: var(--text-secondary);
}
.chart-track {
height: 14px;
background: var(--glass-bg-strong);
border-radius: 999px;
overflow: hidden;
}
.chart-bar {
height: 100%;
border-radius: 999px;
background: linear-gradient(90deg, var(--accent-blue), var(--accent-gold));
transform-origin: left center;
animation: stats-bar-grow 0.6s ease both;
}
@keyframes stats-bar-grow {
from { transform: scaleX(0); }
to { transform: scaleX(1); }
}
.chart-bar-val {
font-size: 0.9rem;
font-weight: 700;
font-variant-numeric: tabular-nums;
min-width: 1.5ch;
text-align: right;
}
/* ------------------------------------------------- team statistics */
.stats-leaders {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
gap: 1rem;
margin-bottom: 1.25rem;
}
.leader-card {
display: flex;
flex-direction: column;
align-items: center;
gap: 0.5rem;
padding: 1.1rem 1rem;
text-align: center;
}
.leader-label {
font-size: 0.72rem;
text-transform: uppercase;
letter-spacing: 0.07em;
color: var(--accent-gold);
font-weight: 600;
}
.leader-team {
display: flex;
align-items: center;
gap: 0.5rem;
}
.leader-name {
font-size: 1rem;
font-weight: 600;
}
.leader-value {
font-size: 1.6rem;
font-weight: 700;
font-variant-numeric: tabular-nums;
color: var(--accent-gold-soft);
}
/* horizontal scroll on narrow screens; rank + team columns stay frozen */
.stats-table-wrap {
overflow-x: auto;
border-radius: var(--radius);
border: 1px solid var(--glass-border);
-webkit-overflow-scrolling: touch;
}
.stats-table {
width: 100%;
border-collapse: collapse;
font-size: 0.88rem;
background: var(--glass-bg);
}
.stats-table th,
.stats-table td {
padding: 0.6rem 0.7rem;
text-align: right;
white-space: nowrap;
font-variant-numeric: tabular-nums;
}
.stats-table thead th {
position: sticky;
top: 0;
background: var(--bg-secondary);
border-bottom: 1px solid var(--glass-border);
font-weight: 600;
color: var(--text-secondary);
}
.stats-table tbody tr {
border-top: 1px solid rgba(255, 255, 255, 0.05);
}
.stats-table tbody tr:hover {
background: var(--glass-bg-strong);
}
.col-rank {
text-align: center;
color: var(--text-secondary);
width: 2.5rem;
}
.col-team {
text-align: left;
display: flex;
align-items: center;
gap: 0.5rem;
}
/* freeze rank + team to the left while metric columns scroll under them */
.stats-table .col-rank,
.stats-table .col-team {
position: sticky;
background: var(--bg-secondary);
z-index: 1;
}
.stats-table .col-rank { left: 0; }
.stats-table .col-team { left: 2.5rem; }
.stats-table tbody .col-rank,
.stats-table tbody .col-team {
background: var(--bg-primary);
}
.stats-table tbody tr:hover .col-rank,
.stats-table tbody tr:hover .col-team {
background: var(--bg-secondary);
}
.col-sort {
display: inline-flex;
align-items: center;
gap: 0.25rem;
padding: 0;
color: inherit;
font: inherit;
font-weight: 600;
}
.col-sort:hover {
color: var(--text-primary);
}
.stats-table th.sorted,
.stats-table td.sorted {
color: var(--accent-gold-soft);
}
.sort-arrow {
font-size: 0.7rem;
}
.row-idle td {
color: var(--text-secondary);
opacity: 0.7;
}
.stats-pagination {
display: flex;
justify-content: center;
flex-wrap: wrap;
gap: 0.4rem;
margin-top: 1rem;
}
.page-btn {
min-width: 2.2rem;
padding: 0.4rem 0.6rem;
border: 1px solid var(--glass-border);
border-radius: var(--radius-sm);
color: var(--text-secondary);
font-variant-numeric: tabular-nums;
transition: color 0.2s, border-color 0.2s, background-color 0.2s;
}
.page-btn:hover:not(:disabled) {
color: var(--text-primary);
border-color: var(--accent-gold);
}
.page-btn.active {
color: var(--bg-primary);
background: linear-gradient(135deg, var(--accent-gold), var(--accent-gold-soft));
border-color: transparent;
font-weight: 600;
}
.page-btn:disabled {
opacity: 0.35;
cursor: default;
}
.sr-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border: 0;
}
/* ---------------------------------------------- header tooltips + key */
.has-tip { cursor: help; }
.col-sort.has-tip { cursor: pointer; }
.app-tooltip {
position: fixed;
z-index: 1000;
max-width: 220px;
padding: 0.45rem 0.65rem;
background: var(--bg-secondary);
border: 1px solid var(--glass-border);
border-radius: var(--radius-sm);
box-shadow: var(--shadow-soft);
color: var(--text-primary);
font-size: 0.76rem;
font-weight: 400;
line-height: 1.4;
text-align: center;
text-transform: none;
letter-spacing: normal;
pointer-events: none;
}
.app-tooltip[hidden] { display: none; }
/* abbreviation key — hidden on desktop (tooltips cover it), shown on mobile */
.stats-legend { display: none; }
.legend-pair b {
color: var(--text-primary);
font-weight: 600;
}
@media (max-width: 600px) {
.stats-legend {
display: flex;
flex-wrap: wrap;
gap: 0.35rem 0.9rem;
margin: 0.9rem 0 0;
padding: 0.8rem 1rem;
background: var(--glass-bg);
border: 1px solid var(--glass-border);
border-radius: var(--radius-sm);
font-size: 0.76rem;
color: var(--text-secondary);
line-height: 1.5;
}
}
/* --------------------------------------------------------------- misc */
.stats-more {
margin-top: 1.5rem;
text-align: center;
}
.stats-link {
padding: 0.55rem 1.2rem;
border: 1px solid var(--glass-border);
border-radius: 999px;
color: var(--text-secondary);
font-size: 0.9rem;
transition: color 0.2s, border-color 0.2s, background-color 0.2s;
}
.stats-link:hover {
color: var(--text-primary);
border-color: var(--accent-gold);
background: var(--glass-bg-strong);
}
/* -------------------------------------------------- sub-nav (scrollspy) */
/* sticks just below the variable-height sticky header (--header-h is kept live
by app.js trackHeaderHeight). NOT a tablist — it's a <nav> of in-page anchors
whose clicks are intercepted, so the top tablist's arrow keys never conflict. */
.stats-subnav {
position: sticky;
top: var(--header-h, 64px);
z-index: 20;
display: flex;
gap: 0.35rem;
margin: 1.4rem 0;
padding: 0.4rem;
overflow-x: auto;
scrollbar-width: none;
background: rgba(8, 20, 33, 0.88);
backdrop-filter: blur(10px) saturate(1.2);
-webkit-backdrop-filter: blur(10px) saturate(1.2);
border: 1px solid var(--glass-border);
border-radius: 999px;
}
.stats-subnav::-webkit-scrollbar { display: none; }
.stats-subnav-chip {
flex: 0 0 auto;
padding: 0.4rem 0.95rem;
border-radius: 999px;
color: var(--text-secondary);
font-size: 0.85rem;
font-weight: 600;
text-decoration: none;
white-space: nowrap;
transition: color 0.2s, background-color 0.2s;
}
.stats-subnav-chip:hover { color: var(--text-primary); }
.stats-subnav-chip.active {
color: var(--bg-primary);
background: linear-gradient(135deg, var(--accent-gold), var(--accent-gold-soft));
}
/* offset scroll targets so the sticky header + sub-nav never cover a heading */
.stats-section {
scroll-margin-top: calc(var(--header-h, 64px) + 3.75rem);
}
.stats-section + .stats-section { margin-top: 2.5rem; }
.stats-section:focus { outline: none; }
/* section spacing is owned by the wrapper, not the first heading inside it */
.stats-section > .section-title:first-child { margin-top: 0; }
/* flag monogram fallback (graceful degradation §0.3) — never a broken-img icon */
.flag-fallback {
display: inline-flex;
align-items: center;
justify-content: center;
background: var(--glass-bg-strong);
border: 1px solid var(--glass-border);
border-radius: 3px;
color: var(--text-secondary);
font-size: 0.5rem;
font-weight: 700;
letter-spacing: 0.01em;
vertical-align: middle;
overflow: hidden;
}
/* ---------------------------------------------------------- responsive */
@media (max-width: 600px) {
.stats-hero-tiles {
grid-template-columns: repeat(2, 1fr);
}
}
@media (prefers-reduced-motion: reduce) {
.chart-bar { animation: none; }
}