/**
 * FLUXX — reset and element defaults.
 *
 * Reads tokens.css. Contains no raw values that belong in the token layer.
 */

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

/*
 * `hidden` must actually hide.
 *
 * The browser's own rule is `[hidden] { display: none }` at user-agent
 * specificity, so ANY class rule that sets `display` beats it. Every drawer and
 * overlay in this theme sets `display: flex`, which silently made `hidden`
 * meaningless: the panels stayed in the layout, invisible but on top of the
 * page, swallowing clicks meant for the content underneath.
 *
 * Found by the interaction checks — pages looked perfect in a screenshot while
 * the size chips and the bag button could not be clicked at all.
 */
[hidden] {
	display: none !important;
}

html {
	-webkit-text-size-adjust: 100%;
	-moz-text-size-adjust: 100%;
	text-size-adjust: 100%;
	scroll-behavior: smooth;
}

body {
	margin: 0;
	font-family: var(--fx-font);
	font-size: 14px;
	line-height: 1.5;
	font-weight: var(--fx-weight-regular);
	letter-spacing: var(--fx-tracking-body);
	color: var(--fx-text);
	background: var(--fx-paper);
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	/* Stop iOS inflating text in landscape, which breaks the dense grid. */
	text-rendering: optimizeLegibility;
	overflow-x: hidden;
}

/*
 * The app shell.
 *
 * On mobile the whole site is a 480px column centred on a grey ground. This is
 * the reference's defining structural trait — it reads as a native app rather
 * than a web page — and everything else in the layout assumes it.
 */
.fx-shell {
	max-width: var(--fx-shell-mobile);
	margin-inline: auto;
	background: var(--fx-paper);
	min-height: 100vh;
	min-height: 100svh;
}

@media (max-width: 767px) {
	body {
		background: var(--fx-surface-muted);
	}
}

@media (min-width: 768px) {
	.fx-shell {
		max-width: none;
	}
}

/* --------------------------------------------------------------- headings */
/*
 * Headings carry no size of their own. Size comes from a type role applied with
 * fluxx_text(), so an h2 in a banner and an h2 in a footer can differ without
 * either fighting a default. This only strips the browser's own styling.
 */
h1, h2, h3, h4, h5, h6 {
	margin: 0;
	font-weight: inherit;
	font-size: inherit;
	line-height: inherit;
}

p {
	margin: 0 0 1em;
}

p:last-child {
	margin-bottom: 0;
}

/* ------------------------------------------------------------------ links */
a {
	color: inherit;
	text-decoration: none;
	transition: color var(--fx-dur) var(--fx-ease);
}

a:hover {
	color: var(--fx-accent);
}

/* Body copy links stay underlined; navigation and cards do not. */
.fx-prose a {
	text-decoration: underline;
	text-underline-offset: 0.2em;
}

/* ------------------------------------------------------------------ media */
img,
picture,
video,
canvas,
svg {
	display: block;
	max-width: 100%;
}

img {
	height: auto;
	border-style: none;
}

.fx-icon {
	flex-shrink: 0;
	color: currentColor;
}

/* ------------------------------------------------------------------ forms */
button,
input,
select,
textarea {
	font: inherit;
	letter-spacing: inherit;
	color: inherit;
	margin: 0;
}

button {
	background: none;
	border: 0;
	padding: 0;
	cursor: pointer;
	text-align: inherit;
}

textarea {
	resize: none;
}

/* Stop iOS zooming the page when a field is focused. Anything under 16px does. */
@media (max-width: 767px) {
	input,
	select,
	textarea {
		font-size: 16px;
	}
}

/* ------------------------------------------------------------------ focus */
/*
 * DEPARTURE, and an important one.
 *
 * The reference applies `focus:outline-none` site-wide with almost no visible
 * replacement, which makes it unusable by keyboard — a WCAG 2.4.7 failure. We
 * take the visual language and put the ring back. `:focus-visible` means mouse
 * users never see it, so nothing about the look changes.
 */
:focus-visible {
	outline: 2px solid var(--fx-ink);
	outline-offset: 2px;
}

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

/* On dark surfaces the ink ring disappears, so invert it. */
.fx-on-dark :focus-visible {
	outline-color: var(--fx-paper);
}

/* ------------------------------------------------------------------- a11y */
.screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

.screen-reader-text:focus {
	position: static !important;
	width: auto;
	height: auto;
	clip-path: none;
	margin: 0;
	padding: 12px 16px;
	background: var(--fx-ink);
	color: var(--fx-text-on-dark);
}

.fx-skip-link {
	position: absolute;
	top: -100px;
	left: 0;
	z-index: var(--fx-z-toast);
	padding: 12px 16px;
	background: var(--fx-ink);
	color: var(--fx-text-on-dark);
}

.fx-skip-link:focus {
	top: 0;
	color: var(--fx-text-on-dark);
}

/* Hide the scrollbar on the horizontal chip rails, which scroll by design. */
.fx-no-scrollbar {
	-ms-overflow-style: none;
	scrollbar-width: none;
}

.fx-no-scrollbar::-webkit-scrollbar {
	display: none;
}

/* ----------------------------------------------------------------- motion */
/*
 * The reference honours none of this. Every animation in the theme is written
 * so that switching it off leaves the design intact rather than broken.
 */
@media (prefers-reduced-motion: reduce) {
	html {
		scroll-behavior: auto;
	}

	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
		scroll-behavior: auto !important;
	}
}
