/*
 * Gamelade Image Caption
 * Front-end caption styling for Classic Editor and Gutenberg.
 */

:root {
	--gic-accent: #0875E1;
	--gic-caption-text: #566273;
	--gic-caption-bg: #F1F6FC;
	--gic-caption-size: 13px;
}

/* Classic Editor caption wrapper: shrink to the image width. */
body .wp-caption {
	display: table;
	width: fit-content !important;
	max-width: 100% !important;
	box-sizing: border-box;
}

/* Keep the image responsive and aligned with its caption. */
body .wp-caption img {
	display: block;
	max-width: 100%;
	height: auto;
	margin: 0 auto;
}

/* Gutenberg image figures should follow the rendered image width. */
body figure.wp-block-image:not(.alignwide):not(.alignfull) {
	width: fit-content;
	max-width: 100%;
	box-sizing: border-box;
}

body figure.wp-block-image img {
	display: block;
	max-width: 100%;
	height: auto;
}

/* Shared caption appearance. */
body .wp-caption > .wp-caption-text,
body figure.wp-block-image > figcaption,
body .wp-block-gallery .wp-block-image figcaption,
body .gallery-caption {
	display: block;
	position: static;
	inset: auto;
	transform: none;
	box-sizing: border-box;
	width: 100%;
	max-width: 100%;
	margin: 0 auto !important;
	padding: 9px 14px 10px !important;
	border: 0;
	border-top: 2px solid var(--gic-accent);
	border-radius: 0 0 6px 6px;
	background: var(--gic-caption-bg);
	color: var(--gic-caption-text) !important;
	font-size: var(--gic-caption-size);
	font-weight: 500;
	font-style: normal;
	line-height: 1.55;
	letter-spacing: 0.005em;
	text-align: center !important;
	text-transform: none;
	text-shadow: none;
	box-shadow: 0 3px 12px rgba(20, 40, 65, 0.045);
	overflow-wrap: anywhere;
}

/* Links in photo credits remain clear and on-brand. */
body .wp-caption-text a,
body figure.wp-block-image figcaption a,
body .gallery-caption a {
	color: var(--gic-accent) !important;
	font-weight: 600;
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 2px;
}

body .wp-caption-text a:hover,
body figure.wp-block-image figcaption a:hover,
body .gallery-caption a:hover {
	text-decoration-thickness: 2px;
}

/* Center ordinary, non-floated classic captions without breaking left/right alignment. */
body .wp-caption:not(.alignleft):not(.alignright) {
	margin-left: auto !important;
	margin-right: auto !important;
}

/* Preserve the theme's intended wide/full image layouts. */
body figure.wp-block-image.alignwide,
body figure.wp-block-image.alignfull {
	width: auto;
}

/* Smaller screens: keep captions legible without taking too much space. */
@media (max-width: 600px) {
	body .wp-caption > .wp-caption-text,
	body figure.wp-block-image > figcaption,
	body .wp-block-gallery .wp-block-image figcaption,
	body .gallery-caption {
		padding: 8px 11px 9px !important;
		line-height: 1.5;
	}
}
