/* =============================================================================
   Wijkkrant Delen — share buttons in the read-aloud bar
   -----------------------------------------------------------------------------
   This stylesheet does two things:

   1. The share buttons themselves.
   2. A handful of corrections to the existing read-aloud bar, so that the bar
      becomes one row: read aloud on the left, share on the right, status below.
      The corrections live here on purpose, not in voorlezen.css, so a new
      read-aloud version overwrites nothing of this plugin and vice versa.

   Contrast: ink (#1B1B18) on white = 16.5:1, white on green #3B7320 = 5.7:1.
   Hit area of every button: 32 × 32 px (WCAG 2.5.8 AA requires ≥ 24 × 24 px).
   ========================================================================== */

.wk-voorlezen,
.wk-delen-los {
	/* Small corner radius for all buttons in the bar: buttons, select, share. */
	--wk-hoek: 4px;
	--wk-delen-groen: var( --wk-a11y-groen, #3B7320 );
	--wk-delen-inkt: var( --wp--preset--color--inkt, #1B1B18 );
	--wk-delen-lijn: var( --wp--preset--color--lijn, #DCDAD2 );
}

/* -----------------------------------------------------------------------------
   1. The bar as one row
   -------------------------------------------------------------------------- */

.wk-voorlezen {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	column-gap: 0.75rem;
	row-gap: 0.4rem;

	/* The bar measures itself, not the browser window: in the two-column view
	   the article column is narrower than the screen. */
	container-type: inline-size;
	container-name: wk-balk;
}

.wk-voorlezen[hidden] {
	display: none;
}

/* Order independent of the order in the HTML: the status belongs at the
   bottom, even though it comes before the share buttons in the source. */
.wk-voorlezen .wk-voorlezen__knoppen {
	order: 1;
}

.wk-voorlezen .wk-delen {
	order: 2;
	margin-left: auto; /* pushes the share buttons to the right */
}

.wk-voorlezen .wk-voorlezen__status {
	order: 3;
	flex-basis: 100%;
	margin-block: 0;
}

.wk-voorlezen .wk-voorlezen__audio {
	order: 1;
	flex: 1 1 18rem;
}

.wk-voorlezen .wk-voorlezen__hulp {
	order: 3;
	flex-basis: 100%;
	margin-block: 0;
}

/* When the column gets narrow, the share buttons move to their own line
   below, aligned left with the read-aloud buttons. */
@container wk-balk ( max-width: 34rem ) {
	.wk-voorlezen .wk-delen {
		flex-basis: 100%;
		margin-left: 0;
	}
}

/* Fallback for browsers without container queries (before 2023). */
@supports not ( container-type: inline-size ) {
	@media ( max-width: 48rem ) {
		.wk-voorlezen .wk-delen {
			flex-basis: 100%;
			margin-left: 0;
		}
	}
}

/* -----------------------------------------------------------------------------
   2. Corrections to the read-aloud buttons
   Everything the same height (32 px), everything the same small corner, and
   the text neatly centred: line-height 1 removes the extra space above the
   serif typeface, so the label no longer sits too high in the button.
   -------------------------------------------------------------------------- */

.wk-voorlezen .wk-voorlezen__knop,
.wk-voorlezen .wk-voorlezen__snelheid select {
	min-height: 2rem;
	border-radius: var( --wk-hoek );
	line-height: 1;
}

.wk-voorlezen .wk-voorlezen__knop {
	align-items: center;
	padding-block: 0;
	padding-inline: 0.7rem;
	gap: 0.4rem;
}

.wk-voorlezen .wk-voorlezen__knop > span {
	display: block;
	line-height: 1;
}

.wk-voorlezen .wk-voorlezen__icoon {
	display: block;
	flex: 0 0 auto;
}

.wk-voorlezen .wk-voorlezen__snelheid select {
	padding-block: 0;
	padding-inline: 0.4rem;
}

/* The bar itself almost square too, so it matches the buttons. */
.wk-voorlezen {
	border-radius: var( --wk-hoek );
}

/* -----------------------------------------------------------------------------
   3. The share buttons
   -------------------------------------------------------------------------- */

.wk-delen {
	display: flex;
	align-items: center;
	gap: 0.4rem;
	font-family: var( --wp--preset--font-family--ui, system-ui, sans-serif );
	color: var( --wk-delen-inkt );
}

.wk-delen__label {
	font-size: 0.8125rem;
	font-weight: 600;
	line-height: 1;
	white-space: nowrap;
}

.wk-delen__rij {
	display: flex;
	align-items: center;
	gap: 0.3rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.wk-delen__item {
	margin: 0;
	padding: 0;
	list-style: none;
}

.wk-delen__knop {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box; /* same height as the read-aloud buttons: 32 px */
	width: 2rem;
	height: 2rem;
	padding: 0;
	border: 1.5px solid var( --wk-delen-lijn );
	border-radius: var( --wk-hoek );
	background: #fff;
	color: var( --wk-delen-inkt );
	line-height: 1;
	text-decoration: none;
	cursor: pointer;
	transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.wk-delen__knop:hover,
.wk-delen__knop:focus-visible {
	border-color: var( --wk-delen-groen );
	background: var( --wk-delen-groen );
	color: #fff;
	text-decoration: none;
}

.wk-delen__knop:focus-visible {
	outline: 3px solid var( --wk-delen-inkt );
	outline-offset: 3px;
}

.wk-delen__icoon {
	display: block;
	width: 1.05rem;
	height: 1.05rem;
}

/* Message after "link copied". Not permanently visible; empty = gone. */
.wk-delen__melding:empty {
	display: none;
}

.wk-delen__melding {
	font-size: 0.8125rem;
	line-height: 1;
	color: var( --wp--preset--color--grijs, #6B6B64 );
	white-space: nowrap;
}

/* -----------------------------------------------------------------------------
   4. Standalone variant
   If the device cannot read aloud, the read-aloud bar stays hidden.
   delen.js then takes the buttons out and puts them in here, so that sharing
   always works, even without speech.
   -------------------------------------------------------------------------- */

.wk-delen-los {
	display: flex;
	justify-content: flex-start;
	margin-block: 0.75rem;
}

/* -----------------------------------------------------------------------------
   5. Edge cases
   -------------------------------------------------------------------------- */

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

@media ( forced-colors: active ) {
	.wk-delen__knop {
		border-color: ButtonText;
	}

	.wk-delen__knop:hover,
	.wk-delen__knop:focus-visible {
		border-color: Highlight;
	}
}

@media print {
	.wk-delen,
	.wk-delen-los {
		display: none !important;
	}
}
