/* GF ID Capture Field
   Design tokens live here so the Signature field can be matched to them later. */

.gfidc-wrap {
	--gfidc-accent: #e8262c;
	--gfidc-accent-dark: #c81f24;
	--gfidc-ink: #231f20;
	--gfidc-line: #d9dde3;
	--gfidc-muted: #6b7280;
	--gfidc-radius: 8px;
	--gfidc-stroke: 1px;

	max-width: 420px;
	font-family: inherit;
}

.gfidc-stage {
	position: relative;
	width: 100%;
	aspect-ratio: 4 / 3;
	background: #f3f4f6;
	border: var(--gfidc-stroke) solid var(--gfidc-line);
	border-radius: var(--gfidc-radius);
	overflow: hidden;
}

.gfidc-video,
.gfidc-shot {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: none;
}

.gfidc-wrap.gfidc-live .gfidc-video { display: block; }
.gfidc-wrap.gfidc-captured .gfidc-shot { display: block; }

.gfidc-idle {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 8px;
	color: var(--gfidc-muted);
	font-size: 13px;
}

.gfidc-wrap.gfidc-live .gfidc-idle,
.gfidc-wrap.gfidc-captured .gfidc-idle { display: none; }

.gfidc-idle-icon {
	width: 34px;
	height: 26px;
	border: var(--gfidc-stroke) solid var(--gfidc-muted);
	border-radius: 5px;
	position: relative;
}

.gfidc-idle-icon::before {
	content: "";
	position: absolute;
	left: 50%;
	top: 50%;
	width: 12px;
	height: 12px;
	margin: -6px 0 0 -6px;
	border: var(--gfidc-stroke) solid var(--gfidc-muted);
	border-radius: 50%;
}

/* Framing guide */
.gfidc-wrap.gfidc-live .gfidc-stage::after {
	content: "";
	position: absolute;
	left: 50%;
	top: 48%;
	width: 46%;
	height: 68%;
	transform: translate(-50%, -50%);
	border: var(--gfidc-stroke) dashed rgba(255, 255, 255, 0.85);
	border-radius: 50% / 42%;
	pointer-events: none;
}

.gfidc-msg {
	margin: 8px 0 10px;
	font-size: 13px;
	line-height: 1.45;
	color: var(--gfidc-muted);
	min-height: 18px;
}

.gfidc-wrap.gfidc-error .gfidc-msg { color: var(--gfidc-accent); }

.gfidc-actions {
	display: flex;
	gap: 10px;
	flex-wrap: wrap;
}

.gfidc-wrap button.gfidc-btn {
	font: inherit;
	font-size: 14px;
	font-weight: 700;
	cursor: pointer;
	padding: 10px 22px;
	border-radius: 6px;
	border: var(--gfidc-stroke) solid var(--gfidc-accent);
	background: var(--gfidc-accent);
	color: #fff;
	line-height: 1.2;
	margin: 0;
}

.gfidc-wrap button.gfidc-btn:hover {
	background: var(--gfidc-accent-dark);
	border-color: var(--gfidc-accent-dark);
}

.gfidc-wrap button.gfidc-btn.gfidc-ghost {
	background: #fff;
	color: var(--gfidc-accent);
}

.gfidc-wrap button.gfidc-btn.gfidc-ghost:hover { background: #fdeaea; }

.gfidc-wrap button.gfidc-btn:focus-visible {
	outline: 2px solid var(--gfidc-ink);
	outline-offset: 2px;
}

.gfidc-canvas { display: none; }

@media (max-width: 480px) {
	.gfidc-actions { flex-direction: column; }
	.gfidc-wrap button.gfidc-btn { width: 100%; }
}

/* --------------------------------------------------------------------------
   Button visibility is driven by state classes on .gfidc-wrap, not the hidden
   attribute, which themes and page builders routinely override.
   idle      -> Start camera
   live      -> Capture
   captured  -> Retake
   -------------------------------------------------------------------------- */

.gfidc-wrap .gfidc-start   { display: inline-block !important; }
.gfidc-wrap .gfidc-capture { display: none !important; }
.gfidc-wrap .gfidc-retake  { display: none !important; }

.gfidc-wrap.gfidc-live .gfidc-start   { display: none !important; }
.gfidc-wrap.gfidc-live .gfidc-capture { display: inline-block !important; }

.gfidc-wrap.gfidc-captured .gfidc-start   { display: none !important; }
.gfidc-wrap.gfidc-captured .gfidc-capture { display: none !important; }
.gfidc-wrap.gfidc-captured .gfidc-retake  { display: inline-block !important; }

@media (max-width: 480px) {
	.gfidc-wrap .gfidc-start,
	.gfidc-wrap.gfidc-live .gfidc-capture,
	.gfidc-wrap.gfidc-captured .gfidc-retake { display: block !important; width: 100%; }
}

/* --------------------------------------------------------------------------
   Layout hardening.
   Themes and page builders commonly reset position/overflow on containers and
   media elements. When .gfidc-stage loses position:relative the absolutely
   positioned video anchors to an ancestor instead and paints over the buttons.
   These rules pin the geometry and keep the controls on top.
   -------------------------------------------------------------------------- */

.gfidc-wrap .gfidc-stage {
	position: relative !important;
	overflow: hidden !important;
	display: block !important;
	z-index: 0 !important;
	aspect-ratio: auto !important;
	min-height: 0;
}

/* padding fallback for browsers or resets that drop aspect-ratio */
.gfidc-wrap .gfidc-stage::before {
	content: "";
	display: block;
	padding-top: 75%;
}

.gfidc-wrap .gfidc-video,
.gfidc-wrap .gfidc-shot {
	position: absolute !important;
	top: 0 !important;
	left: 0 !important;
	right: 0 !important;
	bottom: 0 !important;
	width: 100% !important;
	height: 100% !important;
	max-width: 100% !important;
	object-fit: cover !important;
	margin: 0 !important;
	z-index: 1 !important;
}

.gfidc-wrap .gfidc-idle {
	position: absolute !important;
	top: 0 !important;
	left: 0 !important;
	right: 0 !important;
	bottom: 0 !important;
	z-index: 1 !important;
}

/* Controls and status always sit below the stage, above everything else */
.gfidc-wrap .gfidc-msg,
.gfidc-wrap .gfidc-actions {
	position: relative !important;
	z-index: 5 !important;
	clear: both;
}

.gfidc-wrap .gfidc-actions {
	margin-top: 10px;
	display: flex !important;
}

.gfidc-wrap .gfidc-canvas {
	display: none !important;
}

/* --------------------------------------------------------------------------
   Collapsed idle state.
   The camera box takes no space at all until Start camera is pressed, so the
   field sits as a single line of text plus one button.
   -------------------------------------------------------------------------- */

.gfidc-wrap .gfidc-stage { display: none !important; }

.gfidc-wrap.gfidc-live .gfidc-stage,
.gfidc-wrap.gfidc-captured .gfidc-stage {
	display: block !important;
	margin-bottom: 10px;
}

/* Cap the height on desktop so it never dominates the form */
.gfidc-wrap.gfidc-live .gfidc-stage::before,
.gfidc-wrap.gfidc-captured .gfidc-stage::before {
	padding-top: 0;
	height: 420px;
}

.gfidc-wrap .gfidc-msg {
	margin: 0 0 8px;
	min-height: 0;
}

.gfidc-wrap .gfidc-actions { margin-top: 0; }

@media (max-width: 480px) {
	.gfidc-wrap.gfidc-live .gfidc-stage::before,
	.gfidc-wrap.gfidc-captured .gfidc-stage::before {
		height: 320px;
	}
}
