/*
 * TTAI — sessionVersion 2 auth screens.
 * Loaded by templates/auth/shell.tpl when the active app is TTAI.
 *
 * Self-contained. Two things design.tpl would normally provide are missing on
 * these screens, both because $ttai is unset this early in bootstrap
 * (siteCustomHeader::initialize() runs after sessionUser::loadSession()):
 *   - ttai-extra.css / ttaiNavbar.css / ttaiFooter.css are not loaded, so the
 *     body background and the logo's light-theme treatment are owned here.
 *   - the TTAI navbar is not rendered; the Readocracy one is, and gets hidden.
 * style.css loads only for non-Preauth visitors, so it is absent on step-up,
 * recovery codes and sign-out-everywhere — nothing here may depend on it.
 *
 * Dark is the authored default and `body[data-ttf-theme='light']` overrides it,
 * matching every other TTAI stylesheet. shell.tpl's pre-paint script sets that
 * attribute from localStorage 'ttf-theme' before this card is parsed, so a
 * remembered choice never flashes. With JS off no attribute is set and the
 * screens stay dark. There is no toggle here — the nav that carries it is
 * hidden — so the choice is whatever the rest of the app last stored.
 */

nav.main-nav,
nav.main-nav.ttai-navbar,
nav.main-nav-rwrdrc {
	display: none !important;
}

.auth-ttai {
	--ttai-pink: #ff004e;
	--ttai-pink-deep: #d90042;
	--ttai-pink-soft: rgba(255, 0, 78, 0.12);
	--ttai-green: #10b981;
	--ttai-bg: #000000;
	--ttai-card: #0e0e11;
	--ttai-card-elevated: #16161a;
	--ttai-line: rgba(255, 255, 255, 0.08);
	--ttai-line-strong: rgba(255, 255, 255, 0.14);
	--ttai-ink: #ffffff;
	--ttai-ink-soft: rgba(255, 255, 255, 0.72);
	--ttai-ink-mute: rgba(255, 255, 255, 0.45);
	--ttai-error: #ff4d6f;
	--ttai-error-bg: rgba(255, 77, 111, 0.10);
	--ttai-field: rgba(255, 255, 255, 0.04);
	--ttai-radius: 18px;
	--ttai-radius-sm: 12px;

	box-sizing: border-box;
	display: flex;
	flex-direction: column;
	width: 100%;
	min-height: 100vh;
	padding: 20px 20px 48px;
	background: var(--ttai-bg);
	color: var(--ttai-ink);
	color-scheme: dark;
	font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	-webkit-font-smoothing: antialiased;
}

/* nav.css paints the body #0b0a0c; the card column is centred and narrower than
   the viewport, so the body shows through as gutters and has to match. */
body.ttai {
	background-color: #000000;
}

.auth-ttai .auth-logo {
	display: inline-block;
	align-self: flex-start;
}

.auth-ttai .auth-logo img {
	display: block;
	height: 32px;
	width: auto;
}

.auth-ttai .auth-wrap {
	align-self: center;
	width: 100%;
	max-width: 440px;
	margin-top: 48px;
}

.auth-ttai .auth-card {
	box-sizing: border-box;
	padding: 36px 32px 40px;
	border: 1px solid var(--ttai-line);
	border-radius: var(--ttai-radius);
	background: var(--ttai-card);
}

/* ---- Copy ---- */

.auth-ttai .auth-title {
	margin: 0 0 12px;
	font-size: 25px;
	font-weight: 800;
	letter-spacing: -0.4px;
	line-height: 1.2;
	color: var(--ttai-ink);
}

.auth-ttai .auth-lead {
	margin: 0 0 20px;
	font-size: 15px;
	line-height: 1.55;
	color: var(--ttai-ink-soft);
}

.auth-ttai .auth-lead strong {
	color: var(--ttai-ink);
	font-weight: 700;
}

.auth-ttai .auth-context {
	margin: 0 0 20px;
	padding: 12px 14px;
	border-left: 3px solid var(--ttai-pink);
	border-radius: 0 var(--ttai-radius-sm) var(--ttai-radius-sm) 0;
	background: var(--ttai-pink-soft);
	font-size: 14px;
	line-height: 1.5;
	color: var(--ttai-ink);
}

.auth-ttai .auth-notice {
	margin: 0 0 20px;
	padding: 12px 14px;
	border: 1px solid rgba(255, 77, 111, 0.32);
	border-radius: var(--ttai-radius-sm);
	background: var(--ttai-error-bg);
	color: var(--ttai-error);
	font-size: 14px;
	font-weight: 600;
	line-height: 1.5;
}

/* ---- Form ---- */

.auth-ttai .auth-form {
	margin: 0;
	padding: 0;
}

.auth-ttai .auth-field {
	margin-bottom: 18px;
}

.auth-ttai .auth-field:last-child {
	margin-bottom: 0;
}

.auth-ttai .auth-label {
	display: block;
	margin-bottom: 8px;
	font-size: 13px;
	font-weight: 600;
	color: var(--ttai-ink-soft);
}

.auth-ttai .auth-input {
	box-sizing: border-box;
	width: 100%;
	padding: 13px 15px;
	border: 1px solid var(--ttai-line-strong);
	border-radius: var(--ttai-radius-sm);
	background: var(--ttai-field);
	color: var(--ttai-ink);
	font-family: inherit;
	font-size: 15px;
	font-weight: 500;
	transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.auth-ttai .auth-input::placeholder {
	color: var(--ttai-ink-mute);
	letter-spacing: normal;
}

.auth-ttai .auth-input:focus {
	outline: none;
	border-color: var(--ttai-pink);
	box-shadow: 0 0 0 3px var(--ttai-pink-soft);
}

.auth-ttai .auth-code {
	font-size: 24px;
	font-weight: 700;
	letter-spacing: 10px;
	text-align: center;
	font-variant-numeric: tabular-nums;
}

.auth-ttai .auth-mono {
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 16px;
	letter-spacing: 2px;
	text-align: center;
}

/* No error class reaches the input itself, so key off the message that
   follows it — an unsupported :has() simply leaves the border unchanged. */
.auth-ttai .auth-input:has(+ .auth-error) {
	border-color: var(--ttai-error);
}

.auth-ttai .auth-error {
	display: block;
	margin-top: 6px;
	font-size: 13px;
	font-weight: 600;
	color: var(--ttai-error);
}

.auth-ttai .auth-check {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	font-size: 13px;
	font-weight: 500;
	line-height: 1.45;
	color: var(--ttai-ink-soft);
	cursor: pointer;
}

.auth-ttai .auth-check input {
	flex: 0 0 auto;
	margin: 2px 0 0;
	accent-color: var(--ttai-pink);
}

.auth-ttai .auth-submit {
	box-sizing: border-box;
	width: 100%;
	padding: 15px 24px;
	border: none;
	border-radius: var(--ttai-radius-sm);
	background: var(--ttai-pink);
	color: #ffffff;
	font-family: inherit;
	font-size: 16px;
	font-weight: 700;
	cursor: pointer;
	-webkit-appearance: none;
	transition: background-color 0.2s ease;
}

.auth-ttai .auth-submit:hover {
	background: var(--ttai-pink-deep);
}

.auth-ttai .auth-submit:focus-visible {
	outline: 3px solid var(--ttai-pink-soft);
	outline-offset: 2px;
}

/* Revoking every session is destructive — it does not get the brand CTA. */
.auth-ttai .auth-submit-danger {
	background: transparent;
	border: 1px solid rgba(255, 77, 111, 0.42);
	color: var(--ttai-error);
}

.auth-ttai .auth-submit-danger:hover {
	background: var(--ttai-error-bg);
	border-color: var(--ttai-error);
}

/* ---- Secondary links ---- */

.auth-ttai .auth-fine {
	display: flex;
	flex-direction: column;
	gap: 10px;
	align-items: flex-start;
	margin-top: 24px;
	padding-top: 20px;
	border-top: 1px solid var(--ttai-line);
}

/* nav.css forces `a:link { color:#fff !important }` inside nav, but the
   generic link colours it also sets are broad enough to reach here — state the
   colour on every link state so these read as links in both themes. */
.auth-ttai .auth-fine a,
.auth-ttai .auth-fine a:link,
.auth-ttai .auth-fine a:visited {
	color: var(--ttai-ink-soft);
	font-size: 14px;
	font-weight: 600;
	text-decoration: none;
	border-bottom: 1px solid var(--ttai-line-strong);
	padding-bottom: 2px;
}

.auth-ttai .auth-fine a:hover {
	color: var(--ttai-pink);
	border-color: var(--ttai-pink);
}

/* ---- Enrolment: QR + manual key ---- */

/* config::renderQR() returns false in MWE core and Readocracy does not override
   it yet, so $qr is empty and this does not render. The white plate is not
   decoration: a QR with dark modules is unscannable on the dark card. */
.auth-ttai .auth-qr {
	display: flex;
	justify-content: center;
	margin: 0 0 20px;
	padding: 14px;
	border-radius: var(--ttai-radius-sm);
	background: #ffffff;
}

.auth-ttai .auth-qr img,
.auth-ttai .auth-qr svg,
.auth-ttai .auth-qr canvas {
	display: block;
	width: 180px;
	height: 180px;
	image-rendering: pixelated;
}

.auth-ttai .auth-key {
	margin: 0 0 22px;
	padding: 14px 16px;
	border: 1px solid var(--ttai-line);
	border-radius: var(--ttai-radius-sm);
	background: var(--ttai-card-elevated);
}

.auth-ttai .auth-key p {
	margin: 0 0 8px;
	font-size: 13px;
	line-height: 1.5;
	color: var(--ttai-ink-soft);
}

.auth-ttai .auth-key p:last-child {
	margin-bottom: 0;
}

.auth-ttai .auth-key code {
	display: block;
	word-break: break-all;
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 15px;
	font-weight: 600;
	letter-spacing: 1px;
	color: var(--ttai-ink);
	-webkit-user-select: all;
	user-select: all;
}

.auth-ttai .auth-key-account {
	font-size: 12px;
	color: var(--ttai-ink-mute);
}

/* ---- Recovery codes ---- */

.auth-ttai .auth-codes {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 8px;
	margin: 0 0 24px;
	padding: 14px;
	list-style: none;
	border: 1px solid var(--ttai-line);
	border-radius: var(--ttai-radius-sm);
	background: var(--ttai-card-elevated);
}

.auth-ttai .auth-codes code {
	display: block;
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 15px;
	font-weight: 600;
	letter-spacing: 1px;
	color: var(--ttai-ink);
	-webkit-user-select: all;
	user-select: all;
}

/* ============================================================================
 * LIGHT THEME. Activated by body[data-ttf-theme='light'], set by shell.tpl's
 * pre-paint script from the same localStorage key the rest of TTAI uses.
 * Surfaces mirror the feed light theme (bg #f2f2f7, cards #fff, line #e5e5ea);
 * the pink CTA and the error red are kept.
 * ========================================================================== */

body.ttai[data-ttf-theme='light'] {
	background-color: #f2f2f7;
}

body.ttai[data-ttf-theme='light'] .auth-ttai {
	--ttai-bg: #f2f2f7;
	--ttai-card: #ffffff;
	--ttai-card-elevated: #f7f7fa;
	--ttai-line: rgba(0, 0, 0, 0.08);
	--ttai-line-strong: rgba(0, 0, 0, 0.14);
	--ttai-ink: #1c1c1e;
	--ttai-ink-soft: #3a3a3c;
	--ttai-ink-mute: #8e8e93;
	--ttai-error: #d1244a;
	--ttai-error-bg: rgba(209, 36, 74, 0.08);
	--ttai-field: #ffffff;
	color-scheme: light;
}

/* The brand letter-logo is white-on-transparent — same treatment the light nav
   bar gives it (ttaiNavbar.css), which is not loaded on these screens. */
body.ttai[data-ttf-theme='light'] .auth-ttai .auth-logo img {
	filter: brightness(0);
}

/* The card is white on a near-white canvas — a shadow is what separates them. */
body.ttai[data-ttf-theme='light'] .auth-ttai .auth-card {
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
}

/* Empty on white; give the field a visible edge instead of a tint. */
body.ttai[data-ttf-theme='light'] .auth-ttai .auth-input {
	border-color: #d8d8de;
}

/* The dark outline button is invisible as an outline on white. */
body.ttai[data-ttf-theme='light'] .auth-ttai .auth-submit-danger {
	border-color: rgba(209, 36, 74, 0.38);
}

/* ---- Narrow ---- */

@media screen and (max-width: 700px) {
	.auth-ttai {
		padding: 16px 16px 40px;
	}

	.auth-ttai .auth-wrap {
		margin-top: 28px;
	}

	.auth-ttai .auth-card {
		padding: 26px 20px 30px;
	}

	.auth-ttai .auth-title {
		font-size: 22px;
	}

	.auth-ttai .auth-code {
		letter-spacing: 6px;
		font-size: 21px;
	}

	.auth-ttai .auth-codes {
		grid-template-columns: 1fr;
	}
}
