/*
 * Insight K9 Solutions — sitewide phone refinement layer.
 *
 * These rules are intentionally conservative: desktop and tablet remain under
 * Elementor/theme control, while phones receive consistent type, spacing,
 * touch targets, cards, forms, and overflow protection.
 */

@media (max-width: 767px) {
	body.ik9-mobile-polish {
		--ik9-mobile-gutter: clamp(16px, 5vw, 22px);
		--ik9-mobile-section: clamp(38px, 11vw, 58px);
		--ik9-mobile-radius: 18px;
		--ik9-mobile-red: #d71920;
		--ik9-mobile-ink: #151515;
		--ik9-mobile-muted: #555555;
		--ik9-mobile-line: #dedede;
		--ik9-mobile-paper: #ffffff;
		--ik9-mobile-soft: #f5f5f3;
	}

	/* Prevent common Elementor flex/grid children from forcing horizontal scroll. */
	body.ik9-mobile-polish #content,
	body.ik9-mobile-polish #content .elementor,
	body.ik9-mobile-polish #content .e-con,
	body.ik9-mobile-polish #content .e-con-inner,
	body.ik9-mobile-polish #content .elementor-element,
	body.ik9-mobile-polish #content .elementor-widget-container {
		max-width: 100%;
		min-width: 0;
	}

	body.ik9-mobile-polish #content img,
	body.ik9-mobile-polish #content svg,
	body.ik9-mobile-polish #content video,
	body.ik9-mobile-polish #content canvas {
		max-width: 100%;
		height: auto;
	}

	body.ik9-mobile-polish #content :where(p, li, dd, figcaption, address, a) {
		overflow-wrap: anywhere;
	}

	/* A calm, repeatable type scale prevents one-word lines and giant archive titles. */
	body.ik9-mobile-polish #content :where(h1, .elementor-widget-heading h1.elementor-heading-title) {
		font-size: clamp(2rem, 9.8vw, 2.75rem) !important;
		line-height: 1.06 !important;
		letter-spacing: -0.035em !important;
		text-wrap: balance;
	}

	body.ik9-mobile-polish #content :where(h2, .elementor-widget-heading h2.elementor-heading-title) {
		font-size: clamp(1.7rem, 7.7vw, 2.25rem) !important;
		line-height: 1.12 !important;
		letter-spacing: -0.025em !important;
		text-wrap: balance;
	}

	body.ik9-mobile-polish #content :where(h3, .elementor-widget-heading h3.elementor-heading-title) {
		font-size: clamp(1.3rem, 5.8vw, 1.7rem) !important;
		line-height: 1.18 !important;
		letter-spacing: -0.015em !important;
		text-wrap: balance;
	}

	body.ik9-mobile-polish #content :where(.elementor-widget-text-editor, .elementor-widget-theme-post-content) {
		font-size: 16px;
		line-height: 1.65;
	}

	body.ik9-mobile-polish #content :where(.elementor-widget-text-editor, .elementor-widget-theme-post-content) p:last-child {
		margin-bottom: 0;
	}

	/* Buttons stay tappable and readable without turning every action into a red block. */
	body.ik9-mobile-polish #content :where(.elementor-button, .wp-element-button, .wp-block-button__link, button, input[type="submit"]) {
		max-width: 100%;
		min-height: 48px;
		padding: 13px 20px;
		border-radius: 10px;
		font-size: 16px;
		font-weight: 700;
		line-height: 1.25;
		white-space: normal;
		text-align: center;
	}

	body.ik9-mobile-polish #content :where(a, button, input, select, textarea):focus-visible,
	body.ik9-mobile-polish .ik9-site-footer :where(a, button):focus-visible {
		outline: 3px solid rgba(215, 25, 32, 0.52);
		outline-offset: 3px;
	}

	/* Forms use the available width and do not trigger iOS zoom on focus. */
	body.ik9-mobile-polish #content :where(form, fieldset, .elementor-form-fields-wrapper, .elementor-field-group) {
		max-width: 100%;
		min-width: 0;
	}

	body.ik9-mobile-polish #content :where(input:not([type="checkbox"]):not([type="radio"]), select, textarea) {
		width: 100%;
		max-width: 100%;
		min-width: 0;
		min-height: 48px;
		font-size: 16px;
		line-height: 1.4;
	}

	body.ik9-mobile-polish #content textarea {
		min-height: 120px;
		resize: vertical;
	}

	body.ik9-mobile-polish #content :where(iframe, embed, object) {
		display: block;
		width: 100%;
		max-width: 100%;
	}

	/* Shared custom card grids collapse predictably instead of becoming cramped columns. */
	body.ik9-mobile-polish #content :where(
		[class*="ik9-"][class*="grid"],
		[class*="ik9_"][class*="grid"],
		[class*="ohah-"][class*="grid"],
		[class*="training-"][class*="grid"],
		[class*="health-"][class*="grid"]
	) {
		grid-template-columns: minmax(0, 1fr) !important;
		gap: 16px !important;
	}

	body.ik9-mobile-polish #content :where(
		[class*="ik9-"][class*="card"],
		[class*="ohah-"][class*="card"],
		[class*="training-"][class*="card"],
		[class*="health-"][class*="card"]
	) {
		max-width: 100%;
		min-width: 0;
		border-radius: var(--ik9-mobile-radius);
	}

	/* Compact the custom footer while preserving its established card design. */
	body.ik9-mobile-polish .ik9-site-footer {
		padding: 32px 14px 18px !important;
	}

	body.ik9-mobile-polish .ik9-site-footer-grid {
		gap: 12px !important;
	}

	body.ik9-mobile-polish .ik9-site-footer-card {
		padding: 21px 18px !important;
		border-radius: 16px !important;
	}

	body.ik9-mobile-polish .ik9-site-footer-list {
		gap: 5px !important;
	}

	body.ik9-mobile-polish .ik9-site-footer a {
		min-height: 42px;
	}

	body.ik9-mobile-polish .ik9-site-footer-legal,
	body.ik9-mobile-polish .ik9-site-footer-legal-links {
		gap: 8px 14px !important;
		text-align: center;
	}

	body.ik9-mobile-polish .ik9-site-footer-legal-links {
		display: flex;
		flex-wrap: wrap;
		justify-content: center;
	}
}

/* Services and locations: preserve full-bleed sections but normalize content rhythm. */
@media (max-width: 767px) {
	body:is(.ik9-mobile-polish--service, .ik9-mobile-polish--location) #content :where(
		[class*="service-"][class*="card"],
		[class*="location-"][class*="card"],
		[class*="program-"][class*="card"]
	) {
		padding: clamp(20px, 6vw, 28px) !important;
		box-shadow: 0 10px 28px rgba(0, 0, 0, 0.1);
	}

	body:is(.ik9-mobile-polish--service, .ik9-mobile-polish--location) #content :where(
		[class*="service-"][class*="actions"],
		[class*="location-"][class*="actions"],
		[class*="cta-"][class*="buttons"]
	) {
		display: flex;
		flex-direction: column;
		align-items: stretch;
		gap: 10px !important;
	}

	body:is(.ik9-mobile-polish--service, .ik9-mobile-polish--location) #content :where(
		[class*="service-"][class*="actions"],
		[class*="location-"][class*="actions"],
		[class*="cta-"][class*="buttons"]
	) :where(a, button) {
		width: 100%;
	}
}

/* Team: bios remain readable and trainer imagery cannot overflow narrow screens. */
@media (max-width: 767px) {
	body.ik9-mobile-polish--team #content :where(
		[class*="trainer-"][class*="grid"],
		[class*="team-"][class*="grid"],
		[class*="bio-"][class*="grid"]
	) {
		grid-template-columns: minmax(0, 1fr) !important;
		gap: 22px !important;
	}

	body.ik9-mobile-polish--team #content :where(
		[class*="trainer-"][class*="card"],
		[class*="team-"][class*="card"],
		[class*="trainer-"][class*="bio"]
	) {
		padding: clamp(20px, 6vw, 28px) !important;
	}

	body.ik9-mobile-polish--team #content :where(
		[class*="trainer-"] img,
		[class*="team-member"] img,
		[class*="staff-"] img
	) {
		display: block;
		width: 100%;
		max-width: 460px;
		margin-inline: auto;
		border-radius: var(--ik9-mobile-radius);
	}
}

/* Training Library: taxonomy headings, filters, and article cards stack cleanly. */
@media (max-width: 767px) {
	body.ik9-mobile-polish--training-library #content :where(
		[class*="library-"][class*="hero"],
		[class*="archive-"][class*="hero"],
		[class*="taxonomy-"][class*="hero"],
		[class*="training-"][class*="hero"]
	) {
		padding: var(--ik9-mobile-section) var(--ik9-mobile-gutter) !important;
	}

	body.ik9-mobile-polish--training-library #content :where(
		[class*="library-"][class*="filters"],
		[class*="archive-"][class*="filters"],
		[class*="training-"][class*="filters"],
		[class*="library-"][class*="search"]
	) {
		display: flex !important;
		flex-direction: column !important;
		align-items: stretch !important;
		gap: 10px !important;
	}

	body.ik9-mobile-polish--training-library #content :where(
		[class*="library-"][class*="card"],
		[class*="article-"][class*="card"],
		[class*="training-"][class*="card"]
	) {
		overflow: hidden;
		padding: clamp(18px, 5.5vw, 24px) !important;
	}

	body.ik9-mobile-polish--training-library #content :where(
		[class*="article-"][class*="content"],
		[class*="post-"][class*="content"],
		.elementor-widget-theme-post-content
	) :where(ul, ol) {
		padding-left: 1.25em;
	}
}

/* K9 Health pages and tools: cards, controls, and wide reference data stay usable. */
@media (max-width: 767px) {
	body.ik9-mobile-polish--health-library #content :where(
		[class*="ohah-"][class*="hero"],
		[class*="k9-health"][class*="hero"],
		[class*="health-"][class*="hero"]
	) {
		padding: var(--ik9-mobile-section) var(--ik9-mobile-gutter) !important;
	}

	body.ik9-mobile-polish--health-library #content :where(
		[class*="ohah-"][class*="card"],
		[class*="k9-health"][class*="card"],
		[class*="health-"][class*="card"],
		[class*="tool-"][class*="panel"]
	) {
		padding: clamp(18px, 5.5vw, 24px) !important;
	}

	body.ik9-mobile-polish--health-library #content :where(
		[class*="ohah-"][class*="controls"],
		[class*="health-"][class*="controls"],
		[class*="tool-"][class*="controls"],
		[class*="calculator-"][class*="fields"]
	) {
		display: grid !important;
		grid-template-columns: minmax(0, 1fr) !important;
		gap: 12px !important;
	}

	body.ik9-mobile-polish--health-library #content :where(table, .wp-block-table, pre) {
		display: block;
		width: 100%;
		max-width: 100%;
		overflow-x: auto;
		-webkit-overflow-scrolling: touch;
	}
}

/* Booking pages: contain third-party widgets without restyling their internals. */
@media (max-width: 767px) {
	body.ik9-mobile-polish--booking #content :where(
		[class*="booking-"][class*="wrap"],
		[class*="appointment-"][class*="wrap"],
		[class*="scheduler-"][class*="wrap"],
		[class*="amelia-app-booking"]
	) {
		width: 100% !important;
		max-width: 100% !important;
		min-width: 0 !important;
		margin-inline: auto !important;
	}

	body.ik9-mobile-polish--booking #content :where(
		[class*="booking-"][class*="columns"],
		[class*="appointment-"][class*="columns"]
	) {
		display: grid !important;
		grid-template-columns: minmax(0, 1fr) !important;
		gap: 16px !important;
	}
}

/* Legal pages: long headings, links, tables, and the contents list remain scannable. */
@media (max-width: 767px) {
	body.ik9-mobile-polish--legal #content :where(
		.elementor-widget-theme-post-content,
		.elementor-widget-text-editor,
		.entry-content
	) {
		overflow-wrap: anywhere;
	}

	body.ik9-mobile-polish--legal #content :where(
		#toc_container,
		.elementor-toc__body,
		[class*="table-of-contents"],
		[class*="legal-"][class*="summary"]
	) {
		width: 100% !important;
		max-width: 100% !important;
		padding: 18px !important;
		border-radius: 14px;
	}

	body.ik9-mobile-polish--legal #content :where(table, .wp-block-table, pre) {
		display: block;
		width: 100%;
		max-width: 100%;
		overflow-x: auto;
		-webkit-overflow-scrolling: touch;
	}

	body.ik9-mobile-polish--legal #content :where(code, pre) {
		white-space: pre-wrap;
		word-break: break-word;
	}
}

@media (max-width: 360px) {
	body.ik9-mobile-polish {
		--ik9-mobile-gutter: 14px;
	}

	body.ik9-mobile-polish #content :where(h1, .elementor-widget-heading h1.elementor-heading-title) {
		font-size: 1.9rem !important;
	}

	body.ik9-mobile-polish .ik9-site-footer-card {
		padding-inline: 16px !important;
	}
}

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