/* =========================================================
   ADLC phase deep dives — shared scene styles (Intent, Plan, ...)
   Builds on style.css + adlc.css tokens
   ========================================================= */

:root {
  --pm: #db2777;
}

:root[data-theme="dark"] {
  --pm: #f472b6;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --pm: #f472b6;
  }
}

.role-pm  { --role: var(--pm); }
.role-eng { --role: var(--human); }

/* ---------- Hero ---------- */

.intent-hero .back-link {
  margin-bottom: 18px;
}

.phase-rail {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 26px;
}

.phase {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  background: var(--bg-elevated);
}

.phase span {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 11.5px;
  opacity: 0.7;
}

.phase.active {
  color: var(--role);
  border-color: var(--role);
  background: color-mix(in srgb, var(--role) 10%, var(--bg-elevated));
}

.phase.soon {
  opacity: 0.55;
  cursor: default;
}

/* ---------- Scene shell ---------- */

.intent-stage {
  padding: 8px 0 48px;
}

.scene {
  position: relative;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px 18px;
}

.scene-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.beats {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
}

.beat {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  font: 600 13px var(--font-sans);
  padding: 5px 12px 5px 5px;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.beat .n {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--border);
  color: var(--text-muted);
  font-size: 12px;
  transition: background 0.2s ease, color 0.2s ease;
}

.beat:hover {
  color: var(--text);
}

.beat.done .n {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.beat.active {
  color: var(--accent-strong);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.beat.active .n {
  background: var(--accent);
  color: #fff;
}

.play-btn {
  min-width: 110px;
  justify-content: center;
}

.play-btn svg { display: none; }
.play-btn[data-state="pause"] .i-pause,
.play-btn[data-state="play"] .i-play,
.play-btn[data-state="replay"] .i-replay { display: inline; }

.caption {
  margin: 18px 0 20px;
  min-height: 3.2em;
  font-size: 17px;
  line-height: 1.55;
  color: var(--text);
  max-width: 820px;
}

.caption.fresh {
  animation: caption-in 0.5s ease-out;
}

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

/* ---------- Columns ---------- */

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

@media (min-width: 1000px) {
  .scene-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 0.82fr) minmax(0, 1.38fr);
    align-items: start;
  }
}

/* ---------- Actors ---------- */

.actor {
  --c: var(--role);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px 10px 10px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
  transition: border-color 0.3s ease;
}

.actor.busy {
  border-color: color-mix(in srgb, var(--c) 55%, var(--border));
}

.avatar {
  position: relative;
  flex: none;
  width: 64px;
  height: 64px;
}

.avatar svg {
  display: block;
  position: relative;
  z-index: 1;
  animation: bob 3.4s ease-in-out infinite;
}

.role-eng .avatar svg {
  animation-delay: -1.7s;
}

.av-bg {
  fill: color-mix(in srgb, var(--role) 18%, var(--bg-elevated));
}

.avatar::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--c);
  opacity: 0;
}

.actor.busy .avatar::after {
  animation: ring 1.3s ease-out infinite;
}

@keyframes bob {
  50% { transform: translateY(-2px); }
}

@keyframes ring {
  0%   { opacity: 0.7; transform: scale(1); }
  100% { opacity: 0;   transform: scale(1.35); }
}

.who {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

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

.status {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--c);
}

.actor.busy .status::after {
  content: "";
  display: inline-block;
  width: 1.2em;
  text-align: left;
  animation: ellipsis 1.2s steps(4, end) infinite;
}

@keyframes ellipsis {
  0%   { content: ""; }
  25%  { content: "."; }
  50%  { content: ".."; }
  75%  { content: "..."; }
}

/* ---------- Documents ---------- */

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

.doc-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-elevated);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.doc-bar .dots {
  display: inline-flex;
  gap: 5px;
}

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

.doc-body {
  padding: 14px 16px 16px;
}

.doc-kicker {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--pm);
}

/* Chips used for traceability */

.chip {
  --c: var(--pm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 20px;
  padding: 0 6px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--c);
  background: color-mix(in srgb, var(--c) 13%, transparent);
  flex: none;
}

.chip-q {
  --c: var(--accent);
}

/* PRD */

.prd-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.prd-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
  padding: 6px 8px;
  margin: 0 -8px 2px;
  border-radius: 8px;
  font-size: 14.5px;
  line-height: 1.45;
  transition: background 0.25s ease, opacity 0.3s ease, transform 0.3s ease;
}

.prd-item .chip {
  margin-top: 1px;
}

.prd-item:not(.shown) {
  opacity: 0;
  transform: translateY(4px);
}

.prd-item.hl {
  background: color-mix(in srgb, var(--pm) 12%, transparent);
}

/* Typing caret, shared by PRD and spec lines */

.typing .txt::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 1px;
  vertical-align: -0.15em;
  background: currentColor;
  animation: caret 0.6s steps(2, start) infinite;
}

@keyframes caret {
  to { visibility: hidden; }
}

/* ---------- Clarification chat ---------- */

.channel-label {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 64px;
  margin-bottom: 12px;
  padding: 0 4px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.chat {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
}

.msg {
  display: flex;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.msg.from-eng {
  justify-content: flex-end;
}

.msg:not(.typing):not(.shown) {
  opacity: 0;
  transform: translateY(6px);
}

.bubble {
  position: relative;
  max-width: 90%;
  padding: 9px 12px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.42;
  transition: box-shadow 0.25s ease;
}

.bubble .chip {
  margin-right: 6px;
  vertical-align: 1px;
}

.from-pm .bubble {
  background: color-mix(in srgb, var(--pm) 13%, var(--bg-elevated));
  border-bottom-left-radius: 4px;
}

.from-eng .bubble {
  background: color-mix(in srgb, var(--human) 15%, var(--bg-elevated));
  border-bottom-right-radius: 4px;
}

.typing-dots {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.typing-dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: dot 1s ease-in-out infinite;
}

.typing-dots i:nth-child(2) { animation-delay: 0.15s; }
.typing-dots i:nth-child(3) { animation-delay: 0.3s; }

@keyframes dot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30%           { transform: translateY(-4px); opacity: 1; }
}

.msg.typing .typing-dots { display: flex; }
.msg.typing .bubble > :not(.typing-dots) { visibility: hidden; }

.msg.hl .bubble {
  box-shadow: 0 0 0 2px var(--accent);
}

.mid-note {
  margin: 12px 4px 0;
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
}

/* ---------- Spec ---------- */

.spec .doc-body {
  font-family: var(--font-mono);
  font-size: 12.8px;
  line-height: 1.5;
  padding: 12px 10px 16px;
}

.sl {
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
  padding: 3px 6px;
  border-radius: 6px;
  transition: background 0.25s ease, opacity 0.25s ease;
}

.sl:not(.shown) {
  opacity: 0;
}

.sl.hl {
  background: var(--accent-soft);
}

.sl .sid {
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

.sl .srcs {
  display: inline-flex;
  gap: 4px;
}

.sl.k-h1,
.sl.k-h2,
.sl.k-meta,
.sl.k-p,
.sl.k-li {
  grid-template-columns: minmax(0, 1fr) auto;
}

.sl.k-h1 {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  padding-top: 2px;
}

.sl.k-h1 .txt::before { content: "# "; color: var(--accent); }

.sl.k-meta {
  color: var(--text-muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.sl.k-h2 {
  margin-top: 10px;
  font-weight: 600;
  color: var(--accent-strong);
}

.sl.k-h2 .txt::before { content: "## "; opacity: 0.6; }

.sl.k-li .txt::before { content: "- "; color: var(--accent); }

.spec-status {
  display: inline-block;
  margin-left: 2px;
  padding: 0 7px;
  border-radius: 5px;
  color: var(--human);
  background: color-mix(in srgb, var(--human) 14%, transparent);
  transition: color 0.3s ease, background 0.3s ease;
}

.sl:not(.shown) .spec-status,
.sl.typing .spec-status {
  visibility: hidden;
}

.spec-status.ok {
  color: var(--gate);
  background: color-mix(in srgb, var(--gate) 14%, transparent);
}

.stamp {
  position: absolute;
  bottom: 22px;
  right: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 14px;
  border: 3px solid var(--gate);
  border-radius: 10px;
  color: var(--gate);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1.1;
  opacity: 0;
  transform: rotate(-8deg) scale(1.8);
  transition: opacity 0.25s ease, transform 0.35s cubic-bezier(0.2, 1.6, 0.4, 1);
  pointer-events: none;
}

.stamp small {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

.stamp.on {
  opacity: 1;
  transform: rotate(-8deg) scale(1);
}

/* Placeholder until the engineer starts writing */
.spec-empty {
  position: absolute;
  inset: 38px 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  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;
}

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

/* ---------- Footer of scene ---------- */

.scene-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.foot-hint {
  font-size: 13px;
  color: var(--text-muted);
}

.next-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border: 1.5px dashed var(--border);
  border-radius: 999px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.next-kicker {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.8;
}

.next-chip.lit {
  color: var(--accent-strong);
  border-style: solid;
  border-color: var(--accent);
  box-shadow: 0 0 0 6px var(--accent-soft);
}

.chip-spec {
  --c: var(--accent);
}

/* ---------- Scene footer ---------- */

.prev-chip {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  transition: color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.prev-chip.lit {
  color: var(--accent-strong);
  border-color: var(--accent);
  box-shadow: 0 0 0 6px var(--accent-soft);
}

/* ---------- Flying document ---------- */

.packet {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1.5px solid var(--accent);
  background: var(--bg-elevated);
  color: var(--accent-strong);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: 0 0 0 6px var(--accent-soft), 0 14px 30px rgba(20, 23, 31, 0.18);
  opacity: 0;
  pointer-events: none;
  will-change: transform, opacity;
}

/* ---------- Takeaways ---------- */

.takeaways {
  padding: 24px 0 100px;
}

.takeaways .section-head {
  margin-bottom: 22px;
}

.takeaways h2 {
  font-family: var(--font-display);
  font-size: 24px;
  margin: 0;
}

.phase-nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 32px;
}

.btn.disabled {
  opacity: 0.5;
  cursor: default;
  pointer-events: none;
}

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

@media (max-width: 560px) {
  .scene { padding: 16px 14px; }
  .caption { font-size: 16px; }
  .channel-label { height: auto; }
  .sl { grid-template-columns: 44px minmax(0, 1fr); }
  .sl .srcs { grid-column: 2; }
  .sl.k-p .srcs { grid-column: 1; }
  .stamp { bottom: 16px; font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .avatar svg,
  .actor.busy .avatar::after,
  .typing-dots i,
  .caption.fresh {
    animation: none !important;
  }
}

/* =========================================================
   Shared components for the Verify / Review / Release / Observe pages
   ========================================================= */

.panel {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.panel-head .pill {
  margin-left: auto;
  letter-spacing: 0;
  text-transform: none;
}

.panel-body {
  padding: 12px 14px 14px;
}

.grid-2,
.grid-3 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 12px;
}

@media (min-width: 1000px) {
  .grid-2 { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); }
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Status pill */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  color: var(--text-muted);
  background: var(--code-bg);
  white-space: nowrap;
  transition: color 0.3s ease, background 0.3s ease;
}

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

/* Code / diff box */
.codebox {
  margin: 0;
  padding: 10px 0;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.65;
  overflow-x: auto;
}

.codebox .ln {
  display: block;
  padding: 0 14px 0 34px;
  position: relative;
  white-space: pre;
  transition: background 0.3s ease, opacity 0.3s ease;
}

.codebox .ln::before {
  content: attr(data-n);
  position: absolute;
  left: 8px;
  width: 18px;
  text-align: right;
  color: var(--text-muted);
  opacity: 0.6;
}

.codebox .ln.add { background: color-mix(in srgb, var(--gate) 13%, transparent); }
.codebox .ln.add::before { content: "+"; color: var(--gate); opacity: 1; }
.codebox .ln.del { background: color-mix(in srgb, var(--fail) 11%, transparent); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--fail) 60%, transparent); }
.codebox .ln.del::before { content: "−"; color: var(--fail); opacity: 1; }
.codebox .ln.hot { background: color-mix(in srgb, var(--fail) 14%, transparent); box-shadow: inset 3px 0 0 var(--fail); }
.codebox .ln.focus { background: color-mix(in srgb, var(--human) 14%, transparent); box-shadow: inset 3px 0 0 var(--human); }
.codebox .ln.hidden { display: none; }

/* Event log */
.event-log {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.event-log li {
  --c: var(--agent);
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  padding: 7px 10px;
  border-left: 3px solid var(--c);
  border-radius: 8px;
  background: color-mix(in srgb, var(--c) 7%, var(--bg));
  font-size: 13px;
  line-height: 1.45;
}

.event-log li:not(.shown) { display: none; }
.event-log li.shown { animation: log-in 0.35s ease-out; }
.event-log li.k-human { --c: var(--human); }
.event-log li.k-bad   { --c: var(--fail); }
.event-log li.k-good  { --c: var(--gate); }
.event-log li.k-pm    { --c: var(--pm); }

.event-log .who {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--c);
  white-space: nowrap;
}

/* KPI tiles */
.kpis {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

@media (min-width: 900px) {
  .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.kpi {
  --c: var(--accent);
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.kpi.alert {
  --c: var(--human);
  border-color: color-mix(in srgb, var(--human) 60%, var(--border));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--human) 12%, transparent);
}

.kpi-label {
  font-size: 12px;
  color: var(--text-muted);
}

.kpi-value {
  display: block;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.kpi.alert .kpi-value { color: var(--human); }

.kpi svg {
  display: block;
  width: 100%;
  height: 28px;
  margin-top: 4px;
}

.kpi svg polyline {
  fill: none;
  stroke: var(--c);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

/* Generic checklist */
.checks {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}

.checks li {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 8px;
  align-items: start;
  color: var(--text-muted);
  transition: opacity 0.3s ease, color 0.3s ease;
}

.checks li::before {
  content: "○";
  color: var(--text-muted);
}

.checks li.on { color: var(--text); }
.checks li.on::before { content: "✓"; color: var(--gate); font-weight: 700; }
.checks li.bad::before { content: "✗"; color: var(--fail); font-weight: 700; }
.checks li:not(.shown) { opacity: 0; }

.checks code,
.mono {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

/* Packet label hook used by js/adlc-scene.js */
.packet .packet-label { white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  .event-log li.shown { animation: none !important; }
}
