/*
 * grzegorzek-child — blog: wpis (templates/single-post.html), lista, karty.
 * Ładowany z functions.php (po global.css). Zasady: builder first (global.css).
 */

/* ─── 1. Blog — wpis (templates/single-post.html) i karty wpisów ─────── */
/* Spis treści i pasek postępu dokłada assets/js/tg-post.js (decyzja §9.6). */
/* Kolory, ramki, odstępy, typografia — atrybuty bloków w szablonie.      */

/* Układ: szyna 240 + kolumna treści (wp:columns na szerokość kontenera).  */
/* Tekst wpisu 820 px = „Szerokość treści” post-content w szablonie.        */
/* ≤1180 jak na starej: szyna znika, kolumna na całą szerokość kontenera.   */
@media (max-width: 1180px) {
	.tg-post-layout > .tg-post__rail {
		display: none;
	}

	.tg-post-layout > .tg-post__main {
		flex-basis: 100% !important;
	}
}

/* Spis treści — szyna (grupa .tg-toc, lista z JS) */
.tg-toc {
	position: sticky;
	top: 104px;
	font-size: 0.88rem;
}

.tg-toc:not(.is-ready) {
	display: none;
}

.tg-toc::before {
	content: "";
	display: block;
	width: 32px;
	height: 3px;
	margin-bottom: 22px;
	border-radius: 2px;
	background: var(--wp--preset--color--accent-2);
}

.tg-toc__list {
	display: grid;
	gap: 0.55rem;
	margin: 0;
	padding: 0;
	list-style: none;
	border-left: 2px solid var(--wp--preset--color--line);
}

.tg-toc__list li {
	margin-left: -2px;
	border-left: 2px solid transparent;
}

.tg-toc__list a {
	display: block;
	padding: 0.1rem 0 0.1rem 0.85rem;
	color: var(--wp--preset--color--body);
	font-size: 14px;
	line-height: 1.5;
	text-decoration: none;
}

.tg-toc__list a:is(:hover, :focus-visible) {
	color: var(--wp--preset--color--accent-1);
}

.tg-toc__list li.is-current {
	border-left-color: var(--wp--preset--color--accent-1);
}

.tg-toc__list li.is-current a {
	color: var(--wp--preset--color--accent-3);
	font-weight: 600;
}

/* Spis treści — wersja zwijana (≤1180), wstawiana przez JS przed treścią */
.tg-toc-inline {
	display: none;
}

@media (max-width: 1180px) {
	.tg-toc-inline {
		display: block;
		width: fit-content;
		max-width: 100%;
		margin-top: 2rem;
		padding: 0.85rem 1rem;
		border: 1px solid var(--wp--preset--color--line);
		border-radius: 16px;
		background: var(--wp--preset--color--white);
	}

	.tg-toc-inline[open] {
		width: auto;
	}

	.tg-toc-inline summary {
		display: flex;
		justify-content: space-between;
		align-items: center;
		color: var(--wp--preset--color--accent-3);
		font-family: var(--wp--preset--font-family--heading);
		font-size: 0.92rem;
		font-weight: 600;
		list-style: none;
		cursor: pointer;
	}

	.tg-toc-inline summary::-webkit-details-marker {
		display: none;
	}

	.tg-toc-inline .tg-toc__list {
		margin-top: 0.8rem;
	}
}

/* Pasek postępu czytania (JS) — nad nagłówkiem */
.tg-progress {
	position: fixed;
	inset: 0 0 auto;
	z-index: 1300;
	height: 3px;
	pointer-events: none;
}

/* Zalogowany: pod paskiem admina (inaczej go zasłania). ≤600 px pasek    */
/* admina przewija się ze stroną — wtedy wracamy na samą górę.             */
.admin-bar .tg-progress {
	top: var(--wp-admin--admin-bar--height, 32px);
}

@media (max-width: 600px) {
	.admin-bar .tg-progress {
		top: 0;
	}
}

.tg-progress i {
	display: block;
	width: 0;
	height: 100%;
	background: linear-gradient(90deg, var(--wp--preset--color--accent-2), var(--wp--preset--color--accent-1));
	transition: width 0.1s linear;
}

/* Okruszki (core/breadcrumbs) */
.tg-crumbs a {
	text-decoration: none;
}

.tg-crumbs a:is(:hover, :focus-visible) {
	color: var(--wp--preset--color--accent-1);
}

/* Etykieta działu nad tytułem — pigułka na linku core/post-terms */
.tg-eyebrow a {
	display: inline-flex;
	align-items: center;
	gap: 0.45rem;
	padding: 0.35rem 0.75rem;
	border: 1px solid color-mix(in srgb, var(--wp--preset--color--accent-1) 16%, transparent);
	border-radius: 999px;
	background: color-mix(in srgb, var(--wp--preset--color--accent-1) 7%, transparent);
	text-decoration: none;
}

.tg-eyebrow a::before {
	content: "";
	flex: 0 0 auto;
	width: 14px;
	height: 14px;
	background-color: currentColor;
	-webkit-mask: var(--tg-ic-article) center / contain no-repeat;
	mask: var(--tg-ic-article) center / contain no-repeat;
}

/* Jak na starej: tylko pierwszy dział (wpis w 2 kategoriach) */
.tg-eyebrow a ~ a,
.tg-eyebrow .wp-block-post-terms__separator,
.tg-bcard__k .wp-block-post-terms a ~ a,
.tg-bcard__k .wp-block-post-terms__separator {
	display: none;
}

/* Obrazek wpisu na mobile: od krawędzi do krawędzi (wychodzi o margines   */
/* boczny = token root padding), 4:3, bez zaokrągleń                       */
@media (max-width: 782px) {
	.tg-post-image {
		margin-left: calc(var(--wp--style--root--padding-left) * -1) !important;
		margin-right: calc(var(--wp--style--root--padding-right) * -1) !important;
	}

	.tg-post-image img {
		aspect-ratio: 4 / 3 !important;
		border-radius: 0 !important;
	}
}

/* Treść wpisów (224 wpisy z importu — markup redakcyjny, nie szablon) */
.tg-post-content > h2 {
	margin-top: 2.2rem;
	margin-bottom: 0.7rem;
}

/* Rytm starej strony: po nagłówku, linii i obrazku następny blok bez odstępu */
/* (odstęp daje margines nagłówka; obraz przylega do tekstu jak na starej)    */
.tg-post-content > :is(h2, hr, .wp-block-image) + :not(h2) {
	margin-top: 0;
}

.tg-post-content > h2::before {
	content: "";
	display: block;
	width: 34px;
	height: 3px;
	margin-bottom: 0.8rem;
	border-radius: 2px;
	background: var(--wp--preset--color--accent-2);
}

.tg-post-content > :is(p, ul, ol, blockquote) a {
	font-weight: 600;
	text-decoration: underline;
	text-underline-offset: 3px;
}

.tg-post-content img {
	border-radius: 12px;
}

@media (max-width: 782px) {
	.tg-post-content > h2 {
		margin-top: 1.8rem;
	}
}

/* Wizytówka gabinetu pod wpisem */
.tg-gab__a {
	display: grid;
	flex: 0 0 auto;
	place-items: center;
	width: 56px;
	height: 56px;
	border-radius: 50%;
	background: var(--wp--preset--color--accent-3);
	color: var(--wp--preset--color--surface);
	font-family: var(--wp--preset--font-family--heading);
	font-size: 1rem;
	font-weight: 700;
}

.tg-gab a {
	font-weight: 600;
	text-decoration: underline;
	text-underline-offset: 3px;
}

@media (max-width: 782px) {
	.tg-gab {
		flex-direction: column;
	}
}

/* Karta wpisu (Query: lista bloga, „Przeczytaj też”, wyniki wyszukiwania) */
.tg-bcard {
	overflow: hidden;
	transition: box-shadow 0.18s ease, transform 0.18s ease;
}

.tg-bcard:hover {
	box-shadow: var(--wp--preset--shadow--md) !important;
	transform: translateY(-2px);
}

.tg-bcard .wp-block-post-featured-image {
	overflow: hidden;
}

.tg-bcard .wp-block-post-featured-image img {
	transition: transform 0.45s;
}

.tg-bcard:hover .wp-block-post-featured-image img {
	transform: scale(1.04);
}

.tg-bcard__k a,
.tg-bcard .wp-block-post-title a {
	text-decoration: none;
}

.tg-bcard .wp-block-post-excerpt__excerpt {
	margin: 0;
}

/* „Czytaj →” — core/read-more ze strzałką (maska) */
.wp-block-read-more.tg-ic-arrow {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	text-decoration: none;
}

.wp-block-read-more.tg-ic-arrow::after {
	content: "";
	width: 15px;
	height: 15px;
	background-color: currentColor;
	-webkit-mask: var(--tg-ic-arrow) center / contain no-repeat;
	mask: var(--tg-ic-arrow) center / contain no-repeat;
}

/* Karta: wiersz „dział · data · czas” płynie jak tekst (łamie się po słowach) */
.tg-bcard__k > * {
	display: inline;
}

/* ─── 2. Lista poradnika (templates/home.html, category.html, parts/blog-lista.html) ─── */

/* Etykieta w nagłówku podstrony (grupa .tg-pill-label + akapit) */
.tg-pill-label {
	width: fit-content;
	border: 1px solid color-mix(in srgb, var(--wp--preset--color--accent-1) 16%, transparent);
	background: color-mix(in srgb, var(--wp--preset--color--accent-1) 7%, transparent);
}

.tg-pill-label::before {
	content: "";
	flex: 0 0 auto;
	width: 14px;
	height: 14px;
	background-color: var(--wp--preset--color--accent-1);
	-webkit-mask: var(--tg-ic-article) center / contain no-repeat;
	mask: var(--tg-ic-article) center / contain no-repeat;
}

/* Pasek działów — przyklejony pod nagłówkiem, półprzezroczysty, wysunięty */
/* o 1rem poza kontener (constrained wymusza margines auto — stąd !important) */
.tg-blognav {
	position: sticky;
	top: 92px;
	z-index: 20;
	max-width: none !important;
	margin-inline: -1rem !important;
	background: color-mix(in srgb, var(--wp--preset--color--page) 93%, transparent);
	backdrop-filter: blur(8px);
}

@media (max-width: 782px) {
	.tg-blognav {
		top: 64px;
		flex-wrap: nowrap !important;
		margin-inline: calc(var(--wp--style--root--padding-left) * -1) !important;
		padding-inline: var(--wp--style--root--padding-left) !important;
		overflow-x: auto;
		scrollbar-width: none;
	}

	.tg-blognav::-webkit-scrollbar {
		display: none;
	}

	.tg-blognav .wp-block-term-template {
		flex-wrap: nowrap !important;
	}

	.tg-blognav :is(.wp-block-button__link, .wp-block-term-name) {
		white-space: nowrap;
	}
}

/* Pigułki: cała pigułka klikalna (link nazwy rozciągnięty), stany */
.tg-pill {
	position: relative;
	transition: background-color 0.18s ease, border-color 0.18s ease;
}

.tg-pill .wp-block-term-name a {
	text-decoration: none;
}

.tg-pill .wp-block-term-name a::after {
	content: "";
	position: absolute;
	inset: 0;
}

.tg-pill:has(a:is(:hover, :focus-visible)) {
	border-color: var(--wp--preset--color--accent-1) !important;
}

.tg-pill:has(a:is(:hover, :focus-visible)) a {
	color: var(--wp--preset--color--accent-1);
}

.tg-pill:has(.is-current) {
	border-color: var(--wp--preset--color--accent-3) !important;
	background-color: var(--wp--preset--color--accent-3) !important;
}

.tg-pill:has(.is-current) a {
	color: var(--wp--preset--color--white);
}

.tg-pill:has(.is-current) .wp-block-term-count {
	color: var(--wp--preset--color--muted-invert) !important;
}

.tg-pill-all .wp-block-button__link {
	transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.tg-pill-all .wp-block-button__link:is(:hover, :focus-visible) {
	border-color: var(--wp--preset--color--accent-1) !important;
	background-color: var(--wp--preset--color--white) !important;
	color: var(--wp--preset--color--accent-1) !important;
}

body.blog .tg-pill-all .wp-block-button__link {
	border-color: var(--wp--preset--color--accent-3) !important;
	background-color: var(--wp--preset--color--accent-3) !important;
	color: var(--wp--preset--color--white) !important;
}

/* Brak wyników (core/query-no-results) — link bez podkreślenia, jak na starej */
.tg-bempty a {
	text-decoration: none;
}

/* Zajawka: 22 słowa na karcie, 34 na wpisie wiodącym */
.tg-ex-long {
	display: none;
}

/* Wpis wiodący — 1. karta na 1. stronie listy, gdy wpisów jest > 4 (jak na starej) */
body:not(.paged) .tg-blog-list .wp-block-post-template:has(> li:nth-child(5)) > li:first-child {
	grid-column: 1 / -1;
	margin-bottom: 0.5rem;
}

body:not(.paged) .tg-blog-list .wp-block-post-template:has(> li:nth-child(5)) > li:first-child .tg-bcard {
	display: grid;
	grid-template-columns: 1.15fr 1fr;
	align-items: center;
	gap: 2rem;
}

body:not(.paged) .tg-blog-list .wp-block-post-template:has(> li:nth-child(5)) > li:first-child .wp-block-post-featured-image {
	height: 100%;
	min-height: 260px;
}

body:not(.paged) .tg-blog-list .wp-block-post-template:has(> li:nth-child(5)) > li:first-child .wp-block-post-featured-image img {
	height: 100%;
	aspect-ratio: auto !important;
}

body:not(.paged) .tg-blog-list .wp-block-post-template:has(> li:nth-child(5)) > li:first-child .tg-bcard__body {
	gap: 0.6rem;
	padding: 2rem 2rem 2rem 0 !important;
}

body:not(.paged) .tg-blog-list .wp-block-post-template:has(> li:nth-child(5)) > li:first-child .wp-block-post-title {
	font-size: 1.5rem !important;
	line-height: 1.22 !important;
}

body:not(.paged) .tg-blog-list .wp-block-post-template:has(> li:nth-child(5)) > li:first-child .tg-ex-short {
	display: none;
}

body:not(.paged) .tg-blog-list .wp-block-post-template:has(> li:nth-child(5)) > li:first-child .tg-ex-long {
	display: block;
}

body:not(.paged) .tg-blog-list .wp-block-post-template:has(> li:nth-child(5)) > li:first-child .wp-block-read-more {
	margin-top: 0 !important;
	padding-top: 0 !important;
}

/* Wpis wiodący bez obrazka (np. strona w wynikach wyszukiwania) — na całą */
/* szerokość z odstępem z każdej strony (poprawka błędu starej strony)       */
@media (min-width: 901px) {
	body:not(.paged) .tg-blog-list .wp-block-post-template:has(> li:nth-child(5)) > li:first-child .tg-bcard:not(:has(.wp-block-post-featured-image)) {
		grid-template-columns: minmax(0, 1fr);
	}

	body:not(.paged) .tg-blog-list .wp-block-post-template:has(> li:nth-child(5)) > li:first-child .tg-bcard:not(:has(.wp-block-post-featured-image)) .tg-bcard__body {
		padding: 2rem !important;
	}
}

@media (max-width: 900px) {
	body:not(.paged) .tg-blog-list .wp-block-post-template:has(> li:nth-child(5)) > li:first-child .tg-bcard {
		grid-template-columns: minmax(0, 1fr);
	}

	body:not(.paged) .tg-blog-list .wp-block-post-template:has(> li:nth-child(5)) > li:first-child .wp-block-post-featured-image {
		min-height: 0;
		aspect-ratio: 16 / 9;
	}

	body:not(.paged) .tg-blog-list .wp-block-post-template:has(> li:nth-child(5)) > li:first-child .tg-bcard__body {
		padding: 1.5rem !important;
	}

	body:not(.paged) .tg-blog-list .wp-block-post-template:has(> li:nth-child(5)) > li:first-child .wp-block-post-title {
		font-size: 1.25rem !important;
	}
}

@media (max-width: 782px) {
	body:not(.paged) .tg-blog-list .wp-block-post-template:has(> li:nth-child(5)) > li:first-child {
		margin-bottom: 0;
	}

	body:not(.paged) .tg-blog-list .wp-block-post-template:has(> li:nth-child(5)) > li:first-child .tg-bcard__body {
		padding: 1rem !important;
	}
}

/* Paginacja (core/query-pagination) — kwadraty 44 px jak na starej */
.tg-blog-list .wp-block-query-pagination :is(.page-numbers, .wp-block-query-pagination-previous, .wp-block-query-pagination-next) {
	box-sizing: border-box;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 44px;
	height: 44px;
	padding: 0 0.85rem;
	border: 1px solid var(--wp--preset--color--line);
	border-radius: 12px;
	background: var(--wp--preset--color--white);
	color: var(--wp--preset--color--accent-3);
	font-family: var(--wp--preset--font-family--heading);
	font-weight: 600;
	text-decoration: none;
}

.tg-blog-list .wp-block-query-pagination-numbers {
	display: inline-flex;
	gap: 0.4rem;
}

.tg-blog-list .wp-block-query-pagination :is(a.page-numbers, .wp-block-query-pagination-previous, .wp-block-query-pagination-next):is(:hover, :focus-visible) {
	border-color: var(--wp--preset--color--accent-1);
	color: var(--wp--preset--color--accent-1);
}

.tg-blog-list .wp-block-query-pagination .page-numbers.current {
	border-color: var(--wp--preset--color--accent-3);
	background: var(--wp--preset--color--accent-3);
	color: var(--wp--preset--color--white);
}

.tg-blog-list .wp-block-query-pagination .page-numbers.dots {
	min-width: 24px;
	border-color: transparent;
	background: none;
}

/* ─── 3. Wyniki wyszukiwania (templates/search.html) i strona 404 ─────── */

/* Wiersz karty bez działu (strona) albo bez czasu czytania (zabieg) —   */
/* bez osieroconej kropki na początku i na końcu                          */
.tg-bcard__k > p:first-child,
.tg-bcard__k > p:last-child {
	display: none;
}

/* Wyszukiwarka na 404 (core/search, przycisk z ikoną obok pola) — jak na */
/* starej: pole bez zaokrągleń z ramką, przycisk bordo 12 px, ikona 16 px  */
.tg-search-404 .wp-block-search__input {
	box-sizing: border-box;
	min-height: 48px;
	padding: 10px 15px;
	border: 1px solid var(--wp--preset--color--line);
	border-radius: 0;
	background: var(--wp--preset--color--white);
	color: var(--wp--preset--color--accent-3);
	font-size: 17px;
}

.tg-search-404 .wp-block-search__button {
	box-sizing: border-box;
	align-self: flex-start;
	height: 45px;
	margin-left: 3px;
	padding: 12px 25px;
	border-radius: 12px;
}

.tg-search-404 .wp-block-search__button svg {
	width: 16px;
	min-width: 16px;
	height: 16px;
	min-height: 16px;
}
