/* ============================================================
   FIGURES (template-parts/figure.php): charts drawn from a few numbers,
   from fate-scot-concept-11.html, "The facts, beautifully". Loch blue for
   the data, olive for the second series, a pale track for the rest. Every
   value is also in the text, so the drawing is decoration; with JS the bars
   and dots draw themselves in when the figure is revealed (.rv → .in).
   ============================================================ */
.fig {
	--data: var(--loch);
	--data-2: var(--olive);
	--data-rest: rgb(19 38 26 / 0.16);
	--data-track: rgb(19 38 26 / 0.09);
	--fig-ink: var(--ink);
	--fig-muted: var(--slate);
	--fig-rule: var(--rule-mid);
	--fig-small: 0.95rem;
	max-width: 1100px;
	margin: 0;
	font-size: 1.05rem;
	line-height: 1.5;
	color: var(--fig-ink);
}
.fig + .fig { margin-top: clamp(56px, 7vw, 96px); }
.ch-figs { max-width: 1100px; margin-top: clamp(36px, 4vw, 56px); }
.ch-art:empty + .ch-figs, .ch-body > .ch-figs:first-child { margin-top: 0; }
.blk-figure .fig { margin-top: clamp(28px, 3vw, 40px); }
.blk-figure .blk-intro { max-width: 58ch; }

.fig-t { max-width: 40ch; margin: 0; font-size: 1.15rem; font-weight: 700; line-height: 1.35; color: var(--fig-ink); text-wrap: balance; }
.fig-s { max-width: 58ch; margin: 4px 0 0; font-size: var(--fig-small); line-height: 1.45; color: var(--fig-muted); text-wrap: pretty; }
.fig .num { font-family: var(--display); font-weight: var(--w-head); font-variant-numeric: lining-nums tabular-nums; letter-spacing: -0.03em; }
.fig figcaption { max-width: 68ch; margin-top: 24px; padding-top: 12px; border-top: 1px solid var(--fig-rule); font-size: var(--fig-small); line-height: 1.5; color: var(--fig-muted); text-wrap: pretty; }
.fig figcaption b { color: var(--fig-ink); }
.fig figcaption a { font-weight: 700; color: var(--data); text-decoration-thickness: 1px; text-underline-offset: 0.22em; }

/* The data, as a table */
.fig-data { margin-top: 6px; font-size: var(--fig-small); }
.fig-data summary { display: inline-flex; align-items: center; gap: 0.5em; min-height: 44px; cursor: pointer; font-weight: 700; color: var(--data); text-decoration: underline; text-underline-offset: 0.22em; }
.fig-data summary::marker { color: var(--data); }
.fig-data table { min-width: min(100%, 26rem); max-width: 100%; margin: 6px 0 10px; border-collapse: collapse; }
.fig-data caption { padding: 0 0 8px; font-weight: 700; text-align: left; color: var(--fig-ink); }
.fig-data th, .fig-data td { padding: 8px 12px 8px 0; border-bottom: 1px solid var(--rule); font-weight: 400; line-height: 1.4; text-align: left; vertical-align: top; }
.fig-data thead th { border-bottom: 1px solid var(--fig-ink); font-weight: 700; }
.fig-data td.n, .fig-data th.n { padding-right: 0; padding-left: 8px; font-variant-numeric: tabular-nums; text-align: right; }
.fig-data td.n { white-space: nowrap; }

/* The legend (votes) */
.legend { display: flex; flex-wrap: wrap; gap: 6px 22px; margin: 16px 0 0; padding: 0; list-style: none; font-size: var(--fig-small); }
.legend li { display: inline-flex; align-items: center; gap: 8px; }
.fig .k { display: inline-block; flex: none; width: 12px; height: 12px; border-radius: 2px; background: var(--data); }
.fig .k.ag { background: var(--data-2); }
.fig .k.rest { background: var(--data-rest); }

/* ---------- Ranked bars ---------- */
.hbar { display: grid; gap: 16px; max-width: 68rem; margin: 26px 0 0; padding: 0; list-style: none; }
.hbar li { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.hl { font-size: var(--fig-small); line-height: 1.35; text-wrap: pretty; }
.ht { display: flex; align-items: center; gap: 10px; min-height: 26px; border-left: 1px solid var(--fig-ink); }
.hb { flex: none; width: calc((100% - 4rem) * var(--v) / 100); height: 18px; border-radius: 0 4px 4px 0; background: var(--data); transform-origin: left center; transition: transform 1.1s var(--ease); transition-delay: calc(var(--i) * 70ms); }
.hv { font-size: var(--fig-small); font-weight: 700; font-variant-numeric: tabular-nums; transition: opacity 0.6s; transition-delay: calc(var(--i) * 70ms + 0.5s); }
.js .fig.rv:not(.in) .hb { transform: scaleX(0); }
.js .fig.rv:not(.in) .hv { opacity: 0; }
.ann { position: relative; max-width: 22rem; margin: -6px 0 0 min(calc((100% - 4rem) * var(--v) / 100), 45%); padding: 16px 0 0 12px; border-left: 1px solid var(--fig-ink); font-size: var(--fig-small); line-height: 1.45; text-wrap: pretty; }
.ann::before { content: ""; position: absolute; top: 0; left: -4px; width: 7px; height: 7px; border-radius: 50%; background: var(--fig-ink); }
@media (min-width: 760px) {
	.hbar li { grid-template-columns: 15rem minmax(0, 1fr); column-gap: 24px; align-items: center; }
	.hl { text-align: right; }
	.ann { grid-column: 2; }
}

/* ---------- Blocks out of 100 ---------- */
.units { --w: calc(var(--per) * 1%); display: grid; gap: 22px; max-width: 68rem; margin: 28px 0 0; padding: 0; list-style: none; }
.units li { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 14px; align-items: baseline; }
.u-n { font-family: var(--display); font-size: clamp(2rem, 3.4vw, 3.2rem); font-weight: var(--w-head); line-height: 0.9; letter-spacing: -0.03em; font-variant-numeric: lining-nums tabular-nums; color: var(--fig-ink); }
.u-l { font-size: var(--fig-small); line-height: 1.35; text-wrap: pretty; }
.u-bar { grid-column: 1 / -1; position: relative; height: 22px; margin-top: 4px; background: repeating-linear-gradient(90deg, var(--data-track) 0 calc(var(--w) - 3px), transparent calc(var(--w) - 3px) var(--w)); }
.u-bar::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, var(--data) 0 calc(var(--w) - 3px), transparent calc(var(--w) - 3px) var(--w)); clip-path: inset(0 calc(100% - var(--v) * 1%) 0 0); transition: clip-path 1.2s var(--ease); transition-delay: calc(var(--i) * 120ms); }
.js .fig.rv:not(.in) .u-bar::after { clip-path: inset(0 100% 0 0); }
@media (min-width: 760px) {
	.units li { grid-template-columns: 7.5rem minmax(0, 1fr); column-gap: 24px; align-items: center; }
	.u-n { grid-row: 1 / 3; text-align: right; }
	.u-bar { grid-column: 2; }
}

/* ---------- The big line (ten circles, one big number) ---------- */
.fig-big { display: grid; gap: 0.25em 0; max-width: 28ch; margin: 0 0 clamp(24px, 3vw, 36px); font-weight: var(--w-head); line-height: 1.06; letter-spacing: var(--ls-big); color: var(--fig-ink); }
.fig-t + .fig-big, .fig-s + .fig-big { margin-top: clamp(20px, 2.5vw, 32px); }
.fig-big .say { font-size: clamp(1.5rem, 2.6vw, 2.4rem); text-wrap: balance; }
.fig-ten { display: flex; flex-wrap: nowrap; gap: clamp(8px, 1.2vw, 18px); align-items: baseline; line-height: 0.8; }
.fig-ten .num { font-size: clamp(3.4rem, 7vw, 6.5rem); }
.fig-ten .in { align-self: center; font-size: clamp(1.2rem, 1.8vw, 1.6rem); font-weight: 600; letter-spacing: 0; color: var(--fig-muted); }
.fig-count .big { font-size: clamp(4rem, 8vw, 7.5rem); line-height: 0.85; }
@media (min-width: 900px) {
	.fig-big { grid-template-columns: auto minmax(0, 1fr); column-gap: clamp(24px, 3vw, 56px); align-items: end; max-width: none; }
	.fig-big .say { max-width: 18ch; padding-bottom: 0.12em; }
}

/* ---------- Ten circles ---------- */
.tens, .brk { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: clamp(5px, 1vw, 12px); max-width: 34rem; }
.tens .d { aspect-ratio: 1; border: 2px solid var(--data); border-radius: 50%; background: transparent; }
.tens .d.on { background: var(--data); }
.js .fig.rv.in .tens .d.on { animation: fig-dot-in 0.7s var(--ease) both; animation-delay: calc(var(--i) * 90ms + 250ms); }
@keyframes fig-dot-in { from { background: transparent; } }
.brk { margin-top: 12px; font-size: var(--fig-small); line-height: 1.3; }
.brk span { position: relative; padding-top: 12px; border-top: 1px solid var(--fig-ink); }
.brk span::before, .brk span::after { content: ""; position: absolute; top: -7px; width: 1px; height: 7px; background: var(--fig-ink); }
.brk span::before { left: 0; }
.brk span::after { right: 0; }
.brk .b1 { grid-column: 1 / calc(var(--on) + 1); }
.brk .b2 { grid-column: calc(var(--on) + 1) / 11; }

/* ---------- One big number, a circle for each ---------- */
.rings { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: clamp(4px, 0.8vw, 8px); max-width: 30rem; }
.rings span { aspect-ratio: 1; border: 2px solid var(--leaf); border-radius: 50%; transition: transform 0.5s var(--ease), opacity 0.5s; transition-delay: calc(var(--i) * 40ms); }
.js .fig.rv:not(.in) .rings span { opacity: 0; transform: scale(0.4); }

/* ---------- Votes on one scale ---------- */
.vscale { display: grid; grid-template-columns: minmax(0, 1fr); margin-top: 22px; }
.vscale-in { position: relative; height: 2.4rem; font-size: 0.8rem; color: var(--fig-muted); font-variant-numeric: tabular-nums; }
.vscale-in span { position: absolute; bottom: 6px; line-height: 1.2; white-space: nowrap; }
.vscale-in .s0 { left: 0; }
.vscale-in .s1 { left: 50%; transform: translateX(-50%); text-align: center; }
.vscale-in .s2 { right: 0; }
.votes { margin: 0; padding: 0; list-style: none; }
.vrow { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; padding: 20px 0 22px; border-top: 1px solid var(--fig-rule); }
.vyear { margin: 0; font-size: clamp(2rem, 3.4vw, 3.2rem); line-height: 0.9; color: var(--fig-ink); }
.vbill { margin: 0 0 10px; font-weight: 700; line-height: 1.35; text-wrap: balance; }
.vrow--plain .vbill { margin-bottom: 0; }
.vbar { position: relative; display: flex; gap: 2px; height: 24px; clip-path: inset(-10px 0 -10px 0); transition: clip-path 1.3s var(--ease); transition-delay: calc(var(--i) * 180ms); }
.js .fig.rv:not(.in) .vbar { clip-path: inset(-10px 100% -10px 0); }
.vbar::after { content: ""; position: absolute; top: -7px; bottom: -7px; left: 50%; width: 1px; background: var(--fig-ink); }
.seg { flex: var(--n) 1 0%; min-width: 0; background: var(--data); }
.seg.ag { background: var(--data-2); }
.seg.rest { border-radius: 0 4px 4px 0; background: var(--data-rest); }
.vkey { display: flex; flex-wrap: wrap; gap: 4px 22px; margin: 12px 0 0; font-size: var(--fig-small); line-height: 1.3; }
.vkey span { display: inline-flex; align-items: baseline; gap: 7px; }
.vkey .k { align-self: center; }
.vkey b { font-family: var(--display); font-size: 1.35rem; font-weight: var(--w-head); font-variant-numeric: lining-nums tabular-nums; }
.vres { margin: 8px 0 0; font-size: var(--fig-small); line-height: 1.45; color: var(--fig-muted); text-wrap: pretty; }
.vres strong { display: block; color: var(--fig-ink); }
@media (min-width: 900px) {
	.vscale { grid-template-columns: 7rem minmax(0, 1fr) 14rem; column-gap: 28px; }
	.vscale-in { grid-column: 2; }
	.vrow { grid-template-columns: 7rem minmax(0, 1fr) 14rem; column-gap: 28px; align-items: start; }
	.vres { align-self: stretch; margin: 0; padding: 2px 0 0 14px; border-left: 1px solid var(--fig-ink); }
}

/* ---------- Years on a line ---------- */
.wl { margin: 28px 0 0; padding: 0; list-style: none; border-left: 1px solid var(--fig-ink); }
.wl li { position: relative; display: grid; grid-template-columns: 1.9rem minmax(0, 1fr); gap: 10px; align-items: center; padding: 10px 0 10px 16px; }
.wl li::before { content: ""; position: absolute; top: 50%; left: 0; width: 10px; height: 1px; background: var(--fig-ink); }
.wlab { display: flex; flex-wrap: wrap; gap: 0 12px; align-items: baseline; min-width: 0; }
.wy { font-size: 1.35rem; font-weight: var(--w-head); }
.wd { display: flex; gap: 4px; }
.wd i { width: 12px; height: 12px; border-radius: 50%; background: var(--data); box-shadow: 0 0 0 2px var(--card); transition: transform 0.5s var(--ease), opacity 0.5s; }
.ch--paper .wd i, .blk--paper .wd i { box-shadow: 0 0 0 2px var(--paper); }
.js .fig.rv:not(.in) .wd i { opacity: 0; transform: scale(0.3); }
.wp { font-size: var(--fig-small); line-height: 1.35; }
.wt { display: none; }
@media (min-width: 1100px) {
	.wl { --tier: 4.6rem; position: relative; height: calc(3 * var(--tier) + 4.5rem); margin-top: 40px; border-left: 0; border-bottom: 1px solid var(--fig-ink); }
	.wl li { position: absolute; bottom: 0; left: calc((var(--y) - var(--y0)) * 100% / var(--span)); display: block; width: 0; height: 0; padding: 0; }
	.wl li::before { top: auto; bottom: 0; left: 0; width: 1px; height: calc(var(--t) * var(--tier)); background: var(--fig-ink); }
	.wd { position: absolute; bottom: -6px; left: -6px; flex-direction: column-reverse; gap: 3px; }
	.wlab { display: block; position: absolute; bottom: calc(var(--t) * var(--tier)); left: 0; padding: 0 0 4px 10px; white-space: nowrap; }
	.wl li.r .wlab { right: 0; left: auto; padding: 0 10px 4px 0; text-align: right; }
	.wy, .wp { display: block; }
	.wt { display: block; position: relative; height: 2.4rem; margin: 0; padding: 0; list-style: none; font-size: 0.8rem; color: var(--fig-muted); font-variant-numeric: tabular-nums; }
	.wt li { position: absolute; top: 0; left: calc((var(--y) - var(--y0)) * 100% / var(--span)); padding-top: 10px; transform: translateX(-50%); }
	.wt li::before { content: ""; position: absolute; top: 0; left: 50%; width: 1px; height: 6px; background: var(--fig-ink); }
}

/* On night green (a figure after a Questions chapter's words, or inside a
   dark section): cream type, lime data */
.ch--night .fig { --data: var(--lime); --data-2: rgb(var(--cream-rgb) / 0.55); --data-rest: rgb(255 255 255 / 0.16); --data-track: rgb(255 255 255 / 0.1); --fig-ink: var(--cream); --fig-muted: rgb(var(--cream-rgb) / 0.75); --fig-rule: var(--on-dark-rule); }
.ch--night .fig figcaption a, .ch--night .fig-data summary { color: var(--cream); }
.ch--night .rings span { border-color: var(--lime); }
.ch--night .wd i { box-shadow: 0 0 0 2px var(--night); }

@media (prefers-reduced-motion: reduce) {
	.hb, .hv, .u-bar::after, .vbar, .rings span, .wd i { transition: none; }
	.js .fig.rv.in .tens .d.on { animation: none; }
}
