/*
 * Glass 4 Me widgets: core rules every site needs (list resets, readable rich text, keyboard focus,
 * the lightbox, forced colors and reduced motion). The look is in glass4me-widgets.css, which a theme
 * can turn off with add_theme_support( 'glass4me-widget-styles' ) when it styles the widgets itself.
 */

/* Lists that are styled as grids or rows */
:where(.g4m-stats, .g4m-dl-box__specs, .g4m-hero__highlights, .g4m-card__highlights) {
	list-style: none;
	margin: 0;
	padding: 0;
}
:where(.g4m-faq summary) {
	cursor: pointer;
}

/* "Solid (no glass)" chosen in a widget's Glass section. It must win over sitewide glass, so it uses
   !important on the few properties that make glass. Themes set --g4m-w-solid and --g4m-w-solid-ink. */
.g4m-solid {
	background: var(--g4m-w-solid, Canvas) !important;
	color: var(--g4m-w-solid-ink, CanvasText) !important;
	-webkit-backdrop-filter: none !important;
	backdrop-filter: none !important;
}
.g4m-solid::before,
.g4m-solid::after {
	display: none !important;
}

/* Alignment chosen in the panel: two classes, so it wins over a theme's own one-class layout. */
.g4m-actions.g4m-actions--start {
	justify-content: flex-start;
}
.g4m-actions.g4m-actions--center {
	justify-content: center;
}
.g4m-actions.g4m-actions--end {
	justify-content: flex-end;
}
.g4m-head.g4m-head--center {
	text-align: center;
	justify-content: center;
}
.g4m-head.g4m-head--center > div,
.g4m-head.g4m-head--center :is(.g4m-head__title, .g4m-head__text) {
	margin-inline: auto;
}

/* Whole card clickable: the title link is stretched over the card, so there is still one real link. */
.g4m-card--linked {
	position: relative;
}
.g4m-card--linked .g4m-card__title a::after {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: inherit;
}
.g4m-card--linked:focus-within {
	outline: 3px solid var(--g4m-w-focus, var(--e-global-color-accent, #5b4bdb));
	outline-offset: 3px;
}
.g4m-card--linked .g4m-card__title a:focus-visible {
	outline: none;
}

/* Paragraphs inside rich text: one class of specificity, so a theme's plain "p" margins do not win. */
.g4m-hero__lead p,
.g4m-card__desc p,
.g4m-panel__body p,
.g4m-form-lead p,
.g4m-faq__answer p {
	margin: 0 0 .7em;
}
.g4m-hero__lead > :last-child,
.g4m-card__desc > :last-child,
.g4m-panel__body > :last-child,
.g4m-form-lead > :last-child,
.g4m-faq__answer > :last-child {
	margin-bottom: 0;
}

/* Visible keyboard focus */
:where(.g4m-btn:focus-visible, .g4m-hero a:focus-visible, .g4m-card a:focus-visible, .g4m-crumbs a:focus-visible, .g4m-shot__media:focus-visible, .g4m-shot__btn:focus-visible, .g4m-faq summary:focus-visible, .g4m-lightbox button:focus-visible, .g4m-lightbox a:focus-visible) {
	outline: 3px solid var(--g4m-w-focus, var(--e-global-color-accent, #5b4bdb));
	outline-offset: 3px;
}

/* Lightbox: a native dialog, so focus stays inside and Escape closes it */
:where(.g4m-lightbox) {
	width: min(96vw, 1400px);
	max-width: none;
	max-height: 94vh;
	padding: 0;
	border: 1px solid rgb(255 255 255 / 18%);
	border-radius: 20px;
	background: #111015;
	color: #f6f4ef;
	overflow: hidden;
}
:where(.g4m-lightbox)::backdrop {
	background: rgb(10 9 14 / 78%);
	-webkit-backdrop-filter: blur(6px);
	backdrop-filter: blur(6px);
}
:where(.g4m-lightbox__bar) {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 12px 16px;
	border-bottom: 1px solid rgb(255 255 255 / 12%);
}
:where(.g4m-lightbox__title) {
	margin: 0;
	font-size: .95rem;
	font-weight: 600;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
:where(.g4m-lightbox__tools) {
	display: flex;
	gap: 8px;
	flex: none;
}
:where(.g4m-lightbox__tools a, .g4m-lightbox__tools button) {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	padding: 8px 18px;
	border-radius: 999px;
	border: 1px solid rgb(255 255 255 / 28%);
	background: transparent;
	color: inherit;
	font: inherit;
	font-size: .88rem;
	font-weight: 600;
	text-decoration: none;
	cursor: pointer;
}
:where(.g4m-lightbox__frame) {
	overflow: auto;
	max-height: calc(94vh - 70px);
}
:where(.g4m-lightbox__frame img) {
	display: block;
	width: 100%;
	height: auto;
}

/* Windows high contrast and other forced color modes: keep every edge visible */
@media (forced-colors: active) {
	:where(.g4m-hero, .g4m-card, .g4m-stat, .g4m-faq details, .g4m-panel, .g4m-dl-box, .g4m-shot, .g4m-btn, .g4m-badge) {
		border: 1px solid CanvasText;
	}
}

@media (prefers-reduced-motion: reduce) {
	:where(.g4m-btn, .g4m-shot__media img, .g4m-faq summary)::after,
	:where(.g4m-btn, .g4m-shot__media img) {
		transition: none;
	}
	:where(.g4m-btn:hover, .g4m-shot:hover .g4m-shot__media img) {
		transform: none;
	}
}
