/* Sem Sentido — azul-gelo, minimalista. Contrastes verificados (WCAG 2.2 AA):
   ink/bg 15.2:1 · muted/bg 6.8:1 · accent/bg 7.0:1 · branco/accent 7.5:1 ·
   danger/branco 7.5:1 · bordas de campos 4.35:1 · segmentos da barra ≥ 5:1 sobre a trilha. */

:root {
  --bg: #F2F8FB;
  --surface: #FFFFFF;
  --soft: #DDEFF8;
  --track: #DCE9F0;
  --line: #C9DDE8;
  --control: #5F7D90;
  --ink: #0E2230;
  --muted: #43596A;
  --accent: #0A5A85;
  --accent-hover: #084A6E;
  --reject: #4F6372;
  --danger: #A1261B;
  --danger-soft: #FBEDEB;
  --ok-soft: #E3F3EA;
  --ok-ink: #1C5B36;
  --radius: 10px;
  --space: clamp(1rem, 0.6rem + 1.6vw, 1.75rem);
  --measure: 46rem;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

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

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.skip {
  position: absolute;
  left: 1rem; top: -100px;
  z-index: 10;
  padding: 0.75rem 1rem;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius);
  font-weight: 600;
}
.skip:focus { top: 1rem; }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}
/* Foco programático em títulos/regiões: visível, mas discreto. */
[tabindex="-1"]:focus { outline: none; }
[tabindex="-1"]:focus-visible { outline: 3px solid var(--accent); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

[hidden] { display: none !important; }

/* ---------- Layout ---------- */

.wrap {
  width: 100%;
  max-width: calc(var(--measure) + 2 * var(--space));
  margin-inline: auto;
  padding-inline: var(--space);
}

header.site {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
header.site .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  padding-block: 0.75rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 44px;
  color: var(--ink);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
  text-decoration: none;
}
.brand svg { flex: none; }

nav.main ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
nav.main a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 0.85rem;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 500;
  text-decoration: none;
}
nav.main a:hover { color: var(--ink); background: var(--bg); }
nav.main a[aria-current="page"] {
  color: var(--accent);
  background: var(--soft);
  font-weight: 650;
}

main {
  padding-block: calc(var(--space) * 1.6) calc(var(--space) * 3);
}

footer.site {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9375rem;
}
footer.site .wrap { padding-block: 1.5rem; }
footer.site p { margin: 0; }

/* ---------- Tipografia ---------- */

h1, h2, h3 { line-height: 1.25; letter-spacing: -0.015em; margin: 0; }
h1 { font-size: clamp(1.75rem, 1.4rem + 1.4vw, 2.35rem); font-weight: 700; }
h2 { font-size: 1.3rem; font-weight: 650; }
h3 { font-size: 1.15rem; font-weight: 650; }
p { margin: 0; }
.lead { color: var(--muted); margin-top: 0.6rem; max-width: 40rem; }
.muted { color: var(--muted); }
.small { font-size: 0.9375rem; }
.pre { white-space: pre-line; }

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

.page-head { margin-bottom: calc(var(--space) * 1.4); }

.stack > * + * { margin-top: var(--gap, 1rem); }

section + section { margin-top: calc(var(--space) * 2); }

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 1rem;
}

/* ---------- Superfícies ---------- */

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

.notice {
  padding: 1rem 1.15rem;
  border-radius: var(--radius);
  background: var(--soft);
  border: 1px solid var(--line);
}
.notice.error { background: var(--danger-soft); border-color: var(--danger); color: var(--ink); }
.notice.success { background: var(--ok-soft); border-color: var(--ok-ink); }
.notice strong { display: block; margin-bottom: 0.15rem; }

/* ---------- Formulários ---------- */

form .field + .field { margin-top: 1.15rem; }

label, .label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
}
.hint {
  display: block;
  color: var(--muted);
  font-size: 0.9375rem;
  margin-top: 0.3rem;
}
.req { color: var(--muted); font-weight: 400; }

input[type="text"], input[type="password"], textarea {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 0.65rem 0.8rem;
  border: 1.5px solid var(--control);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  line-height: 1.5;
}
textarea { resize: vertical; min-height: 8rem; }
input:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
[aria-invalid="true"] { border-color: var(--danger) !important; border-width: 2px !important; }

.field-error {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.4rem;
  color: var(--danger);
  font-weight: 600;
  font-size: 0.9375rem;
}
.field-error:empty { display: none; }
.field-error::before { content: "⚠"; speak: never; }

.counter { font-variant-numeric: tabular-nums; }
.counter.over { color: var(--danger); font-weight: 600; }

.password-row { display: flex; gap: 0.5rem; align-items: stretch; }
.password-row input { flex: 1; min-width: 0; }

.check {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  font-weight: 500;
}
.check input {
  flex: none;
  width: 24px; height: 24px;
  margin: 0.15rem 0 0;
  accent-color: var(--accent);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.4rem;
  align-items: center;
}

/* ---------- Botões ---------- */

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 44px;
  min-width: 44px;
  padding: 0.55rem 1.1rem;
  border: 1.5px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
}
button:hover, .button:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
button:disabled { cursor: not-allowed; opacity: 1; background: var(--track); border-color: var(--control); color: var(--muted); }

.secondary {
  background: var(--surface);
  color: var(--accent);
}
.secondary:hover { background: var(--soft); color: var(--accent-hover); }

.quiet {
  background: transparent;
  border-color: transparent;
  color: var(--accent);
  padding-inline: 0.7rem;
}
.quiet:hover { background: var(--soft); border-color: transparent; color: var(--accent-hover); }

.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.danger:hover { background: #821E15; border-color: #821E15; }
.danger.secondary { background: var(--surface); color: var(--danger); }
.danger.secondary:hover { background: var(--danger-soft); color: #821E15; }

button[aria-busy="true"] { cursor: progress; }

/* Votação: estado comunicado por texto, ícone e aria-pressed, não só cor. */
.vote {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 0.75rem;
  margin-top: 1.1rem;
}
.vote .options { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.vote button { background: var(--surface); color: var(--accent); }
.vote button:hover { background: var(--soft); color: var(--accent-hover); }
.vote button .mark { display: inline-block; width: 1.1em; text-align: center; }
.vote button[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.vote button[data-choice="reject"][aria-pressed="true"] { background: var(--reject); border-color: var(--reject); }
.vote .state { color: var(--muted); font-size: 0.9375rem; }
.vote .state strong { color: var(--ink); }

/* ---------- Ideias e regras ---------- */

.list { list-style: none; margin: 0; padding: 0; }
.list > li + li { margin-top: 1rem; }

.item h3 { font-size: 1.2rem; }
.meta {
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.9375rem;
}
.meta span + span::before { content: " · "; }
.item .body { margin-top: 0.8rem; }

.tally { margin-top: 1.1rem; }
.bar {
  display: flex;
  height: 12px;
  border: 1px solid var(--control);
  border-radius: 999px;
  background: var(--track);
  overflow: hidden;
  gap: 2px;
}
.bar .seg { height: 100%; flex: none; }
.bar .seg.approve { background: var(--accent); }
.bar .seg.reject {
  background: repeating-linear-gradient(135deg, var(--reject) 0 4px, #6F8291 4px 7px);
}
.figures {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  margin: 0.55rem 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.9375rem;
  font-variant-numeric: tabular-nums;
}
.figures .key {
  display: inline-block;
  width: 0.85em; height: 0.85em;
  margin-right: 0.35rem;
  vertical-align: -0.05em;
  border-radius: 2px;
  border: 1px solid var(--control);
}
.figures .key.approve { background: var(--accent); }
.figures .key.reject { background: repeating-linear-gradient(135deg, var(--reject) 0 3px, #6F8291 3px 5px); }
.figures .key.pending { background: var(--track); }

details.voters { margin-top: 0.9rem; }
details.voters summary {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
}
details.voters ul { margin: 0.25rem 0 0; padding-left: 1.25rem; }

.item-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}

.empty {
  padding: 2rem var(--space);
  text-align: center;
  color: var(--muted);
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
}

/* Estatuto */
.rule-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}
.rule-num {
  display: block;
  color: var(--accent);
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 0.2rem;
}

.revocation {
  margin-top: 1.1rem;
  padding: 1rem;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--line);
}
.revocation h4 { margin: 0; font-size: 1.05rem; }

/* Menu de três pontos (padrão disclosure) */
.menu { position: relative; flex: none; }
.menu > button {
  width: 44px; height: 44px;
  padding: 0;
  border-radius: 999px;
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  font-size: 1.4rem;
}
.menu > button:hover, .menu > button[aria-expanded="true"] { background: var(--soft); color: var(--ink); }
.menu ul {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 5;
  min-width: 14rem;
  margin: 0;
  padding: 0.35rem;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--control);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgb(14 34 48 / 0.12);
}
.menu ul button {
  width: 100%;
  justify-content: flex-start;
  background: transparent;
  border-color: transparent;
  color: var(--ink);
  font-weight: 500;
}
.menu ul button:hover, .menu ul button:focus-visible { background: var(--soft); color: var(--ink); }

/* Sobre */
.prose p + p { margin-top: 1em; }
.prose { font-size: 1.125rem; }

.conflict pre {
  margin: 0.5rem 0 0;
  padding: 0.85rem;
  max-height: 16rem;
  overflow: auto;
  white-space: pre-wrap;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-size: 0.9375rem;
}

/* Entrar */
.auth-grid {
  display: grid;
  gap: var(--space);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 19rem), 1fr));
}

/* Perfil */
dl.facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.4rem 1.25rem;
  margin: 1rem 0 0;
}
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; font-weight: 600; }
@media (max-width: 30rem) {
  dl.facts { grid-template-columns: 1fr; }
  dl.facts dd { margin-bottom: 0.5rem; }
}

.danger-zone { border-color: var(--danger); }
.danger-zone h2 { color: var(--danger); }

/* Diálogos */
dialog {
  width: min(32rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  overflow: auto;
  padding: var(--space);
  border: 1px solid var(--control);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 20px 60px rgb(14 34 48 / 0.25);
}
dialog::backdrop { background: rgb(14 34 48 / 0.45); }
dialog h2 { margin-bottom: 0.75rem; }
dialog .irreversible {
  display: flex;
  gap: 0.5rem;
  margin: 1rem 0;
  padding: 0.85rem 1rem;
  border-left: 4px solid var(--danger);
  background: var(--danger-soft);
  font-weight: 600;
}

.loading { color: var(--muted); }

@media (max-width: 30rem) {
  .actions > button, .actions > .button { flex: 1 1 auto; }
}

@media (forced-colors: active) {
  .bar .seg.approve, .figures .key.approve { background: Highlight; }
  .bar .seg.reject, .figures .key.reject { background: GrayText; }
  .vote button[aria-pressed="true"] { border-width: 3px; }
}

@media print {
  header.site nav, footer.site, .menu, .vote, .actions, .skip { display: none !important; }
  body { background: #fff; }
  .card { border: none; padding: 0; }
}

/* Utilitários de espaçamento (sem estilos inline, por causa da CSP). */
.mt-1 { margin-top: 1rem; }
.mt-2 { margin-top: 2rem; }
.mb-1 { margin-bottom: 1rem; }
.gap-0 { --gap: 0; }
.mt-075 { margin-top: 0.75rem; }
.item h2.h3 { font-size: 1.2rem; }
.revocation h3.h4 { font-size: 1.05rem; }
.body p + p, .prose p + p { margin-top: 0.85em; }
.vote + p, .vote + details { margin-top: 0.75rem; }
