/**
 * Вход / регистрация по коду из письма (inc/auth.php).
 *
 * Mobile first: модалка — bottom sheet; с 768px — окно по центру;
 * с 992px — слева тёмная bento-панель. Встроенный вариант на
 * «Моём аккаунте» (.cncgc-auth--inline) — карточка в потоке страницы.
 * Подключается только для гостей.
 */

/* ---------- Модалка ---------- */
body.cncgc-auth-open {
	overflow: hidden;
}

.cncgc-auth-modal {
	position: fixed;
	inset: 0;
	z-index: 1200; /* выше шапки (1000), мега-меню (1001) и мобильного меню (1100) */
	display: flex;
	align-items: flex-end;
	justify-content: center;
}

.cncgc-auth-modal[hidden] {
	display: none;
}

.cncgc-auth-modal__scrim {
	position: absolute;
	inset: 0;
	background: rgb(17 17 17 / 46%);
	animation: cncgc-auth-fade 0.2s ease;
}

.cncgc-auth-modal__dialog {
	position: relative;
	width: 100%;
	max-height: 92vh;
	max-height: 92dvh;
	overflow-y: auto;
	overscroll-behavior: contain;
	background: var(--cncgc-bg);
	border-radius: 16px 16px 0 0;
	box-shadow: 0 -10px 40px rgb(0 0 0 / 18%);
	animation: cncgc-auth-sheet 0.28s cubic-bezier(0.2, 0.7, 0.2, 1);
}

@keyframes cncgc-auth-fade {
	from { opacity: 0; }
}

@keyframes cncgc-auth-sheet {
	from {
		transform: translateY(40px);
		opacity: 0;
	}
}

@media (min-width: 768px) {
	.cncgc-auth-modal {
		align-items: center;
		padding: 24px;
	}

	.cncgc-auth-modal__dialog {
		width: min(480px, 100%);
		max-height: calc(100vh - 48px);
		border-radius: var(--cncgc-radius);
		box-shadow: 0 30px 80px rgb(0 0 0 / 25%);
	}
}

@media (min-width: 992px) {
	.cncgc-auth-modal__dialog {
		width: min(880px, 100%);
	}
}

/* ---------- Карточка формы ---------- */
.cncgc-auth {
	display: grid;
	grid-template-columns: 1fr;
	background: var(--cncgc-bg);
	color: var(--cncgc-text);
}

.cncgc-auth--inline {
	max-width: 880px;
	margin: 8px auto 48px;
	border: 1px solid var(--cncgc-border);
	border-radius: var(--cncgc-radius);
	box-shadow: var(--cncgc-shadow);
}

.cncgc-auth__bento {
	display: none;
}

@media (min-width: 992px) {
	.cncgc-auth {
		grid-template-columns: 320px 1fr;
	}

	.cncgc-auth__bento {
		display: grid;
		grid-template-rows: auto 1fr auto;
		gap: 24px;
		padding: 28px;
		background: var(--cncgc-black);
		color: #cfcfcf;
	}
}

.cncgc-auth__logo {
	width: 150px;
	height: auto;
}

.cncgc-auth__tiles {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 8px;
	align-content: start;
	margin: 0;
	padding: 0;
	list-style: none;
}

.cncgc-auth__tile {
	display: grid;
	align-content: start;
	gap: 4px;
	padding: 12px;
	background: #1c1c1c;
	border: 1px solid #2c2c2c;
	border-radius: var(--cncgc-radius);
	font-size: 13px;
	line-height: 1.35;
}

.cncgc-auth__tile strong {
	color: #fff;
	font-size: 14px;
}

.cncgc-auth__tile::before {
	content: "";
	width: 6px;
	height: 6px;
	margin-bottom: 4px;
	background: var(--cncgc-red);
}

.cncgc-auth__tile--wide {
	grid-column: 1 / -1;
}

.cncgc-auth__note {
	margin: 0;
	font-size: 12px;
	line-height: 1.45;
	color: #8a8a8a;
}

/* Сноска под «Получить код» — цвет основного текста, приглушённый читался плохо. */
.cncgc-auth__footnote {
	margin: 0;
	font-size: 12px;
	line-height: 1.45;
	color: var(--cncgc-text);
}

/* ---------- Правая часть: шаги ---------- */
.cncgc-auth__pane {
	position: relative;
	display: flex;
	flex-direction: column;
	padding: 12px 20px calc(24px + env(safe-area-inset-bottom, 0px));
}

.cncgc-auth--modal .cncgc-auth__pane::before {
	content: "";
	align-self: center;
	width: 40px;
	height: 4px;
	margin-bottom: 4px;
	border-radius: 2px;
	background: var(--cncgc-border-strong);
}

@media (min-width: 768px) {
	.cncgc-auth__pane {
		min-height: 500px;
		padding: 32px;
	}

	.cncgc-auth--modal .cncgc-auth__pane::before {
		display: none;
	}
}

.cncgc-auth__icon-btn {
	position: absolute;
	top: 8px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 0;
	border-radius: var(--cncgc-radius);
	background: transparent;
	color: var(--cncgc-charcoal);
	cursor: pointer;
}

.cncgc-auth__close {
	right: 8px;
}

.cncgc-auth__back {
	left: 8px;
}

.cncgc-auth__icon-btn[hidden] {
	display: none;
}

@media (hover: hover) and (pointer: fine) {
	.cncgc-auth__icon-btn:hover {
		background: var(--cncgc-bg-soft);
		color: var(--cncgc-black);
	}
}

.cncgc-auth__step {
	display: none;
	flex: 1;
	flex-direction: column;
	gap: 16px;
}

.cncgc-auth__step.is-active {
	display: flex;
	animation: cncgc-auth-step 0.28s cubic-bezier(0.2, 0.7, 0.2, 1);
}

@keyframes cncgc-auth-step {
	from {
		opacity: 0;
		transform: translateX(8px);
	}
}

.cncgc-auth__title {
	margin: 36px 0 0;
	font-size: clamp(22px, 2.4vw, 26px);
	font-weight: 800;
	line-height: 1.15;
	letter-spacing: -0.01em;
	text-wrap: balance;
}

.cncgc-auth--inline .cncgc-auth__title {
	margin-top: 20px;
}

.cncgc-auth__sub {
	margin: 0;
	color: var(--cncgc-text-muted);
	font-size: 15px;
	line-height: 1.5;
}

.cncgc-auth__sub b {
	color: var(--cncgc-text);
	word-break: break-all;
}

/* Поля */
.cncgc-auth__field {
	display: grid;
	gap: 6px;
}

.cncgc-auth__field label {
	font-size: 13px;
	font-weight: 600;
	color: var(--cncgc-charcoal);
}

.cncgc-auth__input {
	width: 100%;
	height: 52px;
	padding: 0 14px;
	border: 1px solid var(--cncgc-border-strong);
	border-radius: var(--cncgc-radius);
	background: var(--cncgc-bg);
	color: var(--cncgc-text);
	font: 500 17px/1 var(--cncgc-font);
	transition: border-color var(--cncgc-transition), box-shadow var(--cncgc-transition);
}

.cncgc-auth__input:focus {
	outline: none;
	border-color: var(--cncgc-black);
	box-shadow: 0 0 0 3px rgb(17 17 17 / 8%);
}

.cncgc-auth__field.is-valid .cncgc-auth__input {
	border-color: var(--cncgc-success);
}

.cncgc-auth__field.is-invalid .cncgc-auth__input {
	border-color: var(--cncgc-red);
}

.cncgc-auth__msg {
	margin: 0;
	font-size: 13px;
	line-height: 1.4;
	color: var(--cncgc-text-muted);
}

.cncgc-auth__msg:empty {
	display: none;
}

.cncgc-auth__msg.is-error,
.cncgc-auth__msg--error,
.cncgc-auth__field.is-invalid .cncgc-auth__msg {
	color: var(--cncgc-red);
}

.cncgc-auth__msg.is-ok {
	color: var(--cncgc-success);
}

.cncgc-auth__msg button {
	padding: 0;
	border: 0;
	background: none;
	color: var(--cncgc-text);
	font: inherit;
	font-weight: 700;
	text-decoration: underline;
	cursor: pointer;
}

/* Honeypot — вне экрана, но не display:none (часть ботов это проверяет) */
.cncgc-auth__hp {
	position: absolute;
	left: -9999px;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

/* Согласия */
.cncgc-auth__checks {
	display: grid;
	gap: 10px;
}

.cncgc-auth__check {
	display: flex;
	gap: 10px;
	align-items: flex-start;
	font-size: 13px;
	line-height: 1.45;
	color: var(--cncgc-charcoal);
	cursor: pointer;
}

.cncgc-auth__check input {
	appearance: none;
	flex: none;
	display: grid;
	place-items: center;
	width: 22px;
	height: 22px;
	margin: 0;
	border: 1.5px solid var(--cncgc-border-strong);
	border-radius: var(--cncgc-radius);
	background: var(--cncgc-bg);
	cursor: pointer;
}

.cncgc-auth__check input:checked {
	border-color: var(--cncgc-black);
	background: var(--cncgc-black);
}

.cncgc-auth__check input:checked::after {
	content: "";
	width: 10px;
	height: 6px;
	border: 2px solid #fff;
	border-top: 0;
	border-right: 0;
	transform: rotate(-45deg) translate(1px, -1px);
}

.cncgc-auth__check input:focus-visible {
	outline: 2px solid var(--cncgc-red);
	outline-offset: 2px;
}

.cncgc-auth__check a {
	color: var(--cncgc-text);
	font-weight: 600;
	text-decoration: underline;
	text-underline-offset: 2px;
}

/* Кнопки */
.cncgc-auth__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	width: 100%;
	min-height: 52px;
	padding: 0 18px;
	border: 1px solid var(--cncgc-black);
	border-radius: var(--cncgc-radius);
	background: var(--cncgc-black);
	color: #fff;
	font: 700 13px/1 var(--cncgc-font);
	letter-spacing: 0.04em;
	text-transform: uppercase;
	cursor: pointer;
	transition: background var(--cncgc-transition), color var(--cncgc-transition);
}

.cncgc-auth__btn:disabled {
	border-color: var(--cncgc-bg-muted);
	background: var(--cncgc-bg-muted);
	color: #8f8f8f;
	cursor: not-allowed;
}

@media (hover: hover) and (pointer: fine) {
	.cncgc-auth__btn:not(:disabled):hover {
		background: #000;
	}
}

.cncgc-auth__spin {
	display: none;
	width: 16px;
	height: 16px;
	border: 2px solid currentcolor;
	border-right-color: transparent;
	border-radius: 50%;
	animation: cncgc-auth-spin 0.7s linear infinite;
}

.cncgc-auth__btn.is-busy .cncgc-auth__spin {
	display: block;
}

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

.cncgc-auth__link {
	align-self: center;
	min-height: 44px;
	padding: 0 8px;
	border: 0;
	background: none;
	color: var(--cncgc-text);
	font: 700 14px/1 var(--cncgc-font);
	text-decoration: underline;
	text-underline-offset: 3px;
	cursor: pointer;
}

.cncgc-auth__link.is-muted {
	color: var(--cncgc-text-muted);
	font-weight: 600;
}

/* Код: одно настоящее поле поверх шести визуальных ячеек */
.cncgc-auth__otp {
	position: relative;
	display: grid;
	grid-template-columns: repeat(6, 1fr);
	gap: 8px;
}

.cncgc-auth__otp input {
	position: absolute;
	inset: 0;
	z-index: 1;
	width: 100%;
	border: 0;
	background: transparent;
	color: transparent;
	caret-color: transparent;
	font-size: 16px;
	opacity: 0;
}

.cncgc-auth__cell {
	display: grid;
	place-items: center;
	height: 56px;
	border: 1px solid var(--cncgc-border-strong);
	border-radius: var(--cncgc-radius);
	background: var(--cncgc-bg);
	font-size: 26px;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
	transition: border-color 0.15s ease;
}

@media (min-width: 768px) {
	.cncgc-auth__cell {
		height: 60px;
	}
}

.cncgc-auth__cell.is-current {
	border-color: var(--cncgc-black);
	box-shadow: 0 0 0 3px rgb(17 17 17 / 8%);
}

.cncgc-auth__cell.is-current:empty::after {
	content: "";
	width: 2px;
	height: 26px;
	background: var(--cncgc-black);
	animation: cncgc-auth-blink 1s steps(1) infinite;
}

@keyframes cncgc-auth-blink {
	50% { opacity: 0; }
}

.cncgc-auth__otp.is-bad .cncgc-auth__cell {
	border-color: var(--cncgc-red);
}

.cncgc-auth__otp.is-bad {
	animation: cncgc-auth-shake 0.35s;
}

.cncgc-auth__otp.is-good .cncgc-auth__cell {
	border-color: var(--cncgc-success);
	color: var(--cncgc-success);
}

@keyframes cncgc-auth-shake {
	25% { transform: translateX(-6px); }
	50% { transform: translateX(6px); }
	75% { transform: translateX(-3px); }
}

.cncgc-auth__resend {
	padding: 12px;
	border-radius: var(--cncgc-radius);
	background: var(--cncgc-bg-soft);
	color: var(--cncgc-text-muted);
	font-size: 14px;
	font-variant-numeric: tabular-nums;
	text-align: center;
}

.cncgc-auth__resend:empty {
	display: none;
}

.cncgc-auth__resend button {
	min-height: 32px;
	padding: 0;
	border: 0;
	background: none;
	color: var(--cncgc-text);
	font: 700 14px/1 var(--cncgc-font);
	text-decoration: underline;
	cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
	.cncgc-auth-modal__scrim,
	.cncgc-auth-modal__dialog,
	.cncgc-auth__step.is-active,
	.cncgc-auth__otp.is-bad,
	.cncgc-auth__cell.is-current:empty::after {
		animation: none;
	}
}
