/* ==========================================================
   Sejm w liczbach: style
   Wszystkie rozmiary w rem, więc działają z powiększeniem
   przeglądarki i z przełącznikiem rozmiaru tekstu.
   ========================================================== */

/* ---------- Motywy (kontrast sprawdzony wg WCAG 2.2 AA) ---------- */
:root, [data-theme="light"] {
  color-scheme: light;
  --bg: #f4f5f7;
  --card: #ffffff;
  --card-2: #eef0f4;
  --ink: #12151c;
  --muted: #545b6a;           /* 6.6:1 na białym */
  --line: #d5d9e1;
  --line-strong: #8a92a3;     /* ramki pól formularzy: 3:1 */
  --accent: #3a4ca8;          /* kolor marki: zmień tutaj, by zmienić całą stronę */
  --accent-ink: #ffffff;
  --focus: #1d4ed8;
  /* etykiety głosów (biały tekst, min. 4.5:1) */
  --yes: #2a7247; --no: #b3261e; --abst: #8a5a00; --absent: #5b6271; --other: #4b5261;
  /* kolor liczb w tekście */
  --yes-t: #2a7247; --no-t: #b3261e; --abst-t: #8a5a00;
  --heat: 58, 76, 168; --heat-max: .62;  /* cieniowanie tabeli klubów; limit zapewnia kontrast tekstu */
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-pop: 0 12px 32px rgba(16, 24, 40, .18);
  --notice-bg: #fff4d1; --notice-line: #c9a227;
}
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1117;
  --card: #171b24;
  --card-2: #222837;
  --ink: #eceef3;
  --muted: #a7aebd;           /* 7.6:1 */
  --line: #2c3343;
  --line-strong: #6b7486;
  --accent: #9aa8ff;
  --accent-ink: #0e1117;
  --focus: #ffd24d;
  --yes: #2a7247; --no: #b3261e; --abst: #8a5a00; --absent: #5b6271; --other: #4b5261;
  --yes-t: #6fd39b; --no-t: #ff8a80; --abst-t: #f0c060;
  --heat: 154, 168, 255; --heat-max: .5;
  --shadow: 0 1px 2px rgba(0, 0, 0, .45);
  --shadow-pop: 0 12px 32px rgba(0, 0, 0, .6);
  --notice-bg: #2e2714; --notice-line: #8a6d1f;
}
[data-theme="contrast"] {
  color-scheme: dark;
  --bg: #000000;
  --card: #000000;
  --card-2: #1a1a1a;
  --ink: #ffffff;
  --muted: #ffffff;
  --line: #ffffff;
  --line-strong: #ffffff;
  --accent: #ffe14d;
  --accent-ink: #000000;
  --focus: #00e5ff;
  --yes: #000000; --no: #000000; --abst: #000000; --absent: #000000; --other: #000000;
  --yes-t: #7dffb0; --no-t: #ff9e9e; --abst-t: #ffe14d;
  --heat: 255, 225, 77; --heat-max: .45;
  --shadow: none; --shadow-pop: none;
  --notice-bg: #000000; --notice-line: #ffe14d;
}
[data-theme="contrast"] .v { border: 2px solid #fff; }
[data-theme="contrast"] .v-Y { color: var(--yes-t); border-color: var(--yes-t); }
[data-theme="contrast"] .v-N { color: var(--no-t); border-color: var(--no-t); }
[data-theme="contrast"] .v-W { color: var(--abst-t); border-color: var(--abst-t); }
[data-theme="contrast"] a:not(.brand) { color: var(--accent); }
[data-theme="contrast"] .card, [data-theme="contrast"] .vot, [data-theme="contrast"] .panel { border-width: 2px; }

/* ---------- Rozmiar tekstu ---------- */
html { font-size: 100%; }
html[data-text="2"] { font-size: 118.75%; }
html[data-text="3"] { font-size: 137.5%; }

/* ---------- Podstawy ---------- */
* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1.125rem;        /* 18 px przy domyślnych ustawieniach */
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
p { margin: 0 0 .5rem; }
.wrap { max-width: 72rem; margin: 0 auto; padding: 0 1.25rem; }
a { color: var(--accent); text-decoration: underline; text-underline-offset: .15em; }
.muted { color: var(--muted); }
.small { font-size: 1rem; }
.nowrap { white-space: nowrap; }
h2, h3 { line-height: 1.3; }
h3 { font-size: 1.15rem; margin: 1.5rem 0 .75rem; }

/* tylko dla czytników ekranu */
.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;
}

/* link „Przejdź do treści”: widoczny po naciśnięciu Tab */
.skip-link {
  position: absolute; left: 1rem; top: -4rem; z-index: 100;
  background: var(--accent); color: var(--accent-ink); padding: .6rem 1rem; border-radius: .5rem; font-weight: 700;
}
.skip-link:focus { top: 1rem; }

/* wyraźny fokus klawiatury */
:focus { outline: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: .25rem; }
input:focus-visible, select:focus-visible { outline-offset: 1px; }
main:focus { outline: none; }

/* ---------- Nagłówek i logo ---------- */
.top { background: var(--card); border-bottom: 1px solid var(--line); padding-top: 1.1rem; }
.brand-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.top a.brand { display: inline-flex; align-items: center; gap: .75rem; color: var(--ink); text-decoration: none; padding: .25rem 0; }
.logo-mark { width: 2.9rem; height: 1.6rem; color: var(--accent); flex: none; }
.wordmark { font-size: 1.65rem; font-weight: 750; letter-spacing: -.03em; line-height: 1; }
.wordmark .w { font-weight: 400; color: var(--muted); letter-spacing: -.015em; }
.sub { margin: .6rem 0 .4rem; color: var(--muted); font-size: 1rem; }

.display-settings { display: flex; gap: .6rem; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: .6rem; padding: .15rem; margin: 0; gap: .15rem; background: var(--card-2); }
.seg label { position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.seg span[aria-hidden], .seg label > span:not(.sr-only) {
  display: inline-flex; align-items: center; justify-content: center; min-height: 2.25rem; min-width: 2.25rem;
  padding: 0 .7rem; border-radius: .45rem; font-size: .9rem; color: var(--ink);
}
.seg input:checked + span { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.seg input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 1px; }
.seg span.a1[aria-hidden] { font-size: .85rem; } .seg span.a2[aria-hidden] { font-size: 1.1rem; } .seg span.a3[aria-hidden] { font-size: 1.4rem; }
.seg label:has(.a1), .seg label:has(.a2), .seg label:has(.a3) { font-weight: 700; }

.mainnav ul { display: flex; flex-wrap: wrap; gap: .15rem; list-style: none; margin: .5rem 0 0; padding: 0; }
.mainnav a {
  display: inline-flex; align-items: center; min-height: 2.75rem; padding: .55rem .9rem; font-size: 1.02rem;
  color: var(--muted); text-decoration: none; border-bottom: 3px solid transparent; margin-bottom: -1px;
}
.mainnav a:hover { color: var(--ink); }
.mainnav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 700; }

/* ---------- Formularze ---------- */
.filters { display: flex; gap: 1.25rem; align-items: end; flex-wrap: wrap; padding-top: 1.25rem; }
.filter-info { padding-bottom: .55rem; font-size: 1rem; margin: 0; }
.controls { display: flex; gap: 1rem; flex-wrap: wrap; align-items: end; margin: 1rem 0 1.25rem; }
.field { display: flex; flex-direction: column; gap: .35rem; }
.field > label { font-size: .95rem; font-weight: 700; color: var(--ink); }
label.check { display: inline-flex; align-items: center; gap: .55rem; font-size: 1rem; padding: .55rem 0; cursor: pointer; }
input[type=checkbox] { accent-color: var(--accent); width: 1.3rem; height: 1.3rem; margin: 0; cursor: pointer; }
select, input[type=search], input[type=text] {
  font: inherit; font-size: 1rem; padding: .6rem .75rem; min-height: 2.75rem;
  border: 1px solid var(--line-strong); border-radius: .5rem; background: var(--card); color: var(--ink); min-width: 15rem;
}
::placeholder { color: var(--muted); opacity: 1; }
button { font: inherit; color: var(--ink); }

.view-title { font-size: 1.6rem; margin: 1.25rem 0 .25rem; line-height: 1.25; }
.view-title:focus { outline: none; }
.view-title:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; }
.view[hidden], .filters[hidden] { display: none; }
.notice { background: var(--notice-bg); border: 2px solid var(--notice-line); padding: .9rem 1rem; border-radius: .6rem; margin: 1rem 0; }
code { background: var(--card-2); padding: .05rem .35rem; border-radius: .25rem; }
.empty { list-style: none; }

/* ---------- Karty posłów ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr)); gap: 1rem; list-style: none; padding: 0; margin: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: .8rem; padding: 1rem; display: flex; gap: 1rem; box-shadow: var(--shadow); }
.card img { width: 4.25rem; height: 5.4rem; object-fit: cover; border-radius: .5rem; background: var(--card-2); flex: none; }
.card-body { flex: 1; min-width: 0; }
.card h3 { margin: 0 0 .15rem; font-size: 1.15rem; }
.card .club { font-size: .95rem; color: var(--muted); }
.stat { margin: .6rem 0 0; font-size: 1rem; }
.bar { display: block; height: .45rem; background: var(--card-2); border-radius: .25rem; overflow: hidden; margin-top: .3rem; border: 1px solid var(--line); }
.bar > span { display: block; height: 100%; background: var(--accent); }
.btn, .card button, .more, .swap {
  font-size: 1rem; border: 1px solid var(--line-strong); background: var(--card); color: var(--ink);
  border-radius: .5rem; cursor: pointer; min-height: 2.75rem;
}
.card button { margin-top: .8rem; padding: .4rem .8rem; font-size: .95rem; }
.btn:hover, .card button:hover, .more:hover, .swap:hover { border-color: var(--accent); background: var(--card-2); }
.inactive { opacity: .75; }

/* ---------- Panele i tabele ---------- */
.big { font-size: 3.4rem; font-weight: 800; letter-spacing: -.04em; line-height: 1.1; color: var(--accent); margin: 0 0 .3rem; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: .8rem; padding: 1.25rem; margin: 1rem 0 1.25rem; box-shadow: var(--shadow); }
.scroll-x { overflow-x: auto; border: 1px solid var(--line); border-radius: .8rem; box-shadow: var(--shadow); background: var(--card); margin-bottom: .75rem; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: .6rem .75rem; border-bottom: 1px solid var(--line); text-align: left; font-size: 1rem; vertical-align: top; }
tbody tr:last-child > * { border-bottom: 0; }
thead th { color: var(--muted); font-weight: 700; font-size: .9rem; }
tbody th { font-weight: 600; }
.row-title { font-weight: 400; }
.topic { display: block; font-size: .95rem; }
.matrix td, .matrix th { text-align: center; white-space: nowrap; }
.matrix th.row { text-align: left; position: sticky; left: 0; background: var(--card); z-index: 1; }
.matrix td { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---------- Głosy ---------- */
.v { display: inline-block; min-width: 7.5rem; white-space: nowrap; padding: .15rem .6rem; border-radius: 999px; font-size: .9rem; font-weight: 700; color: #fff; text-align: center; }
.v-Y { background: var(--yes); } .v-N { background: var(--no); } .v-W { background: var(--abst); }
.v-absent { background: var(--absent); } .v-P { background: var(--other); } .v-none { background: var(--card-2); color: var(--ink); }
.tag { font-size: .85rem; padding: .05rem .55rem; border-radius: 999px; background: var(--card-2); color: var(--ink); margin-left: .5rem; border: 1px solid var(--line-strong); }

.vot-list { list-style: none; padding: 0; margin: 0; }
.vot { background: var(--card); border: 1px solid var(--line); border-radius: .8rem; padding: .9rem 1rem; margin-bottom: .75rem; box-shadow: var(--shadow); }
.vot .meta { font-size: .95rem; color: var(--muted); margin: 0; }
.vot-title { margin: .2rem 0; font-size: 1.1rem; }
.vot-head {
  all: unset; box-sizing: border-box; display: block; width: 100%; cursor: pointer; font-weight: 700; line-height: 1.4;
  padding: .2rem 2rem .2rem 0; position: relative; color: var(--ink);
}
.vot-head::after { content: "▾"; position: absolute; right: .25rem; top: .15rem; color: var(--muted); transition: transform .15s; }
.vot-head[aria-expanded="true"]::after { transform: rotate(180deg); }
.vot-head:hover { color: var(--accent); }
.vot-head:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.vot .res { font-size: .95rem; margin: .35rem 0 0; color: var(--muted); }
.vot .res b.y { color: var(--yes-t); } .vot .res b.n { color: var(--no-t); } .vot .res b.w { color: var(--abst-t); }
.vot .detail { margin-top: .9rem; }
.more { display: block; margin: 1rem auto; padding: .6rem 1.25rem; }

/* ---------- Wyszukiwarka posłów ---------- */
.combo { position: relative; }
.combo input { min-width: 22rem; width: 100%; }
.combo ul {
  position: absolute; z-index: 30; top: calc(100% + .3rem); left: 0; right: 0; min-width: 24rem; max-height: 22rem; overflow-y: auto;
  margin: 0; padding: .3rem; list-style: none; background: var(--card); border: 1px solid var(--line-strong); border-radius: .6rem; box-shadow: var(--shadow-pop);
}
.combo li { padding: .55rem .7rem; cursor: pointer; font-size: 1rem; color: var(--ink); border-radius: .4rem; }
.combo li .muted { font-size: .9rem; }
.combo li.hi, .combo li:hover { background: var(--card-2); outline: 2px solid var(--accent); outline-offset: -2px; }
.combo li.old { opacity: .8; }
.combo li.info { cursor: default; font-size: .9rem; outline: none; background: none; }
.swap { font-size: 1.3rem; padding: 0 .9rem; }

footer { margin: 2.5rem auto; border-top: 1px solid var(--line); padding-top: 1rem; }
footer p { margin-bottom: .75rem; }

/* ---------- Ograniczony ruch ---------- */
@media (prefers-reduced-motion: no-preference) {
  .view:not([hidden]) { animation: fade .15s ease; }
  body { transition: background-color .2s, color .2s; }
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Tryb wymuszonych kolorów Windows ---------- */
@media (forced-colors: active) {
  .v, .tag, .bar { border: 1px solid CanvasText; }
  .bar > span { background: Highlight; }
  .seg input:checked + span { background: Highlight; color: HighlightText; }
  .mainnav a[aria-current="page"] { border-bottom-color: Highlight; }
}

/* ---------- Telefon ---------- */
@media (max-width: 40rem) {
  .wordmark { font-size: 1.35rem; }
  .combo input, .combo ul, select, input[type=search], input[type=text] { min-width: 0; width: 100%; }
  .controls > *, .filters > * { flex: 1 1 100%; }
  .swap { width: 100%; }
  .seg span[aria-hidden], .seg label > span:not(.sr-only) { padding: 0 .5rem; }
  .big { font-size: 2.6rem; }
}

/* ---------- Przyciski i paski narzędzi ---------- */
a.btn, .btn { display: inline-flex; align-items: center; gap: .4rem; padding: .45rem .9rem; text-decoration: none; color: var(--ink); line-height: 1.3; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
.btn.primary:hover { background: var(--accent); filter: brightness(1.08); }
.card .btn { margin-top: .8rem; font-size: .95rem; }
.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .75rem 0; }
.toolbar > a:not(.btn) { padding: .45rem .2rem; }
.pills { list-style: none; padding: 0; margin: .25rem 0 1rem; display: flex; flex-wrap: wrap; gap: .5rem; }
.crumbs { margin: 1rem 0 0; font-size: .95rem; color: var(--muted); }
.lead { font-size: 1.15rem; margin: .25rem 0 .5rem; }
.plain { list-style: none; padding: 0; margin: 0 0 1rem; }
.plain li { padding: .3rem 0; border-bottom: 1px solid var(--line); }
.plain li:last-child { border-bottom: 0; }
.plain.cols { columns: 18rem; column-gap: 2rem; }
.plain.cols li { break-inside: avoid; display: flex; justify-content: space-between; gap: .5rem; align-items: center; }
.result { font-weight: 700; }
.result.ok { color: var(--yes-t); } .result.no { color: var(--no-t); }
.cell-link { color: inherit; text-decoration: none; display: block; }
.cell-link:hover { text-decoration: underline; }
details > summary { cursor: pointer; padding: .4rem 0; font-weight: 600; min-height: 2.75rem; display: flex; align-items: center; }
.club-votes { border-bottom: 1px solid var(--line); }

/* ---------- Profil posła ---------- */
.profile-head { display: flex; gap: 1.25rem; align-items: flex-start; margin-top: 1rem; }
.profile-head img { width: 7.5rem; height: 9.5rem; object-fit: cover; border-radius: .6rem; background: var(--card-2); flex: none; }
.profile-head .view-title { margin-top: 0; }
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: 1rem; margin: 1rem 0; }
.stat-box { margin: 0; }
.stat-box .big { font-size: 2.6rem; }
.stat-label { font-weight: 700; color: var(--muted); margin: 0; font-size: .95rem; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); gap: 1.5rem; }

/* ---------- Wykresy ---------- */
.chart { margin: 1.25rem 0; background: var(--card); border: 1px solid var(--line); border-radius: .8rem; padding: 1rem; box-shadow: var(--shadow); }
.chart figcaption { font-weight: 700; margin-bottom: .4rem; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 13px; font-family: inherit; }
.chart .line { stroke-width: 2.5; }
.chart .line.s0 { stroke: var(--accent); }
.chart .line.s1 { stroke: var(--ink); stroke-dasharray: 6 4; }
.chart .pt.s0 { fill: var(--accent); }
.chart .pt.s1 { fill: var(--card); stroke: var(--ink); stroke-width: 2; }
.legend { display: flex; flex-wrap: wrap; gap: 1.25rem; font-size: .95rem; margin-bottom: .25rem; }
.lg { display: inline-flex; align-items: center; gap: .4rem; white-space: nowrap; }
.lg .line { stroke-width: 2.5; }
.lg .line.s0 { stroke: var(--accent); } .lg .line.s1 { stroke: var(--ink); stroke-dasharray: 6 4; }
.lg .pt.s0 { fill: var(--accent); } .lg .pt.s1 { fill: var(--card); stroke: var(--ink); stroke-width: 2; }
.chart details { margin-top: .5rem; }

/* ---------- Quiz ---------- */
.quiz-list { padding-left: 0; list-style: none; counter-reset: q; }
.quiz-q { border: 1px solid var(--line); border-radius: .8rem; padding: 1rem 1.1rem; margin: 0 0 1rem; background: var(--card); box-shadow: var(--shadow); }
.quiz-q legend { font-weight: 700; padding: 0 .3rem; line-height: 1.4; float: left; width: 100%; margin-bottom: .4rem; }
.quiz-q legend + * { clear: both; }
.seg-answers { display: flex; flex-wrap: wrap; gap: .5rem; }
.seg-answers label { position: relative; cursor: pointer; }
.seg-answers input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.seg-answers span { display: inline-flex; align-items: center; min-height: 2.75rem; padding: 0 1rem; border: 1px solid var(--line-strong); border-radius: .5rem; background: var(--card); }
.seg-answers input:checked + span { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
.seg-answers input:checked + span::before { content: "✓ "; white-space: pre; }
.seg-answers input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.qr { list-style: none; padding: 0; margin: 0 0 1.25rem; }
.qr li { display: grid; grid-template-columns: 1fr auto; gap: .2rem 1rem; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.qr .bar { grid-column: 1 / -1; }
#qr-title:focus { outline: none; }

/* ---------- Strona „O projekcie” ---------- */
.prose { max-width: 48rem; }
.prose ul { padding-left: 1.25rem; }
.prose li { margin-bottom: .35rem; }
.defs dt { font-weight: 700; margin-top: .9rem; }
.defs dd { margin: .2rem 0 0; }
h4 { font-size: 1.05rem; margin: 1.25rem 0 .5rem; }

@media (max-width: 40rem) {
  .profile-head { flex-direction: column; }
  .stat-box .big { font-size: 2.1rem; }
}
