/* The plan page serves two people. A first-time visitor sees the intro and
   the enquiry form around an empty builder; a traveller opening their
   personal link sees only the builder. */
.safiri-builder.is-idle {
	display: none;
}

.safiri-builder.is-live ~ * {
	display: none;
}

/*
 * Itinerary builder.
 *
 * Every colour and space is a theme.json token with a fallback, because this
 * plugin has to look right under a theme that knows nothing about it. Under
 * Safiri it inherits the palette; under anything else it degrades to a plain,
 * legible default rather than to something broken.
 *
 * Mobile first. The one genuinely hard interaction here is reordering stops on
 * a touchscreen, and the answer is explicit up/down buttons rather than drag
 * and drop — dragging a list item with a thumb, on a page that also scrolls,
 * is miserable and fails silently when it fails.
 */

.safiri-builder {
	--sf-ink: var(--wp--preset--color--contrast, #2B230C);
	--sf-soft: var(--wp--preset--color--contrast-soft, #5C4A1E);
	--sf-line: var(--wp--preset--color--border, #E2D6B6);
	--sf-surface: var(--wp--preset--color--surface, #ffffff);
	--sf-panel: var(--wp--preset--color--surface-alt, #F1E6C8);
	--sf-accent: var(--wp--preset--color--accent, #936F1B);
	--sf-primary: var(--wp--preset--color--primary, #41310C);
	--sf-radius: var(--wp--custom--radius--lg, 16px);
	--sf-tap: var(--wp--custom--control--min-height, 44px);

	color: var(--sf-ink);
	font-size: 1rem;
	line-height: 1.6;
}

.safiri-builder__layout {
	display: flex;
	flex-direction: column;
	gap: 1.5rem;
}

.safiri-builder__title {
	margin: 0 0 1rem;
}

/* --- stops ------------------------------------------------------------- */

.safiri-stops {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
}

.safiri-stop {
	display: grid;
	grid-template-columns: auto 1fr;
	gap: 0.25rem 1rem;
	align-items: start;
	background: var(--sf-surface);
	border: 1px solid var(--sf-line);
	border-radius: var(--sf-radius);
	padding: 1rem;
}

.safiri-stop__days {
	grid-row: span 2;
	min-width: 3.5rem;
	text-align: center;
	color: var(--sf-soft);
	font-size: 0.875rem;
}

.safiri-stop__dayrange {
	display: block;
	font-size: 1.125rem;
	color: var(--sf-ink);
}

.safiri-stop__name {
	margin: 0;
	font-size: 1.125rem;
}

.safiri-stop__nights {
	margin: 0.125rem 0 0;
	color: var(--sf-soft);
	font-size: 0.9375rem;
}

.safiri-stop__controls {
	grid-column: 2;
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin-top: 0.75rem;
}

.safiri-stop__order {
	display: flex;
	gap: 0.375rem;
}

/* --- controls ---------------------------------------------------------- */

.safiri-stepper {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	background: var(--sf-panel);
	border-radius: 999px;
	padding: 0.25rem;
}

.safiri-stepper__btn,
.safiri-icon-btn {
	min-width: var(--sf-tap);
	min-height: var(--sf-tap);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border: 1px solid var(--sf-line);
	background: var(--sf-surface);
	color: var(--sf-ink);
	font: inherit;
	font-size: 1.125rem;
	line-height: 1;
	cursor: pointer;
}

.safiri-stepper__btn {
	border: 0;
	border-radius: 999px;
}

.safiri-icon-btn {
	border-radius: 10px;
}

.safiri-icon-btn--danger {
	color: #9C3B1B;
	border-color: #E0BFB0;
}

.safiri-stepper__value {
	min-width: 2.5rem;
	text-align: center;
	font-size: 0.9375rem;
}

.safiri-tier {
	display: block;
	width: 100%;
	min-height: var(--sf-tap);
	margin-bottom: 0.5rem;
	padding: 0.5rem 0.875rem;
	text-align: left;
	background: var(--sf-surface);
	border: 1px solid var(--sf-line);
	border-radius: 12px;
	font: inherit;
	color: var(--sf-ink);
	cursor: pointer;
}

.safiri-tier.is-selected {
	background: var(--sf-panel);
	border: 2px solid var(--sf-accent);
	font-weight: 500;
}

/* --- summary ----------------------------------------------------------- */

.safiri-summary {
	background: var(--sf-surface);
	border: 1px solid var(--sf-line);
	border-radius: var(--sf-radius);
	padding: 1.25rem;
}

.safiri-field {
	margin-bottom: 1rem;
}

.safiri-field__label {
	display: block;
	margin-bottom: 0.375rem;
	font-size: 0.8125rem;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--sf-soft);
}

.safiri-input {
	width: 100%;
	min-height: var(--sf-tap);
	box-sizing: border-box;
	padding: 0 0.75rem;
	border: 1px solid var(--sf-line);
	border-radius: 10px;
	font: inherit;
	color: var(--sf-ink);
	background: var(--sf-surface);
}

.safiri-total {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 1rem;
	padding-top: 1rem;
	border-top: 1px solid var(--sf-line);
}

.safiri-total__value {
	font-size: 1.5rem;
}

.safiri-status {
	margin: 0.5rem 0 0;
	min-height: 1.5em;
	font-size: 0.875rem;
	color: var(--sf-soft);
}

.safiri-consent {
	display: flex;
	gap: 0.625rem;
	align-items: flex-start;
	/* The label is the tap target, not the 18px box inside it, so give the
	   whole row enough height for a thumb. */
	min-height: var(--sf-tap);
	padding: 0.5rem 0;
	margin-bottom: 0.25rem;
	font-size: 0.9375rem;
	line-height: 1.5;
	cursor: pointer;
}

.safiri-consent input {
	margin-top: 0.25rem;
	width: 1.125rem;
	height: 1.125rem;
	flex-shrink: 0;
}

.safiri-terms {
	/* A 22px text link is not a tap target. Booking terms are exactly the
	   thing a traveller should be able to open without aiming. */
	display: inline-flex;
	align-items: center;
	min-height: var(--sf-tap);
	margin-bottom: 0.5rem;
	font-size: 0.9375rem;
}

.safiri-book {
	width: 100%;
	min-height: 3.25rem;
	border: 0;
	border-radius: 999px;
	background: var(--sf-primary);
	color: var(--wp--preset--color--base, #ffffff);
	font: inherit;
	font-weight: 500;
	cursor: pointer;
}

.safiri-book[disabled] {
	opacity: 0.6;
	cursor: progress;
}

.safiri-empty {
	margin: 0;
	padding: 1.25rem;
	background: var(--sf-panel);
	border-radius: var(--sf-radius);
	color: var(--sf-soft);
}

.safiri-builder :focus-visible {
	outline: 2px solid var(--sf-accent);
	outline-offset: 2px;
}

/* --- editor placeholder ------------------------------------------------ */

.safiri-builder-placeholder {
	padding: 1.5rem;
	border: 1px dashed var(--wp--preset--color--border, #c3c4c7);
	border-radius: 12px;
	background: var(--wp--preset--color--surface-alt, #f6f7f7);
}

/* --- from tablet up ---------------------------------------------------- */

@media (min-width: 782px) {
	.safiri-builder__layout {
		flex-direction: row;
		align-items: flex-start;
	}

	.safiri-builder__main {
		flex: 1 1 auto;
		min-width: 0;
	}

	.safiri-builder__aside {
		flex: 0 0 22rem;
		position: sticky;
		top: 2rem;
	}

	.safiri-stop {
		grid-template-columns: auto 1fr auto;
	}

	.safiri-stop__controls {
		grid-column: 3;
		grid-row: span 2;
		margin-top: 0;
		flex-direction: column;
		align-items: flex-end;
	}
}

@media (prefers-reduced-motion: reduce) {
	.safiri-builder * {
		transition: none !important;
	}
}
