/**
 * Florian FD - Base layer
 *
 * Normalisation, accessibility primitives and styling for elements that are
 * not blocks (form controls, tables, WordPress core utility classes).
 *
 * Colour, type and spacing all come from theme.json presets.
 */

/* -------------------------------------------------------------------------
 * Reset
 * ---------------------------------------------------------------------- */

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

html {
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
	scroll-behavior: smooth;
	scroll-padding-top: calc( var( --fl-header-offset, var( --fl-header-height ) ) + 1rem );
	/* The text-size control sets --fl-font-scale; every rem-based token in
	   theme.json scales with it. */
	font-size: calc( 100% * var( --fl-font-scale, 1 ) );
}

body {
	margin: 0;
	min-height: 100vh;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	font-synthesis-weight: none;
	text-rendering: optimizeLegibility;
}

::selection {
	background-color: var( --wp--preset--color--accent );
	color: var( --wp--preset--color--base );
}

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

svg {
	fill: currentColor;
	flex-shrink: 0;
}

button,
input,
select,
textarea {
	font: inherit;
	color: inherit;
}

/* Balance short headings; let long body copy wrap normally. */
h1,
h2,
h3 {
	text-wrap: balance;
}

p,
li {
	text-wrap: pretty;
}

/* Avoid orphaned words in lead paragraphs. */
:where( h1, h2, h3, h4, h5, h6 ) {
	overflow-wrap: break-word;
}

hr {
	border: 0;
	border-top: 1px solid var( --wp--preset--color--outline );
	margin-block: var( --wp--preset--spacing--60 );
}

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

/* A single, consistent focus ring everywhere. Never remove without replacing. */
:focus-visible {
	outline: var( --fl-focus-width ) solid var( --fl-focus-color );
	outline-offset: var( --fl-focus-offset );
	border-radius: var( --fl-radius-sm );
}

/* Older engines that lack :focus-visible still get a ring. */
:focus:not( :focus-visible ) {
	outline: none;
}

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

.screen-reader-text:focus {
	clip-path: none;
	height: auto;
	margin: 0;
	overflow: visible;
	position: static;
	white-space: normal;
	width: auto;
}

.skip-link:focus,
.florian-skip-link:focus {
	background-color: var( --wp--preset--color--contrast );
	color: var( --wp--preset--color--base );
	display: inline-block;
	font-weight: 600;
	left: var( --fl-gutter );
	padding: 0.75rem 1.25rem;
	position: fixed;
	top: 0.75rem;
	text-decoration: none;
	z-index: 1000;
	border-radius: var( --fl-radius-md );
}

/**
 * Motion policy.
 *
 * The theme ships no decorative motion, so this only needs to neutralise
 * transitions from core blocks and any smooth scrolling.
 */
@media ( prefers-reduced-motion: reduce ) {
	html {
		scroll-behavior: auto;
	}

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

/* -------------------------------------------------------------------------
 * Interactive sizing
 *
 * WCAG 2.5.8 asks for a 24px minimum; we target 44px which also satisfies
 * the stricter 2.5.5 guideline. Applied to every control the theme renders.
 * ---------------------------------------------------------------------- */

.wp-block-button__link,
.wp-element-button,
.florian-tap,
button:not( .florian-tap-exempt ),
input[ type='submit' ],
input[ type='button' ] {
	min-height: var( --fl-target );
}

/* Icon-only controls need width as well as height. */
.florian-icon-button {
	align-items: center;
	background: none;
	border: 1px solid transparent;
	border-radius: var( --fl-radius-md );
	color: var( --wp--preset--color--contrast-2 );
	cursor: pointer;
	display: inline-flex;
	justify-content: center;
	min-height: var( --fl-target );
	min-width: var( --fl-target );
	padding: 0;
	transition: color var( --fl-transition ), background-color var( --fl-transition ), border-color var( --fl-transition );
}

.florian-icon-button:hover {
	background-color: var( --wp--preset--color--base-3 );
	color: var( --wp--preset--color--accent );
}

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

input[ type='text' ],
input[ type='email' ],
input[ type='url' ],
input[ type='tel' ],
input[ type='number' ],
input[ type='date' ],
input[ type='time' ],
input[ type='search' ],
input[ type='password' ],
select,
textarea {
	background-color: var( --wp--preset--color--base );
	border: 1px solid #c9d3db;
	border-radius: 8px;
	color: var( --wp--preset--color--contrast );
	min-height: var( --fl-target );
	padding: 0.9375rem;
	transition: border-color var( --fl-transition ), background-color var( --fl-transition );
	width: 100%;
	font-size: max( 1rem, var( --wp--preset--font-size--small ) );
}

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

select {
	appearance: none;
	background-image: url( "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E" );
	background-position: right 0.75rem center;
	background-repeat: no-repeat;
	padding-right: 2.5rem;
}

input:focus,
select:focus,
textarea:focus {
	background-color: var( --wp--preset--color--base );
	border-color: var( --wp--preset--color--navy );
	box-shadow: none;
	outline: none;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
	outline: var( --fl-focus-width ) solid var( --fl-focus-color );
	outline-offset: var( --fl-focus-offset );
}

input::placeholder,
textarea::placeholder {
	color: var( --wp--preset--color--contrast-3 );
	opacity: 1;
}

input[ type='checkbox' ],
input[ type='radio' ] {
	accent-color: var( --wp--preset--color--navy );
	height: 1.125rem;
	width: 1.125rem;
	min-height: 0;
}

label {
	display: block;
	font-size: 0.92rem;
	font-weight: 700;
	margin-bottom: 0.3rem;
}

fieldset {
	border: 1px solid var( --wp--preset--color--outline );
	border-radius: var( --fl-radius-md );
	margin: 0 0 var( --wp--preset--spacing--50 );
	padding: var( --wp--preset--spacing--50 );
}

legend {
	font-weight: 600;
	padding-inline: 0.5rem;
}

.florian-field {
	margin-bottom: var( --wp--preset--spacing--40 );
}

.florian-field__hint {
	color: var( --wp--preset--color--contrast-3 );
	display: block;
	font-size: var( --wp--preset--font-size--x-small );
	margin-top: 0.375rem;
}

.florian-field__error {
	color: var( --wp--preset--color--accent );
	display: block;
	font-size: var( --wp--preset--font-size--x-small );
	font-weight: 600;
	margin-top: 0.375rem;
}

.florian-form-notice {
	border: 1px solid var( --wp--preset--color--outline );
	border-left: 3px solid var( --wp--preset--color--accent );
	border-radius: var( --fl-radius-md );
	margin-bottom: var( --wp--preset--spacing--50 );
	padding: var( --wp--preset--spacing--40 );
}

.florian-form-notice--success {
	border-left-color: var( --wp--preset--color--success );
}

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

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

.wp-block-table th,
.wp-block-table td,
table.florian-table th,
table.florian-table td {
	border-bottom: 1px solid var( --wp--preset--color--outline );
	padding: 0.75rem 0.875rem;
	text-align: left;
	vertical-align: top;
}

.wp-block-table th,
table.florian-table th {
	color: var( --wp--preset--color--contrast );
	font-size: var( --wp--preset--font-size--x-small );
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	white-space: nowrap;
}

/* Tables are the most common source of horizontal overflow on phones. */
.wp-block-table,
.florian-table-scroll {
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}

/* -------------------------------------------------------------------------
 * WordPress core utility classes
 * ---------------------------------------------------------------------- */

.alignleft {
	float: left;
	margin-right: var( --wp--preset--spacing--50 );
	margin-bottom: var( --wp--preset--spacing--40 );
}

.alignright {
	float: right;
	margin-left: var( --wp--preset--spacing--50 );
	margin-bottom: var( --wp--preset--spacing--40 );
}

.aligncenter {
	margin-inline: auto;
}

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

.wp-caption-text,
figcaption {
	color: var( --wp--preset--color--contrast-3 );
	font-size: var( --wp--preset--font-size--x-small );
	line-height: 1.5;
	margin-top: 0.5rem;
}

.sticky,
.gallery-caption,
.bypostauthor {
	/* Required by the WordPress theme review guidelines. */
	display: block;
}

/* WordPress admin bar offsets for the sticky header. */
.admin-bar .florian-header,
.admin-bar .florian-header--sticky {
	top: 32px;
}

@media ( max-width: 782px ) {
	.admin-bar .florian-header,
	.admin-bar .florian-header--sticky {
		top: 46px;
	}
}

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

/* Keeps the site footer at the bottom on short pages. */
.wp-site-blocks {
	display: flex;
	flex-direction: column;
	min-height: 100vh;
}

.wp-site-blocks > main {
	flex: 1 0 auto;
}

/* Prevent any single element from forcing a horizontal scrollbar on mobile. */
body {
	overflow-x: clip;
}

.florian-visually-balanced {
	text-wrap: balance;
}

/* -------------------------------------------------------------------------
 * Print
 * ---------------------------------------------------------------------- */

@media print {
	.florian-header,
	.florian-alert-bar,
	.wp-block-navigation,
	.wp-block-search,
	footer.wp-block-template-part,
	.florian-no-print {
		display: none !important;
	}

	body {
		background: #fff;
		color: #000;
		font-size: 11pt;
	}

	a[ href^='http' ]::after {
		content: ' (' attr( href ) ')';
		font-size: 9pt;
		word-break: break-all;
	}
}