/* Typography is inherited, not imposed.
 *
 * This shipped a hardcoded -apple-system stack and its own 13/14/15/16/18px
 * scale, so on any site with a brand font the consent banner was the one
 * element in a different typeface. It now inherits the host family and exposes
 * its sizes as custom properties, with the previous values as fallbacks, so a
 * site that sets nothing looks exactly as it did.
 */
/* MyConsent banner + modal. Scoped under #myconsent-root. */

#myconsent-root {
	--myconsent-accent: #2563eb;
	--myconsent-bg: #ffffff;
	--myconsent-text-color: #1f2937;
	--myconsent-text: 14px;
	--myconsent-btn-text: #ffffff;
	--myconsent-max-width: 1100px;
	--myconsent-radius: 12px;
	position: fixed;
	z-index: 999999;
	left: 0;
	right: 0;
	box-sizing: border-box;
}

#myconsent-root[hidden] {
	display: none;
}

#myconsent-root * {
	box-sizing: border-box;
}

/* Position variants */
#myconsent-root.myconsent-position-bottom { bottom: 0; }
#myconsent-root.myconsent-position-top { top: 0; }
#myconsent-root.myconsent-position-center {
	top: 0; bottom: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba( 0, 0, 0, 0.45 );
}

/* Floating bars pinned to the bottom-left or bottom-right corner. The root
   hugs its side (overriding the full-width default) so the rest of the page
   stays clickable; the bar is only as tall as its content. */
#myconsent-root.myconsent-position-left { right: auto; bottom: 0; }
#myconsent-root.myconsent-position-right { left: auto; bottom: 0; }
#myconsent-root.myconsent-position-left .myconsent-banner,
#myconsent-root.myconsent-position-right .myconsent-banner {
	margin: 16px;
	width: var( --myconsent-max-width );
	max-width: calc( 100vw - 32px );
}

/* Banner */
.myconsent-banner {
	background: var( --myconsent-bg );
	color: var( --myconsent-text-color );
	margin: 16px auto;
	width: calc( 100% - 32px );
	max-width: var( --myconsent-max-width );
	padding: 20px 24px;
	border: 1px solid color-mix( in srgb, currentColor 24%, transparent );
	border-radius: var( --myconsent-radius );
	display: flex;
	gap: 24px;
	align-items: center;
	flex-wrap: wrap;
	font-family: var(--myconsent-font, inherit);
	font-size: var(--myconsent-text, 14px);
	line-height: 1.5;
}

.myconsent-position-center .myconsent-banner { margin: 0; }

.myconsent-banner__text { flex: 1 1 360px; }
.myconsent-banner__title { margin: 0 0 6px; font-size: var(--myconsent-title, 16px); font-weight: 600; }
.myconsent-banner__message { margin: 0; color: var( --myconsent-text-color ); opacity: 0.85; }
.myconsent-banner__message a { color: var( --myconsent-accent ); }

.myconsent-banner__actions {
	display: grid;
	grid-template-columns: repeat( 2, minmax( 140px, 1fr ) );
	gap: 10px;
	flex: 0 1 360px;
}

/* Buttons */
.myconsent-btn {
	cursor: pointer;
	border-radius: 8px;
	min-height: 44px;
	padding: 10px 16px;
	font-size: var(--myconsent-text, 14px);
	font-weight: 600;
	border: 1px solid transparent;
	line-height: 1.2;
}
.myconsent-btn--primary,
.myconsent-btn--decision {
	background: var( --myconsent-accent );
	color: var( --myconsent-btn-text );
}
.myconsent-btn--primary:hover,
.myconsent-btn--decision:hover { filter: brightness( 0.94 ); }
.myconsent-btn:focus-visible,
.myconsent-modal__close:focus-visible {
	outline: 3px solid currentColor;
	outline-offset: 3px;
}
.myconsent-btn--ghost {
	background: transparent;
	color: var( --myconsent-text-color );
	border-color: currentColor;
	opacity: 0.75;
}
.myconsent-btn--ghost:hover { opacity: 1; }
.myconsent-btn--preferences {
	grid-column: 1 / -1;
	background: transparent;
	color: var( --myconsent-text-color );
	border-color: currentColor;
}
.myconsent-btn--preferences:hover { background: color-mix( in srgb, currentColor 8%, transparent ); }

/* Modal */
.myconsent-modal {
	position: fixed;
	inset: 0;
	background: rgba( 0, 0, 0, 0.5 );
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
}
.myconsent-modal[hidden] { display: none; }

.myconsent-modal__panel {
	background: var( --myconsent-bg );
	color: var( --myconsent-text-color );
	width: 100%;
	max-width: 520px;
	max-height: 85vh;
	overflow: auto;
	border-radius: var( --myconsent-radius );
	padding: 28px;
	font-family: var(--myconsent-font, inherit);
}
.myconsent-modal__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	margin-bottom: 16px;
}
.myconsent-modal__title { margin: 0; font-size: var(--myconsent-title-lg, 18px); }
.myconsent-modal__close {
	display: inline-grid;
	place-items: center;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 1px solid currentColor;
	border-radius: 50%;
	background: transparent;
	color: inherit;
	font: inherit;
	font-size: 24px;
	line-height: 1;
	cursor: pointer;
}

.myconsent-cat {
	display: grid;
	grid-template-columns: auto 1fr;
	gap: 4px 12px;
	padding: 14px 0;
	border-top: 1px solid #e5e7eb;
}
.myconsent-cat input { grid-row: span 2; width: 24px; height: 24px; margin: 0; }
.myconsent-cat__label { font-weight: 600; }
.myconsent-cat__desc { color: #6b7280; font-size: var(--myconsent-small, 13px); }

.myconsent-modal__actions {
	display: flex;
	justify-content: flex-end;
	gap: 10px;
	margin-top: 20px;
}

@media ( max-width: 600px ) {
	/* Lift the card clear of anything anchored to the bottom of the viewport.
	   On sportsafeuk.com that is the chat launcher, an essential service that
	   stays put, which was covering 51% of the Accept button on a 393px screen:
	   a tap on the right-hand half of Accept opened the chat instead.

	   A custom property so neither side hard-codes the other's dimensions. The
	   default suits a site with something in that corner; a site with nothing
	   there sets it back to 8px and gets the plain margin.

	   The position selectors are repeated because the floating variants set
	   `margin: 16px` at a higher specificity than a bare .myconsent-banner, so
	   a single-class rule here is silently overridden. */
	#myconsent-root.myconsent-position-left .myconsent-banner,
	#myconsent-root.myconsent-position-right .myconsent-banner,
	#myconsent-root.myconsent-position-bottom .myconsent-banner,
	#myconsent-root.myconsent-position-top .myconsent-banner,
	.myconsent-banner {
		margin-bottom: var( --myconsent-banner-bottom, 76px );
	}

	.myconsent-banner {
		width: calc( 100% - 16px );
		max-height: calc( 100vh - 16px );
		margin: 8px auto;
		padding: 16px;
		gap: 16px;
		flex-direction: column;
		align-items: stretch;
		overflow-y: auto;
	}
	.myconsent-banner__text { flex: 0 1 auto; }
	.myconsent-banner__actions {
		flex: 0 1 auto;
		grid-template-columns: repeat( 2, minmax( 0, 1fr ) );
		gap: 8px;
	}
	.myconsent-modal { padding: 8px; }
	.myconsent-modal__panel { max-height: calc( 100vh - 16px ); padding: 20px 16px; }
}

/* Persistent re-open button (consent withdrawal, GDPR Art. 7(3)) */
.myconsent-toggle {
	position: fixed;
	bottom: var( --myconsent-toggle-bottom, 18px );
	left: 18px;
	z-index: 999998;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 10px 14px;
	border: none;
	border-radius: 999px;
	cursor: pointer;
	font-family: var(--myconsent-font, inherit);
	font-size: var(--myconsent-small, 13px);
	font-weight: 600;
	line-height: 1;
	min-height: 44px;
	opacity: 0.92;
	transition: opacity 0.15s ease, transform 0.15s ease;
}
.myconsent-toggle:hover { opacity: 1; transform: translateY( -1px ); }
.myconsent-toggle:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
.myconsent-toggle svg { flex: 0 0 auto; }

/* Sit on the right when the banner itself is right-aligned. */
.myconsent-toggle--right { left: auto; right: 18px; }

/* On small screens, collapse to just the icon to stay out of the way. */
@media ( max-width: 600px ) {
	.myconsent-toggle { padding: 12px; }
	.myconsent-toggle__label { display: none; }
}

/* Cookie-policy shortcode disclosure */
.myconsent-cookie-policy { font-size: var(--myconsent-text, 15px); line-height: 1.6; }
.myconsent-cp-heading { margin: 1.5em 0 0.25em; font-size: 1.25em; }
.myconsent-cp-desc { margin: 0 0 1em; color: #4b5563; }
.myconsent-cp-service { margin: 1em 0 0.5em; font-size: 1.05em; }
.myconsent-cp-table {
	width: 100%;
	border-collapse: collapse;
	margin-bottom: 1em;
	font-size: 0.95em;
}
.myconsent-cp-table th,
.myconsent-cp-table td {
	border: 1px solid #e5e7eb;
	padding: 8px 12px;
	text-align: left;
	vertical-align: top;
}
.myconsent-cp-table th { background: #f9fafb; font-weight: 600; }
.myconsent-cp-table code { background: #f3f4f6; padding: 1px 5px; border-radius: 4px; }

/* The policy link is inline in a sentence, so it inherited the paragraph's line
 * box and measured 20px tall, under the 24px WCAG 2.2 target minimum. Padding
 * grows the hit area without breaking the sentence flow. */
.myconsent-banner__message a {
	display: inline-block;
	padding-block: var(--myconsent-link-pad, 4px);
}
