/* Public Photocard Generator — mobile-first responsive */
.pcg-public-wrap {
	--pcg-gap: 1rem;
	--pcg-radius: 12px;
	--pcg-red: #AA0001;
	--pcg-green: #1b5e20;
	--pcg-fb: #1877f2;
	box-sizing: border-box;
	width: 100%;
	max-width: 960px;
	margin: 1rem auto;
	padding: 0 12px;
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Bengali", sans-serif;
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
}
.pcg-public-wrap *,
.pcg-public-wrap *::before,
.pcg-public-wrap *::after {
	box-sizing: border-box;
}

.pcg-public-layout {
	display: flex;
	flex-direction: column;
	gap: var(--pcg-gap);
	align-items: stretch;
}

/* On mobile: preview first (top), form below — already natural column order if we put preview first in DOM.
   HTML currently has controls then preview; use column-reverse on small screens. */
.pcg-public-controls {
	width: 100%;
	max-width: none;
	order: 2;
}
.pcg-public-preview-col {
	width: 100%;
	order: 1;
}

.pcg-public-panel {
	background: #fff;
	border: 1px solid #e0e0e0;
	border-radius: var(--pcg-radius);
	padding: 1rem 1rem 1.15rem;
	box-shadow: 0 2px 12px rgba(0, 0, 0, .06);
}

.pcg-public-title {
	margin: 0 0 .4rem;
	font-size: 1.2rem;
	font-weight: 700;
	color: #1a1a1a;
	line-height: 1.3;
	word-wrap: break-word;
}
.pcg-public-desc {
	margin: 0 0 1rem;
	font-size: .9rem;
	color: #555;
	line-height: 1.5;
}

.pcg-public-field {
	margin-bottom: .85rem;
}
.pcg-public-field label {
	display: block;
	font-weight: 600;
	font-size: .9rem;
	margin-bottom: .4rem;
	color: #333;
}

/* Touch-friendly file picker */
.pcg-public-file-wrap {
	position: relative;
}
.pcg-public-field input[type="file"] {
	display: block;
	width: 100%;
	max-width: 100%;
	font-size: 16px; /* iOS: avoid auto-zoom */
	padding: .65rem .5rem;
	border: 1.5px dashed #bbb;
	border-radius: 10px;
	background: #fafafa;
	cursor: pointer;
	min-height: 48px;
	line-height: 1.3;
}
.pcg-public-field input[type="file"]:focus {
	outline: none;
	border-color: var(--pcg-red);
	box-shadow: 0 0 0 2px rgba(170, 0, 1, .15);
}

.pcg-public-field textarea {
	width: 100%;
	max-width: 100%;
	padding: .7rem .75rem;
	border: 1px solid #ccc;
	border-radius: 10px;
	font-size: 16px; /* iOS: avoid auto-zoom on focus */
	line-height: 1.45;
	resize: vertical;
	min-height: 3.2em;
	font-family: inherit;
	-webkit-appearance: none;
	appearance: none;
}
.pcg-public-field textarea:focus {
	outline: none;
	border-color: var(--pcg-red);
	box-shadow: 0 0 0 2px rgba(170, 0, 1, .15);
}

/* Action buttons — full width stack on phones */
.pcg-public-actions {
	display: flex;
	flex-direction: column;
	gap: .65rem;
	margin: 1rem 0 .35rem;
	width: 100%;
}
.pcg-public-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	min-height: 48px;
	padding: .75rem 1rem;
	background: var(--pcg-red);
	color: #fff !important;
	border: none;
	border-radius: 10px;
	font-size: 1rem;
	font-weight: 600;
	line-height: 1.25;
	cursor: pointer;
	text-decoration: none !important;
	text-align: center;
	transition: background .15s, opacity .15s;
	-webkit-tap-highlight-color: transparent;
	touch-action: manipulation;
	user-select: none;
}
.pcg-public-btn:active:not(:disabled) {
	opacity: .9;
}
.pcg-public-btn:hover:not(:disabled) {
	background: #8a0001;
}
.pcg-public-btn:disabled {
	opacity: .6;
	cursor: wait;
}
.pcg-public-btn-dl {
	background: var(--pcg-green);
}
.pcg-public-btn-dl:hover:not(:disabled) {
	background: #0d3d12 !important;
}
.pcg-public-btn-fb {
	background: var(--pcg-fb);
	margin-left: 0;
}
.pcg-public-btn-fb:hover:not(:disabled) {
	background: #0d65d9 !important;
}

.pcg-public-status {
	min-height: 1.25rem;
	font-size: .875rem;
	margin-top: .4rem;
	line-height: 1.4;
	word-wrap: break-word;
}
.pcg-public-fb-hint {
	margin: .25rem 0 0;
	font-size: .8rem;
	color: #666;
	line-height: 1.4;
}

/* Live preview — no overflow on small screens */
.pcg-public-live {
	background: #ececec;
	border: 1px solid #ddd;
	border-radius: var(--pcg-radius);
	overflow: hidden;
	min-height: 160px;
	max-width: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 2px 12px rgba(0, 0, 0, .06);
	/* sticky preview while scrolling form on long phones */
	position: relative;
}
.pcg-public-live-img {
	display: block;
	width: 100%;
	max-width: 100%;
	height: auto;
	vertical-align: top;
	/* prevent long-press image menu stealing UI occasionally */
	-webkit-touch-callout: default;
}
.pcg-public-live-placeholder {
	padding: 2rem 1rem;
	color: #888;
	font-size: .95rem;
	text-align: center;
	line-height: 1.4;
}
.pcg-public-live-hint {
	margin: .5rem 0 0;
	font-size: .8rem;
	color: #888;
	text-align: center;
}

.pcg-public-closed {
	padding: 1rem 1.15rem;
	background: #fafafa;
	border: 1px dashed #ccc;
	border-radius: 10px;
	color: #666;
	text-align: center;
	font-size: .95rem;
	line-height: 1.45;
	margin: 0 12px;
}

/* Sticky bottom bar for actions when card is ready (mobile) */
.pcg-public-actions.is-sticky-mobile {
	position: sticky;
	bottom: 0;
	z-index: 20;
	background: linear-gradient(to top, #fff 70%, rgba(255, 255, 255, 0));
	padding: .75rem 0 calc(.75rem + env(safe-area-inset-bottom, 0px));
	margin-bottom: 0;
}

/* ——— Tablet+ (≥600px) ——— */
@media (min-width: 600px) {
	.pcg-public-wrap {
		margin: 1.25rem auto;
		padding: 0 16px;
	}
	.pcg-public-panel {
		padding: 1.25rem 1.35rem;
	}
	.pcg-public-actions {
		flex-direction: row;
		flex-wrap: wrap;
	}
	.pcg-public-btn {
		width: auto;
		min-width: 140px;
		flex: 1 1 auto;
	}
}

/* ——— Desktop side-by-side (≥900px) ——— */
@media (min-width: 900px) {
	.pcg-public-wrap {
		margin: 1.5rem auto;
		padding: 0;
	}
	.pcg-public-layout {
		flex-direction: row;
		align-items: flex-start;
		gap: 1.25rem;
	}
	.pcg-public-controls {
		flex: 0 1 360px;
		max-width: 380px;
		order: 0;
	}
	.pcg-public-preview-col {
		flex: 1 1 0;
		min-width: 0; /* allow shrink inside flex */
		order: 0;
	}
	.pcg-public-actions.is-sticky-mobile {
		position: static;
		background: transparent;
		padding: 0;
	}
	.pcg-public-title {
		font-size: 1.3rem;
	}
}

/* Landscape phones: keep preview usable */
@media (max-height: 480px) and (orientation: landscape) {
	.pcg-public-live {
		min-height: 120px;
		max-height: 70vh;
	}
	.pcg-public-live-img {
		max-height: 70vh;
		width: auto;
		max-width: 100%;
		margin: 0 auto;
	}
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
	.pcg-public-btn {
		transition: none;
	}
}
