/**
 * tlr-addons.css — Add-ons selection modal overlay
 *
 * Styled to the Tacos La Rana design system: theme.json presets with
 * hard-coded fallbacks so the modal stays on-brand under any theme.
 * Bottom sheet on mobile, centered card on desktop.
 */

:root {
	--tlr-modal-ink: var( --wp--preset--color--contrast, #16150F );
	--tlr-modal-ink-2: var( --wp--preset--color--muted, #5B5A50 );
	--tlr-modal-line: var( --wp--preset--color--line, #E4E3DC );
	--tlr-modal-green: var( --wp--preset--color--rana-green, #5E9418 );
	--tlr-modal-green-soft: var( --wp--preset--color--green-soft, #EDF3E0 );
	--tlr-modal-bg: var( --wp--preset--color--base, #FAFAF7 );
	--tlr-modal-ease: cubic-bezier( 0.22, 0.61, 0.36, 1 );
}

/* ── Modal container ──────────────────────────────────────────────────────── */

.tlr-addons-modal {
	display: none; /* JS sets aria-hidden and controls visibility via class */
	position: fixed;
	inset: 0;
	z-index: 99999;
}

.tlr-addons-modal.is-open {
	display: flex;
	align-items: flex-end; /* Panel slides up from bottom on mobile */
	justify-content: center;
}

/* ── Dim overlay ───────────────────────────────────────────────────────────── */

.tlr-addons-modal__overlay {
	position: absolute;
	inset: 0;
	background: rgba( 22, 21, 15, 0.45 );
	backdrop-filter: blur( 2px );
	-webkit-backdrop-filter: blur( 2px );
	animation: tlr-fade-in 0.2s ease;
}

/* ── Panel ─────────────────────────────────────────────────────────────────── */

.tlr-addons-modal__panel {
	position: relative;
	z-index: 1;
	width: 100%;
	max-width: 520px;
	max-height: 82vh;
	display: flex;
	flex-direction: column;
	background: #fff;
	border-radius: 16px 16px 0 0;
	overflow: hidden;
	box-shadow: 0 30px 80px rgba( 0, 0, 0, 0.25 );
	animation: tlr-slide-up 0.32s var( --tlr-modal-ease );
}

@media ( min-width: 640px ) {
	.tlr-addons-modal.is-open {
		align-items: center;
	}

	.tlr-addons-modal__panel {
		border-radius: 16px;
		margin: 16px;
	}
}

/* ── Header ─────────────────────────────────────────────────────────────────── */

.tlr-addons-modal__header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
	padding: 24px 28px 16px;
	border-bottom: 1px solid var( --tlr-modal-line );
	flex-shrink: 0;
}

.tlr-addons-modal__product-name {
	font-family: var( --wp--preset--font-family--display, inherit );
	font-size: 1.2rem;
	font-weight: 700;
	letter-spacing: -0.01em;
	color: var( --tlr-modal-ink );
	margin: 0 0 4px;
	line-height: 1.25;
}

.tlr-addons-modal__base-price {
	font-family: var( --wp--preset--font-family--mono, inherit );
	font-size: 0.9rem;
	color: var( --tlr-modal-ink-2 );
	margin: 0;
}

.tlr-addons-modal__close {
	flex-shrink: 0;
	background: transparent;
	border: 1px solid var( --tlr-modal-line );
	border-radius: 50%;
	width: 38px;
	height: 38px;
	font-size: 1.25rem;
	line-height: 1;
	cursor: pointer;
	color: var( --tlr-modal-ink );
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	transition: border-color 0.2s ease;
}

.tlr-addons-modal__close:hover,
.tlr-addons-modal__close:focus {
	border-color: var( --tlr-modal-ink );
	background: transparent;
}

/* ── Body / add-on list ────────────────────────────────────────────────────── */

.tlr-addons-modal__body {
	flex: 1 1 auto;
	overflow-y: auto;
	overflow-x: hidden; /* no sideways scrollbar — inputs are border-boxed */
	padding: 20px 28px;
}

.tlr-addons-modal__prompt {
	font-family: var( --wp--preset--font-family--mono, inherit );
	font-size: 0.72rem;
	font-weight: 500;
	text-transform: uppercase;
	letter-spacing: 0.22em;
	color: var( --tlr-modal-green );
	margin: 0 0 12px;
}

.tlr-addons-modal__list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

/* ── Individual addon row ──────────────────────────────────────────────────── */

.tlr-addon-row {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 13px 16px;
	border: 1px solid var( --tlr-modal-line );
	border-radius: 10px;
	background: var( --tlr-modal-bg );
	cursor: pointer;
	transition: border-color 0.2s ease, background 0.2s ease;
	user-select: none;
}

.tlr-addon-row:hover {
	border-color: var( --tlr-modal-ink );
	background: #fff;
}

.tlr-addon-row.is-checked {
	border-color: var( --tlr-modal-green );
	background: var( --tlr-modal-green-soft );
}

.tlr-addon-row__checkbox {
	flex-shrink: 0;
	width: 18px;
	height: 18px;
	accent-color: var( --tlr-modal-green );
	cursor: pointer;
}

.tlr-addon-row__label {
	flex: 1 1 auto;
	font-size: 0.95rem;
	font-weight: 500;
	color: var( --tlr-modal-ink );
	cursor: pointer;
}

.tlr-addon-row__price {
	flex-shrink: 0;
	font-family: var( --wp--preset--font-family--mono, inherit );
	font-size: 0.88rem;
	font-weight: 500;
	color: var( --tlr-modal-green );
	white-space: nowrap;
}

/* ── Footer ─────────────────────────────────────────────────────────────────── */

.tlr-addons-modal__footer {
	flex-shrink: 0;
	padding: 16px 28px 24px;
	border-top: 1px solid var( --tlr-modal-line );
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	background: #fff;
}

@supports ( padding: env( safe-area-inset-bottom ) ) {
	.tlr-addons-modal__footer {
		padding-bottom: calc( 24px + env( safe-area-inset-bottom ) );
	}
}

.tlr-addons-modal__total {
	margin: 0;
	font-size: 0.85rem;
	color: var( --tlr-modal-ink-2 );
}

.tlr-addons-modal__total-value {
	display: block;
	font-family: var( --wp--preset--font-family--mono, inherit );
	font-size: 1.1rem;
	font-weight: 700;
	color: var( --tlr-modal-ink );
}

.tlr-addons-modal__submit {
	flex: 1 1 auto;
	max-width: 300px;
	background: var( --tlr-modal-green );
	color: #fff;
	border: none;
	border-radius: 99px;
	padding: 14px 28px;
	font-size: 0.95rem;
	font-weight: 700;
	letter-spacing: 0.02em;
	cursor: pointer;
	min-height: 48px;
	transition: background 0.25s var( --tlr-modal-ease ), transform 0.25s var( --tlr-modal-ease ), opacity 0.15s;
}

.tlr-addons-modal__submit:hover:not( :disabled ) {
	background: var( --tlr-modal-ink );
	transform: translateY( -2px );
}

.tlr-addons-modal__submit:disabled {
	opacity: 0.45;
	cursor: not-allowed;
}

.tlr-addons-modal__submit.tlr-btn--loading {
	opacity: 0.6;
	pointer-events: none;
}

/* ── Variant rows (grouped items — choose your option) ─────────────────────── */

.tlr-variant-row__radio {
	flex-shrink: 0;
	width: 18px;
	height: 18px;
	accent-color: var( --tlr-modal-green );
	cursor: pointer;
}

.tlr-variant-row.is-soldout {
	opacity: 0.55;
	cursor: not-allowed;
}

.tlr-variant-row.is-soldout .tlr-addon-row__price {
	text-decoration: line-through;
	color: var( --tlr-modal-ink-2 );
}

.tlr-variant-row__soldout {
	display: inline-block;
	margin-left: 8px;
	font-family: var( --wp--preset--font-family--mono, inherit );
	font-size: 0.6rem;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	background: var( --tlr-modal-line );
	color: var( --tlr-modal-ink-2 );
	padding: 2px 8px;
	border-radius: 99px;
	vertical-align: middle;
}

/* Sub-section: the selected variant's add-ons, revealed below the radios. */
.tlr-addons-modal__prompt--sub {
	margin-top: 20px;
}

.tlr-addons-modal__list--sub {
	margin-top: 0;
}

/* ── Special requests (per-item note) ──────────────────────────────────────── */

.tlr-addons-modal__note {
	margin-top: 18px;
}

.tlr-addons-modal__note .tlr-addons-modal__prompt {
	display: block;
	margin-bottom: 8px;
}

.tlr-addons-modal__note-input {
	box-sizing: border-box; /* width:100% + padding must not overflow */
	width: 100%;
	padding: 12px 14px;
	border: 1px solid var( --tlr-modal-line );
	border-radius: 10px;
	background: var( --tlr-modal-bg );
	font-size: 16px; /* prevent iOS focus-zoom */
	min-height: 44px;
	color: var( --tlr-modal-ink );
	transition: border-color 0.2s ease;
}

.tlr-addons-modal__note-input:focus {
	outline: none;
	border-color: var( --tlr-modal-green );
}

/* ── Animations ─────────────────────────────────────────────────────────────── */

@keyframes tlr-slide-up {
	from { transform: translateY( 40px ); opacity: 0; }
	to   { transform: translateY( 0 );    opacity: 1; }
}

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

@media ( prefers-reduced-motion: reduce ) {
	.tlr-addons-modal__panel,
	.tlr-addons-modal__overlay {
		animation: none;
	}
}

/* ── Accessibility: focus outline ────────────────────────────────────────────── */

.tlr-addons-modal__panel *:focus-visible {
	outline: 2px solid var( --tlr-modal-green );
	outline-offset: 2px;
}
