/* ==========================================================================
   Grasbloggen — base / reset / typography
   Ported from design/prototypes/v5/styles.css element rules.
   ========================================================================== */

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

html {
	-webkit-text-size-adjust: 100%;
	scroll-behavior: smooth;
	/* A11y fix (WCAG 2.2 SC 2.4.11 Focus Not Obscured): .site-header is fixed/sticky at --header-h (tokens.css,
	   a real token instead of a guessed ~68-70px estimate) with
	   z-index 50 over every page. Without this, jumping to any in-page
	   anchor — the skip link's #main, TOC entries, the article aside's
	   "Hoppa till I korthet"/"Hoppa till källor" links, a heading's own #id
	   via :target — lands the target flush with the viewport top, hidden
	   completely under the header. scroll-padding-top reserves that space
	   (header height + a small breathing-room buffer) for every fragment
	   jump and focus() scroll, in one place. */
	scroll-padding-top: calc(var(--header-h) + var(--sp-4) + var(--sp-2));
}

@media (prefers-reduced-motion: reduce) {
	html { scroll-behavior: auto; }
	*, *::before, *::after {
		animation-duration: 0.001ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.001ms !important;
	}
}

body {
	margin: 0;
	background: var(--color-bg);
	color: var(--color-ink);
	font-family: var(--font-sans);
	font-size: var(--step-0);
	line-height: 1.55;
	-webkit-font-smoothing: antialiased;
	text-rendering: optimizeLegibility;
}

img { max-width: 100%; display: block; height: auto; }
svg { max-width: 100%; }

a {
	color: var(--color-accent);
	text-decoration-thickness: 1px;
	text-underline-offset: 3px;
}
a:hover { color: var(--color-ink); }

h1, h2 {
	font-family: var(--font-display);
	font-optical-sizing: auto;
	font-weight: 500;
	line-height: 1.06;
	margin: 0 0 0.5em;
	color: var(--color-ink);
	letter-spacing: -0.01em;
}
h3, h4 {
	font-family: var(--font-serif);
	font-weight: 500;
	line-height: 1.2;
	margin: 0 0 0.5em;
	color: var(--color-ink);
}
/*
 * Long Swedish compound words (robotgräsklippare, jämförelsetabell,
 * specifikationsguide…) overflow or break mid-word with no visible hyphen
 * at narrow (390px) widths otherwise. `hyphens: auto` needs a language on
 * the element/ancestor to pick the right dictionary — header.php already
 * outputs `<html lang="sv-SE">` via language_attributes(), which is enough,
 * but headings also declare it explicitly so hyphenation still works if a
 * heading's markup is ever lifted out of the document (e.g. copied into an
 * SVG/og-image render or a future syndication feed).
 *
 * Visual QA confirmed `hyphens: auto` is
 * correctly configured (lang is right, the property computes to "auto")
 * but does not visually hyphenate in this project's headless-Chromium
 * screenshot tooling — a known class of headless-browser limitation
 * (missing ICU/Minikin hyphenation dictionary), flagged as
 * needing live verification in a real browser. Confirmed live: "Slinglösa robotgräsklippare" breaks to
 * a bare "robotgräsklip" / "pare" line split with no hyphen at 390px.
 * `overflow-wrap: anywhere` (up from `break-word`) is the more aggressive
 * fallback the brief asks for — it lets the layout engine consider a
 * mid-word break a valid line-break opportunity everywhere (not only as a
 * last resort), which in practice moves the break to a less awkward point
 * and keeps min-content sizing sane for headings placed in narrow flex/grid
 * contexts. Combined with the narrower h1 clamp below, this is a rendering
 * safety net for environments without hyphenation, not a replacement for
 * `hyphens: auto` (kept — real browsers with the sv dictionary still get a
 * proper hyphen).
 */
h1, h2, h3 {
	hyphens: auto;
	-webkit-hyphens: auto;
	overflow-wrap: anywhere;
	word-break: normal;
}
h1 { font-size: var(--step-5); }
/*
 * Narrower minimum for h1 specifically at phone widths: --step-5's clamp
 * minimum (2.8rem) still sizes long compound words wide enough to force a
 * mid-word break inside a ~350px content column. A smaller minimum gives
 * the (still-hyphenation-less) fallback break more characters per line to
 * work with, so the break lands in a visually calmer spot.
 */
@media (max-width: 479px) {
	h1 { font-size: clamp(2.1rem, 1.5rem + 5vw, 2.8rem); }
}
h2 { font-size: var(--step-3); }
h3 { font-size: var(--step-2); }
h4 { font-size: var(--step-1); font-family: var(--font-sans); font-weight: 600; }
p { margin: 0 0 1.1em; }

ul, ol { margin: 0 0 1.1em; padding-left: 1.3em; }

button, input, select, textarea { font-family: inherit; }

/* Visible, high-contrast focus for keyboard users everywhere (no outline
   removal anywhere else in this theme's CSS). */
:focus-visible {
	outline: 2px solid var(--color-action);
	outline-offset: 2px;
}

/* Focus ring on dark surfaces: the green action outline measures 2.8-3.1:1 on
   forest-900/950. Mint is ~8.7-9.7:1; white over the transparent hero header. */
.photo-hero :focus-visible,
.article-hero :focus-visible,
.diagnos-band :focus-visible,
.site-footer :focus-visible,
.tool-cta :focus-visible,
.grasbloggen-tool__output :focus-visible { outline-color: #9fd3b5; }
.site-header.has-hero:not(.is-solid) :focus-visible { outline-color: #fff; }

.visually-hidden {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
}

.skip-link {
	position: absolute;
	left: -999px;
	top: 0;
	background: var(--color-ink);
	color: var(--color-bg);
	padding: var(--sp-3) var(--sp-4);
	z-index: 100;
}
.skip-link:focus {
	left: var(--sp-4);
	top: var(--sp-4);
}

.kicker {
	font-family: var(--font-mono);
	font-size: var(--step--1);
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--color-accent);
	display: inline-flex;
	align-items: center;
	gap: 0.5em;
}
.kicker::before {
	content: "";
	width: 1.4em;
	height: 1px;
	background: var(--color-accent);
	display: inline-block;
}
.kicker--on-dark { color: #9fd3b5; }
.kicker--on-dark::before { background: #9fd3b5; }
/* Over a photo the mint tint measured ~2:1 against bright blades; flat dark
   bands keep the mint, photo heroes use white. */
.photo-hero .kicker--on-dark,
.article-hero .kicker--on-dark { color: #fff; }
.photo-hero .kicker--on-dark::before,
.article-hero .kicker--on-dark::before { background: #fff; }

.hairline {
	border: none;
	border-top: 1px solid var(--hairline);
	margin: var(--sp-6) 0;
}
