/**
 * OGAL Social Share
 *
 * Scoped entirely under .ogal-ss. Uses currentColor by default so the buttons
 * inherit whatever the surrounding theme sets.
 */

/**
 * Layout properties below are declared explicitly rather than left at their
 * initial values. Themes commonly ship low-specificity ambient rules such as
 * `:where(section div) { display:flex; flex-direction:column }` -- those lose
 * to a class selector only for properties we actually declare, so anything
 * left unset would silently inherit the theme's layout.
 */
.ogal-ss {
	--ogal-ss-icon: 20px;
	--ogal-ss-pad: 0.5em;
	--ogal-ss-gap: 0.5em;
	--ogal-ss-radius: 0.25em;
	--ogal-ss-color: currentColor;
	--ogal-ss-border-width: 0;

	display: flex;
	flex-direction: row;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--ogal-ss-gap);
	box-sizing: border-box;
	max-width: 100%;
	/* Fill the inline axis even inside a column flex parent that sets
	   align-items: flex-start, so the alignment option works. */
	align-self: stretch;
}

.ogal-ss__label {
	flex: 0 0 auto;
	width: auto;
	font-weight: 600;
	line-height: 1.2;
}

/* Some plugins and themes append an "external link" marker inside every
   target="_blank" anchor. Suppress it inside share buttons only. */
.ogal-ss__btn > svg:not(.ogal-ss__icon),
.ogal-ss__btn > [class*="external-link"] {
	display: none;
}

.ogal-ss__list {
	display: flex;
	flex-direction: row;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--ogal-ss-gap);
	margin: 0;
	padding: 0;
	list-style: none;
	/* Themes often force `ul { width: 100% }`, which would push the heading
	   onto its own line. */
	width: auto;
	max-width: 100%;
	align-self: auto;
}

.ogal-ss__item {
	display: block;
	width: auto;
	margin: 0;
	padding: 0;
	list-style: none;
}

.ogal-ss__item::before,
.ogal-ss__item::marker {
	content: none;
}

/* ---------- Button ---------- */

.ogal-ss__btn {
	display: inline-flex;
	flex-direction: row;
	align-items: center;
	justify-content: center;
	gap: 0.4em;
	box-sizing: border-box;
	width: auto;
	/* WCAG 2.5.8 Target Size (Minimum). Small icon-only buttons with no box
	   would otherwise sit under 24px and too close together to qualify for the
	   spacing exception. */
	min-width: 24px;
	min-height: 24px;
	padding: var(--ogal-ss-pad);
	border: var(--ogal-ss-border-width) solid var(--ogal-ss-border-color, currentColor);
	border-radius: var(--ogal-ss-radius);
	background: none;
	color: var(--ogal-ss-color);
	font: inherit;
	line-height: 1;
	text-decoration: none;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
	transition: opacity 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

/* Hover is signalled with a background tint rather than reduced opacity --
   fading the icon lowers its contrast against the page, and several brand
   colours have little headroom to give (WhatsApp is 1.98:1 on white at full
   strength). */
.ogal-ss__btn:hover {
	color: var(--ogal-ss-color);
	text-decoration: none;
	background-color: color-mix(in srgb, currentColor 12%, transparent);
	opacity: 1;
}

/* The focus ring must not inherit the brand colour, or a WhatsApp button gets
   a 1.98:1 focus indicator. `color: inherit` drops back to the surrounding
   text colour, whose contrast the theme already guarantees, and currentColor
   then follows it. */
.ogal-ss__btn:focus-visible {
	color: inherit;
	outline: 2px solid currentColor;
	outline-offset: 2px;
	background-color: color-mix(in srgb, currentColor 12%, transparent);
	opacity: 1;
}

.ogal-ss__icon {
	display: block;
	width: var(--ogal-ss-icon);
	height: var(--ogal-ss-icon);
	fill: currentColor;
	flex: none;
}

.ogal-ss__text {
	white-space: nowrap;
}

/* ---------- Size ---------- */

.ogal-ss--size-small {
	--ogal-ss-icon: 16px;
	--ogal-ss-pad: 0.4em;
	--ogal-ss-gap: 0.4em;
	font-size: 0.875em;
}

.ogal-ss--size-medium {
	--ogal-ss-icon: 20px;
}

.ogal-ss--size-large {
	--ogal-ss-icon: 26px;
	--ogal-ss-pad: 0.6em;
	--ogal-ss-gap: 0.6em;
}

/* ---------- Shape ---------- */

.ogal-ss--shape-square {
	--ogal-ss-radius: 0;
}

.ogal-ss--shape-rounded {
	--ogal-ss-radius: 0.25em;
}

.ogal-ss--shape-circle {
	--ogal-ss-radius: 50%;
}

/* "None" strips the box entirely -- bare icons, no padding, no border. */
.ogal-ss--shape-none {
	--ogal-ss-pad: 0;
	--ogal-ss-radius: 0;
	--ogal-ss-border-width: 0;
}

.ogal-ss--shape-none .ogal-ss__btn {
	border: 0;
}

/* A circle only stays circular while the button is square, i.e. icon-only. */
.ogal-ss--shape-circle.ogal-ss--icon-only .ogal-ss__btn {
	aspect-ratio: 1;
}

/* ---------- Border ---------- */

.ogal-ss--bordered:not(.ogal-ss--shape-none) {
	--ogal-ss-border-width: 1px;
	--ogal-ss-border-color: color-mix(in srgb, currentColor 35%, transparent);
}

.ogal-ss--bordered:not(.ogal-ss--shape-none) .ogal-ss__btn:hover {
	--ogal-ss-border-color: currentColor;
}

.ogal-ss--bordered:not(.ogal-ss--shape-none) .ogal-ss__btn:focus-visible {
	--ogal-ss-border-color: currentColor;
}

/* ---------- Colour modes ---------- */

/*
 * In brand mode the brand colour is applied to the icon alone. Applying it to
 * the label text as well produced real contrast failures that depend on the
 * page background and so cannot be fixed with a fixed palette: WhatsApp's
 * #25d366 is 1.98:1 on white, and LinkedIn's #0a66c2 is 3.18:1 on a dark
 * background. Brand marks are exempt from contrast requirements and only need
 * to be recognisable; the text beside them is ordinary text and inherits the
 * theme's colour, whose contrast the theme already guarantees.
 */
.ogal-ss--color-brand .ogal-ss__btn {
	color: inherit;
}

.ogal-ss--color-brand .ogal-ss__icon {
	fill: var(--ogal-ss-color, currentColor);
}

/* ---------- Alignment ---------- */

.ogal-ss--align-left {
	justify-content: flex-start;
}

.ogal-ss--align-center {
	justify-content: center;
}

.ogal-ss--align-right {
	justify-content: flex-end;
}

/* ---------- Labelled variant ---------- */

.ogal-ss--labelled {
	--ogal-ss-gap: 1em;
}

.ogal-ss--labelled.ogal-ss--borderless .ogal-ss__btn,
.ogal-ss--labelled.ogal-ss--shape-none .ogal-ss__btn {
	padding: 0;
}

/* ---------- Copy Link feedback ---------- */

/* Set colour and border-colour directly rather than via --ogal-ss-color:
   in brand/custom mode that custom property is written as an inline style on
   the button, which would outrank any class-level redefinition of it.
   #2e7d32 is 5.13:1 on white. */
/*
 * The success green tints the tick and the outline, not the label. No single
 * fixed green can satisfy 4.5:1 as text on both a white and a dark background
 * -- #2e7d32 measures 5.13:1 on white but 3.52:1 on #161616. As a graphic and
 * a border it only needs 3:1, which it clears on both, so the label stays at
 * the theme's colour and the signal still reads.
 */
.ogal-ss__btn--copy.is-copied,
.ogal-ss__btn--copy.is-copied:hover {
	color: inherit;
	border-color: #2e7d32;
	background-color: transparent;
	opacity: 1;
}

.ogal-ss__btn--copy.is-copied .ogal-ss__icon--check {
	fill: #2e7d32;
}

/* Swap the chain-link glyph for a tick, so success is visible and not only
   announced. The visible text is left alone on purpose -- see the note in
   includes/render.php about WCAG 2.5.3 Label in Name. */
.ogal-ss__icon--check {
	display: none;
}

.ogal-ss__btn--copy.is-copied .ogal-ss__icon--link {
	display: none;
}

.ogal-ss__btn--copy.is-copied .ogal-ss__icon--check {
	display: block;
}

/* Rendered server-side and left empty; never display:none, which would take it
   out of the accessibility tree and stop announcements. */
.ogal-ss__status {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

/* Manual fallback, revealed only when the browser refuses clipboard access. */
.ogal-ss__manual {
	display: flex;
	flex-direction: row;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5em;
	flex-basis: 100%;
	font-size: 0.875em;
}

.ogal-ss__manual[hidden] {
	display: none;
}

.ogal-ss__manual-input {
	flex: 1 1 14em;
	min-width: 0;
	max-width: 100%;
	padding: 0.35em 0.5em;
	border: 1px solid currentColor;
	border-radius: 0.25em;
	background: transparent;
	color: inherit;
	font: inherit;
	font-size: inherit;
}

/* ---------- Forced colours (Windows High Contrast) ---------- */

@media (forced-colors: active) {
	.ogal-ss__btn {
		border-color: currentColor;
	}

	/* Background tints are dropped in forced-colors mode, so hover needs a
	   non-colour cue. */
	.ogal-ss__btn:hover {
		text-decoration: underline;
	}

	.ogal-ss__btn:focus-visible {
		outline: 2px solid CanvasText;
		outline-offset: 2px;
	}

	/* The tick is the only signal that a copy succeeded once colour is gone. */
	.ogal-ss__btn--copy.is-copied {
		outline: 1px solid CanvasText;
	}

	.ogal-ss__icon {
		forced-color-adjust: auto;
	}
}

/* ---------- Motion ---------- */

@media (prefers-reduced-motion: reduce) {
	.ogal-ss__btn {
		transition: none;
	}
}
