/**
 * Styles for the acf/banarbeten-datumfilter block.
 *
 * Matches the trafikinformation date picker by reusing the theme design
 * tokens (--mossa dark green, --gradde cream, --grodd light green, soleil).
 * BEM, prefix: tib-banarbeten-filter. WCAG 2.1 AA: visible focus, high
 * contrast (mossa on gradde), no colour-only meaning, respects reduced motion.
 */

.tib-banarbeten-filter {
	margin-bottom: 2rem;
}

.tib-banarbeten-filter__form {
	margin-bottom: 1rem;
}

.tib-banarbeten-filter__fieldset {
	border: 1px solid rgba(16, 44, 12, 0.25); /* subtle mossa */
	border-radius: var(--rounded-lg, 0.3rem);
	padding: 1rem 1.25rem 1.25rem;
	margin: 0;
}

.tib-banarbeten-filter__legend {
	font-weight: 600;
	font-size: var(--h5, 1.135rem);
	padding: 0 0.5rem;
	color: var(--mossa, #102c0c);
}

.tib-banarbeten-filter__hint {
	margin: 0 0 1rem;
	font-size: 0.9rem;
	color: rgba(16, 44, 12, 0.8); /* mossa @ 80% */
}

/* Fields + buttons share one row when there's space; the buttons wrap below
   when it gets tight. align-items:flex-end bottom-aligns the buttons with the
   input boxes (not the labels). */
.tib-banarbeten-filter__controls {
	display: flex;
	flex-wrap: wrap;
	gap: 1rem;
	align-items: flex-end;
}

/* The two date fields side by side; they grow to take most of the row so the
   buttons sit to their right. */
.tib-banarbeten-filter__fields {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 1rem;
	align-items: end;
	flex: 1 1 20rem;
	min-width: 0;
}

/* The field is a cream box with the label sitting inside it (small, on top)
   and the value below — matching the .tib-api-search / trafikinformation
   fields. A thin border keeps the cream box visible on the cream page. */
.tib-banarbeten-filter__field {
	display: flex;
	flex-direction: column;
	min-width: 0;
	position: relative;
	background: var(--gradde, #fff9ec);
	border: 1px solid rgba(16, 44, 12, 0.4); /* mossa @ 40% */
	border-radius: var(--rounded, 0.25rem);
	padding: 0.4rem 0.75rem 0.5rem;
}

.tib-banarbeten-filter__field:focus-within {
	outline: 2px solid var(--mossa, #102c0c);
	outline-offset: 1px;
}

/* Small label inside the box. */
.tib-banarbeten-filter__label {
	font-size: 0.8125rem;
	font-weight: 400;
	line-height: 1.2;
	margin: 0 0 0.1rem;
	color: var(--mossa, #102c0c);
}

.tib-banarbeten-filter__inputwrap {
	min-width: 0;
}

/* The value, styled as text — the box provides background/border/focus. */
.tib-banarbeten-filter__input {
	width: 100%;
	padding: 0;
	font-size: var(--h5, 1.135rem);
	font-weight: 600;
	line-height: 1.2;
	color: var(--mossa, #102c0c);
	background: transparent;
	border: 0;
	border-radius: 0;
}

.tib-banarbeten-filter__input:focus {
	outline: none; /* the box shows focus via :focus-within */
}

/* Calendar icon injected by JS on desktop; native input keeps its own icon.
   Positioned against the whole field box (inputwrap is not positioned). */
.tib-banarbeten-filter__inputwrap--icon .tib-banarbeten-filter__input {
	padding-right: 1.75rem;
}

.tib-banarbeten-filter__icon {
	position: absolute;
	right: 0.75rem;
	top: 50%;
	transform: translateY(-50%);
	width: 24px;
	height: 24px;
	color: var(--mossa, #102c0c);
	pointer-events: none; /* clicks fall through to the input, opening flatpickr */
}

.tib-banarbeten-filter__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.75rem;
	align-items: center;
	flex: 0 0 auto; /* content width — sits to the right of the fields */
}

/* Buttons reuse the theme's global classes (.btn-primary / .btn-outline-primary);
   the BEM classes are kept only as JS hooks, not for styling. */

/* Functional, not styling: Bootstrap's `.btn { display:inline-block }` would
   otherwise override the `hidden` attribute, so keep the clear button hidden
   until a filter is active. */
.tib-banarbeten-filter__clear[hidden] {
	display: none;
}

/* Validation error. Contrast ~5.9:1; reinforced by the text itself.
   Scoped under the block to outweigh the theme's `.entry-content :where(p)`
   margin reset (same specificity, loaded later) and keep the top spacing. */
.tib-banarbeten-filter .tib-banarbeten-filter__error {
	margin: 1.5rem 0 0;
	padding: 0.5rem 0.75rem;
	font-weight: 600;
	color: #b3261e;
	background-color: #fdecea;
	border-left: 4px solid #b3261e;
	border-radius: 4px;
}

.tib-banarbeten-filter__error[hidden] {
	display: none;
}

/* Result banner: same cream-green box style as the empty box below, so the two
   states read as one consistent element (when a filter yields 0 matches the
   banner is emptied and the empty box takes its place). */
.tib-banarbeten-filter__results {
	font-weight: 600;
	margin: 0 0 1rem;
	padding: 1rem 1.25rem;
	color: var(--mossa, #102c0c);
	background-color: var(--grodd, #e2e8c7);
	border-left: 4px solid var(--mossa, #102c0c);
}

.tib-banarbeten-filter__results:empty {
	display: none;
}

/* Emphasise the match count within the banner (the rest is already 600). */
.tib-banarbeten-filter__count {
	font-weight: 700;
}

.tib-banarbeten-filter__empty {
	padding: 1rem 1.25rem;
	background-color: var(--grodd, #e2e8c7);
	border-left: 4px solid var(--mossa, #102c0c);
	color: var(--mossa, #102c0c);
}

/* ---------------------------------------------------------------------------
   flatpickr calendar theme — scoped to our calendar (flatpickr appends to
   <body>) so it matches the trafikinformation picker without affecting other
   flatpickr instances. Cream background, mossa text, mossa-circle selected day.
   --------------------------------------------------------------------------- */
.flatpickr-calendar.tib-banarbeten-filter__calendar {
	background: var(--gradde, #fff9ec);
	color: var(--mossa, #102c0c);
	font-family: var(--font-family-sans-serif, soleil, sans-serif);
	border: none;
	border-radius: var(--rounded-lg, 0.3rem);
	box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
	/* 21rem grid (336px) + 1.5rem horizontal padding = 22.5rem, border-box so
	   the padding gives air around the grid without overflowing the box. */
	box-sizing: border-box;
	width: 22.5rem;
	min-width: 22.5rem;
	max-width: 22.5rem;
	padding: 0.5rem 0.75rem 0.75rem; /* air around the grid, like trafikinfo */
}

/* Connecting arrow tip matches the cream background. */
.flatpickr-calendar.tib-banarbeten-filter__calendar.arrowTop::after {
	border-bottom-color: var(--gradde, #fff9ec);
}
.flatpickr-calendar.tib-banarbeten-filter__calendar.arrowBottom::after {
	border-top-color: var(--gradde, #fff9ec);
}

.flatpickr-calendar.tib-banarbeten-filter__calendar .flatpickr-months .flatpickr-month,
.flatpickr-calendar.tib-banarbeten-filter__calendar .flatpickr-current-month,
.flatpickr-calendar.tib-banarbeten-filter__calendar .flatpickr-monthDropdown-months,
.flatpickr-calendar.tib-banarbeten-filter__calendar .numInputWrapper span,
.flatpickr-calendar.tib-banarbeten-filter__calendar .flatpickr-current-month input.cur-year {
	color: var(--mossa, #102c0c);
	fill: var(--mossa, #102c0c);
}

.flatpickr-calendar.tib-banarbeten-filter__calendar .flatpickr-monthDropdown-months {
	background: var(--gradde, #fff9ec);
}

.flatpickr-calendar.tib-banarbeten-filter__calendar .flatpickr-prev-month svg,
.flatpickr-calendar.tib-banarbeten-filter__calendar .flatpickr-next-month svg {
	fill: var(--mossa, #102c0c);
}

.flatpickr-calendar.tib-banarbeten-filter__calendar span.flatpickr-weekday {
	color: rgba(38, 38, 38, 0.8);
	font-weight: 400;
	font-size: 16px;
	flex: 0 0 40px;
	width: 40px;
	max-width: 40px;
	margin: 0 4px; /* same 48px column pitch as the days, so they line up */
}

/* Fixed 40px cells with a 4px margin → a deterministic 8px gap between days
   (flatpickr's flex-basis layout leaves no room for space-around to work). */
.flatpickr-calendar.tib-banarbeten-filter__calendar .flatpickr-day {
	color: var(--mossa, #102c0c);
	border-radius: 50%;
	flex: 0 0 40px;
	width: 40px;
	min-width: 40px;
	max-width: 40px;
	height: 40px;
	line-height: 40px;
	margin: 4px;
	font-size: 16px;
}

.flatpickr-calendar.tib-banarbeten-filter__calendar .flatpickr-day.prevMonthDay,
.flatpickr-calendar.tib-banarbeten-filter__calendar .flatpickr-day.nextMonthDay {
	color: rgba(16, 44, 12, 0.4);
}

.flatpickr-calendar.tib-banarbeten-filter__calendar .flatpickr-day.flatpickr-disabled {
	color: rgba(16, 44, 12, 0.3);
}

.flatpickr-calendar.tib-banarbeten-filter__calendar .flatpickr-day.today {
	border-color: var(--mossa, #102c0c);
}

.flatpickr-calendar.tib-banarbeten-filter__calendar .flatpickr-day:hover,
.flatpickr-calendar.tib-banarbeten-filter__calendar .flatpickr-day.today:hover,
.flatpickr-calendar.tib-banarbeten-filter__calendar .flatpickr-day.selected,
.flatpickr-calendar.tib-banarbeten-filter__calendar .flatpickr-day.selected:hover {
	background: var(--mossa, #102c0c);
	border-color: var(--mossa, #102c0c);
	color: var(--grodd, #e2e8c7);
}

/* Widen the nested width chain (flatpickr 4.6.13 fixes these at 307.875px) to
   21rem = 336px = 7 × 48px columns. The calendar element itself is left to
   auto-size (content + its padding) so the edge air is preserved. */
.flatpickr-calendar.tib-banarbeten-filter__calendar .flatpickr-months,
.flatpickr-calendar.tib-banarbeten-filter__calendar .flatpickr-innerContainer,
.flatpickr-calendar.tib-banarbeten-filter__calendar .flatpickr-rContainer,
.flatpickr-calendar.tib-banarbeten-filter__calendar .flatpickr-weekdaycontainer,
.flatpickr-calendar.tib-banarbeten-filter__calendar .flatpickr-weekdays,
.flatpickr-calendar.tib-banarbeten-filter__calendar .flatpickr-days,
.flatpickr-calendar.tib-banarbeten-filter__calendar .dayContainer {
	width: 21rem;
	min-width: 21rem;
	max-width: 21rem;
}

/* Left-align the columns; the per-cell margins provide the 8px gaps. */
.flatpickr-calendar.tib-banarbeten-filter__calendar .dayContainer,
.flatpickr-calendar.tib-banarbeten-filter__calendar .flatpickr-weekdays {
	justify-content: flex-start;
}

.flatpickr-calendar.tib-banarbeten-filter__calendar .dayContainer {
	padding-top: 2px;
}

/* Larger, semi-bold month/year header. */
.flatpickr-calendar.tib-banarbeten-filter__calendar .flatpickr-current-month .flatpickr-monthDropdown-months,
.flatpickr-calendar.tib-banarbeten-filter__calendar .flatpickr-current-month input.cur-year {
	font-size: 1.135rem;
	font-weight: 600;
}

@media (max-width: 600px) {
	.tib-banarbeten-filter__fields {
		grid-template-columns: 1fr; /* stack Från over Till */
	}

	.tib-banarbeten-filter__actions {
		flex-direction: column;
		align-items: stretch;
		width: 100%; /* full-width row under the fields */
	}

	.tib-banarbeten-filter__submit,
	.tib-banarbeten-filter__clear {
		width: 100%;
	}
}

@media (prefers-reduced-motion: reduce) {
	.tib-banarbeten-filter *,
	.tib-banarbeten-filter *::before,
	.tib-banarbeten-filter *::after {
		transition-duration: 0.01ms !important;
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		scroll-behavior: auto !important;
	}
}
