/**
 * Store-wide sale (inc/sale.php).
 *
 * Pages carry both the regular and the sale markup until the sale ends; the
 * <head> script adds .dfs-sale-on to <html> while it runs. Elements keep
 * their own display, these rules only hide the side that doesn't apply.
 *
 * The bar sits above the header. On phones it scrolls away with the page
 * (the header does too). From lg up the header is fixed, so the bar is
 * fixed above it and the page and the sticky purchase box move down by its
 * height.
 *
 * Colors from the theme palette: primary #03F4E8, foreground-dark #00020B,
 * foreground #353839, foreground-light #98989C.
 */

html:not(.dfs-sale-on) .dfs-sale-only,
html.dfs-sale-on .dfs-sale-hide {
	display: none !important;
}

html.dfs-sale-on {
	--dfs-sale-bar-h: 2.5rem;
}

/* Bar */
.dfs-sale-bar {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: var(--dfs-sale-bar-h, 2.5rem);
	padding: 0.375rem 1rem;
	box-sizing: border-box;
	background: var(--wp--preset--color--primary, #03f4e8);
	color: var(--wp--preset--color--foreground-dark, #00020b);
	font-size: 0.875rem;
	line-height: 1.3;
	text-align: center;
}

.dfs-sale-bar__text {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 0.25rem 0.625rem;
	margin: 0;
	font-weight: 500;
}

.dfs-sale-bar__label {
	padding: 0.1875rem 0.5rem;
	border-radius: 999px;
	background: var(--wp--preset--color--foreground-dark, #00020b);
	color: var(--wp--preset--color--primary, #03f4e8);
	font-size: 0.6875rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	line-height: 1.2;
	text-transform: uppercase;
	white-space: nowrap;
}

.dfs-sale-bar__short {
	display: none;
}

.dfs-sale-bar__link {
	display: inline-flex;
	align-items: center;
	gap: 0.375rem;
	color: inherit;
	font-weight: 700;
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 0.2em;
	white-space: nowrap;
}

.dfs-sale-bar__link:hover,
.dfs-sale-bar__link:focus-visible {
	text-decoration-thickness: 2px;
}

.dfs-sale-bar__link:focus-visible {
	outline: 2px solid var(--wp--preset--color--foreground-dark, #00020b);
	outline-offset: 2px;
	border-radius: 2px;
}

.dfs-sale-bar__link svg {
	width: 0.75rem;
	height: 0.75rem;
	flex: none;
}

@media (prefers-reduced-motion: no-preference) {
	.dfs-sale-bar__link svg {
		transition: transform 0.15s ease;
	}

	.dfs-sale-bar__link:hover svg {
		transform: translateX(2px);
	}
}

/* Phones: one short line, no link (the prices on each page show the sale). */
@media (max-width: 781px) {
	.dfs-sale-bar__long,
	.dfs-sale-bar__link {
		display: none;
	}

	.dfs-sale-bar__short {
		display: inline;
	}
}

/* The header sits below the bar (absolute on phones, fixed from lg). The
   theme's own offsets (header.css: top-5, admin bar top-16.5 / md:top-13)
   plus the bar. Not margin (the theme forces 0 on top-level blocks) and not
   transform (it would trap the fixed mobile menu inside the header). */
html.dfs-sale-on .danfisher-header {
	top: calc(1.25rem + var(--dfs-sale-bar-h));
}

html.dfs-sale-on .admin-bar .danfisher-header {
	top: calc(4.125rem + var(--dfs-sale-bar-h));
}

@media (min-width: 782px) {
	html.dfs-sale-on .admin-bar .danfisher-header {
		top: calc(3.25rem + var(--dfs-sale-bar-h));
	}
}

@media (min-width: 1024px) {
	.dfs-sale-bar {
		position: fixed;
		top: var(--wp-admin--admin-bar--height, 0px);
		right: 0;
		left: 0;
		z-index: 31;
		height: var(--dfs-sale-bar-h, 2.5rem);
		white-space: nowrap;
	}

	html.dfs-sale-on body {
		padding-top: var(--dfs-sale-bar-h);
	}

	/* Same rule as the theme's purchase-box.css, moved down by the bar. */
	html.dfs-sale-on .danfisher-buybox.danfisher-product-sticky {
		top: max(
			calc(6rem + var(--dfs-sale-bar-h)),
			min(calc(8rem + var(--dfs-sale-bar-h)), calc(100vh - var(--dfs-buybox-h, 0px) - 1rem))
		);
	}
}

/* Was / now amounts */
.dfs-amount__was {
	text-decoration-line: line-through;
	text-decoration-thickness: 1.5px;
	opacity: 0.6;
}

/* Purchase card price line: smaller grey old price, big new price, badge. */
.dfs-price-line .dfs-amount__was {
	margin-right: 0.25em;
	color: var(--wp--preset--color--foreground-light, #98989c);
	font-size: 0.625em;
	font-weight: 600;
	text-decoration-thickness: 2px;
	opacity: 1;
}

.dfs-sale-badge {
	display: inline-block;
	margin-left: 0.625rem;
	padding: 0.25rem 0.625rem;
	border-radius: 999px;
	background: var(--wp--preset--color--primary, #03f4e8);
	color: var(--wp--preset--color--foreground-dark, #00020b);
	font-family: var(--wp--preset--font-family--base, inherit);
	font-size: 0.75rem;
	font-weight: 700;
	letter-spacing: 0.04em;
	line-height: 1.2;
	text-transform: uppercase;
	vertical-align: 0.4em;
	white-space: nowrap;
}

.dfs-sale-note {
	margin: 0;
	color: var(--wp--preset--color--foreground, #353839);
	font-size: 0.8125rem;
	line-height: 1.5;
}

.dfs-sale-note strong {
	color: var(--wp--preset--color--foreground-dark, #00020b);
	font-weight: 700;
	letter-spacing: 0.02em;
}

/* Inside buttons the old price stays readable on the button color. */
.wp-block-button__link .dfs-amount__was {
	opacity: 0.55;
}
