/* ==========================================================================
   Progress surface v2 (Phase 5 of Saved + Progress Rebuild)
   --------------------------------------------------------------------------
   Lifted from docs/progress-mockup.html with three strips:
     1. Removed mockup-local :root token overrides (we use design/tokens.css)
     2. Removed .pr-meta-section + tagline-picker blocks (mockup-only chrome)
     3. Removed the * { box-sizing/margin/padding } global reset

   Heat tokens (--heat-0..--heat-4) live in design/tokens.css under both
   theme blocks so any future surface can reuse them.

   Legacy design/progress.css continues to style the v1 showProgress surface
   until Phase 6 cleanup. Active when body.pr-active is set by _showProgress
   (parallel to wb-active, sv-active, ait-v2-active patterns).
   ========================================================================== */

/* Width override: beat legacy progress.css's max-width:860px rule */
body.pr-active[data-view="progress"] #ct,
body.pr-active #ct {
  max-width: 1480px;
  padding: 0;
}

/* ===== Shell ===== */
.pr-shell {
  max-width: 1480px;
  margin: 0 auto;
  padding: var(--sp-6) var(--sp-8) var(--sp-12);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.5;
  color: var(--tx);
}

/* ===== Header ===== */
.pr-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-6);
  padding-bottom: var(--sp-8);
  margin-bottom: var(--sp-8);
  border-bottom: 0.5px solid var(--bdr);
}
.pr-header-left { flex: 1; min-width: 0; }
.pr-back {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  color: var(--tx2);
  font-size: var(--fs-sm);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: none;
  margin-bottom: var(--sp-3);
  transition: color var(--dur) var(--ease-out);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: var(--font-sans);
}
.pr-back:hover { color: var(--ac); }
.pr-back::before {
  content: "";
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--ac);
}
.pr-title {
  font-family: var(--font-serif);
  font-size: var(--fs-4xl);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.05;
  margin-bottom: var(--sp-2);
}
.pr-tagline {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 17px;
  line-height: 1.55;
  color: var(--tx1);
  max-width: 640px;
}
.pr-header-actions {
  display: flex;
  gap: var(--sp-2);
  flex-shrink: 0;
  margin-top: var(--sp-2);
  align-items: center;
}

.pr-range-toggle {
  display: flex;
  gap: 0;
  padding: 3px;
  background: var(--bg2);
  border: 0.5px solid var(--bdr);
  border-radius: var(--radius-md);
}
.pr-range {
  padding: 6px 12px;
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--tx2);
  border-radius: 6px;
  border: none;
  background: none;
  cursor: pointer;
  transition: all var(--dur) var(--ease-out);
}
.pr-range:hover { color: var(--tx); }
.pr-range.is-active { background: var(--bg3); color: var(--tx); }

/* ===== Section ===== */
.pr-section {
  margin-bottom: var(--sp-10);
  animation: pr-section-in 480ms var(--ease-out) backwards;
}
@keyframes pr-section-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.pr-section:nth-of-type(1) { animation-delay: 0ms; }
.pr-section:nth-of-type(2) { animation-delay: 80ms; }
.pr-section:nth-of-type(3) { animation-delay: 160ms; }
.pr-section:nth-of-type(4) { animation-delay: 240ms; }
.pr-section:nth-of-type(5) { animation-delay: 320ms; }

.pr-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: var(--sp-5);
  gap: var(--sp-4);
}
.pr-eyebrow {
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--tx2);
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
}
.pr-eyebrow::before {
  content: "";
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--ac);
}
.pr-section-title {
  font-family: var(--font-serif);
  font-size: var(--fs-2xl);
  font-weight: 500;
  letter-spacing: -0.01em;
  margin-top: 6px;
}
.pr-section-sub {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: var(--fs-sm);
  color: var(--tx3);
}

/* ===== KPI tiles ===== */
.pr-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--sp-4);
}
.pr-kpi {
  background: var(--bg2);
  border: 0.5px solid var(--bdr);
  border-radius: var(--radius-md);
  padding: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  position: relative;
  overflow: hidden;
  transition: all var(--dur) var(--ease-out);
}
.pr-kpi:hover {
  border-color: var(--bdr2);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.pr-kpi-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.pr-kpi-label {
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--tx2);
}
.pr-kpi-trend {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 7px;
  border-radius: var(--radius-full);
  background: var(--gn-bg);
  color: var(--gn);
  letter-spacing: 0.02em;
}
.pr-kpi-trend.is-down {
  background: rgba(217, 119, 102, 0.18);
  color: var(--rd);
}
.pr-kpi-trend.is-flat {
  background: rgba(163, 153, 136, 0.18);
  color: var(--tx2);
}
.pr-kpi-num {
  font-family: var(--font-serif);
  font-size: 42px;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--tx);
  font-variant-numeric: tabular-nums;
}
.pr-kpi-sub {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: var(--fs-sm);
  color: var(--tx2);
  line-height: 1.4;
}
.pr-kpi-spark {
  width: 100%;
  height: 32px;
  margin-top: var(--sp-2);
}
.pr-kpi-spark svg { width: 100%; height: 100%; display: block; }

/* ===== Heatmap ===== */
.pr-heatmap-wrap {
  background: var(--bg2);
  border: 0.5px solid var(--bdr);
  border-radius: var(--radius-md);
  padding: var(--sp-5);
}
.pr-heatmap-grid {
  display: grid;
  gap: 4px;
  /* Center the grid horizontally when its fixed-cell-size width is less
     than the container (4w / 12w views). Replaces min-height: 200px which
     was forcing rows to be ~26px tall, which combined with cells'
     aspect-ratio:1 made cells 26px wide, which (53 cols × 26px) overflowed
     the wrap container by ~508px in 1Y view (Moses screenshot 2026-05-26). */
  justify-content: center;
}
.pr-heatmap-corner { grid-row: 1; grid-column: 1; }
.pr-heatmap-week-label {
  font-family: var(--font-sans);
  font-size: 9px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--tx3);
  text-align: center;
  align-self: center;
}
.pr-heatmap-day-label {
  font-family: var(--font-sans);
  font-size: 9px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--tx3);
  align-self: center;
  text-align: right;
  padding-right: 6px;
}
.pr-heatmap-cell {
  /* Fixed 14×14 px cells (GitHub commit-activity heatmap style). Replaces
     aspect-ratio: 1 + flex grid sizing which let cells inflate to ~26px in
     1Y view, causing 121 cells to render outside the wrap container.
     14px × 53 cols + 52 × 4px gap + 28px label = 978px, fits the 1052px
     wrap inner cleanly. Updated 2026-05-26. */
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: var(--heat-0);
  cursor: pointer;
  transition: transform var(--dur) var(--ease-out), outline var(--dur) var(--ease-out);
  position: relative;
}
.pr-heatmap-cell[data-i="1"] { background: var(--heat-1); }
.pr-heatmap-cell[data-i="2"] { background: var(--heat-2); }
.pr-heatmap-cell[data-i="3"] { background: var(--heat-3); }
.pr-heatmap-cell[data-i="4"] { background: var(--heat-4); }
.pr-heatmap-cell:hover {
  transform: scale(1.18);
  outline: 1px solid var(--ac);
  z-index: 2;
}
.pr-heatmap-cell[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  bottom: 130%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg3);
  color: var(--tx);
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 4px;
  border: 0.5px solid var(--bdr2);
  white-space: nowrap;
  pointer-events: none;
  box-shadow: var(--shadow-sm);
  z-index: 3;
}

.pr-heatmap-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: var(--sp-4);
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 11px;
  color: var(--tx3);
}
.pr-heatmap-legend-scale { display: flex; gap: 3px; }
.pr-heatmap-legend-scale span {
  width: 12px; height: 12px;
  border-radius: 3px;
}

/* ===== Two-column row ===== */
.pr-row-2 {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: var(--sp-5);
}
@media (max-width: 980px) {
  .pr-row-2 { grid-template-columns: 1fr; }
}

.pr-panel {
  background: var(--bg2);
  border: 0.5px solid var(--bdr);
  border-radius: var(--radius-md);
  padding: var(--sp-5);
}
.pr-panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: var(--sp-4);
}
.pr-panel-title {
  font-family: var(--font-serif);
  font-size: var(--fs-lg);
  font-weight: 500;
  letter-spacing: -0.01em;
}
.pr-panel-sub {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: var(--fs-xs);
  color: var(--tx3);
}

/* Stacked bar chart (activity by tool, by week) */
.pr-stack-chart {
  height: 200px;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding-bottom: 24px;
  position: relative;
}
.pr-stack-bar {
  flex: 1;
  display: flex;
  flex-direction: column-reverse;
  gap: 1px;
  position: relative;
  border-radius: 4px 4px 0 0;
  overflow: hidden;
  cursor: pointer;
  transition: opacity var(--dur) var(--ease-out);
  min-height: 2px;
}
.pr-stack-bar:hover { opacity: 0.85; }
.pr-stack-seg {
  width: 100%;
  transition: filter var(--dur) var(--ease-out);
}
.pr-stack-seg[data-tool="tutor"]      { background: var(--cy); }
.pr-stack-seg[data-tool="code"]       { background: var(--gn); }
.pr-stack-seg[data-tool="whiteboard"] { background: var(--ac); }
.pr-stack-seg[data-tool="saved"]      { background: var(--yl); }
.pr-stack-label {
  position: absolute;
  bottom: -20px;
  left: 0; right: 0;
  font-family: var(--font-sans);
  font-size: 9px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--tx3);
  text-align: center;
}

.pr-legend {
  display: flex;
  gap: var(--sp-4);
  flex-wrap: wrap;
  margin-top: var(--sp-4);
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 11px;
  color: var(--tx2);
}
.pr-legend-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.pr-legend-dot::before {
  content: "";
  width: 9px; height: 9px;
  border-radius: 2px;
  background: currentColor;
}
.pr-legend-dot[data-tool="tutor"]      { color: var(--cy); }
.pr-legend-dot[data-tool="code"]       { color: var(--gn); }
.pr-legend-dot[data-tool="whiteboard"] { color: var(--ac); }
.pr-legend-dot[data-tool="saved"]      { color: var(--yl); }
.pr-legend-dot span:last-child { color: var(--tx2); }

/* Time-of-day chart */
.pr-tod-chart {
  height: 200px;
  display: flex;
  align-items: flex-end;
  gap: 3px;
  padding-bottom: 24px;
  position: relative;
}
.pr-tod-bar {
  flex: 1;
  background: var(--ac-soft);
  border-radius: 3px 3px 0 0;
  position: relative;
  transition: background var(--dur) var(--ease-out);
  min-height: 2px;
}
.pr-tod-bar.is-peak { background: var(--ac); }
.pr-tod-bar:hover { background: var(--ac2); }
.pr-tod-bar[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  bottom: 108%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg3);
  color: var(--tx);
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 4px;
  border: 0.5px solid var(--bdr2);
  white-space: nowrap;
  pointer-events: none;
  box-shadow: var(--shadow-sm);
  z-index: 2;
}
.pr-tod-labels {
  position: absolute;
  bottom: 0;
  left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  font-family: var(--font-sans);
  font-size: 9px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--tx3);
}

/* Topic breakdown */
.pr-topics-wrap {
  background: var(--bg2);
  border: 0.5px solid var(--bdr);
  border-radius: var(--radius-md);
  padding: var(--sp-5);
}
.pr-topic-bar {
  display: flex;
  height: 40px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: var(--sp-4);
  background: var(--bg3);
}
.pr-topic-seg {
  position: relative;
  transition: filter var(--dur) var(--ease-out);
}
.pr-topic-seg:hover { filter: brightness(1.08); }
/* Dynamic palette: rotate through 5 accent tones for unknown topic names */
.pr-topic-seg[data-tone="0"] { background: var(--ac); }
.pr-topic-seg[data-tone="1"] { background: var(--cy); }
.pr-topic-seg[data-tone="2"] { background: var(--gn); }
.pr-topic-seg[data-tone="3"] { background: var(--yl); }
.pr-topic-seg[data-tone="4"] { background: var(--bdr2); }
.pr-topic-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: var(--sp-3);
}
.pr-topic-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: var(--sp-2) 0;
  font-family: var(--font-serif);
  font-size: var(--fs-sm);
  color: var(--tx1);
}
.pr-topic-dot {
  width: 10px; height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}
.pr-topic-dot[data-tone="0"] { background: var(--ac); }
.pr-topic-dot[data-tone="1"] { background: var(--cy); }
.pr-topic-dot[data-tone="2"] { background: var(--gn); }
.pr-topic-dot[data-tone="3"] { background: var(--yl); }
.pr-topic-dot[data-tone="4"] { background: var(--bdr2); }
.pr-topic-pct {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--tx2);
  font-variant-numeric: tabular-nums;
}

/* Calibration log */
.pr-calibration {
  background: var(--bg2);
  border: 0.5px solid var(--bdr);
  border-radius: var(--radius-md);
  padding: var(--sp-5);
}
.pr-cal-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}
.pr-cal-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--ac);
  color: var(--ac-tx);
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--dur) var(--ease-out);
}
.pr-cal-add-btn:hover { background: var(--ac2); }
.pr-cal-add-btn::before {
  content: "+";
  font-size: 14px;
  line-height: 1;
}

.pr-cal-form {
  background: var(--bg3);
  border: 0.5px solid var(--bdr2);
  border-radius: var(--radius-sm);
  padding: var(--sp-4);
  margin-bottom: var(--sp-5);
  display: none;
}
.pr-cal-form.is-open { display: block; }
.pr-cal-form-row { margin-bottom: var(--sp-3); }
.pr-cal-form-label {
  display: block;
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--tx2);
  margin-bottom: 6px;
}
.pr-cal-form-input,
.pr-cal-form-textarea {
  width: 100%;
  background: var(--bg2);
  border: 0.5px solid var(--bdr);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-family: var(--font-serif);
  font-size: var(--fs-sm);
  color: var(--tx);
  line-height: 1.5;
}
.pr-cal-form-textarea {
  min-height: 88px;
  resize: vertical;
  font-family: var(--font-serif);
}
.pr-cal-form-hint {
  margin-top: 4px;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: var(--fs-xs);
  color: var(--tx3);
}
.pr-cal-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
}
.pr-cal-form-cancel,
.pr-cal-form-save {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  border: 0.5px solid var(--bdr);
  transition: all var(--dur) var(--ease-out);
}
.pr-cal-form-cancel {
  background: none;
  color: var(--tx2);
}
.pr-cal-form-cancel:hover {
  color: var(--tx);
  background: var(--hover-bg);
}
.pr-cal-form-save {
  background: var(--ac);
  color: var(--ac-tx);
  border-color: var(--ac);
}
.pr-cal-form-save:hover { background: var(--ac2); }
.pr-cal-form-save:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.pr-cal-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
}
.pr-cal-entry {
  display: grid;
  grid-template-columns: 96px 1fr 24px;
  gap: var(--sp-4);
  padding-left: var(--sp-4);
  border-left: 0.5px dashed var(--bdr2);
  position: relative;
}
.pr-cal-date {
  font-family: var(--font-sans);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--tx3);
  padding-top: 3px;
}
.pr-cal-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.pr-cal-belief {
  font-family: var(--font-serif);
  font-size: var(--fs-sm);
  color: var(--tx2);
  font-style: italic;
}
.pr-cal-belief::before {
  content: "Believed: ";
  font-style: normal;
  font-family: var(--font-sans);
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ac);
  margin-right: 6px;
}
.pr-cal-correction {
  font-family: var(--font-serif);
  font-size: var(--fs-md);
  line-height: 1.55;
  color: var(--tx);
  word-wrap: break-word;
}
.pr-cal-delete {
  align-self: start;
  background: none;
  border: none;
  color: var(--tx3);
  font-size: 16px;
  line-height: 1;
  padding: 4px;
  cursor: pointer;
  opacity: 0;
  transition: all var(--dur) var(--ease-out);
  border-radius: var(--radius-sm);
}
.pr-cal-entry:hover .pr-cal-delete { opacity: 1; }
.pr-cal-delete:hover {
  color: var(--rd);
  background: var(--hover-bg);
}

.pr-cal-show-all {
  margin-top: var(--sp-4);
  display: block;
  width: 100%;
  text-align: center;
  background: none;
  border: 0.5px dashed var(--bdr2);
  color: var(--tx2);
  font-family: var(--font-sans);
  font-size: var(--fs-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--dur) var(--ease-out);
}
.pr-cal-show-all:hover {
  color: var(--tx);
  border-color: var(--ac);
}

.pr-cal-empty {
  text-align: center;
  padding: var(--sp-6);
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--tx3);
}

/* ===== Empty states (activityLog empty / calibration empty) ===== */
.pr-empty-state {
  background: var(--bg2);
  border: 0.5px dashed var(--bdr2);
  border-radius: var(--radius-md);
  padding: var(--sp-8);
  text-align: center;
}
.pr-empty-state-title {
  font-family: var(--font-serif);
  font-size: var(--fs-lg);
  font-weight: 500;
  color: var(--tx);
  margin-bottom: var(--sp-2);
}
.pr-empty-state-body {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: var(--fs-sm);
  color: var(--tx2);
  max-width: 460px;
  margin: 0 auto;
  line-height: 1.55;
}

/* Reduced-motion respect */
@media (prefers-reduced-motion: reduce) {
  .pr-section { animation: none !important; }
  .pr-kpi:hover { transform: none !important; }
  .pr-heatmap-cell:hover { transform: none !important; }
}
