/* ==========================================================================
   Reset, type scale, layout shell, header, footer, buttons and cards.
   Section-specific rules live in sections.css.
   ========================================================================== */

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

html {
	-webkit-text-size-adjust: 100%;
	/* Only 400, 500, 700 and one italic ship. Asking for anything else would get
	   a browser-fabricated bold or slant; this makes the gap visible instead. */
	font-synthesis: none;
	scrollbar-width: thin;
	scrollbar-color: color-mix(in srgb, var(--fg) 28%, transparent) transparent;
}

::-webkit-scrollbar { width: 10px; height: 10px; background: transparent; }
::-webkit-scrollbar-track { background: transparent; }

::-webkit-scrollbar-thumb {
	background: color-mix(in srgb, var(--fg) 28%, transparent);
	border-radius: 999px;
	border: 3px solid transparent;
	background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover { background-color: color-mix(in srgb, var(--fg) 45%, transparent); }
::-webkit-scrollbar-corner { background: transparent; }

::selection { background: color-mix(in srgb, var(--accent) 18%, var(--bg)); color: var(--fg); }

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

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

h1, h2, h3, h4,
p, figure, blockquote, ul, ol { margin: 0; }

ul, ol { padding: 0; list-style: none; }

a { color: inherit; }

button { font: inherit; color: inherit; }

/* Icelandic compounds run long - vefþjónustusamningur, Framfarafélag - so headings
   wrap on whole words and never hyphenate mid-compound. */
h1, h2, h3, .hero__title, .masthead__title, .stats__heading, .post-card__title {
	overflow-wrap: break-word;
	hyphens: manual;
	text-wrap: balance;
}

p, li { text-wrap: pretty; }

/* ---------- Layout ---------- */

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

.section { padding-block: var(--section-y); }

.site-main > .section:first-child { padding-top: clamp(3rem, 7.5vw, 7rem); }

/* ---------- Type ---------- */

.h2,
.stats__heading,
.posts__heading,
.newsletter__heading,
.archive__title {
	font-size: var(--step-h2);
	font-weight: 500;
	line-height: 1.12;
	letter-spacing: -0.02em;
}

/* Reading columns are capped by character count, not by a pixel width that
   happens to look right at one font size. */
.prose { max-width: 65ch; }

.prose > * + * { margin-top: 1.1em; }

.prose a {
	text-decoration: underline;
	text-underline-offset: 0.18em;
	text-decoration-thickness: 1px;
	text-decoration-color: var(--rule-strong);
	/* Icelandic runs thick with descenders - g, j, p, y, ý, þ - and an underline
	   drawn straight through them is the first thing that reads as sloppy. */
	text-decoration-skip-ink: auto;
	transition: text-decoration-color 150ms ease;
}

.prose a:hover { text-decoration-color: currentColor; }

.prose ul { padding-left: 1.15rem; list-style: disc; }
.prose ol { padding-left: 1.3rem; list-style: decimal; }
.prose li + li { margin-top: 0.35rem; }

.prose blockquote {
	margin-block: 1.6em;
	padding-inline-start: clamp(1rem, 3vw, 1.75rem);
	border-inline-start: 2px solid var(--accent);
	color: var(--fg);
	font-size: var(--step-lede);
	line-height: 1.4;
}

.prose blockquote p + p { margin-top: 0.8em; }

.prose--lede { font-size: var(--step-lede); line-height: 1.45; }

.prose img { border-radius: var(--radius-media); }

/* ---------- Links and buttons ---------- */

.arrow-link {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	margin-top: 1.4rem;
	font-weight: 500;
	text-decoration: none;
	border-bottom: 1px solid var(--rule-strong);
	padding-bottom: 2px;
	transition: border-color 150ms ease;
}

.arrow-link:empty { display: none; }
.arrow-link:hover { border-color: currentColor; }

.arrow-link .icon {
	flex: none;
	transition: transform 150ms ease;
}

.arrow-link:hover .icon { transform: translateX(3px); }

.btn {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.75rem 1.35rem;
	border: 1px solid var(--fg);
	border-radius: var(--radius-media);
	background: var(--fg);
	color: var(--bg);
	font-weight: 500;
	text-decoration: none;
	cursor: pointer;
	transition: background 150ms ease, border-color 150ms ease, transform 100ms ease;
}

.btn:hover { background: var(--accent); border-color: var(--accent); }

/* Without a pressed state a button feels unresponsive on click. */
.btn:active { transform: scale(0.98); }

.icon { display: inline-block; vertical-align: middle; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Accessibility ---------- */

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

.skip-link:focus {
	position: fixed;
	top: 0.5rem; left: 0.5rem;
	z-index: 100;
	width: auto; height: auto;
	padding: 0.65rem 1rem;
	clip-path: none;
	background: var(--fg);
	color: var(--bg);
	border-radius: var(--radius-media);
}

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

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

.site-header {
	position: sticky;
	top: 0;
	z-index: 20;
	background: var(--bg);
	border-bottom: 1px solid var(--rule);
}

.site-header__inner {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--gap);
	min-height: var(--header-h);
}

/* The whole lockup is the brand green, mark and name alike - the mark takes its
   fill from currentColor, so colouring the link colours both. */
.site-header__brand {
	text-decoration: none;
	color: var(--accent);
}

.brand { display: inline-flex; align-items: center; gap: 0.7rem; }

.brand__mark { width: clamp(44px, 4vw, 56px); height: auto; }

.brand__name {
	/* The lower bound keeps "Framfarafélag Vestfjarða" on one line at 390px,
	   where the mark and the menu button leave it about 235px to work with.
	   Measured at 205.6px in DM Sans Bold 18px, so there is roughly 30px of
	   headroom; the previous name set 14.6px narrower, which is the margin
	   this rename spent. Re-measure before lengthening the name again. */
	font-size: clamp(1.125rem, 2vw, 1.875rem);
	font-weight: 700;
	letter-spacing: -0.02em;
	line-height: 1.1;
}

.site-nav__list { display: flex; align-items: center; gap: clamp(1rem, 2.5vw, 2rem); }

.site-nav__item a {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	color: var(--accent);
	font-size: var(--step-small);
	font-weight: 500;
	text-decoration: none;
	border-bottom: 1px solid transparent;
	transition: border-color 150ms ease;
}

.site-nav__item a:hover,
.site-nav__item.is-current a { border-color: currentColor; }

.site-header__toggle {
	display: none;
	/* 44px square: the floor for a touch target, and this is the only control
	   in the header on a phone. */
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 1px solid var(--rule);
	border-radius: var(--radius-media);
	background: none;
	cursor: pointer;
	transition: border-color 150ms ease;
}

.site-header__toggle:hover { border-color: var(--rule-strong); }
.site-header__toggle:active { transform: scale(0.96); }

/* ---------- Mobile drawer ---------- */

.drawer {
	position: fixed;
	inset: var(--header-h) 0 auto;
	z-index: 19;
	padding: 1.25rem var(--gutter) 2rem;
	background: var(--bg);
	border-bottom: 1px solid var(--rule);
}

.drawer[hidden] { display: none; }
.drawer__nav li + li { margin-top: 0.25rem; }

.drawer__nav a {
	display: block;
	padding: 0.65rem 0;
	border-bottom: 1px solid var(--rule);
	font-size: 1.125rem;
	font-weight: 500;
	text-decoration: none;
}

@media (max-width: 860px) {
	.site-nav { display: none; }
	.site-header__toggle { display: inline-flex; }
}

/* ---------- Post grid ---------- */

.post-grid {
	display: grid;
	gap: var(--gap);
	grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr));
}

.post-grid--2 { --cols: 2; }
.post-grid--3 { --cols: 3; }
.post-grid--4 { --cols: 4; }

@media (max-width: 1000px) { .post-grid { --cols: 2; } }
@media (max-width: 600px)  { .post-grid { --cols: 1; } }

/* The card is the positioning context for the title link's stretched hit area. */
.post-card { position: relative; }

.post-card__media {
	margin-bottom: 1rem;
	border-radius: var(--radius-media);
	overflow: hidden;
	background: var(--surface);
}

.post-card__media img,
.post-card__placeholder {
	display: block;
	width: 100%;
	aspect-ratio: 3 / 2;
	object-fit: cover;
	transition: transform 400ms ease;
}

.post-card:hover .post-card__media img { transform: scale(1.03); }

.post-card__date {
	color: var(--muted);
	font-size: var(--step-small);
}

.post-card__title {
	margin-top: 0.35rem;
	font-size: var(--step-h3);
	font-weight: 500;
	line-height: 1.25;
	letter-spacing: -0.01em;
}

.post-card__link {
	text-decoration: none;
	/* The accessible name stays the headline alone; the ::after below is what
	   makes the rest of the card clickable. */
}

.post-card__link::after {
	content: "";
	position: absolute;
	inset: 0;
}

.post-card__link:hover { text-decoration: underline; text-underline-offset: 0.16em; }

/* The stretched link swallows the focus ring, so draw it on the card instead. */
.post-card:focus-within { outline: 2px solid var(--accent); outline-offset: 6px; }
.post-card__link:focus-visible { outline: none; }

/* Only rendered when the caller asks for one - see card-post.php. */
.post-card__excerpt {
	margin-top: 0.6rem;
	color: var(--muted);
	font-size: var(--step-small);
	line-height: 1.5;
}

/* ---------- Single post ---------- */

.single-post__head { max-width: var(--wrap-narrow); padding-top: clamp(2rem, 4vw, 3.5rem); }

.single-post__meta {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	color: var(--muted);
	font-size: var(--step-small);
}

.single-post__terms a { text-decoration: none; border-bottom: 1px solid var(--rule-strong); }

.single-post__title {
	margin-top: 0.75rem;
	font-size: var(--step-h1);
	font-weight: 500;
	line-height: 1.1;
	letter-spacing: -0.02em;
}

.single-post__media { margin-block: clamp(2rem, 4vw, 3rem); }
.single-post__media img { width: 100%; border-radius: var(--radius-media); }

.single-post__body { max-width: var(--wrap-narrow); padding-bottom: var(--section-y); }

.post-nav {
	display: flex;
	flex-wrap: wrap;
	gap: var(--gap);
	justify-content: space-between;
	padding-bottom: var(--section-y);
	border-top: 1px solid var(--rule);
	padding-top: 1.75rem;
}

.post-nav__link { max-width: 32ch; text-decoration: none; }
.post-nav__link--next { margin-left: auto; text-align: right; }
.post-nav__label { display: block; color: var(--muted); font-size: var(--step-small); }
.post-nav__title { font-weight: 500; }
.post-nav__link:hover .post-nav__title { text-decoration: underline; text-underline-offset: 0.16em; }

/* ---------- Archive ---------- */

.archive__title { margin-bottom: 0.75rem; }
.archive__intro { max-width: var(--wrap-narrow); margin-bottom: var(--gap); color: var(--muted); }
.archive .post-grid { margin-top: var(--gap); }
.archive__empty { color: var(--muted); }

.wp-block-query-pagination,
.navigation.pagination { margin-top: var(--gap); }

.nav-links { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.nav-links .page-numbers {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 2.5rem;
	padding: 0.4rem 0.6rem;
	border: 1px solid var(--rule);
	border-radius: var(--radius);
	text-decoration: none;
}

.nav-links .page-numbers.current,
.nav-links .page-numbers:hover { border-color: var(--fg); }

/* ---------- Plain page ---------- */

.page-plain__title {
	margin-bottom: 1.25rem;
	font-size: var(--step-h1);
	font-weight: 500;
	line-height: 1.1;
	letter-spacing: -0.02em;
}

.page-plain .prose { max-width: var(--wrap-narrow); }

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

.site-footer {
	margin-top: auto;
	border-top: 1px solid var(--rule);
	padding-top: clamp(2.5rem, 5vw, 4rem);
}

.site-footer__inner {
	display: grid;
	gap: var(--gap);
	grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
	padding-bottom: clamp(2rem, 4vw, 3rem);
}

.site-footer__name { font-size: var(--step-h3); font-weight: 500; }

.site-footer__address {
	margin-top: 1rem;
	font-style: normal;
	color: var(--muted);
}

.site-footer__address p { margin: 0; }

.site-footer__email { margin-top: 1rem; }
.site-footer__email a { text-decoration: none; border-bottom: 1px solid var(--rule-strong); }

.site-footer__heading { font-weight: 500; }
.site-footer__column ul { margin-top: 1rem; }
.site-footer__column li + li { margin-top: 0.15rem; }

/* 44px of tappable height, without opening the visual gaps that far wide. */
.site-footer__column a,
.site-footer__email a {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
}

.site-footer__column a {
	text-decoration: none;
	color: var(--muted);
	border-bottom: 1px solid transparent;
	transition: color 0.15s ease, border-color 0.15s ease;
}

.site-footer__column a:hover { color: var(--fg); border-color: var(--rule-strong); }

.site-footer__legal {
	display: flex;
	flex-wrap: wrap;
	gap: 1rem;
	justify-content: space-between;
	padding-block: 1.25rem;
	border-top: 1px solid var(--rule);
	color: var(--muted);
	font-size: var(--step-small);
}

/* ---------- Motion ---------- */

/* Reveal: elements rise into place as they reach the viewport.
 *
 * The hidden starting state hangs off `.reveal-on`, which nothing in the markup
 * carries - a snippet in the document head puts it on <html>, and only when the
 * browser has an IntersectionObserver and the reader has not asked for less
 * motion. So with JavaScript off, on an old browser, or with motion turned down,
 * none of this exists: the page is just the page, and there is nothing hidden
 * waiting on a script that may never arrive.
 *
 * It is one mechanism for both the load and the scroll. An element already on
 * screen intersects the moment it is observed, so the masthead and the lead story
 * animate at zero without a separate code path; everything below simply reaches
 * the viewport later. */
.reveal-on [data-reveal] {
	opacity: 0;
	transform: translateY(var(--reveal-rise));
	transition:
		opacity var(--reveal-time) var(--reveal-ease) var(--reveal-delay, 0ms),
		transform var(--reveal-time) var(--reveal-ease) var(--reveal-delay, 0ms);
}

/* `rise` moves without fading, for the image that is the largest thing painted
   above the fold. A browser does not count an element at zero opacity as having
   been painted, so fading the lead photograph in would push Largest Contentful
   Paint back by the delay plus the duration - most of a second added to the
   number, for an effect nobody asked for. Moving it costs nothing: the paint is
   recorded where the pixels land. */
.reveal-on [data-reveal="rise"] { opacity: 1; }

.reveal-on [data-reveal][data-revealed] {
	opacity: 1;
	transform: none;
}

/* The stagger is positional rather than authored: an element's delay comes from
   where it sits among its siblings, so a row of three cards and a list of six
   headlines both cascade without either template having to say so.
   Capped at the sixth - past that the last item is waiting on the animation
   rather than on the page. */
.reveal-on [data-reveal]:nth-child(2) { --reveal-delay: calc(1 * var(--reveal-step)); }
.reveal-on [data-reveal]:nth-child(3) { --reveal-delay: calc(2 * var(--reveal-step)); }
.reveal-on [data-reveal]:nth-child(4) { --reveal-delay: calc(3 * var(--reveal-step)); }
.reveal-on [data-reveal]:nth-child(5) { --reveal-delay: calc(4 * var(--reveal-step)); }
.reveal-on [data-reveal]:nth-child(n + 6) { --reveal-delay: calc(5 * var(--reveal-step)); }

/* Print has no viewport to scroll and no script running, so nothing would ever
   be revealed and the page would come out of the printer with holes in it. */
@media print {
	.reveal-on [data-reveal] {
		opacity: 1;
		transform: none;
	}
}

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

	/* The head snippet already declines to switch reveals on when motion is
	   turned down, so this only matters for the reader who changes the setting
	   with the page open: without it, whatever had not yet been revealed would
	   stay hidden until a reload. */
	.reveal-on [data-reveal] {
		opacity: 1 !important;
		transform: none !important;
	}
}
