/*
 * Advokat Ømos – base styles for the front end and the editor.
 *
 * Colors, type sizes and spacing come from theme.json. This file holds what theme.json
 * cannot express: the dark-field tokens, the button layout and icons, and the looks of
 * the block styles registered in inc/blokkstiler.php. Each custom block has its own
 * stylesheet in the Advokat Ømos plugin.
 */

:root {
	--omos-maks: var(--wp--custom--maks, 84rem);
	--omos-innrykk: var(--wp--preset--spacing--innrykk, 1.25rem);
	--omos-radius: var(--wp--custom--radius, 3px);
	--omos-rolig: var(--wp--custom--rolig, cubic-bezier(0.22, 1, 0.36, 1));
	/* The header is 68px high until the menu becomes a row at 1024px, then 80px. */
	--omos-topphoyde: 4.25rem;

	/* Tokens that flip on dark fields. */
	--omos-dempet: var(--wp--preset--color--stein);
	--omos-aksent: var(--wp--preset--color--merke);
	--omos-linje: var(--wp--preset--color--is);
	--omos-fokus: var(--wp--preset--color--merke);
}

@media (min-width: 1024px) {
	:root {
		--omos-topphoyde: 5rem;
	}
}

/* Sizes include padding and borders, also in the custom blocks. */
*,
::before,
::after {
	box-sizing: border-box;
}

/* Header, content and footer sit directly against each other. */
body .wp-site-blocks > * {
	margin-block-start: 0;
}

body {
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

/* Dark fields: the section backgrounds Fjell and Merkeblå, and the blocks that are always dark. */
.er-mork,
.has-fjell-background-color,
.has-fjell-2-background-color,
.has-fjell-dyp-background-color,
.has-merke-background-color {
	--omos-dempet: var(--wp--preset--color--stein-lys);
	--omos-aksent: var(--wp--preset--color--merke-lys);
	--omos-linje: rgb(255 255 255 / 0.15);
	--omos-fokus: var(--wp--preset--color--merke-lys);
	color: var(--wp--preset--color--hvit);

	:where(p:not(.has-text-color)) {
		color: var(--wp--preset--color--is);
	}
}

:where(h1, h2) {
	text-wrap: balance;
}

:where(a, button, input, select, textarea, summary):focus-visible {
	outline: 2px solid var(--omos-fokus);
	outline-offset: 2px;
}

/* Text only for screen readers. */
.screen-reader-text:not(:focus) {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip-path: inset(50%);
	border: 0;
	white-space: nowrap;
}

/* Images keep their proportions when CSS sets the width; alt text is set in the sans serif. */
img {
	max-width: 100%;
	height: auto;
	font-family: var(--wp--preset--font-family--jost);
	font-size: var(--wp--preset--font-size--small);
}

/* ---------------------------------------------------------------------------
 * Buttons
 * ------------------------------------------------------------------------ */

.wp-block-button__link,
.wp-element-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.625rem;
	min-height: 3rem;
	transition: background-color var(--wp--custom--overgang, 200ms), border-color var(--wp--custom--overgang, 200ms), color var(--wp--custom--overgang, 200ms);
}

/* The icons belong to the styles «Ring» and «Melding». */
.wp-block-button:is(.is-style-ring, .is-style-melding) > .wp-block-button__link::before {
	content: "";
	flex: none;
	width: 1.25rem;
	height: 1.25rem;
	background: currentColor;
	mask: var(--omos-ikon) center / contain no-repeat;
}

.wp-block-button.is-style-ring {
	--omos-ikon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.8'%3E%3Cpath d='M6.6 3.5h-2a1.5 1.5 0 0 0-1.5 1.6C3.8 13.4 10.6 20.2 18.9 21a1.5 1.5 0 0 0 1.6-1.5v-2a1.5 1.5 0 0 0-1.1-1.4l-3-.9a1.5 1.5 0 0 0-1.5.4l-1.2 1.2a12 12 0 0 1-5.3-5.3l1.2-1.2a1.5 1.5 0 0 0 .4-1.5l-.9-3a1.5 1.5 0 0 0-1.5-1.3Z'/%3E%3C/svg%3E");
}

.wp-block-button.is-style-melding {
	--omos-ikon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.8'%3E%3Crect x='3' y='5.5' width='18' height='13' rx='1.5'/%3E%3Cpath d='m3.5 6.5 8.5 6.5 8.5-6.5'/%3E%3C/svg%3E");
}

/* Outline buttons turn white on dark fields. */
:is(.er-mork, .has-fjell-background-color, .has-fjell-2-background-color, .has-fjell-dyp-background-color, .has-merke-background-color) .wp-block-button:is(.is-style-melding, .is-style-outline) > .wp-block-button__link {
	border-color: rgb(255 255 255 / 0.45);
	background-color: transparent;
	color: var(--wp--preset--color--hvit);

	&:hover {
		border-color: var(--wp--preset--color--hvit);
		background-color: rgb(255 255 255 / 0.1);
	}
}

/* «Tekstlenke»: an underlined link with the height of a touch target. It is not a flex
   box like the other buttons, so words and marked numbers keep their spaces and one underline. */
.wp-block-button.is-style-tekstlenke > .wp-block-button__link {
	display: inline-block;
	min-height: 0;
	padding-block: calc((2.75rem - 1lh) / 2);
	border-radius: 2px;
	text-decoration: underline 2px;
	text-underline-offset: 6px;
}

:is(.er-mork, .has-fjell-background-color, .has-fjell-2-background-color, .has-fjell-dyp-background-color, .has-merke-background-color) .wp-block-button.is-style-tekstlenke > .wp-block-button__link {
	color: var(--wp--preset--color--hvit);
	text-decoration-color: var(--wp--preset--color--merke-lys);

	&:hover {
		color: var(--wp--preset--color--hvit);
		text-decoration-color: var(--wp--preset--color--hvit);
	}
}

.wp-block-buttons {
	align-items: center;
}

/* Below 640px the buttons stack and fill the width; text links keep their own width. */
@media (max-width: 639px) {
	.wp-block-buttons {
		flex-direction: column;
		align-items: stretch;

		> .wp-block-button:not(.is-style-tekstlenke) > .wp-block-button__link {
			width: 100%;
		}

		> .wp-block-button.is-style-tekstlenke {
			align-self: flex-start;
		}
	}
}

/* ---------------------------------------------------------------------------
 * Text
 * ------------------------------------------------------------------------ */

/* «Overlinje»: the short line above a page title. Light blue on dark fields. */

:is(.er-mork, .has-fjell-background-color, .has-fjell-2-background-color, .has-fjell-dyp-background-color, .has-merke-background-color) p.is-style-overlinje:not(.has-text-color) {
	color: var(--wp--preset--color--dis);
}

p.is-style-ingress-stor {
	text-wrap: balance;
}

.wp-block-quote {
	> p {
		margin: 0;
	}

	> cite {
		display: block;
		margin-top: 0.75rem;
		color: var(--omos-dempet);
	}
}

:is(.er-mork, .has-fjell-background-color, .has-fjell-2-background-color, .has-fjell-dyp-background-color, .has-merke-background-color) .wp-block-quote {
	border-left-color: var(--wp--preset--color--merke-lys);

	> p {
		color: inherit;
	}
}

/* ---------------------------------------------------------------------------
 * Images
 * ------------------------------------------------------------------------ */

.wp-block-image {
	margin: 0;

	img {
		display: block;
	}
}

/* «Skrå kant»: on phones the photo runs to both screen edges; from 1024px the left
   edge is cut at the same angle as the A in the logo. */
.wp-block-image.is-style-skra {
	margin-inline: calc(var(--omos-innrykk) * -1);

	img {
		width: 100%;
		aspect-ratio: 4 / 3;
		object-fit: cover;
	}

	figcaption {
		margin: 0.75rem 0 0;
		padding-inline: var(--omos-innrykk);
		text-align: right;
	}

	@media (min-width: 1024px) {
		margin-inline: 0;

		img {
			aspect-ratio: 5 / 4;
			clip-path: polygon(36% 0, 100% 0, 100% 100%, 0 100%);
		}

		figcaption {
			padding-inline: 0;
		}
	}
}

/* ---------------------------------------------------------------------------
 * Editor
 * ------------------------------------------------------------------------ */

/* Server-rendered previews of the custom blocks sit directly in the block's own element. */
.omos-ssr,
.wp-block[data-type^="omos/"] > .components-disabled {
	display: contents;
}
