/* Strona #/porownaj: wybór do 4 powiatów, kafelki, tabela ze słupkami, wykres liniowy, budżet. Tylko zmienne z style.css (tryb ciemny). */

/* kolory serii: niebieski, ochra, kolor tekstu, róż; bez zieleni i czerwieni */
.cmp {
  --cmp-s1: var(--data-1);
  --cmp-s2: var(--data-3);
  --cmp-s3: var(--fg);
  --cmp-s4: var(--data-7);
  min-width: 0;
}
.cmp h2 { font-size: 20px; margin: 0 0 4px; letter-spacing: -.01em; }
.cmp-sub { font-size: 14px; color: var(--muted); margin: 0 0 12px; max-width: 760px; }
.cmp-block { margin-top: 28px; padding: 18px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); min-width: 0; }

.cmp-msg { margin: 16px 0 0; padding: 10px 14px; border: 1px solid var(--border); border-left: 3px solid var(--muted); border-radius: 0 8px 8px 0; background: var(--bg-alt); font-size: 14px; }
.cmp-msg p { margin: 2px 0; }

/* wybór */
.cmp-picker { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: 20px 0 0; padding: 14px 16px; background: var(--bg-alt); border: 1px solid var(--border); border-radius: 12px; }
.cmp-search { flex: 1 1 280px; max-width: 420px; }
.cmp-search input:disabled { opacity: .75; cursor: not-allowed; }
.cmp-search li[aria-disabled="true"] { color: var(--muted); }
.cmp-chips { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 0; padding: 0; }
.cmp-chip { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; padding: 3px 4px 3px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--bg); }
.cmp-chip > i { width: 10px; height: 10px; border-radius: 50%; flex: none; }
/* przycisk „×”: obszar trafienia 44 × 44 px, ujemny margines trzyma niską pigułkę */
.cmp-chips { row-gap: 14px; }
.cmp-chip button { min-width: 44px; min-height: 44px; margin: -9px -4px -9px -8px; padding: 0; border: 0; border-radius: 50%; background: none; cursor: pointer; font-size: 17px; line-height: 1; color: var(--muted); }
.cmp-chip button:hover { background: var(--bg-hover); color: var(--fg); }
.cmp-chip button:focus-visible, .cmp-preset:focus-visible, .cmp-tablewrap:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cmp-share { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.cmp-copy-msg { font-size: 13px; color: var(--muted); word-break: break-all; }

/* ekran startowy */
.cmp-start { margin-top: 28px; }
.cmp-start p { color: var(--muted); margin: 0 0 14px; }
.cmp-presets { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 12px; }
.cmp-preset { display: block; text-decoration: none; padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); }
.cmp-preset:hover { border-color: color-mix(in srgb, var(--fg) 30%, var(--border)); background: var(--bg-alt); }
.cmp-preset b { display: block; font-size: 16px; }
.cmp-preset span { display: block; font-size: 13.5px; color: var(--muted); margin-top: 2px; }

/* rok */
.cmp-yearbar { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; margin-top: 18px; }
.cmp-yearbar-lbl { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

/* kafelki */
.cmp-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 12px; margin-top: 16px; }
.cmp-tile { border: 1px solid var(--border); border-top: 4px solid var(--c); border-radius: 12px; padding: 12px 16px 14px; background: var(--bg); min-width: 0; }
.cmp-tile h3 { font-size: 19px; margin: 2px 0 0; line-height: 1.25; }
.cmp-tile h3 a { text-decoration: none; }
.cmp-tile h3 a:hover { text-decoration: underline; }
.cmp-tile-type { font-size: 12px; color: var(--muted); margin: 0; }
.cmp-tile-meta { font-size: 13.5px; color: var(--muted); margin: 2px 0 8px; }
.cmp-tile-pop { margin: 0; font-family: var(--mono); font-size: 16px; font-weight: 500; }
.cmp-tile-spike { font-size: 12.5px; color: var(--muted); margin: 8px 0 0; line-height: 1.4; }
.cmp-tile-pop small { font-family: var(--font); font-size: 12.5px; color: var(--muted); font-weight: 400; }

/* podsumowanie */
.cmp-summary { margin-top: 16px; padding: 14px 16px; border-left: 3px solid var(--fg); background: var(--bg-alt); border-radius: 0 10px 10px 0; max-width: 860px; }
.cmp-summary p { margin: 0; font-size: 16px; line-height: 1.55; }
.cmp-summary .cmp-summary-note { font-size: 13px; color: var(--muted); margin-top: 6px; }

/* tabela */
.cmp-tablewrap { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: 10px; }
.cmp-table { width: 100%; min-width: 560px; margin: 0; border-collapse: collapse; font-size: 14px; }
.cmp-table caption { caption-side: top; text-align: left; font-size: 12.5px; color: var(--muted); padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--bg-alt); }
.cmp-table th, .cmp-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.cmp-table tbody tr:last-child > * { border-bottom: 0; }
.cmp-table thead th { font-size: 13px; font-weight: 700; color: var(--fg); background: var(--bg); vertical-align: bottom; }
.cmp-table thead th:first-child { color: var(--muted); font-weight: 500; }
.cmp-table tbody th { font-weight: 500; font-size: 13.5px; min-width: 130px; }
.cmp-table tbody th small { display: block; color: var(--muted); font-size: 11.5px; font-weight: 400; }
.cmp-table tr.cmp-total th, .cmp-table tr.cmp-total .cmp-val { font-weight: 700; }
.cmp-table tr:nth-last-child(1) > * { border-top: 2px solid var(--border); }
.cmp-table tr > :first-child { position: sticky; left: 0; z-index: 1; background: var(--bg); box-shadow: 1px 0 0 var(--border); }
.cmp-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: 0; }
.cmp-cell { min-width: 120px; }
.cmp-val { font-family: var(--mono); font-size: 14px; }
.cmp-rank { display: inline-block; font-family: var(--mono); font-size: 11.5px; color: var(--muted); margin-left: 8px; white-space: nowrap; }
.cmp-n { display: block; font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.cmp-bar { position: relative; display: block; height: 8px; margin-top: 5px; background: var(--bg-alt); border-radius: 4px; }
.cmp-bar i { display: block; height: 100%; border-radius: 4px; }
.cmp-bar b { position: absolute; top: -3px; bottom: -3px; width: 0; border-left: 1.5px dashed var(--fg); opacity: .65; }
.cmp-table td.cmp-med, .cmp-table th.cmp-med { color: var(--muted); font-family: var(--mono); font-size: 13px; white-space: nowrap; }
.cmp-table thead th.cmp-med { font-family: var(--font); font-weight: 500; font-size: 12.5px; }

/* zastrzeżenia */
.cmp-caveats { margin-top: 18px; max-width: 860px; }
.cmp-caveats h2 { font-size: 16px; }
.cmp-caveats ul { margin: 6px 0 0; padding-left: 20px; font-size: 14.5px; color: var(--muted); }
.cmp-caveats li { margin: 6px 0; }
.cmp-caveats b { color: var(--fg); font-weight: 600; }

/* wykres */
.cmp-catchips { margin-bottom: 12px; }
.cmp-chart { overflow: visible; max-width: 920px; }
.cmp-chart .cmp-medline { stroke: var(--muted); stroke-width: 1.8; stroke-dasharray: 5 4; }
.cmp-chart .cmp-yearline { stroke: var(--border); stroke-width: 6; opacity: .7; }
.cmp-chart .cmp-endlbl { font-weight: 600; paint-order: stroke; stroke: var(--bg); stroke-width: 3px; }
.cmp-chart .cmp-endlbl.med { font-weight: 400; font-style: italic; }
.cmp-legend i.cmp-k-med { width: 16px; height: 0; border-radius: 0; border-top: 2px dashed var(--muted); vertical-align: 3px; }
.cmp-legend i.cmp-k-year { width: 8px; height: 12px; border-radius: 2px; background: var(--border); vertical-align: -2px; }

/* budżet */
.cmp-note { font-size: 13.5px; margin: 0 0 12px; padding: 8px 12px; background: var(--bg-alt); border-left: 3px solid var(--muted); border-radius: 0 6px 6px 0; max-width: 760px; }
.cmp-budget { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.cmp-bname { margin: 0 0 4px; font-weight: 600; font-size: 14.5px; }
.cmp-brow { display: grid; grid-template-columns: 170px minmax(0, 1fr) 96px; align-items: center; gap: 10px; font-size: 13px; margin: 3px 0; }
.cmp-blbl { color: var(--muted); }
.cmp-bbar { margin-top: 0; height: 10px; }
.cmp-bval { font-family: var(--mono); font-size: 13px; text-align: right; white-space: nowrap; }

.cmp-hint { margin-top: 18px; color: var(--muted); font-size: 14px; }

/* tylko dla czytników ekranu */
.cmp .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
/* źródło pod tabelą, jak na karcie powiatu */
.cmp-zrodlo { font-family: var(--mono); font-size: 11px; color: var(--muted); margin: 8px 0 0; line-height: 1.5; overflow-wrap: anywhere; }
/* podpowiedź pary miasto – powiat ziemski */
.cmp-pair { min-height: 32px; font-weight: 600; color: var(--accent); border-color: var(--accent); }
/* wykres: kontener .viz daje styl tabeli liczb, ale bez własnej ramki */
.cmp-viz { margin: 0; padding: 0; background: none; border: 0; border-radius: 0; }

/* cień przy prawej krawędzi tabeli: są dalsze kolumny (klasę more-right ustawia porownaj.js) */
.cmp-frame { position: relative; }
.cmp-frame::after {
  content: ""; position: absolute; top: 1px; bottom: 1px; right: 1px; width: 22px; pointer-events: none; z-index: 3;
  border-radius: 0 9px 9px 0; background: linear-gradient(to left, color-mix(in srgb, var(--fg) 22%, transparent), transparent);
  opacity: 0; transition: opacity .15s;
}
.cmp-frame.more-right::after { opacity: 1; }

@media (max-width: 760px) {
  .cmp-picker { padding: 12px; }
  .cmp-search { flex-basis: 100%; max-width: none; }
  .cmp-share { margin-left: 0; }
  .cmp-block { padding: 14px 12px; }
  .cmp-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .cmp-tile { padding: 10px 12px 12px; }
  .cmp-tile h3 { font-size: 16px; }
  .cmp-tile-pop { font-size: 14px; }
  .cmp-table th, .cmp-table td { padding: 7px 9px; }
  .cmp-table tbody th { min-width: 108px; max-width: 120px; }
  .cmp-cell { min-width: 108px; }
  .cmp-brow { grid-template-columns: minmax(0, 1fr) 84px; gap: 4px 8px; }
  .cmp-blbl { grid-column: 1 / -1; }
}

/* podpis tabeli: na wąskim ekranie zostaje w widocznej części kontenera, zamiast uciekać w prawo z przewijaną tabelą */
@media (max-width: 760px) {
  .cmp-table caption { position: sticky; left: 0; max-width: calc(100vw - 58px); box-sizing: border-box; }
}

/* telefon: wąska (104 px), przyklejona kolumna kategorii, żeby obok zmieściły się dwa powiaty.
   Mniejszy prawy padding daje 90 px na tekst: najdłuższe słowa („gospodarczym”, „Wykrywalność”) mają ok. 85 px i się nie łamią. */
@media (max-width: 560px) {
  .cmp-table { min-width: 0; }
  .cmp-table tr > :first-child { position: sticky; left: 0; width: 104px; min-width: 104px; max-width: 104px; box-sizing: border-box; overflow-wrap: break-word; }
  .cmp-table tbody th { font-size: 12px; min-width: 104px; max-width: 104px; }
  .cmp-table th, .cmp-table td { padding: 7px 8px; }
  .cmp-table tr > :first-child { padding-right: 6px; }
  /* tabela liczb pod wykresem: nagłówki serii łamią się, żeby tabela zmieściła się w ramce */
  .cmp-viz .chart-data thead th { white-space: normal; }
  .cmp-cell { min-width: 104px; }
  .cmp-table thead th { font-size: 12.5px; }
  .cmp-rank { display: block; margin-left: 0; }
}
