/*
 * Jovem Lata Vision - leitor mobile.
 * Dark mode (OLED: preto puro), alto contraste, alvos de toque grandes (uso com luva).
 * Tudo escopado em .jl-leitor para não brigar com o tema.
 */

html.jl-leitor-open,
html.jl-leitor-open body {
	overflow: hidden;
	overscroll-behavior: none;
}

.jl-leitor {
	--jl-bg: #000;
	--jl-surface: rgba(18, 18, 20, 0.92);
	--jl-text: #f4f4f5;
	--jl-muted: #a1a1aa;
	--jl-accent: #ffb300;
	--jl-ok: #4ade80;
	--jl-warn: #ffb300;
	--jl-bad: #ff5a5f;
	--jl-safe-top: env(safe-area-inset-top, 0px);
	--jl-safe-bottom: env(safe-area-inset-bottom, 0px);

	position: fixed;
	inset: 0;
	z-index: 2147483000; /* Cobre cabeçalho do tema e barra de admin. */
	height: 100vh;
	height: 100dvh;
	background: var(--jl-bg);
	color: var(--jl-text);
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	font-size: 16px;
	line-height: 1.35;
	overflow: hidden;
	-webkit-tap-highlight-color: transparent;
	touch-action: manipulation;
	user-select: none;
	-webkit-user-select: none;
}

.jl-leitor *,
.jl-leitor *::before,
.jl-leitor *::after {
	box-sizing: border-box;
}

.jl-leitor [hidden] {
	display: none !important;
}

.jl-leitor button,
.jl-leitor select {
	appearance: none;
	-webkit-appearance: none;
	margin: 0;
	border: 0;
	font: inherit;
	color: inherit;
	cursor: pointer;
}

.jl-leitor :focus-visible {
	outline: 3px solid var(--jl-accent);
	outline-offset: 2px;
}

.jl-sr {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

/* Vídeo ---------------------------------------------------------------- */

.jl-video {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	background: #000;
}

/* Topo ----------------------------------------------------------------- */

.jl-top {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	z-index: 5;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: calc(10px + var(--jl-safe-top)) 14px 22px;
	background: linear-gradient(to bottom, rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0));
}

.jl-select {
	position: relative;
	display: block;
	min-width: 0;
}

.jl-select::after {
	content: "";
	position: absolute;
	right: 12px;
	top: 50%;
	width: 8px;
	height: 8px;
	margin-top: -6px;
	border-right: 2px solid var(--jl-muted);
	border-bottom: 2px solid var(--jl-muted);
	transform: rotate(45deg);
	pointer-events: none;
}

.jl-tela {
	max-width: 52vw;
	min-height: 44px;
	padding: 0 34px 0 14px;
	border-radius: 22px;
	background: var(--jl-surface);
	font-size: 15px;
	font-weight: 600;
	text-overflow: ellipsis;
}

.jl-modo {
	display: inline-flex;
	padding: 3px;
	border-radius: 22px;
	background: var(--jl-surface);
}

.jl-modo__btn {
	min-height: 38px;
	padding: 0 16px;
	border-radius: 19px;
	background: transparent;
	color: var(--jl-muted);
	font-size: 15px;
	font-weight: 600;
}

.jl-modo__btn[aria-checked="true"] {
	background: var(--jl-accent);
	color: #000;
}

/* Moldura guia ---------------------------------------------------------- */

.jl-frame {
	position: absolute;
	top: 50%;
	left: 50%;
	z-index: 2;
	width: min(84vw, 560px);
	aspect-ratio: 4 / 3;
	max-height: 58dvh;
	transform: translate(-50%, -54%);
	border-radius: 18px;
	box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.42); /* Escurece fora da moldura. */
	pointer-events: none;
}

.jl-frame i {
	position: absolute;
	width: 36px;
	height: 36px;
	border: 0 solid var(--jl-accent);
}

.jl-frame i:nth-child(1) { top: 0; left: 0; border-top-width: 4px; border-left-width: 4px; border-top-left-radius: 18px; }
.jl-frame i:nth-child(2) { top: 0; right: 0; border-top-width: 4px; border-right-width: 4px; border-top-right-radius: 18px; }
.jl-frame i:nth-child(3) { bottom: 0; left: 0; border-bottom-width: 4px; border-left-width: 4px; border-bottom-left-radius: 18px; }
.jl-frame i:nth-child(4) { bottom: 0; right: 0; border-bottom-width: 4px; border-right-width: 4px; border-bottom-right-radius: 18px; }

.jl-hint {
	position: absolute;
	top: 100%;
	left: 0;
	right: 0;
	margin: 12px 0 0;
	text-align: center;
	color: var(--jl-text);
	font-size: 14px;
	text-shadow: 0 1px 3px #000;
}

/* Rodapé / disparo ------------------------------------------------------ */

.jl-bottom {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 5;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 14px;
	padding: 28px 18px calc(18px + var(--jl-safe-bottom));
	background: linear-gradient(to top, rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0));
}

.jl-bottom__spacer {
	width: 56px;
	flex: none;
}

.jl-shot {
	flex: 1;
	max-width: 360px;
	min-height: 76px;
	border-radius: 38px;
	background: var(--jl-accent);
	color: #000;
	font-size: 21px;
	font-weight: 800;
	letter-spacing: 0.01em;
	box-shadow: 0 0 0 4px rgba(255, 179, 0, 0.25);
	transition: transform 0.08s ease, opacity 0.2s ease;
}

.jl-shot:active:not(:disabled) {
	transform: scale(0.97);
}

.jl-shot:disabled {
	opacity: 0.4;
	cursor: default;
}

.jl-torch {
	display: grid;
	place-items: center;
	flex: none;
	width: 56px;
	height: 56px;
	border-radius: 50%;
	background: var(--jl-surface);
	color: var(--jl-text);
}

.jl-torch[aria-pressed="true"] {
	background: var(--jl-accent);
	color: #000;
}

/* Carregando ------------------------------------------------------------ */

.jl-loading {
	position: absolute;
	inset: 0;
	z-index: 4;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 14px;
	background: rgba(0, 0, 0, 0.55);
	font-size: 20px;
	font-weight: 700;
	pointer-events: none;
}

.jl-spinner {
	width: 46px;
	height: 46px;
	border: 5px solid rgba(255, 255, 255, 0.25);
	border-top-color: var(--jl-accent);
	border-radius: 50%;
	animation: jl-spin 0.8s linear infinite;
}

@keyframes jl-spin {
	to { transform: rotate(360deg); }
}

/* Cartão de resultado ---------------------------------------------------- */

.jl-card {
	position: absolute;
	left: 12px;
	right: 12px;
	bottom: calc(118px + var(--jl-safe-bottom));
	z-index: 6;
	max-width: 560px;
	margin: 0 auto;
	padding: 14px 44px 14px 16px;
	border-radius: 18px;
	border-left: 6px solid var(--jl-ok);
	background: var(--jl-surface);
	-webkit-backdrop-filter: blur(10px);
	backdrop-filter: blur(10px);
	animation: jl-rise 0.22s ease-out;
}

.jl-card[data-nivel="medio"] { border-left-color: var(--jl-warn); }
.jl-card[data-nivel="baixo"],
.jl-card[data-nivel="erro"] { border-left-color: var(--jl-bad); }

.jl-card__head {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 12px;
}

.jl-card__title {
	min-width: 0;
	font-size: 19px;
	overflow-wrap: anywhere;
}

.jl-card__conf {
	flex: none;
	font-size: 20px;
	font-weight: 800;
	font-variant-numeric: tabular-nums;
	color: var(--jl-ok);
}

.jl-card[data-nivel="medio"] .jl-card__conf { color: var(--jl-warn); }
.jl-card[data-nivel="baixo"] .jl-card__conf { color: var(--jl-bad); }

.jl-card__line {
	margin: 6px 0 0;
	font-size: 15px;
}

.jl-card__meta {
	margin: 4px 0 0;
	color: var(--jl-muted);
	font-size: 13px;
}

.jl-card__close {
	position: absolute;
	top: 4px;
	right: 4px;
	width: 44px;
	height: 44px;
	border-radius: 50%;
	background: transparent;
	color: var(--jl-muted);
	font-size: 28px;
	line-height: 1;
}

@keyframes jl-rise {
	from { opacity: 0; transform: translateY(12px); }
	to { opacity: 1; transform: none; }
}

/* Flash do obturador ----------------------------------------------------- */

.jl-flash {
	position: absolute;
	inset: 0;
	z-index: 7;
	background: #fff;
	opacity: 0;
	pointer-events: none;
}

.jl-flash.is-on {
	animation: jl-flash 0.25s ease-out;
}

@keyframes jl-flash {
	from { opacity: 0.8; }
	to { opacity: 0; }
}

/* Painel de erro (câmera/HTTPS) ----------------------------------------- */

.jl-panel {
	position: absolute;
	inset: 0;
	z-index: 10;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 14px;
	padding: 28px;
	background: var(--jl-bg);
	text-align: center;
}

.jl-panel__title {
	margin: 0;
	color: var(--jl-text);
	font-size: 22px;
	font-weight: 800;
}

.jl-panel__msg {
	max-width: 34em;
	margin: 0;
	color: var(--jl-muted);
	font-size: 16px;
	white-space: pre-line;
}

.jl-panel__retry {
	min-height: 56px;
	padding: 0 28px;
	border-radius: 28px;
	background: var(--jl-accent);
	color: #000;
	font-size: 18px;
	font-weight: 800;
}

/* Aviso para quem não está logado ---------------------------------------- */

.jl-leitor-aviso {
	padding: 16px;
	border-left: 4px solid #ffb300;
	background: #1c1c1e;
	color: #f4f4f5;
}

.jl-leitor-aviso a {
	color: #ffb300;
}

@media (prefers-reduced-motion: reduce) {
	.jl-leitor *,
	.jl-leitor *::before,
	.jl-leitor *::after {
		animation-duration: 0.001ms !important;
		animation-iteration-count: 1 !important;
		transition: none !important;
	}
	.jl-spinner {
		animation: none;
		border-top-color: var(--jl-accent);
		border-right-color: var(--jl-accent);
	}
}

/* Paisagem: encolhe moldura e botões para caber. */
@media (orientation: landscape) and (max-height: 520px) {
	.jl-frame { width: auto; height: 62dvh; max-height: none; transform: translate(-50%, -50%); }
	.jl-hint { display: none; }
	.jl-shot { min-height: 60px; font-size: 18px; }
	.jl-card { bottom: calc(90px + var(--jl-safe-bottom)); }
}
