/**
 * FTM cash-on-delivery popup checkout.
 * Uses the theme's own colour and type variables so it reads as part of the store.
 */

.ftmcp {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: flex-end;
	justify-content: center;
}

.ftmcp[hidden] {
	display: none;
}

.ftmcp__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(17, 17, 17, 0.55);
	backdrop-filter: blur(2px);
	animation: ftmcp-fade 0.2s ease-out;
}

.ftmcp__dialog {
	position: relative;
	display: flex;
	flex-direction: column;
	width: 100%;
	max-width: 30rem;
	max-height: 94vh;
	max-height: 94dvh;
	background: var(--ftm-background, #fff);
	color: var(--ftm-text, #111);
	border-radius: 14px 14px 0 0;
	box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.22);
	animation: ftmcp-rise 0.26s cubic-bezier(0.2, 0.8, 0.3, 1);
	outline: none;
}

@keyframes ftmcp-fade {
	from { opacity: 0; }
	to { opacity: 1; }
}

@keyframes ftmcp-rise {
	from { transform: translateY(24px); opacity: 0; }
	to { transform: translateY(0); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
	.ftmcp__backdrop,
	.ftmcp__dialog {
		animation: none;
	}
}

html.ftmcp-locked,
html.ftmcp-locked body {
	overflow: hidden;
}

/* ------------------------------------------------------------------ header */

.ftmcp__header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 1rem;
	padding: 1.1rem 1.25rem 0.85rem;
	border-bottom: 1px solid var(--ftm-border, #e6e2dc);
}

.ftmcp__eyebrow {
	margin: 0 0 0.15rem;
	font-size: 0.68rem;
	letter-spacing: 0.16em;
	text-transform: uppercase;
	color: var(--ftm-muted, #8a8279);
}

.ftmcp__title {
	margin: 0;
	font-family: "Cormorant Garamond", Georgia, serif;
	font-size: 1.5rem;
	font-weight: 500;
	line-height: 1.15;
	color: var(--ftm-heading, #111);
}

.ftmcp__close {
	flex: 0 0 auto;
	display: grid;
	place-items: center;
	width: 2.25rem;
	height: 2.25rem;
	margin: -0.25rem -0.35rem 0 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--ftm-text, #111);
	cursor: pointer;
	transition: background-color 0.15s ease;
}

.ftmcp__close:hover,
.ftmcp__close:focus-visible {
	background: rgba(17, 17, 17, 0.07);
}

.ftmcp__close svg {
	width: 1.05rem;
	height: 1.05rem;
}

/* ------------------------------------------------------------------- body */

.ftmcp__scroll {
	overflow-y: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
	padding: 1rem 1.25rem 1.5rem;
}

.ftmcp__notice {
	margin: 0 0 1rem;
	padding: 0.7rem 0.85rem;
	border-radius: 8px;
	background: var(--ftm-surface, #f6f3ef);
	border: 1px solid var(--ftm-border, #e6e2dc);
	font-size: 0.85rem;
	line-height: 1.75;
	color: var(--ftm-text, #111);
}

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

.ftmcp__summary {
	margin-bottom: 1.25rem;
}

.ftmcp__loading {
	margin: 0;
	padding: 1rem 0;
	text-align: center;
	color: var(--ftm-muted, #8a8279);
}

.ftmcp__item {
	display: flex;
	align-items: flex-start;
	gap: 0.75rem;
	padding: 0.6rem 0;
	border-bottom: 1px solid var(--ftm-border, #e6e2dc);
}

.ftmcp__item-image {
	flex: 0 0 auto;
	width: 3.25rem;
	height: 3.25rem;
	border-radius: 6px;
	object-fit: cover;
	background: var(--ftm-surface, #f6f3ef);
}

.ftmcp__item-body {
	flex: 1 1 auto;
	min-width: 0;
}

.ftmcp__item-name {
	margin: 0 0 0.15rem;
	font-size: 0.9rem;
	font-weight: 500;
	line-height: 1.35;
}

.ftmcp__item-meta {
	margin: 0;
	font-size: 0.78rem;
	color: var(--ftm-muted, #8a8279);
}

.ftmcp__item-total {
	flex: 0 0 auto;
	margin: 0;
	font-size: 0.9rem;
	font-weight: 500;
	white-space: nowrap;
}

.ftmcp__qty {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding: 0.85rem 0;
	border-bottom: 1px solid var(--ftm-border, #e6e2dc);
}

.ftmcp__qty-label {
	font-size: 0.72rem;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: var(--ftm-muted, #8a8279);
}

.ftmcp__stepper {
	display: inline-flex;
	align-items: center;
	border: 1px solid var(--ftm-border, #d9d4cc);
	border-radius: 6px;
	overflow: hidden;
}

.ftmcp__stepper button {
	width: 2.3rem;
	height: 2.3rem;
	border: 0;
	background: transparent;
	font-size: 1rem;
	line-height: 1;
	color: var(--ftm-text, #111);
	cursor: pointer;
}

.ftmcp__stepper button:hover {
	background: var(--ftm-surface, #f6f3ef);
}

.ftmcp__stepper input {
	width: 2.75rem;
	height: 2.3rem;
	padding: 0;
	border: 0;
	border-left: 1px solid var(--ftm-border, #d9d4cc);
	border-right: 1px solid var(--ftm-border, #d9d4cc);
	text-align: center;
	font-size: 0.9rem;
	background: transparent;
	color: inherit;
	-moz-appearance: textfield;
}

.ftmcp__stepper input::-webkit-outer-spin-button,
.ftmcp__stepper input::-webkit-inner-spin-button {
	-webkit-appearance: none;
	margin: 0;
}

.ftmcp__totals {
	margin: 0.85rem 0 0;
}

.ftmcp__totals > div {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 1rem;
	padding: 0.28rem 0;
}

.ftmcp__totals dt,
.ftmcp__totals dd {
	margin: 0;
	font-size: 0.88rem;
	color: var(--ftm-muted, #8a8279);
}

.ftmcp__totals dd {
	color: var(--ftm-text, #111);
}

.ftmcp__totals-grand {
	margin-top: 0.3rem;
	padding-top: 0.6rem !important;
	border-top: 1px solid var(--ftm-border, #e6e2dc);
}

.ftmcp__totals-grand dt {
	font-size: 0.78rem;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--ftm-text, #111);
}

.ftmcp__totals-grand dd {
	font-size: 1.15rem;
	font-weight: 600;
	color: var(--ftm-heading, #111);
}

/* ------------------------------------------------------------------- form */

.ftmcp__field {
	margin-bottom: 0.85rem;
}

.ftmcp__row {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 0.75rem;
}

.ftmcp__field label {
	display: block;
	margin-bottom: 0.3rem;
	font-size: 0.74rem;
	font-weight: 600;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--ftm-heading, #111);
}

.ftmcp__field label span {
	color: var(--ftm-sale, #b3261e);
}

.ftmcp__field label .ftmcp__optional {
	font-weight: 400;
	letter-spacing: 0.02em;
	text-transform: none;
	color: var(--ftm-muted, #8a8279);
}

.ftmcp__field input,
.ftmcp__field select,
.ftmcp__field textarea {
	width: 100%;
	padding: 0.7rem 0.75rem;
	border: 1px solid var(--ftm-border, #d9d4cc);
	border-radius: 6px;
	background: #fff;
	color: var(--ftm-text, #111);
	font-family: inherit;
	font-size: 0.95rem;
	line-height: 1.4;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
	-webkit-appearance: none;
	appearance: none;
}

.ftmcp__field select {
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%23111' stroke-width='1.4'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 0.75rem center;
	background-size: 0.7rem;
	padding-right: 2rem;
}

.ftmcp__field textarea {
	resize: vertical;
	min-height: 4.5rem;
}

.ftmcp__field input:focus,
.ftmcp__field select:focus,
.ftmcp__field textarea:focus {
	outline: none;
	border-color: var(--ftm-primary, #111);
	box-shadow: 0 0 0 3px rgba(17, 17, 17, 0.08);
}

.ftmcp__field input.is-invalid,
.ftmcp__field select.is-invalid,
.ftmcp__field textarea.is-invalid {
	border-color: var(--ftm-sale, #b3261e);
	box-shadow: 0 0 0 3px rgba(179, 38, 30, 0.1);
}

.ftmcp__hint {
	margin: 0.3rem 0 0;
	font-size: 0.75rem;
	color: var(--ftm-muted, #8a8279);
}

.ftmcp__error {
	margin: 0.3rem 0 0;
	font-size: 0.78rem;
	color: var(--ftm-sale, #b3261e);
}

.ftmcp__form-error {
	margin: 0 0 0.85rem;
	padding: 0.65rem 0.8rem;
	border-radius: 6px;
	border: 1px solid rgba(179, 38, 30, 0.35);
	background: rgba(179, 38, 30, 0.06);
	font-size: 0.85rem;
	color: var(--ftm-sale, #b3261e);
}

.ftmcp__hp {
	position: absolute;
	left: -9999px;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

/* ----------------------------------------------------------------- submit */

.ftmcp__submit {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.6rem;
	width: 100%;
	min-height: 3rem;
	margin-top: 0.35rem;
	padding: 0.9rem 1rem;
	border: 0;
	border-radius: 6px;
	background: var(--ftm-primary, #111);
	color: #fff;
	font-family: inherit;
	font-size: 0.8rem;
	font-weight: 500;
	letter-spacing: 0.16em;
	text-transform: uppercase;
	cursor: pointer;
	transition: opacity 0.15s ease, transform 0.15s ease;
}

.ftmcp__submit:hover:not(:disabled) {
	opacity: 0.9;
}

.ftmcp__submit:active:not(:disabled) {
	transform: translateY(1px);
}

.ftmcp__submit:disabled {
	opacity: 0.65;
	cursor: progress;
}

.ftmcp__spinner {
	display: none;
	width: 1rem;
	height: 1rem;
	border: 2px solid rgba(255, 255, 255, 0.35);
	border-top-color: #fff;
	border-radius: 50%;
	animation: ftmcp-spin 0.7s linear infinite;
}

.ftmcp__submit.is-busy .ftmcp__spinner {
	display: block;
}

@keyframes ftmcp-spin {
	to { transform: rotate(360deg); }
}

.ftmcp__alt {
	margin: 0.85rem 0 0;
	text-align: center;
	font-size: 0.8rem;
	color: var(--ftm-muted, #8a8279);
}

.ftmcp__alt a {
	color: var(--ftm-text, #111);
	text-underline-offset: 3px;
}

/* ------------------------------------------- inline prompt on product pages */

.ftmcp-inline-notice {
	margin: 0 0 0.6rem;
	padding: 0.6rem 0.8rem;
	border-radius: 6px;
	border: 1px solid rgba(179, 38, 30, 0.35);
	background: rgba(179, 38, 30, 0.06);
	font-size: 0.85rem;
	color: var(--ftm-sale, #b3261e);
}

/* ----------------------------------------------------------- larger screens */

@media (min-width: 640px) {
	.ftmcp {
		align-items: center;
		padding: 1.5rem;
	}

	.ftmcp__dialog {
		max-width: 34rem;
		max-height: 88vh;
		border-radius: 12px;
		box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
	}

	.ftmcp__header {
		padding: 1.4rem 1.6rem 1rem;
	}

	.ftmcp__scroll {
		padding: 1.2rem 1.6rem 1.6rem;
	}
}
