/*
    autismesiden.no – PAKS CMS v2 theme.
    A modern, responsive take on the original design (teal and green on a dark header),
    built with CSS grid: two columns (section menu + content) on wide screens,
    one column on phones, with the content first.
*/

:root {
	--brand: #1d6e68;
	--brand-dark: #134a46;
	--brand-darker: #0d3532;
	--accent: #7accc8;
	--accent-tint: #e8f6f5;
	--green: #b7d885;
	--green-tint: #f2f8e8;
	--text: #26302f;
	--text-muted: #5f6b6a;
	--border: #dde6e4;
	--bg: #f3f7f6;
	--surface: #ffffff;
	--link: #1a6a64;
	--link-hover: #0d3f3b;
	--radius: 12px;
	--radius-small: 8px;
	--shadow: 0 1px 2px rgb(13 53 50 / 6%), 0 6px 20px rgb(13 53 50 / 7%);
	--max-width: 1180px;
	--side-width: 270px;
	--gutter: clamp(16px, 4vw, 32px);
	--font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ---- Base ---- */

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

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

body {
	margin: 0;
	min-height: 100vh;
	display: flex;
	flex-direction: column;
	background: var(--bg);
	color: var(--text);
	font-family: var(--font);
	font-size: 1.0625rem;
	line-height: 1.65;
}

img,
video,
embed,
object,
iframe {
	max-width: 100%;
}

img {
	height: auto;
	border: 0;
}

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

a:hover {
	color: var(--link-hover);
	text-decoration-thickness: 2px;
}

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

h1,
h2,
h3,
h4 {
	color: var(--brand-darker);
	line-height: 1.25;
	font-weight: 650;
	margin: 1.6em 0 .5em;
}

h1 {
	font-size: clamp(1.65rem, 1.2rem + 1.6vw, 2.25rem);
	margin-top: 0;
	letter-spacing: -.01em;
}

h2 {
	font-size: 1.4rem;
}

h3 {
	font-size: 1.15rem;
}

p,
ul,
ol,
blockquote {
	margin: 0 0 1em;
}

.container {
	width: 100%;
	max-width: var(--max-width);
	margin: 0 auto;
	padding: 0 var(--gutter);
}

.skip-link {
	position: absolute;
	left: 1rem;
	top: -100px;
	z-index: 10;
	padding: .6rem 1rem;
	background: var(--surface);
	color: var(--brand-dark);
	border-radius: var(--radius-small);
	box-shadow: var(--shadow);
	font-weight: 600;
}

.skip-link:focus {
	top: 1rem;
}

/* ---- Header ---- */

.site-header {
	/* The original autismesiden.no header: black with a subtle texture. */
	background: #000 url(/images/img02.gif) repeat-x;
	color: #fff;
	box-shadow: 0 2px 12px rgb(0 0 0 / 25%);
}

.header-inner {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem 2rem;
	min-height: 84px;
	padding-top: .75rem;
	padding-bottom: .75rem;
}

.site-logo {
	display: inline-flex;
	flex-shrink: 0;
	border-radius: 6px;
}

.site-logo img {
	display: block;
	width: 282px;
}

.site-nav ul {
	display: flex;
	flex-wrap: wrap;
	gap: .25rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.site-nav a {
	display: block;
	padding: .45rem .9rem;
	border-radius: 999px;
	color: #fff;
	font-weight: 600;
	font-size: .98rem;
	text-decoration: none;
	transition: background-color .15s ease, color .15s ease;
}

.site-nav a:hover {
	background: rgb(255 255 255 / 14%);
	color: #fff;
}

.site-nav a.active {
	background: var(--green);
	color: var(--brand-darker);
}

/* ---- Page layout ---- */

.site-main {
	flex: 1;
	padding-top: clamp(1.25rem, 3vw, 2.25rem);
	padding-bottom: clamp(2rem, 5vw, 3.5rem);
}

/* The content comes first in the markup (and on phones); the menu is to its left on wider screens. */
.page-layout {
	display: grid;
	grid-template-columns: var(--side-width) minmax(0, 1fr);
	grid-template-areas: "side main";
	gap: clamp(1.25rem, 3vw, 2rem);
	align-items: start;
}

.page-layout.no-side {
	grid-template-columns: minmax(0, 1fr);
	grid-template-areas: "main";
}

.page-main {
	grid-area: main;
	min-width: 0;
}

.page-side {
	grid-area: side;
	min-width: 0;
}

.card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
}

.page-content {
	padding: clamp(1.25rem, 4vw, 2.5rem);
}

.page-header {
	margin-bottom: 1.5rem;
	padding-bottom: 1rem;
	border-bottom: 3px solid var(--green);
}

.page-header h1 {
	margin-bottom: .25rem;
}

.page-meta {
	margin: 0;
	color: var(--text-muted);
	font-size: .9rem;
}

.preview-banner {
	margin: 0 0 1rem;
	padding: .7rem 1rem;
	background: #fff4c2;
	border: 1px solid #e0c24a;
	border-radius: var(--radius-small);
	color: #5a4a00;
	font-weight: 600;
}

/* ---- Front page ---- */

.hero {
	margin-bottom: clamp(1.25rem, 3vw, 2rem);
	padding: clamp(1.5rem, 5vw, 2.75rem) clamp(1.25rem, 5vw, 2.75rem);
	background:
		radial-gradient(circle at 100% 0%, rgb(183 216 133 / 55%) 0, transparent 45%),
		linear-gradient(135deg, var(--accent-tint) 0%, var(--green-tint) 100%);
	border: 1px solid var(--border);
	border-radius: var(--radius);
}

.hero h1 {
	margin: 0 0 .35rem;
}

.hero p {
	margin: 0;
	max-width: 46rem;
	color: var(--text-muted);
	font-size: 1.1rem;
}

/* ---- Page content written in the editor (much of it pasted from Word) ---- */

.story {
	overflow-wrap: break-word;
}

.story > :last-child {
	margin-bottom: 0;
}

/* Pasted text carries its own fonts, sizes and line heights; let the site's typography win. */
.story [style],
.story font {
	font-family: inherit !important;
	line-height: inherit !important;
}

.story p[style],
.story div[style],
.story span[style],
.story font {
	font-size: inherit !important;
}

/* Some pages carry Word's own <style> block (p.MsoNormal { font: 11pt Calibri }). */
.story [class^="Mso"] {
	font-family: inherit !important;
	font-size: inherit !important;
	line-height: inherit !important;
}

/* Fixed widths from the old 800px layout must not overflow a phone screen. */
.story * {
	max-width: 100%;
}

.story table {
	display: block;
	overflow-x: auto;
	border-collapse: collapse;
	margin: 0 0 1em;
}

.story td,
.story th {
	padding: .35rem .6rem;
	vertical-align: top;
}

.story img[align="left"],
.story img.left {
	float: left;
	margin: .3rem 1.25rem 1rem 0;
}

.story img[align="right"],
.story img.right {
	float: right;
	margin: .3rem 0 1rem 1.25rem;
}

.story img {
	border-radius: var(--radius-small);
}

.story::after {
	content: "";
	display: table;
	clear: both;
}

.story blockquote {
	margin-left: 0;
	padding: .75rem 1.25rem;
	border-left: 4px solid var(--accent);
	background: var(--accent-tint);
	border-radius: 0 var(--radius-small) var(--radius-small) 0;
}

.story ul,
.story ol {
	padding-left: 1.4rem;
}

.story li {
	margin-bottom: .3rem;
}

.ingress {
	font-size: 1.12em;
	color: var(--text-muted);
}

/* ---- Section menu (left) ---- */

.section-menu {
	padding: 1.25rem 1rem 1rem;
	position: sticky;
	top: 1rem;
}

.section-menu h2 {
	margin: 0 .5rem .75rem;
	padding-bottom: .5rem;
	border-bottom: 3px solid var(--green);
	font-size: 1.15rem;
}

.section-menu ul {
	margin: 0;
	padding: 0;
	list-style: none;
}

.section-menu > ul > li + li {
	margin-top: 2px;
}

.section-menu a {
	display: block;
	padding: .45rem .6rem;
	border-radius: var(--radius-small);
	color: var(--text);
	text-decoration: none;
	line-height: 1.35;
}

.section-menu a:hover {
	background: var(--accent-tint);
	color: var(--brand-darker);
}

.section-menu .section-link {
	font-weight: 600;
	font-size: .98rem;
}

.section-menu li.open > .section-link {
	background: var(--accent-tint);
	color: var(--brand-darker);
	box-shadow: inset 3px 0 0 var(--brand);
}

.section-menu .sub {
	margin: .25rem 0 .5rem .6rem;
	padding-left: .6rem;
	border-left: 2px solid var(--accent);
}

.section-menu .sub a {
	font-size: .93rem;
	padding: .3rem .55rem;
	color: var(--text-muted);
}

.section-menu a[aria-current="page"] {
	color: var(--brand-darker);
	font-weight: 700;
	background: var(--green-tint);
}

/* ---- Search ---- */

.search-form {
	display: flex;
	flex-wrap: wrap;
	gap: .5rem;
	margin-bottom: 1.5rem;
}

.search-form input[type="search"] {
	flex: 1 1 16rem;
	min-width: 0;
	padding: .7rem .95rem;
	border: 1px solid var(--border);
	border-radius: var(--radius-small);
	background: var(--surface);
	color: var(--text);
	font: inherit;
}

.search-form input[type="search"]:focus {
	border-color: var(--brand);
	outline: 3px solid rgb(122 204 200 / 45%);
	outline-offset: 0;
}

.button {
	padding: .7rem 1.4rem;
	border: 0;
	border-radius: var(--radius-small);
	background: var(--brand);
	color: #fff;
	font: inherit;
	font-weight: 600;
	cursor: pointer;
}

.button:hover {
	background: var(--brand-dark);
}

.search-results {
	margin: 0;
	padding: 0;
	list-style: none;
}

.search-results li {
	padding: .75rem 0;
	border-top: 1px solid var(--border);
}

.search-results a {
	font-weight: 600;
}

.search-results .page-meta {
	display: block;
}

.search-count {
	color: var(--text-muted);
}

/* ---- Footer ---- */

.site-footer {
	background: var(--brand-darker);
	color: rgb(255 255 255 / 75%);
	font-size: .88rem;
}

.footer-inner {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	gap: .5rem 2rem;
	padding-top: 1.5rem;
	padding-bottom: 1.5rem;
}

.site-footer p {
	margin: 0;
}

.site-footer a {
	color: #fff;
}

/* ---- Smaller screens ---- */

@media (max-width: 900px) {
	.header-inner {
		flex-direction: column;
		align-items: flex-start;
	}

	.site-nav {
		width: 100%;
	}

	.page-layout {
		grid-template-columns: minmax(0, 1fr);
		grid-template-areas: "main" "side";
	}

	/* Below the content on phones and tablets, so it no longer needs to follow the page. */
	.section-menu {
		position: static;
	}
}

@media (max-width: 560px) {
	body {
		font-size: 1rem;
	}

	.site-logo img {
		width: 220px;
	}

	.site-nav ul {
		gap: .2rem;
	}

	.site-nav a {
		padding: .4rem .7rem;
		font-size: .93rem;
	}

	/* Floated images go on their own line instead of squeezing the text (also when floated inline). */
	.story img[align="left"],
	.story img.left,
	.story img[align="right"],
	.story img.right,
	.story img[style*="float"] {
		float: none !important;
		display: block;
		margin: 0 0 1rem !important;
	}

	.footer-inner {
		flex-direction: column;
	}
}

@media (prefers-reduced-motion: reduce) {
	* {
		transition: none !important;
	}
}

@media print {
	.site-header,
	.site-footer,
	.page-side,
	.skip-link {
		display: none;
	}

	body {
		background: #fff;
	}

	.card {
		border: 0;
		box-shadow: none;
	}

	.page-layout {
		display: block;
	}
}
