/* Simple Top Ribbon — frontend styles */

/*
 * Font size, padding and text alignment are admin-controlled, passed in
 * per-instance via CSS custom properties set inline on #str-top-ribbon
 * (see templates/ribbon-template.php). The values below are fallbacks
 * only, used if those properties are ever missing.
 */

/*
 * Base state: a normal element in the document's natural flow. It must
 * never float or overlap anything — it simply pushes the rest of the
 * page down, the same as any other block element would.
 *
 * `position: relative` here is only a positioning context for the close
 * button (which is `position: absolute` inside it) — it does NOT remove
 * the ribbon from normal flow and must never carry a z-index, since a
 * stacking context on an in-flow element is what caused it to visually
 * paint over the theme's own header instead of sitting above it in flow.
 */
.str-top-ribbon {
	width: 100%;
	box-sizing: border-box;
	/* Extra space is reserved on the right, beyond the chosen horizontal
	   padding, so the close button never overlaps the text regardless of
	   how much padding the admin picks. */
	padding: var(--str-padding-v, 10px) calc(var(--str-padding-h, 16px) + 28px) var(--str-padding-v, 10px) var(--str-padding-h, 16px);
	font-size: var(--str-font-size, 14px);
	line-height: 1.4;
	text-align: var(--str-text-align, center);
	position: relative;
	max-height: 300px;
	overflow: hidden;
	transition: max-height 0.35s ease, padding 0.35s ease, opacity 0.25s ease;
}

/*
 * Floating/sticky behaviour is opt-in only, via the Sticky switch in the
 * admin. Only in this state does the ribbon leave normal flow to stay
 * pinned while scrolling, and only then does it need a z-index to stay
 * above the content scrolling underneath it.
 */
.str-top-ribbon--sticky {
	position: sticky;
	top: 0;
	z-index: 9999;
}

.str-top-ribbon__inner {
	max-width: 1100px;
	margin: 0 auto;
}

.str-top-ribbon a {
	color: inherit;
	text-decoration: underline;
}

.str-top-ribbon__close {
	position: absolute;
	right: var(--str-padding-h, 16px);
	top: 50%;
	transform: translateY(-50%);
	background: none;
	border: none;
	color: inherit;
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
	opacity: 0.8;
	padding: 4px;
}

.str-top-ribbon__close:hover {
	opacity: 1;
}

.str-top-ribbon.str-ribbon-hide {
	max-height: 0;
	padding-top: 0;
	padding-bottom: 0;
	opacity: 0;
}

@media (max-width: 600px) {
	.str-top-ribbon {
		padding-right: calc(var(--str-padding-h, 16px) + 24px);
	}

	.str-top-ribbon__close {
		font-size: 18px;
	}
}
