/* WC Upload Before Checkout — text customization (modal + button) */

.wcup-text,
.wcup-modal {
	--wcup-bg: #ffffff;
	--wcup-surface: #fafafa;
	--wcup-surface-2: #f4f4f5;
	--wcup-border: #e4e4e7;
	--wcup-border-strong: #d4d4d8;
	--wcup-text-primary: #18181b;
	--wcup-text-muted: #71717a;
	--wcup-text-subtle: #a1a1aa;
	--wcup-accent: #18181b;
	--wcup-success: #16a34a;
	--wcup-danger: #dc2626;
	--wcup-radius-lg: 14px;
	--wcup-radius: 10px;
	--wcup-radius-sm: 8px;
	--wcup-shadow-sm: 0 1px 2px rgba(24, 24, 27, 0.04);
	--wcup-shadow: 0 1px 3px rgba(24, 24, 27, 0.06), 0 1px 2px rgba(24, 24, 27, 0.04);
	--wcup-shadow-md: 0 4px 12px rgba(24, 24, 27, 0.06), 0 2px 4px rgba(24, 24, 27, 0.04);
	--wcup-shadow-lg: 0 20px 50px rgba(24, 24, 27, 0.18), 0 10px 20px rgba(24, 24, 27, 0.08);
	--wcup-ease: cubic-bezier(0.4, 0, 0.2, 1);
	font: inherit;
	color: var(--wcup-text-primary);
	box-sizing: border-box;
}

.wcup-text *, .wcup-text *::before, .wcup-text *::after,
.wcup-modal *, .wcup-modal *::before, .wcup-modal *::after {
	box-sizing: inherit;
}

.wcup-text [hidden], .wcup-modal [hidden],
.wcup-text[hidden], .wcup-modal[hidden] {
	display: none !important;
}

/* ============================================================
   Trigger button on the product page
   ============================================================ */

.wcup-text {
	display: block;
	max-width: 560px;
	margin-top: 12px;
}

.wcup-text__open {
	appearance: none;
	display: inline-flex;
	align-items: center;
	gap: 10px;
	padding: 12px 18px;
	background: var(--wcup-bg);
	border: 1.5px solid var(--wcup-border-strong);
	border-radius: var(--wcup-radius);
	color: var(--wcup-text-primary);
	font: inherit;
	font-weight: 600;
	cursor: pointer;
	transition: border-color 0.15s var(--wcup-ease), background 0.15s var(--wcup-ease), box-shadow 0.15s var(--wcup-ease);
}

.wcup-text__open:hover {
	border-color: var(--wcup-text-muted);
	background: var(--wcup-surface);
	box-shadow: var(--wcup-shadow);
}

.wcup-text__open-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	color: var(--wcup-text-primary);
}

.wcup-text__count {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 22px;
	height: 22px;
	padding: 0 7px;
	margin-left: 2px;
	background: #f0fdf4;
	color: #15803d;
	border: 1px solid #bbf7d0;
	border-radius: 999px;
	font-size: 0.75em;
	font-weight: 700;
}

.wcup-text__open[data-has-customizations="1"] {
	border-color: var(--wcup-success);
	background: #f0fdf4;
	color: #15803d;
}

.wcup-text__open[data-has-customizations="1"] .wcup-text__open-icon {
	color: #15803d;
}

/* ============================================================
   Modal
   ============================================================ */

.wcup-modal {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
}

.wcup-modal__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(24, 24, 27, 0.45);
	backdrop-filter: blur(4px);
	-webkit-backdrop-filter: blur(4px);
	animation: wcup-fade-in 0.18s var(--wcup-ease);
}

.wcup-modal__panel {
	position: relative;
	display: flex;
	flex-direction: column;
	width: 100%;
	max-width: 580px;
	max-height: 90vh;
	background: var(--wcup-bg);
	border-radius: var(--wcup-radius-lg);
	box-shadow: var(--wcup-shadow-lg);
	overflow: hidden;
	animation: wcup-pop-in 0.22s var(--wcup-ease);
	/* Tightens overall popup typography — every em-based size below cascades from this. */
	font-size: 14px;
	line-height: 1.45;
}

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

@keyframes wcup-pop-in {
	from { opacity: 0; transform: scale(0.96) translateY(6px); }
	to   { opacity: 1; transform: scale(1) translateY(0); }
}

.wcup-modal__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 16px 20px;
	border-bottom: 1px solid var(--wcup-border);
}

.wcup-modal .wcup-modal__title,
h1.wcup-modal__title,
h2.wcup-modal__title,
h3.wcup-modal__title {
	margin: 0 !important;
	padding: 0 !important;
	font-size: 14px !important;
	font-weight: 700 !important;
	line-height: 1.3 !important;
	letter-spacing: -0.01em !important;
	color: var(--wcup-text-primary) !important;
	text-transform: none !important;
	font-family: inherit !important;
	border: 0 !important;
	background: transparent !important;
}

.wcup-modal__close {
	appearance: none;
	background: transparent;
	border: 0;
	width: 32px;
	height: 32px;
	border-radius: 50%;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	color: var(--wcup-text-muted);
	cursor: pointer;
	transition: background 0.15s var(--wcup-ease), color 0.15s var(--wcup-ease);
}

.wcup-modal__close:hover {
	background: var(--wcup-surface);
	color: var(--wcup-text-primary);
}

.wcup-modal__body {
	flex: 1;
	overflow-y: auto;
	padding: 16px 20px 8px;
	background: var(--wcup-surface);
}

.wcup-modal__customizations {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.wcup-modal__add-customization {
	width: 100%;
	margin: 14px 0 6px;
	appearance: none;
	background: var(--wcup-bg);
	border: 1.5px dashed var(--wcup-border-strong);
	color: var(--wcup-text-primary);
	padding: 12px 14px;
	border-radius: var(--wcup-radius);
	font: inherit;
	font-weight: 600;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	transition: border-color 0.15s var(--wcup-ease), background 0.15s var(--wcup-ease);
}

.wcup-modal__add-customization:hover {
	border-color: var(--wcup-text-muted);
	background: var(--wcup-surface-2);
}

.wcup-modal__foot {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding: 14px 20px;
	border-top: 1px solid var(--wcup-border);
	background: var(--wcup-bg);
}

.wcup-modal__cancel,
.wcup-modal__save {
	appearance: none;
	font: inherit;
	font-size: 0.92em;
	font-weight: 600;
	padding: 8px 16px;
	border-radius: var(--wcup-radius-sm);
	cursor: pointer;
	transition: background 0.15s var(--wcup-ease), border-color 0.15s var(--wcup-ease), color 0.15s var(--wcup-ease);
	border: 1px solid var(--wcup-border-strong);
}

.wcup-modal__cancel {
	background: var(--wcup-bg);
	color: var(--wcup-text-primary);
}

.wcup-modal__cancel:hover {
	background: var(--wcup-surface);
}

.wcup-modal__save {
	background: var(--wcup-accent);
	color: #fff;
	border-color: var(--wcup-accent);
}

.wcup-modal__save:hover {
	background: #000;
}

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

/* ============================================================
   Customization card (inside modal)
   ============================================================ */

.wcup-text__customization {
	background: var(--wcup-bg);
	border: 1px solid var(--wcup-border);
	border-radius: var(--wcup-radius);
	overflow: hidden;
}

.wcup-text__customization-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 8px 12px;
	background: var(--wcup-bg);
	border-bottom: 1px solid var(--wcup-border);
}

.wcup-text__customization[data-collapsed="true"] .wcup-text__customization-head {
	border-bottom-color: transparent;
}

.wcup-text__customization-toggle {
	flex: 1;
	min-width: 0;
	appearance: none;
	background: transparent;
	border: 0;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 4px 0;
	cursor: pointer;
	font: inherit;
	color: var(--wcup-text-primary);
	text-align: left;
}

.wcup-text__customization-caret {
	display: inline-flex;
	width: 10px;
	height: 10px;
	transition: transform 0.18s var(--wcup-ease);
	flex: 0 0 auto;
	color: var(--wcup-text-muted);
}

.wcup-text__customization-caret::before {
	content: "";
	display: block;
	width: 6px;
	height: 6px;
	border: solid currentColor;
	border-width: 0 1.5px 1.5px 0;
	transform: rotate(45deg);
	margin: 2px 0 0 1px;
}

.wcup-text__customization[data-collapsed="true"] .wcup-text__customization-caret {
	transform: rotate(-90deg);
}

.wcup-text__customization-label {
	font-weight: 600;
	font-size: 0.92em;
	flex: 0 0 auto;
}

.wcup-text__customization-summary {
	font-weight: 400;
	color: var(--wcup-text-subtle);
	font-size: 0.85em;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	min-width: 0;
}

.wcup-text__customization-remove {
	appearance: none;
	background: transparent;
	border: 0;
	width: 26px;
	height: 26px;
	border-radius: 50%;
	color: var(--wcup-text-subtle);
	font-size: 18px;
	line-height: 1;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	transition: background 0.15s var(--wcup-ease), color 0.15s var(--wcup-ease);
}

.wcup-text__customization-remove:hover {
	background: #fef2f2;
	color: var(--wcup-danger);
}

.wcup-text__customization-body {
	padding: 12px;
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.wcup-text__customization[data-collapsed="true"] .wcup-text__customization-body {
	display: none;
}

.wcup-text__font-row {
	display: flex;
	align-items: center;
	gap: 8px;
}

.wcup-text__font-label {
	font-size: 0.78em;
	font-weight: 600;
	color: var(--wcup-text-muted);
	letter-spacing: 0.04em;
	text-transform: uppercase;
	flex: 0 0 auto;
}

.wcup-text__font {
	flex: 1;
	max-width: 220px;
	appearance: none;
	font: inherit;
	font-size: 0.9em;
	padding: 6px 28px 6px 10px;
	background: var(--wcup-bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%2371717a' stroke-width='1.6'%3E%3Cpath d='M3 5l3 3 3-3'/%3E%3C/svg%3E") no-repeat right 8px center / 12px;
	border: 1px solid var(--wcup-border);
	border-radius: var(--wcup-radius-sm);
	color: var(--wcup-text-primary);
	cursor: pointer;
}

.wcup-text__lines {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.wcup-text__line {
	display: grid;
	grid-template-columns: auto 1fr auto auto auto;
	gap: 8px;
	align-items: center;
	padding: 4px 0;
}

.wcup-text__line-num {
	font-size: 0.75em;
	font-weight: 600;
	color: var(--wcup-text-muted);
	min-width: 38px;
	letter-spacing: 0.02em;
}

.wcup-text__line-input {
	flex: 1;
	appearance: none;
	font: inherit;
	font-size: 0.92em;
	padding: 8px 10px;
	background: var(--wcup-bg);
	border: 1px solid var(--wcup-border);
	border-radius: var(--wcup-radius-sm);
	color: var(--wcup-text-primary);
	min-width: 0;
}

.wcup-text__line-input:focus {
	outline: none;
	border-color: var(--wcup-accent);
	box-shadow: 0 0 0 3px rgba(24, 24, 27, 0.06);
}

.wcup-text__line-size {
	appearance: none;
	font: inherit;
	font-size: 0.85em;
	padding: 7px 22px 7px 8px;
	background: var(--wcup-bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%2371717a' stroke-width='1.6'%3E%3Cpath d='M3 5l3 3 3-3'/%3E%3C/svg%3E") no-repeat right 6px center / 10px;
	border: 1px solid var(--wcup-border);
	border-radius: var(--wcup-radius-sm);
	color: var(--wcup-text-primary);
	cursor: pointer;
}

.wcup-text__line-bold {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	font-size: 0.82em;
	color: var(--wcup-text-muted);
	cursor: pointer;
	user-select: none;
}

.wcup-text__line-bold input {
	margin: 0;
	cursor: pointer;
}

.wcup-text__line-remove {
	appearance: none;
	background: transparent;
	border: 0;
	width: 24px;
	height: 24px;
	color: var(--wcup-text-subtle);
	font-size: 16px;
	line-height: 1;
	border-radius: 50%;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	transition: background 0.15s var(--wcup-ease), color 0.15s var(--wcup-ease);
}

.wcup-text__line-remove:hover {
	background: #fef2f2;
	color: var(--wcup-danger);
}

.wcup-text__add-line {
	appearance: none;
	background: transparent;
	border: 0;
	color: var(--wcup-text-muted);
	font: inherit;
	font-size: 0.85em;
	font-weight: 600;
	padding: 6px 0 0;
	cursor: pointer;
	text-align: left;
	transition: color 0.15s var(--wcup-ease);
}

.wcup-text__add-line:hover {
	color: var(--wcup-text-primary);
}

.wcup-text__add-line:disabled {
	opacity: 0.45;
	cursor: not-allowed;
}

.wcup-text__line-count {
	font-weight: 400;
	color: var(--wcup-text-subtle);
}

/* ============================================================
   Preview block on the product page (rendered by [wcup_text_preview])
   ============================================================ */

.wcup-text-preview {
	font: inherit;
	color: var(--wcup-text-primary);
	box-sizing: border-box;
	display: block;
	width: 100%;
	max-width: 560px;
	margin-top: 14px;
	background: var(--wcup-bg);
	border: 1px solid var(--wcup-border);
	border-radius: var(--wcup-radius);
	overflow: hidden;
	box-shadow: var(--wcup-shadow-sm);
}

.wcup-text-preview *, .wcup-text-preview *::before, .wcup-text-preview *::after {
	box-sizing: inherit;
}

.wcup-text-preview[hidden] {
	display: none !important;
}

.wcup-text-preview__head {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 8px 12px;
	background: #f0fdf4;
	border-bottom: 1px solid #bbf7d0;
}

.wcup-text-preview__title {
	font-size: 0.78em;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: #15803d;
	flex: 1;
}

.wcup-text-preview__count {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 20px;
	height: 20px;
	padding: 0 6px;
	background: var(--wcup-success);
	color: #fff;
	border-radius: 999px;
	font-size: 0.72em;
	font-weight: 700;
}

.wcup-text-preview__list {
	display: flex;
	flex-direction: column;
}

.wcup-text-preview__card {
	padding: 10px 12px;
	border-top: 1px dashed var(--wcup-border);
}

.wcup-text-preview__card:first-child {
	border-top: 0;
}

.wcup-text-preview__card-head {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-bottom: 4px;
}

.wcup-text-preview__card-remove {
	margin-left: auto;
	appearance: none;
	background: transparent;
	border: 0;
	width: 22px;
	height: 22px;
	border-radius: 50%;
	color: var(--wcup-text-subtle);
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	transition: background 0.15s var(--wcup-ease), color 0.15s var(--wcup-ease);
}

.wcup-text-preview__card-remove:hover {
	background: #fef2f2;
	color: var(--wcup-danger);
}

.wcup-text-preview__card-remove:disabled {
	opacity: 0.5;
	cursor: wait;
}

.wcup-text-preview__card-num {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 22px;
	height: 22px;
	background: var(--wcup-surface-2);
	border-radius: 999px;
	font-size: 0.72em;
	font-weight: 700;
	color: var(--wcup-text-primary);
}

.wcup-text-preview__card-font {
	font-size: 0.7em;
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var(--wcup-text-subtle);
}

.wcup-text-preview__card-body {
	color: var(--wcup-text-primary);
	line-height: 1.4;
}

.wcup-text-preview__line {
	padding: 1px 0;
	overflow-wrap: anywhere;
}

/* ============================================================
   "Edit text" button rendered in cart rows
   ============================================================ */

.wcup-cart-edit-text {
	appearance: none;
	display: inline-flex;
	align-items: center;
	gap: 5px;
	margin-top: 6px;
	padding: 4px 10px 4px 8px;
	background: var(--wcup-bg);
	border: 1px solid var(--wcup-border);
	color: var(--wcup-text-muted);
	font: inherit;
	font-size: 0.75em;
	font-weight: 600;
	border-radius: 999px;
	cursor: pointer;
	transition: background 0.15s var(--wcup-ease), border-color 0.15s var(--wcup-ease), color 0.15s var(--wcup-ease);
}

.wcup-cart-edit-text:hover {
	background: var(--wcup-surface);
	border-color: var(--wcup-text-muted);
	color: var(--wcup-text-primary);
}

.wcup-cart-edit-text svg {
	flex: 0 0 auto;
}

/* ============================================================
   Reduced motion
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
	.wcup-modal *, .wcup-text * {
		animation-duration: 0.01ms !important;
		transition-duration: 0.01ms !important;
	}
}
