/* Cross-Impact Instrument — functional stylesheet.
   Scope deliberately: legible structure, real interactive states (hover,
   active/pressed, disabled, "this is the current step"), and enough visual
   grouping that a cold respondent isn't reading a wall of plain text. Not
   a visual identity pass — colours are a small neutral-plus-one-accent
   system, not a brand system. */

:root {
  --sticky-offset: 0px;
  --bg: #faf9f5;
  --ink: #141413;
  --ink-soft: #5b5952;
  --border: #e4e1d8;
  --card: #ffffff;
  --accent: #3f6b52;
  --accent-ink: #ffffff;
  --danger: #a13f2b;
  --radius: 8px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-padding-top: 12px; }
body {
  margin: 0;
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
}
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 18px 80px;
}

.eyebrow {
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
h1 { font-size: 1.4rem; margin: 0 0 12px; line-height: 1.25; }
h3 { font-size: 1rem; margin: 0 0 8px; }
p { margin: 0 0 12px; }
.muted { color: var(--ink-soft); font-size: 0.85rem; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

/* ---- buttons ---- */
button {
  font: inherit;
  cursor: pointer;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--ink);
  padding: 9px 16px;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.05s ease;
}
button:hover:not(:disabled) { border-color: #c9c4b6; background: #f4f2ec; }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  padding: 11px 20px;
}
.btn-primary:hover:not(:disabled) { background: #345a44; border-color: #345a44; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-soft); }
.btn-ghost:hover:not(:disabled) { background: #f0efe8; color: var(--ink); }

/* toggle/chip controls (relevant?, direction, strength) */
.chiprow { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 6px;
  padding: 7px 12px;
  font-size: 0.86rem;
  min-width: 40px;
}
.chip.chip-on {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
  font-weight: 600;
}
.ctrl-group { margin-bottom: 8px; }
.ctrl-group.is-sub { opacity: 0.72; }
.ctrl-label { display: block; font-size: 0.78rem; color: var(--ink-soft); margin-bottom: 4px; }
.ctrl-label-needed { color: var(--danger); font-weight: 600; }
.ctrl-label-editable::after { content: " — still editable"; font-weight: 400; }
.ctrl-inactive-note { display: block; font-size: 0.74rem; color: var(--ink-soft); margin-top: 2px; }

/* ---- pass tabs ---- */
.passtabs { display: flex; gap: 6px; margin: 14px 0; flex-wrap: wrap; }
.passtab { font-size: 0.84rem; padding: 7px 14px; }
.passtab-active { background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 600; }

/* ---- sticky pass-tabs + progress bar while scrolling the matrix ---- */
.vote-sticky-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  padding-top: 10px;
  margin: 0 -18px;
  padding-left: 18px;
  padding-right: 18px;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 4px 10px -6px rgba(20, 20, 19, 0.15);
}
.vote-sticky-bar .progress-row { margin-bottom: 12px; }
.sticky-title-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap; margin-bottom: 10px;
}
.sticky-title { font-size: 1rem; font-weight: 700; line-height: 1.3; }

/* ---- progress ---- */
.progress-row { display: flex; gap: 18px; margin: 10px 0 16px; flex-wrap: wrap; }
.progress-item { flex: 1 1 160px; min-width: 140px; }
.progress-item .label { font-size: 0.76rem; color: var(--ink-soft); margin-bottom: 4px; display: flex; justify-content: space-between; }
.progress-track { height: 8px; border-radius: 4px; background: var(--border); overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 4px; transition: width 0.2s ease; }
.progress-note { font-size: 0.84rem; color: var(--ink-soft); margin: 6px 0 14px; }

/* ---- issue / matrix rows ---- */
.issue-card { border-top: 1px solid var(--border); padding-top: 0; margin-top: 16px; }
.issue-card:first-of-type { border-top: none; margin-top: 0; }

/* Frozen per-issue header: stays pinned just under the global sticky bar
   while you work through that issue's rows, then the next issue's own
   header takes its place once you scroll past this one. */
.issue-sticky-header {
  position: sticky;
  top: var(--sticky-offset, 0px);
  background: var(--bg);
  z-index: 15;
  padding: 14px 0 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}
.issue-title { font-size: 1.05rem; font-weight: 700; margin-bottom: 4px; }
.issue-summary { color: var(--ink-soft); font-size: 0.92rem; }
.issue-media { margin: 10px 0; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.issue-details { background: #f6f4ee; border-radius: 6px; padding: 12px; font-size: 0.88rem; color: var(--ink-soft); margin: 8px 0 4px; }

.passrow {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  background: var(--card);
}
.passrow-label { flex: 1 1 220px; min-width: 200px; }
.passrow-dim { display: flex; align-items: center; gap: 6px; font-weight: 600; margin-top: 2px; }

/* ---- dimension navigation icons (nav-icons-sketch) ----
   Same ink colour as surrounding text, one fixed glyph per dimension.
   No colour/direction/verdict encoded — purely "which row is this." */
.dim-icon {
  width: 16px; height: 16px; flex: none;
  stroke: currentColor; stroke-width: 1.6; fill: none;
  stroke-linecap: round; stroke-linejoin: round;
}
.dim-label-icon { display: inline-flex; align-items: center; gap: 5px; }
.dim-info-btn {
  width: 18px; height: 18px; border-radius: 50%;
  padding: 0; font-size: 0.7rem; line-height: 1;
  border: 1px solid var(--border); color: var(--ink-soft); background: var(--bg);
}
.dim-explain { margin-top: 6px; font-size: 0.82rem; color: var(--ink-soft); background: #f6f4ee; border-radius: 6px; padding: 8px 10px; }
.passrow-controls { flex: 1 1 260px; min-width: 220px; }

/* ---- R1 histogram toggle ---- */
.r1hist-btn {
  font-size: 0.72rem; border-radius: 12px; padding: 3px 10px;
  border-color: var(--border); color: var(--ink-soft); margin-top: 6px;
}
.r1hist-btn[aria-expanded="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.hist-bar { display: flex; height: 10px; border-radius: 4px; overflow: hidden; border: 1px solid var(--border); margin-top: 6px; max-width: 320px; }
.hist-seg-lean { background: var(--ink-soft); }
.hist-seg-nr { background: var(--border); }
.hist-legend { display: flex; justify-content: space-between; font-size: 0.72rem; color: var(--ink-soft); max-width: 320px; margin-top: 3px; }

/* ---- rank / accord rows (results, insights) ---- */
.rank-row { display: flex; align-items: center; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.rank-row:last-child { border-bottom: none; }
.rank-row .rr-label { flex: 1 1 40%; font-size: 0.92rem; }
.rank-bar-track { flex: 1 1 40%; height: 9px; background: var(--border); border-radius: 5px; overflow: hidden; }
.rank-bar-fill { height: 100%; background: var(--accent); }
.rr-value { flex: 0 0 auto; min-width: 90px; text-align: right; font-size: 0.82rem; color: var(--ink-soft); }
.lean-tag { font-size: 0.78rem; padding: 2px 8px; border-radius: 10px; background: #f0efe8; color: var(--ink-soft); }

/* ---- moderator ---- */
.modbar { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.modtab { font-size: 0.86rem; }
.modtab-active { background: var(--ink); border-color: var(--ink); color: #fff; }
.modrow { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
input[type="text"], input[type="datetime-local"], input[type="password"] {
  font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--card); color: var(--ink);
}
label { font-size: 0.84rem; color: var(--ink-soft); }
.status-pill { display: inline-block; font-size: 0.78rem; padding: 3px 10px; border-radius: 12px; background: #f0efe8; color: var(--ink-soft); }
.status-pill.is-live { background: #e6efe9; color: var(--accent); font-weight: 600; }
.status-pill.is-closed { background: #fbeae5; color: var(--danger); font-weight: 600; }

.error-banner { background: #fbeae5; border: 1px solid #eec3b6; color: var(--danger); border-radius: 6px; padding: 10px 12px; margin-bottom: 14px; font-size: 0.88rem; }
.nudge-banner { background: #f0efe8; border-radius: 6px; padding: 10px 12px; margin-bottom: 14px; font-size: 0.9rem; }

a.modlink { display: inline-block; margin-top: 18px; font-size: 0.82rem; color: var(--ink-soft); }

@media (max-width: 480px) {
  .rank-row { flex-wrap: wrap; }
  .rr-value { text-align: left; }
}
