/*
 * FM Parent base styles.
 *
 * Every color, font and size comes from the tokens printed in <head> (inc/tokens.php), so a child theme
 * changes the look by changing Site Settings first and CSS second. Layout styles live in layouts/{name}/style.css.
 *
 * Layers: reset, base, layout, components, utilities. Child theme CSS loads after and wins without !important.
 */

@layer reset, base, layout, components, utilities;

/* ---------------------------------------------------------------- Reset */
@layer reset {
	*, *::before, *::after { box-sizing: border-box; }
	html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
	body, h1, h2, h3, h4, p, figure, blockquote, dl, dd { margin: 0; }
	img, svg, video { max-width: 100%; height: auto; display: block; }
	input, button, textarea, select { font: inherit; }
	@media (prefers-reduced-motion: reduce) {
		*, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
	}
}

/* ---------------------------------------------------------------- Base */
@layer base {
	:root {
		--fm-gutter: clamp(1rem, 4vw, 2rem);
		--fm-space-s: clamp(1.5rem, 4vw, 2.5rem);
		--fm-space-m: clamp(2.5rem, 7vw, 5rem);
		--fm-space-l: clamp(3.5rem, 10vw, 7.5rem);
		--fm-focus: var(--fm-color-secondary);
		--fm-text: var(--fm-color-dark);
		--fm-bg: var(--fm-color-white);
		--fm-card-bg: var(--fm-color-light);
		--fm-card-text: var(--fm-color-dark);
		--fm-rule: color-mix(in srgb, currentColor 18%, transparent);
		--fm-link: var(--fm-color-primary);
		color-scheme: light;
	}
	html { scroll-behavior: smooth; scroll-padding-top: 6rem; }
	body {
		font-family: var(--fm-font-body);
		font-size: var(--fm-font-size);
		line-height: 1.6;
		color: var(--fm-text);
		background: var(--fm-bg);
		-webkit-font-smoothing: antialiased;
	}
	h1, h2, h3, h4 { font-family: var(--fm-font-heading); line-height: 1.15; font-weight: 700; text-wrap: balance; }
	h1 { font-size: var(--fm-step-5); }
	h2 { font-size: var(--fm-step-3); }
	h3 { font-size: var(--fm-step-2); }
	h4 { font-size: var(--fm-step-1); }
	p, li { text-wrap: pretty; }
	a { color: var(--fm-link); text-underline-offset: .18em; text-decoration-thickness: 1px; }
	a:hover { text-decoration-thickness: 2px; }
	small, figcaption, .fm-caption { font-family: var(--fm-font-caption); font-size: var(--fm-step-sm); }
	:focus-visible { outline: 3px solid var(--fm-focus); outline-offset: 3px; border-radius: 2px; }
	::selection { background: var(--fm-color-secondary); color: var(--fm-on-secondary); }
	address { font-style: normal; }
	.fm-main:focus { outline: none; }
}

/* ---------------------------------------------------------------- Layout */
@layer layout {
	.fm-container { width: 100%; max-width: calc(var(--fm-container) + 2 * var(--fm-gutter)); margin-inline: auto; padding-inline: var(--fm-gutter); }

	/* Sections: spacing and background come from per-section options. */
	.fm-section { position: relative; isolation: isolate; background: var(--fm-section-bg, transparent); color: var(--fm-section-text, inherit); }
	.fm-space-top-none { padding-top: 0; } .fm-space-top-s { padding-top: var(--fm-space-s); } .fm-space-top-m { padding-top: var(--fm-space-m); } .fm-space-top-l { padding-top: var(--fm-space-l); }
	.fm-space-bottom-none { padding-bottom: 0; } .fm-space-bottom-s { padding-bottom: var(--fm-space-s); } .fm-space-bottom-m { padding-bottom: var(--fm-space-m); } .fm-space-bottom-l { padding-bottom: var(--fm-space-l); }
	/* Two same-background sections in a row share one gap instead of doubling it. */
	.fm-section:not([class*="fm-bg-"], .fm-section--homepage-hero, .fm-section--internal-hero) + .fm-section:not([class*="fm-bg-"]) { padding-top: 0; }

	/* Cards adapt to the section they sit on. */
	.fm-bg-light { --fm-card-bg: var(--fm-color-white); }
	.fm-bg-primary, .fm-bg-secondary, .fm-bg-dark, .fm-bg-image { --fm-link: currentColor; --fm-card-bg: var(--fm-color-white); --fm-card-text: var(--fm-color-dark); }
	.fm-text-light { --fm-section-text: #fff; --fm-link: currentColor; color: #fff; }
	.fm-text-dark { --fm-section-text: var(--fm-color-dark); color: var(--fm-color-dark); }

	/* Image backgrounds: image behind, overlay set per section with --fm-overlay. */
	.fm-bg-image { color: #fff; }
	.fm-section__bg { position: absolute; inset: 0; z-index: -1; }
	.fm-section__bg img { width: 100%; height: 100%; object-fit: cover; }
	.fm-bg-image::before { content: ""; position: absolute; inset: 0; z-index: -1; background: rgb(0 0 0 / var(--fm-overlay, .5)); }

	.fm-section__header { margin-bottom: clamp(1.5rem, 3vw, 2.5rem); max-width: 60ch; }
	.fm-section__title { margin: 0 0 .5rem; }
	.fm-section__intro { font-size: var(--fm-step-1); margin: 0; }

	/* Heroes (shared by both hero layouts). */
	.fm-hero { position: relative; display: grid; isolation: isolate; color: var(--fm-section-text, var(--fm-on-dark)); background: var(--fm-section-bg, var(--fm-color-dark)); }
	.fm-hero__media { position: absolute; inset: 0; z-index: -1; }
	.fm-hero__media img { width: 100%; height: 100%; object-fit: cover; }
	.fm-hero.has-image { color: #fff; }
	.fm-hero__title { margin: 0; }
	/* Fallback hero for templates without sections. */
	.fm-section--internal-hero.fm-bg-dark > .fm-hero__content { padding-block: clamp(2.5rem, 7vw, 4.5rem) clamp(2rem, 5vw, 3rem); }

	/* Service pages with a sidebar. Sections inside the column drop their own container. */
	.fm-with-sidebar { display: grid; gap: clamp(2rem, 4vw, 3.5rem); padding-block: var(--fm-space-m); }
	@media (min-width: 1000px) { .fm-with-sidebar { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; } }
	.fm-with-sidebar__main .fm-container { padding-inline: 0; max-width: none; }
	.fm-with-sidebar__main .fm-section { padding-block: 0 var(--fm-space-s); }
	.fm-with-sidebar__main .fm-section[class*="fm-bg-"] { padding: var(--fm-space-s); border-radius: var(--fm-radius); margin-bottom: var(--fm-space-s); }
}

/* ---------------------------------------------------------------- Components */
@layer components {
	/* Buttons. Variant tokens come from Site Settings (inc/buttons.php). */
	.fm-btn {
		display: inline-flex; align-items: center; justify-content: center; gap: .55em;
		padding: var(--fm-btn-pad, .8rem 1.4rem); font-family: var(--fm-font-button, inherit); font-size: var(--fm-btn-size, 1rem); font-weight: 700; line-height: 1.2;
		color: var(--fm-btn-text); background: var(--fm-btn-bg); border: var(--fm-btn-bw, 0) solid var(--fm-btn-border);
		border-radius: var(--fm-btn-radius, var(--fm-radius)); text-decoration: none; cursor: pointer;
		min-height: 44px; transition: background-color .15s, color .15s, border-color .15s;
	}
	.fm-btn:hover, .fm-btn:focus-visible { color: var(--fm-btn-hover-text); background: var(--fm-btn-hover-bg); border-color: var(--fm-btn-hover-border); text-decoration: none; }
	.fm-btn__icon { display: inline-grid; width: 1.15em; height: 1.15em; flex: none; }
	.fm-btn__icon svg, .fm-btn__icon img { width: 100%; height: 100%; }
	.fm-btn__icon--images img { grid-area: 1 / 1; }
	.fm-btn__img--hover { opacity: 0; }
	.fm-btn:hover .fm-btn__img--hover, .fm-btn:focus-visible .fm-btn__img--hover { opacity: 1; }
	.fm-btn:hover .fm-btn__img--initial, .fm-btn:focus-visible .fm-btn__img--initial { opacity: 0; }
	.fm-actions { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin: 0; }

	/* Prose from the editor and CMS slots. */
	.fm-prose > * + * { margin-top: 1em; }
	.fm-prose :is(h2, h3, h4) { margin-top: 1.6em; }
	.fm-prose :is(ul, ol) { padding-left: 1.25em; }
	.fm-prose li + li { margin-top: .35em; }
	.fm-prose img { border-radius: var(--fm-radius); }
	.fm-prose blockquote { border-left: 4px solid var(--fm-color-primary); padding-left: 1rem; font-size: var(--fm-step-1); }
	.fm-prose table { width: 100%; border-collapse: collapse; display: block; overflow-x: auto; }
	.fm-prose :is(th, td) { padding: .5rem .75rem; border-bottom: 1px solid var(--fm-rule); text-align: left; }

	/* Stars. */
	.fm-stars { display: inline-flex; gap: 2px; color: var(--fm-color-secondary); }
	.fm-star { width: 1.05em; height: 1.05em; opacity: .3; }
	.fm-star.is-on { opacity: 1; }
	.fm-star svg { width: 100%; height: 100%; }

	/* Coupon card (Coupons layout and service sidebar). */
	.fm-coupon { display: flex; flex-direction: column; gap: .6rem; padding: 1.5rem; border: 2px dashed color-mix(in srgb, var(--fm-color-primary) 55%, transparent); border-radius: var(--fm-radius); background: var(--fm-card-bg); color: var(--fm-card-text); }
	.fm-coupon__value { font-family: var(--fm-font-heading); font-size: var(--fm-step-4); font-weight: 800; line-height: 1; color: var(--fm-color-primary); margin: 0; }
	.fm-coupon__title { font-size: var(--fm-step-1); margin: 0; }
	.fm-coupon__text > * + * { margin-top: .5em; }
	.fm-coupon__expires { font-weight: 700; font-size: var(--fm-step-sm); margin: 0; }
	.fm-coupon .fm-actions { margin-top: auto; padding-top: .5rem; }
	.fm-coupon__disclaimer { font-family: var(--fm-font-caption); font-size: .8rem; opacity: .8; margin: 0; }
	.fm-coupon--compact .fm-coupon__value { font-size: var(--fm-step-3); }

	/* Carousel (reviews, coupons, logos): scroll-snap track with prev/next buttons. Works with no JS. */
	/* position: relative keeps absolutely positioned content in off-screen slides (screen-reader text) inside the track; without it the page scrolls sideways. */
	[data-fm-track] { position: relative; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(min(85%, 340px), 1fr); gap: 1.25rem; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; padding-bottom: .25rem; }
	[data-fm-track]::-webkit-scrollbar { display: none; }
	[data-fm-track] > * { scroll-snap-align: start; }
	.fm-logos [data-fm-track] { display: flex; }
	.fm-carousel__controls { display: flex; gap: .5rem; justify-content: flex-end; margin: 1rem 0 0; }
	.fm-carousel__btn { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; border: 2px solid currentColor; background: transparent; color: inherit; cursor: pointer; }
	.fm-carousel__btn:disabled { opacity: .35; cursor: default; }
	.fm-carousel__btn svg { width: 20px; height: 20px; }

	/* Contact details and hours. */
	.fm-contact-details { display: grid; gap: .9rem; }
	.fm-contact-details__item { display: flex; gap: .65rem; align-items: flex-start; margin: 0; }
	.fm-contact-details .fm-icon { flex: none; width: 1.2em; height: 1.2em; margin-top: .2em; }
	.fm-hours dl { display: grid; gap: .15rem; margin: 0; }
	.fm-hours dl div { display: flex; justify-content: space-between; gap: 1.5rem; }
	.fm-hours dt { font-weight: 600; }

	/* Forms (Gravity Forms' own CSS is off; this styles its markup from the tokens). */
	.gform_wrapper .gform_fields { display: grid; gap: 1rem; grid-template-columns: repeat(12, 1fr); list-style: none; margin: 0; padding: 0; border: 0; }
	.gform_wrapper .gfield { grid-column: span 12; }
	@media (min-width: 640px) { .gform_wrapper .gfield--width-half { grid-column: span 6; } .gform_wrapper .gfield--width-third { grid-column: span 4; } }
	.gform_wrapper .gfield_label, .gform_wrapper legend { display: block; font-weight: 700; margin-bottom: .35rem; }
	.gform_wrapper .gfield_required { color: #b32d2e; margin-left: .2em; }
	.gform_wrapper :is(input:not([type=checkbox]):not([type=radio]):not([type=submit]), select, textarea) {
		width: 100%; min-height: 48px; padding: .7rem .85rem; border: 1px solid color-mix(in srgb, var(--fm-color-dark) 35%, transparent);
		border-radius: calc(var(--fm-radius) * .75); background: var(--fm-color-white); color: var(--fm-color-dark);
	}
	/* Paragraph Text follows its Field Height (Small, Medium, Large). */
	.gform_wrapper textarea { resize: vertical; }
	.gform_wrapper textarea.small { height: 120px; }
	.gform_wrapper textarea.medium { height: 180px; }
	.gform_wrapper textarea.large { height: 260px; }
	.gform_wrapper :is(input, select, textarea):focus-visible { outline: 3px solid var(--fm-focus); outline-offset: 1px; border-color: var(--fm-color-primary); }
	.gform_wrapper .gfield_error :is(input, select, textarea) { border-color: #b32d2e; border-width: 2px; }
	.gform_wrapper .validation_message, .gform_wrapper .gform_validation_errors { color: #b32d2e; font-weight: 600; margin-top: .35rem; }
	.gform_wrapper .gfield_description { font-size: var(--fm-step-sm); margin-top: .35rem; }
	.gform_wrapper fieldset { border: 0; padding: 0; margin: 0; }
	.gform_wrapper .gform_footer { margin-top: 1.25rem; }
	.gform_wrapper :is(.gform_button, input[type=submit]) {
		display: inline-flex; min-height: 48px; padding: .8rem 1.6rem; border: 0; border-radius: var(--fm-radius); font-family: var(--fm-font-button, inherit); font-weight: 700; cursor: pointer;
		background: var(--fm-color-primary); color: var(--fm-on-primary);
	}
	.gform_wrapper .gform_hidden, .gform_wrapper .gfield--type-honeypot, .gform_wrapper .gform_validation_container { display: none !important; }

	.fm-notice { padding: 1rem; border: 2px dashed currentColor; border-radius: var(--fm-radius); }
}

/* ---------------------------------------------------------------- Header and footer */
@layer components {
	.fm-skip-link { position: absolute; left: 1rem; top: -100px; z-index: 1000; padding: .75rem 1rem; background: var(--fm-color-dark); color: var(--fm-color-white); border-radius: var(--fm-radius); }
	.fm-skip-link:focus { top: 1rem; }

	.fm-header { position: sticky; top: 0; z-index: 100; background: var(--fm-color-white); color: var(--fm-color-dark); box-shadow: 0 1px 0 var(--fm-rule); }
	.admin-bar .fm-header { top: var(--wp-admin--admin-bar--height, 32px); }
	.fm-header__inner { display: flex; align-items: center; gap: 1rem 1.5rem; min-height: 76px; }
	.fm-header__logo { flex: none; display: block; margin-right: auto; }
	.fm-logo { max-height: 56px; width: auto; }
	.fm-logo-text { font-family: var(--fm-font-heading); font-weight: 800; font-size: var(--fm-step-1); color: var(--fm-color-dark); text-decoration: none; }
	.fm-header__actions { display: flex; align-items: center; gap: .75rem; }
	.fm-header__hours { font-size: var(--fm-step-sm); font-weight: 600; margin: 0; }

	.fm-nav__list { display: flex; gap: .25rem; list-style: none; margin: 0; padding: 0; }
	.fm-nav__list a { display: block; padding: .6rem .75rem; color: inherit; font-weight: 600; text-decoration: none; border-radius: var(--fm-radius); }
	.fm-nav__list a:hover, .fm-nav__list .current-menu-item > a, .fm-nav__list .current-menu-ancestor > a { color: var(--fm-color-primary); }
	.fm-nav__list .current-menu-item > a { text-decoration: underline; text-underline-offset: .35em; }
	.fm-nav__list li { position: relative; }
	.fm-nav__list .sub-menu { list-style: none; margin: 0; padding: .5rem; min-width: 240px; background: var(--fm-color-white); border-radius: var(--fm-radius); box-shadow: 0 12px 32px rgb(0 0 0 / .14); }
	.fm-nav-toggle { display: none; place-items: center; width: 48px; height: 48px; padding: 0; border: 0; background: transparent; color: inherit; cursor: pointer; }
	.fm-nav-toggle svg { width: 28px; height: 28px; }
	.fm-nav-toggle__close { display: none; }
	.fm-nav-toggle[aria-expanded="true"] .fm-nav-toggle__open { display: none; }
	.fm-nav-toggle[aria-expanded="true"] .fm-nav-toggle__close { display: block; }

	/* Desktop dropdowns open on hover and keyboard focus. */
	@media (min-width: 1081px) {
		.fm-nav__list .sub-menu { position: absolute; top: 100%; left: 0; visibility: hidden; opacity: 0; transform: translateY(6px); transition: opacity .15s, transform .15s, visibility .15s; }
		.fm-nav__list li:hover > .sub-menu, .fm-nav__list li:focus-within > .sub-menu { visibility: visible; opacity: 1; transform: none; }
	}

	/* Mobile menu: full-width panel under the header. */
	@media (max-width: 1080px) {
		.fm-nav-toggle { display: inline-grid; }
		.fm-header__schedule, .fm-header__hours { display: none; }
		.fm-nav { position: absolute; top: 100%; left: 0; right: 0; max-height: calc(100vh - 76px); overflow-y: auto; background: var(--fm-color-white); box-shadow: 0 12px 24px rgb(0 0 0 / .12); padding: .5rem var(--fm-gutter) 1.5rem; }
		.fm-nav:not(.is-open) { display: none; }
		.fm-nav__list { flex-direction: column; }
		.fm-nav__list a { padding: .85rem .5rem; border-bottom: 1px solid var(--fm-rule); }
		.fm-nav__list .sub-menu { box-shadow: none; padding: 0 0 0 1rem; }
	}
	@media (max-width: 520px) {
		.fm-header__phone .fm-btn__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
		.fm-header__phone { padding: .7rem; }
	}

	.fm-footer { background: var(--fm-color-dark); color: var(--fm-on-dark); --fm-link: currentColor; padding-top: var(--fm-space-m); }
	.fm-footer__grid { display: grid; gap: 2rem 3rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); padding-bottom: var(--fm-space-s); }
	.fm-footer__logo img { max-height: 64px; width: auto; }
	.fm-footer__title { font-size: var(--fm-step-1); margin: 0 0 .75rem; }
	.fm-footer ul { list-style: none; margin: 0; padding: 0; }
	.fm-footer li + li { margin-top: .4rem; }
	.fm-footer a { text-decoration: none; }
	.fm-footer a:hover { text-decoration: underline; }
	.fm-social { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1.25rem !important; }
	.fm-social li + li { margin-top: 0; }
	.fm-social a { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; border: 1px solid color-mix(in srgb, currentColor 35%, transparent); }
	.fm-social svg, .fm-social img { width: 20px; height: 20px; }
	.fm-footer__legal { border-top: 1px solid color-mix(in srgb, currentColor 18%, transparent); padding-block: 1.25rem; font-size: var(--fm-step-sm); }
	.fm-footer__legal p { margin: 0; }

	/* Sidebar. */
	.fm-sidebar { display: grid; gap: 1.25rem; position: sticky; top: 100px; }
	.fm-sidebar__block { padding: 1.25rem; border-radius: var(--fm-radius); background: var(--fm-card-bg); color: var(--fm-card-text); }
	.fm-sidebar__block:has(.fm-coupon) { padding: 0; background: none; }
	.fm-sidebar__title { font-size: var(--fm-step-1); margin: 0 0 .75rem; }
	.fm-sidebar ul { list-style: none; margin: 0; padding: 0; }
	.fm-sidebar li a { display: block; padding: .45rem 0; border-bottom: 1px solid var(--fm-rule); }
	.fm-sidebar__cta { display: grid; gap: .75rem; background: var(--fm-color-primary); color: var(--fm-on-primary); }

	/* Blog. */
	.fm-post-grid { display: grid; gap: 1.5rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); list-style: none; margin: 0; padding: 0; }
	.fm-post-card { position: relative; border-radius: var(--fm-radius); overflow: hidden; background: var(--fm-card-bg); }
	.fm-post-card__image { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; }
	.fm-post-card__body { padding: 1.25rem; }
	.fm-post-card__title { font-size: var(--fm-step-1); }
	.fm-post-card__title a { color: inherit; text-decoration: none; }
	.fm-post-card__title a::after { content: ""; position: absolute; inset: 0; }
	.fm-post-card__meta { font-size: var(--fm-step-sm); opacity: .75; margin: .35rem 0 .5rem; }
}

/* ---------------------------------------------------------------- Utilities */
/* Form popups (inc/form-dialog.php): a Gravity Form in a <dialog>, in the site's colors and fonts. */
@layer components {
	.fm-dialog { width: min(640px, calc(100% - 2rem)); max-height: calc(100dvh - 2rem); padding: 0; border: 0; border-radius: var(--fm-radius); background: var(--fm-color-white); color: var(--fm-color-dark); box-shadow: 0 24px 60px rgb(0 0 0 / .3); overscroll-behavior: contain; }
	.fm-dialog::backdrop { background: color-mix(in srgb, var(--fm-color-dark) 70%, transparent); }
	.fm-dialog__panel { position: relative; padding: clamp(1.5rem, 5vw, 2.75rem); }
	.fm-dialog__title { margin: 0 3rem .5rem 0; font-family: var(--fm-font-heading); font-size: var(--fm-step-2); line-height: 1.15; text-wrap: balance; }
	.fm-dialog__text { margin: 0 0 1.25rem; text-wrap: pretty; }
	.fm-dialog__close { position: absolute; top: 1rem; right: 1rem; display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: var(--fm-color-light); color: var(--fm-color-dark); cursor: pointer; }
	.fm-dialog__close svg { width: 20px; height: 20px; }
	.fm-dialog__close:hover { background: var(--fm-color-secondary); color: var(--fm-on-secondary); }
	html:has(.fm-dialog[open]) { overflow: hidden; }
	@media (prefers-reduced-motion: no-preference) {
		.fm-dialog[open] { animation: fm-dialog-in .25s ease; }
		@keyframes fm-dialog-in { from { opacity: 0; transform: translateY(12px); } }
	}
}

@layer utilities {
	.screen-reader-text { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
	.screen-reader-text:focus { position: static !important; width: auto; height: auto; clip: auto; }
	[hidden] { display: none !important; }
}
