/* Scale Command showcase: Tool C, the pipeline and projection chart, plus the read-only
 * projection card on /projections/ (.pj-*, drawn by js/projection-card.js into #projection-card).
 * Owns only .pipe-* and .pj-* classes, the chart inside #pipe-chart and the two mounts. Shell tokens
 * are used where the spec names them (--font-mono); the data colors are pinned here under --pipe-*
 * so the chart reads the same on any surface. Alias these to the shell's tokens if the names ever match.
 */
:root {
  --pipe-series-gold: var(--series-gold, #AC8C36);
  --pipe-series-gold-hi: var(--gold-light, #DFC06A);
  --pipe-series-blue: var(--series-blue, #4A8FD4);
  --pipe-band-alpha: var(--band-alpha, rgba(74, 143, 212, 0.16));
  --pipe-band-edge: var(--band-edge, rgba(74, 143, 212, 0.4));
  --pipe-hairline: var(--hair, rgba(200, 168, 78, 0.15));
  --pipe-hairline-strong: var(--hair-strong, rgba(200, 168, 78, 0.42));
  --pipe-hairline-faint: var(--hair-faint, rgba(200, 168, 78, 0.06));
  --pipe-gold: var(--gold, #C8A84E);
  --pipe-page: var(--bg, #0A0A0C);
  --pipe-text: var(--text, #EDEBE3);
  --pipe-text-2: var(--text-2, #A7A5A0);
  --pipe-muted: var(--muted, #8A8A93);
  --pipe-money: var(--money, #4ADE80);
  --pipe-amber: var(--amber, #E0A63A);
  --pipe-mono: var(--font-mono, 'Manrope', system-ui, sans-serif);
  --pipe-display: var(--font-display, 'Manrope', system-ui, sans-serif);
}

/* ---------- the chart container ---------- */

#pipe-chart {
  touch-action: pan-y;
  position: relative;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin-block: 12px 4px;
}

#pipe-chart .pipe-svg {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  overflow: visible;
  touch-action: pan-y;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.pipe-svg text {
  font-family: var(--pipe-mono);
  font-size: 10px;
  font-weight: 500;
  fill: var(--pipe-muted);
  pointer-events: none;
}

.pipe-grid-line {
  stroke: var(--pipe-hairline);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.pipe-grid-text {
  fill: var(--pipe-muted);
}

.pipe-bar-hair {
  stroke: var(--pipe-hairline-strong);
  stroke-width: 1;
  stroke-dasharray: 3 4;
  shape-rendering: crispEdges;
}

.pipe-bar-text {
  fill: var(--pipe-gold);
  font-size: 10px;
  letter-spacing: 0.04em;
  opacity: 0.9;
  paint-order: stroke;
  stroke: var(--pipe-page);
  stroke-width: 3px;
  stroke-linejoin: round;
}

.pipe-bar {
  fill: var(--pipe-series-gold);
  transition: height 0.35s ease, y 0.35s ease, fill 0.2s ease, opacity 0.2s ease;
}

.pipe-bar.is-zero {
  fill: var(--pipe-hairline-strong);
}

.pipe-bar.is-selected {
  fill: var(--pipe-series-gold-hi);
}

/* A hidden week input has focus: the selected bar carries the ring the input cannot show. */
#pipe-chart.is-kbd .pipe-bar.is-selected {
  stroke: var(--pipe-series-gold-hi);
  stroke-width: 2;
  paint-order: stroke;
}

.pipe-hit {
  fill: transparent;
  cursor: pointer;
}

@media (hover: hover) and (pointer: fine) {
  .pipe-hit { cursor: ns-resize; }
  /* The hit rect sits after its bar, so a `+ .pipe-bar` sibling rule would recolor the NEXT week. */
  .pipe-bars .pipe-hit:hover { fill: var(--pipe-hairline-faint); }
}

.pipe-svg.is-dragging .pipe-bar {
  transition: none;
}

.pipe-svg.is-dragging .pipe-hit {
  cursor: ns-resize;
}

.pipe-sel-label {
  fill: var(--pipe-text);
  font-size: 11px;
  font-weight: 700;
  paint-order: stroke;
  stroke: var(--pipe-page);
  stroke-width: 3px;
  stroke-linejoin: round;
}

.pipe-xlabel {
  fill: var(--pipe-text-2);
}

.pipe-xlabel.is-proj {
  fill: var(--pipe-series-blue);
}

.pipe-xlabel.is-hidden {
  display: none;
}

.pipe-proj.is-off {
  display: none;
}

.pipe-band-fill {
  fill: var(--pipe-band-alpha);
  stroke: none;
}

.pipe-proj-line {
  fill: none;
  stroke: var(--pipe-series-blue);
  stroke-width: 2;
  stroke-dasharray: 5 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.pipe-proj-dot {
  fill: var(--pipe-series-blue);
}

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

.pipe-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin: 4px 0 0 38px;
  font-family: var(--pipe-mono);
  font-size: 11px;
  color: var(--pipe-muted);
  letter-spacing: 0.02em;
}

.pipe-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 24px;
}

.pipe-legend-swatch {
  display: inline-block;
  width: 14px;
  height: 8px;
  border-radius: 2px;
  background: var(--pipe-series-gold);
}

.pipe-legend-item.is-proj .pipe-legend-swatch {
  height: 0;
  border-top: 2px dashed var(--pipe-series-blue);
  border-radius: 0;
  background: none;
}

.pipe-legend-item.is-band .pipe-legend-swatch {
  background: var(--pipe-band-alpha);
  border: 1px solid var(--pipe-band-edge);
}

/* ---------- stage note under the tracker ---------- */

.pipe-stage-note {
  margin: 10px 0 0;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--pipe-text-2);
}

.pipe-stage-word {
  font-family: var(--pipe-display);
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  color: var(--pipe-gold);
}

.pipe-stage-note.is-paused .pipe-stage-word {
  color: var(--pipe-amber);
}

/* ---------- the 6 AM log ---------- */

#pipe-log {
  margin-top: 14px;
  font-family: var(--pipe-mono);
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--pipe-text-2);
}

.pipe-log-list,
#pipe-log > ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.pipe-log-head {
  color: var(--pipe-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  padding: 0 0 6px;
  border-bottom: 1px solid var(--pipe-hairline);
  margin-bottom: 6px;
}

.pipe-log-line {
  display: flex;
  gap: 12px;
  align-items: baseline;
  padding: 4px 0;
  border-bottom: 1px solid var(--pipe-hairline);
}

.pipe-log-line:last-child {
  border-bottom: 0;
}

.pipe-log-week {
  flex: 0 0 auto;
  min-width: 4.5em;
  color: var(--pipe-muted);
}

.pipe-log-line.is-now {
  color: var(--pipe-text);
}

.pipe-log-line.is-now .pipe-log-week {
  color: var(--pipe-gold);
}

/* ---------- next 30 days line ---------- */

#pipe-next30 {
  margin-top: 12px;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--pipe-text);
}

#pipe-next30.is-empty {
  color: var(--pipe-text-2);
}

.pipe-next-num {
  font-family: var(--pipe-mono);
  font-weight: 700;
  color: var(--pipe-money);
  font-variant-numeric: tabular-nums;
}

.pipe-next-range {
  font-family: var(--pipe-mono);
  font-size: 0.85em;
  color: var(--pipe-text-2);
}

/* ---------- narrow screens ---------- */

@media (max-width: 620px) {
  .pipe-legend { margin-left: 0; gap: 6px 14px; }
  .pipe-log-line { gap: 8px; }
  .pipe-log-week { min-width: 4em; }
}

/* ---------- the mount: inside a .row-visual column or a full-width block ---------- */

#pipeline-tool,
#pipe-log,
#pipe-next30 {
  max-width: 100%;
  min-width: 0;
}

/* ---------- the projection card on /projections/ ---------- */

#projection-card {
  /* the shell's .app-card caps the card at 420px like every other app card; only guard shrink */
  min-width: 0;
}

.pj-card {
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin: 0;
  padding: 16px;
  background: var(--card, #141418);
  border: 1px solid var(--pipe-hairline);
  border-radius: var(--radius-card, 10px);
  color: var(--pipe-text);
  font-size: 0.9rem;
  line-height: 1.45;
}

.pj-card * { box-sizing: border-box; min-width: 0; }
.pj-card p { margin: 0; }

.pj-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.pj-title {
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--pipe-text-2);
}

.pj-chips { display: flex; gap: 6px; flex-wrap: wrap; }

.pj-chip {
  position: relative;
  min-height: 28px;
  min-width: 36px;
  padding: 0 10px;
  border: 1px solid var(--pipe-hairline);
  border-radius: var(--radius-chip, 6px);
  background: transparent;
  color: var(--pipe-text-2);
  font-family: var(--pipe-mono);
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

/* 44px hit area on a 28px chip: a transparent box, the visual unchanged. */
.pj-chip::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 44px;
  transform: translateY(-50%);
}

.pj-chip:hover { color: var(--pipe-text); border-color: var(--pipe-hairline-strong); }
.pj-chip.is-on { background: var(--raised, #1B1B21); border-color: var(--pipe-gold); color: var(--pipe-series-gold-hi); }
.pj-chip:focus-visible { outline: 2px solid var(--pipe-series-gold-hi); outline-offset: 2px; }

.pj-big { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }

.pj-figure {
  font-family: var(--pipe-mono);
  font-weight: 700;
  font-size: clamp(1.7rem, 2vw + 1.1rem, 2.2rem);
  line-height: 1.1;
  letter-spacing: -0.01em;
  color: var(--pipe-money);
  font-variant-numeric: tabular-nums;
}

.pj-card.is-empty .pj-figure {
  font-family: var(--pipe-display);
  font-weight: 500;
  font-size: 1rem;
  color: var(--pipe-text-2);
}

.pj-range {
  margin-top: 4px;
  font-family: var(--pipe-mono);
  font-size: 0.85rem;
  color: var(--pipe-text-2);
  font-variant-numeric: tabular-nums;
}

.pj-range[hidden] { display: none; }

.pj-chart { margin-top: 12px; }
.pj-chart:empty { display: none; }

.pj-svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: 150px;
  overflow: visible;
}

.pj-band { fill: var(--pipe-series-blue); fill-opacity: 0.14; stroke: none; }
.pj-solid { fill: none; stroke: var(--pipe-series-gold); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.pj-dashed { fill: none; stroke: var(--pipe-series-blue); stroke-width: 2; stroke-dasharray: 5 4; stroke-linejoin: round; stroke-linecap: round; }

.pj-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 6px;
  font-family: var(--pipe-mono);
  font-size: 10px;
  letter-spacing: 0.02em;
  color: var(--pipe-muted);
}

.pj-legend[hidden] { display: none; }

.pj-lg { display: inline-flex; align-items: center; gap: 6px; min-height: 20px; }
.pj-lg::before { content: ''; display: inline-block; width: 14px; height: 2px; background: var(--pipe-series-gold); }
.pj-lg-proj::before { background: repeating-linear-gradient(90deg, var(--pipe-series-blue) 0 4px, transparent 4px 7px); }
.pj-lg-band::before { height: 8px; background: var(--pipe-band-alpha); border: 1px solid var(--pipe-band-edge); }

.pj-shop {
  margin-top: 12px;
  font-family: var(--pipe-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--pipe-muted);
}

/* The slider demo: the one ledger row the shell's grammar styles, then the line in the app's words. */
.pj-demo {
  margin-top: 12px;
  padding-top: 4px;
  border-top: 1px solid var(--pipe-hairline);
}

.pj-demo[hidden] { display: none; }

.pj-row { border-bottom: 0; }

.pj-line {
  margin-top: 2px;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--pipe-text);
  overflow-wrap: anywhere;
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .pipe-bar { transition: none; }
  .pj-chip { transition: none; }
}
