/* ═══ 15. TRACKER ════════════════════════════════════════════════════ */

.trk-picker { display: flex; align-items: center; gap: 8px; font-size: var(--text-sm); color: var(--ink-soft); }
.trk-picker select { min-width: 200px; height: var(--control-h-sm); }

/* Sub-title trailing the "Project Tracker" heading. */
.cover-sub {
  display: block; margin-top: 4px;
  font-size: var(--text-sm); color: var(--ink-faint); font-weight: 400;
  letter-spacing: 0; text-transform: none;
}

/* ── toolbar: picker + overall progress + insight, one full-width row ──── */
.trk-toolbar {
  flex: none;
  display: flex; align-items: center; gap: 28px;
  padding: 12px 18px;
  background: var(--panel-bg);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}
.trk-overall { display: flex; align-items: center; gap: 16px; flex: 1; min-width: 0; }
.trk-overall-cap {
  flex: none;
  font-size: var(--text-xs); color: var(--ink-faint);
  text-transform: uppercase; letter-spacing: .08em;
}
.trk-overall-row { display: flex; align-items: center; gap: 14px; flex: 1; min-width: 0; }
.trk-overall-num { flex: none; font-size: 24px; font-weight: 600; line-height: 1; }
.trk-overall-bar {
  flex: 1; min-width: 60px; height: 8px;
  background: var(--line); border-radius: var(--radius-bar); overflow: hidden;
}
.trk-overall-bar i { display: block; height: 100%; background: var(--fg); }
.trk-overall-help {
  flex: none; max-width: 220px;
  font-size: var(--text-xs); color: var(--ink-faint); line-height: 1.35;
}

/* ── strip: square grids + coordination gate bars + legend ────────────── */
.trk-overview {
  flex: none; height: 118px;
  display: flex; gap: 20px; align-items: flex-end;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line-strong);
  margin-bottom: 16px;
}
/* align-self:stretch (overriding the row's flex-end) pins the strip to the
   overview's fixed height. renderOverview() derives its row count from
   squaresEl.clientHeight, so that height MUST NOT depend on the grid it draws —
   otherwise rows→gridHeight→clientHeight→rows feeds back and the strip shrinks
   a little on every re-render. Stretching breaks that loop. */
.trk-squares {
  flex: 1; align-self: stretch;
  display: flex; gap: 7px; align-items: flex-end; min-width: 0;
}
.trk-sq-phase { display: flex; flex-direction: column; }
.trk-sq-grid { display: grid; gap: 2px; }
.trk-sq {
  width: 7px; height: 7px;
  background: var(--line);
  position: relative; overflow: hidden;
}
.trk-sq i {
  position: absolute; inset: 0;
  background: var(--fg);
  display: block;
}
.trk-sq-label {
  margin-top: 6px;
  text-align: center;
  font-size: 8px; color: var(--ink-faint);
  text-transform: capitalize; letter-spacing: .01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* Coordination gate bars — thin, tinted by sign-off state. */
.trk-sq-gate { position: relative; }
.trk-sq-gate .trk-sq i { background: var(--line-strong); }
.trk-sq-gate.t-warn .trk-sq i { background: var(--warn); }
.trk-sq-gate.t-ok .trk-sq i { background: var(--ok); }
.trk-sq-gate .trk-sq-label { color: var(--ink-faint); }
/* Gate name floats above its (2-square-wide) bar rather than trying to fit
   inside it — centered, unclipped, free to overflow past the bar's own
   width since the space above the strip is otherwise empty. */
.trk-sq-gate-label {
  position: absolute; bottom: 100%; left: 50%;
  transform: translateX(-50%);
  margin-bottom: 6px;
  font-size: 8px; color: var(--ink-faint);
  text-transform: capitalize; letter-spacing: .01em;
  white-space: nowrap;
}

.trk-legend {
  flex: none; align-self: flex-end;
  display: flex; flex-direction: column; gap: 6px;
}
.trk-leg { display: flex; align-items: center; gap: 6px; font-size: 8px; color: var(--ink-soft); }
.trk-leg i { width: 8px; height: 8px; flex: none; }
.trk-leg i.done { background: var(--fg); }
.trk-leg i.rem { background: var(--line); }

/* ── the scrolling body: phase cards only — gates sit below, frozen ───── */
/* This row itself no longer scrolls — it's pinned to exactly the space
   available above the frozen gates row (height:100% on .trk-cards below), so
   every card is visible without paging the whole row. Only a card whose own
   content is taller than that (DED, typically) scrolls internally — see
   .trk-card's own overflow-y below. Sibling of .trk-gates, not a parent. */
.trk-scroll {
  flex: 1; min-height: 0;
  overflow: hidden;
}
.trk-cards {
  height: 100%;
  display: grid;
  grid-template-rows: 1fr;   /* the single row fills .trk-scroll exactly */
  /* Pre-JS fallback only (tracker.js's applyCardLayout immediately overrides
     this with content-weighted or auto-fit tracks — see CARD_FALLBACK_MIN). */
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px; align-items: stretch;
}
/* Sibling of .trk-scroll (not inside it) — a fixed row that never scrolls,
   always showing the three sign-off gates regardless of how far the phase
   cards above have been scrolled. */
.trk-gates {
  flex: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  margin-top: 14px;
}
.trk-card {
  background: var(--panel-bg);
  border-radius: var(--radius-md);
  padding: 8px 8px;
  display: flex; flex-direction: column;
  /* min-height:0 lets the grid's stretched height actually cap this card
     instead of growing to fit its content; overflow-y then only engages
     (scrolls) when a card's content is genuinely taller than that — the
     other, shorter cards show in full with no scrollbar at all. */
  min-height: 0;
  overflow-y: auto;
}
.trk-card-head {
  display: flex; align-items: baseline; gap: 8px;
  padding-bottom: 9px; margin-bottom: 6px;
  border-bottom: 1px solid var(--line-strong);
}
.trk-card-head h4 { font-size: var(--text-base); font-weight: 500; letter-spacing: .2px; flex: 1; }
/* Advisory phase-owner initials (plan doc 12 §3.3). */
.trk-card-head .trk-owner {
  align-self: center;
  padding: 1px 6px; border-radius: var(--radius-pill);
  font-size: var(--text-xs); font-weight: 600; letter-spacing: .3px;
  color: var(--bg); background: var(--fg);
}
.trk-card-head .wt { font-size: var(--text-xs); color: var(--ink-faint); }
.trk-card-head .pct { font-size: var(--text-base); }
.trk-task-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin: 9px 0 3px;
  font-size: var(--text-sm); color: var(--ink-soft);
  text-transform: uppercase; letter-spacing: .08em;
}
.trk-item {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 0;
  font-size: var(--text-sm);
  border-bottom: 1px solid var(--line);
}
.trk-item:last-child { border-bottom: none; }
.trk-item.off { opacity: .45; }
.trk-item .code { flex: none; width: 26px; color: var(--ink-faint); font-size: var(--text-xs); }
.trk-item .iname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trk-item input.iname {
  border: none; border-bottom: 1px dashed var(--line-strong);
  border-radius: 0; padding: 1px 2px; background: transparent;
  font-size: var(--text-sm); width: 100%;
}
.trk-item .iwt { flex: none; color: var(--ink-faint); font-size: var(--text-xs); }
.trk-scope { flex: none; display: flex; align-items: center; }
/* Ghost checkbox — outline only, no solid accent-color fill (that read as
   too heavy/contrasty against the item row). A checkmark tick appears in
   --fg when checked; the box itself always stays transparent. */
.trk-scope input {
  appearance: none; -webkit-appearance: none;
  /* flex:none on .trk-scope isn't enough on its own — this input is still a
     flex ITEM there, and flex items get an automatic min-width based on
     their own content/padding. The base `input` reset's padding:0 8px was
     winning that min-size battle and stretching the box to ~17px (with the
     checkmark's `left:3px` then landing inside that padding, off-center) —
     resetting padding to 0 and pinning min-width/height removes both. */
  width: 12px; height: 12px;
  min-width: 12px; min-height: 12px;
  padding: 0;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  position: relative;
  transition: border-color var(--dur-fast);
}
.trk-scope input:hover { border-color: var(--fg); }
.trk-scope input:checked { border-color: var(--fg); }
.trk-scope input:checked::after {
  content: '';
  position: absolute; left: 3px; top: 1px;
  width: 3px; height: 6px;
  border: solid var(--fg);
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
}

/* One bordered pill — chevrons live inside the same border as the label
   (no per-arrow boxes), which trims the control's width to leave more room
   for item names. */
.stepper {
  flex: none; display: inline-flex; align-items: center;
  height: 20px;
  border: 1px solid var(--hairline); border-radius: var(--radius-md);
  overflow: hidden;
}
.stepper:hover { border-color: var(--fg); }
.stepper .stp {
  width: 15px; height: 100%; padding: 0;
  font-size: var(--text-sm); line-height: 1; color: var(--ink-soft);
  display: flex; align-items: center; justify-content: center;
  transition: transform var(--dur-fast), background var(--dur-fast), color var(--dur-fast);
}
.stepper .stp:hover:not(:disabled) { background: var(--hover-bg); color: var(--fg); }
.stepper .stp:active:not(:disabled) { transform: scale(0.94); }
.stepper .stp:disabled { color: var(--line-strong); cursor: default; }
/* min-width holds the longest state label ("Not started") on one line so the
   pill never reflows as the state changes. */
.stepper .stlabel {
  min-width: 56px; padding: 0 3px; text-align: center; white-space: nowrap;
  font-size: var(--text-xs); letter-spacing: .02em; line-height: 1;
}
.stepper .stlabel[data-level="0"] { color: var(--ink-faint); }
.stepper .stlabel[data-level="1"] { color: var(--ink-soft); }
.stepper .stlabel[data-level="2"] { color: var(--ink-soft); }
.stepper .stlabel[data-level="3"] { color: var(--ink); }
.stepper .stlabel[data-level="4"] { color: var(--fg); font-weight: 500; }

.rev-badge {
  flex: none;
  font-size: var(--text-xs);
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  background: var(--chip-bg); color: var(--ink-faint);
}
.rev-badge.r1, .rev-badge.r2 { color: var(--warn-text); background: color-mix(in srgb, var(--warn) 18%, transparent); }
.rev-badge.r3 { color: var(--bad-text); background: color-mix(in srgb, var(--bad) 18%, transparent); }
.rev-btn {
  flex: none; padding: 0 5px; height: 18px;
  border: 1px solid var(--hairline); border-radius: var(--radius-md);
  font-size: var(--text-xs); color: var(--ink-soft);
}
.rev-btn:hover { border-color: var(--fg); background: var(--hover-bg); }
.rev-btn:disabled { border-color: var(--line); color: var(--ink-faint); }

.trk-move { flex: none; display: flex; gap: 2px; }
.trk-add { margin-top: 8px; width: 100%; }
.trk-del {
  flex: none; width: 18px; height: 18px; padding: 0;
  color: var(--bad-text); font-size: var(--text-base); line-height: 1;
  border-radius: var(--radius-md);
}
.trk-del:hover { background: color-mix(in srgb, var(--bad) 20%, transparent); }

/* Small anchored delete-confirm popover (tracker.js openDelPop) — lives in
   #statusMenuLayer next to the status-menu it shares that layer with, top-left
   anchored under the × that opened it (not centered like the status menu,
   which would sit on top of the trigger). */
.trk-del-pop {
  position: absolute;
  pointer-events: auto;
  background: var(--popover-bg);
  -webkit-backdrop-filter: var(--popover-blur);
  backdrop-filter: var(--popover-blur);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  padding: 10px;
  width: 200px;
  box-shadow: var(--shadow-float);
  animation: menu-pop-in var(--dur-fast) ease-out;
}
.trk-del-pop p { font-size: var(--text-sm); color: var(--ink); line-height: 1.35; }
.trk-del-pop-actions {
  display: flex; justify-content: flex-end; gap: 6px;
  margin-top: 9px;
}

.trk-gate {
  display: flex; align-items: center; gap: 7px;
  margin-top: auto; padding-top: 9px;
  border-top: 1px solid var(--line-strong);
  font-size: var(--text-sm); color: var(--ink-soft);
}
.trk-gate .gdot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.trk-gate.ready .gdot { background: var(--ok); }
.trk-gate.ready .gstate { color: var(--ok-text); }
.trk-gate:not(.ready) .gdot { background: var(--warn); }
.trk-gate:not(.ready) .gstate { color: var(--warn-text); }
.trk-gate .glabel { flex: 1; }

/* ── sign-off gate cards (tri-state: Open / Pending / Approved) ────────── */
/* Row layout, not .trk-card's default column: name + note stack on the
   left, the selector sits on the right — align-items:center centers it
   against that WHOLE stacked block (title+note), not just the title line. */
.trk-gate-card {
  flex-direction: row; align-items: center; justify-content: space-between; gap: 10px;
}
.trk-gate-card-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.trk-gate-card h4 { font-size: var(--text-base); font-weight: 500; letter-spacing: .2px; flex: none; }
.trk-gate-note {
  font-size: 8px; color: var(--ink-faint);
}

.trk-seg {
  flex: none;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 0;
  border: 1px solid var(--hairline); border-radius: var(--radius-md);
  overflow: hidden;
}
.trk-seg-btn {
  padding: 5px 10px;
  font-size: var(--text-sm); color: var(--ink-soft);
  border-right: 1px solid var(--line);
  transition: background var(--dur-fast), color var(--dur-fast);
}
.trk-seg-btn:last-child { border-right: none; }
.trk-seg-btn:hover { background: var(--hover-bg); color: var(--fg); }
.trk-seg-btn.active { background: var(--fg); color: var(--bg); font-weight: 500; }
.trk-gate-card.t-warn .trk-seg-btn.active { background: var(--warn); color: #181613; }
.trk-gate-card.t-ok .trk-seg-btn.active { background: var(--ok); color: #181613; }


/* ═══ CONSTRUCTION VIEW ═══════════════════════════════════════════════════
   Two cards that replace the phase-card row and the sign-off gates while the
   toolbar's toggle is on Construction. Stage is set in the Project Manager;
   nothing here is tinted by a percentage, because construction has none.
   Spec: docs/feature-construction.md. */

/* Phases ↔ Construction toggle */
.trk-views { flex: none; display: flex; gap: 4px; }
.trk-view {
  font: inherit; font-size: var(--text-sm);
  background: transparent; color: var(--ink-soft);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: 5px 12px; cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast),
              border-color var(--dur-fast), transform var(--dur-fast);
}
.trk-view:hover:not(:disabled) { background: var(--hover-bg); color: var(--fg); }
.trk-view.on { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.trk-view:disabled { opacity: .4; cursor: not-allowed; }
/* Press feedback, the same instant-scale idiom every other control in the app
   already uses (.tab 0.94, .stp 0.94, .user-menu-toggle 0.98) — 0.97 suits this
   button's width. :not(:disabled) because the Construction half is disabled on
   non-construction projects and must not answer a press. */
.trk-view:active:not(:disabled) { transform: scale(0.97); }

/* Toolbar counters — what replaces the percentage in construction view. */
.trk-count { flex: none; font-size: var(--text-lg); font-weight: 500; }
.trk-count.quiet { color: var(--ink-soft); font-weight: 400; }
.trk-count.bad { color: var(--bad-text); }

/* The two cards fill the space the phase-card scroller had. */
.trk-construction { flex: 1; min-height: 0; display: flex; }
.trk-construction[hidden] { display: none; }
/* Toggling the view swaps a full half-screen of content; without this it hard
   cuts. Entrance only — renderAll() flips `display` synchronously, so the
   outgoing panel can't animate without JS orchestration, which is the normal
   trade for a tab-like swap. It cannot replay spuriously either: renderAll runs
   on every store emit while this view is open, but re-assigning hidden=false
   when it is already false changes no display value, and only a real
   display:none → non-none transition restarts a CSS animation (motion.css §20). */
.trk-construction:not([hidden]) { animation: cx-view-in var(--dur-base) ease-out; }
@keyframes cx-view-in { from { opacity: 0; transform: translateY(6px); } }
.cx-cards {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: minmax(0, 4fr) minmax(0, 5fr);
  gap: 16px;
}
.cx-card {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--panel-bg); border-radius: var(--radius-md);
  padding: 14px 16px;
}
.cx-card-head {
  flex: none; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 10px;
}
.cx-card-head h3 {
  font-size: var(--text-xs); color: var(--ink-faint);
  text-transform: uppercase; letter-spacing: .08em; font-weight: 400;
}
/* Only the card bodies scroll — the headers and composer stay put, so the
   "+ Raise issue" button is never scrolled away from a long list. */
.cx-body { flex: 1; min-height: 0; overflow-y: auto; }
.cx-list { list-style: none; margin: 0; padding: 0; }

/* composer + inline edit share one form skeleton */
.cx-composer, .cx-form { display: flex; flex-direction: column; gap: 8px; }
.cx-composer {
  flex: none; margin-bottom: 12px; padding: 10px;
  border: 1px solid var(--line); border-radius: var(--radius-md);
}
.cx-composer[hidden] { display: none; }
/* Opening a composer shoves the list below it down; reuse the app's shared
   pop-in (motion.css §20) rather than adding a third near-identical keyframe. */
.cx-composer:not([hidden]) { animation: menu-pop-in var(--dur-fast) ease-out; }
.cx-fields { display: flex; flex-wrap: wrap; gap: 8px; }
.cx-field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cx-field.grow { flex: 1 1 160px; }
.cx-field > span { font-size: var(--text-xs); color: var(--ink-faint); }
.cx-form textarea { font: inherit; font-size: var(--text-sm); resize: vertical; }
.cx-actions { display: flex; gap: 6px; margin-top: 6px; }
.cx-actions.end { justify-content: flex-end; }

/* An open issue: amber by default, red once past its own target. */
.cx-issue {
  border-left: 2px solid var(--warn);
  padding: 8px 0 10px 10px; margin-bottom: 10px;
}
.cx-issue.overdue { border-left-color: var(--bad); }
.cx-issue-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.cx-issue-title { font-size: var(--text-base); color: var(--fg); }
.cx-issue-target { font-size: var(--text-sm); color: var(--ink-soft); margin-left: auto; }
.cx-issue.overdue .cx-issue-target { color: var(--bad-text); font-weight: 500; }
.cx-issue-meta { font-size: var(--text-xs); color: var(--ink-faint); margin-top: 3px; }
.cx-issue-note { margin: 5px 0 0; font-size: var(--text-sm); color: var(--ink-soft); white-space: pre-wrap; }

/* The site log: manual updates and graduated fixes in one stream. */
.cx-log-row { padding: 7px 0; border-bottom: 1px solid var(--line); }
.cx-log-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.cx-log-row.fix .cx-log-head { cursor: pointer; }
.cx-log-date { flex: none; font-size: var(--text-sm); color: var(--ink-faint); min-width: 84px; }
.cx-badge {
  flex: none; font-size: var(--text-xs); letter-spacing: .04em;
  border-radius: var(--radius-sm); padding: 0 6px;
  border: 1px solid var(--line-strong); color: var(--ink-soft);
}
/* A fix is marked so a rough build and a smooth one don't read alike later. */
.cx-badge.fix { color: var(--warn-text); border-color: var(--warn); }
.cx-log-title { flex: 1; min-width: 0; font-size: var(--text-base); color: var(--fg); }
.cx-log-by { flex: none; font-size: var(--text-xs); color: var(--ink-faint); }
.cx-log-note { margin: 4px 0 0 92px; font-size: var(--text-sm); color: var(--ink-soft); white-space: pre-wrap; }
/* A fix's full story stays available but out of the way until asked for. */
.cx-log-detail { display: none; margin: 4px 0 0 92px; font-size: var(--text-xs); color: var(--ink-faint); }
.cx-log-row.open .cx-log-detail {
  display: block;
  animation: menu-pop-in var(--dur-fast) ease-out;
}

/* A resolved issue graduating from the left card into this one is the feature's
   defining move, and it otherwise happens with no bridge at all: the row simply
   vanishes from one list and exists in the other. Applied for ONE render only,
   via the justArrived flag in construction-view.js — this body is rebuilt by
   innerHTML on every store emit, so an unflagged entrance would replay whenever
   an unrelated project changed. Same one-shot pattern as attention-board.js's
   justExpanded. */
.cx-arrived { animation: menu-pop-in var(--dur-base) ease-out both; }

/* Row actions stay quiet until hovered — same restraint as the PM row pencil. */
.cx-issue .cx-actions, .cx-log-row .cx-actions {
  opacity: 0; transition: opacity var(--dur-fast);
}
.cx-issue:hover .cx-actions, .cx-issue:focus-within .cx-actions,
.cx-log-row:hover .cx-actions, .cx-log-row:focus-within .cx-actions { opacity: 1; }

/* Jump target from the dashboard's to-do panel. */
.cx-flash { animation: cx-flash var(--dur-base) ease-out 2 alternate; }
@keyframes cx-flash { to { background: var(--hover-bg); } }
