/* views/stats.css — the progress screen.
   Charts: one series in brand blue, thin bars with a 4px rounded top,
   2px gaps, a recessive baseline, and a hover/focus tooltip. */

.stat-tiles {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: var(--s-5); overflow: hidden;
}
.stat-tiles > div { padding: var(--s-4) var(--s-5); display: grid; gap: 2px; min-width: 0; }
.stat-tiles > div + div { border-inline-start: 1px solid var(--line); }
.stat-tiles dt { display: flex; align-items: center; gap: 6px; color: var(--ink-3); font-size: var(--text-sm); }
.stat-tiles dd { font-family: var(--font-display); font-size: var(--text-xl); font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.15; }
.stat-tiles small { font-family: var(--font-body); font-size: var(--text-sm); font-weight: 400; color: var(--ink-3); }

.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-4); margin-top: var(--s-5); }
.chart { padding: var(--s-5); display: grid; gap: var(--s-4); margin: 0; }
.chart figcaption { display: grid; gap: 2px; }
.chart h2 { font-size: var(--text-md); }

.bars {
  display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 2px;
  align-items: end; height: 150px; padding-top: 22px;
  border-bottom: 1px solid var(--line);
}
.bar-col {
  position: relative; display: flex; flex-direction: column; justify-content: end; align-items: center;
  height: 100%; outline: none;
}
.bar {
  display: block; width: 100%; max-width: 26px; min-height: 0;
  background: var(--brand); border-radius: 4px 4px 0 0;
  transform-origin: bottom; animation: rise 600ms var(--ease) both;
}
.bar-col small {
  position: absolute; top: 100%; margin-top: 6px;
  font-size: .7rem; color: var(--ink-3); white-space: nowrap;
}
.bar-peak { position: absolute; top: -20px; font-size: var(--text-xs); color: var(--ink-2); white-space: nowrap; }
.bars + .chart-table { margin-top: var(--s-4); }

/* Tooltip: the column is the hit target, wider and taller than the bar. */
.bar-col:hover .bar, .bar-col:focus-visible .bar { background: var(--brand-hover); }
.bar-col:hover::after, .bar-col:focus-visible::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); z-index: 5;
  padding: 6px 10px; border-radius: var(--r-sm); white-space: nowrap;
  background: var(--ink); color: var(--paper); font-size: var(--text-xs); font-weight: 500;
  box-shadow: var(--shadow-2); pointer-events: none;
}

/* Memory strength: one hue, light → dark as memory gets stronger. */
.bar.seq-0 { background: var(--line-strong); }
.bar.seq-1 { background: color-mix(in srgb, var(--brand) 30%, var(--surface)); }
.bar.seq-2 { background: color-mix(in srgb, var(--brand) 45%, var(--surface)); }
.bar.seq-3 { background: color-mix(in srgb, var(--brand) 60%, var(--surface)); }
.bar.seq-4 { background: color-mix(in srgb, var(--brand) 75%, var(--surface)); }
.bar.seq-5 { background: color-mix(in srgb, var(--brand) 88%, var(--ink)); }
.bar.seq-6 { background: color-mix(in srgb, var(--brand) 70%, var(--ink)); }

.chart-table summary { display: flex; align-items: center; min-height: var(--tap); cursor: pointer; color: var(--ink-2); font-size: var(--text-sm); }
.chart-table table { margin-top: var(--s-2); border-collapse: collapse; font-size: var(--text-sm); width: 100%; }
.chart-table td { padding: 4px 0; border-bottom: 1px solid var(--line); }
.chart-table td + td { text-align: right; font-variant-numeric: tabular-nums; }
.stats-note { margin-top: var(--s-4); }
.forecast { margin-top: var(--s-5); }

/* Recall forecast: 7 bars, today highlighted */
.fc-bars {
  list-style: none; display: grid; grid-template-columns: repeat(7, 1fr); gap: var(--s-1);
  padding: var(--s-4) var(--s-5);
}
.fc-bars li { display: grid; justify-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.fc-bars b { font-size: var(--text-sm); min-height: 1.2em; }
.fc-bars small { color: var(--ink-3); font-size: var(--text-2xs); white-space: nowrap; }
.fc-bar { display: flex; align-items: end; width: 100%; max-width: 44px; height: 72px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.fc-bar i { display: block; width: 100%; background: var(--brand); border-radius: 6px 6px 0 0; transform-origin: bottom; animation: rise 600ms var(--ease) both; }
.fc-bars .is-today .fc-bar i { background: var(--mark); }
.fc-bars .is-today small { color: var(--ink); font-weight: 600; }



@media (max-width: 900px) {
  .stat-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-tiles > div + div { border-inline-start: 0; }
  .stat-tiles > div:nth-child(even) { border-inline-start: 1px solid var(--line); }
  .stat-tiles > div:nth-child(n + 3) { border-top: 1px solid var(--line); }
  .chart-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .bar-col small { font-size: .72rem; }
  .stat-tiles > div { padding: 13px var(--s-4); }
  .stat-tiles dd { font-size: var(--text-lg); }
  .stat-tiles small { display: block; margin-top: 2px; font-size: var(--text-xs); }
}

/* ── Your week (Saturday → Friday) ─────────────────────────────── */
.week-page { max-width: var(--activity-max); }
.wk-head { margin-bottom: var(--s-4); }
.wk-head h1 { font-family: var(--font-display); font-size: var(--text-3xl); letter-spacing: -0.02em; }
.wk-card { display: grid; gap: var(--s-5); padding: clamp(20px, 4vw, 32px); }
.wk-headline { font-family: var(--font-display); font-size: clamp(1.6rem, 1.2rem + 2vw, 2.2rem); line-height: 1.2; letter-spacing: -0.02em; text-wrap: balance; }

.wk-days { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: var(--s-1); }
.wk-days li { display: grid; justify-items: center; gap: var(--s-1); }
.wk-days small { font-size: var(--text-2xs); color: var(--ink-3); white-space: nowrap; }
/* Seven columns and "Today" collide on a 320px phone with Larger text;
   "Now" says the same thing in three letters. */
.today-long { display: inline; }
.today-short { display: none; }
@media (max-width: 360px) {
  .today-long { display: none; }
  .today-short { display: inline; }
  .wk-days { gap: 2px; }
  .fc-bars { padding-inline: var(--s-3); gap: 4px; }
}
.wk-dot { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; border: 1.5px solid var(--line-strong); color: var(--on-brand); }
.wk-days .is-done .wk-dot { background: var(--brand); border-color: var(--brand); }
.wk-days .is-future .wk-dot { border-style: dashed; border-color: var(--line); }
.wk-days .is-today small { color: var(--ink); font-weight: 700; }
.wk-days .is-today .wk-dot { box-shadow: 0 0 0 3px var(--mark); }

.wk-numbers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-4) var(--s-5); margin: 0; }
.wk-numbers > div { display: grid; gap: 2px; padding-top: var(--s-3); border-top: 1px solid var(--line); }
.wk-numbers dt { font-size: var(--text-sm); color: var(--ink-2); }
.wk-numbers dd { margin: 0; font-family: var(--font-display); font-size: var(--text-2xl); font-variant-numeric: tabular-nums; line-height: 1.1; }
.wk-numbers dd small { font-family: var(--font-body); font-size: var(--text-sm); color: var(--ink-2); }
.wk-delta { font-size: var(--text-xs); color: var(--ink-3); }
.wk-delta.is-up { color: var(--good); }
@media (min-width: 720px) { .wk-numbers { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.wk-note { display: flex; gap: var(--s-2); align-items: baseline; padding: var(--s-3) var(--s-4); border-radius: var(--r-md); background: var(--mark-soft); color: var(--on-mark); line-height: 1.5; }
.wk-note .icon { flex: none; transform: translateY(2px); }
.wk-nav { margin-top: var(--s-5); gap: var(--s-2); flex-wrap: wrap; }
.wk-nav .btn-primary { margin-inline-start: auto; }

/* Toward the next milestone: the highlighter fills the track */
.wk-milestone { display: grid; gap: var(--s-2); margin-top: var(--s-5); }
.wk-milestone p { display: flex; gap: var(--s-2); align-items: baseline; font-size: var(--text-sm); color: var(--ink-2); }
.wk-milestone .icon { flex: none; color: var(--on-mark); transform: translateY(2px); }
.wk-milestone b { color: var(--ink); }
.wk-track { height: 10px; border-radius: var(--r-pill); background: var(--surface-2); overflow: hidden; }
.wk-track i { display: block; height: 100%; background: var(--mark); border-radius: inherit; }

.stats-week { display: grid; gap: var(--s-3); padding: var(--s-4) var(--s-5); margin-bottom: var(--s-2); }
.wk-best { margin-top: calc(var(--s-2) * -1); }
