/*
 * base.css — typography, forms, buttons, focus. Names no colour of its own; every value comes from
 * tokens.css.
 */

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

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

body {
	margin: 0;
	background: var(--srt-bg);
	color: var(--srt-text);
	font-family: var(--srt-font);
	font-size: var(--srt-font-size);
	line-height: var(--srt-line-height);
	/* NF-07 235: the document never scrolls sideways. */
	overflow-x: hidden;
}

h1,
h2,
h3,
h4 {
	margin: 0 0 var(--srt-space-sm);
	line-height: 1.25;
	font-weight: 700;
}

h1 {
	font-size: clamp(1.5rem, 1.2rem + 1.4vw, 2.1rem);
}

h2 {
	font-size: clamp(1.2rem, 1.05rem + 0.7vw, 1.5rem);
}

h3 {
	font-size: 1.05rem;
}

p {
	margin: 0 0 var(--srt-space-md);
}

a {
	color: var(--srt-link);
	text-decoration-thickness: 1px;
	text-underline-offset: 2px;
}

a:hover {
	color: var(--srt-link-hover);
}

/*
 * ⚠️ NF-06 232. Visible, and visible against every surface — which is why it is an outline with an
 * offset rather than a border or a background change.
 */
:focus-visible {
	outline: var(--srt-focus-width) solid var(--srt-focus);
	outline-offset: var(--srt-focus-offset);
	border-radius: var(--srt-radius-sm);
}

img,
svg,
video {
	max-width: 100%;
	height: auto;
}

/* NF-07 235: a wide table or code block scrolls inside itself, never taking the page with it. */
pre,
table {
	max-width: 100%;
	overflow-x: auto;
}

.srt-screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* The skip link is the first thing in the tab order and must become visible when focused. */
.srt-skip-link {
	position: absolute;
	left: -9999px;
	z-index: 100;
	padding: var(--srt-space-xs) var(--srt-space-md);
	background: var(--srt-accent);
	color: var(--srt-on-accent);
	font-weight: 600;
	border-radius: 0 0 var(--srt-radius) 0;
}

.srt-skip-link:focus {
	left: 0;
	top: 0;
}

/* ------------------------------------------------------------------------------- Buttons. */

.srt-button,
.srt-button:hover {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: var(--srt-space-xs);
	/* 44px minimum hit target, everywhere, on every input type (NF-06). */
	min-height: 44px;
	padding: var(--srt-space-xs) var(--srt-space-md);
	border: 1px solid transparent;
	border-radius: var(--srt-radius);
	font: inherit;
	font-weight: 600;
	text-decoration: none;
	cursor: pointer;
}

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

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

.srt-button--ghost {
	background: transparent;
	color: var(--srt-text);
	border-color: var(--srt-border-strong);
}

.srt-button--ghost:hover {
	background: var(--srt-surface-hover);
	color: var(--srt-text);
}

.srt-button--quiet {
	background: transparent;
	color: var(--srt-text-muted);
	min-height: 44px;
	padding: var(--srt-space-xs) var(--srt-space-sm);
}

.srt-button--quiet:hover {
	color: var(--srt-text);
}

/* -------------------------------------------------------------------------------- Forms. */

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

input[type="text"],
input[type="search"],
input[type="email"],
input[type="password"],
input[type="url"],
select,
textarea {
	width: 100%;
	min-height: 44px;
	padding: var(--srt-space-xs) var(--srt-space-sm);
	background: var(--srt-bg-elevated);
	color: var(--srt-text);
	border: 1px solid var(--srt-border-strong);
	border-radius: var(--srt-radius);
}

textarea {
	min-height: 10rem;
	line-height: 1.55;
	resize: vertical;
}

/*
 * ⚠️ A file input needs its own rule. It is not covered by the selector list above, and left alone
 * it lays out at its intrinsic width — which is wider than a 390px viewport once the button and the
 * "no file selected" text are counted. That pushes the whole document sideways by a few pixels: the
 * NF-07 235 failure, arriving from the one control nobody thinks to style.
 */
input[type="file"] {
	display: block;
	width: 100%;
	max-width: 100%;
	padding: var(--srt-space-xs);
	background: var(--srt-bg-elevated);
	border: 1px dashed var(--srt-border-strong);
	border-radius: var(--srt-radius);
}

::placeholder {
	color: var(--srt-text-faint);
	opacity: 1;
}

label {
	display: inline-block;
	margin-bottom: var(--srt-space-3xs);
	font-weight: 600;
}

/* NF-06 233: an error is associated with its field and is not colour alone. */
.srt-field-error {
	display: block;
	margin-top: var(--srt-space-3xs);
	color: var(--srt-danger);
	font-weight: 600;
}

.srt-field-error::before {
	content: "⚠ ";
}

[aria-invalid="true"] {
	border-color: var(--srt-danger);
	border-width: 2px;
}

/* ------------------------------------------------------------------------------ Notices. */

.srt-notice {
	padding: var(--srt-space-sm) var(--srt-space-md);
	border: 1px solid var(--srt-border);
	border-left-width: 4px;
	border-radius: var(--srt-radius);
	background: var(--srt-surface);
	margin-bottom: var(--srt-space-lg);
}

.srt-notice--error {
	border-left-color: var(--srt-danger);
}

.srt-notice--success {
	border-left-color: var(--srt-success);
}

.srt-notice--info {
	border-left-color: var(--srt-info);
}

/*
 * Respect a reader who has asked for less motion. NF-06 does not require this; it costs three lines
 * and prevents a class of complaint that is impossible to reproduce afterwards.
 */
@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 0.001ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.001ms !important;
		scroll-behavior: auto !important;
	}
}
