/* ============================================================
   AI4S-Benchmark · Task workflow
   Lifecycle timeline and stage meter, the proposal checklist,
   the task PR pre-flight checker and the contributor guide.
   Loaded after components.css and pages.css; it only adds
   components and narrowly scoped fixes.
   ============================================================ */

/* ---------------- Fixes ---------------- */

/* Domain chips: `.form-field label { display: block }` outranks `.choice`,
   so the checkbox sat on the text baseline instead of centred on it. */
.form-field .choice { display: flex; align-items: center; }

/* Board rows: keep id · title · badge on one line, so a long title wraps
   inside its own column instead of pushing the badge onto a line of its own. */
@media (min-width: 701px) {
  .task-row__head {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: baseline;
  }
  .task-row__badges { margin-left: 0; }
}

/* Field names are free text; keep that filter a normal width. */
#filter-field_name { width: 17rem; }
#filter-stage { width: 14.5rem; }
@media (max-width: 700px) {
  #filter-field_name, #filter-stage { width: 100%; }
}

/* Math in one-line summaries sits on the text line. */
.task-row__desc .katex { font-size: 1em; }

/* Task hero: the long, free-text field sits on a line of its own. */
.task-hero__meta .task-hero__field { flex-basis: 100%; }

.badge--implementation { background: var(--blue-soft); color: #1B5FD9; border-color: #C9DCFF; }

/* ---------------- Stage meter (board rows) ---------------- */
.stage-meter {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--ink-muted);
  white-space: nowrap;
}
.stage-meter__bar { display: inline-flex; gap: 3px; }
.stage-meter__bar i {
  display: block;
  width: 1.1rem;
  height: 0.3rem;
  border-radius: var(--radius-full);
  background: var(--border);
}
.stage-meter__bar i.is-done { background: var(--cyan-deep); }
.stage-meter__bar i.is-current { background: var(--electric-blue); }
.stage-meter__bar i.is-attention { background: var(--amber); }
.stage-meter__bar i.is-stopped { background: var(--red); }
.task-row__foot .task-row__facts { margin-left: 0; }
@media (max-width: 700px) {
  .stage-meter { margin-left: 0; }
}

/* ---------------- Lifecycle timeline (task page) ---------------- */
.stagetrack {
  margin-top: var(--space-6);
  padding: var(--space-5) var(--space-5) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-raised, var(--surface));
}
.stagetrack__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2) var(--space-4);
  margin-bottom: var(--space-4);
}
.stagetrack__head h2 {
  margin: 0;
  font-size: var(--text-md);
  border: 0;
  padding: 0;
}
.stagetrack__head p { margin: 0; font-size: var(--text-sm); color: var(--ink-muted); }
.stagetrack__track {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  /* One column per public stage (PUBLIC_STAGE_COUNT in js/lifecycle.js). */
  grid-template-columns: repeat(auto-fit, minmax(0, 17rem));
  gap: var(--space-3);
}
.stagetrack__step {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-width: 0;
}
/* connector from this dot to the next one */
.stagetrack__step:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 0.95rem;
  left: 2.3rem;
  right: calc(-1 * var(--space-3) + 0.35rem);
  height: 2px;
  background: var(--border);
}
.stagetrack__step.is-done:not(:last-child)::after { background: var(--cyan-deep); }
.stagetrack__dot {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 50%;
  border: 2px dashed var(--border-strong);
  background: var(--surface);
  color: var(--ink-muted);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
}
.stagetrack__dot svg { width: 0.95rem; height: 0.95rem; }
.stagetrack__step.is-done .stagetrack__dot { border: 2px solid var(--cyan-deep); background: var(--cyan-deep); color: #fff; }
.stagetrack__step.is-current .stagetrack__dot { border: 2px solid var(--electric-blue); color: var(--electric-blue); box-shadow: 0 0 0 4px var(--blue-soft); }
.stagetrack__step.is-attention .stagetrack__dot { border: 2px solid var(--amber); color: var(--amber); box-shadow: 0 0 0 4px var(--amber-soft); }
.stagetrack__step.is-stopped .stagetrack__dot { border: 2px solid var(--red); background: var(--red); color: #fff; }
.stagetrack__label {
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--navy);
  line-height: var(--leading-snug);
}
.stagetrack__step.is-upcoming .stagetrack__label { color: var(--ink-muted); font-weight: 600; }
.stagetrack__now {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.05rem 0.4rem;
  border-radius: var(--radius-full);
  background: var(--blue-soft);
  color: #1B5FD9;
  font-family: var(--font-mono);
  font-size: 0.625rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  vertical-align: 0.1em;
}
.stagetrack__step.is-attention .stagetrack__now { background: var(--amber-soft); color: var(--amber); }
.stagetrack__step.is-stopped .stagetrack__now { background: var(--red-soft); color: #A23A3A; }
.stagetrack__note { font-size: var(--text-sm); color: var(--ink-secondary); line-height: var(--leading-snug); }
.stagetrack__step.is-upcoming .stagetrack__note { color: var(--ink-faint); }
.stagetrack__meta { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--ink-muted); overflow-wrap: anywhere; }
.stagetrack__link { font-size: var(--text-sm); font-weight: 600; width: fit-content; }
@media (max-width: 860px) {
  .stagetrack { padding: var(--space-4); }
  .stagetrack__track { grid-template-columns: 1fr; gap: var(--space-4); }
  .stagetrack__step { padding-left: 2.7rem; min-height: 1.9rem; }
  .stagetrack__dot { position: absolute; left: 0; top: 0; }
  .stagetrack__step:not(:last-child)::after {
    top: 2.1rem;
    bottom: calc(-1 * var(--space-4) + 0.2rem);
    left: 0.9rem;
    right: auto;
    width: 2px;
    height: auto;
  }
}

/* ---------------- Proposal checklist ---------------- */
.advice-note {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  margin: 0.4rem 0 0;
  padding: 0.45rem 0.65rem;
  border-radius: var(--radius-sm);
  background: var(--amber-soft);
  border: 1px solid #F0DCBE;
  color: #7A5212;
  font-size: var(--text-xs);
  line-height: 1.45;
}
.advice-note--tip { background: var(--blue-soft); border-color: #C9DCFF; color: #1F4E9E; }
.advice-note svg { width: 0.95rem; height: 0.95rem; flex-shrink: 0; margin-top: 0.05rem; }
.advice-note a { color: inherit; text-decoration: underline; }

.checklist {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: var(--space-4) var(--space-5);
  margin: var(--space-4) 0;
}
.checklist__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}
.checklist__head h3 { margin: 0; font-size: var(--text-md); }
.checklist__summary { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--ink-muted); }
.checklist__intro { margin: 0 0 var(--space-3); font-size: var(--text-sm); color: var(--ink-muted); }
.checklist ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.checklist li {
  display: grid;
  grid-template-columns: 1.1rem minmax(0, 1fr);
  gap: 0.55rem;
  font-size: var(--text-sm);
  color: var(--ink-secondary);
  line-height: 1.5;
}
.checklist li svg { width: 1.05rem; height: 1.05rem; margin-top: 0.15rem; }
.checklist li.is-ok svg { color: var(--cyan-deep); }
.checklist li.is-warn svg { color: var(--amber); }
.checklist li.is-fail svg { color: var(--red); }
.checklist li.is-tip svg { color: var(--electric-blue); }
.checklist li.is-info svg { color: var(--ink-muted); }
.checklist li strong { color: var(--navy); }
.checklist__field { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--ink-muted); margin-right: 0.35rem; }
.checklist button.checklist__goto {
  border: 0;
  background: none;
  padding: 0;
  color: var(--electric-blue);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.checklist button.checklist__goto:hover { text-decoration: underline; }
.aside-card .checklist { border: 0; padding: 0; margin: 0; }
.aside-card .checklist__head { margin-bottom: var(--space-2); }
.aside-card .checklist__head h3 { font-size: var(--text-xs); margin: 0; }
.aside-card .checklist__intro { font-size: var(--text-xs); }
/* Aside list items are flex rows in pages.css; checklist items keep their icon grid. */
.aside-card .checklist li { display: grid; }
.aside-card .checklist li { font-size: var(--text-xs); }

/* ---------------- Guide page ---------------- */
.guide-layout {
  display: grid;
  grid-template-columns: 14rem minmax(0, 1fr);
  gap: var(--space-7);
  padding-block: var(--space-7);
  align-items: start;
}
.guide-toc { position: sticky; top: calc(var(--header-height) + var(--space-4)); }
.guide-toc ol { list-style: none; margin: 0; padding: 0; counter-reset: toc; }
.guide-toc a {
  display: block;
  padding: 0.4rem 0.75rem;
  border-left: 2px solid var(--border);
  color: var(--ink-muted);
  font-size: var(--text-sm);
}
.guide-toc a:hover { color: var(--navy); border-left-color: var(--electric-blue); text-decoration: none; }
.guide-body { max-width: 48rem; }
.guide-body > section { margin-bottom: var(--space-8); }
.guide-body h2 {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  font-size: var(--text-xl);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
}
.guide-step-num {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--electric-blue);
  font-weight: 600;
}
.guide-body h3 { font-size: var(--text-md); margin-top: var(--space-5); }
.guide-body p, .guide-body li { color: var(--ink-secondary); }
.guide-body pre {
  background: var(--navy);
  color: #E6ECF7;
  padding: var(--space-4);
  border-radius: var(--radius-md);
  overflow-x: auto;
  font-size: var(--text-xs);
  line-height: 1.6;
}
.guide-body pre code { background: none; color: inherit; padding: 0; }
.guide-body .def-grid { grid-template-columns: 1fr; }
.guide-callout { margin: var(--space-4) 0; }
.guide-files { display: grid; gap: var(--space-2); margin: var(--space-4) 0; }
.guide-files > div {
  display: grid;
  grid-template-columns: 13rem minmax(0, 1fr);
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  font-size: var(--text-sm);
}
.guide-files code { font-weight: 600; color: var(--navy); }
.guide-outcomes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-3); margin: var(--space-4) 0; }
.guide-outcomes > div {
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  font-size: var(--text-sm);
}
.guide-outcomes .badge { margin-bottom: var(--space-2); }
.guide-outcomes p { margin: 0; }
.guide-checklist { list-style: none; padding: 0; display: grid; gap: 0.55rem; }
.guide-checklist li {
  display: grid;
  grid-template-columns: 1.1rem minmax(0, 1fr);
  gap: 0.6rem;
}
.guide-checklist li::before {
  content: "";
  width: 1rem;
  height: 1rem;
  margin-top: 0.25rem;
  border: 1.5px solid var(--border-strong);
  border-radius: 4px;
  background: var(--surface);
}
@media (max-width: 900px) {
  .guide-layout { grid-template-columns: minmax(0, 1fr); gap: var(--space-5); }
  .guide-toc { position: static; }
  .guide-outcomes { grid-template-columns: 1fr; }
  .guide-files > div { grid-template-columns: 1fr; gap: var(--space-1); }
}

/* ---------------- Pre-flight checker ---------------- */
.preflight-inputs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
  margin: var(--space-5) 0;
}
.preflight-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.preflight-card h2 { margin: 0; font-size: var(--text-lg); }
.preflight-card p { margin: 0; font-size: var(--text-sm); color: var(--ink-muted); }
.preflight-card .form-field { margin: 0; }
.preflight-card__row { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; margin-top: auto; }
.preflight-card__row input[type="url"] {
  flex: 1 1 14rem;
  min-width: 0;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  background: var(--surface);
}
.preflight-card__row input[type="url"]:focus { outline: none; border-color: var(--electric-blue); box-shadow: var(--focus-ring); }
.preflight-examples { font-size: var(--text-xs); color: var(--ink-muted); }
.preflight-examples button {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  color: var(--electric-blue);
  cursor: pointer;
  text-align: left;
  overflow-wrap: anywhere;
}
.preflight-examples button:hover { text-decoration: underline; }
.preflight-status { min-height: 1.4rem; font-size: var(--text-sm); color: var(--ink-muted); }
.preflight-status.is-error { color: var(--red); }
.preflight-result { margin-bottom: var(--space-7); }
.preflight-task {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  margin-bottom: var(--space-5);
  overflow: hidden;
}
.preflight-task__head {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
  background: var(--surface-sunken, var(--bg));
}
.preflight-task__head h3 { margin: 0; font-size: var(--text-md); overflow-wrap: anywhere; }
.preflight-task__path { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--ink-muted); overflow-wrap: anywhere; }
.preflight-verdict {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  white-space: nowrap;
}
.preflight-verdict.is-pass { background: var(--green-soft); color: #0B7C57; }
.preflight-verdict.is-warn { background: var(--amber-soft); color: var(--amber); }
.preflight-verdict.is-fail { background: var(--red-soft, #FFF0F0); color: #A23A3A; }
.preflight-group { padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border-faint); }
.preflight-group:last-child { border-bottom: 0; }
.preflight-group h4 {
  margin: 0 0 var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--ink-muted);
}
.preflight-group .checklist { border: 0; padding: 0; margin: 0; }
.preflight-group code { font-size: 0.85em; overflow-wrap: anywhere; }
@media (max-width: 800px) {
  .preflight-inputs { grid-template-columns: 1fr; }
  .preflight-task__head, .preflight-group { padding-inline: var(--space-4); }
}
