/* Shared components for fridell.xyz subpages (Astrid, Kåre, ...).
   Each subpage's own style.css is linked AFTER this file and must define
   these custom properties in :root:

     --accent-900  --accent-700  --accent-100  --accent-50   palette accents
     --ink         main text          --ink-soft     softer text (.lead, dd)
     --caption-ink figure captions    --tag-ink      .tag text
     --muted       muted text         --line         borders
     --bg          page background    --card-shadow  card box shadow colour
     --amber --red --good   badge colours
     --focus       focus outline colour
*/

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
	margin: 0;
	background: var(--bg);
	color: var(--ink);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
	line-height: 1.6;
}
a { color: var(--accent-700); }
a:hover { color: var(--accent-900); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
img { max-width: 100%; }

.site-header {
	position: sticky;
	top: 0;
	z-index: 10;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 0.4rem 1rem;
	padding: 0.7rem 1rem;
	background: rgba(255, 255, 255, 0.96);
	border-bottom: 1px solid var(--line);
	backdrop-filter: blur(6px);
}
.brand {
	font-weight: 800;
	color: var(--accent-900);
	text-decoration: none;
	font-size: 1.02rem;
}
.site-header nav { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.site-header nav a {
	color: var(--accent-700);
	text-decoration: none;
	padding: 0.3rem 0.7rem;
	border-radius: 999px;
	font-size: 0.9rem;
	font-weight: 600;
}
.site-header nav a:hover { background: var(--accent-50); }
.site-header nav a.active { background: var(--accent-100); color: var(--accent-900); }

main {
	max-width: 900px;
	margin: 0 auto;
	padding: 1.4rem 1rem 3rem;
}
h1 {
	font-size: clamp(1.7rem, 5vw, 2.5rem);
	line-height: 1.2;
	color: var(--accent-900);
	margin: 0.4rem 0 0.8rem;
}
h2 {
	font-size: clamp(1.25rem, 3.5vw, 1.6rem);
	color: var(--accent-900);
	margin: 2.4rem 0 0.7rem;
}
h3 {
	font-size: 1.08rem;
	color: var(--accent-700);
	margin: 0.9rem 0 0.35rem;
}
p { margin: 0.7rem 0; }
ul, ol { padding-left: 1.3rem; }
li { margin: 0.35rem 0; }
.lead { font-size: 1.13rem; color: var(--ink-soft); }
.small { font-size: 0.85rem; color: var(--muted); }

.card-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
	gap: 1rem;
	margin: 1.2rem 0;
}
.card {
	background: #fff;
	border: 1px solid var(--line);
	border-radius: 14px;
	overflow: hidden;
	box-shadow: 0 1px 2px var(--card-shadow);
	padding-bottom: 0.9rem;
}
.card img {
	display: block;
	width: 100%;
	height: 180px;
	object-fit: cover;
	background: var(--accent-50);
}
.card h3, .card p { margin-left: 1rem; margin-right: 1rem; }
.card h3 { margin-top: 0.8rem; }
.card p { margin-top: 0.4rem; margin-bottom: 0; font-size: 0.95rem; }

.tag {
	display: inline-block;
	font-size: 0.7rem;
	font-weight: 600;
	color: var(--tag-ink);
	background: var(--accent-50);
	border: 1px solid var(--line);
	border-radius: 999px;
	padding: 0.1rem 0.5rem;
	margin: 0.15rem 0.15rem 0 0;
	white-space: nowrap;
}
.badge {
	display: inline-block;
	font-size: 0.76rem;
	font-weight: 700;
	color: #fff;
	border-radius: 999px;
	padding: 0.18rem 0.6rem;
	white-space: nowrap;
}
.badge-good { background: var(--good); }
.badge-mid { background: var(--amber); }
.badge-bad { background: var(--red); }
.badge-neutral { background: #4b5563; }

.callout {
	background: var(--accent-50);
	border-left: 4px solid var(--accent-700);
	border-radius: 8px;
	padding: 0.85rem 1rem;
	margin: 1.3rem 0;
}
.callout p:first-child { margin-top: 0; }
.callout p:last-child { margin-bottom: 0; }
.callout.key { background: var(--accent-100); border-left-color: var(--accent-900); }

.glossary { margin: 1rem 0; }
.glossary dt { font-weight: 700; color: var(--accent-900); margin-top: 0.8rem; }
.glossary dd { margin: 0.1rem 0 0; color: var(--ink-soft); }

.steps { margin: 1rem 0; padding-left: 1.4rem; }
.step { margin: 0.8rem 0; }

table.data {
	width: 100%;
	border-collapse: collapse;
	margin: 1rem 0;
	font-size: 0.9rem;
	background: #fff;
}
table.data caption {
	text-align: left;
	font-size: 0.82rem;
	color: var(--muted);
	margin-bottom: 0.5rem;
}
table.data th, table.data td {
	padding: 0.5rem 0.6rem;
	border-bottom: 1px solid var(--line);
	text-align: left;
	vertical-align: top;
}
table.data th { background: var(--accent-50); color: var(--accent-900); font-weight: 700; }
table.data tr:last-child td { border-bottom: none; }
table.data td .badge { font-size: 0.7rem; }

.figure { margin: 1.6rem 0; }
.figure img {
	display: block;
	max-width: 100%;
	height: auto;
	margin: 0 auto;
	background: #fff;
	border: 1px solid var(--line);
	border-radius: 10px;
}
.figure figcaption {
	font-size: 0.86rem;
	color: var(--caption-ink);
	margin-top: 0.55rem;
	line-height: 1.55;
}

.grid-2 { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 680px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
}

.site-footer {
	max-width: 900px;
	margin: 2.5rem auto 0;
	padding: 1.2rem 1rem 2.5rem;
	border-top: 1px solid var(--line);
}

@media (max-width: 640px) {
	table.data { display: block; overflow-x: auto; white-space: nowrap; }
	table.data caption { white-space: normal; }
	.card img { height: 160px; }
	.site-header { position: static; padding: 0.55rem 0.8rem; }
	.site-header nav {
		flex-wrap: nowrap;
		width: 100%;
		overflow-x: auto;
		-webkit-overflow-scrolling: touch;
		scrollbar-width: none;
	}
	.site-header nav::-webkit-scrollbar { display: none; }
	.site-header nav a { flex: none; }
	.site-header nav::after {
		content: "\203A";
		position: sticky;
		right: 0;
		display: flex;
		align-items: center;
		padding: 0 0.45rem 0 1.1rem;
		font-size: 1.15rem;
		font-weight: 800;
		line-height: 1;
		color: var(--accent-700);
		background: linear-gradient(to right, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.96) 45%);
		pointer-events: none;
	}
	.site-header nav::before {
		content: "\2039";
		position: sticky;
		left: 0;
		display: none;
		align-items: center;
		padding: 0 1.1rem 0 0.45rem;
		font-size: 1.15rem;
		font-weight: 800;
		line-height: 1;
		color: var(--accent-700);
		background: linear-gradient(to left, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.96) 45%);
		pointer-events: none;
	}
	@supports (animation-timeline: scroll()) {
		.site-header nav::after {
			animation: nav-hint-out 1s linear both;
			animation-timeline: scroll(nearest inline);
			animation-range: 85% 100%;
		}
		.site-header nav::before {
			display: flex;
			animation: nav-hint-in 1s linear both;
			animation-timeline: scroll(nearest inline);
			animation-range: 0% 15%;
		}
	}
}

@keyframes nav-hint-out {
	from { opacity: 1; }
	to { opacity: 0; }
}
@keyframes nav-hint-in {
	from { opacity: 0; }
	to { opacity: 1; }
}
