/* Base: reset, typography, layout primitives. Logical properties throughout for RTL. */

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

html {
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
	scroll-behavior: smooth;
	scroll-padding-top: calc(var(--ml-header-h) + 56px);
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
	margin: 0;
	min-height: 100vh;
	background: var(--ml-bg);
	color: var(--ml-text);
	font-family: var(--ml-font);
	font-size: var(--ml-fs-md);
	line-height: var(--ml-lh);
	font-feature-settings: "ss01";
	-webkit-font-smoothing: antialiased;
	overflow-x: hidden;
	/* Room for the fixed bottom nav on mobile. */
	padding-block-end: calc(var(--ml-bottom-nav-h) + env(safe-area-inset-bottom));
}
@media (min-width: 1024px) { body { padding-block-end: 0; } }

img, svg, video { display: block; max-width: 100%; height: auto; }
img { border-style: none; }

h1, h2, h3, h4 { margin: 0; line-height: var(--ml-lh-tight); font-weight: 800; letter-spacing: -.01em; }
h1 { font-size: var(--ml-fs-2xl); }
h2 { font-size: var(--ml-fs-xl); }
h3 { font-size: var(--ml-fs-lg); }
p { margin: 0 0 var(--ml-s4); }

a { color: inherit; text-decoration: none; }
a:hover { color: var(--ml-accent); }

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

:focus-visible {
	outline: 2px solid var(--ml-accent);
	outline-offset: 2px;
	border-radius: 6px;
}

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

/* Layout */
.ml-container {
	width: 100%;
	max-width: var(--ml-container);
	margin-inline: auto;
	padding-inline: var(--ml-gutter);
}
.ml-main { display: block; outline: none; }
.ml-main > .ml-container, .ml-home { padding-block: var(--ml-s4) var(--ml-s12); }

/* Accessibility helpers */
.ml-sr, .screen-reader-text {
	position: absolute !important;
	width: 1px !important; height: 1px !important; min-width: 0 !important; /* beats form rules such as select { inline-size: 100% } (variation selects are hidden this way) */
	padding: 0; margin: -1px;
	overflow: hidden; clip: rect(0 0 0 0);
	white-space: nowrap; border: 0;
}
.ml-skip {
	position: absolute;
	inset-inline-start: var(--ml-s4);
	inset-block-start: -100px;
	z-index: 1000;
	padding: var(--ml-s3) var(--ml-s4);
	background: var(--ml-accent);
	color: var(--ml-on-accent);
	border-radius: var(--ml-r-md);
	font-weight: 700;
}
.ml-skip:focus { inset-block-start: var(--ml-s3); }

/* Horizontal scrollers (chips, rails, thumbs) */
.ml-scroller {
	display: flex;
	gap: var(--ml-s2);
	overflow-x: auto;
	overscroll-behavior-x: contain;
	scroll-snap-type: x proximity;
	scrollbar-width: none;
	margin: 0;
	padding: 0;
	list-style: none;
}
.ml-scroller::-webkit-scrollbar { display: none; }
.ml-scroller > * { scroll-snap-align: start; flex: 0 0 auto; }

/* Prose (descriptions, pages, guides) */
.ml-prose { color: var(--ml-text-2); font-size: var(--ml-fs-md); line-height: 2; }
.ml-prose > * + * { margin-block-start: var(--ml-s4); }
.ml-prose h2, .ml-prose h3 { color: var(--ml-text); margin-block-start: var(--ml-s8); }
.ml-prose h2 { font-size: var(--ml-fs-xl); }
.ml-prose h3 { font-size: var(--ml-fs-lg); }
.ml-prose a { color: var(--ml-accent); text-decoration: underline; text-underline-offset: 3px; }
.ml-prose ul, .ml-prose ol { padding-inline-start: var(--ml-s6); }
.ml-prose li + li { margin-block-start: var(--ml-s2); }
.ml-prose img { border-radius: var(--ml-r-lg); }
.ml-prose table { width: 100%; border-collapse: collapse; font-size: var(--ml-fs-sm); display: block; overflow-x: auto; }
.ml-prose th, .ml-prose td { padding: var(--ml-s3); border-block-end: 1px solid var(--ml-border); text-align: start; }
.ml-prose blockquote { margin: 0; padding: var(--ml-s4); border-inline-start: 3px solid var(--ml-accent); background: var(--ml-surface-1); border-radius: var(--ml-r-md); }

@media (min-width: 768px) {
	h1 { font-size: var(--ml-fs-3xl); }
	h2 { font-size: var(--ml-fs-2xl); }
}
