/* Statistics categories: one category at a time, chosen from a grouped menu. */
#view-statistics [hidden] { display: none !important; }
.stats-layout { display: grid; grid-template-columns: 236px minmax(0, 1fr); gap: 28px; align-items: start; margin-top: 8px; }
.stats-main { min-width: 0; }
.stats-nav { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; overscroll-behavior: contain; padding: 12px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); }
.stats-nav-toggle, .stats-nav-label { display: none; }
.stats-nav-group + .stats-nav-group { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); }
.stats-nav-group summary { display: flex; align-items: center; justify-content: space-between; min-height: 40px; padding: 0 10px; border-radius: 4px; color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; cursor: pointer; list-style: none; }
.stats-nav-group summary::-webkit-details-marker { display: none; }
.stats-nav-group summary::after { content: ''; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); transition: transform .15s; }
.stats-nav-group:not([open]) summary::after { transform: rotate(-45deg); }
.stats-nav-group summary:hover { color: var(--text); }
.stats-nav-group summary:focus-visible, .stats-nav-item:focus-visible, .stats-nav-toggle:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.stats-nav-group ul { display: grid; gap: 2px; margin: 2px 0 4px; padding: 0; list-style: none; }
.stats-nav-item { display: flex; align-items: center; width: 100%; min-height: 44px; padding: 8px 12px; border: 0; border-left: 3px solid transparent; border-radius: 4px; background: none; color: #c3ccc0; font: inherit; font-size: 15px; text-align: left; cursor: pointer; }
.stats-nav-item:hover { color: #f2dec0; background: #e9ad4509; }
.stats-nav-item[aria-current='page'] { border-left-color: var(--sand); color: #f0c06e; background: #e9ad4514; font-weight: 600; }
.stats-category-head { margin: 0 0 18px; }
.stats-category-group { margin: 0 0 4px; color: var(--sand); font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.stats-category-head h2 { margin: 0; font: 700 34px/1.1 var(--display); color: var(--text); overflow-wrap: anywhere; }
.stats-category-head h2:focus { outline: none; }
.stats-category-head h2:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 4px; }
.stats-category-head p:last-child { margin: 6px 0 0; color: var(--muted); font-size: 14px; line-height: 1.55; max-width: 75ch; }
/* The category heading names the section; the panels' own repeated titles step aside. */
#view-statistics #insights-title, #view-statistics #seasons-title, #view-statistics #seasons-title + p { display: none; }
/* With its title and note above, a panel's own heading box would sit empty: drop it (seasons keep it for a loading or error message). */
#view-statistics #statistics-weapons-panel > .section-heading, #view-statistics #statistics-seasons > .section-heading:not(:has(.seasons-status:not(:empty))) { display: none; }
#view-statistics .view-toolbar { margin-top: 0; }
#view-statistics #statistics-period { margin-bottom: 18px; }
#view-statistics { overflow-anchor: none; }
/* A successful load leaves only an accessible status, without an empty heading gap. */
#view-statistics #statistics-insights > .section-heading:has(#insights-status.sr-only) { padding: 0; border: 0; }
#view-statistics #insights-content[data-shown='1'] .insight-block { grid-column: 1 / -1; }
#view-statistics .stats-main > .panel:first-of-type, #view-statistics .stats-main > section { margin-top: 0; }

@media (max-width: 1099px) {
  .stats-layout { display: block; }
  .stats-nav { position: static; max-height: none; overflow: visible; margin-bottom: 18px; padding: 0; border: 0; background: none; }
  .stats-nav-label { display: block; margin: 0 0 8px; color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
  .stats-nav-box { border: 1px solid var(--line); border-radius: 6px; background: var(--paper); }
  .stats-nav-toggle { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 52px; padding: 8px 16px; border: 0; border-radius: 6px; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
  .stats-nav-toggle strong { flex: 1; min-width: 0; font-size: 16px; overflow-wrap: anywhere; }
  .stats-nav-toggle svg { flex: 0 0 auto; width: 18px; height: 18px; transform: rotate(90deg); transition: transform .15s; }
  .stats-nav[data-open='true'] .stats-nav-toggle svg { transform: rotate(-90deg); }
  .stats-nav[data-open='false'] .stats-nav-list { display: none; }
  .stats-nav-list { max-height: min(62vh, 560px); overflow-y: auto; overscroll-behavior: contain; padding: 4px 10px 10px; border-top: 1px solid var(--line); }
  .stats-category-head h2 { font-size: 28px; }
}
@media (prefers-reduced-motion: reduce) {
  .stats-nav-group summary::after, .stats-nav-toggle svg { transition: none; }
}
