/* Spiele-Icons – Navigation zur Spieleseite
   Alle Regeln sind auf .spi gescoped, damit kein Theme-CSS kollidiert. */

.spi {
	--spi-ink:    #14293b;
	--spi-muted:  #5b6f7f;
	--spi-line:   #d4dbe0;
	--spi-accent: #14293b;   /* je Kachel per style-Attribut überschrieben */

	--spi-sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	--spi-mono: ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

	container-type: inline-size;
	container-name: spi;

	font-family: var(--spi-sans);
	box-sizing: border-box;
}

.spi *,
.spi *::before,
.spi *::after { box-sizing: border-box; }

.spi__title {
	font-family: var(--spi-mono);
	font-size: 11px;
	letter-spacing: 0.3em;
	text-transform: uppercase;
	color: var(--spi-muted);
	margin: 0 0 12px;
	padding-bottom: 8px;
	border-bottom: 1px solid var(--spi-line);
}

/* auto-fit statt fester Spaltenzahl: die Kacheln brechen nach der Breite des
   Kastens um, ganz ohne Breakpoint. */
.spi__list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
	gap: 10px;
}

.spi__item { min-width: 0; }

.spi__link {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: flex-start;
	gap: 4px;
	height: 100%;
	padding: 16px 10px 13px;
	text-align: center;
	text-decoration: none;
	color: var(--spi-ink);
	background: #fff;
	border: 1px solid var(--spi-line);
	border-radius: 10px;
	transition: transform 140ms ease, border-color 140ms ease, background-color 140ms ease;
}

.spi__link:hover,
.spi__link:focus-visible {
	transform: translateY(-2px);
	border-color: var(--spi-accent);
	background: color-mix(in srgb, var(--spi-accent) 7%, #fff);
	text-decoration: none;
}

.spi__link:focus-visible {
	outline: 2px solid var(--spi-accent);
	outline-offset: 2px;
}

.spi__icon {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 46px;
	height: 46px;
	margin-bottom: 6px;
	border-radius: 50%;
	color: var(--spi-accent);
	background: color-mix(in srgb, var(--spi-accent) 11%, #fff);
	transition: background-color 140ms ease, color 140ms ease;
}

.spi__link:hover .spi__icon,
.spi__link:focus-visible .spi__icon {
	color: #fff;
	background: var(--spi-accent);
}

.spi__svg { width: 27px; height: 27px; display: block; }

.spi__label {
	font-size: 13px;
	font-weight: 700;
	line-height: 1.25;
	color: var(--spi-ink);
	overflow-wrap: anywhere;
}

.spi__sub {
	font-family: var(--spi-mono);
	font-size: 10px;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--spi-muted);
	line-height: 1.3;
	overflow-wrap: anywhere;
}

/* ---------- Leisten-Layout ([spiele_icons layout="leiste"]) ----------
   Eine einzige horizontale Reihe; passt sie nicht, wird gescrollt. */

.spi--leiste .spi__list {
	display: flex;
	grid-template-columns: none;
	gap: 10px;
	overflow-x: auto;
	overflow-y: hidden;
	padding-bottom: 10px;
	scroll-snap-type: x proximity;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: thin;
	scrollbar-color: var(--spi-line) transparent;
}

.spi--leiste .spi__list::-webkit-scrollbar { height: 8px; }
.spi--leiste .spi__list::-webkit-scrollbar-track { background: transparent; }
.spi--leiste .spi__list::-webkit-scrollbar-thumb { background: var(--spi-line); border-radius: 4px; }

.spi--leiste .spi__item {
	flex: 0 0 auto;
	width: 112px;
	scroll-snap-align: start;
}

/* In der schmalen Spalte etwas kleinere Kacheln – aber weiter EINE Reihe. */
@container spi (max-width: 400px) {
	.spi--leiste .spi__item { width: 96px; }
}

/* ---------- Blöcke auf der Spieleseite ----------
   scroll-margin-top hält das Sprungziel unter einer etwaigen festen
   Kopfzeile hervor, statt es darunter verschwinden zu lassen. */

.spi-block {
	margin: 0 0 44px;
	scroll-margin-top: 80px;
}

.spi-block:last-child { margin-bottom: 0; }

/* ---------- Schmale Spalten ----------
   Gemessen wird die Breite von .spi, nicht die des Fensters. */

/* Reicht bis 400px, damit die 1/3-Spalte des Themes (~326px) sicher
   darunter fällt. Dort stehen dann drei Kacheln je Zeile. */
@container spi (max-width: 400px) {
	.spi__list { grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); gap: 7px; }
	.spi__link { padding: 11px 6px 9px; gap: 3px; }
	.spi__icon { width: 36px; height: 36px; margin-bottom: 4px; }
	.spi__svg { width: 22px; height: 22px; }
	.spi__label { font-size: 11.5px; line-height: 1.2; }
	.spi__sub { font-size: 8.5px; letter-spacing: 0.04em; }
}

/* Ganz schmal (Handy hochkant im gestapelten Layout): zwei je Zeile. */
@container spi (max-width: 220px) {
	.spi__list { grid-template-columns: repeat(auto-fit, minmax(74px, 1fr)); }
	.spi__sub { display: none; }
}

/* color-mix ist neuer als der Rest der Datei – ohne Unterstützung bleiben die
   Flächen schlicht weiß bzw. grau, die Icons behalten ihre Farbe. */
@supports not (background: color-mix(in srgb, red 10%, white)) {
	.spi__icon { background: #f0f3f5; }
	.spi__link:hover { background: #f7f9fa; }
}

@media (prefers-reduced-motion: reduce) {
	.spi__link { transition: none; }
	.spi__link:hover,
	.spi__link:focus-visible { transform: none; }
}
