/* Policy Cascade Map — author tool styles */

:root {
  --blue: #0076BA;      /* policy_instrument / funds_flow */
  --slate: #3E4A52;     /* admin_process / dependency */
  --orange: #F5A623;    /* behavioral_response / behavioral_feedback */
  --brick: #B23A2E;     /* outcome */
  --green: #6AA84F;     /* buffer_response / absorption */
  --teal: #2BA6A4;      /* watch indicator */
  --ink: #1f272c;
  --muted: #64707a;
  --hairline: #e2e6e9;
  --paper: #ffffff;
  --panel: #f6f8f9;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  display: flex;
  flex-direction: column;
}

/* ---------- toolbar ---------- */
#toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--hairline);
  background: var(--paper);
  flex-wrap: wrap;
}
.brand { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 700; font-size: 14px; }
.brand-sub { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }

.map-picker { display: flex; align-items: center; gap: 8px; }
.map-picker-label {
  font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
}
#map-select {
  font: inherit; font-size: 13px; font-weight: 600; color: var(--ink);
  padding: 6px 30px 6px 10px; min-width: 220px; max-width: 320px;
  border: 1px solid var(--slate); border-radius: 6px; background-color: var(--paper); cursor: pointer;
}
#map-select:focus-visible { outline: 2px solid var(--teal); outline-offset: 1px; }

.toolbar-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; flex-wrap: wrap; }
.toolbar-actions button, #modal button, #sidebar button {
  font: inherit; font-size: 12.5px; padding: 5px 10px;
  border: 1px solid #c8d0d6; border-radius: 6px; background: var(--paper); cursor: pointer; color: var(--ink);
}
.toolbar-actions button:hover, #modal button:hover, #sidebar button:hover { background: var(--panel); }
.toolbar-actions button.armed { background: var(--teal); color: #fff; border-color: var(--teal); }
.toolbar-sep { width: 1px; height: 20px; background: var(--hairline); }
.style-toggle select { font: inherit; font-size: 12.5px; padding: 4px 6px; border-radius: 6px; border: 1px solid #c8d0d6; }

.edge-hint {
  padding: 6px 16px; background: var(--teal); color: #fff; font-size: 13px;
}

/* ---------- present mode (facilitation) ---------- */
body.present .map-picker { display: none; }
body.present .toolbar-actions > *:not(#btn-present) { display: none; }
body.present #btn-present { background: var(--slate); color: #fff; border-color: var(--slate); }
body.present #sidebar { display: none; }
body.present #map-pane { padding: 22px 34px 34px; }
body.present #map-title-block h1 { font-size: 26px; }
body.present #map-title-block p { font-size: 15px; }
body.present .scenario-pill { font-size: 15px; padding: 8px 18px; border-radius: 20px; }
body.present #scenario-narrative { font-size: 15px; max-width: none; }
body.present .edge-hit { stroke-width: 28; }
body.present #popup { width: 400px; }
body.present #popup h3 { font-size: 17px; }
body.present #popup .popup-summary { font-size: 13.5px; }
body.present #popup .popup-detail { font-size: 14px; }

/* ---------- workspace ---------- */
#workspace { flex: 1; display: flex; min-height: 0; }
#map-pane { flex: 1; overflow: auto; padding: 18px 22px 30px; }
#map-title-block h1 { font-size: 20px; margin: 0 0 2px; }
#map-title-block p { margin: 0 0 14px; color: var(--muted); font-size: 13px; max-width: 70ch; }

/* scenario switcher */
#scenario-bar { margin-bottom: 12px; }
#scenario-pills { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.scenario-pill {
  font: inherit; font-size: 12.5px; padding: 5px 14px;
  border: 1px solid #c8d0d6; border-radius: 16px; background: var(--paper);
  color: var(--ink); cursor: pointer;
}
.scenario-pill:hover { background: var(--panel); }
.scenario-pill.active { background: var(--slate); border-color: var(--slate); color: #fff; font-weight: 600; }
.scenario-pill.base-pill.active { background: var(--ink); border-color: var(--ink); }
#scenario-narrative {
  margin-top: 8px; padding: 10px 14px; background: var(--panel);
  border-left: 3px solid var(--slate); border-radius: 0 8px 8px 0;
  font-size: 13px; line-height: 1.55; max-width: 92ch;
}
#scenario-narrative .sc-desc { color: var(--muted); font-style: italic; display: block; margin-bottom: 4px; }
#scenario-narrative:empty { display: none; }

/* highlight-on-switch */
.node.hl rect:not(.selection-ring) { filter: drop-shadow(0 0 5px rgba(245, 200, 60, 0.95)) drop-shadow(0 0 10px rgba(245, 200, 60, 0.6)); }
.edge.hl .edge-path { filter: drop-shadow(0 0 4px rgba(245, 200, 60, 0.95)); }
.edge.hl .shield { filter: drop-shadow(0 0 6px rgba(245, 200, 60, 0.95)); }

#svg-wrap { position: relative; }
#map-svg { display: block; background: var(--paper); max-width: 100%; height: auto; }

/* Diagram styling lives in js/svgstyles.js (shared with exports and injected at
   boot). Only UI-interaction rules belong here. */
.node { cursor: pointer; }
.node text { pointer-events: none; }
.edge-hit { fill: none; stroke: rgba(0,0,0,0); stroke-width: 16; cursor: pointer; }
.edge.selected .edge-path { filter: drop-shadow(0 0 2px rgba(0,0,0,0.55)); }

/* legend */
#legend {
  display: flex; flex-wrap: wrap; gap: 14px 22px; align-items: center;
  margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--hairline);
  font-size: 11.5px; color: var(--ink);
}
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 18px; height: 12px; border-radius: 3px; display: inline-block; }
.legend-line { width: 26px; height: 0; border-top-width: 2.5px; display: inline-block; }
.legend-diamond { width: 9px; height: 9px; background: var(--teal); transform: rotate(45deg); display: inline-block; }

/* ---------- popup ---------- */
#popup {
  position: absolute; z-index: 30; width: 340px; max-height: 420px; overflow: auto;
  background: var(--paper); border: 1px solid #c8d0d6; border-radius: 10px;
  box-shadow: 0 8px 28px rgba(20,35,45,0.18); padding: 14px 16px;
}
#popup .popup-kicker {
  font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  display: inline-block; padding: 2px 8px; border-radius: 10px; color: #fff; margin-bottom: 6px;
}
#popup h3 { margin: 0 0 6px; font-size: 15px; }
#popup .popup-summary { font-size: 12.5px; color: var(--muted); font-style: italic; margin: 0 0 8px; }
#popup .popup-detail { font-size: 13px; line-height: 1.5; }
#popup .popup-detail p { margin: 0 0 8px; }
#popup .popup-sources { border-top: 1px solid var(--hairline); margin-top: 8px; padding-top: 8px; font-size: 11.5px; color: var(--muted); }
#popup .popup-sources li { margin-bottom: 3px; }
#popup .popup-actions { margin-top: 10px; display: flex; gap: 8px; }
#popup .popup-actions button { font: inherit; font-size: 12px; padding: 4px 10px; border: 1px solid #c8d0d6; border-radius: 6px; background: var(--paper); cursor: pointer; }
#popup .popup-close { position: absolute; top: 8px; right: 10px; border: none; background: none; font-size: 16px; cursor: pointer; color: var(--muted); }

/* ---------- sidebar ---------- */
#sidebar {
  width: 330px; border-left: 1px solid var(--hairline); background: var(--panel);
  overflow-y: auto; padding: 14px;
}
#sidebar h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--slate); margin: 0 0 10px; }
#sidebar .hint { font-size: 12.5px; color: var(--muted); line-height: 1.5; }
#sidebar form { display: flex; flex-direction: column; gap: 10px; }
#sidebar label, #modal label { display: flex; flex-direction: column; gap: 3px; font-size: 11.5px; font-weight: 600; color: var(--slate); }
#sidebar input[type="text"], #sidebar input[type="number"], #sidebar textarea, #sidebar select,
#modal input[type="text"], #modal input[type="number"], #modal textarea, #modal select {
  font: inherit; font-size: 13px; font-weight: 400; padding: 6px 8px;
  border: 1px solid #c8d0d6; border-radius: 6px; background: var(--paper); width: 100%;
}
#sidebar textarea, #modal textarea { resize: vertical; min-height: 54px; }
.check-row { flex-direction: row !important; align-items: center; gap: 6px !important; }
.check-row input { width: auto !important; }
.source-checks { display: flex; flex-direction: column; gap: 4px; font-weight: 400; }
.source-checks label { flex-direction: row; align-items: flex-start; gap: 6px; font-weight: 400; color: var(--ink); font-size: 12px; }
.form-actions { display: flex; gap: 8px; margin-top: 4px; }
.danger { color: var(--brick); border-color: var(--brick) !important; }
.validation-report { font-size: 12.5px; line-height: 1.5; }
.validation-report .v-error { color: var(--brick); margin-bottom: 6px; }
.validation-report .v-warning { color: #8a6d1a; margin-bottom: 6px; }
.validation-report .v-ok { color: var(--green); font-weight: 600; }

/* origin badges in entity forms */
.origin-badge {
  font-size: 11.5px; color: var(--muted); background: #eef2f4;
  border-left: 3px solid #9fb0ba; padding: 6px 8px; border-radius: 0 6px 6px 0;
  margin: 0 0 10px; line-height: 1.4;
}
.origin-badge.added { border-left-color: var(--green); }
.origin-badge.modified { border-left-color: var(--orange); }

/* scenario manager */
.scenario-card {
  border: 1px solid var(--hairline); border-radius: 10px; padding: 12px;
  display: flex; flex-direction: column; gap: 8px;
}
.scenario-card.active-card { border-color: var(--slate); box-shadow: 0 0 0 1px var(--slate); }
.scenario-card-head { display: flex; align-items: center; gap: 8px; }
.scenario-card-head .sc-name { flex: 1; font-weight: 600; }
.sc-kind {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); border: 1px solid var(--hairline); border-radius: 10px; padding: 2px 8px;
}
.sc-diff-summary { font-size: 11.5px; color: var(--muted); margin: 0; }
.removed-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: 11px; background: #f3e9e7; color: var(--brick);
  border-radius: 10px; padding: 3px 8px; display: inline-flex; align-items: center; gap: 6px;
}
.chip-restore {
  font-size: 10.5px !important; padding: 1px 6px !important; border-radius: 8px !important;
}

/* ---------- modal ---------- */
#modal-backdrop {
  position: fixed; inset: 0; background: rgba(20,30,38,0.45); z-index: 50;
  display: flex; align-items: center; justify-content: center;
}
#modal-backdrop[hidden] { display: none; }
#popup[hidden] { display: none; }
#modal {
  background: var(--paper); border-radius: 12px; padding: 20px 22px;
  width: min(560px, 92vw); max-height: 84vh; overflow-y: auto;
  box-shadow: 0 12px 40px rgba(10,20,28,0.3);
}
#modal h2 { margin: 0 0 14px; font-size: 16px; }
#modal .modal-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
#modal .modal-row { display: flex; gap: 6px; align-items: center; }
#modal .modal-row input { flex: 1; }
#modal .modal-row .row-id { flex: 0 0 60px; font-size: 11px; color: var(--muted); }
#modal .modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
#modal .field-stack { display: flex; flex-direction: column; gap: 10px; }
