/* ============================================================
   TABELE HTML — `.si-table`
   ------------------------------------------------------------
   Jedna klasa na wszystkie tabele. Szerokości kolumn liczy
   przeglądarka (`table-layout: auto`) z minimum `--si-t-colmin`,
   więc ta sama klasa obsługuje tabelę 2- i 6-kolumnową — nie ma
   już wariantów `table-2col`…`table-5col`.

   Warianty:
     .si-table                    — widoczna od razu w całości
     .si-table si-table--zwijana  — startuje zwinięta, JS dokłada
                                    przycisk „Rozwiń / Zwiń”

   Zachowanie:
     • Rozwinięta tabela wchodzi w tekst CAŁĄ wysokością — nigdy nie
       ma własnego pionowego paska przewijania.
     • ≤700 px tabela o WIĘCEJ NIŻ DWÓCH kolumnach rozsypuje się na
       kafelki (wiersz = karta, nagłówek kolumny = etykieta nad
       wartością); dwukolumnowa zostaje tabelą, bo mieści się na
       telefonie co do piksela. Nic nie jeździ wtedy w bok.

   Przyklejanie nagłówka — dwa tryby, bo `position: sticky` mierzy się
   względem najbliższego obszaru przewijania, a nie względem okna:
     1. Tabela mieści się na szerokość → klasa `is-sticky-page`
        (`overflow: clip`, które NIE tworzy obszaru przewijania) →
        nagłówek klei się do okna czystym CSS-em.
     2. Tabela wychodzi poza kontener → `overflow-x: auto` → przykleja
        się pierwsza kolumna, a nagłówek zastępuje kopia w pasku
        `position: fixed` (patrz `.si-table-floathead` na końcu pliku).

   Stare klasy `table-responsive` / `table-Ncol` przepisuje na
   `si-table` filtr `plmbr_tables_legacy_classes()` w mu-pluginie.
   ============================================================ */

.si-table {
	/* Kolory — rodzina spisu treści i FAQ tego serwisu. */
	--si-t-bg: #ffffff;
	--si-t-zebra: #f7f8fa;
	--si-t-hover: #eef4fb;
	--si-t-border: #e4e6ea;
	--si-t-text: #404040;
	--si-t-strong: #010042;
	--si-t-head-bg: #010042;
	--si-t-head-fg: #ffffff;
	--si-t-accent: #0986c0;
	--si-t-muted: #6b7280;

	/* Wymiary */
	--si-t-radius: 18px;
	--si-t-colmin: 16rem;
	--si-t-pad-y: 14px;
	--si-t-pad-x: 18px;
	--si-t-peek: min(380px, 46vh);
	--si-t-fade: 84px;

	position: relative;
	margin: 30px auto;
	/* Bez `max-height` — rozwinięta tabela ma pokazać się w całości.
	   `overflow-y: hidden` (nie `auto`) gwarantuje, że pionowy pasek
	   przewijania nie pojawi się nawet przy zaokrągleniach. */
	overflow-x: auto;
	overflow-y: hidden;
	overscroll-behavior-x: contain;
	-webkit-overflow-scrolling: touch;
	background: var(--si-t-bg);
	border: 1px solid var(--si-t-border);
	border-radius: var(--si-t-radius);
	box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
	scrollbar-width: thin;
	scrollbar-color: #c7ccd4 transparent;
	transition: max-height 0.38s cubic-bezier(0.4, 0, 0.2, 1);
}

.si-table::-webkit-scrollbar {
	width: 12px;
	height: 12px;
}

.si-table::-webkit-scrollbar-track {
	background: transparent;
}

.si-table::-webkit-scrollbar-thumb {
	background: #c7ccd4;
	border: 3px solid var(--si-t-bg);
	border-radius: 99px;
}

/* Przewijany obszar dostaje od JS `tabindex`, więc musi mieć
   widoczny fokus dla osób sterujących klawiaturą. */
.si-table:focus-visible {
	outline: 2px solid var(--si-t-strong);
	outline-offset: 2px;
}

.si-table table {
	width: 100%;
	margin: 0;
	border: 0;
	border-collapse: separate;
	border-spacing: 0;
	background: transparent;
	font-family: inherit;
	color: var(--si-t-text);
}

.si-table caption {
	caption-side: top;
	padding: 15px var(--si-t-pad-x) 13px;
	background: var(--si-t-bg);
	color: var(--si-t-strong);
	font-size: 15px;
	font-weight: 700;
	text-align: left;
}

.si-table th,
.si-table td {
	/* Kolumna nie może żądać więcej niż 42% szerokości ekranu — bez tego
	   tabela 2-kolumnowa na telefonie wystawała o kilkanaście pikseli
	   i jeździła w bok bez powodu. Powyżej ~610 px ekranu ogranicznik
	   jest bezczynny, bo `--si-t-colmin` jest wtedy mniejsze. */
	min-width: min(var(--si-t-colmin), 42vw);
	padding: var(--si-t-pad-y) var(--si-t-pad-x);
	border: 0;
	text-align: left;
	vertical-align: top;
	line-height: 1.55;
	overflow-wrap: break-word;
}

.si-table thead th {
	position: sticky;
	top: 0;
	z-index: 3;
	background: var(--si-t-head-bg);
	color: var(--si-t-head-fg);
	padding-top: 16px;
	padding-bottom: 16px;
	font-size: 14px;
	font-weight: 600;
	/* Kreska akcentu jako `inset box-shadow`, bo obramowanie na
	   przyklejonej komórce potrafi zniknąć przy przewijaniu. */
	box-shadow: inset 0 -3px 0 var(--si-t-accent);
}

/* Klejenie do okna — pod ewentualnym paskiem administratora. */
.si-table.is-sticky-page thead th {
	top: var(--si-t-top, 0px);
}

/* Część tabel ma nagłówek owinięty w <strong> — ma wtedy wyglądać
   tak samo jak nagłówek bez niego. */
.si-table thead th strong,
.si-table thead th b {
	font: inherit;
	color: inherit;
}

.si-table tbody th,
.si-table tbody td {
	background: var(--si-t-bg);
	border-top: 1px solid var(--si-t-border);
	font-size: 15px;
	transition: background 0.18s ease;
}

.si-table tbody tr:first-child > * {
	border-top: 0;
}

.si-table tbody tr:nth-child(even) > * {
	background: var(--si-t-zebra);
}

.si-table tbody tr:hover > * {
	background: var(--si-t-hover);
}

/* Pierwsza kolumna to etykieta wiersza — przykleja się do lewej
   krawędzi, gdy tabela jedzie w bok. */
.si-table tbody tr > :first-child {
	position: sticky;
	left: 0;
	z-index: 2;
	color: var(--si-t-strong);
	font-weight: 600;
	box-shadow: 1px 0 0 var(--si-t-border);
}

/* Róg tabeli klei się w obu osiach naraz, więc potrzebuje `left`
   obok `top` z reguły wyżej, i musi leżeć nad resztą. */
.si-table thead tr > :first-child {
	left: 0;
	z-index: 4;
	box-shadow: inset 0 -3px 0 var(--si-t-accent), 1px 0 0 rgba(255, 255, 255, 0.16);
}

.si-table a {
	color: var(--si-t-accent);
	text-underline-offset: 2px;
	transition: color 0.2s ease;
}

.si-table a:hover {
	color: var(--si-t-strong);
}

.si-table thead a {
	color: inherit;
	text-decoration-color: currentColor;
}

/* --- Zwinięcie -------------------------------------------------
   Domyślnie zwija CSS (bez czekania na JS — brak przeskoku przy
   wczytywaniu), a JS tylko dokłada przycisk i klasę `is-expanded`.

   Progiem jest WYSOKOŚĆ, nie liczba wierszy — `max-height` sam nic
   nie robi tabeli niższej niż `--si-t-peek`. Liczenie wierszy
   dawałoby złe wyniki w obie strony: we wpisach blogowych zdarza
   się wiersz o wysokości 326 px, a w cenniku wypożyczalni 56 px.
   Gdy po zwinięciu zostaje ukryte mniej niż ~50 px, JS zdejmuje
   zwinięcie. */
.si-table--zwijana:not(.is-expanded) {
	max-height: var(--si-t-peek);
	/* W poziomie nadal da się przewinąć — bez tego szeroka tabela
	   gubi ostatnią kolumnę bez żadnego sposobu, żeby do niej dojść. */
	overflow-x: auto;
	overflow-y: hidden;
	-webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - var(--si-t-fade)), transparent 100%);
	        mask-image: linear-gradient(to bottom, #000 calc(100% - var(--si-t-fade)), transparent 100%);
}

/* Tabela mieszcząca się na szerokość przestaje być obszarem
   przewijania — dopiero wtedy nagłówek może kleić się do okna.
   `clip` zamiast `visible`, żeby zaokrąglone narożniki dalej
   przycinały tabelę. Klasę nadaje JS i tylko wtedy, gdy tabela nie
   jest zwinięta. Starsze przeglądarki bez `overflow: clip` pomijają
   tę regułę — zostaje im zachowanie bazowe. */
.si-table.is-sticky-page {
	overflow: clip;
}

/* --- Telefon ---------------------------------------------------
   Tabela zostaje tabelą i dalej jeździ w bok; zmniejszamy tylko
   minimum kolumny i odstępy, żeby droga w bok nie była absurdalna. */
@media (max-width: 700px) {
	.si-table {
		--si-t-colmin: 11rem;
		--si-t-pad-y: 11px;
		--si-t-pad-x: 13px;
		--si-t-radius: 14px;
		--si-t-peek: min(300px, 44vh);
		--si-t-fade: 72px;

		margin: 24px auto;
	}

	.si-table thead th {
		padding-top: 13px;
		padding-bottom: 13px;
		font-size: 13px;
	}

	.si-table tbody th,
	.si-table tbody td {
		font-size: 14px;
	}
}

/* --- Kafelki na telefonie ---------------------------------------
   Klasę `is-cards` nadaje JS tabelom o więcej niż dwóch kolumnach —
   razem z atrybutami `data-label`, z których biorą się etykiety.
   Bez skryptu klasy nie ma i zostaje zwykła, przewijana w bok tabela.

   ⚠️ Kolejność reguł niżej ma znaczenie: wyzerowanie pasów zebry
   i regułę pierwszej komórki dzieli ta sama specyficzność (0,3,2),
   więc gdyby zebra stała później, nagłówek parzystej karty zrobiłby
   się biały. To samo dotyczy pary `[data-label]::before`
   i `:first-child::before`.
   ============================================================ */

@media (max-width: 700px) {
	.si-table.is-cards {
		overflow: visible;
		background: transparent;
		border: 0;
		border-radius: 0;
		box-shadow: none;
	}

	/* Zwijanie działa dalej — powtórzone z wyższą specyficznością,
	   bo reguła wyżej jest w tym samym miejscu kaskady. */
	.si-table.is-cards.si-table--zwijana:not(.is-expanded) {
		max-height: var(--si-t-peek);
		overflow: hidden;
	}

	.si-table.is-cards table,
	.si-table.is-cards tbody,
	.si-table.is-cards tfoot,
	.si-table.is-cards tr,
	.si-table.is-cards tbody th,
	.si-table.is-cards td {
		display: block;
		width: auto;
		min-width: 0;
	}

	/* Nagłówek zostaje w drzewie dostępności, znika tylko z ekranu. */
	.si-table.is-cards thead {
		position: absolute;
		width: 1px;
		height: 1px;
		margin: -1px;
		padding: 0;
		border: 0;
		overflow: hidden;
		clip-path: inset(50%);
		white-space: nowrap;
	}

	.si-table.is-cards tbody tr {
		margin-bottom: 14px;
		background: var(--si-t-bg);
		border: 1px solid var(--si-t-border);
		border-radius: 14px;
		box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
		overflow: hidden;
	}

	.si-table.is-cards tbody tr:last-child {
		margin-bottom: 0;
	}

	.si-table.is-cards tbody tr > * {
		position: static;
		padding: 12px 16px 13px;
		border-top: 0;
		box-shadow: none;
		font-size: 14px;
	}

	.si-table.is-cards tbody tr > * + * {
		border-top: 1px solid var(--si-t-border);
	}

	/* Pasy zebry i podświetlenie wiersza nie mają w kartach sensu. */
	.si-table.is-cards tbody tr:nth-child(even) > *,
	.si-table.is-cards tbody tr:hover > * {
		background: var(--si-t-bg);
	}

	.si-table.is-cards tbody tr > [data-label]::before {
		content: attr(data-label);
		display: block;
		margin-bottom: 3px;
		color: var(--si-t-muted);
		font-size: 12px;
		font-weight: 700;
		letter-spacing: 0.04em;
		text-transform: uppercase;
	}

	/* Pierwsza komórka = nagłówek karty, więc bez etykiety. */
	.si-table.is-cards tbody tr > :first-child {
		padding: 14px 16px 15px;
		background: var(--si-t-head-bg);
		color: var(--si-t-head-fg);
		box-shadow: inset 0 -3px 0 var(--si-t-accent);
		font-size: 15px;
		font-weight: 600;
	}

	.si-table.is-cards tbody tr > :first-child::before {
		content: none;
	}

	.si-table.is-cards tbody tr > :first-child strong,
	.si-table.is-cards tbody tr > :first-child b {
		font: inherit;
		color: inherit;
	}
}

/* --- Przycisk „Rozwiń / Zwiń” (wstawia go JS) ------------------ */

.si-table-shell {
	margin: 30px auto;
}

.si-table-shell > .si-table {
	margin: 0;
}

.si-table__toggle {
	position: relative;
	z-index: 2;
	display: flex;
	align-items: center;
	gap: 10px;
	margin: -22px auto 0;
	padding: 9px 20px 9px 11px;
	background: #ffffff;
	border: 1px solid #e4e6ea;
	border-radius: 999px;
	box-shadow: 0 6px 18px rgba(1, 0, 66, 0.12);
	color: #010042;
	font-family: inherit;
	font-size: 15px;
	font-weight: 600;
	line-height: 1.2;
	cursor: pointer;
	transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.si-table-shell.is-expanded .si-table__toggle {
	margin-top: 14px;
}

.si-table__toggle:hover {
	border-color: #0986c0;
	box-shadow: 0 8px 22px rgba(1, 0, 66, 0.18);
}

.si-table__toggle:focus-visible {
	outline: 2px solid #010042;
	outline-offset: 2px;
}

.si-table__toggle-icon {
	display: grid;
	place-items: center;
	width: 28px;
	height: 28px;
	background: #0986c0;
	border-radius: 50%;
	transition: transform 0.25s ease;
}

.si-table-shell.is-expanded .si-table__toggle-icon {
	transform: rotate(180deg);
}

.si-table__toggle-icon svg {
	display: block;
	width: 13px;
	height: 13px;
	fill: none;
	stroke: #ffffff;
	stroke-width: 2.4;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.si-table__toggle-count {
	color: #6b7280;
	font-weight: 500;
}

/* --- Kopia nagłówka dla tabel przewijanych w bok ----------------
   Pasek z klonem `thead`, wstawiany przez JS do `<body>` (poza
   `.si-table`, żeby żaden przodek z `transform` nie przestawił mu
   `position: fixed`). Leży poza tabelą, więc zmienne `--si-t-*` tu
   nie sięgają — wartości muszą odpowiadać regule `.si-table thead th`
   i zmieniać się razem z nią.

   Pasek sam jest obszarem przewijania (`overflow: hidden` nim jest),
   dzięki czemu jego pierwsza komórka przykleja się do lewej krawędzi
   dokładnie tak, jak w prawdziwej tabeli. Skrypt trzyma jego
   `scrollLeft` w zgodzie z tabelą.
   ============================================================ */

.si-table-floathead {
	position: fixed;
	/* Odstęp na pasek administratora bierze się ze zmiennej, którą
	   skrypt przelicza przy każdym przewinięciu. */
	top: var(--si-t-top, 0px);
	left: 0;
	z-index: 90;
	overflow: hidden;
	visibility: hidden;
	pointer-events: none;
	box-shadow: 0 8px 18px rgba(1, 0, 66, 0.18);
}

.si-table-floathead.is-visible {
	visibility: visible;
}

.si-table-floathead table {
	margin: 0;
	border: 0;
	border-collapse: separate;
	border-spacing: 0;
	background: transparent;
	/* Szerokości kolumn przepisuje skrypt z oryginału. */
	table-layout: fixed;
}

.si-table-floathead th,
.si-table-floathead td {
	box-sizing: border-box;
	padding: 16px 18px;
	border: 0;
	background: #010042;
	color: #ffffff;
	font-family: inherit;
	font-size: 14px;
	font-weight: 600;
	line-height: 1.55;
	text-align: left;
	vertical-align: top;
	overflow-wrap: break-word;
	box-shadow: inset 0 -3px 0 #0986c0;
}

.si-table-floathead tr > :first-child {
	position: sticky;
	left: 0;
	z-index: 2;
	box-shadow: inset 0 -3px 0 #0986c0, 1px 0 0 rgba(255, 255, 255, 0.16);
}

.si-table-floathead strong,
.si-table-floathead b {
	font: inherit;
	color: inherit;
}

@media (max-width: 700px) {
	.si-table-floathead th,
	.si-table-floathead td {
		padding: 13px;
		font-size: 13px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.si-table,
	.si-table tbody th,
	.si-table tbody td,
	.si-table__toggle,
	.si-table__toggle-icon {
		transition: none;
	}
}

@media print {
	.si-table {
		max-height: none !important;
		overflow: visible !important;
		box-shadow: none;
		-webkit-mask-image: none !important;
		        mask-image: none !important;
	}

	.si-table__toggle,
	.si-table-floathead {
		display: none;
	}
}
