/*
 * Nordvestsjaellands Fiskepark - supplementary styles.
 *
 * theme.json owns colours, type and spacing. This file only covers what it
 * cannot express: custom block styles, navigation behaviour, and the handful
 * of details carried over from the original design.
 *
 * Tokens come from theme.json as --wp--preset--* variables; nothing is
 * hard-coded here unless the original design used a one-off value.
 */

/* ---------------------------------------------------------------- header */

.site-header {
	position: relative;
	z-index: 10;
}

.site-header .wp-block-site-title a {
	color: inherit;
	text-decoration: none;
}

/* Navigation: uppercase, with the thin underline the original design used. */
.site-header .wp-block-navigation {
	--nv-underline: var(--wp--preset--color--primary);
}

.site-header .wp-block-navigation .wp-block-navigation-item__content {
	position: relative;
	padding-block: 0.35rem;
	text-decoration: none;
}

.site-header .wp-block-navigation .wp-block-navigation-item__content::after {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	height: 2px;
	background: var(--nv-underline);
	transform: scaleX(0);
	transform-origin: left;
	transition: transform 0.22s ease;
}

.site-header .wp-block-navigation .current-menu-item > .wp-block-navigation-item__content::after,
.site-header .wp-block-navigation .wp-block-navigation-item__content:hover::after,
.site-header .wp-block-navigation .wp-block-navigation-item__content:focus-visible::after {
	transform: scaleX(1);
}

/* Submenus sat on white, matching the original dropdown. */
.site-header .wp-block-navigation .wp-block-navigation-submenu .wp-block-navigation__submenu-container {
	background-color: var(--wp--preset--color--base);
	border: 0;
	box-shadow: 0 12px 32px rgba(19, 27, 29, 0.18);
	padding-block: 0.5rem;
	min-width: 15rem;
}

.site-header .wp-block-navigation .wp-block-navigation__submenu-container .wp-block-navigation-item__content {
	color: var(--wp--preset--color--contrast);
	padding-inline: 1.25rem;
}

.site-header .wp-block-navigation .wp-block-navigation__submenu-container .wp-block-navigation-item__content:hover {
	color: var(--wp--preset--color--primary);
}

/* The submenu sits on white, so the underline would be invisible. */
.site-header .wp-block-navigation .wp-block-navigation__submenu-container .wp-block-navigation-item__content::after {
	display: none;
}

.site-header .nv-brandmark {
	margin: 0;
}

.site-header .nv-brandmark a {
	color: inherit;
	text-decoration: none;
}

/* ------------------------------------------------------------- splash */

/*
 * The root page is a brand chooser: two cards, one per fishing park. Each
 * card is an image, a linked heading, a line of text and a button, so pair
 * them up and let the image sit behind the words.
 */
.splash {
	min-height: 100vh;
	display: flex;
	flex-direction: column;
	justify-content: center;
}

.splash .wp-block-post-content {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr));
	gap: var(--wp--preset--spacing--40);
	align-items: start;
}

.splash :is(h1, h2, h3, h4, h5, h6) {
	color: var(--wp--preset--color--base);
}

.splash :is(h2, p, .wp-block-buttons) {
	max-width: 34rem;
}

.splash h2 a {
	color: inherit;
	text-decoration: none;
}

.splash h2 a:hover,
.splash h2 a:focus-visible {
	color: var(--wp--preset--color--primary);
}

.splash figure.wp-block-image img {
	width: 100%;
	aspect-ratio: 3 / 2;
	object-fit: cover;
}

/* -------------------------------------------------------- page hero */

.page-hero {
	border-bottom: 1px solid rgba(69, 106, 114, 0.18);
}

.page-hero .wp-block-post-title {
	margin: 0;
}

/* ------------------------------------------------- custom block styles */

/*
 * Dark section. Children inherit the light foreground, which core does not
 * do on its own for headings and links inside a coloured group.
 */
.wp-block-group.is-style-section-dark {
	background-color: var(--wp--preset--color--contrast);
	color: var(--wp--preset--color--base);
	padding-block: var(--wp--preset--spacing--60);
}

.wp-block-group.is-style-section-dark :is(h1, h2, h3, h4, h5, h6) {
	color: var(--wp--preset--color--base);
}

.wp-block-group.is-style-section-dark a:where(:not(.wp-element-button)) {
	color: var(--wp--preset--color--base);
	text-decoration-color: var(--wp--preset--color--primary);
	text-underline-offset: 0.25em;
}

.wp-block-group.is-style-section-light {
	background-color: var(--wp--preset--color--light);
	padding-block: var(--wp--preset--spacing--60);
}

/*
 * Eyebrow: the small wide-tracked label above section headings. In the
 * original this was a 20px/800 heading with 5px of letter-spacing.
 */
.wp-block-heading.is-style-eyebrow {
	font-size: var(--wp--preset--font-size--x-small);
	font-weight: 700;
	letter-spacing: 5px;
	text-transform: uppercase;
	color: var(--wp--preset--color--primary);
	margin-bottom: 0.5rem;
}

/* Heading with the short accent rule underneath. */
.wp-block-heading.is-style-underlined {
	padding-bottom: 0.6rem;
	position: relative;
}

.wp-block-heading.is-style-underlined::after {
	content: "";
	position: absolute;
	left: 0;
	bottom: 0;
	width: 64px;
	height: 3px;
	background: var(--wp--preset--color--primary);
}

.wp-block-heading.is-style-underlined.has-text-align-center::after {
	left: 50%;
	transform: translateX(-50%);
}

.wp-block-image.is-style-full-bleed img {
	width: 100%;
	border-radius: 0;
}

/* -------------------------------------------------------------- tables */

.wp-block-table table {
	border-collapse: collapse;
	width: 100%;
}

.wp-block-table :is(td, th) {
	border: 1px solid rgba(69, 106, 114, 0.25);
	padding: 0.7rem 0.9rem;
}

.wp-block-table.is-style-price-table :is(th, tr:first-child td) {
	background: var(--wp--preset--color--contrast);
	color: var(--wp--preset--color--base);
	text-transform: uppercase;
	letter-spacing: 1px;
	font-weight: 700;
}

.wp-block-table.is-style-price-table tr:nth-child(even) td {
	background: var(--wp--preset--color--light);
}

/* Price tables are the most likely thing to overflow on a phone. */
.wp-block-table {
	overflow-x: auto;
}

/* ------------------------------------------------------------ galleries */

/*
 * Square-ish tiles, sized by aspect-ratio rather than height:100%. A
 * percentage height against an auto-height parent is circular, and browsers
 * resolve it by collapsing the image to something close to its intrinsic
 * ratio - which produced ~54px thumbnails instead of full-width ones.
 */
.wp-block-gallery.has-nested-images figure.wp-block-image img {
	width: 100%;
	height: auto;
	aspect-ratio: 4 / 3;
	object-fit: cover;
}

/*
 * The imported galleries are three and four up. At phone widths that leaves
 * thumbnails around 80px wide, which is too small to make anything out, so
 * drop to two columns.
 */
@media (max-width: 600px) {
	.wp-block-gallery.has-nested-images.columns-3 figure.wp-block-image,
	.wp-block-gallery.has-nested-images.columns-4 figure.wp-block-image,
	.wp-block-gallery.has-nested-images.columns-5 figure.wp-block-image,
	.wp-block-gallery.has-nested-images.columns-6 figure.wp-block-image {
		width: calc(50% - (var(--wp--style--block-gap, 1rem) / 2));
	}

}

/* ------------------------------------------------------------ long words */

/*
 * The cookie policy contains bare URLs and email addresses. Left alone they
 * are unbreakable strings that push the whole page sideways on a phone.
 */
body {
	overflow-wrap: break-word;
}

:is(p, li, td, th, dd, dt, figcaption) a {
	overflow-wrap: anywhere;
}

/* ------------------------------------------------------- media & embeds */

.wp-block-image img {
	height: auto;
	max-width: 100%;
}

iframe {
	max-width: 100%;
	border: 0;
}

/* --------------------------------------------- migration placeholder */

/*
 * Marks where the old Elementor contact form was. Deliberately loud: it
 * should be impossible to ship this to production by accident. Hidden from
 * visitors, shown to logged-in editors.
 */
.migrate-todo-form {
	display: none;
}

.logged-in .migrate-todo-form {
	display: block;
	border: 2px dashed #c1666b;
	background: #fdf3f3;
	color: #7a2e32;
	padding: 1.25rem 1.5rem;
	border-radius: 3px;
	font-size: 1rem;
}

.logged-in .migrate-todo-form::before {
	content: "Kontaktformular mangler — kun synlig for redaktører";
	display: block;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 1px;
	margin-bottom: 0.5rem;
}

.logged-in .migrate-todo-form ul {
	margin: 0;
	padding-left: 1.25rem;
}

/* ----------------------------------------------------------- footer */

.site-footer a {
	color: inherit;
	text-decoration: none;
}

.site-footer a:hover,
.site-footer a:focus-visible {
	text-decoration: underline;
	text-underline-offset: 0.25em;
}

.site-footer :is(h1, h2, h3, h4, h5, h6) {
	color: var(--wp--preset--color--base);
	margin-bottom: 0.75rem;
}

/* ---------------------------------------------------------- a11y */

:where(a, button, input, select, textarea, .wp-block-navigation-item__content):focus-visible {
	outline: 3px solid var(--wp--preset--color--primary);
	outline-offset: 2px;
}

.skip-link:focus {
	background: var(--wp--preset--color--base);
	color: var(--wp--preset--color--contrast);
	padding: 0.75rem 1.25rem;
	z-index: 999999;
}

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

/* --------------------------------------------------------- responsive */

@media (max-width: 781px) {
	.site-header .wp-block-group {
		gap: 0.75rem;
	}

	/* Stacked footer columns need their own breathing room. */
	.site-footer .wp-block-columns {
		gap: var(--wp--preset--spacing--40);
	}
}
