/*
 * Front page (front-page.php, template-parts/home/*) – Sturlaugur Marás brand 2026.
 * Hero and „Nýtt" follow the client's mockup (docs/design/brand-2026/skissa-forsida.webp). Below them – less is more,
 * sept. 2026 – four calm sections: the merger line, four category tiles, the booth wall and one line about
 * reikningsviðskipti. Tokens only (tokens.css); turquoise is decoration or text on navy, never text on white.
 */

.ms-home-section {
	padding-block: clamp(28px, 3vw, 40px);
}

/* ================================================================== Hero */
/*
 * Mockup: the navy header band continues around a photo inset in the page frame (gutter on both sides), rounded
 * top corners, the photo's bottom edge flush with the end of the band. ≈ 320 px high at 1440 px; taller relative
 * to the width on small screens so the headline fits. White bold headline top left, no buttons.
 */
.ms-hero {
	background: var(--ms-color-brand);
	color: var(--ms-color-on-brand);
}

.ms-hero__frame {
	position: relative;
	isolation: isolate;
	display: flex;
	align-items: flex-start;
	height: clamp(260px, 22.2vw, 320px);
	overflow: hidden;
	border-radius: var(--ms-radius-lg) var(--ms-radius-lg) var(--ms-radius-xs) var(--ms-radius-xs);
	background: var(--ms-color-brand-strong);
}

.ms-hero__image {
	position: absolute;
	inset: 0;
	z-index: -2;
	width: 100%;
	height: 100%;
	object-fit: cover;
	object-position: 50% 50%;
}

/* Legibility: a soft navy wash behind the headline only (top left), the rest of the photo untouched. */
.ms-hero--has-media .ms-hero__frame::before {
	content: "";
	position: absolute;
	inset: 0;
	z-index: -1;
	background: linear-gradient(100deg, color-mix(in srgb, var(--ms-color-brand) 50%, transparent) 0%, color-mix(in srgb, var(--ms-color-brand) 22%, transparent) 36%, transparent 60%);
	pointer-events: none;
}

.ms-hero__content {
	min-width: 0;
	max-width: min(100%, 60rem);
	padding: clamp(20px, 2.9vw, 44px) clamp(20px, 2.6vw, 40px);
}

.ms-hero__title {
	margin: 0;
	color: var(--ms-color-on-brand);
	font-size: clamp(1.75rem, 1rem + 2vw, 2.75rem);
	font-weight: var(--ms-fw-bold);
	line-height: 1.12;
	letter-spacing: -.015em;
	text-wrap: balance;
}

.ms-hero__intro {
	max-width: 46ch;
	margin: .6em 0 0;
	color: var(--ms-color-on-brand);
	font-size: clamp(1rem, .92rem + .35vw, 1.25rem);
	font-weight: var(--ms-fw-medium);
	line-height: 1.45;
}

@media (max-width: 1023px) {
	.ms-hero__frame {
		height: auto;
		aspect-ratio: 12 / 5;
	}

	/* The headline spans most of the width here: the wash runs along the top instead. */
	.ms-hero--has-media .ms-hero__frame::before {
		background: linear-gradient(180deg, color-mix(in srgb, var(--ms-color-brand) 55%, transparent) 0%, color-mix(in srgb, var(--ms-color-brand) 22%, transparent) 42%, transparent 68%);
	}
}

@media (max-width: 599px) {
	.ms-hero__frame {
		min-height: 220px;
		aspect-ratio: 3 / 2;
	}

	.ms-hero__image {
		/* Split sea | grass (brand guide „Til sjávar og sveita"): keep the dividing line centred. */
		object-position: 50% 50%;
	}
}

/* ================================================================== Nýtt */
.ms-home-new {
	padding-block: clamp(22px, 2.2vw, 32px) clamp(32px, 3.2vw, 52px);
}

.ms-home-new__head {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 8px 16px;
	margin-bottom: clamp(10px, 1vw, 14px);
}

.ms-home-new__title {
	margin: 0;
	color: var(--ms-color-ink);
	font-size: clamp(1.125rem, .95rem + .3vw, 1.25rem);
	font-weight: var(--ms-fw-black);
	line-height: 1.2;
	letter-spacing: .02em;
	text-transform: uppercase;
}

.ms-home-new__actions {
	display: flex;
	align-items: center;
	gap: 16px;
	margin-left: auto;
}

.ms-home-new__all {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	min-height: 44px;
	color: var(--ms-color-link);
	font-size: .9375rem;
	font-weight: var(--ms-fw-bold);
	text-decoration: none;
}

.ms-home-new__all:hover {
	color: var(--ms-color-link);
	text-decoration: underline;
	text-underline-offset: .2em;
}

.ms-home-new__all .ms-icon {
	transition: transform 200ms var(--ms-ease);
}

.ms-home-new__all:hover .ms-icon {
	transform: translateX(3px);
}

.ms-home-new__all:focus-visible {
	outline: 2px solid var(--ms-color-focus);
	outline-offset: 2px;
	border-radius: var(--ms-radius-xs);
}

.ms-home-new__intro {
	max-width: 60ch;
	margin: 0 0 14px;
	color: var(--ms-color-text-muted);
}

/* The mockup's card: photo, name, price, stepper + „Í körfu" – no part number or stock line on the front page,
   and a lower photo frame (the mockup's „Nýtt" photos are about 16:9). */
.ms-home-new .ms-product-card__meta {
	display: none;
}

.ms-home-new .ms-product-card__media {
	aspect-ratio: 16 / 9;
}

/* Rail arrows (shown only while the row can scroll). */
.ms-rail-nav {
	display: flex;
	gap: 8px;
}

.ms-carousel:not(.is-enhanced) .ms-rail-nav,
.ms-carousel.is-enhanced:not(.is-scrollable) .ms-rail-nav {
	display: none;
}

.ms-rail-nav__btn {
	display: grid;
	place-items: center;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 1px solid var(--ms-color-rule-strong);
	border-radius: var(--ms-radius-md);
	background: var(--ms-color-surface);
	color: var(--ms-color-ink);
	cursor: pointer;
	transition: background-color var(--ms-t-fast) var(--ms-ease), border-color var(--ms-t-fast) var(--ms-ease), color var(--ms-t-fast) var(--ms-ease);
}

.ms-rail-nav__btn:hover:not(:disabled) {
	border-color: var(--ms-color-ink);
	background: var(--ms-color-ink);
	color: var(--ms-color-on-brand);
}

.ms-rail-nav__btn:focus-visible {
	outline: 2px solid var(--ms-color-focus);
	outline-offset: 2px;
}

.ms-rail-nav__btn:disabled {
	opacity: .4;
	cursor: default;
}

.ms-carousel__viewport {
	--ms-carousel-per-view: 4;
	margin: -12px;
	padding: 12px;
	overflow-x: auto;
	overflow-y: hidden;
	overscroll-behavior-x: contain;
	scroll-snap-type: x mandatory;
	scroll-padding-inline: 12px;
	scrollbar-width: none;
}

.ms-carousel__viewport::-webkit-scrollbar {
	display: none;
}

.ms-carousel__viewport:focus-visible {
	outline: 2px solid var(--ms-color-focus);
	outline-offset: -4px;
}

.ms-carousel__track.products {
	display: grid;
	grid-auto-flow: column;
	grid-auto-columns: calc((100% - (var(--ms-carousel-per-view) - 1) * var(--ms-grid-gap)) / var(--ms-carousel-per-view));
	gap: var(--ms-grid-gap);
	margin: 0;
	padding: 0;
	list-style: none;
}

.ms-carousel__track.products::before,
.ms-carousel__track.products::after {
	content: none;
	display: none;
}

.ms-carousel__track.products > li {
	float: none;
	width: auto;
	min-width: 0;
	margin: 0;
	scroll-snap-align: start;
}

/* Five in a row (mockup); narrower screens scroll sideways with snap points. */
.ms-carousel__viewport.ms-home-new__viewport {
	--ms-carousel-per-view: 5;
}

@media (max-width: 1199px) {
	.ms-carousel__viewport.ms-home-new__viewport {
		--ms-carousel-per-view: 3.4;
	}
}

@media (max-width: 767px) {
	.ms-carousel__viewport.ms-home-new__viewport {
		--ms-carousel-per-view: 1.6;
	}

	.ms-home-new .ms-rail-nav {
		display: none;
	}
}

/* ================================================ One-line sections */
/* The merger line and the reikningsviðskipti line: one sentence and a link on white, between two thin rules. */
.ms-home-story {
	padding-block: 0;
}

.ms-home-line {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: var(--ms-space-3) var(--ms-space-6);
	padding-block: var(--ms-space-5);
	border-block: 1px solid var(--ms-color-border);
}

.ms-home-line__text {
	flex: 1 1 32rem;
	max-width: 68ch;
	margin: 0;
	color: var(--ms-color-text);
	font-size: var(--ms-fs-lead);
	line-height: var(--ms-lh-body);
	text-wrap: pretty;
}

.ms-home-line__text .ms-accent-text {
	color: var(--ms-color-ink);
	font-weight: var(--ms-fw-bold);
	white-space: nowrap;
}

.ms-home-line__actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--ms-space-3) var(--ms-space-5);
}

.ms-home-line__link {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	color: var(--ms-color-link);
	font-weight: var(--ms-fw-bold);
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 4px;
}

.ms-home-line__link:hover {
	color: var(--ms-color-ink);
	text-decoration-thickness: 2px;
}

.ms-home-line__link:focus-visible {
	outline: 2px solid var(--ms-color-focus);
	outline-offset: 2px;
	border-radius: var(--ms-radius-xs);
}

/* ========================================================= Vöruflokkar */
.ms-home-heading {
	margin: 0 0 var(--ms-space-5);
	color: var(--ms-color-ink);
	font-size: var(--ms-fs-h2);
	font-weight: var(--ms-fw-bold);
	line-height: var(--ms-lh-heading);
	letter-spacing: var(--ms-track-h2);
}

.ms-home-tiles {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: var(--ms-space-6) var(--ms-space-5);
	margin: 0;
	padding: 0;
	list-style: none;
}

.ms-home-tile {
	position: relative;
	min-width: 0;
	border-radius: var(--ms-radius-lg);
}

.ms-home-tile__media {
	display: block;
	aspect-ratio: 4 / 3;
	overflow: hidden;
	border-radius: var(--ms-radius-lg);
	background: var(--ms-color-surface-alt);
}

.ms-home-tile__image {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.ms-home-tile__name {
	margin: var(--ms-space-4) 0 0;
	color: var(--ms-color-ink);
	font-size: var(--ms-fs-h3);
	font-weight: var(--ms-fw-bold);
	line-height: var(--ms-lh-heading);
	letter-spacing: var(--ms-track-h3);
}

/* The name link covers the whole tile; focus is drawn around the tile. */
.ms-home-tile__link {
	color: inherit;
	text-decoration: none;
}

.ms-home-tile__link::after {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: inherit;
}

.ms-home-tile:hover .ms-home-tile__link {
	text-decoration: underline;
	text-decoration-thickness: 2px;
	text-underline-offset: 4px;
}

.ms-home-tile__link:focus-visible {
	outline: none;
}

.ms-home-tile:has(.ms-home-tile__link:focus-visible) {
	outline: 2px solid var(--ms-color-focus);
	outline-offset: 4px;
}

.ms-home-tile__count {
	margin: var(--ms-space-1) 0 0;
	color: var(--ms-color-text-muted);
	font-size: var(--ms-fs-sm);
}

/* Phones and small tablets: 2 × 2. */
@media (max-width: 767px) {
	.ms-home-tiles {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: var(--ms-space-5) var(--ms-space-3);
	}

	.ms-home-tile__name {
		margin-top: var(--ms-space-3);
		font-size: var(--ms-fs-body);
	}
}

/* ============================================================ Brand wall */
/* The booth wall „Þjónustan í höfn" (Brandenburg 2026): navy band, heading left, the four main dealerships larger
   over a turquoise rule (decoration), then the rest of the wall in four columns. White vector logos sized as on the
   booth: --w = logo width / booth column width (201 pt), --k scales them on narrow screens. */
.ms-booth {
	--k: 1;
	display: grid;
	grid-template-columns: minmax(0, 9fr) minmax(0, 16fr);
	gap: 32px clamp(32px, 4vw, 72px);
	padding: clamp(40px, 5vw, 80px) clamp(24px, 5vw, 80px);
	border-radius: var(--ms-radius-xl);
	background: var(--ms-color-brand);
	color: var(--ms-color-on-brand);
}

.ms-booth__head {
	align-self: start;
	min-width: 0;
}

.ms-booth__title {
	max-width: 10ch;
	margin: 0;
	color: var(--ms-color-on-brand);
	font-size: var(--ms-fs-display);
	font-weight: var(--ms-fw-bold);
	line-height: var(--ms-lh-tight);
	letter-spacing: var(--ms-track-display);
	text-wrap: balance;
}

.ms-booth__intro {
	max-width: 34ch;
	margin: 20px 0 0;
	color: var(--ms-color-on-brand-muted);
	font-size: var(--ms-fs-sm);
	line-height: var(--ms-lh-body);
}

.ms-booth__link {
	margin-top: 28px;
}

.ms-booth__wall {
	min-width: 0;
}

.ms-logo-wall {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: clamp(6px, .8vw, 12px) 0;
	margin: 0;
	padding: 0;
	list-style: none;
}

.ms-logo-wall--lead {
	position: relative;
	margin-bottom: clamp(16px, 2vw, 28px);
	padding-bottom: clamp(12px, 1.6vw, 22px);
}

/* The turquoise rule runs from the first logo to the last, as on the booth. */
.ms-logo-wall--lead::after {
	content: "";
	position: absolute;
	right: 5.5%;
	bottom: 0;
	left: 7%;
	height: 3px;
	border-radius: 2px;
	background: var(--ms-color-accent-on-brand);
}

.ms-logo-wall__cell {
	display: flex;
	min-width: 0;
}

.ms-logo-wall__item {
	display: grid;
	place-items: center;
	width: 100%;
	aspect-ratio: 201 / 60;
	border-radius: var(--ms-radius-md);
	color: inherit;
	text-decoration: none;
	transition: background-color var(--ms-t-base) var(--ms-ease);
}

.ms-logo-wall--lead .ms-logo-wall__item {
	aspect-ratio: 201 / 72;
}

.ms-logo-wall__logo {
	display: block;
	width: calc(var(--w, .5) * var(--k) * 100%);
	max-width: 92%;
	height: auto;
}

.ms-logo-wall a.ms-logo-wall__item:hover {
	background: var(--ms-color-brand-pattern);
}

.ms-logo-wall a.ms-logo-wall__item:focus-visible {
	outline: 2px solid var(--ms-color-focus-on-brand);
	outline-offset: 2px;
}

/* Below desktop the heading goes above the wall, which then has the full width. */
@media (max-width: 1199px) {
	.ms-booth {
		grid-template-columns: minmax(0, 1fr);
	}

	.ms-booth__head {
		display: grid;
		grid-template-columns: minmax(0, 1fr) auto;
		column-gap: 32px;
		align-items: end;
	}

	.ms-booth__head > :not(.ms-booth__link) {
		grid-column: 1;
	}

	.ms-booth__title {
		max-width: none;
	}

	.ms-booth__link {
		grid-row: 1 / span 3;
		grid-column: 2;
		margin-top: 0;
	}
}

/* Phones: main dealerships 2 × 2, the rest in three columns; logos scaled up. */
@media (max-width: 767px) {
	.ms-booth {
		--k: 1.65;
	}

	.ms-booth__head {
		display: block;
	}

	.ms-booth__link {
		margin-top: 20px;
	}

	.ms-logo-wall {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}

	.ms-logo-wall__item {
		aspect-ratio: 201 / 90;
	}

	.ms-logo-wall--lead {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		row-gap: 4px;
	}

	.ms-logo-wall--lead .ms-logo-wall__item {
		aspect-ratio: 201 / 88;
	}

	.ms-logo-wall--lead .ms-logo-wall__logo {
		width: calc(var(--w, .5) * 110%);
	}

	.ms-logo-wall--lead::after {
		right: 0;
		left: 0;
	}
}

@media (prefers-reduced-motion: reduce) {
	.ms-logo-wall__item {
		transition: none;
	}
}

/* ============================================================ Reikningsviðskipti */
.ms-home-b2b {
	padding-block: 0 var(--ms-space-5);
}
