/**
 * AI Summaries & Share Buttons — floating bar (v2.5.0, own look v2.8.0)
 *
 * Loaded only on pages where the bar renders, and on the settings screen for
 * its preview. The buttons take their whole look from the main stylesheet,
 * with the same classes as the buttons in the content (since 2.8.0 the bar
 * carries .icons-only plus the colour, corners and size classes of the look
 * in use); what is here is placement, stacking, the optional auto-hide and
 * the "More" panel. The rules that are not about placement hang from
 * .ayudawp-aiss-bar and not from .ayudawp-aiss-floating, so the preview in
 * Settings can use them without being pinned to the screen.
 */

/* =============================================
   Placement
   ============================================= */
.ayudawp-aiss-floating {
	position: fixed;
	z-index: 9990;
	/* Undo the inline block's own spacing and separator lines, inherited from
	   the .ayudawp-share-buttons class the bar reuses for its button styles. */
	margin: 0;
	padding: 8px;
	border: 0;
	border-radius: 10px;
	background: rgba(255, 255, 255, 0.92);
	box-shadow: 0 2px 14px rgba(0, 0, 0, 0.14);
	backdrop-filter: saturate(160%) blur(6px);
	-webkit-backdrop-filter: saturate(160%) blur(6px);
	max-width: calc(100vw - 24px);
	box-sizing: border-box;
}

/*
 * Specificity high enough to beat the main stylesheet's mobile rules. Below
 * 480px those turn every icons-only container into `display: grid` with 40px
 * columns, and `flex-direction` has no effect on a grid, so the bar stayed a
 * vertical column pinned to the bottom — which on a phone reads as "stuck in
 * the middle of the screen". The bar lays itself out, always.
 */
.ayudawp-aiss-floating.ayudawp-share-buttons.icons-only .ayudawp-buttons-container,
.ayudawp-aiss-floating .ayudawp-buttons-container {
	display: flex;
	gap: 8px;
	margin: 0;
	max-width: none;
	grid-template-columns: none;
}

/* Left and right: a vertical column, centred against the viewport. */
.ayudawp-aiss-floating--left,
.ayudawp-aiss-floating--right {
	top: 50%;
	transform: translateY(-50%);
	max-height: 90vh;
	overflow-y: auto;
	overscroll-behavior: contain;
}

.ayudawp-aiss-floating--left {
	left: 12px;
}

.ayudawp-aiss-floating--right {
	right: 12px;
}

.ayudawp-aiss-floating--left.ayudawp-share-buttons .ayudawp-buttons-container,
.ayudawp-aiss-floating--right.ayudawp-share-buttons .ayudawp-buttons-container {
	flex-direction: column;
	flex-wrap: nowrap;
	justify-content: flex-start;
}

/* Bottom: a horizontal strip, centred and allowed to wrap. */
.ayudawp-aiss-floating--bottom {
	left: 50%;
	bottom: 12px;
	transform: translateX(-50%);
	padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
}

.ayudawp-aiss-floating--bottom.ayudawp-share-buttons .ayudawp-buttons-container {
	flex-direction: row;
	flex-wrap: wrap;
	justify-content: center;
}

/*
 * With a "More" panel the side bar holds at most six buttons, so it no longer
 * needs its own scroll, and the scroll would clip the panel that opens beside
 * it (v2.8.0).
 */
.ayudawp-aiss-floating--left.has-more,
.ayudawp-aiss-floating--right.has-more {
	max-height: none;
	overflow: visible;
}

/* =============================================
   "For dark backgrounds" (v2.8.0)
   The bar is its own background, so with the colours for dark backgrounds
   it is dark too; otherwise its light icons would sit on white.
   ============================================= */
.ayudawp-aiss-floating.dark {
	background: rgba(24, 24, 24, 0.92);
	box-shadow: 0 2px 14px rgba(0, 0, 0, 0.5);
}

/* =============================================
   "More" and its panel (v2.8.0)
   A native <details>: the summary takes the size and shape of the buttons
   next to it, and the panel opens beside the bar instead of making it taller.
   ============================================= */
.ayudawp-aiss-bar-more {
	display: flex;
	margin: 0;
	padding: 0;
	border: 0;
}

.ayudawp-share-buttons.icons-only.ayudawp-aiss-bar .ayudawp-share-btn.ayudawp-aiss-bar-more-btn {
	list-style: none;
	background: #fff;
	border: 1px dashed #8c8f94;
	color: #1d2327;
	box-shadow: none;
	filter: none;
}

.ayudawp-share-buttons.icons-only.ayudawp-aiss-bar .ayudawp-share-btn.ayudawp-aiss-bar-more-btn:hover,
.ayudawp-share-buttons.icons-only.ayudawp-aiss-bar .ayudawp-share-btn.ayudawp-aiss-bar-more-btn:focus-visible {
	background: #f0f0f1;
	border-color: #1d2327;
	color: #1d2327;
}

.ayudawp-share-buttons.icons-only.ayudawp-aiss-bar.is-on-dark .ayudawp-share-btn.ayudawp-aiss-bar-more-btn,
.ayudawp-share-buttons.icons-only.ayudawp-aiss-bar.dark .ayudawp-share-btn.ayudawp-aiss-bar-more-btn {
	background: #1e1e1e;
	border-color: #8c8f94;
	color: #e6e6e6;
}

.ayudawp-aiss-bar-more-btn::-webkit-details-marker {
	display: none;
}

.ayudawp-aiss-bar-more-btn svg {
	transition: transform 0.2s ease;
}

.ayudawp-aiss-bar-more:not(.is-single)[open] > .ayudawp-aiss-bar-more-btn svg {
	transform: rotate(45deg);
}

/*
 * "A single Share button" (v2.8.0): the toggle is the only thing in sight, so
 * it looks like a button and not like the dashed "+" that hangs off a row of
 * buttons; it shows the share icon and stays still when the panel opens.
 */
.ayudawp-share-buttons.icons-only.ayudawp-aiss-bar .ayudawp-aiss-bar-more.is-single > .ayudawp-share-btn.ayudawp-aiss-bar-more-btn {
	border-style: solid;
}

.ayudawp-aiss-bar-more.is-single > .ayudawp-aiss-bar-more-btn .ayudawp-icon-wrapper {
	display: inline-flex;
}

.ayudawp-aiss-bar-panel {
	position: absolute;
	z-index: 1;
	display: grid;
	grid-template-columns: repeat(var(--aiss-cols, 1), auto);
	gap: 8px;
	padding: 8px;
	border-radius: 10px;
	background: rgba(255, 255, 255, 0.97);
	box-shadow: 0 2px 14px rgba(0, 0, 0, 0.14);
	max-height: 80vh;
	overflow-y: auto;
	overscroll-behavior: contain;
	box-sizing: border-box;
}

.ayudawp-aiss-bar.is-on-dark .ayudawp-aiss-bar-panel,
.ayudawp-aiss-bar.dark .ayudawp-aiss-bar-panel {
	background: rgba(24, 24, 24, 0.96);
	box-shadow: 0 2px 14px rgba(0, 0, 0, 0.5);
}

/* Beside a side bar, centred on it; above the bottom one. */
.ayudawp-aiss-floating--right .ayudawp-aiss-bar-panel {
	right: calc(100% + 8px);
	top: 50%;
	transform: translateY(-50%);
}

.ayudawp-aiss-floating--left .ayudawp-aiss-bar-panel {
	left: calc(100% + 8px);
	top: 50%;
	transform: translateY(-50%);
}

.ayudawp-aiss-floating--bottom .ayudawp-aiss-bar-panel {
	bottom: calc(100% + 8px);
	left: 50%;
	transform: translateX(-50%);
}

@media (prefers-reduced-motion: reduce) {
	.ayudawp-aiss-bar-more-btn svg {
		transition: none;
	}
}

/* =============================================
   Auto-hide
   The bar is visible by default. `js-autohide` is added by the script, so a
   site where the JS never runs keeps a usable bar instead of an invisible one.
   ============================================= */
.ayudawp-aiss-floating.js-autohide {
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.25s ease, visibility 0.25s ease, transform 0.25s ease;
	pointer-events: none;
}

.ayudawp-aiss-floating--left.js-autohide {
	transform: translateY(-50%) translateX(-12px);
}

.ayudawp-aiss-floating--right.js-autohide {
	transform: translateY(-50%) translateX(12px);
}

.ayudawp-aiss-floating--bottom.js-autohide {
	transform: translateX(-50%) translateY(12px);
}

.ayudawp-aiss-floating.js-autohide.is-visible {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
}

.ayudawp-aiss-floating--left.js-autohide.is-visible,
.ayudawp-aiss-floating--right.js-autohide.is-visible {
	transform: translateY(-50%) translateX(0);
}

.ayudawp-aiss-floating--bottom.js-autohide.is-visible {
	transform: translateX(-50%) translateY(0);
}

@media (prefers-reduced-motion: reduce) {
	.ayudawp-aiss-floating.js-autohide {
		transition: none;
	}
}

/* =============================================
   Dark background adaptation
   Follows the .is-on-dark class the main script sets, plus the OS preference
   for sites that switch theme with prefers-color-scheme.
   ============================================= */
.ayudawp-aiss-floating.is-on-dark {
	background: rgba(24, 24, 24, 0.92);
	box-shadow: 0 2px 14px rgba(0, 0, 0, 0.5);
}

/* =============================================
   Responsive
   Side bars become a bottom strip on phones, where a vertical column would eat
   the reading area. The whole bar can also be switched off for mobile.
   ============================================= */
@media (max-width: 782px) {
	/*
	 * One strip across the bottom, using the width available instead of
	 * shrinking to the buttons: on a 375px screen a content-width bar wrapped
	 * into three rows and covered a third of the screen.
	 */
	.ayudawp-aiss-floating--left,
	.ayudawp-aiss-floating--right,
	.ayudawp-aiss-floating--bottom {
		top: auto;
		left: 12px;
		right: 12px;
		bottom: 12px;
		transform: none;
		max-width: none;
		max-height: none;
		padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
	}

	.ayudawp-aiss-floating--left.ayudawp-share-buttons .ayudawp-buttons-container,
	.ayudawp-aiss-floating--right.ayudawp-share-buttons .ayudawp-buttons-container,
	.ayudawp-aiss-floating.ayudawp-share-buttons.icons-only .ayudawp-buttons-container {
		display: flex;
		flex-direction: row;
		flex-wrap: wrap;
		justify-content: center;
		grid-template-columns: none;
		max-width: none;
	}

	.ayudawp-aiss-floating--left.js-autohide,
	.ayudawp-aiss-floating--right.js-autohide,
	.ayudawp-aiss-floating--bottom.js-autohide {
		transform: translateY(12px);
	}

	.ayudawp-aiss-floating--left.js-autohide.is-visible,
	.ayudawp-aiss-floating--right.js-autohide.is-visible,
	.ayudawp-aiss-floating--bottom.js-autohide.is-visible {
		transform: translateY(0);
	}

	/* Every position is a strip along the bottom here, so "More" opens above
	   it, five to a row (v2.8.0). */
	.ayudawp-aiss-floating--left .ayudawp-aiss-bar-panel,
	.ayudawp-aiss-floating--right .ayudawp-aiss-bar-panel,
	.ayudawp-aiss-floating--bottom .ayudawp-aiss-bar-panel {
		top: auto;
		right: auto;
		bottom: calc(100% + 8px);
		left: 50%;
		transform: translateX(-50%);
		grid-template-columns: repeat(var(--aiss-cols-phone, 5), auto);
		max-height: 60vh;
	}

	.ayudawp-aiss-floating.hide-on-mobile {
		display: none;
	}
}
