/*!
 * WP-ImmoMakler gallery — image-element normalisation (shared base).
 *
 * Loaded as a dependency of every gallery preset stylesheet (see
 * HookInitializer::register_available_styles_scripts). Its sole job is to keep
 * the gallery layout intact when a third-party image-optimization plugin
 * (WebP/AVIF converters such as Converter for Media, ShortPixel, Optimole,
 * EWWW, ...) rewrites our markup.
 *
 * Our presets render a single `<img class="immomakler-gallery__image">` per
 * slide (via wp_get_attachment_image()) and size THAT element to fill its
 * slide. Optimizers commonly wrap the `<img>` in a `<picture>` that offers a
 * WebP/AVIF `<source>`, and many of them MOVE the class onto the `<picture>`,
 * leaving the inner `<img>` bare:
 *
 *   <picture class="immomakler-gallery__image">
 *     <source type="image/webp" srcset="...">
 *     <img src="..." width="100" height="75">   <-- no class, no sizing
 *   </picture>
 *
 * A `<picture>` is a non-replaced inline box: width/height/object-fit neither
 * size it nor reach its child, so the bare `<img>` falls back to its native
 * attribute size — thumbnails shrink away from their slide and main images
 * stop covering. (Confirmed on leonhard-immobilien.de: an optimizer-wrapped
 * horizontal-thumbs gallery rendered its <img> at native 100x75 / inline /
 * object-fit: fill inside a 147x110 slide, while an un-wrapped gallery on the
 * same site rendered correctly at 147x110 / object-fit: cover — the optimizer
 * only wraps some galleries, so the breakage is intermittent per property.)
 *
 * Fix: treat any `<picture>` inside a gallery as a transparent, box-filling
 * wrapper and let its inner `<img>` cover — independent of where the optimizer
 * left the class. The preset rules keep sizing .immomakler-gallery__image
 * (which, with the class on the `<picture>`, IS that `<picture>`); this base
 * file only adds the missing `display: block` (so the preset's height: 100%
 * applies to the now-block `<picture>`) and propagates the fill + cover to the
 * real `<img>`. `object-fit: cover` matches every preset — all gallery image
 * areas crop with cover. Galleries only ever contain image `<picture>`
 * elements, so the broad `.immomakler-gallery picture` scope is safe;
 * lightgallery's lightbox overlay is appended to `<body>`, outside this scope.
 */

.immomakler-gallery picture {
	display: block;
	width: 100%;
	height: 100%;
}

.immomakler-gallery picture > img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/*
 * The prev/next and thumb-strip navigation controls are real <button>s:
 * aria-label is a prohibited ARIA attribute on a plain <div> (implicit generic
 * role), and a button is natively keyboard-operable (the presets already carry
 * :focus-visible styles). Strip the native button chrome here — every preset
 * loads this base file — so the per-preset sizing/positioning and the
 * ::before/::after arrow art render exactly as before.
 *
 * Themes style buttons far more aggressively than the browser does, and two
 * details decide whether this reset actually wins against them:
 *
 * 1. Specificity, not source order. Themes commonly reset buttons through the
 *    ATTRIBUTE selector `[type=button]` — Hello Elementor's reset.css does —
 *    which weighs (0,1,0), exactly as much as a bare
 *    `.immomakler-gallery__prev`. A tie goes to whichever stylesheet comes
 *    last, and the theme is always enqueued after the plugin, so the theme
 *    won: on Hello Elementor the prev/next click zones shipped with its
 *    `1px solid #c36` border and `0.5rem 1rem` padding, and the thumb-strip
 *    arrows with its `border-radius: 3px`. Scoping every selector to the
 *    `.immomakler-gallery` wrapper lifts the reset to (0,2,0) and settles it
 *    independently of enqueue order.
 *
 * 2. The interactive states have to be named explicitly. `[type=button]:hover`
 *    weighs (0,2,0) and therefore outranks even the presets' own (0,2,0) base
 *    rules, so hovering a nav button painted the whole click zone `#c36`.
 *    Re-asserting the same values under `:is( :hover, :focus, :focus-visible,
 *    :active )` lands at (0,3,0) and holds each button's own look through
 *    every state.
 *
 * Properties a preset legitimately varies stay out of the state rules —
 * `transition` and `font` (whose shorthand carries line-height, which the
 * vertical preset sets on its thumb-nav) are declared base-only, where the
 * presets' later (0,2,0) rules still override them.
 */
.immomakler-gallery :is(.immomakler-gallery__prev, .immomakler-gallery__next, .immomakler-gallery__thumbs-prev, .immomakler-gallery__thumbs-next) {
	appearance: none;
	-webkit-appearance: none;
	margin: 0;
	border-radius: 0;
	font: inherit;
	transition: none;
}

.immomakler-gallery :is(.immomakler-gallery__prev, .immomakler-gallery__next, .immomakler-gallery__thumbs-prev, .immomakler-gallery__thumbs-next),
.immomakler-gallery :is(.immomakler-gallery__prev, .immomakler-gallery__next, .immomakler-gallery__thumbs-prev, .immomakler-gallery__thumbs-next):is(:hover, :focus, :focus-visible, :active) {
	padding: 0;
	border: 0;
	box-shadow: none;
	text-decoration: none;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}

/*
 * Background and text colour are stated per button family, because the two
 * families genuinely differ: the main prev/next element is only a hit area —
 * its visible art is the `::before` circle, so the box itself is transparent —
 * while the thumb-strip arrows ARE the visible bar. Both read the
 * gallery-level custom properties, so a skin or Customizer override still
 * flows through, and the thumb presets' disabled-state keyframes still win
 * over these declarations (CSS animations outrank normal author rules).
 */
.immomakler-gallery :is(.immomakler-gallery__prev, .immomakler-gallery__next),
.immomakler-gallery :is(.immomakler-gallery__prev, .immomakler-gallery__next):is(:hover, :focus, :focus-visible, :active) {
	background-color: transparent;
	color: var(--immomakler-gallery-primary-color-inverted, #fff);
}

.immomakler-gallery :is(.immomakler-gallery__thumbs-prev, .immomakler-gallery__thumbs-next),
.immomakler-gallery :is(.immomakler-gallery__thumbs-prev, .immomakler-gallery__thumbs-next):is(:hover, :focus, :focus-visible, :active) {
	background-color: var(--immomakler-gallery-primary-color, #af1615);
	color: var(--immomakler-gallery-primary-color-inverted, #fff);
}
