/* GKFC — form upload cropper
   Loaded only by forms carrying a field with a `crop` property. Kept
   self-contained so the theme never has to know the cropper exists, and so a
   missing stylesheet degrades to a plain unstyled canvas rather than a hidden
   one. Nothing here may set display:none on the canvas or the stage. */

.gkfc-cropper {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 14px;
	padding: 20px;
	background: rgba(15, 23, 42, .82);
	overscroll-behavior: contain;
}

/* Padding + centred rather than bottom-sheet: the stage needs both dimensions
   to letterbox a 35:45 frame, and phones in portrait are the tight case. */
@media (max-width: 480px) {
	.gkfc-cropper {
		justify-content: flex-start;
		padding: 12px;
	}
}

.gkfc-cropper[hidden] {
	display: none;
}

.gkfc-cropper__head {
	width: 100%;
	max-width: 420px;
}

.gkfc-cropper__title {
	margin: 0;
	font-size: 17px;
	line-height: 1.3;
	color: #fff;
}

/* The stage is the crop window, so it carries the guide overlay. No extra
   markup: the box-shadow inset draws the frame over the canvas edges. */
.gkfc-cropper__stage {
	position: relative;
	flex: 0 0 auto;
	line-height: 0;
	border-radius: 4px;
	background:
		repeating-conic-gradient(#e2e8f0 0% 25%, #94a3b8 0% 50%) 50% / 16px 16px;
	box-shadow: 0 0 0 1px rgba(255, 255, 255, .35);
	/* Stop the browser turning a drag into a page scroll or a pinch-zoom of the
	   document, which is the single most common way a canvas cropper feels
	   broken on a phone. */
	touch-action: none;
	user-select: none;
	-webkit-user-select: none;
	-webkit-tap-highlight-color: transparent;
	cursor: grab;
}

.gkfc-cropper__stage:active {
	cursor: grabbing;
}

.gkfc-cropper__canvas {
	display: block;
	max-width: 100%;
	height: auto;
	border-radius: 4px;
}

/* Guide lines. The frame IS the output, so these sit exactly on the canvas
   edge rather than inside it: nothing visible gets cut off, which is the whole
   point of a passport crop. */
.gkfc-cropper__stage::after {
	content: "";
	position: absolute;
	inset: 0;
	pointer-events: none;
	background:
		linear-gradient(to right, transparent 33.33%, rgba(255, 255, 255, .45) 33.33%, rgba(255, 255, 255, .45) calc(33.33% + 1px), transparent calc(33.33% + 1px)),
		linear-gradient(to right, transparent 66.66%, rgba(255, 255, 255, .45) 66.66%, rgba(255, 255, 255, .45) calc(66.66% + 1px), transparent calc(66.66% + 1px)),
		linear-gradient(to bottom, transparent 33.33%, rgba(255, 255, 255, .45) 33.33%, rgba(255, 255, 255, .45) calc(33.33% + 1px), transparent calc(33.33% + 1px)),
		linear-gradient(to bottom, transparent 66.66%, rgba(255, 255, 255, .45) 66.66%, rgba(255, 255, 255, .45) calc(66.66% + 1px), transparent calc(66.66% + 1px));
}

.gkfc-cropper__hint {
	margin: 0;
	font-size: 13px;
	line-height: 1.5;
	color: rgba(255, 255, 255, .82);
	text-align: center;
}

.gkfc-cropper__bar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 8px;
	width: 100%;
	max-width: 420px;
}

.gkfc-cropper__bar button {
	margin: 0;
	font-size: 14px;
	line-height: 1.2;
	cursor: pointer;
}

.gkfc-cropper__zoom {
	flex: 0 0 auto;
	min-width: 42px;
	min-height: 42px;
	padding: 0;
	font-size: 20px !important;
	color: #fff;
	background: rgba(255, 255, 255, .14);
	border: 1px solid rgba(255, 255, 255, .3);
	border-radius: 8px;
}

.gkfc-cropper__zoom:hover,
.gkfc-cropper__zoom:focus-visible {
	background: rgba(255, 255, 255, .26);
}

.gkfc-cropper__cancel {
	flex: 1 1 6rem;
	min-height: 42px;
	padding: 8px 14px;
	color: #1f2937;
	background: #fff;
	border: 1px solid #d1d5db;
	border-radius: 8px;
}

.gkfc-cropper__use {
	flex: 2 1 10rem;
	min-height: 42px;
	padding: 8px 14px;
	font-weight: 600;
	color: #fff;
	background: #15803d;
	border: 1px solid #166534;
	border-radius: 8px;
}

.gkfc-cropper__use:hover,
.gkfc-cropper__use:focus-visible {
	background: #166534;
}

/* Safari <15 lacks :focus-visible, so give the buttons a visible focus ring by
   default and only remove it where the pseudo-class is supported. */
.gkfc-cropper__bar button:focus {
	outline: 2px solid #93c5fd;
	outline-offset: 2px;
}

.gkfc-cropper__bar button:focus:not(:focus-visible) {
	outline: none;
}

.gkfc-cropper__bar button:focus-visible {
	outline: 2px solid #93c5fd;
	outline-offset: 2px;
}

.gkfc-cropper.is-reduced .gkfc-cropper__stage,
.gkfc-cropper.is-reduced .gkfc-cropper__canvas {
	transition: none !important;
}

/* Inline note shown under the file input. Rendered in normal flow, never as an
   overlay, so a failure message cannot cover the field the user has to fix. */
.gkfc-cropper__note {
	margin: 8px 0 0;
	font-size: 13px;
	line-height: 1.5;
	color: #92400e;
}

.gkfc-cropper__note[hidden] {
	display: none;
}
