/* ============================================
   STATS – wykresy statystyk nauki (stats.js). Namespace: .stx-*
   Kolor działu przez --cat, spójny z kaflami działów w style.css.
   ============================================ */
.stx { --cat: var(--subject); font-size: 0.875rem; }
.stx [data-section="algorytmy"], .stx[data-section="algorytmy"]     { --cat: #6C2BD9; }
.stx [data-section="bazy-danych"], .stx[data-section="bazy-danych"] { --cat: #2563EB; }
.stx [data-section="excel"], .stx[data-section="excel"]             { --cat: #217346; }
.stx [data-section="teoria"], .stx[data-section="teoria"]           { --cat: #E8890C; }
.stx [data-section="gold"], .stx[data-section="gold"]               { --cat: var(--gold); }

/* --- paski --- */
.stx-bar + .stx-bar, .stx-sec + .stx-sec { margin-top: 10px; }
.stx-bar-row {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 0.781rem; margin-bottom: 5px; gap: 12px;
}
.stx-bar-label { font-weight: 600; color: var(--text); }
.stx-bar-num {
  font-family: var(--mono); font-size: 0.688rem; color: var(--text-muted);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.stx-track {
  position: relative; height: 7px; border-radius: 99px; background: var(--line); overflow: hidden;
}
.stx-track--thin { height: 5px; }
.stx-fill {
  position: absolute; inset: 0 auto 0 0; height: 100%; border-radius: 99px;
  background: var(--cat); transition: width 0.6s var(--ease-out);
}
/* „zapisane na później” – jaśniejsza warstwa pod spodem (do gdzie sięga zapis) */
.stx-fill--soft { z-index: -1; opacity: 0.28; }
.stx-track { isolation: isolate; }

/* --- pierścienie --- */
.stx-ring { display: block; }
.stx-ring-bg { fill: none; stroke: var(--line); }
.stx-ring-fg {
  fill: none; stroke: var(--cat); stroke-linecap: round;
  transition: stroke-dasharray 0.6s var(--ease-out);
}
.stx-ring--gold .stx-ring-fg { stroke: var(--gold); }
.stx-ring--subject .stx-ring-fg { stroke: var(--subject); }
.stx-ringset, .stx-exams { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.stx-ring-main { position: relative; flex: 0 0 auto; }
.stx-ring-center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; line-height: 1.1;
}
.stx-ring-center b { font-family: 'Lexend', sans-serif; font-size: 1.5rem; font-weight: 800; letter-spacing: -0.02em; }
.stx-ring-center span { font-family: var(--mono); font-size: 0.656rem; color: var(--text-muted); margin-top: 3px; }
.stx-ring-legend { display: grid; grid-template-columns: repeat(2, minmax(140px, 1fr)); gap: 10px 18px; flex: 1 1 260px; }
.stx-ring-item { display: flex; align-items: center; gap: 10px; }
.stx-ring-item > div { display: flex; flex-direction: column; line-height: 1.2; }
.stx-ring-lab { font-weight: 600; font-size: 0.813rem; }
.stx-ring-val { font-family: var(--mono); font-size: 0.656rem; color: var(--text-muted); }

/* --- mapa opanowania (waffle) --- */
.stx-wsec + .stx-wsec { margin-top: 16px; }
.stx-wsec-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.stx-wsec-lab {
  font-family: 'Lexend', sans-serif; font-weight: 700; font-size: 0.813rem;
  padding-left: 10px; border-left: 3px solid var(--cat);
}
.stx-wcats { display: flex; flex-direction: column; gap: 5px; }
.stx-wcat { display: grid; grid-template-columns: minmax(110px, 190px) 1fr auto; align-items: center; gap: 12px; }
.stx-wcells { display: flex; flex-wrap: wrap; gap: 3px; }
.stx-cell {
  display: block; width: 14px; height: 14px; border-radius: 3px;
  background: var(--line); border: 1px solid transparent;
  transition: background 0.3s var(--ease), transform 0.15s var(--ease);
}
a.stx-cell:hover { transform: scale(1.25); }
.stx-cell.is-done { background: var(--cat); }
.stx-cell.is-saved { background: color-mix(in srgb, var(--gold) 45%, var(--surface)); border-color: var(--gold); }
.stx-wcat-lab { font-size: 0.75rem; color: var(--text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stx-legend {
  display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 14px;
  font-family: var(--mono); font-size: 0.625rem; color: var(--text-muted);
}
.stx-legend span { display: inline-flex; align-items: center; gap: 6px; }
.stx-legend i { width: 11px; height: 11px; }
.stx-legend .stx-cell.is-done { --cat: var(--text-soft); }

/* --- kategorie (rozwijane) --- */
.stx-cat-sec summary { list-style: none; cursor: pointer; }
.stx-cat-sec summary::-webkit-details-marker { display: none; }
.stx-cat-sec + .stx-cat-sec { margin-top: 12px; }
.stx-cat-list { padding: 8px 0 4px 12px; border-left: 2px solid color-mix(in srgb, var(--cat) 25%, var(--line)); margin: 8px 0 0 2px; }
.stx-cat-row { display: grid; grid-template-columns: minmax(110px, 160px) 1fr 52px; align-items: center; gap: 10px; padding: 3px 0; }
.stx-cat-lab { font-size: 0.75rem; color: var(--text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stx-cat-row .stx-bar-num { text-align: right; }

/* --- arkusze: oś lat --- */
.stx-years-head { font-size: 0.813rem; color: var(--text-soft); margin-bottom: 12px; }
.stx-years-head b { font-family: var(--mono); color: var(--text); }
.stx-years-grid { display: flex; align-items: flex-end; gap: 5px; overflow-x: auto; padding-bottom: 2px; }
.stx-year { display: flex; flex-direction: column; align-items: center; gap: 5px; flex: 1 0 16px; min-width: 16px; }
.stx-year-stack { display: flex; flex-direction: column-reverse; gap: 3px; }
.stx-block {
  display: block; width: 16px; height: 11px; border-radius: 3px;
  background: var(--line); transition: background 0.3s var(--ease), transform 0.15s var(--ease);
}
a.stx-block:hover { transform: scale(1.15); }
.stx-block--rozszerzona { --cat: var(--subject); }
.stx-block--podstawowa { --cat: #2563EB; }
.stx-block.is-done { background: var(--cat); }
.stx-block.is-started { background: color-mix(in srgb, var(--gold) 55%, var(--surface)); box-shadow: inset 0 0 0 1px var(--gold); }
.stx-year-lab { font-family: var(--mono); font-size: 0.594rem; color: var(--text-muted); }
.stx-year.is-complete .stx-year-lab { color: var(--gold-ink); font-weight: 700; }

/* --- arkusze: pierścień + KPI --- */
.stx-exams-side { flex: 1 1 220px; }
.stx-kpis { display: flex; gap: 18px; margin-bottom: 12px; }
.stx-kpis > div { display: flex; flex-direction: column; line-height: 1.1; }
.stx-kpis b { font-family: 'Lexend', sans-serif; font-size: 1.25rem; font-weight: 800; }
.stx-kpis span { font-family: var(--mono); font-size: 0.625rem; color: var(--text-muted); letter-spacing: 0.06em; text-transform: uppercase; }

@media (max-width: 560px) {
  .stx-ring-legend { grid-template-columns: 1fr 1fr; }
  .stx-wcat { grid-template-columns: minmax(80px, 120px) 1fr auto; }
  .stx-cat-row { grid-template-columns: minmax(80px, 120px) 1fr 48px; }
}
@media (prefers-reduced-motion: reduce) {
  .stx-fill, .stx-ring-fg, .stx-cell, .stx-block { transition: none; }
}
