/* Progressive-pipeline UI styles (REQ-431..437, spec/tech/23 §23.7).
   Tokens come from dashboard.css :root.

   Two distinct surfaces, each with its own typography focus:
     - Progress page (.ts-progress-*): compact dashboard chrome
     - Result page (.ts-result-*, .ts-toc):  blog-typography prose
   Reading scale on the result surface mirrors the blog post body
   (19px / 1.7 desktop, 17px / 1.65 mobile) per the project-wide
   typography baseline (memory: feedback_typography_blog_baseline). */

/* ═══════════════════════════════════════════════════════════════════
   PROGRESS PAGE
   ═══════════════════════════════════════════════════════════════════ */

.ts-progress-head {
  margin-bottom: 32px;
}
.ts-progress-kicker {
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 10px;
}
.ts-progress-title {
  font-family: var(--f-display);
  font-style: italic;
  font-weight: 500;
  font-size: clamp(34px, 5.5vw, 56px);
  line-height: 1.08;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 0 0 18px;
}
.ts-progress-title em {
  color: var(--gold);
  font-style: italic;
}
.ts-progress-lede {
  font-family: var(--f-display);
  font-size: 19px;
  line-height: 1.55;
  color: var(--text-2);
  max-width: 56ch;
  margin: 0;
}

/* ── Progress dashboard (shared across pipelines) ──────────────── */
/* The visible UI is a D3 SVG component (`window.ProgressDashboard`)
   mounted into #ts-progress-mount. CSS here only styles the outer
   container chrome + SVG-internal text/rect classes. */

.ts-progress-dashboard {
  margin: 36px 0 32px;
  padding: 26px 28px 22px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(28, 25, 48, 0.55), rgba(22, 19, 36, 0.55));
  position: relative;
}
.ts-progress-dashboard::before,
.ts-progress-dashboard::after {
  content: '';
  position: absolute;
  width: 10px;
  height: 10px;
  border: 1px solid var(--gold);
  opacity: 0.5;
}
.ts-progress-dashboard::before { top: 8px; left: 8px; border-right: none; border-bottom: none; }
.ts-progress-dashboard::after  { bottom: 8px; right: 8px; border-left: none; border-top: none; }

.ts-progress-mount { display: block; }
.ts-pd-svg {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}
.ts-pd-total-kicker {
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  fill: var(--text-3);
}
.ts-pd-total-value {
  font-family: var(--f-display);
  font-style: italic;
  font-weight: 500;
  font-size: 32px;
  fill: var(--gold);
  letter-spacing: 0.005em;
  font-variant-numeric: tabular-nums;
}
.ts-pd-sep {
  stroke: var(--line);
  stroke-width: 1;
}
.ts-pd-bar-label {
  font-family: var(--f-display);
  font-style: italic;
  font-size: 15px;
  fill: var(--text);
  letter-spacing: 0.01em;
}
.ts-pd-bar-counts {
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.10em;
  fill: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.ts-pd-bar-track {
  fill: rgba(201, 168, 109, 0.12);
}
.ts-pd-bar-fill--phases {
  fill: var(--gold);
}
.ts-pd-bar-fill--current {
  fill: var(--gold-dim);
}

/* ── Per-phase cards ─────────────────────────────────────────────
   Hidden by default on the dashboard — they exist only as the
   substrate the orchestrator uses for SSE wiring. They surface
   only when a phase fails, to host the inline error message + the
   Retry / Skip buttons inside the dashboard. */

.ts-progressive-root {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ts-progressive-root:empty { display: none; }

.ts-phase-card {
  display: none;
  border: 1px solid rgba(184, 74, 46, 0.55);
  background: linear-gradient(180deg, rgba(48, 22, 18, 0.4), rgba(28, 19, 22, 0.4));
  padding: 14px 18px;
  position: relative;
  margin-top: 22px;
}
.ts-phase-card.ts-phase-failed { display: block; }

.ts-phase-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.ts-phase-label {
  font-family: var(--f-display);
  font-style: italic;
  font-size: 16px;
  color: var(--text);
  letter-spacing: 0.01em;
}
.ts-phase-card.ts-phase-running .ts-phase-label,
.ts-phase-card.ts-phase-done .ts-phase-label {
  color: var(--gold);
}
.ts-phase-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--f-mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-3);
}
.ts-phase-status {
  padding: 2px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  white-space: nowrap;
}
.ts-phase-card.ts-phase-running .ts-phase-status {
  border-color: var(--gold-dim);
  color: var(--gold);
  position: relative;
  padding-left: 22px;
}
.ts-phase-card.ts-phase-running .ts-phase-status::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
  animation: ts-phase-pulse 1.4s ease-in-out infinite;
}
@keyframes ts-phase-pulse {
  0%, 100% { opacity: 0.3; transform: translateY(-50%) scale(0.8); }
  50%      { opacity: 1;   transform: translateY(-50%) scale(1.2); }
}
.ts-phase-card.ts-phase-done .ts-phase-status {
  border-color: var(--gold);
  color: var(--gold);
}
.ts-phase-card.ts-phase-failed .ts-phase-status {
  border-color: rgba(184, 74, 46, 0.7);
  color: #d9745a;
}
.ts-phase-eta {
  font-family: var(--f-mono);
  font-size: 10.5px;
  color: var(--text-3);
  min-width: 46px;
  text-align: right;
}

/* On the progress page, hide the (empty) content slot completely. */
.ts-phase-card .ts-phase-content,
.ts-phase-card .ts-phase-progress { display: none; }

.ts-phase-error {
  margin-top: 8px;
  color: #d9745a;
  font-family: var(--f-sans);
  font-size: 13px;
  line-height: 1.55;
}
.ts-phase-error:empty { display: none; }

.ts-phase-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.ts-phase-actions:empty { display: none; }
.ts-phase-action {
  padding: 7px 16px;
  font-family: var(--f-sans);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  border: 1px solid var(--gold-dim);
  background: transparent;
  color: var(--gold);
  cursor: pointer;
  transition: all var(--t) var(--ease);
}
.ts-phase-action:hover { background: var(--gold); color: var(--bg); }
.ts-phase-action:disabled { opacity: 0.45; cursor: progress; }
.ts-phase-action-skip { border-color: var(--line); color: var(--text-3); }
.ts-phase-action-skip:hover { background: var(--line); color: var(--bg); }

/* Pipeline-level error banner. */
.ts-pipeline-banner {
  margin-top: 24px;
  padding: 14px 20px;
  border: 1px solid rgba(184, 74, 46, 0.5);
  color: #d9745a;
  font-family: var(--f-sans);
  font-size: 14px;
  background: rgba(48, 22, 18, 0.25);
}

/* ═══════════════════════════════════════════════════════════════════
   RESULT PAGE — blog-typography prose + TOC
   ═══════════════════════════════════════════════════════════════════ */

.ts-result-body {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 0 64px;
}

.ts-result-head {
  margin: 0 0 36px;
}
.ts-result-head .section-kicker {
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 10px;
}
.ts-result-head .section-title {
  font-family: var(--f-display);
  font-style: italic;
  font-weight: 500;
  font-size: clamp(34px, 5.5vw, 56px);
  line-height: 1.08;
  color: var(--text);
  margin: 0;
}
.ts-result-head .section-title em {
  color: var(--gold);
  font-style: italic;
}

.ts-result-partial-note {
  margin: 0 0 28px;
  padding: 12px 18px;
  border: 1px solid rgba(201, 168, 109, 0.35);
  background: rgba(201, 168, 109, 0.05);
  font-family: var(--f-sans);
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-2);
}

/* ── Section nav (TOC) — sticky right rail on desktop, top on mobile ─ */

.ts-toc {
  position: fixed;
  top: 100px;
  right: max(24px, calc((100vw - 760px) / 2 - 220px));
  width: 200px;
  z-index: 5;
  font-family: var(--f-sans);
}
.ts-toc-kicker {
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 10px;
  padding-left: 14px;
}
.ts-toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
  border-left: 1px solid var(--line);
}
.ts-toc-list li { margin: 0; }
.ts-toc-link {
  display: block;
  padding: 8px 14px;
  font-family: var(--f-display);
  font-size: 13.5px;
  line-height: 1.4;
  color: var(--text-3);
  text-decoration: none;
  border-left: 2px solid transparent;
  margin-left: -1px;
  transition: color var(--t) var(--ease), border-color var(--t) var(--ease);
}
.ts-toc-link:hover { color: var(--text-2); }
.ts-toc-link.is-active {
  color: var(--gold);
  border-left-color: var(--gold);
}
@media (max-width: 1100px) {
  .ts-toc {
    position: static;
    width: 100%;
    margin: 0 0 32px;
  }
  .ts-toc-kicker { padding-left: 0; }
  .ts-toc-list {
    border-left: none;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    display: flex;
    overflow-x: auto;
    scrollbar-width: thin;
  }
  .ts-toc-list li { flex: 0 0 auto; }
  .ts-toc-link {
    border-left: none;
    border-bottom: 2px solid transparent;
    margin-left: 0;
    margin-bottom: -1px;
    padding: 12px 16px;
    white-space: nowrap;
  }
  .ts-toc-link.is-active {
    border-left: none;
    border-bottom-color: var(--gold);
  }
}

/* ── Section blocks ──────────────────────────────────────────────── */

.ts-result-section {
  scroll-margin-top: 96px;
  margin: 56px 0 0;
  padding-top: 32px;
  border-top: 1px solid var(--line);
}
.ts-result-section:first-of-type {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}

.ts-result-section-title {
  font-family: var(--f-display);
  font-weight: 500;
  font-size: clamp(28px, 3.6vw, 40px);
  line-height: 1.18;
  color: var(--gold-2);
  margin: 0 0 24px;
  display: flex;
  align-items: baseline;
  gap: 16px;
}
.ts-result-section-roman {
  font-family: var(--f-display);
  font-style: italic;
  font-size: 0.65em;
  color: var(--gold);
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--gold-dim);
  padding-bottom: 2px;
  flex: 0 0 auto;
}

.ts-result-graphic {
  margin: 24px 0 32px;
}

/* ── Prose — calibrated to the blog post body scale ──────────── */

.ts-result-prose {
  font-family: var(--f-display);
  font-size: 19px;
  line-height: 1.7;
  color: var(--text);
}
.ts-result-prose .ts-subsection { margin-bottom: 28px; }
.ts-result-prose .ts-subsection:last-child { margin-bottom: 0; }
.ts-result-prose p {
  margin: 0 0 1.25rem;
  color: var(--text);
}
.ts-result-prose :is(h2, h3, h4) {
  font-family: var(--f-display);
  color: var(--gold-2);
  margin-top: 2.2rem;
  margin-bottom: 0.85rem;
  line-height: 1.2;
  letter-spacing: 0.005em;
  font-weight: 500;
}
.ts-result-prose h2 { font-size: clamp(26px, 3vw, 36px); }
.ts-result-prose h3 { font-size: clamp(22px, 2.4vw, 28px); }
.ts-result-prose h4 { font-size: 20px; }
.ts-result-prose strong { color: var(--gold-2); font-weight: 600; }
.ts-result-prose em { color: var(--text-2); font-style: italic; }
.ts-result-prose ul,
.ts-result-prose ol {
  margin: 1rem 0 1.25rem;
  padding-left: 1.5rem;
}
.ts-result-prose li { margin-bottom: 0.5rem; }
.ts-result-prose blockquote {
  margin: 1.5rem 0;
  padding: 0.5rem 1.25rem;
  border-left: 2px solid var(--gold-dim);
  color: var(--text-2);
  font-style: italic;
}

/* Astro-fact tags inside the prose stay readable but distinct. */
.ts-result-prose .astro-fact {
  cursor: pointer;
  border-bottom: 1px dashed var(--gold-dim);
  color: var(--gold-2);
  transition: color var(--t) var(--ease), border-color var(--t) var(--ease);
}
.ts-result-prose .astro-fact:hover {
  color: var(--gold);
  border-bottom-color: var(--gold);
}

@media (max-width: 700px) {
  .ts-result-body { padding: 0 16px 48px; }
  .ts-result-prose { font-size: 17px; line-height: 1.65; }
  .ts-result-prose h2 { font-size: 24px; }
  .ts-result-prose h3 { font-size: 21px; }
  .ts-result-prose h4 { font-size: 18px; }
  .ts-result-section { margin-top: 40px; padding-top: 24px; }
  .ts-result-section-title { gap: 12px; margin-bottom: 18px; }
}

/* ── Footer actions on the result page ──────────────────────── */

.ts-result-footer-actions {
  margin-top: 56px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}
.ts-result-action {
  padding: 11px 22px;
  font-family: var(--f-sans);
  font-size: 11.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  border: 1px solid var(--gold-dim);
  background: transparent;
  color: var(--gold);
  text-decoration: none;
  transition: all var(--t) var(--ease);
}
.ts-result-action:hover { background: var(--gold); color: var(--bg); }

/* REQ-578 — long-task UX: over-run + safe-to-leave affordances. */
/* When a phase burns past its ETA, the current-phase fill gently pulses so the
   surface reads as alive ("finalizing…") rather than a frozen full bar. */
.ts-pd-overrun .ts-pd-bar-fill--current {
  animation: ts-pd-pulse 1.6s ease-in-out infinite;
}
@keyframes ts-pd-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}
@media (prefers-reduced-motion: reduce) {
  .ts-pd-overrun .ts-pd-bar-fill--current { animation: none; }
}

/* "Safe to leave" reassurance line under the dashboard. */
.ts-progress-safe-to-leave {
  margin: 14px auto 0;
  max-width: 46ch;
  text-align: center;
  font-size: 0.86rem;
  line-height: 1.5;
  color: var(--muted, rgba(201,168,109,0.62));
  opacity: 0.85;
}

/* REQ-577/§2.5b — daily domain preview (moon-tracker + activity stats). */
.ts-preview { margin-top: 20px; }
.ts-preview-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.15rem;
  color: var(--gold, #c9a86d);
  text-align: center;
  margin-bottom: 14px;
  letter-spacing: 0.02em;
}
/* The HTML `hidden` attribute MUST win over the author `display` rules below.
   Preview blocks are flex/grid and mark themselves `hidden` until their phase
   lands; a plain `display:flex` beats the UA stylesheet's `[hidden]{display:none}`,
   which would leak an empty placeholder row on page load — exactly what REQ-576
   forbids. This file only ships on progress pages, so the reach is contained. */
[hidden] { display: none !important; }

/* Narrative preview block — the prose a pipeline reveals mid-run (monthly's
   `what_matters`, weekly's `spirit`, natal's portrait excerpt). Shared by every
   kind whose preview ends with a paragraph. */
.ts-preview-narrative {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid rgba(201,168,109,0.12);
  animation: npCardIn 0.8s ease-out both;
}
.ts-preview-narrative-body {
  max-width: 62ch;
  margin: 10px auto 0;
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.05rem;
  font-style: italic;
  line-height: 1.75;
  text-align: center;
  color: var(--cream-dim, rgba(232,220,196,0.78));
}

/* Stat row — the generic `.ts-preview-stats` form plus daily's original
   `.ts-daily-*` names, kept so the daily template needs no change. */
.ts-preview-stats,
.ts-daily-preview-stats {
  display: flex;
  justify-content: center;
  gap: 28px;
  flex-wrap: wrap;
}
.ts-stat,
.ts-daily-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 96px;
}
.ts-stat-value,
.ts-daily-stat-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.6rem;
  color: var(--gold-bright, #e3c88a);
  line-height: 1.2;
}
.ts-stat-label,
.ts-daily-stat-label {
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted, rgba(201,168,109,0.6));
  margin-top: 4px;
  text-align: center;
}

/* ── REQ-437/§2.17 — natal domain preview (chart signature + vector grid) ── */

.ts-natal-preview .ts-preview-stats { margin-bottom: 26px; }

.np-vector-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin-top: 6px;
}

.np-vector {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 14px 10px 12px;
  border: 1px solid rgba(201,168,109,0.14);
  border-radius: 3px;
  background: rgba(201,168,109,0.02);
  transition: opacity 0.5s ease, border-color 0.5s ease, background 0.5s ease;
}
.np-vector[data-state="queued"]  { opacity: 0.34; }
.np-vector[data-state="running"] {
  opacity: 1;
  border-color: rgba(201,168,109,0.4);
  animation: npVectorPulse 1.8s ease-in-out infinite;
}
.np-vector[data-state="done"] {
  opacity: 1;
  border-color: rgba(201,168,109,0.32);
  background: rgba(201,168,109,0.05);
}
@keyframes npVectorPulse {
  0%, 100% { background: rgba(201,168,109,0.03); }
  50%      { background: rgba(201,168,109,0.11); }
}
@media (prefers-reduced-motion: reduce) {
  .np-vector[data-state="running"] { animation: none; background: rgba(201,168,109,0.08); }
}

.np-vector-glyph {
  font-size: 1.3rem;
  color: var(--gold, #c9a86d);
  line-height: 1;
}
.np-vector-name {
  margin-top: 7px;
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted, rgba(201,168,109,0.62));
}
.np-vector-card {
  width: 62px;
  height: auto;
  margin-top: 10px;
  border: 1px solid rgba(201,168,109,0.22);
  animation: npCardIn 0.7s ease-out both;
}
@keyframes npCardIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.np-vector-archetype {
  margin-top: 8px;
  font-family: 'Cormorant Garamond', serif;
  font-size: 0.94rem;
  font-style: italic;
  color: var(--gold-bright, #e3c88a);
  line-height: 1.3;
}

/* ── REQ-437/§21.10 — derived domain preview (arms text · talisman picks) ── */

.ts-derived-preview .dp-motto-latin {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.35rem;
  color: var(--gold-bright, #e3c88a);
  text-align: center;
  letter-spacing: 0.04em;
}
.ts-derived-preview .dp-motto-translation {
  margin-top: 4px;
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 1rem;
  text-align: center;
  color: var(--muted, rgba(201,168,109,0.66));
}
.ts-derived-preview .dp-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 6px;
  vertical-align: middle;
  border: 1px solid rgba(201,168,109,0.32);
}

/* ── §10.7 — compatibility domain preview (aspects · dimensions · prose) ── */

.ts-compat-preview .cp-block { margin-top: 24px; }

/* Cross-aspect chips — the synastry phase's real output, before any LLM. */
.ts-compat-preview .cp-aspects {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}
.ts-compat-preview .cp-aspect {
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: 2px;
  font-family: var(--f-mono);
  font-size: 0.86rem;
  color: var(--gold-bright);
  background: var(--surface);
}

/* Dimension bars — one row per dimension as the analysis phase lands. */
.ts-compat-preview .cp-dimensions {
  max-width: 46ch;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.ts-compat-preview .cp-dimension {
  display: grid;
  grid-template-columns: minmax(0, 12ch) 1fr;
  align-items: center;
  gap: 12px;
}
.ts-compat-preview .cp-dim-name {
  font-size: 0.82rem;
  color: var(--text-2);
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* The split bar, previewed. Same two segments and the same polarity tokens the
   result page draws, so the transition between surfaces reads continuous. */
.ts-compat-preview .cp-dim-track {
  display: flex;
  height: 7px;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  overflow: hidden;
}
.ts-compat-preview .cp-dim-bar {
  display: block;
  height: 100%;
  transition: width var(--t) var(--ease);
}
.ts-compat-preview .cp-dim-bar--harmony { background: var(--harmony); }
.ts-compat-preview .cp-dim-bar--tension { background: var(--tension); }
/* A dimension no aspect touches — an empty track, never a half-filled one. */
.ts-compat-preview .cp-dim-track--empty { opacity: 0.45; }

/* ── §29.2 — codex domain preview (the square, then the scholar's voice) ── */

.ts-codex-preview .cx-block { margin-top: 20px; }
.ts-codex-preview .cx-chart-host {
  max-width: 420px;
  margin: 0 auto;
}
.ts-codex-preview .cx-dominant {
  margin-top: 12px;
  text-align: center;
  font-family: var(--f-mono);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted, var(--text-3));
}
