/**
 * Gallery Post-It Block Styles (Frontend)
 * Based on Figma Design System - Node 227:2134
 * Exact match from Figma:
 * - Gap: gap-[40px] between top section and thumbnails, gap-[40px] between post-it and main image
 * - Post-It: padding p-[50px], gap gap-[20px]
 * - Main Image: height h-[450px]
 * - Thumbnails: aspect-[393.33/288.44]
 * - Active thumbnail overlay: rgba(30,55,145,0.65)
 */

/* Ensure parent WordPress containers allow overflow for arrows */
.wp-site-blocks:has(.wp-block-kultur-b-digital-gallery-post-it),
.is-layout-constrained:has(.wp-block-kultur-b-digital-gallery-post-it),
.is-layout-flow:has(.wp-block-kultur-b-digital-gallery-post-it),
.entry-content:has(.wp-block-kultur-b-digital-gallery-post-it),
.wp-block-post-content:has(.wp-block-kultur-b-digital-gallery-post-it),
.wp-block-group:has(.wp-block-kultur-b-digital-gallery-post-it) {
	overflow: visible !important;
}

.wp-block-kultur-b-digital-gallery-post-it {
	box-sizing: border-box;
	overflow: visible; /* Allow arrows to be visible outside */
}

.kbd-gallery-post-it__container {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 40px;
	width: 100%;
	overflow: visible; /* Allow arrows to be visible outside */
}

/* Top Section: Post-It + Main Image - inherits parent grid columns via subgrid */
.kbd-gallery-post-it__top {
	grid-column: 1 / -1;
	display: grid;
	grid-template-columns: subgrid;
	align-items: stretch;
}

/* Post-It Box - spans 2 grid columns */
.kbd-gallery-post-it__post-it {
	grid-column: span 2;
	min-width: 0;
	height: 450px;
	overflow: hidden;
	box-sizing: border-box;
}

.kbd-gallery-post-it__post-it.has-secondary-lesetip-background-color {
	background-color: var(--wp--preset--color--secondary-lesetip);
}

.kbd-gallery-post-it__post-it.has-secondary-salmon-background-color {
	background-color: var(--wp--preset--color--secondary-salmon);
}

.kbd-gallery-post-it__post-it.has-secondary-yellow-background-color {
	background-color: var(--wp--preset--color--secondary-yellow);
}

.kbd-gallery-post-it__post-it.has-secondary-green-background-color {
	background-color: var(--wp--preset--color--secondary-green);
}

.kbd-gallery-post-it__post-it-inner {
	display: flex;
	flex-direction: column;
	gap: 20px;
	padding: 50px;
	box-sizing: border-box;
	width: 100%;
	height: 100%;
	overflow: hidden;
	align-items: stretch;
}

/* Header - H3 style from theme.json (28px, weight 700) */
.kbd-gallery-post-it__header {
	font-family: var(--wp--preset--font-family--inter);
	font-size: var(--wp--preset--font-size--h3, 28px);
	font-weight: 700;
	line-height: 1.2;
	color: var(--wp--preset--color--primary-blue);
	margin: 0;
	transition: opacity 0.3s ease;
}

/* Divider */
.kbd-gallery-post-it__divider {
	width: 100%;
	height: 3px !important;
	min-height: 3px !important;
	max-height: 3px !important;
	overflow: visible;
	display: block !important;
	margin: 0;
	padding: 0;
	flex-shrink: 0;
	align-self: stretch;
}

.kbd-gallery-post-it__divider svg {
	display: block !important;
	width: 100%;
	height: 3px !important;
	min-height: 3px !important;
	max-height: 3px !important;
	vertical-align: top;
	margin: 0;
	padding: 0;
}

/* Text */
.kbd-gallery-post-it__text {
	font-family: var(--wp--preset--font-family--inter);
	font-size: var(--wp--preset--font-size--body);
	font-weight: 400;
	line-height: 1.8;
	color: var(--wp--preset--color--primary-blue);
	margin: 0;
	transition: opacity 0.3s ease;
}

/* Main Image - spans 2 grid columns, same height as Post-It */
.kbd-gallery-post-it__main-image {
	grid-column: span 2;
	height: 450px;
	position: relative;
	overflow: hidden;
	box-sizing: border-box;
}

.kbd-gallery-post-it__main-image img {
	width: 100% !important;
	height: 100% !important;
	object-fit: cover !important;
	object-position: center center !important;
	display: block;
	transition: opacity 0.3s ease;
}

.kbd-gallery-post-it__main-image .kbd-gallery-post-it__placeholder {
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	background-color: var(--wp--preset--color--contrast);
	color: var(--wp--preset--color--base);
	font-family: var(--wp--preset--font-family--inter);
	font-size: 16px;
}

/* Thumbnails Wrapper - Position context for arrows outside, subgrid to pass columns through */
.kbd-gallery-post-it__thumbnails-wrapper {
	grid-column: 1 / -1;
	display: grid;
	grid-template-columns: subgrid;
	position: relative;
	overflow: visible; /* Allow arrows to be visible outside */
}

/* Thumbnails Section - inherits parent grid columns via subgrid */
.kbd-gallery-post-it__thumbnails {
	grid-column: 1 / -1;
	display: grid;
	grid-template-columns: subgrid;
}

.kbd-gallery-post-it__thumbnails::-webkit-scrollbar {
	display: none; /* Chrome, Safari, Opera */
}

/* Focus state for keyboard accessibility (WCAG 2.1.1, 2.1.3) */
.kbd-gallery-post-it__thumbnails:focus {
	outline: 3px solid var(--wp--preset--color--primary-blue);
	outline-offset: 2px;
}

.kbd-gallery-post-it__thumbnails:focus-visible {
	outline: 3px solid var(--wp--preset--color--primary-blue);
	outline-offset: 2px;
}

/* Arrow Buttons - Absolutely positioned OUTSIDE the thumbnails area */
.kbd-gallery-post-it__arrow {
	background: var(--wp--preset--color--primary-white);
	border: 3px solid var(--wp--preset--color--primary-blue);
	cursor: pointer;
	width: 60px;
	height: 60px;
	min-width: 60px;
	min-height: 60px;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background-color 0.2s ease;
	flex-shrink: 0;
	padding: 0;
	margin: 0;
	box-sizing: border-box;
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	z-index: 10;
}

/* Left arrow: positioned outside left edge (arrow width + gap) */
.kbd-gallery-post-it__arrow--prev {
	left: -100px;
}

/* Right arrow: positioned outside right edge (arrow width + gap) */
.kbd-gallery-post-it__arrow--next {
	right: -100px;
}

/* Beim Ueberfahren blau fuellen und den Pfeil weiss zeichnen - dasselbe
   Muster wie die Paginierungs-Pfeile (neuste-artikel/style.css). Vorher wurde
   die Flaeche nur aufgehellt, was neben den Paginierungen uneinheitlich
   wirkte (#63). Das `stroke="#1E3791"` im SVG ist ein Praesentations-Attribut
   und laesst sich per CSS ueberschreiben. */
.kbd-gallery-post-it__arrow:hover:not(:disabled),
.kbd-gallery-post-it__arrow:focus-visible:not(:disabled) {
	background-color: var(--wp--preset--color--primary-blue);
}

.kbd-gallery-post-it__arrow:hover:not(:disabled) svg path,
.kbd-gallery-post-it__arrow:focus-visible:not(:disabled) svg path {
	stroke: var(--wp--preset--color--primary-white);
}

.kbd-gallery-post-it__arrow:disabled {
	visibility: hidden;
}

.kbd-gallery-post-it__arrow svg {
	display: block;
	width: 27px;
	height: 25px;
}

/* Thumbnail - fills grid column, maintains aspect ratio */
.kbd-gallery-post-it__thumbnail {
	width: 100%;
	aspect-ratio: 270 / 200;
	position: relative;
	cursor: pointer;
	overflow: hidden;
	transition: opacity 0.3s ease;
}

.kbd-gallery-post-it__thumbnail:hover {
	opacity: 0.8;
}

.kbd-gallery-post-it__thumbnail img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.kbd-gallery-post-it__thumbnail-overlay {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	/* rgba equivalent of primary-blue (#1e3791) with 65% opacity */
	background-color: rgba(30, 55, 145, 0.65);
	pointer-events: none;
	opacity: 0;
	transition: opacity 0.3s ease;
}

.kbd-gallery-post-it__thumbnail.is-active .kbd-gallery-post-it__thumbnail-overlay {
	opacity: 1;
}

.kbd-gallery-post-it__thumbnail-placeholder {
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	background-color: var(--wp--preset--color--contrast);
	color: var(--wp--preset--color--base);
	font-family: var(--wp--preset--font-family--inter);
	font-size: 18px;
	font-weight: 600;
}

/* ===========================================
   RESPONSIVE BREAKPOINTS
   Einheitliches System: 1440px, 1024px, 768px, 480px
   =========================================== */

/* Large Desktop - Sanfte Reduktion */
@media (max-width: 1440px) {
	.kbd-gallery-post-it__container {
		gap: 30px;
	}

	/* __top and __thumbnails inherit gap from container via subgrid */

	.kbd-gallery-post-it__post-it-inner {
		padding: 40px;
		gap: 18px;
	}

	.kbd-gallery-post-it__text {
		font-size: 17px;
	}
}

/* Desktop/Tablet Landscape - Stacked Layout mit Grid-Pfeilen */
@media (max-width: 1024px) {
	.kbd-gallery-post-it__container {
		grid-template-columns: 1fr 1fr;
		gap: 24px;
	}

	/* Top Section: single column stacked - override subgrid */
	.kbd-gallery-post-it__top {
		grid-column: 1 / -1;
		grid-template-columns: 1fr;
		gap: 24px;
	}

	.kbd-gallery-post-it__post-it {
		grid-column: 1;
		height: auto;
	}

	.kbd-gallery-post-it__post-it-inner {
		padding: 40px;
		gap: 16px;
	}

	.kbd-gallery-post-it__text {
		font-size: 17px;
		line-height: 1.7;
	}

	.kbd-gallery-post-it__main-image {
		grid-column: 1;
		height: 450px;
	}

	/* Hide thumbnails on tablet */
	.kbd-gallery-post-it__thumbnails {
		display: none !important;
	}

	/* Thumbnails Wrapper: arrows as 2-column grid - override subgrid */
	.kbd-gallery-post-it__thumbnails-wrapper {
		grid-column: 1 / -1;
		position: static;
		display: grid !important;
		grid-template-columns: 1fr 1fr;
		gap: 20px;
	}

	/* Arrows: Grid positioned, 50/50 */
	.kbd-gallery-post-it__arrow {
		position: static;
		width: 100%;
		height: 60px;
		transform: none;
	}

	.kbd-gallery-post-it__arrow--prev {
		grid-column: 1;
		left: auto;
	}

	.kbd-gallery-post-it__arrow--next {
		grid-column: 2;
		right: auto;
	}

	.kbd-gallery-post-it__arrow svg {
		width: 24px;
		height: 22px;
	}
}

/* Tablet Portrait */
@media (max-width: 768px) {
	.kbd-gallery-post-it__container {
		grid-template-columns: 1fr 1fr;
		gap: 20px;
	}

	/* Override subgrid for single-column layout */
	.kbd-gallery-post-it__top {
		grid-column: 1 / -1;
		grid-template-columns: 1fr;
		gap: 16px;
	}

	.kbd-gallery-post-it__post-it-inner {
		padding: 28px;
		gap: 12px;
	}

	.kbd-gallery-post-it__text {
		font-size: 16px;
		line-height: 1.6;
	}

	.kbd-gallery-post-it__main-image {
		height: 400px;
	}

	/* Hide thumbnails on tablet */
	.kbd-gallery-post-it__thumbnails {
		display: none !important;
	}

	/* Override subgrid for arrow layout */
	.kbd-gallery-post-it__thumbnails-wrapper {
		grid-column: 1 / -1;
		position: static;
		display: grid !important;
		grid-template-columns: 1fr 1fr;
		gap: 20px;
	}

	.kbd-gallery-post-it__arrow svg {
		width: 22px;
		height: 20px;
	}
}

/* Mobile */
@media (max-width: 480px) {
	.kbd-gallery-post-it__top {
		gap: 12px;
	}

	.kbd-gallery-post-it__post-it-inner {
		padding: 30px 20px;
		gap: 10px;
	}

	.kbd-gallery-post-it__text {
		font-size: 15px;
		line-height: 1.5;
	}

	.kbd-gallery-post-it__main-image {
		height: 350px;
	}

	.kbd-gallery-post-it__arrow svg {
		width: 20px;
		height: 18px;
	}
}
