/* A newspaper's data page: serif headlines, plain tables, colour only where it is data. */
:root {
  --paper: #f6f3ec;
  --ink: #1c1a17;
  --muted: #6a645b;
  --rule: #d8d1c4;
  --rule-strong: #1c1a17;
  --accent: #a61e27;
  --mark: #1c1a17;
  --soft: #ece6da;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Charter, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #151412;
    --ink: #ece7dd;
    --muted: #a39c90;
    --rule: #37332d;
    --rule-strong: #ece7dd;
    --accent: #f0727a;
    --mark: #ece7dd;
    --soft: #23211d;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 17px/1.55 var(--sans);
  font-variant-numeric: tabular-nums;
}
.wrap { max-width: 44rem; margin: 0 auto; padding: 0 16px; }
a { color: inherit; text-decoration-color: var(--accent); text-underline-offset: 0.18em; }
a:hover { color: var(--accent); }
b { font-weight: 650; }
small { font-size: 0.8em; }

/* Masthead */
.masthead { border-bottom: 1px solid var(--rule-strong); margin-bottom: 1.75rem; }
.masthead .wrap { display: grid; grid-template-columns: 1fr; gap: 0.15rem; padding-top: 1.1rem; padding-bottom: 0.6rem; }
.brand { font: 700 1.6rem/1.1 var(--serif); text-decoration: none; letter-spacing: -0.01em; }
.dateline { margin: 0; color: var(--muted); font-size: 0.85rem; }
nav { display: flex; gap: 1.1rem; margin-top: 0.55rem; font-size: 0.92rem; }
nav a { text-decoration: none; padding: 0.2rem 0; border-bottom: 2px solid transparent; }
nav a[aria-current="page"] { border-bottom-color: var(--accent); font-weight: 600; }

/* Headlines */
h1, h2 { font-family: var(--serif); font-weight: 700; letter-spacing: -0.012em; }
h1 { font-size: clamp(1.9rem, 7vw, 2.7rem); line-height: 1.08; margin: 0.2rem 0 0.7rem; }
h2 { font-size: 1.3rem; line-height: 1.2; margin: 2.4rem 0 0.6rem; padding-top: 0.6rem; border-top: 1px solid var(--rule-strong); }
.kicker { margin: 0; color: var(--accent); font-size: 0.8rem; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; }
.standfirst { font: 1.12rem/1.5 var(--serif); margin: 0 0 1.2rem; }
.note { color: var(--muted); font-size: 0.86rem; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }

/* National seat bar */
.hemi { margin: 1.5rem 0 1rem; }
.hemi-bar { position: relative; display: flex; height: 2.2rem; gap: 1px; background: var(--paper); }
.hemi-bar span { display: block; min-width: 2px; }
.hemi-bar span:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; position: relative; z-index: 1; }
.hemi-bar span.on { filter: brightness(1.12); box-shadow: inset 0 0 0 2px var(--paper); }
.hemi-tip {
  position: absolute; bottom: calc(100% + 0.6rem); left: 0; z-index: 2;
  padding: 0.35rem 0.6rem; white-space: nowrap; pointer-events: none;
  background: var(--ink); color: var(--paper); font-size: 0.85rem; line-height: 1.3;
}
.hemi-tip b { font-weight: 650; }
.hemi-tip i { display: inline-block; width: 0.65em; height: 0.65em; margin-right: 0.4em; vertical-align: 0.02em; box-shadow: 0 0 0 1px var(--paper); }
.hemi-mark { pointer-events: none; position: absolute; top: -0.4rem; bottom: -0.4rem; width: 2px; background: var(--mark); }
.hemi-blocs { display: flex; justify-content: space-between; margin-top: 0.55rem; font-size: 0.9rem; }
.hemi-blocs b { font: 700 1.25rem/1 var(--serif); display: block; }
.hemi-blocs .bloc-otros { text-align: center; color: var(--muted); }
.hemi-blocs .bloc-der { text-align: right; }
.hemi figcaption { color: var(--muted); font-size: 0.8rem; margin-top: 0.3rem; }
.swing { border-left: 3px solid var(--accent); padding-left: 0.85rem; }

/* Province picker */
.picker { margin: 2rem 0 0.5rem; padding: 1rem 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.picker label { display: block; font-weight: 650; font-size: 0.9rem; margin-bottom: 0.4rem; }
.picker-row { display: flex; gap: 0.5rem; }
.picker select, .picker button {
  font: inherit; color: var(--ink); background: var(--paper);
  border: 1px solid var(--ink); border-radius: 2px; padding: 0.55rem 0.7rem; min-height: 2.75rem;
}
.picker select { flex: 1; min-width: 0; }
.picker button { background: var(--ink); color: var(--paper); cursor: pointer; }
.mine { margin: 0.5rem 0 0; }

/* Province header */
.crumb { margin: 0; font-size: 0.88rem; color: var(--muted); }
.facts { color: var(--muted); font-size: 0.9rem; margin: 0 0 1rem; }
.seats { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 0.5rem; }
.seat {
  display: inline-flex; align-items: flex-end; justify-content: flex-start;
  width: 3.1rem; height: 2.4rem; padding: 0.2rem 0.3rem;
  color: #fff; font-size: 0.66rem; font-weight: 650; line-height: 1;
  text-shadow: 0 0 2px rgba(0, 0, 0, 0.45); overflow: hidden;
}

/* The answer */
.verdict { margin-top: 1.5rem; }
.verdict h2 { margin-top: 1.5rem; }
.answer { font: 700 clamp(1.6rem, 6vw, 2.1rem)/1.15 var(--serif); margin: 0.4rem 0 0.6rem; }
.warn { font-size: 0.92rem; color: var(--muted); border-left: 3px solid var(--rule); padding-left: 0.85rem; }

/* Swatches */
.sw { display: inline-block; width: 0.7em; height: 0.7em; margin-right: 0.45em; vertical-align: 0.02em; }
.sw.lg { width: 0.62em; height: 0.62em; margin-right: 0.3em; }

/* Tables */
table.data { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.data th, .data td { padding: 0.55rem 0.4rem; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: top; }
.data thead th { font-size: 0.74rem; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 1px solid var(--rule-strong); vertical-align: bottom; line-height: 1.25; }
.data th:first-child, .data td:first-child { padding-left: 0; }
.data th:last-child, .data td:last-child { padding-right: 0; }
.data tbody th { font-weight: 600; }
.data .num { text-align: right; white-space: nowrap; }
.data small { display: block; color: var(--muted); font-weight: 400; white-space: nowrap; }
.data tbody th small { white-space: normal; }
.data tr.out { color: var(--muted); }
.useful thead th.num { white-space: normal; max-width: 7.5rem; }
.useful .short { display: none; }
.basis { margin-top: 1rem; }
/* The provinces table: sortable headers, and the provinces with nothing within reach in grey */
.data th[data-sort] button {
  font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit;
  background: none; border: 0; padding: 0; cursor: pointer;
  text-decoration: underline dotted; text-underline-offset: 0.25em;
}
.data th[data-sort] button::after { content: "\00a0↕"; opacity: 0.45; }
.data th[aria-sort="ascending"] button::after { content: "\00a0↑"; opacity: 1; }
.data th[aria-sort="descending"] button::after { content: "\00a0↓"; opacity: 1; }
.data th[aria-sort] { color: var(--ink); }
.contested tr.far th, .contested tr.far td { color: var(--muted); font-weight: 400; }
.contested tr.far a { text-decoration-color: var(--rule); }
.contested tr.far .sw { opacity: 0.45; }
.contested td.why { font-size: 0.86rem; font-style: italic; }
.polls tbody th { font-weight: 500; overflow-wrap: anywhere; }
.polls .weight { margin-top: 0.15rem; }
.polls td.num { padding-left: 0.3rem; }

.explain { margin-top: 0.8rem; font-size: 0.9rem; }
.explain summary { cursor: pointer; color: var(--muted); }
.explain dt { font-weight: 650; margin-top: 0.7rem; }
.explain dd { margin: 0.15rem 0 0; color: var(--muted); }

.prose h2 { font-size: 1.15rem; }

/* /simulaciones */
.steps { padding-left: 1.3rem; }
.steps li { margin: 0.5rem 0; }
.draws { margin: 0.5rem 0 1rem; }
.draw th, .draw td { padding-left: 0.3rem; padding-right: 0.3rem; }
.draw tr.total th, .draw tr.total td { border-top: 1px solid var(--rule-strong); border-bottom: 0; }
.hist { margin: 1rem 0 0.5rem; }
.hist-bars { display: flex; align-items: flex-end; gap: 1px; height: 9rem; border-bottom: 1px solid var(--rule-strong); }
.hist-bars span { flex: 1; min-height: 1px; background: var(--rule); }
.hist-bars span.maj { background: var(--ink); }
.hist-axis { display: flex; gap: 1px; height: 1.2rem; font-size: 0.72rem; color: var(--muted); }
.hist-axis span { flex: 1; position: relative; }
.hist-axis i { position: absolute; left: 50%; transform: translateX(-50%); font-style: normal; }
.hist figcaption { color: var(--muted); font-size: 0.8rem; margin-top: 0.4rem; }
/* The animation */
.sim-picker { margin: 0.5rem 0 1rem; padding: 0.6rem 0; border: 0; }
.anim { margin: 0.5rem 0 1.5rem; padding: 1rem 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.anim-head { display: flex; justify-content: space-between; align-items: center; gap: 0.8rem; margin-bottom: 0.8rem; }
.anim-count { margin: 0; font: 1.25rem/1.2 var(--serif); }
.anim-count b { display: inline-block; min-width: 2.6em; font-weight: 700; }
.anim-buttons { display: flex; gap: 0.4rem; }
.anim button, .hist-count button {
  font: inherit; font-size: 0.9rem; color: var(--paper); background: var(--ink);
  border: 1px solid var(--ink); border-radius: 2px; padding: 0.4rem 0.8rem; min-height: 2.4rem; cursor: pointer;
}
.ab-row { display: grid; grid-template-columns: 5.6rem 1fr 3.9rem; align-items: center; gap: 0.5rem; margin: 0.3rem 0; font-size: 0.92rem; }
.ab-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ab-track { position: relative; height: 1.1rem; background: var(--soft); }
.ab-bar { position: absolute; left: 0; top: 0; bottom: 0; width: 0; transition: width 0.9s cubic-bezier(.3,.7,.2,1); }
.ab-central { position: absolute; top: -0.2rem; bottom: -0.2rem; width: 2px; margin-left: -1px; background: var(--ink); }
.ab-pct { text-align: right; font-variant-numeric: tabular-nums; }
.ab-legend { margin: 0.4rem 0 0; font-size: 0.78rem; color: var(--muted); }
.ab-legend .ab-central { position: relative; display: inline-block; top: 0.15rem; height: 0.85rem; margin: 0 0.35rem 0 0.2rem; }
.anim-seats { display: flex; flex-wrap: wrap; gap: 4px; margin: 1rem 0 0.6rem; }
.anim-seats .seat { transition: background-color 0.6s; background: var(--soft); }
.anim.fast .ab-bar, .anim.fast .seat { transition: none; }
.anim-caption { min-height: 3.2em; margin: 0.4rem 0 0; font-family: var(--serif); font-size: 1.02rem; }
.anim h3 { font-size: 0.95rem; margin: 1.2rem 0 0.2rem; }
.anim-tally thead th.num { white-space: normal; max-width: 7rem; }
.hist-bars span { transition: height 0.12s linear; }
.hist-count { margin: 0.4rem 0 0; font-size: 0.85rem; display: flex; align-items: center; gap: 0.6rem; }
@media (prefers-reduced-motion: reduce) {
  .ab-bar, .anim-seats .seat, .hist-bars span { transition: none; }
}
.readings dt { font-weight: 650; margin-top: 0.9rem; }
.readings dd { margin: 0.2rem 0 0; }
.prose ul { padding-left: 1.2rem; }
.prose li { margin: 0.3rem 0; }

.colophon { margin-top: 3rem; padding-top: 0.8rem; padding-bottom: 2rem; border-top: 1px solid var(--rule-strong); color: var(--muted); font-size: 0.82rem; }
.colophon p { margin: 0.3rem 0; }

/* Narrow phones: drop the columns that only add detail */
@media (max-width: 30rem) {
  .data .wide { display: none; }
  .useful .long { display: none; }
  .useful .short { display: inline; }
  .useful thead th.num { max-width: 5rem; }
  .data th, .data td { padding-left: 0.25rem; padding-right: 0.25rem; }
  .seat { width: 2.45rem; height: 2rem; font-size: 0.6rem; }
}
@media (min-width: 40rem) {
  .masthead .wrap { grid-template-columns: 1fr auto; align-items: end; }
  nav { grid-column: 2; grid-row: 1 / span 2; margin: 0; }
}
