/**
 * Krebs Knolle Flipbook – Frontend
 * Farben/Schrift über CSS-Variablen, Elementor-Globals werden bevorzugt.
 */

.kk-grid,
.kk-lightbox {
	--kk-font: var(--e-global-typography-primary-font-family, "Ubuntu"), "Ubuntu", system-ui, sans-serif;
	--kk-primary: var(--e-global-color-primary, #bf0000);
	--kk-secondary: var(--e-global-color-secondary, #a00000);
	--kk-text: var(--e-global-color-text, #022422);
	--kk-accent: var(--e-global-color-accent, #231f20);
	--kk-card-bg: #f2f2f2;
	--kk-gap: 30px;
	--kk-radius: 0px;
	--kk-tap-size: 30%;
	--kk-overlay: #141414;
}

/* ------------------------------------------------------------------ */
/* Raster + Karten                                                     */
/* ------------------------------------------------------------------ */

.kk-grid {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: var(--kk-gap);
	font-family: var(--kk-font);
}

.kk-grid--cols-1 { grid-template-columns: minmax(0, 1fr); }
.kk-grid--cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kk-grid--cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kk-grid--single { max-width: 420px; }

@media (max-width: 1024px) {
	.kk-grid:not(.kk-grid--cols-1) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 767px) {
	.kk-grid,
	.kk-grid:not(.kk-grid--cols-1) { grid-template-columns: minmax(0, 1fr); --kk-gap: 20px; }
}

.kk-card-wrap { min-width: 0; scroll-margin-top: 120px; }

.kk-card {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 22px;
	height: 100%;
	padding: 34px 34px 28px;
	background: var(--kk-card-bg);
	border-radius: var(--kk-radius);
	color: var(--kk-text);
	text-decoration: none;
	cursor: pointer;
	transition: background-color 0.2s ease;
}

.kk-card:hover,
.kk-card:focus-visible { color: var(--kk-text); background: #ececec; }

.kk-card:focus-visible {
	outline: 3px solid var(--kk-primary);
	outline-offset: 3px;
}

.kk-card__cover {
	position: relative;
	display: block;
	width: 100%;
	aspect-ratio: 210 / 297;
	background: #fff;
	box-shadow: 0 6px 18px rgba(0, 0, 0, 0.16), 0 1px 3px rgba(0, 0, 0, 0.12);
	overflow: hidden;
	transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.kk-card:hover .kk-card__cover,
.kk-card:focus-visible .kk-card__cover {
	transform: translateY(-3px);
	box-shadow: 0 12px 26px rgba(0, 0, 0, 0.2), 0 2px 4px rgba(0, 0, 0, 0.12);
}

.kk-card__cover img.kk-card__img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	margin: 0;
	border-radius: 0;
}

.kk-card__placeholder {
	display: flex;
	align-items: center;
	justify-content: center;
	height: 100%;
	padding: 1em;
	font-weight: 700;
	text-align: center;
}

/* Tipp-Icon als Overlay – zentriert, ca. 30 % der Coverbreite */
.kk-card__tap {
	position: absolute;
	top: 50%;
	left: 50%;
	width: var(--kk-tap-size);
	aspect-ratio: 1;
	transform: translate(-50%, -50%);
	pointer-events: none;
	filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.25));
	transition: transform 0.3s ease;
}

.kk-card__tap svg { display: block; width: 100%; height: 100%; }

.kk-tap__hand { transform-origin: 52px 40px; transform-box: view-box; }
.kk-tap__rays { transform-origin: 52px 34px; transform-box: view-box; opacity: 1; }

.kk-card:hover .kk-card__tap,
.kk-card:focus-visible .kk-card__tap { transform: translate(-50%, -50%) scale(1.07); }

.kk-card:hover .kk-tap__hand,
.kk-card:focus-visible .kk-tap__hand { animation: kk-tap-press 1.1s ease-in-out infinite; }

.kk-card:hover .kk-tap__rays,
.kk-card:focus-visible .kk-tap__rays { animation: kk-tap-rays 1.1s ease-in-out infinite; }

@keyframes kk-tap-press {
	0%, 100% { transform: translateY(0) scale(1); }
	45% { transform: translateY(3px) scale(0.96); }
}

@keyframes kk-tap-rays {
	0%, 100% { opacity: 1; transform: scale(1); }
	45% { opacity: 0.35; transform: scale(1.15); }
}

.kk-card__label {
	display: block;
	font-family: var(--kk-font);
	font-weight: 700;
	font-size: 1.125rem;
	line-height: 1.3;
	text-align: center;
	color: var(--kk-text);
}

@media (prefers-reduced-motion: reduce) {
	.kk-card,
	.kk-card__cover,
	.kk-card__tap { transition: none; }
	.kk-card:hover .kk-tap__hand,
	.kk-card:hover .kk-tap__rays,
	.kk-card:focus-visible .kk-tap__hand,
	.kk-card:focus-visible .kk-tap__rays { animation: none; }
}

/* ------------------------------------------------------------------ */
/* Lightbox                                                            */
/* ------------------------------------------------------------------ */

html.kk-lock,
html.kk-lock body { overflow: hidden !important; }

.kk-lightbox {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: flex;
	flex-direction: column;
	background: var(--kk-overlay);
	color: #fff;
	font-family: var(--kk-font);
	-webkit-tap-highlight-color: transparent;
}

.kk-lightbox[hidden] { display: none; }

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

.kk-lb__top,
.kk-lb__toolbar {
	position: relative;
	z-index: 3;
	display: flex;
	align-items: center;
	gap: 6px;
	flex: 0 0 auto;
	padding: 10px 14px;
}

.kk-lb__top { justify-content: space-between; }

.kk-lb__counter {
	min-width: 5em;
	font-size: 0.95rem;
	font-variant-numeric: tabular-nums;
	opacity: 0.9;
}

.kk-lb__title {
	flex: 1 1 auto;
	overflow: hidden;
	font-size: 0.95rem;
	font-weight: 700;
	text-align: center;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.kk-lb__toolbar {
	justify-content: center;
	flex-wrap: wrap;
	padding-bottom: max(10px, env(safe-area-inset-bottom));
}

.kk-lb__sep { width: 1px; height: 24px; margin: 0 6px; background: rgba(255, 255, 255, 0.25); }

.kk-lb__zoomval { min-width: 3.4em; font-size: 0.85rem; text-align: center; font-variant-numeric: tabular-nums; opacity: 0.85; }

/* Buttons – Theme-Styles (Hello/Elementor) neutralisieren */
.kk-lightbox .kk-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 42px;
	height: 42px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: #fff;
	font: inherit;
	line-height: 1;
	text-decoration: none;
	cursor: pointer;
	box-shadow: none;
	transition: background-color 0.15s ease, opacity 0.15s ease;
}

.kk-lightbox .kk-btn:hover { background: rgba(255, 255, 255, 0.14); color: #fff; }
.kk-lightbox .kk-btn:focus-visible { outline: 2px solid #ffd500; outline-offset: 2px; background: rgba(255, 255, 255, 0.14); }
.kk-lightbox .kk-btn[disabled] { opacity: 0.3; cursor: default; background: transparent; }
.kk-lightbox .kk-btn[aria-pressed="true"] { background: rgba(255, 255, 255, 0.22); }
.kk-lightbox .kk-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.kk-lightbox .kk-btn[hidden] { display: none; }

.kk-lb__stage {
	position: relative;
	flex: 1 1 auto;
	min-height: 0;
	display: flex;
	align-items: stretch;
}

.kk-lightbox .kk-lb__nav {
	position: absolute;
	top: 50%;
	z-index: 4;
	width: 52px;
	height: 52px;
	transform: translateY(-50%);
	background: rgba(0, 0, 0, 0.35);
}

.kk-lightbox .kk-lb__nav:hover { background: rgba(0, 0, 0, 0.6); }
.kk-lightbox .kk-lb__nav svg { width: 28px; height: 28px; }
.kk-lb__prev { left: 12px; }
.kk-lb__next { right: 12px; }

.kk-lb__book-host {
	position: absolute;
	inset: 12px 76px;
}

.kk-lb__book { width: 100%; height: 100%; }
.kk-lb__book .stf__wrapper { height: 100%; }

@media (max-width: 767px) {
	.kk-lb__book-host { inset: 6px 8px; }
	.kk-lightbox .kk-lb__nav { width: 40px; height: 40px; background: rgba(0, 0, 0, 0.45); }
	.kk-lb__prev { left: 4px; }
	.kk-lb__next { right: 4px; }
	.kk-lb__sep, .kk-lb__zoomval { display: none; }
	.kk-lightbox .kk-btn { width: 40px; height: 40px; }
}

/* Seiten */
.kk-page {
	position: relative;
	overflow: hidden;
	background: #fff;
}

.kk-page canvas {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	display: block;
}

.kk-page__links { position: absolute; inset: 0; z-index: 2; }

.kk-page__links a {
	position: absolute;
	display: block;
	cursor: pointer;
}

.kk-page__links a:hover,
.kk-page__links a:focus-visible { background: rgba(255, 213, 0, 0.18); outline: 1px solid rgba(255, 213, 0, 0.7); }

/* Ladeanzeige */
.kk-spinner {
	width: 38px;
	height: 38px;
	border: 3px solid rgba(0, 0, 0, 0.12);
	border-top-color: var(--kk-primary);
	border-radius: 50%;
	animation: kk-spin 0.8s linear infinite;
}

.kk-page .kk-spinner { position: absolute; top: 50%; left: 50%; margin: -19px 0 0 -19px; }
.kk-page.is-rendered .kk-spinner { display: none; }

@keyframes kk-spin { to { transform: rotate(360deg); } }

.kk-lb__loader {
	position: absolute;
	inset: 0;
	z-index: 5;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 14px;
	font-size: 0.95rem;
	text-align: center;
}

.kk-lb__loader .kk-spinner { border-color: rgba(255, 255, 255, 0.2); border-top-color: #ffd500; }
.kk-lb__loader[hidden] { display: none; }
.kk-lb__loader a { color: #ffd500; }

/* Zoom-Ansicht */
.kk-lb__zoom {
	position: absolute;
	inset: 0;
	z-index: 2;
	overflow: auto;
	cursor: grab;
	overscroll-behavior: contain;
	touch-action: pan-x pan-y;
}

.kk-lb__zoom.is-dragging { cursor: grabbing; }
.kk-lb__zoom[hidden] { display: none; }

.kk-lb__zoom-inner {
	display: flex;
	justify-content: center;
	align-items: flex-start;
	min-width: 100%;
	min-height: 100%;
	width: max-content;
	margin: 0 auto;
	padding: 20px;
}

.kk-lb__zoom-inner .kk-page { flex: 0 0 auto; box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5); }

.kk-lightbox.is-zoomed .kk-lb__book-host { visibility: hidden; }

/* Seitenübersicht */
.kk-lb__thumbs {
	position: absolute;
	inset: 0;
	z-index: 6;
	overflow: auto;
	padding: 24px;
	background: #151515;
	overscroll-behavior: contain;
}

.kk-lb__thumbs[hidden] { display: none; }

.kk-lb__thumbs-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
	gap: 18px;
	max-width: 1200px;
	margin: 0 auto;
}

.kk-lightbox .kk-thumb {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 6px;
	margin: 0;
	padding: 6px;
	border: 2px solid transparent;
	border-radius: 4px;
	background: transparent;
	color: #fff;
	font: inherit;
	font-size: 0.8rem;
	cursor: pointer;
}

.kk-lightbox .kk-thumb:hover,
.kk-lightbox .kk-thumb:focus-visible { border-color: rgba(255, 255, 255, 0.5); outline: none; background: transparent; color: #fff; }
.kk-lightbox .kk-thumb.is-current { border-color: #ffd500; }

.kk-thumb__img {
	position: relative;
	display: block;
	width: 100%;
	background: #fff;
}

.kk-thumb__img canvas { display: block; width: 100%; height: 100%; }

.kk-sr {
	position: absolute !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}
