/* ── PDF buttons block (frontend) ────────────────────────────────── */

.wp-block-buttons.c2pdf-buttons{
	display:flex;
	flex-direction:column;
	align-items:flex-start;
	gap:var(--c2pdf-spacing, 8px);
}

.wp-block-buttons.c2pdf-buttons.c2pdf-grid{
	display:grid;
	grid-template-columns:repeat(var(--c2pdf-cols, 2), 1fr);
	align-items:start;
}
.c2pdf-grid .c2pdf-button-row{
	width:100%;
}
.c2pdf-grid > .wp-block-button,
.c2pdf-grid > .wp-block-button > .wp-block-button__link{
	width:100%;
	box-sizing:border-box;
}

.c2pdf-buttons .c2pdf-button-row{
	display:inline-flex;
	align-items:center;
	gap:12px;
}
/* In narrow grid cells the title wraps; the button keeps its width. */
.c2pdf-buttons .c2pdf-button-row > .wp-block-button{
	flex-shrink:0;
}

.c2pdf-buttons .c2pdf-icon-button .wp-block-button__link{
	padding:6px;
	line-height:0;
}
.c2pdf-buttons .c2pdf-icon-button .c2pdf-icon{
	display:block;
	/* Text-relative, so the icon grows with the font. 1.5em matches the
	   previous fixed 24px at a 16px base size. */
	width:var(--c2pdf-download-icon-size, 1.5em);
	height:var(--c2pdf-download-icon-size, 1.5em);
	object-fit:contain;
}

/* ── Parent entries with children ─────────────────────────────────── */
/*
   Desktop: the parent sits on the left, its children stack horizontally
   to the right of it. Mobile: everything falls back to vertical stacking,
   with the children indented slightly below their parent.
*/

.c2pdf-buttons .c2pdf-item{
	display:flex;
	flex-direction:row;
	align-items:flex-start;
	flex-wrap:wrap;
	gap:var(--c2pdf-spacing, 8px);
}
.c2pdf-buttons .c2pdf-item-self{
	display:block;
}
.c2pdf-buttons .c2pdf-children{
	display:flex;
	flex-direction:row;
	align-items:flex-start;
	flex-wrap:wrap;
	gap:var(--c2pdf-spacing, 8px);
}

/* In grid mode a parent with children claims a whole row: the parent keeps
   one column of width, the children share what is left. */
.c2pdf-grid > .c2pdf-item{
	grid-column:1 / -1;
}
.c2pdf-grid > .c2pdf-item > .c2pdf-item-self{
	flex:0 0 calc((100% - (var(--c2pdf-cols, 2) - 1) * var(--c2pdf-spacing, 8px)) / var(--c2pdf-cols, 2));
	min-width:0;
}
.c2pdf-grid > .c2pdf-item > .c2pdf-children{
	flex:1 1 0;
	min-width:0;
	flex-wrap:nowrap;
}
.c2pdf-grid > .c2pdf-item > .c2pdf-children > *{
	flex:1 1 0;
	min-width:0;
}
.c2pdf-grid > .c2pdf-item .c2pdf-button-row{
	width:100%;
}
.c2pdf-grid > .c2pdf-item > .c2pdf-item-self > .wp-block-button,
.c2pdf-grid > .c2pdf-item > .c2pdf-item-self > .wp-block-button > .wp-block-button__link,
.c2pdf-grid > .c2pdf-item > .c2pdf-children > .wp-block-button,
.c2pdf-grid > .c2pdf-item > .c2pdf-children > .wp-block-button > .wp-block-button__link{
	width:100%;
	box-sizing:border-box;
}

@media (max-width:781px){
	.c2pdf-buttons .c2pdf-item{
		flex-direction:column;
		align-items:flex-start;
	}
	.c2pdf-buttons .c2pdf-children{
		flex-direction:column;
		align-items:flex-start;
		padding-left:var(--c2pdf-child-indent, 16px);
	}
	.c2pdf-grid > .c2pdf-item > .c2pdf-item-self,
	.c2pdf-grid > .c2pdf-item > .c2pdf-children{
		flex:0 0 auto;
		width:100%;
	}
	.c2pdf-grid > .c2pdf-item > .c2pdf-children{
		width:auto;
		align-self:stretch;
		flex-wrap:wrap;
	}
}

/* ── Tooltip icon ─────────────────────────────────────────────────── */
/*
   Rendered only for entries that have tooltip text. Sits between title and
   button for the title layouts, and to the right of the button when the
   title itself is the button (.c2pdf-entry wraps that pair).
*/

.c2pdf-buttons .c2pdf-entry{
	display:inline-flex;
	align-items:center;
	gap:8px;
}

.c2pdf-buttons .c2pdf-tooltip{
	position:relative;
	display:inline-flex;
	align-items:center;
	justify-content:center;
	flex:0 0 auto;
	width:var(--c2pdf-tooltip-size, 1em);
	height:var(--c2pdf-tooltip-size, 1em);
	cursor:help;
	vertical-align:middle;
}

.c2pdf-buttons .c2pdf-tooltip-glyph{
	display:block;
	width:100%;
	height:100%;
	object-fit:contain;
}
/* Masking lets the chosen color paint the SVG; an <img> cannot be recolored. */
.c2pdf-buttons .c2pdf-tooltip-glyph.is-masked{
	background-color:var(--c2pdf-tooltip-color, currentColor);
	-webkit-mask:var(--c2pdf-tooltip-src) no-repeat center / contain;
	mask:var(--c2pdf-tooltip-src) no-repeat center / contain;
}

/* Light surface, dark text, hairline border and a soft shadow — the
   familiar native-browser-tooltip look. Override these three custom
   properties from the theme to match a different palette. */
.c2pdf-buttons .c2pdf-tooltip{
	--c2pdf-tooltip-bg:#ffffff;
	--c2pdf-tooltip-fg:#1d2327;
	--c2pdf-tooltip-border:#d0d5dd;
}

.c2pdf-buttons .c2pdf-tooltip-bubble{
	position:absolute;
	bottom:calc(100% + 10px);
	left:50%;
	transform:translateX(-50%);
	z-index:20;
	width:max-content;
	max-width:260px;
	padding:8px 11px;
	border:1px solid var(--c2pdf-tooltip-border);
	border-radius:6px;
	background:var(--c2pdf-tooltip-bg);
	color:var(--c2pdf-tooltip-fg);
	box-shadow:0 4px 14px rgba(0,0,0,.14);
	/* Scales with the text, but never drops below a readable size. */
	font-size:max(12px, .875em);
	/* Reset in case the surrounding button styling is inherited. */
	font-weight:400;
	text-transform:none;
	letter-spacing:normal;
	line-height:1.45;
	text-align:left;
	white-space:pre-line;
	opacity:0;
	visibility:hidden;
	transition:opacity .12s ease;
	pointer-events:none;
}

/* Two stacked triangles, so the arrow keeps the bubble's 1px border:
   the larger one paints the border, the smaller one the fill. */
.c2pdf-buttons .c2pdf-tooltip-bubble::before,
.c2pdf-buttons .c2pdf-tooltip-bubble::after{
	content:"";
	position:absolute;
	top:100%;
	left:50%;
	border:solid transparent;
}
.c2pdf-buttons .c2pdf-tooltip-bubble::before{
	border-width:7px;
	border-top-color:var(--c2pdf-tooltip-border);
	transform:translateX(-50%);
}
.c2pdf-buttons .c2pdf-tooltip-bubble::after{
	border-width:6px;
	border-top-color:var(--c2pdf-tooltip-bg);
	transform:translateX(-50%) translateY(-1px);
}

.c2pdf-buttons .c2pdf-tooltip:hover .c2pdf-tooltip-bubble,
.c2pdf-buttons .c2pdf-tooltip:focus .c2pdf-tooltip-bubble,
.c2pdf-buttons .c2pdf-tooltip:focus-within .c2pdf-tooltip-bubble{
	opacity:1;
	visibility:visible;
}

/* Keep the bubble inside the viewport on narrow screens. */
@media (max-width:781px){
	.c2pdf-buttons .c2pdf-tooltip-bubble{
		max-width:min(260px, 78vw);
	}
}

/* In grid mode the wrapper behaves like any other full-width cell. */
.c2pdf-grid > .c2pdf-entry,
.c2pdf-grid .c2pdf-item-self > .c2pdf-entry,
.c2pdf-grid .c2pdf-children > .c2pdf-entry{
	display:flex;
	width:100%;
	box-sizing:border-box;
}
.c2pdf-grid .c2pdf-entry > .wp-block-button{
	flex:1 1 auto;
	min-width:0;
}
.c2pdf-grid .c2pdf-entry > .wp-block-button > .wp-block-button__link{
	width:100%;
	box-sizing:border-box;
}
