/*
 * The page and the few controls every screen shares: buttons, fields, checkboxes, tabs, notices and badges. Every value
 * is a token (app_tokens.css): nothing hardcoded.
 *
 * Inter, and why its italic is loaded too: app_tokens.css.
 */

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

body {
	margin: 0;
	background: var(--background-page);
	color: var(--text-primary);
	font-family: var(--font-family-sans);
	font-size: var(--font-size-base);
	line-height: var(--font-line-height-base);
	-webkit-font-smoothing: antialiased;
}

/*
 * Headings are set tight and balanced everywhere: names and indicator labels are short phrases, and short phrases at a
 * large size need the tracking pulled in. The gap between the page title and everything under it is what gives a
 * screen a shape, so the sizes are far apart.
 */
h1,
h2,
h3 {
	margin: 0;
	font-weight: var(--font-weight-semibold);
	letter-spacing: -0.018em;
	text-wrap: balance;
}

h1 {
	font-size: var(--font-size-4xl);
	line-height: var(--font-line-height-4xl);
}

h2 {
	font-size: var(--font-size-xl);
	line-height: var(--font-line-height-xl);
}

h3 {
	font-size: var(--font-size-lg);
	line-height: var(--font-line-height-lg);
}

p {
	text-wrap: pretty;
}

a {
	color: var(--text-link);
}

/* Hidden means hidden, whatever display a component's own CSS gives it: a folded row's card, a tab's other panels. */
[hidden] {
	display: none !important;
}

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

.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

/* ── buttons ─────────────────────────────────────────────────────────────────── */
/* A button or a link that does a button's job. `button--default` is the quiet one beside a main action; `button--subtle`
   the quietest, for a move back. */
.button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: var(--space-2);
	min-height: 36px;
	padding: 0 var(--space-4);
	border: var(--border-1) solid var(--turquoise-600);
	border-radius: var(--radius-md);
	background: var(--turquoise-600);
	color: var(--base-white);
	font: inherit;
	font-size: var(--font-size-sm);
	font-weight: var(--font-weight-semibold);
	line-height: 1;
	text-decoration: none;
	white-space: nowrap;
	cursor: pointer;
	transition: background-color 120ms ease-out, border-color 120ms ease-out;
}

.button:hover {
	background: var(--turquoise-700);
	border-color: var(--turquoise-700);
}

.button--default {
	background: var(--background-surface);
	border-color: var(--border-default);
	color: var(--text-primary);
}

.button--default:hover {
	background: var(--app-ground);
	border-color: var(--border-default);
}

.button--subtle {
	background: transparent;
	border-color: transparent;
	color: var(--text-link);
}

.button--subtle:hover {
	background: var(--background-accent-subtle);
	border-color: transparent;
}

.button--compact {
	min-height: 28px;
	padding: 0 var(--space-3);
	border-radius: var(--radius-sm);
}

.button--full {
	width: 100%;
}

.button:disabled,
.button[aria-disabled='true'] {
	cursor: not-allowed;
	opacity: 0.55;
}

/* Turbo marks a form's submit while it is sent: the button says it is busy and can't be pressed twice. */
.button[aria-busy='true'] {
	cursor: progress;
	opacity: 0.75;
}

@media (prefers-reduced-motion: reduce) {
	.button {
		transition: none;
	}
}

/* ── fields ──────────────────────────────────────────────────────────────────── */
/* A label, what it is for, the control, and what is wrong with it, stacked. */
.field {
	display: flex;
	flex-direction: column;
	gap: var(--space-1);
	min-width: 0;
}

.field__label {
	font-size: var(--font-size-sm);
	font-weight: var(--font-weight-medium);
	color: var(--text-primary);
}

.field__description {
	margin: 0;
	font-size: var(--font-size-xs);
	line-height: var(--font-line-height-xs);
	color: var(--text-tertiary);
}

.field__error {
	margin: 0;
	font-size: var(--font-size-xs);
	line-height: var(--font-line-height-xs);
	color: var(--feedback-error-fg);
}

.field__input {
	width: 100%;
	min-height: 36px;
	padding: var(--space-2) var(--space-3);
	border: var(--border-1) solid var(--border-default);
	border-radius: var(--radius-md);
	background: var(--background-surface);
	color: var(--text-primary);
	font: inherit;
	/* At least 16px on a phone, or iOS zooms the page when the field is focused. */
	font-size: max(var(--font-size-sm), 16px);
}

.field__input:focus {
	border-color: var(--border-focus);
	outline: none;
	box-shadow: var(--focus-ring);
}

.field__input:disabled {
	background: var(--background-page);
	color: var(--text-secondary);
}

.field__input[aria-invalid='true'] {
	border-color: var(--feedback-error-fg);
}

/* Prose: grows with what is written (`field-sizing`), from two lines. */
textarea.field__input {
	min-height: calc(var(--font-line-height-base) * 2 + var(--space-4));
	field-sizing: content;
	resize: vertical;
	line-height: var(--font-line-height-base);
}

.fields-row {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
	gap: var(--space-4);
}

/* ── checkboxes ──────────────────────────────────────────────────────────────── */
.checkbox {
	display: inline-grid;
	grid-template-columns: auto minmax(0, 1fr);
	column-gap: var(--space-2);
	align-items: start;
	font-size: var(--font-size-sm);
	color: var(--text-primary);
	cursor: pointer;
}

.checkbox input {
	width: 18px;
	height: 18px;
	margin: 1px 0 0;
	accent-color: var(--turquoise-600);
	cursor: inherit;
}

.checkbox:has(input:disabled) {
	cursor: default;
	color: var(--text-secondary);
}

.checkbox__description {
	grid-column: 2;
	font-size: var(--font-size-xs);
	color: var(--text-tertiary);
}

/* ── tabs ────────────────────────────────────────────────────────────────────── */
/* A strip of buttons over panels (the `tabs` controller): the selected one is underlined. */
.tabs__list {
	display: flex;
	flex-wrap: wrap;
	border-bottom: var(--border-1) solid var(--app-rule);
}

.tabs__tab {
	border: 0;
	border-bottom: var(--border-2) solid transparent;
	background: transparent;
	font: inherit;
	font-size: var(--font-size-sm);
	cursor: pointer;
}

.tabs__tab[aria-selected='true'] {
	border-bottom-color: var(--turquoise-600);
}

/* ── notices ─────────────────────────────────────────────────────────────────── */
/* Something refused or wrong, in words someone can act on. */
.notice {
	padding: var(--space-3) var(--space-4);
	border: var(--border-1) solid var(--feedback-error-border);
	border-radius: var(--radius-md);
	background: var(--feedback-error-bg);
	color: var(--feedback-error-fg);
	font-size: var(--font-size-sm);
}

.notice--info {
	border-color: var(--feedback-info-border);
	background: var(--feedback-info-bg);
	color: var(--feedback-info-fg);
}

.notice__title {
	margin: 0;
	font-weight: var(--font-weight-semibold);
}

.notice__list {
	margin: var(--space-2) 0 0;
	padding-left: var(--space-5);
}

/* ── badges ──────────────────────────────────────────────────────────────────── */
/* A label, not an alarm: never in capitals. */
.badge {
	display: inline-flex;
	align-items: center;
	padding: 0 var(--space-2);
	border-radius: var(--radius-full);
	background: var(--background-accent-subtle);
	color: var(--turquoise-800);
	font-size: var(--font-size-xs);
	font-weight: var(--font-weight-semibold);
	line-height: var(--font-line-height-sm);
	white-space: nowrap;
}

.badge--warning {
	background: var(--feedback-warning-bg);
	color: var(--feedback-warning-fg);
}

.badge--muted {
	background: var(--gray-100);
	color: var(--text-secondary);
}

/* ── a score ─────────────────────────────────────────────────────────────────── */
/* The score numeral, the one shape this app repeats: a square of tabular figures in its score's colour, so a 4 is
   recognisably the same object wherever it turns up. */
.score {
	display: inline-grid;
	place-items: center;
	min-width: 26px;
	height: 26px;
	padding: 0 var(--space-1);
	border-radius: var(--radius-sm);
	background: var(--gray-50);
	color: var(--text-tertiary);
	font-size: var(--font-size-sm);
	font-weight: var(--font-weight-semibold);
	font-variant-numeric: tabular-nums;
}

.score[data-score='5'] {
	background: var(--score-5-bg);
	color: var(--score-5-fg);
}

.score[data-score='4'] {
	background: var(--score-4-bg);
	color: var(--score-4-fg);
}

.score[data-score='3'] {
	background: var(--score-3-bg);
	color: var(--score-3-fg);
}

.score[data-score='2'] {
	background: var(--score-2-bg);
	color: var(--score-2-fg);
}

.score[data-score='1'] {
	background: var(--score-1-bg);
	color: var(--score-1-fg);
}

/* ── a quote ─────────────────────────────────────────────────────────────────── */
/* Somebody speaking: who, then what they wrote, in italic (QuoteComponent). */
.quote {
	display: flex;
	flex-direction: column;
	gap: 2px;
	margin: 0;
}

.quote__author {
	font-size: var(--font-size-xs);
	font-weight: var(--font-weight-semibold);
	color: var(--text-secondary);
}

.quote__body {
	font-style: italic;
	color: var(--text-primary);
	white-space: pre-line;
}
