/*
 * DHI Vienna: [instagram-feed] (Smash Balloon). Loaded where "sb_instagram" / "sbi_images" print (site/plugin-views.php,
 * entry dhi-instagram), after sbi-tokens-local and sbi-styles (dependency added at print time).
 *
 * Board: .d-profile (profile card) and .d-insta (8 / 4 square tiles, caption of two lines under each tile; 3 x 3 below
 * 768 px, K20), Load more as the outline pill, Follow as the teal pill (design C1).
 *
 * Consent is untouched: Borlabs' script blocker still holds the plugin's script back until the Instagram service is
 * accepted; nothing here requests anything. Before consent the plugin leaves every tile at opacity 0 and the image on
 * its own placeholder.png; here the tiles show as tinted squares with the camera icon (the board's .d-insta__ph), so
 * the section is never an empty hole, and the real picture replaces the square when the script has run. The profile
 * picture is a file of the site's own uploads (uploads/sb-instagram-feed-images/), a first-party request.
 *
 * Plugin selectors carry #sb_instagram (an id); every selector here starts with "html #sb_instagram".
 * !important only where the plugin forces it inline or with !important (marked).
 */

html #sb_instagram {
	color: var(--wp--preset--color--contrast);
	font-family: inherit;
}

/* ---------- profile card (.d-profile) ---------- */

html #sb_instagram .sb_instagram_header {
	box-sizing: border-box;
	max-width: 47.5rem;
	margin: 0 0 var(--wp--preset--spacing--30);
	padding: 1rem 1.5rem;
	overflow: hidden;
	border-radius: var(--wp--custom--radius--medium);
	background: var(--wp--preset--color--base-2);
	box-shadow: var(--wp--preset--shadow--soft);
}

html #sb_instagram .sb_instagram_header .sbi_header_link {
	display: block;
	color: var(--wp--preset--color--contrast);
}

html #sb_instagram .sb_instagram_header .sbi_header_link:hover h3 {
	color: var(--wp--preset--color--primary);
}

html #sb_instagram .sb_instagram_header .sbi_header_text {
	align-items: center;
	gap: 1rem;
}

html #sb_instagram .sb_instagram_header:is(.sbi_medium, .sbi_large) .sbi_header_img,
html #sb_instagram .sb_instagram_header:is(.sbi_medium, .sbi_large) .sbi_header_img img {
	width: 3.5rem;
	height: 3.5rem;
	border-radius: var(--wp--custom--radius--pill);
	background: var(--wp--preset--color--primary);
}

html #sb_instagram .sb_instagram_header .sbi_header_img img {
	object-fit: cover;
}

html #sb_instagram .sb_instagram_header .sbi_header_img_hover {
	background: color-mix(in srgb, var(--wp--preset--color--primary) 85%, transparent);
	color: var(--wp--preset--color--primary-contrast);
}

html #sb_instagram .sb_instagram_header .sbi_header_text h3 {
	color: var(--wp--preset--color--contrast);
	font-size: var(--wp--preset--font-size--medium);
	font-weight: var(--wp--custom--typography--font-weight--label);
	line-height: 1.4;
	transition: color var(--wp--custom--transition--base);
}

html #sb_instagram .sb_instagram_header .sbi_header_text .sbi_bio {
	color: var(--wp--preset--color--contrast);
	font-size: 0.9375rem;
	line-height: 1.5;
}

/* ---------- tiles (.d-insta) ---------- */

html #sb_instagram.sbi #sbi_images {
	grid-template-columns: repeat(8, minmax(0, 1fr));
	gap: 0.75rem !important; /* the plugin writes gap:10px inline (style attribute) */
	padding: var(--wp--preset--spacing--30) 0;
}

html #sb_instagram #sbi_images .sbi_item {
	overflow: visible;
}

/* Before the script has run the plugin hides the tile (opacity 0): show the square instead. */
html #sb_instagram #sbi_images .sbi_item.sbi_transition {
	opacity: 1;
}

html #sb_instagram .sbi_photo_wrap {
	overflow: visible;
}

html #sb_instagram .sbi_photo {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	grid-template-rows: auto auto;
	gap: 0.5rem;
	color: var(--wp--preset--color--contrast);
	font-size: var(--wp--preset--font-size--x-small);
	line-height: 1.4;
	overflow-wrap: anywhere;
	transition: color var(--wp--custom--transition--base);
}

html #sb_instagram .sbi_photo:hover,
html #sb_instagram .sbi_photo:focus-visible {
	color: var(--wp--preset--color--primary);
}

/* The square: tinted, behind the picture (same grid cell). */
html #sb_instagram .sbi_photo::before {
	content: "";
	grid-area: 1 / 1;
	aspect-ratio: 1 / 1;
	border-radius: var(--wp--custom--radius--small);
	background: var(--wp--preset--color--tint);
}

html #sb_instagram .sbi_photo img {
	grid-area: 1 / 1;
	width: 100%;
	height: auto;
	aspect-ratio: 1 / 1;
	object-fit: cover;
	border-radius: var(--wp--custom--radius--small);
}

/* The plugin's own placeholder file is never shown: the tinted square and the icon stand in. */
html #sb_instagram .sbi_photo img[src*="instagram-feed/img/placeholder"] {
	opacity: 0 !important; /* the plugin sets img opacity 1 !important */
}

html #sb_instagram .sbi_photo:has(img[src*="instagram-feed/img/placeholder"])::after {
	content: "";
	grid-area: 1 / 1;
	place-self: center;
	width: 1.75rem;
	height: 1.75rem;
	background-color: var(--wp--preset--color--primary);
	-webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8'><rect x='3' y='3' width='18' height='18' rx='5'/><circle cx='12' cy='12' r='4'/><circle cx='17.5' cy='6.5' r='1' fill='black' stroke='none'/></svg>") center / contain no-repeat;
	mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8'><rect x='3' y='3' width='18' height='18' rx='5'/><circle cx='12' cy='12' r='4'/><circle cx='17.5' cy='6.5' r='1' fill='black' stroke='none'/></svg>") center / contain no-repeat;
}

/* Caption under the tile: the plugin's screen-reader text (the first words of the post), two lines, as the board.
   The plugin hides it with width, height, line-height, overflow and text-indent, all !important. */
html #sb_instagram .sbi_photo .sbi-screenreader {
	grid-area: 2 / 1;
	width: auto !important;
	height: auto !important;
	overflow: hidden !important;
	display: -webkit-box !important;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	line-clamp: 2;
	line-height: 1.4 !important;
	text-indent: 0 !important;
}

/* Video and carousel marks keep the plugin's icons, tinted to the page. */
html #sb_instagram .sbi_type_carousel .sbi_playbtn,
html #sb_instagram .sbi_type_video .sbi_playbtn {
	color: var(--wp--preset--color--primary-contrast);
}

/* ---------- load more (.d-btn--outline) and follow (.d-btn--primary) ---------- */

html #sb_instagram #sbi_load {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 0.75rem;
	float: none;
}

html #sb_instagram #sbi_load .sbi_load_btn,
html #sb_instagram #sbi_load .sbi_follow_btn a {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5em;
	box-sizing: border-box;
	min-height: 3rem;
	margin: 0;
	padding: 0.7em 1.35em;
	border: 1px solid var(--wp--preset--color--primary);
	border-radius: var(--wp--custom--radius--pill);
	font-family: var(--wp--preset--font-family--heading);
	font-size: 1rem;
	font-weight: 600;
	letter-spacing: 0.005em;
	line-height: 1.1;
	text-decoration: none;
	text-transform: none;
	cursor: pointer;
	transition:
		background-color var(--wp--custom--transition--base),
		color var(--wp--custom--transition--base),
		box-shadow var(--wp--custom--transition--base),
		transform var(--wp--custom--transition--base);
}

html #sb_instagram #sbi_load .sbi_follow_btn {
	margin: 0;
}

html #sb_instagram #sbi_load .sbi_load_btn {
	border-color: var(--wp--preset--color--border-strong);
	background: var(--wp--preset--color--base);
	color: var(--wp--custom--color--teal-950);
}

html #sb_instagram #sbi_load .sbi_load_btn:hover,
html #sb_instagram #sbi_load .sbi_load_btn:focus-visible {
	border-color: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--primary-2);
	box-shadow: none;
}

/* The plugin writes the follow button's colour into the element (a blue in its style attribute). */
html #sb_instagram #sbi_load .sbi_follow_btn a {
	background: var(--wp--preset--color--primary) !important;
	color: var(--wp--preset--color--primary-contrast);
}

html #sb_instagram #sbi_load .sbi_follow_btn a:hover,
html #sb_instagram #sbi_load .sbi_follow_btn a:focus-visible {
	background: var(--wp--preset--color--primary-2) !important;
}

@media (hover: hover) {
	html #sb_instagram #sbi_load .sbi_follow_btn a:hover {
		transform: translateY(-2px);
	}
}

html #sb_instagram #sbi_load .sbi_follow_btn svg {
	margin: 0;
}

/* The spinner dot of the load button (inline white background from the plugin). */
html #sb_instagram #sbi_load .sbi_loader {
	background-color: var(--wp--preset--color--primary-contrast) !important;
}

html #sb_instagram :is(a, button):focus-visible {
	outline: 3px solid var(--wp--preset--color--primary) !important; /* the plugin's own ring is !important */
	outline-offset: 3px !important;
}

/* ---------- breakpoints (board: 980 four tiles; 767 three, K20) ---------- */

@media (max-width: 980px) {
	html #sb_instagram.sbi #sbi_images {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}
}

/* Phones (K20): 3 x 3 tiles, complete with the plugin's 10 (below 480 px) or 16; "Load more" would only add hidden
   tiles, so it is hidden here; Follow stays. The plugin's own counts (16 / 10) are untouched. */
@media (max-width: 767px) {
	html #sb_instagram.sbi #sbi_images {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}

	html #sb_instagram #sbi_images > .sbi_item:nth-child(n + 10),
	html #sb_instagram #sbi_load .sbi_load_btn {
		display: none;
	}

	html #sb_instagram .sb_instagram_header .sbi_header_text {
		align-items: flex-start;
	}
}

/* A phone turned to landscape after a portrait load: the plugin keeps its 10 phone tiles (11 to 16 carry
   sbi_num_diff_hide), so from 768 px 8 of them show: two complete rows of four, or one row of eight. */
@media (min-width: 768px) {
	html #sb_instagram #sbi_images:has(> .sbi_num_diff_hide) > .sbi_item:nth-child(n + 9) {
		display: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	html #sb_instagram #sbi_load .sbi_follow_btn a:hover {
		transform: none;
	}
}
