/* =========================================================
   ADLC deep dive — Phase 2: Plan (Asana-style plan + veto gate)
   Builds on adlc-phase.css
   ========================================================= */

.role-agent { --role: var(--agent); }

.plan-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

@media (min-width: 1000px) {
  .plan-grid {
    grid-template-columns: minmax(0, 0.95fr) minmax(0, 2fr);
    align-items: start;
  }
}

.col-side {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.col-side .actor {
  margin-bottom: 0;
}

/* ---------- Context card ---------- */

.context-list {
  list-style: none;
  margin: 0;
  padding: 10px 14px 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.45;
}

.ctx {
  display: grid;
  grid-template-columns: 16px 1fr;
  gap: 6px;
  padding: 3px 0;
  color: var(--text-muted);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.ctx:not(.shown) {
  opacity: 0;
  transform: translateX(-6px);
}

.ctx-tick {
  color: var(--gate);
}

.ctx.k-spec .ctx-text {
  color: var(--text);
}

/* ---------- Plan gate ---------- */

.gate {
  padding: 14px 16px 14px;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.gate.bad {
  border-color: color-mix(in srgb, var(--fail) 60%, var(--border));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--fail) 10%, transparent);
}

.gate.good {
  border-color: color-mix(in srgb, var(--gate) 60%, var(--border));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--gate) 10%, transparent);
}

.gate-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.gate-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
}

.gate-version {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 6px;
}

.gate-status {
  margin-left: auto;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  color: var(--text-muted);
  background: var(--code-bg);
  transition: color 0.3s ease, background 0.3s ease;
}

.gate-status[data-tone="busy"] { color: var(--accent-strong); background: var(--accent-soft); }
.gate-status[data-tone="bad"]  { color: var(--fail); background: color-mix(in srgb, var(--fail) 13%, transparent); }
.gate-status[data-tone="good"] { color: var(--gate); background: color-mix(in srgb, var(--gate) 14%, transparent); }

.coverage-label {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

#coverage-count {
  font-family: var(--font-mono);
  color: var(--text);
}

.coverage-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--code-bg);
  overflow: hidden;
}

.coverage-bar span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.4s ease, background 0.3s ease;
}

.coverage-bar span.full {
  background: var(--gate);
}

.coverage-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 10px;
}

.cov-chip {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 2px 6px;
  border-radius: 5px;
  color: var(--text-muted);
  background: var(--code-bg);
  border: 1px solid transparent;
  transition: color 0.3s ease, background 0.3s ease, border-color 0.3s ease;
}

.cov-chip.on {
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.cov-chip.missing {
  color: var(--fail);
  background: color-mix(in srgb, var(--fail) 10%, transparent);
  border-color: color-mix(in srgb, var(--fail) 50%, transparent);
  animation: nudge 0.5s ease;
}

@keyframes nudge {
  30% { transform: translateY(-2px); }
}

.gate-stats {
  display: flex;
  gap: 16px;
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.gate-stats b {
  font-family: var(--font-mono);
  color: var(--text);
}

.gate.bad .gate-stats b {
  color: var(--fail);
}

.lock {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--fail);
  background: color-mix(in srgb, var(--fail) 9%, transparent);
  transition: color 0.3s ease, background 0.3s ease;
}

.lock .i-open { display: none; }
.lock.open { color: var(--gate); background: color-mix(in srgb, var(--gate) 11%, transparent); }
.lock.open .i-open { display: inline; animation: pop 0.4s ease; }
.lock.open .i-locked { display: none; }

@keyframes pop {
  40% { transform: scale(1.3) rotate(-10deg); }
}

/* ---------- Asana-style list ---------- */

.asana {
  position: relative;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  min-height: 520px;
}

.asana-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
}

.asana-bar .dots {
  display: inline-flex;
  gap: 5px;
  margin-right: 4px;
}

.asana-bar .dots i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
}

.asana-app {
  font-weight: 700;
  color: var(--text);
}

.asana-sep {
  color: var(--text-muted);
}

.asana-project {
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
}

.asana-tabs {
  display: flex;
  gap: 18px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
}

.asana-tabs span {
  padding: 9px 0 8px;
  border-bottom: 2px solid transparent;
}

.asana-tabs .on {
  color: var(--text);
  font-weight: 600;
  border-bottom-color: var(--text);
}

.asana-head,
.a-main {
  display: grid;
  grid-template-columns: 18px 30px minmax(0, 1fr) 116px 104px 50px;
  gap: 8px;
  align-items: center;
}

.asana-head {
  padding: 7px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-muted);
}

.asana-head span:first-child {
  grid-column: 1 / 4;
}

.asana-body {
  padding: 4px 0 12px;
}

.asana-empty {
  position: absolute;
  inset: 120px 0 auto;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-muted);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.asana.empty .asana-empty {
  opacity: 0.8;
}

.a-section {
  transition: opacity 0.3s ease;
}

.a-section:not(.shown) {
  display: none;
}

.a-section-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px 6px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14.5px;
}

.caret {
  font-size: 11px;
  color: var(--text-muted);
}

.a-count {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

.a-task {
  position: relative;
  border-top: 1px solid var(--border);
  margin: 0 8px;
  padding: 0 8px;
  border-radius: 8px;
  transition: background 0.25s ease, box-shadow 0.25s ease;
}

.a-task:not(.shown) {
  display: none;
}

.a-task.shown {
  animation: task-in 0.35s ease-out;
}

@keyframes task-in {
  from { opacity: 0; transform: translateY(-4px); }
}

.a-main {
  padding: 8px 0;
  font-size: 13.5px;
}

.a-check {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.5px solid var(--text-muted);
  opacity: 0.6;
}

.a-id {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-muted);
}

.a-title {
  min-width: 0;
}

.a-refs {
  display: inline-flex;
  gap: 4px;
  justify-content: flex-end;
}

.a-who {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
}

.a-who-dot {
  width: 18px;
  height: 18px;
  flex: none;
  border-radius: 50%;
  border: 1.5px dashed var(--border);
  transition: background 0.3s ease, border-color 0.3s ease;
}

.a-task.assigned .a-who {
  color: var(--accent-strong);
}

.a-task.assigned .a-who-dot {
  border: none;
  background: var(--agent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round'%3E%3Crect x='5' y='8' width='14' height='11' rx='3'/%3E%3Cpath d='M12 8V5'/%3E%3C/svg%3E") center / 12px no-repeat;
  animation: pop 0.4s ease;
}

.a-due {
  font-size: 12px;
  color: var(--text-muted);
  text-align: right;
}

.a-new {
  grid-column: 3 / -1;
  justify-self: start;
  font-size: 11px;
  font-weight: 600;
  color: var(--gate);
}

/* Review scan */
.a-task.scan {
  background: color-mix(in srgb, var(--human) 9%, transparent);
  box-shadow: inset 3px 0 0 var(--human);
}

/* Veto */
.a-veto,
.a-history {
  display: none;
}

.a-task.vetoed {
  background: color-mix(in srgb, var(--fail) 8%, transparent);
  box-shadow: inset 3px 0 0 var(--fail);
}

.a-task.vetoed .a-title {
  text-decoration: line-through;
  text-decoration-color: var(--fail);
  color: var(--text-muted);
}

.a-task.vetoed .a-veto,
.a-task.revised.open .a-veto {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  align-items: baseline;
  padding: 0 0 10px 56px;
  font-size: 12.5px;
  animation: task-in 0.35s ease-out;
}

.a-task.revised.open .a-veto {
  opacity: 0.6;
}

.a-veto-badge {
  font-weight: 700;
  color: var(--fail);
  white-space: nowrap;
}

.a-veto-reason {
  color: var(--text);
}

.a-task.revised {
  box-shadow: inset 3px 0 0 var(--gate);
}

.a-task.revised .a-history {
  display: block;
  padding: 0 0 9px 56px;
  font-size: 11.5px;
  color: var(--text-muted);
}

.a-task.flash {
  background: color-mix(in srgb, var(--gate) 12%, transparent);
}

/* Approved stamp sits over the bottom of the list */
.asana .stamp {
  top: 44px;
  bottom: auto;
  right: 16px;
  font-size: 16px;
}

/* ---------- Review thread ---------- */

.thread {
  margin-top: 16px;
}

.thread-label {
  height: auto;
  margin-bottom: 8px;
}

.feed {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.feed-item {
  --c: var(--agent);
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  border-left: 3px solid var(--c);
  background: color-mix(in srgb, var(--c) 7%, var(--bg));
  font-size: 13.5px;
  line-height: 1.45;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.feed-item:not(.shown) {
  display: none;
}

.feed-item.shown {
  animation: task-in 0.35s ease-out;
}

.feed-item.from-eng { --c: var(--human); }
.feed-item.kind-veto,
.feed-item.kind-gap { --c: var(--fail); }
.feed-item.kind-ok { --c: var(--gate); }
.feed-item.kind-learn { --c: var(--accent); font-style: italic; }

.feed-who {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--c);
}

/* ---------- Veto explainer ---------- */

.veto-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.veto-steps li {
  position: relative;
  padding: 18px 20px 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-top: 3px solid var(--role);
  border-radius: var(--radius-md);
}

.vs-n {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--role);
  background: color-mix(in srgb, var(--role) 13%, transparent);
  margin-bottom: 10px;
}

.veto-steps h3 {
  font-family: var(--font-display);
  font-size: 18px;
  margin: 0 0 6px;
}

.veto-steps p {
  margin: 0;
  font-size: 14.5px;
  color: var(--text-muted);
}

.veto-steps em {
  color: var(--text);
  font-style: normal;
  font-weight: 600;
}

.tool-note {
  margin: 20px 0 0;
  font-size: 13.5px;
  color: var(--text-muted);
}

/* ---------- Small screens ---------- */

@media (max-width: 700px) {
  .asana-head { display: none; }
  .a-main {
    grid-template-columns: 18px 30px minmax(0, 1fr);
    row-gap: 6px;
  }
  .a-refs { grid-column: 3; justify-content: flex-start; }
  .a-who { grid-column: 3; }
  .a-due { display: none; }
  .a-task.vetoed .a-veto,
  .a-task.revised.open .a-veto,
  .a-task.revised .a-history { padding-left: 8px; }
  .feed-item { grid-template-columns: 1fr; gap: 2px; }
  .asana { min-height: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .a-task.shown,
  .feed-item.shown,
  .cov-chip.missing,
  .lock.open .i-open,
  .a-task.assigned .a-who-dot {
    animation: none !important;
  }
}
