/* Statistics page. Built on the same palette tokens as the trainers, so the
   Chords themes (Urtext included) apply. Series colours: one per trainer,
   validated for colour-blind separation on dark and on the Urtext paper. */

:root {
  --ink: #0a0908;
  --ivory: #f2e9dc;
  --ivory-dim: #c9bfae;
  --gold: #c8a464;
  --gold-bright: #e4c584;
  --crimson: #a03b3b;
  --sage: #6b8e6b;
  --paper: #1a1614;
  --line: #2a2420;
  --gold-rgb: 200, 164, 100;
  --gold-bright-rgb: 228, 197, 132;

  --font-display: 'Playfair Display', 'Cormorant Garamond', serif;
  --font-body: 'Cormorant Garamond', serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius-sm: 2px;
  --ease: 0.2s ease;

  --s-chords: #3987e5;
  --s-sightreading: #d95926;
  --s-arpeggio: #199e70;
  --s-repertoire: #c98500;
  --s-jam: #d55181;
  --heat-rgb: var(--gold-rgb);
  --miss-rgb: 214, 92, 92;
  --card: rgba(255, 255, 255, 0.025);
}
body[data-theme="urtext"] {
  --s-chords: #2a78d6;
  --s-sightreading: #eb6834;
  --s-arpeggio: #1baf7a;
  --s-repertoire: #eda100;
  --s-jam: #e87ba4;
  --miss-rgb: 168, 48, 48;
  --card: rgba(255, 255, 255, 0.28);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

@media (min-width: 900px) {
  html { font-size: 110.5%; zoom: 0.9; }
}

html, body {
  background: var(--ink);
  color: var(--ivory);
  font-family: var(--font-body);
  min-height: 100vh;
  overflow-x: hidden;
}
body {
  background:
    radial-gradient(ellipse at 20% 0%, rgba(var(--gold-rgb), 0.08), transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(160, 59, 59, 0.05), transparent 50%),
    var(--ink);
  background-attachment: fixed;
}

.app {
  position: relative;
  max-width: 1200px;
  margin: 0 auto;
  padding: 3rem 2rem 6rem;
}
@media (max-width: 600px) {
  .app { padding: 1.5rem 1rem 4rem; }
}

a { color: var(--gold); }

button {
  font-family: var(--font-body);
  font-size: 1rem;
  background: transparent;
  color: var(--ivory);
  border: 1px solid var(--gold);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--ease);
}

.ghost-btn {
  border: 1px solid var(--line);
  color: var(--ivory-dim);
  font-size: 0.92rem;
  padding: 0.55rem 1rem;
}
.ghost-btn.small { font-size: 0.8rem; padding: 0.4rem 0.8rem; }
.ghost-btn.danger { border-color: rgba(160, 59, 59, 0.45); }
.ghost-btn.danger:hover { border-color: var(--crimson); color: var(--crimson); }

/* ---- hero ---- */

.hero { max-width: 760px; margin-bottom: 2rem; }
.hero-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(2rem, 5vw, 3.2rem);
  line-height: 1.1;
  margin-bottom: 0.8rem;
}
.hero-title em { color: var(--gold); font-style: italic; }
.hero-sub { font-size: 1.2rem; line-height: 1.5; color: var(--ivory-dim); }

/* ---- tabs ---- */

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1.6rem;
}
.tab {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border-color: var(--line);
  color: var(--ivory-dim);
  font-family: var(--font-display);
  font-size: 0.62rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  padding: 0.6rem 0.9rem;
}
.tab:hover { color: var(--ivory); border-color: rgba(var(--gold-rgb), 0.6); }
.tab.is-on { color: var(--ivory); border-color: var(--gold); background: rgba(var(--gold-rgb), 0.12); }

/* ---- tiles ---- */

.tiles {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.8rem;
  margin-bottom: 0.8rem;
}
@media (max-width: 760px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tile {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 1rem 1.1rem 0.9rem;
  min-width: 0;
}
.tile-label {
  font-family: var(--font-display);
  font-size: 0.58rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ivory-dim);
}
.tile-value {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 4vw, 2.3rem);
  line-height: 1.15;
  margin-top: 0.35rem;
  color: var(--ivory);
  font-variant-numeric: tabular-nums;
}
.tile-value small { font-size: 0.5em; color: var(--ivory-dim); }
.tile-sub { font-size: 0.95rem; color: var(--ivory-dim); font-style: italic; margin-top: 0.15rem; }

/* ---- cards ---- */

.panel-body { display: flex; flex-direction: column; gap: 0.8rem; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.8rem; }
@media (max-width: 760px) { .grid2 { grid-template-columns: minmax(0, 1fr); } }
.card {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 1.2rem 1.3rem 1.3rem;
  min-width: 0;
}
@media (max-width: 600px) { .card { padding: 1rem 0.9rem 1.1rem; } }
.card-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.68rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold);
}
.card-sub { font-size: 1rem; color: var(--ivory-dim); margin-top: 0.3rem; line-height: 1.4; }
.card-body { margin-top: 1rem; }
.empty { font-style: italic; color: var(--ivory-dim); font-size: 1.05rem; padding: 0.6rem 0; }

.chart-slot { width: 100%; overflow: hidden; }
.chart { display: block; overflow: visible; }

/* ---- chart marks ---- */

.chart .grid { stroke: var(--ivory-dim); stroke-opacity: 0.14; stroke-width: 1; }
.chart .base { stroke: var(--ivory-dim); stroke-opacity: 0.35; stroke-width: 1; }
.chart .axis { fill: var(--ivory-dim); font-family: var(--font-mono); font-size: 10px; }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover { fill: var(--ivory); fill-opacity: 0.05; }

.f-gold { fill: var(--gold); fill-opacity: 0.55; }
.f-gold-bright { fill: var(--gold-bright); }
.f-chords { fill: var(--s-chords); }
.f-sightreading { fill: var(--s-sightreading); }
.f-arpeggio { fill: var(--s-arpeggio); }
.f-repertoire { fill: var(--s-repertoire); }
.f-jam { fill: var(--s-jam); }
.f-ok { fill: var(--sage); }
.f-miss { fill: rgb(var(--miss-rgb)); }

.f-bg-chords { background: var(--s-chords); }
.f-bg-sightreading { background: var(--s-sightreading); }
.f-bg-arpeggio { background: var(--s-arpeggio); }
.f-bg-repertoire { background: var(--s-repertoire); }
.f-bg-jam { background: var(--s-jam); }
.f-bg-ok { background: var(--sage); }
.f-bg-miss { background: rgb(var(--miss-rgb)); }
.f-bg-grade-perfect { background: var(--gold-bright); }
.f-bg-grade-good { background: var(--gold); }
.f-bg-grade-late { background: rgba(var(--gold-rgb), 0.45); }
.f-bg-grade-miss { background: rgb(var(--miss-rgb)); }

.stroke-gold { fill: none; stroke: var(--gold); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.dot-gold { fill: var(--gold); fill-opacity: 0.45; stroke: var(--ink); stroke-width: 1.5; }
.stroke-jam { fill: none; stroke: var(--s-jam); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.dot-jam { fill: var(--s-jam); fill-opacity: 0.5; stroke: var(--ink); stroke-width: 1.5; }

/* Sequential heat: one hue, transparent → solid gold. */
.heat.h0 { fill: var(--ivory-dim); fill-opacity: 0.08; }
.heat.h1 { fill: rgb(var(--heat-rgb)); fill-opacity: 0.28; }
.heat.h2 { fill: rgb(var(--heat-rgb)); fill-opacity: 0.5; }
.heat.h3 { fill: rgb(var(--heat-rgb)); fill-opacity: 0.75; }
.heat.h4 { fill: rgb(var(--heat-rgb)); fill-opacity: 1; }
.heat { stroke: transparent; stroke-width: 2; }
.heat:hover { stroke: var(--ivory); }
.heat-sw.h0 { background: rgba(201, 191, 174, 0.12); }
.heat-sw.h1 { background: rgba(var(--heat-rgb), 0.28); }
.heat-sw.h2 { background: rgba(var(--heat-rgb), 0.5); }
.heat-sw.h3 { background: rgba(var(--heat-rgb), 0.75); }
.heat-sw.h4 { background: rgb(var(--heat-rgb)); }

/* Keyboard: key colour = how often that note was missed. */
.keyboard .kw { fill: var(--ivory); fill-opacity: 0.9; stroke: var(--ink); stroke-width: 1; }
.keyboard .kb { fill: #1c1814; stroke: var(--ink); stroke-width: 1; }
.keyboard .k-none.kw { fill: #8f877b; fill-opacity: 1; }
.keyboard .k-none.kb { fill: #1c1814; fill-opacity: 0.6; }
.keyboard .k0 { fill: #efe6d6; fill-opacity: 1; }
.keyboard .k1 { fill: color-mix(in srgb, rgb(var(--miss-rgb)) 30%, #efe6d6); fill-opacity: 1; }
.keyboard .k2 { fill: color-mix(in srgb, rgb(var(--miss-rgb)) 55%, #efe6d6); fill-opacity: 1; }
.keyboard .k3 { fill: color-mix(in srgb, rgb(var(--miss-rgb)) 78%, #efe6d6); fill-opacity: 1; }
.keyboard .k4 { fill: rgb(var(--miss-rgb)); fill-opacity: 1; }
.keyboard rect:hover { stroke: var(--gold-bright); stroke-width: 2; }
.keyboard .key-c { fill: #3a3128; pointer-events: none; }
.key-sw.k-none { background: #8f877b; }
.key-sw.k0 { background: #efe6d6; }
.key-sw.k1 { background: color-mix(in srgb, rgb(var(--miss-rgb)) 30%, #efe6d6); }
.key-sw.k2 { background: color-mix(in srgb, rgb(var(--miss-rgb)) 55%, #efe6d6); }
.key-sw.k3 { background: color-mix(in srgb, rgb(var(--miss-rgb)) 78%, #efe6d6); }
.key-sw.k4 { background: rgb(var(--miss-rgb)); }

/* Circle of fifths */
.cof-layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 1.5rem 2.5rem; align-items: center; }
@media (max-width: 760px) { .cof-layout { grid-template-columns: minmax(0, 1fr); } }
.cof-wrap { display: flex; flex-direction: column; align-items: center; min-width: 0; }
.cof-wrap .chart-slot { display: flex; justify-content: center; }
.mini-title { font-family: var(--font-display); font-weight: 500; font-size: 0.56rem; letter-spacing: 0.22em; text-transform: uppercase; color: var(--ivory-dim); margin: 0 0 0.6rem; }
.hbars + .mini-title { margin-top: 1.3rem; }
.f-bg-gold { background: var(--gold); }
.cof .cof-l { fill: var(--ivory); font-family: var(--font-body); font-size: 15px; font-weight: 500; pointer-events: none; }
.cof .cof-l.small { font-size: 12px; }
.cof .cof-l.on-strong { fill: var(--ink); }
.cof .cof-c { fill: var(--ivory); font-family: var(--font-display); font-size: 22px; }

/* ---- legend ---- */

.legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 1.1rem;
  margin-top: 0.8rem;
  font-size: 0.95rem;
  color: var(--ivory-dim);
}
.legend span { display: inline-flex; align-items: center; gap: 0.4rem; }
.heat-legend { gap: 0.25rem; }
.heat-legend > span:first-child { margin-right: 0.3rem; }
.heat-legend > span + span { margin-left: 0.3rem; }
.legend-gap { margin-left: 1rem !important; }
.sw { display: inline-block; width: 11px; height: 11px; border-radius: 2px; flex: none; }
.key-sw { box-shadow: inset 0 0 0 1px rgba(var(--gold-rgb), 0.35); }
.tab .sw { width: 8px; height: 8px; border-radius: 50%; }
.legend .t1 { background: #b07a48; }
.legend .t2 { background: #c7c4bd; }
.legend .t3 { background: var(--gold-bright); }

/* ---- horizontal bars ---- */

.hbars { display: flex; flex-direction: column; gap: 0.55rem; }
.hbar {
  display: grid;
  grid-template-columns: minmax(6.5rem, 34%) 1fr auto;
  align-items: center;
  gap: 0.7rem;
  font-size: 1rem;
}
.hbar-label { display: inline-flex; align-items: center; gap: 0.45rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { height: 10px; background: rgba(var(--gold-rgb), 0.08); border-radius: 0 4px 4px 0; overflow: hidden; }
.hbar-fill { display: block; height: 100%; border-radius: 0 4px 4px 0; }
.hbar-val { font-family: var(--font-mono); font-size: 0.75rem; color: var(--ivory-dim); white-space: nowrap; min-width: 4.6rem; text-align: right; }
.hbar:hover .hbar-label { color: var(--gold-bright); }

/* ---- coverage ---- */

.cov {
  display: grid;
  grid-template-columns: 2.6rem repeat(var(--cols), minmax(0, 1fr));
  gap: 3px;
  align-items: center;
  max-width: 760px;
}
.cov-h { font-family: var(--font-mono); font-size: 0.68rem; color: var(--ivory-dim); text-align: center; }
.cov-l { font-family: var(--font-mono); font-size: 0.7rem; color: var(--ivory-dim); }
.cov-c { aspect-ratio: 1.6; border-radius: 2px; background: rgba(201, 191, 174, 0.08); }
.cov-c.on { background: var(--s-chords); }
.cov-c:hover { outline: 1px solid var(--ivory); }

/* ---- daily goal dots ---- */

.goal-grid {
  display: grid;
  grid-template-columns: repeat(14, minmax(0, 1fr));
  gap: 5px;
  max-width: 380px;
}
.goal-dot { aspect-ratio: 1; border-radius: 50%; background: rgba(201, 191, 174, 0.1); }
.goal-dot.t1 { background: #b07a48; }
.goal-dot.t2 { background: #c7c4bd; }
.goal-dot.t3 { background: var(--gold-bright); box-shadow: 0 0 6px rgba(var(--gold-bright-rgb), 0.5); }

/* ---- facts, levels, pieces, table ---- */

.facts { display: grid; grid-template-columns: 1fr auto; gap: 0.45rem 1rem; font-size: 1.05rem; }
.facts dt { color: var(--ivory-dim); }
.facts dd { font-family: var(--font-mono); font-size: 0.85rem; text-align: right; align-self: center; }

.levels { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.2rem 1.6rem; }
.levels.compact { grid-template-columns: minmax(0, 1fr); }
@media (max-width: 760px) { .levels { grid-template-columns: minmax(0, 1fr); } }
.level-row {
  display: grid;
  grid-template-columns: 1.6rem minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 0 0.6rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid rgba(var(--gold-rgb), 0.1);
}
.level-row.is-dim { opacity: 0.5; }
.level-n { font-family: var(--font-mono); font-size: 0.7rem; color: var(--ivory-dim); }
.level-name { font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.level-meta { grid-column: 2 / -1; font-size: 0.88rem; color: var(--ivory-dim); font-style: italic; }
.stars { color: var(--gold-bright); letter-spacing: 0.1em; font-size: 0.9rem; }
.stars .off { color: var(--ivory-dim); opacity: 0.3; }

.pieces { display: flex; flex-direction: column; }
.piece {
  display: grid;
  grid-template-columns: 3rem minmax(0, 1fr);
  gap: 0.1rem 0.8rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid rgba(var(--gold-rgb), 0.1);
}
.piece-kind { grid-row: span 2; font-family: var(--font-mono); font-size: 0.65rem; color: var(--gold); border: 1px solid rgba(var(--gold-rgb), 0.4); border-radius: 2px; text-align: center; align-self: center; padding: 0.2rem 0; }
.piece-name { font-size: 1.1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.piece-meta { font-size: 0.9rem; color: var(--ivory-dim); font-style: italic; }

.table { width: 100%; border-collapse: collapse; font-size: 1rem; }
.table th { font-family: var(--font-display); font-size: 0.56rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--ivory-dim); font-weight: 500; text-align: left; padding: 0 0.5rem 0.5rem 0; }
.table td { padding: 0.45rem 0.5rem 0.45rem 0; border-top: 1px solid rgba(var(--gold-rgb), 0.1); }
.table .num { text-align: right; }
.table td.num { font-family: var(--font-mono); font-size: 0.8rem; }
.rank { font-family: var(--font-display); color: var(--gold-bright); }
@media (max-width: 600px) { .table th:last-child, .table td:last-child { display: none; } }

/* ---- chips (circle filter) ---- */

.chips { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 1rem; }
.chip {
  border-color: var(--line);
  color: var(--ivory-dim);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 0.3rem 0.6rem;
}
.chip:hover { border-color: var(--gold); color: var(--ivory); }
.chip.is-on { border-color: var(--gold); color: var(--ink); background: var(--gold); }

/* ---- tooltip ---- */

.tip {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 50;
  max-width: 280px;
  padding: 0.45rem 0.7rem;
  background: var(--paper);
  border: 1px solid rgba(var(--gold-rgb), 0.5);
  border-radius: 3px;
  color: var(--ivory);
  font-size: 0.95rem;
  line-height: 1.35;
  pointer-events: none;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

/* ---- footer ---- */

.page-footer {
  margin-top: 3rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  color: var(--ivory-dim);
  font-size: 0.95rem;
  font-style: italic;
}
.page-footer span { max-width: 640px; }
