/* Coincido: Chilean blue and red, toned down, on warm paper white. */
:root {
  --paper: #faf8f4;
  --card: #ffffff;
  --ink: #1c1b19;
  --ink-2: #57534c;
  --ink-3: #6b665e;
  --line: #e5e0d7;
  --azul: #24427a;
  --azul-soft: #e8edf6;
  --rojo: #c8412f;
  --rojo-soft: #f8e6e1;

  --serif: "Source Serif 4", Georgia, serif;
  --sans: "Source Sans 3", system-ui, sans-serif;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 18px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}

main { max-width: 640px; margin: 0 auto; padding: 0 20px 64px; }

a { color: var(--azul); text-underline-offset: 3px; }

h1, h2 { font-family: var(--serif); font-weight: 600; line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: 2.1rem; margin: 0.2em 0 0.5em; }
h2 { font-size: 1.35rem; margin: 1.6em 0 0.4em; }

/* Header and footer */
.top {
  max-width: 640px; margin: 0 auto; padding: 20px;
  display: flex; justify-content: space-between; align-items: center;
}
.logo {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--serif); font-size: 1.25rem; font-weight: 600;
  color: var(--ink); text-decoration: none;
}
/* A small Chilean flag: blue canton only in the top-left corner, red across the bottom. */
.flag { width: 33px; height: 22px; }
.flag .blue { fill: var(--azul); }
.flag .red { fill: var(--rojo); }
.flag .white { fill: #fff; }
.flag .edge { fill: none; stroke: var(--line); stroke-width: 1; }
.top-link { font-size: 0.95rem; color: var(--ink-2); }

.bottom {
  max-width: 640px; margin: 0 auto; padding: 0 20px 40px;
  font-size: 0.9rem; color: var(--ink-3);
}
.bottom p { margin: 0.3em 0; }
.bottom a { color: var(--ink-2); }
.flag-line { display: flex; height: 4px; margin-bottom: 20px; border-radius: 2px; overflow: hidden; }
.flag-line span:first-child { flex: 1; background: var(--azul); }
.flag-line span:last-child { flex: 2; background: var(--rojo); }

/* Shared pieces */
.kicker {
  font-size: 0.85rem; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 0.06em; padding: 0;
}
.lead { font-size: 1.12rem; color: var(--ink-2); }
.fine { font-size: 0.9rem; color: var(--ink-3); }
.underline {
  /* Over the lower half of the letters, like a highlighter stroke, not under them. */
  background: linear-gradient(transparent 48%, var(--rojo-soft) 48%, var(--rojo-soft) 90%, transparent 90%);
  padding: 0 2px;
}

.button {
  display: inline-block; padding: 12px 26px;
  font: inherit; font-weight: 700; text-decoration: none; cursor: pointer;
  border: 2px solid var(--ink); border-radius: 999px;
  background: transparent; color: var(--ink);
}
.button.primary { background: var(--azul); border-color: var(--azul); color: #fff; }
.button:hover { filter: brightness(1.08); }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--ink-2); cursor: pointer; }
.link:hover { color: var(--ink); text-decoration: underline; }

.hero { padding: 32px 0 8px; }
.block { padding-top: 8px; }

details { border-top: 1px solid var(--line); padding: 12px 0; }
details > summary { cursor: pointer; font-weight: 700; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "+"; display: inline-block; width: 1.2em; color: var(--rojo); }
details[open] > summary::before { content: "–"; }
details p, details ul { color: var(--ink-2); margin: 0.6em 0 0.2em; }
details ul { padding-left: 1.2em; }

/* Landing */
.notes { margin-top: 40px; display: grid; gap: 4px; }
.note { border-top: 1px solid var(--line); padding: 16px 0 4px; }
.note h2 { font-size: 1.1rem; margin: 0 0 0.2em; }
.note p { margin: 0; color: var(--ink-2); }

/* Test */
.test { padding-top: 16px; }
.progress { display: none; align-items: center; gap: 14px; margin-bottom: 16px; color: var(--ink-3); font-size: 0.9rem; }
.one-at-a-time .progress { display: flex; }
.progress-bar { flex: 1; height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
.progress-bar span { display: block; height: 100%; width: 0; background: var(--rojo); transition: width 0.3s; }

.card {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); padding: 24px 22px; margin: 0 0 24px;
}
.card h1 { font-size: 1.7rem; }
/* The vote date and the headline read as one unit: a law is always "this, back then". */
.card-head { border-left: 3px solid var(--azul); padding-left: 14px; margin: 8px 0 16px; }
.card-head h1 { margin: 0; }
.vote-date { margin: 0 0 4px; color: var(--azul); font-size: 0.95rem; }
.vote-year { font-family: var(--serif); font-size: 1.2rem; font-weight: 700; }
.old-note { margin: 6px 0 0; color: var(--ink-3); font-size: 0.88rem; font-style: italic; }
.summary { font-size: 1.05rem; }
.summary p, .lead p { margin: 0 0 0.5em; }
.summary ul, .lead ul { margin: 0.3em 0 0.6em; padding-left: 1.2em; }
.summary li, .lead li, details li { margin-bottom: 0.3em; }
.sides { display: grid; }

.question { font-family: var(--serif); font-size: 1.25rem; font-weight: 600; margin: 24px 0 12px; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.choice, .skip { position: relative; }
.choice input, .skip input { position: absolute; inset: 0; opacity: 0; margin: 0; pointer-events: none; }
.choice span {
  display: block; text-align: center; padding: 14px 10px; cursor: pointer;
  border: 2px solid var(--line); border-radius: var(--radius); font-weight: 700;
  transition: border-color 0.15s, background 0.15s;
}
.choice span:hover { border-color: var(--ink-3); }
.choice input:checked + span { border-color: var(--azul); background: var(--azul-soft); color: var(--azul); }
.choice input:focus-visible + span, .skip input:focus-visible + span { outline: 3px solid var(--rojo-soft); outline-offset: 2px; }
.skip { display: block; margin-top: 12px; }
.skip span {
  display: block; text-align: center; padding: 12px 10px; cursor: pointer;
  border: 2px dashed var(--line); border-radius: var(--radius); color: var(--ink-2); font-weight: 600;
  transition: border-color 0.15s, background 0.15s;
}
.skip span:hover { border-color: var(--ink-3); }
.skip input:checked + span { border-style: solid; border-color: var(--ink-3); background: var(--paper); color: var(--ink); }
.skip-note { text-align: center; color: var(--ink-3); font-size: 0.85rem; margin: 6px 0 0; }

.nav { display: flex; justify-content: space-between; align-items: center; margin-top: 24px; min-height: 1px; }
.nav .button { margin-left: auto; }

/* Results */
.bars { list-style: none; padding: 0; margin: 16px 0; }
.bars li {
  display: grid; grid-template-columns: 1fr 3.2em; grid-template-areas: "label value" "track track";
  gap: 4px 12px; margin-bottom: 14px;
}
.bar-label { grid-area: label; font-weight: 700; }
.bar-label small { font-weight: 400; color: var(--ink-3); font-size: 0.8rem; margin-left: 8px; }
.bar-value { grid-area: value; text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.bar-track { grid-area: track; height: 10px; background: var(--line); border-radius: 5px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--azul); border-radius: 5px; }

.people { list-style: none; padding: 0; margin: 8px 0 16px; }
.people li {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.people small { display: block; color: var(--ink-3); font-size: 0.85rem; }
.people .pct { font-variant-numeric: tabular-nums; font-weight: 700; }

.law > summary { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.law > summary::before { flex: none; }
.law-head { flex: 1; }
.law-title { font-style: italic; }
.positions { list-style: none; padding: 0 !important; }
.positions li { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--line); }

/* Tags are neutral on purpose: color never encodes for or against. */
.tag {
  flex: none; font-size: 0.8rem; font-weight: 700; white-space: nowrap;
  padding: 2px 10px; border-radius: 999px; border: 1.5px solid var(--ink);
}
.tag-yes { background: var(--ink); color: var(--paper); }
.tag-no { background: transparent; color: var(--ink); }
.tag-split { border-style: dashed; color: var(--ink-2); border-color: var(--ink-3); }
.tag-skip { border-color: var(--line); color: var(--ink-3); }

.prose p, .prose li { color: var(--ink-2); }
.prose li { margin-bottom: 0.4em; }

@media (max-width: 480px) {
  body { font-size: 17px; }
  h1 { font-size: 1.75rem; }
  .card { padding: 20px 16px; }
  .card h1 { font-size: 1.45rem; }
}

/* A fieldset legend sits on the border by default; pull it inside the card. */
.card legend { float: left; width: 100%; margin: 0 0 4px; }
.card legend + * { clear: both; }

/* Where each argument comes from. Unsourced drafts are flagged until reviewed. */
details li { margin-bottom: 0.6em; }
.src { display: block; font-size: 0.8rem; color: var(--ink-3); margin-top: 2px; }
.src.todo { color: var(--rojo); }

/* ---------- Navigation ---------- */
.top-nav { display: flex; gap: 18px; }
.crumbs { margin: 8px 0 0; font-size: 0.95rem; }
.crumbs a { color: var(--ink-2); }

/* ---------- Test setup ---------- */
.start { display: grid; gap: 14px; justify-items: start; margin-top: 8px; }
.segmented { border: 0; padding: 0; margin: 0; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.segmented legend { float: left; margin-right: 10px; color: var(--ink-2); padding: 0; }
.segmented label { position: relative; }
.segmented input, .chip input { position: absolute; inset: 0; opacity: 0; margin: 0; }
.segmented span {
  display: inline-block; min-width: 48px; text-align: center; padding: 6px 14px; cursor: pointer;
  border: 2px solid var(--line); border-radius: 999px; font-weight: 700;
}
.segmented input:checked + span { border-color: var(--azul); background: var(--azul-soft); color: var(--azul); }
.year-range { border: 0; padding: 0; margin: 0; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.year-range legend { float: left; margin-right: 10px; color: var(--ink-2); padding: 0; }
.year-range label { color: var(--ink-2); }
.year-range select { font: inherit; font-weight: 700; padding: 4px 8px; border: 2px solid var(--line); border-radius: 8px; background: var(--paper, transparent); color: inherit; }
.year-count, .segmented .hint { color: var(--ink-2); }
.segmented .hint { flex-basis: 100%; }
.topic-picker { border-top: 0; padding: 0; width: 100%; }
.topic-picker > summary { font-weight: 400; color: var(--ink-2); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip { position: relative; }
.chip span {
  display: inline-block; padding: 4px 12px; border: 1.5px solid var(--line); border-radius: 999px;
  font-size: 0.92rem; cursor: pointer; background: var(--card);
}
.chip input:checked + span { border-color: var(--azul); background: var(--azul-soft); color: var(--azul); }
.segmented input:focus-visible + span, .chip input:focus-visible + span { outline: 3px solid var(--rojo-soft); outline-offset: 2px; }

/* ---------- Law list ---------- */
.filters {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
}
.field { display: grid; gap: 4px; font-size: 0.9rem; color: var(--ink-2); }
.field input, .field select {
  font: inherit; font-size: 1rem; color: var(--ink); padding: 8px 10px;
  border: 1.5px solid var(--line); border-radius: 8px; background: var(--paper); width: 100%;
}
.wide { grid-column: 1 / -1; }
.check { display: flex; gap: 8px; align-items: center; font-size: 0.95rem; }
.filter-actions { display: flex; gap: 16px; align-items: center; }
.count { color: var(--ink-3); font-size: 0.9rem; margin: 18px 0 6px; }

.bill-list, .vote-list { list-style: none; padding: 0; margin: 0; }
.bill-list li, .vote-list li { border-bottom: 1px solid var(--line); }
.bill, .vote-list a { display: grid; gap: 6px; padding: 14px 0; color: inherit; text-decoration: none; }
.bill:hover .bill-title, .vote-list a:hover .vl-article { text-decoration: underline; text-underline-offset: 3px; }
.bill .kicker, .vote-list .kicker { font-size: 0.75rem; }
.bill-title {
  font-weight: 700; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.tally { display: flex; height: 6px; border-radius: 3px; overflow: hidden; background: var(--line); }
.tally-text { display: flex; justify-content: space-between; gap: 10px; font-size: 0.85rem; color: var(--ink-3); }
.empty { padding: 24px 0; color: var(--ink-3); }

/* Vote choices. Neutral on purpose: no color means "for" or "against". */
/* Filled = for, ring = against: symmetric and readable without color. */
.t-yes { background: var(--ink); }
.t-no { background: var(--paper); box-shadow: inset 0 0 0 1.5px var(--ink); }
.t-abstain { background: #b9b3a8; }
.dot-yes { background: var(--ink); }
.dot-no { background: transparent; box-shadow: inset 0 0 0 2.5px var(--ink); }
.dot-abstain { background: #b9b3a8; }
.dot-absent, .dot-paired { background: transparent; box-shadow: inset 0 0 0 1.5px #c9c3b8; }

.result { font-weight: 700; color: var(--ink-2); white-space: nowrap; }

/* ---------- Law page ---------- */
.law-h1 { font-size: 1.6rem; }
.hero h3 { font-size: 1rem; margin: 1em 0 0.2em; }
.vote-box { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-top: 16px; }
.vote-box .kicker { margin: 0; }
.article { color: var(--ink-2); margin: 6px 0; }
.big-tally { margin: 6px 0 0; display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; }
.badge { background: var(--rojo-soft); color: #9e2f1f; padding: 1px 8px; border-radius: 999px; text-transform: none; letter-spacing: 0; }

.legend { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.85rem; color: var(--ink-2); }
.legend li { display: flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 14px; height: 14px; border-radius: 3px; }

.party-bars { list-style: none; padding: 0; margin: 8px 0; }
.party-bars li { display: grid; grid-template-columns: 9.5em 1fr; gap: 12px; align-items: center; padding: 6px 0; }
.pb-name { font-weight: 700; font-size: 0.92rem; line-height: 1.25; }
.pb-name small { display: block; font-weight: 400; color: var(--ink-3); font-size: 0.78rem; }
.pb-bar { display: flex; height: 26px; border-radius: 6px; overflow: hidden; gap: 2px; }
.seg {
  display: flex; align-items: center; justify-content: center; min-width: 18px;
  font-size: 0.78rem; font-weight: 700; font-variant-numeric: tabular-nums;
}
.seg-yes { color: var(--paper); }
.seg-no { color: var(--ink); }
.seg-abstain, .seg-absent, .seg-paired { color: var(--ink-2); }

.dots { list-style: none; padding: 0; display: grid; gap: 14px; margin: 14px 0; }
.dot-group { display: grid; grid-template-columns: 11em 1fr; gap: 14px; align-items: start; }
.dot-party { font-size: 0.92rem; line-height: 1.25; }
.dot-party small { display: block; color: var(--ink-3); font-size: 0.8rem; margin-top: 2px; }
.dot-row { display: flex; flex-wrap: wrap; gap: 5px; padding-top: 2px; }
.dot { width: 16px; height: 16px; border-radius: 50%; display: inline-block; flex: none; }
.dot:hover, .dot:focus-visible { outline: 2px solid var(--azul); outline-offset: 1px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.names { list-style: none; padding: 0 !important; margin: 4px 0 12px; }
.names li { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.names a { color: var(--ink); }
.votes-of a { text-decoration: none; }
.votes-of .kicker { display: block; font-size: 0.72rem; margin-bottom: 2px; }

.vote-list li.current { background: var(--azul-soft); margin: 0 -10px; padding: 0 10px; border-radius: 6px; }
.vl-article { font-size: 0.95rem; }
.vl-tally { font-size: 0.85rem; color: var(--ink-3); }

/* ---------- Deputy page ---------- */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat b { display: block; font-family: var(--serif); font-size: 1.8rem; line-height: 1.1; }
.stat span { font-size: 0.9rem; color: var(--ink-2); }
.people a { color: inherit; text-decoration: none; }
.people a:hover b { text-decoration: underline; }

/* Tags for abstention/absence, alongside the yes/no ones defined above. */
.tag-abstain { border-style: dotted; color: var(--ink-2); }
.tag-absent, .tag-paired { border-color: var(--line); color: var(--ink-3); }

@media (max-width: 480px) {
  .filters { grid-template-columns: 1fr; }
  .party-bars li, .dot-group { grid-template-columns: 1fr; gap: 4px; }
  .stats { grid-template-columns: 1fr; }
}

/* ---------- Party matrix ---------- */
.dot-split { background: linear-gradient(90deg, var(--ink) 50%, transparent 50%); box-shadow: inset 0 0 0 2px var(--ink); }
.matrix { --cell: 26px; margin: 12px 0 24px; }
.mx-head, .mx-row {
  display: grid; grid-template-columns: 1fr repeat(var(--cols), var(--cell)); gap: 0 4px; align-items: center;
}
.mx-head { position: sticky; top: 0; background: var(--paper); padding: 8px 0; border-bottom: 1.5px solid var(--ink); z-index: 1; }
.mx-party {
  font-size: 0.72rem; font-weight: 700; writing-mode: vertical-rl; transform: rotate(180deg);
  justify-self: center; white-space: nowrap; color: var(--ink-2);
}
.mx-row { padding: 9px 0; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; }
.mx-row:hover { background: var(--azul-soft); }
.mx-law { display: grid; gap: 2px; padding-right: 10px; min-width: 0; }
.mx-law .kicker { font-size: 0.7rem; margin: 0; }
.mx-title { font-size: 0.9rem; line-height: 1.3; }
.mx-cell { display: flex; justify-content: center; }
.mx-cell .dot { width: 15px; height: 15px; }
.mx-foot { position: static; border-bottom: 0; border-top: 1.5px solid var(--ink); }
.mx-unity { font-size: 0.68rem; color: var(--ink-3); text-align: center; writing-mode: vertical-rl; transform: rotate(180deg); justify-self: center; }

@media (max-width: 560px) {
  .matrix { --cell: 18px; }
  .mx-head, .mx-row { gap: 0 2px; }
  .mx-cell .dot { width: 12px; height: 12px; }
  .mx-title { font-size: 0.82rem; }
}

/* Results matrix: the user's own column stands out. */
.mx-you { background: var(--azul-soft); border-radius: 6px; align-self: stretch; display: flex; align-items: center; justify-content: center; }
.mx-head .mx-you { color: var(--azul); writing-mode: horizontal-tb; transform: none; padding: 4px 0; }
.mx-skip { color: var(--ink-3); }
.sides.flip details:first-child { order: 2; }

.tie-note { background: var(--rojo-soft); border-radius: var(--radius); padding: 10px 14px; font-size: 0.95rem; }
.chip small { color: var(--ink-3); font-size: 0.8rem; margin-left: 2px; }

[hidden] { display: none !important; }

/* Explanation levels: every card holds the three; only the chosen one shows. */
.test[data-nivel="simple"] .lvl:not([data-level="simple"]),
.test[data-nivel="medio"] .lvl:not([data-level="medio"]),
.test[data-nivel="avanzado"] .lvl:not([data-level="avanzado"]) { display: none; }
.level-switch { margin: 0 0 14px; }
.level-switch span { font-size: 0.9rem; padding: 4px 12px; }
.further { font-size: 0.9rem; }
.further small { color: var(--ink-3); }
.level-tabs { display: flex; gap: 14px; font-size: 0.9rem; margin: 0 0 8px; }
.level-tabs a { color: var(--ink-3); }
.level-tabs a[aria-current] { color: var(--azul); font-weight: 700; text-decoration: none; }
