/* The pages on the auth origin: sign-in, setup, the account's credentials, the
   appeal, the waitlist, a notice. The panel's look (modules/web/ui, app/_door):
   the name large and left-aligned in the middle of the window, then one
   section, which is a caption over a hairline and its content. Fields are a label over a control, buttons a line, what a
   page says back a status in mono. Tokens, themes and faces are tokens.css,
   the panel's own (den gen auth-tokens); the rules below are the primitives'
   (Section, Field, TextField, Button, Mono, Door) for markup without
   components, and the little of the web app's reset and base the pages need. */

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

* {
	margin: 0;
}

html {
	-webkit-text-size-adjust: none;
	text-size-adjust: none;
}

body {
	min-height: 100dvh;
	background: var(--ground);
	color: var(--ink);
	font-family: var(--font-sans), system-ui, sans-serif;
	font-size: var(--size-15);
	line-height: var(--lh-body);
	font-weight: var(--w-regular);
	-webkit-font-smoothing: antialiased;
}

svg {
	display: block;
	max-width: 100%;
}

input,
button,
textarea,
select {
	font: inherit;
	color: inherit;
}

button {
	cursor: pointer;
}

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

::selection {
	background: var(--pink-wash);
}

[hidden] {
	display: none !important;
}

/* --- the door: the name, then one column, left-aligned in the middle of the window --- */

.door {
	/* the door's controls: one height for a field and a button, larger than
	   the panel's, since a door page holds little else */
	--door-h: 44px;
	display: grid;
	/* the column is as wide as the name, and at least 26rem for the fields */
	grid-template-columns: minmax(min(100%, 26rem), max-content);
	align-content: center;
	gap: var(--s-6);
	min-height: 100dvh;
	max-width: var(--page);
	margin-inline: auto;
	padding: var(--s-8) var(--gutter);
}

.mark {
	font-size: clamp(48px, 7vw, 96px);
	font-weight: var(--w-medium);
	line-height: 1;
	letter-spacing: -0.03em;
	white-space: nowrap;
}

/* the domain's full stop and tld: pink is ours */
.mark .accent {
	color: var(--pink-ink);
}

/* --- the section: a caption over a hairline, then the content --- */

.door > section {
	display: grid;
	gap: var(--s-3);
	min-width: 0;
}

.head {
	display: flex;
	align-items: center;
	height: var(--caption-h);
	border-bottom: 1px solid var(--line);
}

.head h1 {
	font-size: var(--size-13);
	font-weight: var(--w-medium);
	line-height: var(--lh-tight);
	color: var(--ink-2);
}

.content {
	display: flex;
	flex-direction: column;
	gap: var(--s-4);
	min-width: 0;
}

form {
	display: flex;
	flex-direction: column;
	gap: var(--s-4);
	min-width: 0;
}

/* --- fields: a label over a control, a note under --- */

.field {
	display: grid;
	gap: var(--s-1);
	min-width: 0;
}

.field > label {
	font-size: var(--size-13);
	font-weight: var(--w-medium);
	line-height: var(--lh-tight);
	color: var(--ink-2);
}

input:not([type="hidden"]),
textarea,
select {
	width: 100%;
	min-height: var(--door-h);
	padding: var(--s-1) var(--s-3);
	border: 1px solid var(--line-2);
	border-radius: var(--r);
	background: var(--raised);
	color: var(--ink);
	font-size: var(--size-15);
	line-height: var(--lh-body);
	transition:
		border-color var(--t-hover) var(--ease),
		background var(--t-hover) var(--ease);
}

input:not([type="hidden"]),
select {
	height: var(--door-h);
}

textarea {
	min-height: calc(var(--door-h) * 3);
	resize: vertical;
}

select {
	padding-inline: var(--s-2);
	cursor: pointer;
}

select option {
	background: var(--floating);
	color: var(--ink);
}

input::placeholder,
textarea::placeholder {
	color: var(--ink-3);
}

input:not([type="hidden"]):hover,
textarea:hover,
select:hover {
	background: var(--floating);
}

input:not([type="hidden"]):focus-visible,
textarea:focus-visible,
select:focus-visible {
	outline: 2px solid var(--focus-ring);
	outline-offset: 0;
	border-color: var(--focus-ring);
}

input:disabled,
textarea:disabled,
select:disabled {
	opacity: 0.5;
	background: var(--raised);
}

:is(input, textarea, select):not([type="hidden"])[aria-invalid="true"] {
	border-color: var(--shu);
}

/* A field only a program fills (pages.ts applyPage): out of sight and out of
   the tab order, and not hidden by an attribute a program would skip. */
.trap {
	position: absolute;
	left: -10000px;
	width: 1px;
	height: 1px;
	overflow: hidden;
	opacity: 0;
}

/* --- buttons: plain, the primary (emph) in pink, danger in shu --- */

/* the buttons share the column's width */
.verbs {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--s-3);
}

.verbs > button,
.verbs > .btn {
	flex: 1 1 auto;
}

button,
.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: var(--s-2);
	min-height: var(--door-h);
	padding: 0 var(--s-5);
	border: 1px solid var(--line);
	border-radius: var(--r);
	background: var(--raised);
	color: var(--ink);
	font-size: var(--size-17);
	font-weight: var(--w-medium);
	line-height: 1;
	white-space: nowrap;
	text-decoration: none;
	transition:
		background var(--t-hover) var(--ease),
		border-color var(--t-hover) var(--ease),
		color var(--t-hover) var(--ease);
}

button:hover,
.btn:hover {
	background: var(--floating);
	border-color: var(--line-2);
}

button.emph,
.btn.emph {
	border-color: transparent;
	background: var(--pink);
	color: var(--on-pink);
}

button.emph:hover,
.btn.emph:hover {
	background: color-mix(in oklab, var(--pink) 85%, var(--on-pink));
	border-color: transparent;
}

button.danger,
.btn.danger {
	border-color: var(--shu);
	background: var(--shu-wash);
	color: var(--shu-ink);
}

button.danger:hover,
.btn.danger:hover {
	background: color-mix(in oklab, var(--shu) 16%, var(--ground));
	border-color: var(--shu);
}

button:disabled {
	opacity: 0.5;
	cursor: default;
	pointer-events: none;
}

/* --- links, as the panel's Mono link: a dotted hairline --- */

a:not(.btn) {
	color: inherit;
	text-decoration: underline dotted var(--line-2);
	text-underline-offset: 3px;
	transition: text-decoration-color var(--t-hover) var(--ease);
}

a:not(.btn):hover {
	text-decoration-color: var(--ink-2);
}

/* --- facts: a label over its value, the value in mono --- */

dl {
	display: grid;
	min-width: 0;
}

dt {
	font-size: var(--size-12);
	line-height: var(--lh-snug);
	color: var(--ink-2);
}

dd + dt {
	margin-top: var(--s-3);
}

dd {
	min-width: 0;
	overflow-wrap: anywhere;
}

.v {
	font-family: var(--font-mono), ui-monospace, monospace;
	font-size: var(--size-13);
	line-height: var(--lh-snug);
}

/* Who wrote it, and when, on one line (the appeal's thread). */
dl.line {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: var(--s-1) var(--s-2);
}

dl.line dd + dt {
	margin-top: 0;
}

/* --- what a page says --- */

.status {
	font-family: var(--font-mono), ui-monospace, monospace;
	font-size: var(--size-15);
	line-height: var(--lh-snug);
	color: var(--ink-2);
	overflow-wrap: anywhere;
}

.status.refused {
	color: var(--shu-ink);
}

/* What the page says back after an action (common.js say), under the last
   thing in the section; nothing, and no gap, until there is something. */
output {
	display: block;
	font-family: var(--font-mono), ui-monospace, monospace;
	font-size: var(--size-15);
	color: var(--ink-2);
	line-height: var(--lh-snug);
	overflow-wrap: anywhere;
}

output:empty {
	margin-top: calc(var(--s-4) * -1);
}

/* The appeal's thread (pages.ts appealPage): a message's text as it was typed,
   under the line that says who wrote it and when. */
.entry {
	display: grid;
	gap: var(--s-1);
}

.message {
	white-space: pre-wrap;
	overflow-wrap: anywhere;
	font-size: var(--size-14);
}

/* The authenticator key's QR code (authenticator.js): a light ground and dark
   modules, as a camera expects, whatever the theme. */
.qr {
	align-self: flex-start;
	max-width: 100%;
	height: auto;
	border: 1px solid var(--line-2);
	border-radius: var(--r);
}

.qr-ground {
	fill: var(--graphite-ink);
}

.qr-dark {
	fill: var(--graphite-ground);
}

/* Phone: centred, each button a full-width line of its own. A field's label
   stays over its control. */
@media (max-width: 640px) {
	.mark,
	.head,
	.content > .status,
	output {
		text-align: center;
	}
	.head {
		justify-content: center;
	}
	.verbs {
		flex-direction: column;
		align-items: stretch;
	}
}
