/* Previous Lunch Payment form - loaded only on that product page */
.dca-prev-lunch {
	margin-bottom: 32px;
}

.dca-prev-lunch fieldset {
	border: 0;
	margin: 0 0 24px;
	padding: 0;
}

.dca-prev-lunch legend {
	display: block;
	font-weight: 900;
	margin-bottom: 8px;
}

.dca-prev-lunch__student {
	display: grid;
	gap: 12px 16px;
	grid-template-columns: 1fr 1fr;
}

.dca-prev-lunch__student legend {
	grid-column: 1 / -1;
}

.dca-prev-lunch__student p {
	margin: 0;
}

.dca-prev-lunch__student label {
	display: block;
	margin-bottom: 4px;
}

.dca-prev-lunch__student input,
.dca-prev-lunch__student select {
	box-sizing: border-box;
	width: 100%;
}

.dca-prev-lunch__day {
	border-bottom: 1px solid #e4decd;
	color: #1e2d31;
	margin: 16px 0 4px;
	padding-bottom: 4px;
}

/* Weekday tag sitting above each lunch title */
.dca-prev-lunch__tag {
	background: #1e2d31;
	border-radius: 3px;
	color: #fff;
	display: block;
	font-size: 0.7em;
	font-weight: 700;
	letter-spacing: 0.08em;
	line-height: 1.6;
	margin-bottom: 4px;
	padding: 1px 8px;
	text-transform: uppercase;
	width: fit-content;
}

.dca-prev-lunch__meal {
	align-items: center;
	display: grid;
	gap: 12px;
	grid-template-columns: 1fr auto auto;
	padding: 6px 0;
}

.dca-prev-lunch__meal input {
	text-align: center;
	width: 64px;
}

/* The JS wraps each box as [ − ] box [ + ]; the buttons only show on touch screens. */
.dca-prev-lunch__stepper {
	align-items: center;
	display: inline-flex;
	gap: 6px;
}

.dca-prev-lunch__step {
	display: none;
}

.dca-prev-lunch__price {
	white-space: nowrap;
}

/* Fixed height so the total updating never shifts the layout */
/* Money green #1e7b34: 5.3:1 contrast on white, passes WCAG AA */
.dca-prev-lunch__total {
	border-top: 2px solid #1e2d31;
	color: #1e7b34;
	font-size: 1.75em;
	font-weight: 900;
	line-height: 1.4;
	margin: 12px 0 0;
	min-height: 1.4em;
	padding-top: 8px;
	text-align: right;
}

/* The initial $0.00 is wc_price() markup; keep it from picking up the theme's price color */
.dca-prev-lunch__total .amount {
	color: inherit;
}

/* Right-align the button under the total. WooCommerce floats it left with
   ".woocommerce div.product form.cart .button", so match that and go one higher. */
.woocommerce div.product form.cart .single_add_to_cart_button {
	display: block;
	float: none;
	margin-left: auto;
}

.single_add_to_cart_button:disabled {
	cursor: not-allowed;
	opacity: 0.5;
}

@media (max-width: 600px) {
	.dca-prev-lunch__student {
		grid-template-columns: 1fr;
	}
}

/* Phones and touch screens: name on its own line, then price and a − / + stepper
   with 44px tap targets (Apple's minimum). */
@media (max-width: 600px), (pointer: coarse) {
	.dca-prev-lunch__meal {
		border-bottom: 1px solid #e4decd;
		grid-template-areas: "name name" "price stepper";
		grid-template-columns: 1fr auto;
		padding: 10px 0;
		row-gap: 6px;
	}

	.dca-prev-lunch__meal label {
		grid-area: name;
	}

	.dca-prev-lunch__price {
		grid-area: price;
	}

	.dca-prev-lunch__stepper {
		grid-area: stepper;
	}

	/* Doubled class + attribute selectors: the theme's own input and button rules
	   are specific enough to override plain class selectors here. */
	.dca-prev-lunch .dca-prev-lunch__stepper input[type="number"] {
		-moz-appearance: textfield;
		appearance: textfield;
		flex: 0 0 52px;
		height: 44px;
		max-width: 52px;
		min-width: 0;
		padding: 0;
		width: 52px;
	}

	/* The browser's tiny spin arrows are redundant next to − and + */
	.dca-prev-lunch__meal input::-webkit-inner-spin-button,
	.dca-prev-lunch__meal input::-webkit-outer-spin-button {
		-webkit-appearance: none;
		margin: 0;
	}

	.dca-prev-lunch .dca-prev-lunch__stepper button.dca-prev-lunch__step {
		align-items: center;
		background: #fff;
		border: 1px solid #1e2d31;
		border-radius: 4px;
		box-shadow: none;
		color: #1e2d31;
		cursor: pointer;
		display: inline-flex;
		flex: 0 0 44px;
		font-size: 24px;
		font-weight: 700;
		height: 44px;
		justify-content: center;
		line-height: 1;
		margin: 0;
		max-width: 44px;
		min-width: 44px;
		padding: 0;
		text-transform: none;
		/* No double-tap zoom when tapping + quickly */
		touch-action: manipulation;
		width: 44px;
	}

	/* Keep the total pinned to the bottom of the screen while scrolling the meal
	   list; it drops back into place when its spot is reached. Pure CSS (sticky
	   stays inside the meals fieldset), so there's no scroll JS to cost anything. */
	/* The theme's main wrapper uses overflow: hidden, which switches sticky off for
	   everything inside it. clip trims overflow the same way without doing that.
	   Browsers without clip (Safari < 16) keep hidden and simply don't pin. */
	main.main-site {
		overflow: clip;
	}

	.dca-prev-lunch .dca-prev-lunch__total {
		background: #fff;
		bottom: 0;
		box-shadow: 0 -6px 12px -6px rgba(30, 45, 49, 0.25);
		padding-bottom: calc(8px + env(safe-area-inset-bottom));
		position: sticky;
		z-index: 5;
	}

	.dca-prev-lunch .dca-prev-lunch__stepper button.dca-prev-lunch__step:disabled {
		cursor: default;
		opacity: 0.35;
	}
}
