/**
 * Base
 *
 * Element defaults, typography, accessibility helpers and the WordPress core
 * markup classes. No component or block styles belong in this file.
 *
 * @package Norwegian_Flagstone
 */

/* Box model & root ---------------------------------------------------------- */

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

html {
	scroll-behavior: smooth;

	/* Anchors and skip-links clear the fixed header. */
	scroll-padding-top: calc(var(--nf-header-space) + var(--nf-space-m));
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
}

body {
	background-color: var(--nf-color-bg);
	color: var(--nf-color-text);
	font-family: var(--nf-font-body);
	font-size: var(--nf-fs-body);
	font-weight: var(--nf-font-weight-regular);
	line-height: var(--nf-lh-body);
	min-height: 100vh;
	overflow-x: hidden;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	text-rendering: optimizelegibility;
}

/* Locks scrolling while the mobile navigation drawer is open. */
body.nf-scroll-locked {
	overflow: hidden;
}

/* Typography ---------------------------------------------------------------- */

h1,
h2,
h3,
h4,
h5,
h6 {
	color: var(--nf-color-heading);
	font-family: var(--nf-font-display);
	font-weight: var(--nf-font-weight-bold);
	line-height: var(--nf-lh-heading);
	margin: 0 0 var(--nf-space-m);
	text-wrap: balance;
}

h1 {
	font-size: var(--nf-fs-h1);
}

h2 {
	font-size: var(--nf-fs-h2);
}

h3 {
	font-size: var(--nf-fs-h3);
}

h4 {
	font-size: var(--nf-fs-lead);
}

h5,
h6 {
	font-size: var(--nf-fs-body);
}

p,
ul,
ol,
dl,
pre,
address,
figure,
table,
blockquote {
	margin: 0 0 var(--nf-space-m);
}

/* Trailing margins never leak out of a container. */
:where(h1, h2, h3, h4, h5, h6, p, ul, ol, dl, figure, table, blockquote):last-child {
	margin-bottom: 0;
}

ul,
ol {
	padding-left: 1.25em;
}

li + li {
	margin-top: var(--nf-space-3xs);
}

blockquote {
	border-left: 2px solid var(--nf-color-accent);
	font-family: var(--nf-font-display);
	font-size: var(--nf-fs-lead);
	padding-left: var(--nf-space-m);
}

blockquote cite {
	display: block;
	font-family: var(--nf-font-body);
	font-size: var(--nf-fs-small);
	font-style: normal;
	margin-top: var(--nf-space-2xs);
	opacity: 0.7;
}

hr {
	background-color: var(--nf-color-border);
	border: 0;
	height: var(--nf-border-width);
	margin: var(--nf-space-xl) 0;
}

strong,
b {
	font-weight: var(--nf-font-weight-bold);
}

small {
	font-size: var(--nf-fs-small);
}

code,
kbd,
pre,
samp {
	font-family: ui-monospace, sfmono-regular, menlo, consolas, monospace;
	font-size: 0.9em;
}

pre {
	background-color: var(--nf-mork-sort-15);
	border-radius: var(--nf-radius-s);
	max-width: 100%;
	overflow: auto;
	padding: var(--nf-space-s);
}

/* Links --------------------------------------------------------------------- */

a {
	color: var(--nf-color-link);
	text-decoration-thickness: 1px;
	text-underline-offset: 0.2em;
	transition: color var(--nf-transition);
}

a:hover,
a:focus {
	color: var(--nf-color-link-hover);
}

/* Focus --------------------------------------------------------------------- */

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

/* Remove the outline for pointer users while keeping it for keyboards. */
:focus:not(:focus-visible) {
	outline: none;
}

/* Media --------------------------------------------------------------------- */

img,
picture,
video,
canvas,
svg,
iframe,
embed,
object {
	display: block;
	max-width: 100%;
}

/*
 * WordPress prints width/height attributes on images; ignore the height so the
 * intrinsic ratio is honoured. Kept as a bare type selector on purpose — an
 * `img[width][height]` selector would outrank component rules such as
 * `.nf-cover__media img { height: 100% }` and silently break cover images.
 */
img,
video {
	height: auto;
}

figure {
	margin-inline: 0;
}

figcaption,
.wp-caption-text {
	color: var(--nf-color-text-muted);
	font-size: var(--nf-fs-small);
	margin-top: var(--nf-space-2xs);
}

svg {
	fill: currentcolor;
}

/* Tables -------------------------------------------------------------------- */

table {
	border-collapse: collapse;
	width: 100%;
}

th,
td {
	border-bottom: var(--nf-border-width) solid var(--nf-color-border);
	padding: var(--nf-space-2xs) var(--nf-space-xs);
	text-align: left;
}

th {
	font-weight: var(--nf-font-weight-medium);
}

/* Forms --------------------------------------------------------------------- */

label {
	display: block;
	font-size: var(--nf-fs-small);
	margin-bottom: var(--nf-space-3xs);
}

input,
select,
textarea {
	background-color: var(--nf-white);
	border: var(--nf-border-width) solid var(--nf-color-border);
	border-radius: var(--nf-radius);
	color: var(--nf-color-text);
	font-family: var(--nf-font-body);
	font-size: var(--nf-fs-body);
	max-width: 100%;
	padding: var(--nf-space-2xs) var(--nf-space-xs);
	width: 100%;
}

input[type="checkbox"],
input[type="radio"] {
	width: auto;
}

input:focus,
select:focus,
textarea:focus {
	border-color: var(--nf-color-accent);
}

textarea {
	min-height: 8rem;
	resize: vertical;
}

::placeholder {
	color: var(--nf-color-text-muted);
	opacity: 1;
}

button,
input[type="submit"],
input[type="button"],
input[type="reset"] {
	cursor: pointer;
}

/* Selection ----------------------------------------------------------------- */

::selection {
	background-color: var(--nf-gull);
	color: var(--nf-mork-sort);
}

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

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

.screen-reader-text:focus {
	background-color: var(--nf-lys);
	border-radius: var(--nf-radius);
	box-shadow: var(--nf-shadow-m);
	clip-path: none;
	color: var(--nf-mork-sort);
	display: block;
	font-size: var(--nf-fs-small);
	font-weight: var(--nf-font-weight-medium);
	height: auto;
	left: var(--nf-space-s);
	line-height: normal;
	padding: var(--nf-space-2xs) var(--nf-space-s);
	text-decoration: none;
	top: var(--nf-space-s);
	width: auto;
	z-index: var(--nf-z-skip-link);
}

.skip-link:focus {
	position: fixed !important;
}

/* Hidden but still announced to assistive tech is `.screen-reader-text`;
   this one is hidden from everything. */
.is-hidden {
	display: none !important;
}

@media (prefers-reduced-motion: reduce) {

	html {
		scroll-behavior: auto;
	}

	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		scroll-behavior: auto !important;
		transition-duration: 0.01ms !important;
	}
}

/* WordPress core markup ----------------------------------------------------- */

.alignleft {
	float: left;
	margin: 0 var(--nf-space-m) var(--nf-space-s) 0;
}

.alignright {
	float: right;
	margin: 0 0 var(--nf-space-s) var(--nf-space-m);
}

.aligncenter {
	clear: both;
	display: block;
	margin-inline: auto;
}

.wp-caption {
	max-width: 100%;
}

.gallery-caption {
	display: block;
}

.sticky {
	display: block;
}

.post,
.page {
	margin: 0;
}

.updated:not(.published) {
	display: none;
}

/* Clears floats after aligned content. */
.entry-content::after,
.comment-content::after {
	clear: both;
	content: "";
	display: table;
}

/* Text colour utilities used by blocks that flip between light and dark ----- */

.nf-on-dark {
	--nf-color-text: var(--nf-lys);
	--nf-color-heading: var(--nf-lys);
	--nf-color-link: var(--nf-lys);
	--nf-color-link-hover: var(--nf-gull);
	--nf-color-border: var(--nf-lys-15);
	--nf-color-text-muted: var(--nf-lys-70);

	color: var(--nf-color-text);
}

.nf-on-light {
	--nf-color-text: var(--nf-mork-sort);
	--nf-color-heading: var(--nf-mork-sort);
	--nf-color-link: var(--nf-mork-sort);
	--nf-color-link-hover: var(--nf-gull-hover);
	--nf-color-border: var(--nf-mork-sort-15);
	--nf-color-text-muted: var(--nf-mork-sort-70);

	color: var(--nf-color-text);
}
