/**
 * Kloovia front-end styles.
 *
 * Every colour comes from a custom property set inline on each item, so one
 * stylesheet serves all 23 themes. Kept deliberately small: this file is
 * inlined on first render rather than loaded as a separate request.
 */

/*
 * Brand tokens. The share buttons themselves take their colour from each
 * network, but Kloovia's own UI — the popup, the subscription form, the QR
 * panel — needs one consistent accent, and previously each invented its own.
 * Set on :where() so a theme or the Extra CSS box can override them without
 * a specificity fight.
 */
:where(:root) {
	--kloovia-accent: #1f6feb;
	--kloovia-accent-strong: #1a5fd0;
	--kloovia-accent-soft: #eaf1fd;
	--kloovia-ink: #16181c;
	--kloovia-ink-soft: #5b6672;
	--kloovia-surface: #ffffff;
	--kloovia-line: #dfe4ea;
	--kloovia-radius: 14px;
	--kloovia-shadow: 0 24px 60px -24px rgba(12, 20, 32, .45);
}

.kloovia {
	--sh-size: 40px;
	--sh-gap: 8px;
	--sh-radius: 8px;
	--sh-bg: #2f3640;
	--sh-fg: #ffffff;
	--sh-border: transparent;
	--sh-shadow: none;
	--sh-overlay: none;

	display: block;
	max-width: 100%;
}

.kloovia__heading {
	display: block;
	margin-bottom: calc(var(--sh-gap) * 0.75);
	font-size: 0.95em;
	line-height: 1.4;
}

.kloovia__list {
	display: flex;
	flex-wrap: wrap;
	gap: var(--sh-gap);
	margin: 0;
	padding: 0;
	list-style: none;
}

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

.kloovia__item::before,
.kloovia__item::marker {
	content: none;
}

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

.kloovia--align-center .kloovia__list { justify-content: center; }
.kloovia--align-right  .kloovia__list { justify-content: flex-end; }
.kloovia--align-center .kloovia__heading { text-align: center; }
.kloovia--align-right  .kloovia__heading { text-align: right; }

/* ---- Fixed columns --------------------------------------------------- */

.kloovia--wrapped .kloovia__list {
	display: grid;
	grid-template-columns: repeat(var(--sh-per-row, 5), max-content);
}

.kloovia--align-center.kloovia--wrapped .kloovia__list { justify-content: center; }
.kloovia--align-right.kloovia--wrapped  .kloovia__list { justify-content: end; }

/* ---- The button ------------------------------------------------------ */

.kloovia__link {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5em;
	box-sizing: border-box;
	min-width: var(--sh-size);
	height: var(--sh-size);
	padding: 0;
	border: 1px solid var(--sh-border);
	border-radius: var(--sh-radius);
	background: var(--sh-bg);
	box-shadow: var(--sh-shadow);
	color: var(--sh-fg);
	text-decoration: none;
	line-height: 1;
	overflow: hidden;
	transition: transform .16s ease, box-shadow .16s ease, opacity .16s ease, filter .16s ease;
}

/* The gloss/gradient pass sits above the background, below the glyph. */
.kloovia__link::after {
	content: "";
	position: absolute;
	inset: 0;
	background: var(--sh-overlay);
	pointer-events: none;
}

.kloovia__icon {
	position: relative;
	z-index: 1;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
}

.kloovia__glyph {
	width: 52%;
	height: 52%;
	fill: currentColor;
	pointer-events: none;
}

.kloovia__image {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	border-radius: inherit;
}

/* ---- Shapes ---------------------------------------------------------- */

.kloovia--shape-square  { --sh-radius: 0; }
.kloovia--shape-rounded { --sh-radius: 22%; }
.kloovia--shape-circle  { --sh-radius: 50%; }

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

.kloovia--labelled .kloovia__link {
	width: auto;
	padding: 0 0.9em 0 0.7em;
}

.kloovia--labelled .kloovia__icon {
	width: calc(var(--sh-size) * 0.55);
	height: calc(var(--sh-size) * 0.55);
}

.kloovia--labelled .kloovia__glyph {
	width: 100%;
	height: 100%;
}

.kloovia__label {
	position: relative;
	z-index: 1;
	font-size: calc(var(--sh-size) * 0.34);
	font-weight: 600;
	white-space: nowrap;
}

/* ---- Counts ---------------------------------------------------------- */

.kloovia__count {
	position: relative;
	z-index: 1;
	font-size: calc(var(--sh-size) * 0.3);
	font-weight: 600;
	font-variant-numeric: tabular-nums;
	padding-right: 0.2em;
}

.kloovia:not(.kloovia--labelled) .kloovia__link:has(.kloovia__count) {
	width: auto;
	padding: 0 0.55em 0 0;
}

.kloovia:not(.kloovia--labelled) .kloovia__link:has(.kloovia__count) .kloovia__icon {
	width: var(--sh-size);
	flex: 0 0 var(--sh-size);
}


/* ---- Vertical stacks -------------------------------------------------- */

.kloovia--vertical .kloovia__list {
	flex-direction: column;
	align-items: flex-start;
}

.kloovia--vertical.kloovia--align-center .kloovia__list { align-items: center; }
.kloovia--vertical.kloovia--align-right  .kloovia__list { align-items: flex-end; }

/* ---- Sticky floating bar --------------------------------------------- */

/* Scrolls with the page instead of pinning to the viewport. */
.kloovia--floating.kloovia--sticky {
	position: absolute;
}

/* ---- Wide share bar --------------------------------------------------- */

/*
 * The labelled full-width variant: one row per network, each reading
 * "Share on Facebook". Sizing comes from the type, not from --sh-size, so a
 * bar button stays legible whatever icon size is configured.
 */

.kloovia--bar {
	--sh-bar-radius: 6px;
}

.kloovia--bar .kloovia__list {
	flex-direction: column;
	align-items: stretch;
}

.kloovia--bar.kloovia--bar-fixed .kloovia__list {
	align-items: flex-start;
}

.kloovia--bar.kloovia--bar-fixed.kloovia--align-center .kloovia__list { align-items: center; }
.kloovia--bar.kloovia--bar-fixed.kloovia--align-right  .kloovia__list { align-items: flex-end; }

.kloovia--bar .kloovia__item { width: 100%; }

.kloovia--bar.kloovia--bar-fixed .kloovia__item {
	width: var(--sh-bar-width, 240px);
	max-width: 100%;
}

.kloovia--bar .kloovia__link {
	width: 100%;
	height: auto;
	min-height: 0;
	padding: .78em 1.1em;
	gap: .65em;
	border-radius: var(--sh-bar-radius);
	justify-content: flex-start;
	font-size: 1rem;
}

.kloovia--bar.kloovia--bartext-center .kloovia__link { justify-content: center; }

.kloovia--bar .kloovia__icon {
	width: 1.25em;
	height: 1.25em;
	flex: 0 0 1.25em;
}

.kloovia--bar .kloovia__glyph { width: 100%; height: 100%; }

.kloovia--bar .kloovia__label {
	font-size: .95em;
	font-weight: 600;
}

.kloovia--bar .kloovia__count {
	margin-left: auto;
	padding-right: 0;
	font-size: .9em;
	opacity: .85;
}

.kloovia--bar.kloovia--bartext-center .kloovia__count { margin-left: .4em; }

/* Fill styles for the bar. */
.kloovia--bar-gradient .kloovia__link {
	background-image: linear-gradient(180deg, rgba(255, 255, 255, .18), rgba(0, 0, 0, .12));
}

.kloovia--bar-flat .kloovia__link {
	background-image: none;
	box-shadow: none;
}

.kloovia--bar-outline .kloovia__link {
	background: transparent;
	background-image: none;
	box-shadow: none;
	border-color: var(--sh-bg);
	color: var(--sh-bg);
}

.kloovia--bar-outline .kloovia__link:hover {
	background: var(--sh-bg);
	color: var(--sh-fg);
}

/* The bar's own gradient replaces any theme gloss. */
.kloovia--bar .kloovia__link::after { background: none; }

/* ---- Combined share total -------------------------------------------- */

.kloovia__total {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	width: max-content;
	min-width: 4.5em;
	margin: 0 0 var(--sh-gap);
	padding: .5em .9em;
	border: 1px solid rgba(0, 0, 0, .12);
	border-radius: var(--sh-bar-radius, 6px);
	line-height: 1.1;
}

.kloovia--align-center .kloovia__total { margin-left: auto; margin-right: auto; }
.kloovia--align-right  .kloovia__total { margin-left: auto; }

.kloovia__total-number {
	font-size: 1.45em;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
}

.kloovia__total-label {
	font-size: .68em;
	font-weight: 600;
	letter-spacing: .1em;
	opacity: .65;
}

/* ---- Textured themes ------------------------------------------------- */

.kloovia--theme-grunge .kloovia__link::after,
.kloovia--theme-splash .kloovia__link::after,
.kloovia--theme-wood   .kloovia__link::after {
	background-image: var(--sh-texture);
	background-size: cover;
	background-blend-mode: overlay;
	opacity: .55;
}

/* ---- Hover effects --------------------------------------------------- */

.kloovia--hover-fade  .kloovia__link:hover { opacity: .72; }
.kloovia--hover-scale .kloovia__link:hover { transform: scale(1.12); }
.kloovia--hover-lift  .kloovia__link:hover { transform: translateY(-3px); box-shadow: 0 6px 14px -6px rgba(0,0,0,.5); }
.kloovia--hover-flip  .kloovia__link:hover { transform: rotateY(180deg); }

.kloovia--hover-shake .kloovia__link:hover { animation: kloovia-shake .4s ease; }

@keyframes kloovia-shake {
	0%, 100% { transform: translateX(0); }
	25%      { transform: translateX(-3px); }
	75%      { transform: translateX(3px); }
}

/* "Affect the other icons instead" — the original's mouse-over alternative. */
.kloovia--hover-others .kloovia__list:hover .kloovia__link { opacity: .45; }
.kloovia--hover-others .kloovia__list .kloovia__link:hover { opacity: 1; transform: none; }

.kloovia__link:focus-visible {
	/* Two rings: a light halo plus a dark core, so the focus state stays
	   visible on both light and dark backgrounds without knowing the theme. */
	outline: 2px solid #fff;
	outline-offset: 2px;
	box-shadow: 0 0 0 4px var(--kloovia-accent), var(--sh-shadow);
}

.kloovia__link:active { transform: translateY(1px) scale(.97); }

/* ---- Floating bar ---------------------------------------------------- */

.kloovia--floating {
	position: fixed;
	z-index: 9998;
}

.kloovia--floating .kloovia__list { flex-direction: column; }

.kloovia--floating.kloovia--pos-top-left      { top: var(--sh-off-top, 16px);    left: var(--sh-off-left, 0); }
.kloovia--floating.kloovia--pos-top-right     { top: var(--sh-off-top, 16px);    right: var(--sh-off-right, 0); }
.kloovia--floating.kloovia--pos-center-left   { top: 50%; left: var(--sh-off-left, 0);  transform: translateY(-50%); }
.kloovia--floating.kloovia--pos-center-right  { top: 50%; right: var(--sh-off-right, 0); transform: translateY(-50%); }
.kloovia--floating.kloovia--pos-bottom-left   { bottom: var(--sh-off-bottom, 16px); left: var(--sh-off-left, 0); }
.kloovia--floating.kloovia--pos-bottom-right  { bottom: var(--sh-off-bottom, 16px); right: var(--sh-off-right, 0); }

/* ---- Popup ----------------------------------------------------------- */

.kloovia-popup {
	position: fixed;
	inset: 0;
	z-index: 9999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
	background: rgba(9, 14, 22, .62);
	animation: kloovia-fade .18s ease both;
}

@supports (backdrop-filter: blur(2px)) {
	.kloovia-popup { backdrop-filter: blur(3px); }
}

.kloovia-popup[hidden] { display: none; }

.kloovia-popup__panel {
	position: relative;
	max-width: 440px;
	width: 100%;
	padding: 32px 32px 28px;
	border: 1px solid var(--sh-popup-border, var(--kloovia-line));
	border-radius: var(--sh-popup-radius, var(--kloovia-radius));
	background: var(--sh-popup-bg, var(--kloovia-surface));
	color: var(--sh-popup-fg, var(--kloovia-ink));
	box-shadow: var(--kloovia-shadow);
	text-align: center;
	animation: kloovia-rise .22s cubic-bezier(.2, .8, .3, 1) both;
}

/* A slim accent bar, so the panel reads as the plugin's own rather than as
   an anonymous white box dropped on the page. */
.kloovia-popup__panel::before {
	content: "";
	position: absolute;
	inset: 0 0 auto;
	height: 4px;
	border-radius: var(--sh-popup-radius, var(--kloovia-radius)) var(--sh-popup-radius, var(--kloovia-radius)) 0 0;
	background: linear-gradient(90deg, var(--kloovia-accent), #7c5cf0);
}

.kloovia-popup__text {
	margin: 0 0 20px;
	font-size: var(--sh-popup-size, 20px);
	font-weight: 600;
	line-height: 1.35;
	text-wrap: balance;
}

.kloovia-popup__close {
	position: absolute;
	top: 10px;
	right: 10px;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--kloovia-ink-soft);
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
	transition: background-color .15s ease, color .15s ease;
}

.kloovia-popup__close:hover {
	background: rgba(0, 0, 0, .07);
	color: var(--kloovia-ink);
}

.kloovia-popup__close:focus-visible {
	outline: 2px solid var(--kloovia-accent);
	outline-offset: 2px;
}

@keyframes kloovia-fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes kloovia-rise {
	from { opacity: 0; transform: translateY(12px) scale(.97) }
	to   { opacity: 1; transform: none }
}

/* ---- QR lightbox (WeChat and other scan-to-share networks) ---------- */

.kloovia-qr {
	position: fixed;
	inset: 0;
	z-index: 9999;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(10, 14, 18, .6);
}

.kloovia-qr[hidden] { display: none; }

.kloovia-qr__panel {
	padding: 22px;
	border-radius: 12px;
	background: #fff;
	text-align: center;
	color: #191d22;
}

.kloovia-qr__code {
	display: block;
	min-height: 60px;
	margin: 0 auto 12px;
}

.kloovia-qr__code svg {
	display: block;
	width: min(240px, 60vw);
	height: auto;
}

.kloovia-qr__url {
	max-width: 260px;
	margin: 0 auto 12px;
	font-size: .78em;
	line-height: 1.45;
	word-break: break-all;
	color: #5f6b75;
}

.kloovia-qr__close {
	padding: .45em 1.2em;
	border: 1px solid rgba(0, 0, 0, .18);
	border-radius: 7px;
	background: #fff;
	font: inherit;
	font-size: .88em;
	font-weight: 600;
	color: #16181c;
	cursor: pointer;
}

.kloovia-qr__close:hover { background: #f2f4f5; }

/* ---- Copy confirmation ---------------------------------------------- */

.kloovia__link--copied::before {
	content: attr(data-copied-label);
	position: absolute;
	inset: 0;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--sh-bg);
	color: var(--sh-fg);
	font-size: calc(var(--sh-size) * 0.26);
	font-weight: 600;
}

/* ---- Screen-reader text (themes may not provide it) ------------------ */

.kloovia .screen-reader-text {
	position: absolute !important;
	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;
}

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

@media (prefers-reduced-motion: reduce) {
	.kloovia__link,
	.kloovia__link:hover {
		transition: none;
		animation: none;
		transform: none;
	}
}

/* ---- Subscription form ---------------------------------------------- */

.kloovia-subscribe {
	max-width: 34rem;
	margin: 0;
	padding: 22px 24px 20px;
	border: 1px solid var(--kloovia-line);
	border-radius: var(--kloovia-radius);
	background: var(--kloovia-surface);
	box-shadow: 0 1px 2px rgba(12, 20, 32, .05);
}

.kloovia-subscribe__heading {
	margin: 0 0 .85em;
	font-size: 1.1em;
	font-weight: 700;
	line-height: 1.3;
	color: var(--kloovia-ink);
	text-wrap: balance;
}

.kloovia-subscribe__row {
	display: flex;
	flex-wrap: wrap;
	gap: 9px;
}

.kloovia-subscribe__input {
	flex: 1 1 12rem;
	min-width: 0;
	padding: .68em .85em;
	border: 1px solid var(--kloovia-line);
	border-radius: 9px;
	font: inherit;
	font-size: .95em;
	background: #fff;
	color: var(--kloovia-ink);
	transition: border-color .15s ease, box-shadow .15s ease;
}

.kloovia-subscribe__input::placeholder { color: #9aa5b1; }

.kloovia-subscribe__input:focus {
	outline: none;
	border-color: var(--kloovia-accent);
	box-shadow: 0 0 0 3px var(--kloovia-accent-soft);
}

.kloovia-subscribe__button {
	flex: 0 0 auto;
	padding: .68em 1.45em;
	border: 0;
	border-radius: 9px;
	background: var(--kloovia-accent);
	color: #fff;
	font: inherit;
	font-size: .95em;
	font-weight: 600;
	cursor: pointer;
	transition: background-color .15s ease, transform .12s ease;
}

.kloovia-subscribe__button:hover { background: var(--kloovia-accent-strong); }
.kloovia-subscribe__button:active { transform: translateY(1px); }

.kloovia-subscribe__button:focus-visible {
	outline: 2px solid var(--kloovia-accent);
	outline-offset: 2px;
}

.kloovia-subscribe__button[disabled] {
	opacity: .6;
	cursor: default;
	transform: none;
}

/* The native checkbox is inconsistent across platforms and was the one
   visibly unstyled control in the whole plugin. */
.kloovia-subscribe__consent {
	display: flex;
	align-items: flex-start;
	gap: .6em;
	margin-top: .95em;
	font-size: .88em;
	line-height: 1.5;
	color: var(--kloovia-ink-soft);
	cursor: pointer;
}

.kloovia-subscribe__consent input {
	flex: none;
	width: 1.05em;
	height: 1.05em;
	margin: .15em 0 0;
	accent-color: var(--kloovia-accent);
	cursor: pointer;
}

.kloovia-subscribe__consent input:focus-visible {
	outline: 2px solid var(--kloovia-accent);
	outline-offset: 2px;
}

/* Kept in the layout but out of sight and out of the tab order. */
.kloovia-subscribe__trap {
	position: absolute !important;
	left: -9999px;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

.kloovia-subscribe__message {
	margin: .8em 0 0;
	font-size: .9em;
	line-height: 1.45;
	min-height: 1.45em;
}

.kloovia-subscribe__message[data-state="error"] { color: #c92a2a; }
.kloovia-subscribe__message[data-state="success"] { color: #128a5f; }
