/* Deliverables Map — v1 styles
   Cream paper + transit-map typography. Slide-in detail panel on the right. */

:root {
  --paper: #FBF6E9;
  --ink: #1A1A1A;
  --ink-soft: #4A4A4A;
  --ink-mute: #777;
  --rule: rgba(0, 0, 0, 0.08);
  --routing: #A6691F;
  --sensemaking: #2E5C8A;
  --selfowner: #356C3E;
  --panel-bg: #FEFCF5;
  --panel-shadow: 0 12px 32px rgba(40, 30, 0, 0.18);
  --badge-bg: #F1ECDB;
  --good: #2D7A3E;
  --warn: #C89020;
  --bad: #B83A2E;
  --sans: "Inter", "Helvetica Neue", system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Georgia", "Times New Roman", serif;
  --mono: "JetBrains Mono", "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  overflow: hidden;
}

/* ---------- Top bar ---------- */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(251, 246, 233, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
  z-index: 50;
}
.topbar .brand {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.02em;
}
.topbar .brand .sub {
  font-family: var(--sans);
  font-weight: 400;
  color: var(--ink-mute);
  font-size: 12px;
  margin-left: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.topbar .controls {
  display: flex;
  gap: 8px;
}
.topbar button {
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--ink-soft);
  padding: 7px 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.topbar button:hover {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

/* ---------- Canvas ---------- */
.canvas {
  position: absolute;
  top: 56px; left: 0; right: 0; bottom: 0;
}
#diagram-svg {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}
#diagram-svg:active { cursor: grabbing; }

/* SVG station styling */
.station {
  cursor: pointer;
  transition: filter 0.15s ease;
}
.station:hover { filter: drop-shadow(0 0 6px rgba(0,0,0,0.18)); }
.station .station-shape {
  fill: var(--paper);
  stroke: var(--ink);
  stroke-width: 2.5;
  transition: stroke-width 0.15s ease;
}
.station.selected .station-shape { stroke-width: 4; }
.station .station-label {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  fill: var(--ink);
  text-anchor: middle;
  pointer-events: none;
  letter-spacing: 0.02em;
}
.station .badge {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  text-anchor: middle;
  pointer-events: none;
}

/* Junction (Integrator) styling — split hub */
.junction-bg {
  fill: var(--paper);
  stroke: var(--ink);
  stroke-width: 2.5;
}

/* Function line plaques */
.plaque-bg {
  fill: var(--paper);
  stroke: currentColor;
  stroke-width: 1.8;
}
.plaque-label {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  fill: currentColor;
}

/* Terminus (CLIENT) */
.terminus circle.inner {
  fill: var(--paper);
  stroke: #B58621;
  stroke-width: 3;
}
.terminus circle.outer {
  fill: none;
  stroke: #D4A537;
  stroke-width: 2;
  stroke-dasharray: 4 3;
  opacity: 0.7;
}
.terminus text.label {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 700;
  fill: #8C5E10;
  text-anchor: middle;
  letter-spacing: 0.08em;
}
.terminus text.sublabel {
  font-family: var(--sans);
  font-size: 8px;
  font-weight: 500;
  fill: #B58621;
  text-anchor: middle;
  letter-spacing: 0.18em;
}

/* Interchange overlay lines */
.overlay-reports-to {
  fill: none;
  stroke: #888;
  stroke-width: 1.5;
  stroke-dasharray: 5 4;
  opacity: 0.7;
  pointer-events: none;
}
.overlay-works-with {
  fill: none;
  stroke: #1DA39A;
  stroke-width: 2.2;
  opacity: 0.85;
  pointer-events: none;
}
.overlay-marker {
  fill: #1DA39A;
}

/* ---------- Legend ---------- */
.legend {
  position: fixed;
  left: 20px;
  bottom: 20px;
  background: rgba(254, 252, 245, 0.96);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 12px 14px;
  font-size: 11px;
  line-height: 1.65;
  max-width: 280px;
  box-shadow: 0 4px 14px rgba(40, 30, 0, 0.08);
  z-index: 40;
}
.legend h4 {
  margin: 0 0 6px 0;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-weight: 700;
}
.legend .row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-soft);
}
.legend .swatch {
  display: inline-block;
  width: 28px;
  flex-shrink: 0;
  text-align: center;
}
.legend .swatch svg { display: block; }

/* ---------- Detail panel (slide-in right) ---------- */
.panel {
  position: fixed;
  top: 56px;
  right: 0;
  bottom: 0;
  width: 460px;
  max-width: 100vw;
  background: var(--panel-bg);
  box-shadow: var(--panel-shadow);
  border-left: 1px solid var(--rule);
  transform: translateX(100%);
  transition: transform 0.22s ease-out;
  overflow-y: auto;
  z-index: 60;
  padding: 0;
}
.panel.open { transform: translateX(0); }

.panel-header {
  padding: 24px 24px 16px;
  border-bottom: 1px solid var(--rule);
  position: sticky;
  top: 0;
  background: var(--panel-bg);
  z-index: 2;
}
.panel-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.panel-close:hover {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.panel-station-label {
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 8px 0;
  line-height: 1.15;
}
.panel-line-pill {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 100px;
  color: white;
  margin-right: 6px;
}
.typology-row {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.typology-pill {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 4px;
  background: var(--badge-bg);
  color: var(--ink-soft);
  border: 1px solid var(--rule);
}
.typology-pill.primary {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.typology-pill.routing.primary    { background: var(--routing); border-color: var(--routing); }
.typology-pill.sensemaking.primary { background: var(--sensemaking); border-color: var(--sensemaking); }
.typology-pill.selfOwnership.primary { background: var(--selfowner); border-color: var(--selfowner); }
/* Chief of "..." tagline, sits right under the role label */
.panel-chief-of {
  font-family: var(--serif);
  font-style: italic;
  font-size: 14px;
  color: var(--ink-soft);
  margin: -2px 0 8px 0;
  line-height: 1.3;
}
.panel-chief-of[hidden] { display: none; }

/* Person chips — initials badge + name */
.panel-people {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0 4px;
}
.person-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--badge-bg);
  border: 1px solid var(--rule);
  border-radius: 100px;
  padding: 3px 10px 3px 3px;
  font-size: 12px;
  color: var(--ink);
}
.person-chip .person-initials {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  background: var(--ink);
  color: var(--paper);
  width: 22px;
  height: 22px;
  border-radius: 100px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0;
}
.person-chip .person-name {
  font-weight: 500;
}
.vacant-pill {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-mute);
  background: var(--badge-bg);
  border: 1px dashed var(--rule);
  padding: 3px 9px;
  border-radius: 100px;
}

/* Responsibilities list (bulleted, compact) */
.responsibility-list {
  list-style: disc;
  margin: 0;
  padding-left: 20px;
}
.responsibility-list li {
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink);
  padding: 3px 0;
}

/* Goals list (numbered with due date) */
.goals-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.goals-list li {
  display: flex;
  gap: 8px;
  align-items: baseline;
  padding: 7px 0;
  border-bottom: 1px dashed var(--rule);
  font-size: 13.5px;
  line-height: 1.4;
}
.goals-list li:last-child { border-bottom: none; }
.goals-list .goal-num {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  background: var(--ink);
  color: var(--paper);
  width: 20px;
  height: 20px;
  border-radius: 100px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.goals-list .goal-text {
  flex: 1;
  color: var(--ink);
}
.goals-list .goal-due {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-mute);
  flex-shrink: 0;
}

/* Obsessions list — bold-styled bullets, matches the org-chart vibe */
.obsessions-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.obsessions-list li {
  position: relative;
  padding: 6px 0 6px 18px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink);
  border-bottom: 1px dashed var(--rule);
}
.obsessions-list li:last-child { border-bottom: none; }
.obsessions-list li::before {
  content: "★";
  position: absolute;
  left: 0;
  top: 6px;
  color: var(--routing);
  font-size: 12px;
}

.draft-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--bad);
  background: rgba(184, 58, 46, 0.08);
  padding: 3px 7px;
  border-radius: 3px;
  margin-left: 8px;
  vertical-align: middle;
}

.panel-section {
  padding: 18px 24px 22px;
  border-bottom: 1px solid var(--rule);
}
.panel-section h3 {
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin: 0 0 10px 0;
}
.panel-section .heading-text {
  font-family: var(--serif);
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--ink);
  font-style: italic;
}

.deliverable-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.deliverable-list li {
  padding: 8px 0;
  border-bottom: 1px dashed var(--rule);
  font-size: 13.5px;
  line-height: 1.45;
  display: flex;
  gap: 10px;
  align-items: baseline;
}
.deliverable-list li:last-child { border-bottom: none; }
.deliverable-list .noun {
  flex: 1;
  color: var(--ink);
}
.deliverable-list .cadence {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-mute);
  text-transform: lowercase;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.gauge-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.gauge-list li {
  padding: 10px 0;
  border-bottom: 1px dashed var(--rule);
  font-size: 13px;
}
.gauge-list li:last-child { border-bottom: none; }
.gauge-name {
  font-weight: 600;
  margin-bottom: 5px;
  color: var(--ink);
}
.gauge-thresholds {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 11px;
  font-family: var(--mono);
}
.gauge-thresholds span {
  padding: 2px 6px;
  border-radius: 3px;
  color: white;
  white-space: nowrap;
}
.gauge-thresholds .g-green  { background: var(--good); }
.gauge-thresholds .g-yellow { background: var(--warn); }
.gauge-thresholds .g-red    { background: var(--bad); }
.gauge-cadence {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-mute);
  margin-top: 5px;
}

.obligation-group {
  margin-bottom: 16px;
}
.obligation-group:last-child { margin-bottom: 0; }
.obligation-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.obligation-label {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.obligation-label.routing      { color: var(--routing); }
.obligation-label.sensemaking  { color: var(--sensemaking); }
.obligation-label.selfOwnership { color: var(--selfowner); }
.obligation-marker {
  width: 14px;
  flex-shrink: 0;
}
.interchange-list {
  list-style: none;
  margin: 0 0 0 22px;
  padding: 0;
}
.interchange-list li {
  padding: 5px 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink-soft);
}
.interchange-list li .other {
  font-weight: 600;
  color: var(--ink);
}
.interchange-list li.empty {
  color: var(--ink-mute);
  font-style: italic;
  font-size: 12px;
}

/* Welcome placeholder card — stacked above the Legend, bottom-left */
.welcome {
  position: fixed;
  left: 20px;
  bottom: 200px;
  background: rgba(254, 252, 245, 0.96);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 14px 16px;
  font-size: 12px;
  line-height: 1.5;
  max-width: 280px;
  box-shadow: 0 4px 14px rgba(40, 30, 0, 0.08);
  z-index: 40;
  color: var(--ink-soft);
}
.welcome.hidden { display: none; }
.welcome strong { color: var(--ink); }

/* Loading / error states */
.status-message {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--sans);
  font-size: 16px;
  color: var(--ink-soft);
  z-index: 100;
}
.status-message.error { color: var(--bad); }
