/**
 * Stoke Shortlist — front-end styles.
 *
 * Deliberately brand-neutral. Every colour, radius and z-index is a custom
 * property on :root, so a theme can restyle the plugin without overriding
 * selectors:
 *
 *   :root {
 *     --sslst-button-bg: #0a5;
 *     --sslst-modal-radius: 0;
 *   }
 *
 * @package Stoke_Shortlist
 */

:root {
	--sslst-modal-bg: #ffffff;
	--sslst-modal-color: #111111;
	--sslst-modal-overlay: rgba(0, 0, 0, 0.6);
	--sslst-modal-radius: 8px;
	--sslst-button-bg: #111111;
	--sslst-button-color: #ffffff;

	--sslst-bar-bg: #111111;
	--sslst-bar-color: #ffffff;
	--sslst-bar-border: rgba(255, 255, 255, 0.15);
	--sslst-bar-z: 9998;
	--sslst-modal-z: 9999;
	--sslst-modal-width: 34rem;
	--sslst-gap: 0.75rem;
	--sslst-radius: 999px;
	--sslst-focus: currentColor;
}

/* -------------------------------------------------------------------------
 * Button
 * ---------------------------------------------------------------------- */

.stoke-shortlist-toggle[type="button"] {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5em;
	padding: 0.6em 1.2em;
	border: 1px solid var(--sslst-button-bg);
	border-radius: var(--sslst-radius);
	background: transparent;
	color: var(--sslst-button-bg);
	font: inherit;
	line-height: 1.2;
	text-align: center;
	cursor: pointer;
	transition: background-color 0.15s ease, color 0.15s ease;
}

.stoke-shortlist-toggle[type="button"]:hover,
.stoke-shortlist-toggle[type="button"]:focus-visible {
	background: var(--sslst-button-bg);
	color: var(--sslst-button-color);
}

.stoke-shortlist-toggle[type="button"].is-shortlisted {
	background: var(--sslst-button-bg);
	color: var(--sslst-button-color);
}

.stoke-shortlist-toggle__icon {
	display: inline-flex;
	align-items: center;
	flex: 0 0 auto;
}

.stoke-shortlist-toggle .stoke-shortlist-icon {
	display: block;
}

.stoke-shortlist-toggle.is-shortlisted .stoke-shortlist-icon {
	fill: currentColor;
	fill-opacity: 0.25;
}

/* -------------------------------------------------------------------------
 * Footer bar
 * ---------------------------------------------------------------------- */

.stoke-shortlist-bar {
	position: fixed;
	right: 0;
	bottom: 0;
	left: 0;
	z-index: var(--sslst-bar-z);
	box-sizing: border-box;
	padding: 0.75rem 1rem;
	padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
	border-top: 1px solid var(--sslst-bar-border);
	background: var(--sslst-bar-bg);
	color: var(--sslst-bar-color);
	font-size: 0.95rem;
	line-height: 1.4;
}

.stoke-shortlist-bar[hidden] {
	display: none;
}

/*
 * Structural positioning, repeated at ID + class specificity (1,1,0).
 *
 * A theme or page builder rule such as `.site-footer > div { position: relative }`
 * beats a single class selector and drops the bar back into the page flow. The
 * appearance stays on the class selectors so themes can still restyle the bar;
 * only the properties that must not be overridden are repeated here.
 *
 * This relies on the id in templates/bar.php — keep it in any theme override.
 */
#stoke-shortlist-bar.stoke-shortlist-bar {
	position: fixed;
	right: 0;
	bottom: 0;
	left: 0;
	z-index: var(--sslst-bar-z);
}

#stoke-shortlist-bar.stoke-shortlist-bar[hidden] {
	display: none;
}

.stoke-shortlist-bar *,
.stoke-shortlist-bar *::before,
.stoke-shortlist-bar *::after {
	box-sizing: inherit;
}

.stoke-shortlist-bar__inner {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--sslst-gap);
	max-width: 80rem;
	margin: 0 auto;
}

.stoke-shortlist-bar__summary {
	display: flex;
	flex-direction: column;
	gap: 0.15rem;
	min-width: 0;
}

.stoke-shortlist-bar__count {
	font-weight: 700;
}

.stoke-shortlist-bar__names {
	display: block;
	overflow: hidden;
	max-width: 100%;
	opacity: 0.8;
	font-size: 0.875em;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.stoke-shortlist-bar__actions {
	display: flex;
	align-items: center;
	flex: 0 0 auto;
	gap: 0.5rem;
}

.stoke-shortlist-bar__enquire,
.stoke-shortlist-bar__clear {
	padding: 0.55em 1.2em;
	border: 1px solid currentColor;
	border-radius: var(--sslst-radius);
	background: transparent;
	color: inherit;
	font: inherit;
	line-height: 1.2;
	cursor: pointer;
}

.stoke-shortlist-bar__enquire {
	border-color: var(--sslst-bar-color);
	background: var(--sslst-bar-color);
	color: var(--sslst-bar-bg);
	font-weight: 600;
}

.stoke-shortlist-bar__clear {
	opacity: 0.8;
}

.stoke-shortlist-bar__clear:hover,
.stoke-shortlist-bar__clear:focus-visible {
	opacity: 1;
}

/* -------------------------------------------------------------------------
 * Built-in modal
 * ---------------------------------------------------------------------- */

.stoke-shortlist-modal {
	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	z-index: var(--sslst-modal-z);
	display: flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	padding: 1rem;
}

.stoke-shortlist-modal[hidden] {
	display: none;
}

/* Same reasoning as the bar: the overlay must cover the viewport. */
#stoke-shortlist-modal.stoke-shortlist-modal {
	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	z-index: var(--sslst-modal-z);
	display: flex;
}

#stoke-shortlist-modal.stoke-shortlist-modal[hidden] {
	display: none;
}

.stoke-shortlist-modal *,
.stoke-shortlist-modal *::before,
.stoke-shortlist-modal *::after {
	box-sizing: inherit;
}

.stoke-shortlist-modal__overlay {
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	background: var(--sslst-modal-overlay);
}

.stoke-shortlist-modal__dialog {
	position: relative;
	overflow-y: auto;
	width: 100%;
	max-width: var(--sslst-modal-width);
	max-height: calc(100vh - 2rem);
	padding: 2rem;
	border-radius: var(--sslst-modal-radius);
	background: var(--sslst-modal-bg);
	color: var(--sslst-modal-color);
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
	-webkit-overflow-scrolling: touch;
}

.stoke-shortlist-modal__close {
	position: absolute;
	top: 0.75rem;
	right: 0.75rem;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2rem;
	height: 2rem;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: inherit;
	line-height: 1;
	cursor: pointer;
}

.stoke-shortlist-modal__close:hover,
.stoke-shortlist-modal__close:focus-visible {
	background: rgba(0, 0, 0, 0.06);
}

.stoke-shortlist-modal__title {
	margin: 0 2rem 1rem 0;
	color: inherit;
	font-size: 1.35rem;
	line-height: 1.25;
}

.stoke-shortlist-modal__names {
	margin: 0 0 1.5rem;
	padding: 0;
	list-style: none;
}

.stoke-shortlist-modal__names .stoke-shortlist-name {
	padding: 0.5rem 0;
	border-bottom: 1px solid rgba(0, 0, 0, 0.08);
	font-size: 0.95rem;
}

.stoke-shortlist-modal__names .stoke-shortlist-name:first-child {
	border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.stoke-shortlist-modal__form .gform_wrapper {
	margin: 0;
}

/* Generic pill submit button for whichever form is embedded. */
.stoke-shortlist-modal__form input[type="submit"],
.stoke-shortlist-modal__form button[type="submit"] {
	padding: 0.7em 1.6em;
	border: 0;
	border-radius: var(--sslst-radius);
	background: var(--sslst-button-bg);
	color: var(--sslst-button-color);
	font: inherit;
	line-height: 1.2;
	cursor: pointer;
}

body.stoke-shortlist-modal-open {
	overflow: hidden;
}

/* -------------------------------------------------------------------------
 * Responsive
 * ---------------------------------------------------------------------- */

@media (max-width: 600px) {
	.stoke-shortlist-bar__inner {
		align-items: stretch;
		flex-direction: column;
		gap: 0.5rem;
	}

	.stoke-shortlist-bar__actions {
		justify-content: space-between;
	}

	.stoke-shortlist-bar__enquire,
	.stoke-shortlist-bar__clear {
		flex: 1 1 auto;
	}

	.stoke-shortlist-modal {
		padding: 0.5rem;
	}

	.stoke-shortlist-modal__dialog {
		max-height: calc(100vh - 1rem);
		padding: 1.5rem 1.25rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	.stoke-shortlist-toggle {
		transition: none;
	}
}