/*
 * Base elements and the controls every module uses: buttons (one kind of raised round button, one kind of pill),
 * flat rows, cards, fields (switches, segmented choices and settings rows: css/controls.css). A module writes only what is its own, with its own prefix
 * (.eo-…, .gr-…); everything here is unprefixed and belongs to the frame (css/tokens.css has the values).
 */
*,
*::before,
*::after {
	box-sizing: border-box;
}

html {
	-webkit-text-size-adjust: 100%;
	-webkit-tap-highlight-color: transparent; /* our buttons show their own press */
}

@media (hover: none) {
	:focus:not(:focus-visible) {
		outline: none;
	}
}

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font-family: var(--font);
	font-size: calc(14px * var(--ui-scale));
	line-height: 1.5;
}

a {
	color: var(--text-strong);
	font-weight: 500;
	text-underline-offset: 2px;
}

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

[hidden] {
	display: none !important;
}

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

/* ---- buttons ----
   .round                a raised round button: the avatar, ☰, ⋯, "?" (32 px; .round--sm 26 px)
   .btn                  a raised pill with words (.btn-secondary says the same: the programs' name for it)
   .btn--solid           the one thing to do (.btn-primary: the same, as wide as its form unless .btn-auto)
   .btn--danger          words in red;  .btn--danger-solid / .btn-danger-solid: red, for "delete" in a question
   .icon-btn             a flat square icon button (in toolbars), .icon-btn-sm smaller
   One look for all of them: lit from the top left, sinking while pressed. */

.round,
.btn {
	display: inline-flex;
	flex: none;
	align-items: center;
	justify-content: center;
	gap: 6px;
	border: 1px solid var(--border);
	border-top-color: var(--edge-top);
	border-bottom-color: var(--edge-bottom);
	background: var(--face), var(--surface);
	color: var(--text);
	box-shadow: var(--edge-light), var(--elev-1);
	text-decoration: none;
	cursor: pointer;
	transition:
		background-color var(--dur-quick),
		color var(--dur-quick),
		box-shadow var(--dur-quick),
		scale var(--dur) var(--ease-grow);
}

.round {
	width: 32px;
	height: 32px;
	padding: 0;
	border-radius: 50%;
	color: var(--muted);
}

.round--sm {
	width: 26px;
	height: 26px;
}

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

.btn {
	min-height: 34px;
	padding: 6px 14px;
	border-radius: 999px;
	font-size: calc(14px * var(--ui-scale));
	font-weight: 500;
	white-space: nowrap;
}

.btn:hover:not(:disabled) {
	background: var(--face), var(--surface-2);
}

.btn--solid,
.btn-primary {
	border-color: var(--accent);
	background: var(--face-solid), var(--accent);
	color: var(--accent-text);
	box-shadow: var(--btn-solid-shadow);
}

.btn--solid:hover:not(:disabled),
.btn-primary:hover:not(:disabled) {
	background: var(--face-solid), var(--accent-hover);
}

.btn-primary {
	width: 100%;
}

.btn-auto {
	width: auto;
	align-self: flex-start;
}

.btn--solid:disabled,
.btn-primary:disabled {
	border-color: var(--well-top) var(--well-bottom) var(--well-bottom) var(--well-top);
	background: var(--well-bg);
	color: var(--faint);
	box-shadow: var(--well-shadow);
	opacity: 1;
	cursor: not-allowed;
}

.btn--danger,
.btn-danger {
	color: var(--danger);
}

.btn--danger-solid,
.btn-danger-solid {
	border-color: var(--danger);
	background: var(--face-solid), var(--danger);
	color: #fff;
	box-shadow: var(--btn-solid-shadow);
}

.btn--danger-solid:hover:not(:disabled),
.btn-danger-solid:hover:not(:disabled) {
	background: var(--face-solid), var(--danger);
	filter: brightness(1.08);
}

.btn-sm {
	min-height: 28px;
	padding: 3px 10px;
	font-size: calc(12px * var(--ui-scale));
}

.round:active:not(:disabled),
.btn:active:not(:disabled) {
	border-top-color: var(--edge-bottom);
	border-bottom-color: var(--edge-top);
	box-shadow: var(--btn-pressed);
	scale: 0.96;
	transition-duration: 80ms;
}

.round:disabled,
.btn:disabled {
	opacity: 0.5;
	cursor: default;
}

.icon-btn {
	display: inline-flex;
	flex: none;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	padding: 0;
	border: 0;
	border-radius: var(--radius-sm);
	background: none;
	color: var(--muted);
	cursor: pointer;
	transition:
		background-color var(--dur-quick),
		color var(--dur-quick),
		scale var(--dur) var(--ease-grow);
}

.icon-btn:hover:not(:disabled) {
	background: var(--surface-2);
	color: var(--text-strong);
}

.icon-btn:active:not(:disabled) {
	scale: 0.92;
	transition-duration: 80ms;
}

.icon-btn:disabled {
	opacity: 0.35;
	cursor: default;
}

.icon-btn-sm {
	width: 28px;
	height: 28px;
}

/* a flat button inside a card or window (a row of a menu, a list's entry): no face of its own until hovered */
.flat {
	display: flex;
	align-items: center;
	gap: 10px;
	width: 100%;
	min-height: 36px;
	padding: 6px 10px;
	border: 0;
	border-radius: var(--radius-sm);
	background: none;
	color: var(--text);
	text-align: left;
	text-decoration: none;
	cursor: pointer;
	transition: background-color var(--dur-quick), color var(--dur-quick);
}

.flat:hover {
	background: var(--surface-2);
	color: var(--text-strong);
}

.flat.is-current {
	background: var(--surface-2);
	color: var(--text-strong);
	font-weight: 600;
}

.flat svg {
	flex: none;
	color: var(--muted);
}

.flat.is-current svg {
	color: var(--text-strong);
}

.flat > span:not([class]),
.flat > .flat-label {
	flex: 1;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* ---- cards ---- */

.card {
	padding: 16px 18px;
	border: 1px solid var(--border);
	border-top-color: var(--edge-top);
	border-bottom-color: var(--edge-bottom);
	border-radius: var(--radius-card);
	background: var(--surface);
	box-shadow: var(--edge-light), var(--elev-1);
}

.card + .card {
	margin-top: 12px;
}

.card-title {
	margin: 0 0 4px;
	font-size: calc(15px * var(--ui-scale));
	font-weight: 600;
	color: var(--text-strong);
}

.muted {
	color: var(--muted);
}

/* ---- text field (.input: the programs' name for it) ---- */

.field,
.input {
	width: 100%;
	min-height: 36px;
	padding: 7px 12px;
	border: 1px solid var(--border);
	border-top-color: var(--edge-bottom);
	border-radius: var(--radius);
	background: var(--surface);
	box-shadow: var(--sunken);
	outline: none;
	transition: border-color var(--dur-quick);
}

.field::placeholder,
.input::placeholder {
	color: var(--faint);
}

.field:focus,
.input:focus {
	border-color: var(--border-strong);
	box-shadow: var(--sunken), 0 0 0 3px var(--focus-ring);
}

.field:disabled,
.input:disabled {
	opacity: 0.5;
	cursor: default;
}

/* a form: its fields one under another; what went wrong in red */
.form {
	display: flex;
	flex-direction: column;
	gap: 16px;
}

.form > .btn-primary {
	margin-top: 8px;
}

.form-error {
	margin: 0;
	color: var(--danger);
}

/* a choice from a list: a field with a drawn arrow (the system's own looks different everywhere) */
select.field,
select.input {
	padding-right: 32px;
	border-radius: 999px;
	appearance: none;
	-webkit-appearance: none;
	background:
		linear-gradient(45deg, transparent 50%, var(--muted) 50%) calc(100% - 17px) 50% / 5px 5px no-repeat,
		linear-gradient(-45deg, transparent 50%, var(--muted) 50%) calc(100% - 12px) 50% / 5px 5px no-repeat,
		var(--surface);
	cursor: pointer;
}

/* ---- the user's picture, or the name's first letter ---- */

.avatar {
	display: inline-flex;
	flex: none;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	color: #fff;
	font-weight: 600;
	line-height: 1;
	user-select: none;
}

.avatar-img {
	object-fit: cover;
	background: var(--surface-2);
}
