/*
 * Direct Checkout Optimizer — Sticky Button Styles
 * Theme-safe: all selectors scoped to .dco-sticky-bar.
 */

/* =====================================================================
   Sticky bar — base
   ===================================================================== */

.dco-sticky-bar {
	position: fixed;
	left: 0;
	right: 0;
	z-index: 99990;
	padding: 10px 16px;
	box-shadow: 0 -3px 12px rgba(0, 0, 0, 0.18);
	transition: transform 0.3s ease, opacity 0.3s ease;
	will-change: transform;
}

.dco-sticky-bar--bottom {
	bottom: 0;
	border-radius: 0;
}

/* Hidden state — JS removes this class after scroll threshold. */
.dco-sticky-bar--hidden {
	transform: translateY(110%);
	opacity: 0;
	pointer-events: none;
}

/* Mobile-only: hidden on desktop via CSS (JS also guards). */
@media (min-width: 783px) {
	.dco-sticky-bar--mobile-only {
		display: none !important;
	}
}

/* =====================================================================
   Inner layout
   ===================================================================== */

.dco-sticky-bar__inner {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	max-width: 960px;
	margin: 0 auto;
}

/* =====================================================================
   Product summary
   ===================================================================== */

.dco-sticky-bar__product {
	display: flex;
	align-items: center;
	gap: 10px;
	flex: 1;
	min-width: 0;
}

.dco-sticky-bar__thumb {
	width: 44px;
	height: 44px;
	flex-shrink: 0;
	overflow: hidden;
	border-radius: 4px;
}

.dco-sticky-bar__thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.dco-sticky-bar__info {
	display: flex;
	flex-direction: column;
	min-width: 0;
}

.dco-sticky-bar__name {
	font-size: 13px;
	font-weight: 600;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.dco-sticky-bar__price {
	font-size: 13px;
	opacity: 0.9;
}

.dco-sticky-bar__price .woocommerce-Price-amount {
	color: inherit;
}

/* =====================================================================
   CTA button
   ===================================================================== */

.dco-sticky-bar__btn {
	flex-shrink: 0;
	padding: 10px 24px;
	font-size: 14px;
	font-weight: 700;
	border: none;
	border-radius: 4px;
	cursor: pointer;
	transition: opacity 0.2s, transform 0.1s;
	white-space: nowrap;
}

.dco-sticky-bar__btn:hover  { opacity: 0.88; }
.dco-sticky-bar__btn:active { transform: scale(0.97); }

.dco-sticky-bar__btn.dco-loading {
	opacity: 0.65;
	cursor: not-allowed;
}

/* =====================================================================
   Close button
   ===================================================================== */

.dco-sticky-bar__close {
	background: none;
	border: none;
	font-size: 18px;
	line-height: 1;
	cursor: pointer;
	padding: 4px;
	opacity: 0.7;
	flex-shrink: 0;
	transition: opacity 0.15s;
}

.dco-sticky-bar__close:hover { opacity: 1; }

/* =====================================================================
   Offset for common cookie/GDPR bars (detected via JS)
   ===================================================================== */

.dco-sticky-bar--offset {
	bottom: var(--dco-cookie-bar-height, 0px);
}

/* =====================================================================
   Responsive — collapse product info on very small screens
   ===================================================================== */

@media (max-width: 400px) {
	.dco-sticky-bar__product {
		display: none;
	}

	.dco-sticky-bar__btn {
		width: 100%;
		text-align: center;
	}

	.dco-sticky-bar__inner {
		justify-content: center;
	}
}

/* ── Reveal animation (sticky_animation) ────────────────────────────────────
 *
 * The shared hidden state fades and slides at the same time, so the bar was
 * almost transparent for the whole of its short travel and simply looked like
 * it appeared. Each mode now animates one property only, which makes the
 * three settings visibly different from each other.
 */

/* Slide: move, do not fade. */
.dco-sticky-bar--anim-slide {
	transition: transform .34s cubic-bezier( .22, .61, .36, 1 );
}

.dco-sticky-bar--anim-slide.dco-sticky-bar--hidden {
	transform: translateY( 110% );
	opacity: 1;
}

/* Fade: change opacity, do not move. */
.dco-sticky-bar--anim-fade {
	transition: opacity .3s ease;
}

.dco-sticky-bar--anim-fade.dco-sticky-bar--hidden {
	transform: none;
	opacity: 0;
}

/* None: no transition at all. */
.dco-sticky-bar--anim-none {
	transition: none;
}

.dco-sticky-bar--anim-none.dco-sticky-bar--hidden {
	transform: none;
	opacity: 0;
	visibility: hidden;
}

/* Respect the visitor's motion preference. */
@media ( prefers-reduced-motion: reduce ) {
	.dco-sticky-bar,
	.dco-sticky-bar--anim-slide,
	.dco-sticky-bar--anim-fade {
		transition: none;
	}
}

/* ── Top position (sticky_position = top) ───────────────────────────────────
   The PHP has always emitted .dco-sticky-bar--top for this option, but only
   the bottom rule existed, so choosing "Top" left the bar with no anchor. */
.dco-sticky-bar--top {
	top: 0;
	bottom: auto;
	border-radius: 0;
	box-shadow: 0 3px 12px rgba( 0, 0, 0, .18 );
}

.dco-sticky-bar--top.dco-sticky-bar--hidden {
	transform: translateY( -110% );
}

.dco-sticky-bar--top.dco-sticky-bar--anim-slide.dco-sticky-bar--hidden {
	transform: translateY( -110% );
	opacity: 1;
}

/* Keep clear of the WordPress admin bar for logged-in users. */
body.admin-bar .dco-sticky-bar--top {
	top: 32px;
}

@media screen and ( max-width: 782px ) {
	body.admin-bar .dco-sticky-bar--top {
		top: 46px;
	}
}
