/* What a bare element looks like anywhere on the site.
 *
 * Bare element selectors only — no classes. index.test.js enforces that,
 * because the value of this file is that it holds no opinions about context:
 * an <input> looks right whether it is in a form, a card, or a page nobody has
 * written yet.
 *
 * That is also why the sizes here are on bare tags rather than scoped to
 * `.section p` the way they used to be. A bare `p` rule is specificity (0,0,1),
 * so any class overrides it without ceremony. Scoped to `.section p` it was
 * (0,1,1) and outranked `.error` at (0,1,0) — which is why every error box on
 * the site once had alarm-coloured chrome around plain grey body text, and why
 * there was a `:not(.error, .notice)` bolted onto the rule to work around it.
 * There is nothing to work around now.
 *
 * Every value comes from tokens.css. No raw colours here.
 */

html,
body {
	margin: 0;
}

body {
	display: flex;
	flex-direction: column;
	align-items: center;
	min-height: 100vh;
	font-family: var(--font-sans);
	font-size: var(--text-base);
	color: var(--fg-1);
	background: var(--surface-page);
	background-attachment: fixed;
	font-synthesis: none;
	text-rendering: optimizeLegibility;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	-webkit-text-size-adjust: 100%;
}

::selection {
	background: var(--accent);
	color: var(--void);
}

/* One visible focus treatment for the whole site. Text fields opt out below —
   they are the one control that matches :focus-visible on a plain mouse click,
   because the browser assumes anything you can type into wants a visible cue,
   and the result was a pink box drawn around every field you clicked into. */
:focus-visible {
	outline: var(--focus-ring);
	outline-offset: var(--focus-offset);
}

/* Nothing on this site animates anything but a control acknowledging a hover
   or a focus, so there is no motion worth preserving for someone who has asked
   for less of it. Kill all of it in one place rather than per rule. */
@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		transition-duration: 0.01ms !important;
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		scroll-behavior: auto !important;
	}
}

/* --- Text ---------------------------------------------------------------
 *
 * Margins are zeroed throughout: every container on this site is a flex column
 * with its own `gap`, so a margin can only ever fight it. A prose block that
 * genuinely wants margins should set them on itself.
 */

h1,
h2,
h3,
p,
ul,
ol,
dl,
dd,
pre,
figure {
	margin: 0;
}

h1 {
	font-size: var(--text-h1);
	font-weight: var(--weight-bold);
	letter-spacing: var(--tracking-tight);
	line-height: var(--leading-tight);
	color: var(--fg-1);
}

h2 {
	font-size: var(--text-h2);
	font-weight: var(--weight-bold);
	letter-spacing: var(--tracking-snug);
	color: var(--fg-1);
}

h3 {
	font-size: var(--text-base);
	font-weight: var(--weight-medium);
	color: var(--fg-1);
}

p,
li {
	font-size: var(--text-md);
	line-height: var(--leading-normal);
	color: var(--fg-3);
}

ul,
ol {
	padding-left: var(--space-5);
	display: flex;
	flex-direction: column;
	gap: var(--space-2);
}

strong {
	font-weight: var(--weight-medium);
	color: var(--fg-2);
}

/* Links take the accent. They were on the positive green, which now means
   "good state" — a link is neither positive nor negative, and reusing the
   success colour for navigation made both mean less.

   Deliberately not `display: inline-flex`, which the shadow-DOM original used
   so an icon could sit beside the label: an inline-flex link cannot break
   across lines, so "No account? Create one." went ragged the moment the
   sentence wrapped. An icon link can opt into flex on its own class. */
a {
	color: var(--accent);
	text-decoration: underline;
	cursor: pointer;
	transition: color var(--motion);
}

a:hover {
	color: var(--fg-1);
}

/* Was `outline: 0` with only a colour shift, which is not enough on its own. */
a:focus-visible {
	color: var(--fg-1);
}

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

form {
	display: flex;
	flex-direction: column;
	gap: var(--space-5);
	margin: 0;
}

/* Bare buttons are not styled — every button on this site carries `.btn`, and
   a half-styled fallback would only make a missing class harder to notice.
   Inheriting the font is the exception: browsers refuse to, and the result is
   a control in the system UI font next to text that is not. */
button {
	font-family: inherit;
	font-size: inherit;
}

input,
textarea,
select {
	width: 100%;
	max-width: 100%;
	box-sizing: border-box;
	padding: var(--space-4);
	font-size: var(--text-base);
	font-family: inherit;
	background-color: var(--surface-inset);
	color: var(--fg-1);
	border: 0;
	border-bottom: 1px solid var(--fg-3);
	outline: 0;
	transition: background-color var(--motion), border-color var(--motion);
	/* The dark fill is ours; without this the browser paints its own light
	   autofill and dropdown chrome over it. */
	color-scheme: light;
}

textarea {
	min-height: 200px;
}

::placeholder {
	color: var(--fg-3);
}

input:hover:not(:focus):not([readonly]),
textarea:hover:not(:focus):not([readonly]),
select:hover:not(:focus):not([readonly]) {
	border-color: var(--fg-1);
}

input[readonly],
textarea[readonly],
select[readonly] {
	background-color: var(--surface-raised);
}

/* The opt-out from the blanket focus ring at the top of this file. A field
   states focus with its own underline, doubled to 2px by an inset shadow so
   the cue is not colour alone and does not reflow the layout. */
input:focus:not([readonly]),
textarea:focus:not([readonly]),
select:focus:not([readonly]) {
	border-color: var(--accent);
	outline: 0;
	box-shadow: inset 0 -1px 0 var(--accent);
}

input[type="checkbox"],
input[type="radio"] {
	width: 20px;
	height: 20px;
	min-width: auto;
	padding: 0;
}

/* These have no underline to state focus with, and their box is the browser's
   to draw, so they keep the ring the rule above turns off. */
input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible {
	outline: var(--focus-ring);
	outline-offset: var(--focus-offset);
	box-shadow: none;
}
