/* XPoll: anodized greys, one configurable accent, system SF/mono type, results readout. */

:root {
  --accent: #2563eb; /* overridden by /theme.css from poll.toml */
  --accent-ink: #ffffff;

  --bg: #f1f3f6;
  --surface: #ffffff;
  --surface-2: #e8ebf0;
  --ink: #101318;
  --muted: #5a616c;
  --line: #d9dee5;
  --danger: #c0262d;
  --success: #1a7f4b;

  --readout: #ffffff;
  --readout-ink: #101318;
  --readout-muted: #5a616c;
  --readout-line: #e3e7ec;
  --readout-track: #e8ebf0;
  --readout-shadow: 0 20px 40px -30px rgb(16 19 24 / 30%);
  --leader: var(--accent);

  --accent-soft: color-mix(in srgb, var(--accent) 10%, var(--surface));
  --accent-line: color-mix(in srgb, var(--accent) 45%, var(--line));
  --accent-strong: color-mix(in srgb, var(--accent) 86%, #000);

  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Menlo, Consolas,
    monospace;

  --radius: 14px;
  --radius-lg: 20px;
  --measure: 54rem;
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%238b93a1' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.5l3 3 6-7' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");

  color-scheme: light dark;
}

:root[data-theme="light"] {
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0d0f13;
  --surface: #161a20;
  --surface-2: #1d2129;
  --ink: #eceef2;
  --muted: #98a0ac;
  --line: #2a2f39;
  --danger: #ff6b6b;
  --success: #4ade80;

  --readout: #07080b;
  --readout-ink: #e8ebf0;
  --readout-muted: #8b93a1;
  --readout-line: #1e232d;
  --readout-track: #171b22;
  --readout-shadow: 0 24px 48px -28px rgb(0 0 0 / 60%);
  --leader: color-mix(in srgb, var(--accent) 55%, #fff);

  --accent-soft: color-mix(in srgb, var(--accent) 18%, var(--surface));
  --accent-line: color-mix(in srgb, var(--accent) 55%, var(--line));
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0f13;
    --surface: #161a20;
    --surface-2: #1d2129;
    --ink: #eceef2;
    --muted: #98a0ac;
    --line: #2a2f39;
    --danger: #ff6b6b;
    --success: #4ade80;

    --readout: #07080b;
    --readout-ink: #e8ebf0;
    --readout-muted: #8b93a1;
    --readout-line: #1e232d;
    --readout-track: #171b22;
    --readout-shadow: 0 24px 48px -28px rgb(0 0 0 / 60%);
    --leader: color-mix(in srgb, var(--accent) 55%, #fff);

    --accent-soft: color-mix(in srgb, var(--accent) 18%, var(--surface));
    --accent-line: color-mix(in srgb, var(--accent) 55%, var(--line));
  }
}

/* ---------- base ---------- */

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--accent);
  text-underline-offset: 0.18em;
}

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

h1,
h2 {
  text-wrap: balance;
}

.container {
  width: 100%;
  max-width: var(--measure);
  margin-inline: auto;
  padding-inline: 1rem;
}

.skip-link {
  position: absolute;
  left: -999px;
}

.skip-link:focus {
  left: 1rem;
  top: 1rem;
  z-index: 20;
  padding: 0.5rem 1rem;
  background: var(--surface);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- header & footer ---------- */

.site-header {
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 3.5rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
  color: var(--ink);
  font-weight: 650;
  text-decoration: none;
}

.brand img {
  flex: none;
  border-radius: 6px;
}

.brand-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-index .brand-text {
  display: none;
}

@media (max-width: 30rem) {
  .brand-text {
    display: none;
  }
}

.site-nav {
  display: flex;
  gap: 0.25rem;
  flex: none;
}

.site-nav a {
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.925rem;
  font-weight: 550;
  text-decoration: none;
}

.site-nav a:hover {
  color: var(--ink);
  background: var(--surface-2);
}

.site-nav a[aria-current="page"] {
  color: var(--ink);
  background: var(--surface-2);
}

.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  min-height: 0;
  margin-left: 0.25rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
}

.theme-toggle:hover {
  color: var(--ink);
  background: var(--surface-2);
}

.theme-toggle[hidden] {
  display: none;
}

/* Show the icon of the theme you would switch to. */
.theme-toggle .icon-sun,
:root[data-theme="dark"] .theme-toggle .icon-moon {
  display: none;
}

:root[data-theme="dark"] .theme-toggle .icon-sun {
  display: block;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] .theme-toggle .icon-sun {
    display: block;
  }

  :root[data-theme="auto"] .theme-toggle .icon-moon {
    display: none;
  }
}

.site-footer {
  margin-top: 4rem;
  padding-block: 1.5rem 2.5rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.85rem;
}

.site-footer p {
  margin: 0.25rem 0;
}

/* ---------- hero ---------- */

.hero {
  padding-block: 2.75rem 1.5rem;
}

.hero-compact {
  padding-bottom: 0.5rem;
}

.eyebrow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 1rem;
  color: var(--muted);
  font: 600 0.75rem/1.4 var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0 0 0.9rem;
  font-size: clamp(2.2rem, 8.5vw, 3.75rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.035em;
}

.lede {
  margin: 0;
  max-width: 38rem;
  font-size: clamp(1.1rem, 3.6vw, 1.3rem);
  font-weight: 500;
  line-height: 1.4;
}

.rule {
  margin: 0.75rem 0 0;
  max-width: 38rem;
  color: var(--muted);
}

.live-dot {
  position: relative;
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--success);
  flex: none;
}

.live-dot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: inherit;
  animation: pulse 2s ease-out infinite;
}

@keyframes pulse {
  from {
    transform: scale(1);
    opacity: 0.7;
  }
  to {
    transform: scale(3);
    opacity: 0;
  }
}

/* ---------- ballot ---------- */

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.ballot-legend {
  display: flex;
  width: 100%;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0;
  margin-bottom: 0.75rem;
}

.legend-title {
  font-weight: 700;
  font-size: 1.05rem;
}

.legend-hint {
  color: var(--muted);
  font: 500 0.8rem var(--font-mono);
}

.options {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.625rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

@media (min-width: 40rem) {
  .options {
    grid-template-columns: 1fr 1fr;
  }
}

.option {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.8rem 0.9rem 0.8rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgb(16 19 24 / 4%);
  transition:
    border-color 0.15s ease,
    background-color 0.15s ease,
    box-shadow 0.15s ease;
}

.option:hover {
  border-color: var(--accent-line);
}

.option.is-selected {
  background: var(--accent-soft);
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.option.is-disabled {
  opacity: 0.45;
}

.option.is-disabled:hover {
  border-color: var(--line);
}

.option input {
  position: relative;
  z-index: 1;
  appearance: none;
  flex: none;
  width: 1.375rem;
  height: 1.375rem;
  margin: 0;
  border: 1.5px solid color-mix(in srgb, var(--ink) 30%, transparent);
  border-radius: 7px;
  background: var(--surface);
  cursor: pointer;
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease;
}

.option input:checked {
  border-color: var(--accent);
  background: var(--accent) var(--check) center / 72% no-repeat;
}

.option input:disabled {
  cursor: not-allowed;
}

.option label {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  cursor: pointer;
}

/* The whole card toggles the checkbox; the repository link sits above this layer. */
.option label::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.option.is-disabled label {
  cursor: not-allowed;
}

.option-name {
  font-weight: 650;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.option-desc {
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.4;
}

.repo-link {
  position: relative;
  z-index: 1;
  flex: none;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font: 500 0.72rem/1 var(--font-mono);
  text-decoration: none;
  white-space: nowrap;
}

.repo-link:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.turnstile {
  min-height: 65px;
  margin: 1.25rem 0 0;
}

.form-error {
  min-height: 1.5em;
  margin: 0.5rem 0 0;
  color: var(--danger);
  font-weight: 600;
}

.form-error:empty {
  min-height: 0;
}

.form-success {
  color: var(--success);
  font-weight: 600;
}

/* Sticky action bar: slot meter + status + vote button, within thumb reach. */
.ballot-bar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.6rem 1rem;
  margin: 1rem -1rem 0;
  padding: 0.85rem 1rem calc(0.85rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  backdrop-filter: saturate(1.6) blur(14px);
}

.meter {
  grid-column: 1 / -1;
  display: flex;
  gap: 4px;
}

.slot {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--line);
  transition: background-color 0.2s ease;
}

.slot.is-filled {
  background: var(--accent);
}

.bar-status {
  display: flex;
  flex-direction: column;
  min-width: 0;
  margin: 0;
  font-family: var(--font-mono);
  line-height: 1.3;
}

.bar-count {
  font-size: 0.95rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.bar-hint {
  color: var(--muted);
  font-size: 0.75rem;
}

/* ---------- buttons ---------- */

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.9rem;
  padding: 0.7rem 1.35rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
  transition:
    background-color 0.15s ease,
    transform 0.1s ease,
    opacity 0.15s ease;
}

button:active:not(:disabled),
.button:active {
  transform: translateY(1px);
}

button.primary,
.button.primary {
  border-color: transparent;
  background: var(--accent);
  color: var(--accent-ink);
}

button.primary:hover:not(:disabled),
.button.primary:hover {
  background: var(--accent-strong);
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.ballot-bar .primary {
  min-width: 8.5rem;
}

.cta {
  margin-top: 1.5rem;
}

/* ---------- notices ---------- */

.notice {
  margin: 1rem 0;
  padding: 1.1rem 1.25rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.notice h2 {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}

.notice p {
  margin: 0.35rem 0 0;
  color: var(--muted);
}

.notice.success {
  border-color: color-mix(in srgb, var(--success) 45%, var(--line));
  box-shadow: inset 4px 0 0 var(--success);
}

/* ---------- results readout ---------- */

.readout {
  margin-top: 2rem;
  padding: 1.25rem 1.25rem 1rem;
  border: 1px solid var(--readout-line);
  border-radius: var(--radius-lg);
  background: var(--readout);
  color: var(--readout-ink);
  box-shadow: var(--readout-shadow);
}

.readout-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--readout-line);
}

.readout-head h2 {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0;
  font: 700 0.8rem/1.4 var(--font-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.readout-meta {
  margin: 0;
  color: var(--readout-muted);
  font: 0.78rem var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.readout-meta strong {
  color: var(--readout-ink);
}

.result-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.result {
  display: grid;
  grid-template-columns: 1.75rem minmax(0, 1fr) 5.25rem;
  grid-template-areas:
    "rank name pct"
    ". bar count";
  align-items: baseline;
  gap: 0.35rem 0.75rem;
  padding: 0.85rem 0 0.75rem;
  border-bottom: 1px solid var(--readout-line);
}

.result-rank {
  grid-area: rank;
  color: var(--readout-muted);
  font: 600 0.8rem var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.result-name {
  grid-area: name;
  min-width: 0;
  overflow: hidden;
  color: var(--readout-ink);
  font-weight: 650;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-name:hover {
  text-decoration: underline;
}

.result-pct {
  grid-area: pct;
  font: 700 1.05rem var(--font-mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.result-count {
  grid-area: count;
  color: var(--readout-muted);
  font: 0.72rem var(--font-mono);
  text-align: right;
  white-space: nowrap;
}

.result-bar {
  grid-area: bar;
  align-self: center;
  display: block;
  width: 100%;
  height: 8px;
  border: 0;
  border-radius: 999px;
  background: var(--readout-track);
  color: var(--accent);
  overflow: hidden;
  appearance: none;
}

.result-bar::-webkit-progress-bar {
  border-radius: 999px;
  background: var(--readout-track);
}

.result-bar::-webkit-progress-value {
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.result-bar::-moz-progress-bar {
  border-radius: 999px;
  background: var(--accent);
}

.result.is-leader .result-pct {
  color: var(--leader);
}

.result.is-zero {
  opacity: 0.5;
}

.empty {
  color: var(--readout-muted);
}

.methodology {
  margin: 0.9rem 0 0;
  color: var(--readout-muted);
  font-size: 0.8rem;
  line-height: 1.5;
}

/* ---------- optional questions ---------- */

.questions {
  margin-top: 1.75rem;
}

.question-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

@media (min-width: 40rem) {
  .question-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.question label {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
}

.question select {
  width: 100%;
  min-height: 2.9rem;
  padding: 0.6rem 2.4rem 0.6rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface) var(--chevron) right 0.9rem center / 0.8rem no-repeat;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  appearance: none;
  cursor: pointer;
}

.question select:hover {
  border-color: var(--accent-line);
}

.question select:focus-visible {
  border-color: var(--accent);
  outline-offset: 1px;
}

/* ---------- results breakdown ---------- */

.breakdown {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--readout-line);
}

.breakdown-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  margin: 0 0 0.5rem;
  font: 700 0.8rem/1.4 var(--font-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.breakdown-meta {
  color: var(--readout-muted);
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
}

.breakdown-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.breakdown-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "label count"
    "bar bar"
    "top top";
  gap: 0.3rem 0.75rem;
  padding: 0.6rem 0;
}

.breakdown-label {
  grid-area: label;
  font-weight: 650;
}

.breakdown-count {
  grid-area: count;
  font: 600 0.85rem var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.breakdown-row .result-bar {
  grid-area: bar;
  height: 5px;
}

.breakdown-top {
  grid-area: top;
  color: var(--readout-muted);
  font: 0.75rem/1.4 var(--font-mono);
}

.breakdown-empty {
  color: var(--readout-muted);
  font-size: 0.85rem;
}

/* ---------- suggestions ---------- */

.suggest {
  margin-top: 2.5rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 55%, transparent);
}

.suggest summary {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 1rem 1.25rem;
  font-weight: 650;
  cursor: pointer;
  list-style: none;
}

.suggest summary::-webkit-details-marker {
  display: none;
}

.suggest summary::before {
  content: "+";
  display: grid;
  place-items: center;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  background: var(--surface-2);
  font: 700 0.95rem/1 var(--font-mono);
  transition: transform 0.2s ease;
}

.suggest[open] summary::before {
  transform: rotate(45deg);
}

.suggestion-form {
  padding: 0 1.25rem 1.25rem;
}

.suggest-note {
  margin: 0 0 0.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.suggestion-form label {
  display: block;
  margin: 1rem 0 0.35rem;
  font-size: 0.9rem;
  font-weight: 650;
}

.optional {
  margin-left: 0.25rem;
  color: var(--muted);
  font: 500 0.72rem var(--font-mono);
}

.suggestion-form input,
.suggestion-form textarea {
  width: 100%;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

.suggestion-form input:focus-visible,
.suggestion-form textarea:focus-visible {
  border-color: var(--accent);
  outline-offset: 0;
}

.suggestion-form button {
  margin-top: 0.75rem;
}

/* ---------- privacy ---------- */

.prose {
  max-width: 40rem;
}

.prose h1 {
  margin: 0 0 1rem;
  font-size: clamp(2rem, 7vw, 2.75rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.05;
}

.prose h2 {
  margin: 2rem 0 0.5rem;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
}

.prose li {
  margin-bottom: 0.6rem;
}

.prose code {
  padding: 0.1rem 0.35rem;
  border-radius: 5px;
  background: var(--surface-2);
  font: 0.85em var(--font-mono);
}

/* ---------- motion ---------- */

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