/* ===================================
   HOW IT WORKS - "Comment ça marche"
   Civic Blueprint field-guide layer.
   Extends legal.css (document spec) +
   design-system.css tokens ONLY - the
   role/status badges below are the
   REAL app components, not replicas.
   =================================== */

/* ===================================
   ROLE SPEC CARDS
   =================================== */
.hiw-roles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
  margin: var(--space-6) 0;
}

.hiw-role-card {
  position: relative;
  overflow: hidden;
  padding: var(--space-5);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
}

/* Oversized glyph watermark in the role's own colour */
.hiw-role-glyph {
  position: absolute;
  top: -0.35em;
  right: var(--space-3);
  font-size: 5.5rem;
  line-height: 1;
  opacity: 0.1;
  pointer-events: none;
  user-select: none;
}

.hiw-role-card-citizen { border-left: 3px solid var(--c-accent); }
.hiw-role-card-citizen .hiw-role-glyph { color: var(--c-accent); }
.hiw-role-card-business { border-left: 3px solid var(--c-idea); }
.hiw-role-card-business .hiw-role-glyph { color: var(--c-idea); }
.hiw-role-card-institution { border-left: 3px solid var(--cat-public-space); }
.hiw-role-card-institution .hiw-role-glyph { color: var(--cat-public-space); }

.hiw-role-name {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--c-text);
  margin: var(--space-2) 0 var(--space-3);
}

.hiw-role-card ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.hiw-role-card li {
  position: relative;
  padding-left: var(--space-5);
  font-size: var(--text-sm);
  color: var(--c-text-soft);
  line-height: 1.6;
}

.hiw-role-card li + li { margin-top: var(--space-2); }

.hiw-role-card li::before {
  content: '+';
  position: absolute;
  left: 0;
  top: 0;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--c-accent);
}

.hiw-role-card li.hiw-cap-extra::before {
  content: '★';
  font-size: 0.7rem;
  top: 2px;
  color: var(--cat-public-space);
}

/* Admin note strip under the role grid */
.hiw-admin-note {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  padding: var(--space-4) var(--space-5);
  margin: var(--space-5) 0;
  background: var(--c-abyss);
  border: 1px dashed var(--c-border-bright);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  color: var(--c-text-soft);
  line-height: 1.65;
}

.hiw-admin-note .role-badge { flex-shrink: 0; margin-top: 2px; }
.hiw-admin-note p { margin: 0; max-width: none; }
.hiw-admin-note-body { min-width: 0; }
.hiw-admin-note-body p + p { margin-top: var(--space-3); }

/* UF-9: institution-only entry point (revealed by js/access-ui.js) */
.hiw-access-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  margin: var(--space-5) 0;
  background: var(--c-accent-soft);
  border: 1px solid var(--c-border-bright);
  border-left: 3px solid var(--c-accent);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  color: var(--c-text-soft);
  line-height: 1.65;
}

.hiw-access-card p { margin: 0; max-width: 46ch; }
.hiw-access-card .btn { min-height: 44px; flex-shrink: 0; }

/* ===================================
   LIFECYCLE DIAGRAM
   A blueprint pipeline: stations on a
   rail, each rendering the app's real
   status badge for that state.
   =================================== */
.hiw-lifecycle {
  margin: var(--space-8) 0;
  padding: var(--space-6) var(--space-5);
  background: var(--c-abyss);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  /* Blueprint grid backdrop */
  background-image:
    linear-gradient(var(--c-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--c-grid) 1px, transparent 1px);
  background-size: 24px 24px;
}

.hiw-track {
  position: relative;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: var(--space-4);
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: hiw-step;
}

/* The rail */
.hiw-track::before {
  content: '';
  position: absolute;
  top: 7px;
  left: 8px;
  right: 8px;
  height: 2px;
  background: linear-gradient(90deg,
    var(--c-idea) 0%,
    var(--c-accent) 30%,
    var(--c-converge) 55%,
    var(--c-reality) 100%);
  opacity: 0.5;
}

.hiw-station {
  position: relative;
  padding-top: var(--space-6);
  counter-increment: hiw-step;
}

.hiw-node {
  position: absolute;
  top: 0;
  left: 0;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--c-accent);
  background: var(--c-void);
  box-shadow: 0 0 0 4px var(--c-abyss);
}

.hiw-station-submit .hiw-node { border-color: var(--c-idea); border-style: dashed; }
.hiw-station-waiting .hiw-node { border-color: var(--c-text-soft); }
.hiw-station-review .hiw-node { border-color: var(--c-converge); }
.hiw-station-decision .hiw-node { border-color: var(--c-reality); }
.hiw-station-progress .hiw-node { border-color: var(--c-idea); }
.hiw-station-completed .hiw-node {
  border-color: var(--c-reality);
  background: var(--c-reality);
}

/* Mono step index above each caption */
.hiw-station-num {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--c-text-dim);
  margin-bottom: var(--space-2);
}

.hiw-station-num::before {
  content: counter(hiw-step, decimal-leading-zero) ' · ';
  color: var(--c-accent);
}

/* Inside the diagram, badges must fit their column - let them wrap. */
.hiw-lifecycle .status-badge {
  white-space: normal;
  align-items: flex-start;
  line-height: 1.4;
  padding-top: 2px;
  padding-bottom: 2px;
  max-width: 100%;
}

.hiw-lifecycle .status-badge .status-badge-dot {
  margin-top: 6px;
}

/* The "act" chip (submission is an action, not a review status) */
.hiw-act {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 2px var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-radius: var(--radius-full);
  border: 1px dashed color-mix(in srgb, var(--c-idea) 50%, transparent);
  color: var(--c-idea);
  white-space: nowrap;
}

/* Fork: approved OR declined, stacked */
.hiw-fork {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-1);
}

.hiw-fork-or {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--c-text-dim);
  padding-left: var(--space-3);
}

.hiw-station-note {
  margin: var(--space-3) 0 0;
  font-size: var(--text-xs);
  line-height: 1.6;
  color: var(--c-text-muted);
  max-width: none;
}

/* Transparency callout (why declined stays visible) */
.hiw-callout {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  margin: var(--space-5) 0;
  background: var(--c-converge-soft);
  border: 1px solid color-mix(in srgb, var(--c-converge) 30%, transparent);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  color: var(--c-text-soft);
  line-height: 1.7;
}

.hiw-callout-mark {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--c-converge);
}

.hiw-callout p { margin: 0; max-width: none; }
.hiw-callout strong { color: var(--c-converge); }

/* ===================================
   PROXIMITY-WEIGHT ILLUSTRATION
   Plain-language bars, no formulas.
   =================================== */
.hiw-weight {
  margin: var(--space-6) 0;
  padding: var(--space-5);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
}

.hiw-weight-row {
  display: grid;
  grid-template-columns: 130px 1fr;
  align-items: center;
  gap: var(--space-4);
}

.hiw-weight-row + .hiw-weight-row { margin-top: var(--space-4); }

.hiw-weight-label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--c-text-soft);
  text-align: right;
}

.hiw-weight-bar {
  height: 14px;
  background: var(--c-accent-soft);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.hiw-weight-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--c-accent);
}

.hiw-weight-near .hiw-weight-fill { width: 100%; }
.hiw-weight-mid .hiw-weight-fill { width: 55%; opacity: 0.75; }
.hiw-weight-far .hiw-weight-fill { width: 14%; opacity: 0.55; }

.hiw-weight-caption {
  margin: var(--space-4) 0 0;
  font-size: var(--text-xs);
  font-style: italic;
  color: var(--c-text-muted);
  max-width: none;
}

/* ===================================
   IDEA SOURCES
   =================================== */
.hiw-sources {
  display: grid;
  gap: var(--space-4);
  margin: var(--space-6) 0;
}

.hiw-source-card {
  padding: var(--space-5);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
}

.hiw-source-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.hiw-source-title {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--c-text);
  margin: 0;
}

.hiw-source-card p {
  font-size: var(--text-sm);
  color: var(--c-text-soft);
  line-height: 1.7;
  max-width: none;
  margin: 0;
}

.hiw-source-card p + p { margin-top: var(--space-3); }

/* Small mono tag chips: live / seeded / upcoming */
.hiw-tag {
  display: inline-flex;
  align-items: center;
  padding: 1px var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: var(--radius-sm);
  border: 1px solid var(--c-border);
}

.hiw-tag-live { color: var(--c-reality); border-color: color-mix(in srgb, var(--c-reality) 40%, transparent); background: var(--c-reality-soft); }
.hiw-tag-seeded { color: var(--c-idea); border-color: color-mix(in srgb, var(--c-idea) 40%, transparent); background: var(--c-idea-soft); }
.hiw-tag-soon { color: var(--c-text-muted); border-style: dashed; }

/* The exact attribution string, rendered as it appears in the app */
.hiw-attribution {
  font-family: var(--font-mono);
  font-size: 0.85em;
  color: var(--c-idea);
  background: var(--c-idea-soft);
  border: 1px solid color-mix(in srgb, var(--c-idea) 30%, transparent);
  border-radius: var(--radius-sm);
  padding: 0 var(--space-2);
  white-space: nowrap;
}

.hiw-example {
  font-style: italic;
  color: var(--c-text-muted) !important;
}

/* ===================================
   RESPONSIVE - the rail goes vertical
   =================================== */
@media (max-width: 700px) {
  .hiw-roles { grid-template-columns: 1fr; }

  .hiw-track {
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
  }

  .hiw-track::before {
    top: 8px;
    bottom: 8px;
    left: 7px;
    right: auto;
    width: 2px;
    height: auto;
    background: linear-gradient(180deg,
      var(--c-idea) 0%,
      var(--c-accent) 30%,
      var(--c-converge) 55%,
      var(--c-reality) 100%);
  }

  .hiw-station {
    padding-top: 0;
    padding-left: var(--space-8);
  }

  .hiw-node { top: 2px; }

  .hiw-weight-row {
    grid-template-columns: 1fr;
    gap: var(--space-1);
  }

  .hiw-weight-label { text-align: left; }
}
