/*
 * Body Type Calculator Pro — front-end styles.
 * Mobile-first, scoped under .btcp-wrap. Full redesign v2.
 */

/* ── Design tokens ───────────────────────────────────────────────── */
.btcp-wrap {
	--btcp-primary:      #5B6CF5;
	--btcp-primary-dark: #4555DF;
	--btcp-primary-soft: rgba(91, 108, 245, .10);
	--btcp-accent:       #F472B6;
	--btcp-text:         #111827;
	--btcp-muted:        #6B7280;
	--btcp-soft:         #9CA3AF;
	--btcp-surface:      #F9FAFB;
	--btcp-surface-2:    #F3F4F6;
	--btcp-border:       #E5E7EB;
	--btcp-border-focus: #A5B4FC;
	--btcp-success:      #10B981;
	--btcp-error:        #EF4444;
	--btcp-radius:       12px;
	--btcp-radius-lg:    20px;

	font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	color: var(--btcp-text);
	background: #ffffff;
	border: 1.5px solid var(--btcp-border);
	border-radius: 24px;
	padding: 22px 20px;
	max-width: 960px;
	margin: 0 auto;
	line-height: 1.6;
	box-sizing: border-box;
	box-shadow:
		0 1px 2px rgba(0, 0, 0, .04),
		0 4px 16px rgba(91, 108, 245, .07),
		0 12px 40px rgba(0, 0, 0, .05);
}

.btcp-wrap *,
.btcp-wrap *::before,
.btcp-wrap *::after {
	box-sizing: border-box;
}

/* ── Header ──────────────────────────────────────────────────────── */
.btcp-header {
	text-align: center;
	margin-bottom: 22px;
}

.btcp-title {
	font-size: 1.375rem;
	font-weight: 800;
	margin: 0 0 6px;
	color: var(--btcp-text);
	letter-spacing: -0.02em;
	line-height: 1.2;
}

.btcp-intro {
	color: var(--btcp-muted);
	margin: 0 auto;
	font-size: 0.9375rem;
	max-width: 52ch;
}

.btcp-intro p { margin: 0; }

/* ── Body grid — mobile: single column ───────────────────────────── */
.btcp-body {
	display: grid;
	grid-template-columns: 1fr;
	gap: 18px;
}

/* ── Form ────────────────────────────────────────────────────────── */
.btcp-form {
	display: grid;
	gap: 13px;
	min-width: 0;
}

.btcp-field {
	display: flex;
	flex-direction: column;
	gap: 5px;
	border: 0;
	margin: 0;
	padding: 0;
	min-width: 0;
}

.btcp-field > legend,
.btcp-field > label {
	font-weight: 600;
	font-size: 0.875rem;
	color: var(--btcp-text);
	padding: 0;
	margin: 0;
	letter-spacing: 0.005em;
}

/* ── Number inputs ───────────────────────────────────────────────── */
.btcp-field input[type="number"] {
	width: 100%;
	height: 46px;
	padding: 0 14px;
	border: 1.5px solid var(--btcp-border);
	border-radius: var(--btcp-radius);
	font-size: 1rem;
	font-family: inherit;
	color: var(--btcp-text);
	background: #fff;
	transition: border-color .15s ease, box-shadow .15s ease;
	-moz-appearance: textfield;
	appearance: textfield;
	font-weight: 500;
}

.btcp-field input[type="number"]::-webkit-outer-spin-button,
.btcp-field input[type="number"]::-webkit-inner-spin-button {
	-webkit-appearance: none;
	margin: 0;
}

.btcp-field input[type="number"]::placeholder {
	color: var(--btcp-soft);
	font-weight: 400;
}

.btcp-field input[type="number"]:hover {
	border-color: #C7D2FE;
}

.btcp-field input[type="number"]:focus {
	outline: none;
	border-color: var(--btcp-primary);
	box-shadow: 0 0 0 3px rgba(91, 108, 245, .15);
	background: #FAFBFF;
}

.btcp-field input[aria-invalid="true"] {
	border-color: var(--btcp-error);
	box-shadow: 0 0 0 3px rgba(239, 68, 68, .12);
}

/* ── Segmented controls (gender, units) ──────────────────────────── */
.btcp-segment {
	display: grid;
	grid-template-columns: 1fr 1fr;
	background: var(--btcp-surface);
	border: 1.5px solid var(--btcp-border);
	border-radius: var(--btcp-radius);
	padding: 3px;
	gap: 3px;
	margin-top: 2px;
}

.btcp-segment-option {
	position: relative;
	display: flex;
	cursor: pointer;
	margin: 0;
	min-width: 0;
}

/* Visually hide the radio input — opacity approach survives theme overrides */
.btcp-segment-option input[type="radio"] {
	position: absolute !important;
	opacity: 0 !important;
	width: 0 !important;
	height: 0 !important;
	pointer-events: none !important;
	margin: 0 !important;
	padding: 0;
	border: 0;
}

.btcp-segment-option > span {
	flex: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 9px 10px;
	font-size: 0.875rem;
	font-weight: 500;
	color: var(--btcp-muted);
	border-radius: 9px;
	transition: background .18s ease, color .18s ease, box-shadow .18s ease;
	-webkit-user-select: none;
	user-select: none;
	white-space: nowrap;
}

.btcp-segment-option:hover > span {
	color: var(--btcp-text);
}

/* Active state via :has() — supported in all modern browsers */
.btcp-segment-option:has(input[type="radio"]:checked) > span {
	background: #fff;
	color: var(--btcp-primary);
	box-shadow: 0 1px 4px rgba(0, 0, 0, .10), 0 1px 2px rgba(0, 0, 0, .06);
	font-weight: 700;
}

/* Fallback for older browsers that don't support :has() —
   JS adds .btcp-seg-active class on the label */
.btcp-seg-active > span {
	background: #fff;
	color: var(--btcp-primary);
	box-shadow: 0 1px 4px rgba(0, 0, 0, .10), 0 1px 2px rgba(0, 0, 0, .06);
	font-weight: 700;
}

.btcp-segment-option:has(input[type="radio"]:focus-visible) > span {
	outline: 2px solid var(--btcp-primary);
	outline-offset: -2px;
}

/* ── Helper text & unit suffix ───────────────────────────────────── */
.btcp-help {
	color: var(--btcp-muted);
	font-size: 0.8rem;
	line-height: 1.4;
}

.btcp-unit-label {
	color: var(--btcp-soft);
	font-weight: 400;
	font-size: 0.8rem;
	margin-left: 4px;
}

/* ── Label visibility: Bust vs Chest ────────────────────────────── */
.btcp-label-female,
.btcp-label-male { display: inline; }
.btcp-wrap .btcp-label-male { display: none; }
.btcp-wrap[data-type="male"] .btcp-label-female,
.btcp-wrap.btcp-gender-male .btcp-label-female { display: none; }
.btcp-wrap[data-type="male"] .btcp-label-male,
.btcp-wrap.btcp-gender-male .btcp-label-male { display: inline; }

/* ── Shoulders visibility ────────────────────────────────────────── */
.btcp-wrap[data-type="general"] .btcp-field-shoulders,
.btcp-wrap[data-type="shape"] .btcp-field-shoulders { display: none; }
.btcp-wrap[data-type="general"].btcp-gender-male .btcp-field-shoulders,
.btcp-wrap[data-type="shape"].btcp-gender-male .btcp-field-shoulders { display: flex; }

/* ── Submit button ───────────────────────────────────────────────── */
.btcp-submit {
	width: 100%;
	height: 50px;
	background: linear-gradient(135deg, #5B6CF5 0%, #818CF8 100%);
	color: #fff;
	border: 0;
	border-radius: var(--btcp-radius);
	font-size: 1rem;
	font-weight: 700;
	font-family: inherit;
	cursor: pointer;
	transition: opacity .2s ease, transform .1s ease, box-shadow .2s ease;
	margin-top: 4px;
	letter-spacing: 0.02em;
	box-shadow: 0 2px 8px rgba(91, 108, 245, .30), 0 4px 16px rgba(91, 108, 245, .20);
}

.btcp-submit:hover {
	opacity: .92;
	box-shadow: 0 4px 16px rgba(91, 108, 245, .40), 0 8px 24px rgba(91, 108, 245, .20);
	transform: translateY(-1px);
}

.btcp-submit:active {
	transform: translateY(0);
	opacity: 1;
}

.btcp-submit:focus-visible {
	outline: 3px solid rgba(91, 108, 245, .45);
	outline-offset: 2px;
}

/* ── Side panel ──────────────────────────────────────────────────── */
.btcp-side {
	background: linear-gradient(150deg, #F5F3FF 0%, #EEF2FF 40%, #FDF2F8 100%);
	border: 1.5px solid #E0E7FF;
	border-radius: var(--btcp-radius-lg);
	padding: 22px 18px;
	display: flex;
	flex-direction: column;
	min-width: 0;
	min-height: 280px;
}

.btcp-panel {
	flex: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
}

/* ── Placeholder state ───────────────────────────────────────────── */
.btcp-placeholder {
	text-align: center;
	width: 100%;
	padding: 16px 8px;
}

/* CONSTRAINED icon — overflow:hidden prevents any bleed */
.btcp-placeholder-icon {
	width: 88px !important;
	height: 88px !important;
	max-width: 88px !important;
	max-height: 88px !important;
	overflow: hidden !important;
	flex-shrink: 0;
	margin: 0 auto 16px;
	color: #A5B4FC;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(255, 255, 255, 0.85);
	border-radius: 50%;
	padding: 18px;
	box-shadow: 0 2px 12px rgba(91, 108, 245, .12);
}

.btcp-placeholder-icon svg {
	display: block !important;
	width: 100% !important;
	height: 100% !important;
	max-width: 100% !important;
	max-height: 100% !important;
	flex-shrink: 0;
}

.btcp-placeholder-title {
	font-size: 1rem;
	font-weight: 700;
	margin: 0 0 6px;
	color: var(--btcp-text);
	letter-spacing: -0.01em;
}

.btcp-placeholder-text {
	color: var(--btcp-muted);
	font-size: 0.875rem;
	margin: 0 auto;
	max-width: 28ch;
	line-height: 1.6;
}

/* ── Result card ─────────────────────────────────────────────────── */
.btcp-result {
	width: 100%;
	animation: btcp-fade-in .3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes btcp-fade-in {
	from { opacity: 0; transform: translateY(8px); }
	to   { opacity: 1; transform: translateY(0); }
}

.btcp-result-card {
	text-align: center;
	width: 100%;
}

.btcp-result-icon {
	width: 100%;
	max-width: 140px;
	height: 140px;
	margin: 0 auto 14px;
	color: var(--btcp-primary);
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(255, 255, 255, .80);
	border-radius: 18px;
	padding: 14px 20px;
	box-shadow: 0 2px 12px rgba(91, 108, 245, .10);
	overflow: hidden;
}

.btcp-result-icon svg {
	display: block;
	width: auto;
	height: 100%;
	max-height: 112px;
	max-width: 100%;
}

.btcp-result-label {
	font-size: 0.72rem;
	text-transform: uppercase;
	letter-spacing: .12em;
	color: var(--btcp-muted);
	font-weight: 700;
	margin-bottom: 5px;
}

.btcp-result-name {
	font-size: 1.75rem;
	font-weight: 800;
	color: var(--btcp-text);
	margin: 0 0 10px;
	line-height: 1.1;
	letter-spacing: -0.02em;
}

.btcp-result-meta {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 6px;
	margin-bottom: 14px;
}

.btcp-meta-pill {
	display: inline-block;
	padding: 4px 12px;
	background: rgba(255, 255, 255, .90);
	color: var(--btcp-primary);
	border-radius: 999px;
	font-size: 0.8125rem;
	font-weight: 600;
	border: 1px solid rgba(91, 108, 245, .18);
}

.btcp-result-tag {
	display: inline-block;
	padding: 4px 14px;
	border-radius: 999px;
	font-size: 0.8125rem;
	font-weight: 700;
	margin: 4px 0 12px;
}

.btcp-tag-low      { background: #D1FAE5; color: #065F46; }
.btcp-tag-moderate { background: #FEF3C7; color: #92400E; }
.btcp-tag-high     { background: #FEE2E2; color: #991B1B; }

.btcp-result-text {
	margin: 0 0 14px;
	color: var(--btcp-text);
	font-size: 0.9rem;
	text-align: left;
	line-height: 1.65;
	background: rgba(255, 255, 255, .60);
	padding: 12px 14px;
	border-radius: 12px;
	border: 1px solid rgba(255,255,255,.8);
}

.btcp-result-text p { margin: 0; }
.btcp-result-text p + p { margin-top: 8px; }

.btcp-result-link {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	color: var(--btcp-primary);
	font-weight: 600;
	text-decoration: none;
	font-size: 0.9rem;
	border-bottom: 1.5px solid transparent;
	padding-bottom: 1px;
	transition: border-color .15s, color .15s;
}

.btcp-result-link:hover {
	color: var(--btcp-primary-dark);
	border-bottom-color: currentColor;
}

.btcp-result-link::after {
	content: "→";
	font-weight: 400;
	transition: transform .15s;
}

.btcp-result-link:hover::after {
	transform: translateX(3px);
}

/* ── Error ───────────────────────────────────────────────────────── */
.btcp-result-error {
	background: #FEF2F2;
	border: 1px solid #FECACA;
	color: #991B1B;
	padding: 14px 16px;
	border-radius: var(--btcp-radius);
	font-size: 0.9rem;
	text-align: left;
}

/* ── Privacy note ────────────────────────────────────────────────── */
.btcp-privacy {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	margin-top: 16px;
	padding-top: 12px;
	border-top: 1px solid rgba(91, 108, 245, .10);
	font-size: 0.78rem;
	color: var(--btcp-muted);
	line-height: 1.5;
	text-align: left;
}

.btcp-privacy svg {
	flex-shrink: 0;
	margin-top: 1px;
	color: var(--btcp-success);
}

/* ── Disclaimer ──────────────────────────────────────────────────── */
.btcp-disclaimer {
	margin-top: 20px;
	padding: 11px 14px;
	background: var(--btcp-surface);
	border-radius: var(--btcp-radius);
	font-size: 0.8rem;
	color: var(--btcp-muted);
	border-left: 3px solid #F9A8D4;
	line-height: 1.55;
}

.btcp-disclaimer p { margin: 0; }

/* ════════════════════════════════════════════════════════════════════
   DESKTOP TWO-COLUMN LAYOUT
   Uses screen and min-width with !important guards to win against
   any Kadence / Gutenberg specificity. Breakpoint lowered to 560px.
   ════════════════════════════════════════════════════════════════════ */

@media screen and (min-width: 560px) {
	.btcp-wrap {
		padding: 28px 26px;
		border-radius: 26px;
	}

	.btcp-title {
		font-size: 1.5rem;
	}

	/* Force two-column side-by-side */
	.btcp-body {
		display: grid !important;
		grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
		grid-auto-rows: auto;
		gap: 22px !important;
		align-items: start !important;
	}

	/* Ensure both children stay in their grid cells */
	.btcp-form,
	.btcp-side {
		width: 100% !important;
		min-width: 0 !important;
		max-width: none !important;
		grid-row: 1 !important;
	}

	.btcp-form  { grid-column: 1 !important; }
	.btcp-side  { grid-column: 2 !important; }

	.btcp-side {
		min-height: 300px;
		padding: 22px 18px;
	}

	.btcp-result-icon {
		max-width: 160px;
		height: 160px;
	}

	.btcp-result-icon svg {
		max-height: 128px;
	}
}

@media screen and (min-width: 760px) {
	.btcp-wrap {
		padding: 36px 32px;
		border-radius: 28px;
	}

	.btcp-title {
		font-size: 1.75rem;
	}

	.btcp-intro {
		font-size: 1rem;
	}

	.btcp-body {
		gap: 28px !important;
	}

	.btcp-side {
		padding: 26px 22px;
	}

	.btcp-result-name {
		font-size: 2rem;
	}

	.btcp-result-icon {
		max-width: 180px;
		height: 180px;
	}

	.btcp-result-icon svg {
		max-height: 150px;
	}
}

@media screen and (min-width: 960px) {
	.btcp-body {
		gap: 36px !important;
	}
}

/* ── Small phones ────────────────────────────────────────────────── */
@media (max-width: 380px) {
	.btcp-wrap {
		padding: 16px 14px;
		border-radius: 18px;
	}

	.btcp-title {
		font-size: 1.125rem;
	}

	.btcp-result-name {
		font-size: 1.5rem;
	}

	.btcp-side {
		padding: 16px 14px;
	}
}

/* ── Reduced motion ──────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
	.btcp-result { animation: none; }

	.btcp-submit,
	.btcp-field input[type="number"],
	.btcp-segment-option > span,
	.btcp-result-link::after { transition: none; }

	.btcp-submit:hover { transform: none; }
}
