/**
 * Rotator tekstow `lukuro-text-rotator` (FW-TXT-001).
 *
 * Arkusz wg docs/css-warstwy.md: najpierw skora w `lukuro.base`, potem szkielet, tryby i stany
 * w `lukuro.modules`. Zero `!important` - kolor, typografie i tlo paska nadaje klasa Bricksa
 * projektu (poza warstwami), ktora z definicji wygrywa z tym arkuszem. Kontrolka "Wysokosc" zapisuje
 * zmienna `--lukuro-text-rotator-height` (FW-TXT-002 D5) - regula `height` Bricksa poza warstwa
 * przebilaby `height: auto` trybu pionowego.
 *
 * Teksty nieaktywne chowane WYLACZNIE wizualnie (`opacity` + `transform`): bez `visibility`,
 * `display: none` i `aria-hidden`, zeby czytnik dostal kazdy tekst raz, a linki zostaly osiagalne.
 *
 * Stany z JS na korzeniu: `is-running` (petla przewija), `is-paused` (dowolna pauza: najechanie,
 * fokus, karta, przycisk), `is-stopped` (pauza przyciskiem albo start przy ograniczeniu ruchu),
 * `is-instant` (zmiana bez przejscia - fokus na tekscie nieaktywnym), `is-static` (petla statyczna:
 * ograniczenie ruchu albo kanwa; niezalezna od `is-running`, FW-TXT-002 D6).
 *
 * `vertical` (D4): lista jako siatka z jedna komorka, teksty zawijane, wysokosc z najwyzszego tekstu
 * (`min-height` = zmienna wysokosci). Separator (D6, klasa korzenia `lukuro-txtrot--sep`) widoczny
 * tylko w petli; odstep tekst-separator-tekst = polowa `--lukuro-text-rotator-gap` po obu stronach.
 *
 * Zmienne: `--lukuro-text-rotator-height` (40px; kontrolka "Wysokosc"; w `vertical` minimum),
 * `--lukuro-text-rotator-duration` (500ms; kontrolka "Czas przejscia"),
 * `--lukuro-text-rotator-pause-size` (32px, cel >= 24 x 24), `--lukuro-text-rotator-gap`
 * (odstep tekstow w petli, 3em). Skrypt ustawia `--lukuro-txtrot-shift` i `--lukuro-txtrot-time`.
 *
 * @package Lukuro
 * @author lukuro
 */

@layer lukuro.base {

/* Reset odstepu listy w skorze, nie w szkielecie: `lukuro.modules` jest pozniejsza warstwa
   i jej `padding: 0` przebiloby odstep petli ponizej bez wzgledu na specyficznosc. */
.lukuro-txtrot__list {
	padding: 0;
}

.lukuro-txtrot:not(.lukuro-txtrot--marquee) .lukuro-txtrot__item {
	padding-inline: .5em;
}

.lukuro-txtrot--marquee .lukuro-txtrot__list {
	gap: var(--lukuro-text-rotator-gap, 3em);
	padding-inline-end: var(--lukuro-text-rotator-gap, 3em);
}

/* Separator (D6): polowa odstepu miedzy trescia a separatorem i polowa za nim - takze na szwie
   ostatni oryginal -> pierwszy klon (koniec listy = `padding-inline-end`). */
.lukuro-txtrot--sep.lukuro-txtrot--marquee .lukuro-txtrot__list {
	gap: calc(var(--lukuro-text-rotator-gap, 3em) / 2);
	padding-inline-end: calc(var(--lukuro-text-rotator-gap, 3em) / 2);
}

.lukuro-txtrot--sep .lukuro-txtrot__item {
	gap: calc(var(--lukuro-text-rotator-gap, 3em) / 2);
}

.lukuro-txtrot__sep {
	color: inherit;
}

.lukuro-txtrot__content {
	gap: .5em;
}

.lukuro-txtrot__link {
	color: inherit;
	text-decoration: underline;
	text-underline-offset: .2em;
}

.lukuro-txtrot__pause {
	border: 0;
	border-radius: 0;
	background: transparent;
	color: inherit;
}

.lukuro-txtrot__link:focus-visible,
.lukuro-txtrot__pause:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: -2px;
}

} /* @layer lukuro.base */

@layer lukuro.modules {

/* Szkielet: pelna szerokosc rodzica (teksty slajdow sa absolutne, wiec bez tego rotator
   w kontenerze flex zwinalby sie do zera), stala wysokosc, tekst w srodkowej kolumnie, przycisk
   przy prawej krawedzi. Kolumna po lewej rowna przyciskowi trzyma tekst na srodku paska. */
.lukuro-txtrot {
	position: relative;
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	align-items: stretch;
	box-sizing: border-box;
	width: 100%;
	height: var(--lukuro-text-rotator-height, 40px);
	overflow: hidden;
}

.lukuro-txtrot--has-pause {
	grid-template-columns: var(--lukuro-text-rotator-pause-size, 32px) minmax(0, 1fr) var(--lukuro-text-rotator-pause-size, 32px);
}

.lukuro-txtrot--has-pause .lukuro-txtrot__viewport {
	grid-column: 2;
}

.lukuro-txtrot--marquee.lukuro-txtrot--has-pause {
	grid-template-columns: minmax(0, 1fr) var(--lukuro-text-rotator-pause-size, 32px);
}

.lukuro-txtrot--marquee.lukuro-txtrot--has-pause .lukuro-txtrot__viewport {
	grid-column: 1;
}

.lukuro-txtrot__viewport {
	position: relative;
	grid-row: 1;
	min-width: 0;
	height: 100%;
	overflow: hidden;
}

.lukuro-txtrot__track {
	height: 100%;
}

.lukuro-txtrot__list {
	position: relative;
	height: 100%;
	margin: 0;
	list-style: none;
}

.lukuro-txtrot__item {
	margin: 0;
	list-style: none;
}

.lukuro-txtrot__content {
	display: inline-flex;
	align-items: center;
	min-width: 0;
	max-width: 100%;
}

.lukuro-txtrot__text {
	min-width: 0;
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.lukuro-txtrot__icon {
	display: inline-flex;
	flex: 0 0 auto;
	align-items: center;
	line-height: 1;
}

.lukuro-txtrot__icon svg {
	width: 1em;
	height: 1em;
}

.lukuro-txtrot__icon svg:not([fill]) {
	fill: currentColor;
}

/* Separator (D6): poza petla niewidoczny; ikona 1em w kolorze tekstu. */
.lukuro-txtrot__sep {
	display: none;
}

.lukuro-txtrot--sep.lukuro-txtrot--marquee .lukuro-txtrot__item {
	display: flex;
	align-items: center;
}

.lukuro-txtrot--sep.lukuro-txtrot--marquee .lukuro-txtrot__sep {
	display: inline-flex;
	flex: 0 0 auto;
	align-items: center;
	line-height: 1;
}

.lukuro-txtrot__sep :is(i, svg) {
	font-size: 1em;
}

.lukuro-txtrot__sep svg {
	width: 1em;
	height: 1em;
}

.lukuro-txtrot__sep svg:not([fill]) {
	fill: currentColor;
}

/* Petla statyczna: bez separatora za ostatnim tekstem. Tylko przy `is-static` - w ruchu lista
   mierzona z ostatnim separatorem, wiec szew oryginal -> klon ma ten sam odstep. */
.lukuro-txtrot--marquee.is-static .lukuro-txtrot__list > .lukuro-txtrot__item:last-child .lukuro-txtrot__sep {
	display: none;
}

/* Tryby slajdowe: wszystkie teksty w tym samym miejscu, jeden aktywny. */
.lukuro-txtrot:not(.lukuro-txtrot--marquee) .lukuro-txtrot__item {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	opacity: 0;
	pointer-events: none;
	transition: opacity var(--lukuro-text-rotator-duration, 500ms) ease, transform var(--lukuro-text-rotator-duration, 500ms) ease;
}

/* Pionowo (D4): lista jako siatka z jedna komorka - wszystkie teksty w tym samym miejscu, wysokosc
   wiersza = najwyzszy tekst, wiec zmiana tekstu nie zmienia wysokosci paska. Korzen bez stalej
   wysokosci, zmienna wysokosci jako minimum; tekst zawijany, wysrodkowany w pionie i poziomie. */
.lukuro-txtrot.lukuro-txtrot--vertical {
	height: auto;
	min-height: var(--lukuro-text-rotator-height, 40px);
}

.lukuro-txtrot--vertical .lukuro-txtrot__list {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
}

.lukuro-txtrot.lukuro-txtrot--vertical .lukuro-txtrot__item {
	position: relative;
	inset: auto;
	grid-area: 1 / 1;
	min-width: 0;
	text-align: center;
}

.lukuro-txtrot.lukuro-txtrot--vertical .lukuro-txtrot__text {
	overflow: visible;
	white-space: normal;
	text-overflow: clip;
	overflow-wrap: anywhere;
}

.lukuro-txtrot--vertical .lukuro-txtrot__item {
	transform: translateY(100%);
}

.lukuro-txtrot--vertical .lukuro-txtrot__item.is-leaving {
	transform: translateY(-100%);
}

.lukuro-txtrot--horizontal .lukuro-txtrot__item {
	transform: translateX(100%);
}

.lukuro-txtrot--horizontal .lukuro-txtrot__item.is-leaving {
	transform: translateX(-100%);
}

.lukuro-txtrot:not(.lukuro-txtrot--marquee) .lukuro-txtrot__item.is-active {
	z-index: 1;
	opacity: 1;
	transform: none;
	pointer-events: auto;
}

.lukuro-txtrot.is-instant .lukuro-txtrot__item {
	transition: none;
}

/* Petla: oryginaly i klony (skrypt, `aria-hidden` + `inert`) w jednym pasie. */
.lukuro-txtrot--marquee .lukuro-txtrot__track {
	display: flex;
	width: max-content;
}

.lukuro-txtrot--marquee .lukuro-txtrot__list {
	display: flex;
	flex: 0 0 auto;
	align-items: center;
}

.lukuro-txtrot--marquee .lukuro-txtrot__item {
	flex: 0 0 auto;
	white-space: nowrap;
}

.lukuro-txtrot--marquee.is-running .lukuro-txtrot__track {
	animation: lukuro-txtrot-marquee var(--lukuro-txtrot-time, 20s) linear infinite;
}

.lukuro-txtrot--marquee.is-running[data-lukuro-txtrot-direction="right"] .lukuro-txtrot__track {
	animation-direction: reverse;
}

.lukuro-txtrot--marquee.is-paused .lukuro-txtrot__track {
	animation-play-state: paused;
}

@keyframes lukuro-txtrot-marquee {
	from {
		transform: translateX(0);
	}
	to {
		transform: translateX(var(--lukuro-txtrot-shift, -50%));
	}
}

/* Przycisk pauzy. */
.lukuro-txtrot__pause {
	display: inline-flex;
	grid-row: 1;
	grid-column: -2;
	align-items: center;
	align-self: center;
	justify-content: center;
	justify-self: center;
	box-sizing: border-box;
	width: var(--lukuro-text-rotator-pause-size, 32px);
	height: var(--lukuro-text-rotator-pause-size, 32px);
	padding: 0;
	cursor: pointer;
}

.lukuro-txtrot__pause[hidden] {
	display: none;
}

.lukuro-txtrot__pause-icon {
	display: block;
	width: 16px;
	height: 16px;
	pointer-events: none;
}

.lukuro-txtrot__pause-icon--play,
.lukuro-txtrot.is-stopped .lukuro-txtrot__pause-icon--pause {
	display: none;
}

.lukuro-txtrot.is-stopped .lukuro-txtrot__pause-icon--play {
	display: block;
}

/* Ograniczenie ruchu: zero przejsc i animacji (logike - brak samoczynnego startu - trzyma skrypt).
   Selektory o tej samej specyficznosci co reguly ruchu wyzej - wygrywaja kolejnoscia. */
@media (prefers-reduced-motion: reduce) {
	.lukuro-txtrot:not(.lukuro-txtrot--marquee) .lukuro-txtrot__item {
		transition: none;
	}

	.lukuro-txtrot--marquee.is-running .lukuro-txtrot__track {
		animation: none;
	}
}

} /* @layer lukuro.modules */
