/* Cloud Drive Sign-in for Kodi. Mobile-first: most people arrive here from the QR code on their TV. */

:root {
	--bg: #f3f5f9;
	--surface: #ffffff;
	--text: #172033;
	--muted: #5a6478;
	--border: #dde3ec;
	--accent: #2457d6;
	--accent-hover: #1c47b3;
	--accent-text: #ffffff;
	--accent-soft: #e8eefc;
	--success: #1f9d55;
	--danger: #c9372c;
	--danger-soft: #fdecea;
	--focus: rgba(36, 87, 214, 0.35);
	--radius: 16px;
	--shadow: 0 1px 2px rgba(23, 32, 51, 0.06), 0 8px 24px rgba(23, 32, 51, 0.08);
	--font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	--mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #0e1422;
		--surface: #161e2f;
		--text: #e6ebf4;
		--muted: #9aa5ba;
		--border: #283349;
		--accent: #5b8cff;
		--accent-hover: #7aa2ff;
		--accent-text: #0b1020;
		--accent-soft: #1c2a4a;
		--success: #3ccf7d;
		--danger: #ff6b5e;
		--danger-soft: #3a1d1d;
		--focus: rgba(91, 140, 255, 0.45);
		--shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
	}
}

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

html {
	-webkit-text-size-adjust: 100%;
}

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font: 16px/1.5 var(--font);
}

a {
	color: var(--accent);
}

a:hover {
	color: var(--accent-hover);
}

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

.visually-hidden {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	border: 0;
}

/* Page shell */

.shell {
	max-width: 460px;
	margin: 0 auto;
	padding: 24px 16px 32px;
}

.shell:has(.prose) {
	max-width: 760px;
}

.brand {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	margin-bottom: 20px;
	color: var(--text);
	font-weight: 600;
	text-decoration: none;
}

.brand:hover {
	color: var(--text);
}

.brand-icon {
	width: 32px;
	height: 32px;
	color: var(--accent);
}

.card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	padding: 24px 20px;
}

@media (min-width: 480px) {
	.shell {
		padding-top: 48px;
	}

	.card {
		padding: 32px;
	}
}

h1 {
	margin: 0 0 8px;
	font-size: 1.5rem;
	line-height: 1.25;
}

h2 {
	margin: 0 0 8px;
	font-size: 1.125rem;
}

.lead {
	margin: 0 0 24px;
	color: var(--muted);
}

/* Step indicator */

.steps {
	display: flex;
	gap: 8px;
	margin: 0 0 28px;
	padding: 0;
	list-style: none;
	font-size: 0.8125rem;
	color: var(--muted);
}

.step {
	flex: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 6px;
	text-align: center;
	position: relative;
}

/* Connector line between dots */
.step + .step::before {
	content: "";
	position: absolute;
	top: 13px;
	right: calc(50% + 18px);
	width: calc(100% - 28px);
	height: 2px;
	background: var(--border);
}

.step.complete + .step::before {
	background: var(--accent);
}

.step-dot {
	display: grid;
	place-items: center;
	width: 28px;
	height: 28px;
	border-radius: 50%;
	border: 2px solid var(--border);
	background: var(--surface);
	font-weight: 600;
	color: var(--muted);
}

.step.current {
	color: var(--text);
	font-weight: 600;
}

.step.current .step-dot {
	border-color: var(--accent);
	color: var(--accent);
}

.step.complete .step-dot {
	border-color: var(--accent);
	background: var(--accent);
	color: var(--accent-text);
}

.step.failed {
	color: var(--danger);
	font-weight: 600;
}

.step.failed .step-dot {
	border-color: var(--danger);
	background: var(--danger);
	color: var(--surface);
}

/* Code input: a plain text field, upgraded to six boxes by app.js */

.code-field {
	position: relative;
	margin-bottom: 16px;
}

.code-field input {
	display: block;
	width: 100%;
	padding: 12px 14px;
	border: 2px solid var(--border);
	border-radius: 12px;
	background: var(--surface);
	color: var(--text);
	font: 600 1.75rem/1.2 var(--mono);
	letter-spacing: 0.3em;
	text-align: center;
	text-transform: uppercase;
}

.code-field input:focus {
	outline: none;
	border-color: var(--accent);
	box-shadow: 0 0 0 4px var(--focus);
}

.code-field input[aria-invalid="true"] {
	border-color: var(--danger);
}

.code-boxes {
	display: none;
}

.code-field.enhanced .code-boxes {
	display: grid;
	grid-template-columns: repeat(6, 1fr);
	gap: 8px;
}

/* The real input stays on top, transparent, so typing, pasting and autofill keep working */
.code-field.enhanced input {
	position: absolute;
	inset: 0;
	z-index: 1;
	opacity: 0;
	font-size: 16px;
	cursor: text;
}

.code-box {
	display: grid;
	place-items: center;
	aspect-ratio: 4 / 5;
	border: 2px solid var(--border);
	border-radius: 12px;
	background: var(--surface);
	font: 600 1.75rem/1 var(--mono);
	color: var(--text);
	transition: border-color 0.15s, box-shadow 0.15s;
}

.code-box.filled {
	border-color: var(--muted);
}

.code-box.active {
	border-color: var(--accent);
	box-shadow: 0 0 0 4px var(--focus);
}

.code-box.active:empty::after {
	content: "";
	width: 2px;
	height: 1.4em;
	background: var(--accent);
	animation: blink 1s steps(1) infinite;
}

.code-field input[aria-invalid="true"] + .code-boxes .code-box {
	border-color: var(--danger);
}

@keyframes blink {
	50% {
		opacity: 0;
	}
}

/* Buttons and alerts */

.button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 48px;
	padding: 12px 24px;
	border: 0;
	border-radius: 12px;
	font: 600 1rem/1.2 var(--font);
	text-decoration: none;
	cursor: pointer;
}

.button.primary {
	background: var(--accent);
	color: var(--accent-text);
}

.button.primary:hover {
	background: var(--accent-hover);
	color: var(--accent-text);
}

.button.secondary {
	border: 2px solid var(--border);
	background: transparent;
	color: var(--text);
}

.button.secondary:hover {
	border-color: var(--accent);
}

.button.block {
	width: 100%;
}

.alert {
	margin: 0 0 16px;
	padding: 12px 14px;
	border-radius: 12px;
	background: var(--danger-soft);
	color: var(--danger);
	font-size: 0.9375rem;
}

/* Notice */

.notice {
	margin: -8px 0 20px;
	font-size: 0.875rem;
	color: var(--muted);
}

/* Help disclosure */

.help {
	margin-top: 24px;
	padding-top: 16px;
	border-top: 1px solid var(--border);
	font-size: 0.9375rem;
	color: var(--muted);
	text-align: left;
}

.help summary {
	cursor: pointer;
	color: var(--text);
	font-weight: 600;
}

.help p {
	margin: 12px 0 0;
}

.help + .help {
	margin-top: 12px;
	padding-top: 12px;
}

.help ul {
	margin: 12px 0 0;
	padding-left: 20px;
}

.help li + li {
	margin-top: 6px;
}

/* Success / failure */

.status {
	text-align: center;
}

.status-icon {
	width: 72px;
	height: 72px;
	margin: 0 auto 16px;
	display: block;
	fill: none;
	stroke-width: 3.5;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.status-icon.success {
	stroke: var(--success);
}

.status-icon.failure {
	stroke: var(--danger);
}

.status-ring,
.status-mark {
	stroke-dasharray: 1;
	stroke-dashoffset: 1;
	animation: draw 0.6s ease-out forwards;
}

.status-mark {
	animation-delay: 0.45s;
}

@keyframes draw {
	to {
		stroke-dashoffset: 0;
	}
}

.status .alert {
	text-align: left;
}

/* Funding card */

.funding {
	margin-top: 28px;
	padding: 20px;
	border-radius: 12px;
	background: var(--accent-soft);
	text-align: left;
}

.funding p {
	margin: 0 0 12px;
	font-size: 0.9375rem;
}

.funding-bar {
	display: block;
	width: 100%;
	height: 10px;
	margin-bottom: 6px;
	border: 0;
	border-radius: 5px;
	background: var(--border);
	overflow: hidden;
	-webkit-appearance: none;
	appearance: none;
}

.funding-bar::-webkit-progress-bar {
	background: var(--border);
	border-radius: 5px;
}

.funding-bar::-webkit-progress-value {
	background: var(--success);
	border-radius: 5px;
}

.funding-bar::-moz-progress-bar {
	background: var(--success);
	border-radius: 5px;
}

.funding .funding-progress {
	font-size: 0.8125rem;
	color: var(--muted);
}

/* Privacy policy */

.prose h2 {
	margin-top: 32px;
}

.prose h3 {
	margin: 20px 0 6px;
	font-size: 1rem;
}

.prose p,
.prose ul {
	margin: 0 0 12px;
}

.prose li + li {
	margin-top: 6px;
}

.prose .meta {
	color: var(--muted);
	font-size: 0.875rem;
}

.prose code {
	font: 0.875em var(--mono);
	padding: 1px 5px;
	border-radius: 5px;
	background: var(--accent-soft);
}

.scopes {
	margin: 0 0 12px;
	border-top: 1px solid var(--border);
}

.scopes dt {
	padding-top: 12px;
	font-weight: 600;
}

.scopes dd {
	margin: 4px 0 0;
	padding-bottom: 12px;
	border-bottom: 1px solid var(--border);
	color: var(--muted);
}

/* Footer */

.footer {
	margin-top: 24px;
	text-align: center;
	font-size: 0.8125rem;
	color: var(--muted);
}

.footer-links {
	display: flex;
	justify-content: center;
	gap: 20px;
	margin-bottom: 6px;
}

.footer p {
	margin: 0;
}

@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after {
		animation: none !important;
		transition: none !important;
	}

	.status-ring,
	.status-mark {
		stroke-dashoffset: 0;
	}
}
