/* Shared styles for the voter screens and the results board. Colours follow the COMPASS dashboard. */

:root {
  color-scheme: light;
  --bg: #eef2f8;
  --surface: #ffffff;
  --text: #0a2342;
  --text-soft: #4a5a78;
  --line: #d3dcea;
  --accent: #004c97;
  --accent-strong: #003a75;
  --accent-soft: #e7f0fa;
  --operator: #004c97;
  --source: #6b5c40;
  --danger: #b3261e;
  --danger-soft: #fbeceb;
  --focus: #0a2342;
  --radius: 6px;
  --gutter: 16px;
  font-family: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
}

h1,
h2,
h3,
p {
  margin: 0;
}

button,
textarea,
input {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.shell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px var(--gutter);
  background: var(--text);
  color: #ffffff;
}

.mark {
  font-weight: 700;
  letter-spacing: 0.04em;
}

.shell-note {
  font-size: 14px;
  color: #c9d6ea;
  font-variant-numeric: tabular-nums;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 10px 18px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--accent);
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease;
}

@media (hover: hover) {
  .button:hover {
    background: var(--accent-soft);
  }

  .button.primary:hover {
    background: var(--accent-strong);
    border-color: var(--accent-strong);
  }

  .row-toggle:hover .row-context {
    text-decoration: underline;
  }
}

.button:active {
  background: #d5e4f6;
}

.button.primary {
  background: var(--accent);
  color: #ffffff;
}

.button.primary:active {
  background: var(--accent-strong);
}

.button.quiet {
  border-color: var(--line);
  color: var(--text);
}

.button:disabled {
  opacity: 0.55;
  cursor: default;
}

.alert {
  padding: 10px 12px;
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  background: var(--danger-soft);
  color: var(--danger);
  font-weight: 600;
}

/* Voter screens */

.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px var(--gutter) 32px;
}

.page.with-bar {
  padding-bottom: 220px;
}

.page.compare {
  max-width: 1120px;
}

.title {
  font-size: 28px;
  line-height: 1.2;
  font-weight: 700;
}

.lead {
  margin-top: 12px;
  font-size: 18px;
}

.steps {
  margin: 20px 0 0;
  padding: 0 0 0 22px;
}

.steps li {
  margin-top: 8px;
}

.fine {
  margin-top: 20px;
  color: var(--text-soft);
  font-size: 15px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

.actions .button {
  flex: 1 1 160px;
}

.progress h1 {
  font-size: 20px;
  font-weight: 700;
}

.meter {
  height: 4px;
  margin-top: 10px;
  border-radius: 2px;
  background: var(--line);
}

.meter span {
  display: block;
  height: 100%;
  border-radius: 2px;
  background: var(--accent);
  transition: width 200ms ease;
}

.switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-top: 16px;
}

.switch button {
  position: relative;
  min-height: 44px;
  border: 1px solid var(--accent);
  border-radius: var(--radius) 0 0 var(--radius);
  background: var(--surface);
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
}

.switch button + button {
  border-left: 0;
  border-radius: 0 var(--radius) var(--radius) 0;
}

.switch button[aria-pressed="true"] {
  background: var(--accent);
  color: #ffffff;
}

.switch button:focus-visible {
  z-index: 1;
}

.excerpts {
  margin-top: 16px;
}

.excerpt {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.excerpt-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.excerpt-name {
  display: none;
  font-size: 15px;
  font-weight: 700;
}

.excerpt-context {
  margin-top: 2px;
  color: var(--text-soft);
  font-size: 15px;
}

.turns {
  margin: 0;
  padding: 4px 16px 12px;
}

.turn {
  margin-top: 12px;
}

.turn dt {
  font-size: 14px;
  font-weight: 700;
}

.turn dd {
  margin: 2px 0 0;
  font-size: 17px;
  line-height: 1.5;
}

.turn.operator dt {
  color: var(--operator);
}

.turn.source dt {
  color: var(--source);
}

.turn.source dd {
  padding-left: 12px;
  border-left: 2px solid var(--line);
}

.bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 12px var(--gutter) calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.bar-inner {
  max-width: 640px;
  margin: 0 auto;
}

.bar-prompt {
  font-weight: 600;
}

.bar-note {
  color: var(--text-soft);
  font-size: 15px;
}

.choices {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.choices .button {
  min-height: 52px;
  padding: 8px 6px;
  line-height: 1.2;
}

.bar .alert {
  margin-top: 10px;
}

.bar .button.primary {
  width: 100%;
  margin-top: 10px;
}

.field {
  display: block;
  margin-top: 20px;
}

.field textarea {
  display: block;
  width: 100%;
  min-height: 140px;
  margin-top: 8px;
  padding: 12px;
  border: 1px solid #8a99b5;
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 17px;
  resize: vertical;
}

.skeleton {
  height: 16px;
  margin-top: 14px;
  border-radius: 4px;
  background: var(--line);
}

.skeleton.short {
  width: 60%;
}

@media (min-width: 960px) {
  .page.compare .switch {
    display: none;
  }

  .page.compare .excerpts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
  }

  .page.compare .excerpt[hidden] {
    display: block !important;
  }

  .page.compare .excerpt-name {
    display: block;
  }
}

/* Results board */

.board {
  max-width: 1500px;
  margin: 0 auto;
  padding: 24px var(--gutter) 48px;
}

.board-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.board-head h1 {
  font-size: 30px;
  line-height: 1.2;
}

.stamp {
  margin-top: 6px;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
}

.board-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.board-tools .button {
  min-height: 44px;
}

.panel {
  margin-top: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow-x: auto;
}

.panel h2 {
  padding: 14px 16px 0;
  font-size: 18px;
}

.panel-note {
  padding: 4px 16px 0;
  color: var(--text-soft);
  font-size: 15px;
}

.empty {
  padding: 28px 16px;
  color: var(--text-soft);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

thead th {
  color: var(--text-soft);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

tbody tr:last-child > td,
tbody tr:last-child > th {
  border-bottom: 0;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.rank {
  width: 44px;
  color: var(--text-soft);
  font-weight: 400;
}

.rating {
  font-size: 20px;
  font-weight: 700;
}

.row-toggle {
  display: block;
  width: 100%;
  min-width: 260px;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  font-weight: 400;
  text-align: left;
  cursor: pointer;
}

.row-context {
  font-weight: 600;
}

.row-context,
.row-attributes {
  display: block;
}

.row-attributes {
  margin-top: 2px;
  color: var(--text-soft);
  font-size: 15px;
}

.tag {
  display: inline-block;
  margin-left: 8px;
  padding: 0 8px;
  border: 1px solid var(--text-soft);
  border-radius: 999px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.ladder-cell {
  position: relative;
  width: 34%;
  min-width: 260px;
}

.ladder {
  position: relative;
  height: 28px;
}

/* The 1500 line runs the full height of every row, so it reads as one line down the table. */
.ladder-cell .middle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  background: #9fb0cb;
}

.ladder .range {
  position: absolute;
  top: 13px;
  height: 2px;
  background: #7fa6d0;
}

.ladder .dot {
  position: absolute;
  top: 8px;
  width: 12px;
  height: 12px;
  margin-left: -6px;
  border-radius: 50%;
  background: var(--accent);
}

.scale {
  display: flex;
  justify-content: space-between;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 400;
}

.detail td {
  background: #f7f9fc;
}

.detail .turns {
  max-width: 900px;
  padding: 0 0 4px;
}

/* Opened on the projector, an excerpt is read by the whole room. */
.detail .turn dt,
.detail .turn dd {
  font-size: inherit;
}

.groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 1fr));
  gap: 8px 32px;
  align-items: start;
  padding: 8px 4px;
}

.groups th,
.groups td {
  padding: 8px 12px;
}

.groups thead th:first-child {
  color: var(--text);
  font-weight: 700;
}

.groups tbody th {
  font-weight: 400;
}

.comments {
  margin: 0;
  padding: 8px 16px 16px;
  list-style: none;
}

.comments li {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.comments li:last-child {
  border-bottom: 0;
}

.gate {
  max-width: 420px;
  margin: 48px auto;
  padding: 0 var(--gutter);
}

.gate label {
  display: block;
  margin-top: 16px;
  font-weight: 600;
}

.gate input {
  display: block;
  width: 100%;
  min-height: 48px;
  margin-top: 8px;
  padding: 10px 12px;
  border: 1px solid #8a99b5;
  border-radius: var(--radius);
  background: var(--surface);
}

.gate .button {
  width: 100%;
  margin-top: 16px;
}

.gate .alert {
  margin-top: 16px;
}

@media (min-width: 1400px) {
  .board {
    font-size: 19px;
  }

  .board-head h1 {
    font-size: 32px;
  }

  .rating {
    font-size: 24px;
  }

  .row-attributes,
  .panel-note {
    font-size: 17px;
  }

  thead th {
    font-size: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
