/**
 * AgriBio mobile visual pass.
 * Loaded last so these rules stay predictable across the theme's specialist layouts.
 */

@media (max-width: 767px) {
	/* Prevent a single wide component from moving the whole page sideways. */
	html,
	body {
		max-width: 100%;
		overflow-x: clip;
	}

	/* Header: comfortable touch targets and a menu that fits the real viewport. */
	.header-inner {
		min-height: 60px !important;
	}

	.menu-toggle,
	.header-search-toggle {
		width: 44px !important;
		min-width: 44px !important;
		height: 44px !important;
		min-height: 44px !important;
	}

	.main-navigation {
		position: fixed !important;
		top: 60px !important;
		left: 0 !important;
		right: 0 !important;
		width: auto !important;
		max-height: calc(100dvh - 60px);
		padding: 10px 14px 14px !important;
		overflow-y: auto;
		transform: none !important;
		z-index: 1000;
	}

	body.admin-bar .main-navigation {
		top: 106px !important;
		max-height: calc(100dvh - 106px);
	}

	.main-navigation a {
		display: flex;
		align-items: center;
		min-height: 44px;
		padding: 9px 0 !important;
		font-size: 15px !important;
	}

	/* Small support text remains legible without making the bar visually heavy. */
	.academic-context-bar__inner {
		gap: 5px 10px !important;
		padding-block: 7px !important;
		font-size: 13px !important;
		line-height: 1.45;
	}

	.academic-context-bar__text,
	.academic-context-bar__link {
		font-size: 13px !important;
	}

	.breadcrumb,
	.archive-hero .breadcrumb,
	.guide-wiki .breadcrumb,
	.single-nutrition .nutrition-single-header .breadcrumb,
	.single-microbe .single-microbe-header .breadcrumb,
	.glossary-hero .breadcrumb {
		font-size: 12.5px !important;
		line-height: 1.55 !important;
	}

	/* Horizontal navigation should feel like a swipe rail, not a desktop scrollbar. */
	.wiki-hub-nav__links,
	.filter-tabs,
	.hub-filter-tabs {
		overscroll-behavior-inline: contain;
		scrollbar-width: none !important;
		-webkit-overflow-scrolling: touch;
	}

	.wiki-hub-nav__links::-webkit-scrollbar,
	.filter-tabs::-webkit-scrollbar,
	.hub-filter-tabs::-webkit-scrollbar {
		display: none;
	}

	.wiki-hub-nav__inner {
		padding-top: 8px !important;
	}

	.wiki-hub-nav__links {
		padding: 7px 0 10px !important;
	}

	.wiki-hub-nav__link,
	.filter-tabs button,
	.hub-filter-tabs button {
		display: inline-flex !important;
		align-items: center;
		justify-content: center;
		min-height: 44px;
		font-size: 13.5px !important;
		white-space: nowrap;
	}

	/* Keep all five homepage filters visible instead of clipping the last pill. */
	.home .featured-section .filter-tabs {
		width: 100%;
		gap: 5px !important;
		overflow-x: visible !important;
	}

	.home .featured-section .filter-tabs button {
		flex: 0 1 auto;
		min-width: 0;
		padding: 8px 8px !important;
		font-size: 12.5px !important;
	}

	/* Home: reduce dead space and improve scanning/readability. */
	.hero-copy {
		padding: 38px 0 20px !important;
	}

	.hero-grid {
		gap: 8px !important;
	}

	.hero-description {
		font-size: 16px !important;
		line-height: 1.65 !important;
	}

	.suggestions a {
		display: inline-flex;
		align-items: center;
		min-height: 38px;
		padding-inline: 12px !important;
		font-size: 13px !important;
	}

	.topic-card {
		padding: 20px !important;
	}

	.topic-card .topic-icon {
		margin-bottom: 14px !important;
	}

	.topic-card p {
		font-size: 15px !important;
		line-height: 1.62 !important;
	}

	.topic-card > a {
		display: inline-flex;
		align-items: center;
		min-height: 44px;
		font-size: 14px !important;
	}

	.featured-grid {
		gap: 14px !important;
	}

	.featured-grid .content-card,
	.featured-grid > div:nth-child(n) .content-card {
		min-height: 188px !important;
		flex-direction: row !important;
	}

	.featured-grid .card-image {
		width: 38% !important;
		min-width: 38% !important;
		height: auto !important;
	}

	.featured-grid .card-body {
		width: 62% !important;
		padding: 14px 14px 15px !important;
	}

	.featured-grid .card-body h3 {
		font-size: 16px !important;
		line-height: 1.38 !important;
	}

	.featured-grid .card-body p {
		font-size: 13.5px !important;
		line-height: 1.5 !important;
	}

	.featured-grid .card-date {
		font-size: 12.5px !important;
	}

	.quick-panel-desc,
	.quick-link-meta {
		font-size: 13px !important;
	}

	.quick-panel-footer {
		display: flex;
		align-items: center;
		min-height: 48px;
	}

	/* Directory controls: enlarge the tap area without making inputs bulky. */
	.filter-search-box input {
		height: 50px !important;
		padding-right: 52px !important;
		font-size: 14px !important;
	}

	.filter-search-box button {
		right: 3px !important;
		width: 44px !important;
		height: 44px !important;
		padding: 0 !important;
	}

	/* Keep every directory filter on one swipeable row on phones. */
	.hub-filter-card .filter-form-grid,
	.hub-filter-card .nutrition-filter-grid,
	.hub-filter-card .dictionary-filter-grid {
		display: grid !important;
		grid-auto-flow: column !important;
		grid-auto-columns: minmax(152px, 46vw) !important;
		grid-template-columns: none !important;
		align-items: end !important;
		gap: 10px !important;
		width: 100% !important;
		max-width: 100% !important;
		padding-bottom: 3px;
		overflow-x: auto !important;
		overflow-y: hidden !important;
		overscroll-behavior-inline: contain;
		scroll-snap-type: inline proximity;
		scrollbar-width: none;
		-webkit-overflow-scrolling: touch;
	}

	.hub-filter-card .filter-form-grid::-webkit-scrollbar,
	.hub-filter-card .nutrition-filter-grid::-webkit-scrollbar,
	.hub-filter-card .dictionary-filter-grid::-webkit-scrollbar {
		display: none;
	}

	.hub-filter-card .filter-form-grid > *,
	.hub-filter-card .nutrition-filter-grid > *,
	.hub-filter-card .dictionary-filter-grid > * {
		min-width: 0 !important;
		width: 100% !important;
		scroll-snap-align: start;
	}

	.hub-filter-card .filter-form-grid select,
	.hub-filter-card .dictionary-filter-grid select {
		height: 48px !important;
	}

	.favorite-btn,
	.view-switch-btns button,
	.grid-view-btn,
	.list-view-btn {
		width: 42px !important;
		height: 42px !important;
		min-width: 42px !important;
		min-height: 42px !important;
	}

	.plant-card-image-wrap {
		height: 190px !important;
	}

	.plant-card-content {
		padding: 18px !important;
	}

	.feature-item,
	.plant-quick-features {
		font-size: 13.5px !important;
	}

	/* Plant cards: light, water and difficulty stay on one compact row. */
	.hub-cay-trong .plant-quick-features,
	.hub-theme-cay-trong .plant-quick-features {
		display: grid !important;
		grid-template-columns: repeat(3, minmax(0, auto)) !important;
		align-items: center !important;
		justify-content: space-between !important;
		gap: 6px !important;
	}

	.hub-cay-trong .plant-quick-features .feature-item,
	.hub-theme-cay-trong .plant-quick-features .feature-item {
		min-width: 0;
		gap: 3px !important;
		font-size: 11.5px !important;
		white-space: nowrap;
	}

	.hub-cay-trong .plant-quick-features .feature-item svg,
	.hub-theme-cay-trong .plant-quick-features .feature-item svg {
		flex: 0 0 14px;
		width: 14px !important;
		height: 14px !important;
	}

	.diagnostic-group-box {
		padding: 17px !important;
	}

	.diagnostic-group-header h3 {
		font-size: 16px !important;
	}

	.diagnostic-symptom-chip {
		display: inline-flex !important;
		align-items: center;
		min-height: 38px;
		padding: 7px 12px !important;
		font-size: 13px !important;
		line-height: 1.25;
	}

	.alphabet {
		gap: 6px !important;
	}

	.alphabet a {
		min-width: 38px !important;
		height: 38px !important;
		padding-inline: 7px !important;
		font-size: 13px !important;
	}

	.dictionary .alphabet a,
	.hub-thuat-ngu .alphabet a,
	.hub-theme-thuat-ngu .alphabet a {
		min-width: 38px !important;
		height: 38px !important;
		font-size: 13px !important;
	}

	.page-numbers {
		min-width: 40px;
		height: 40px;
	}

	/* Article actions should be reliably tappable. */
	.share-icon-links a,
	.share-icon-links button,
	.single-post-redesign .share-icon-links a,
	.single-post-redesign .share-icon-links button {
		width: 42px !important;
		height: 42px !important;
		min-width: 42px !important;
		min-height: 42px !important;
	}

	.cite-button,
	.cite-toggle,
	.article-share-bar button {
		min-height: 42px;
	}

	/* Wide scientific tables scroll inside the article, never at page level. */
	.entry-content table,
	.entry-content-table,
	.diagnostic-table-scientific,
	.single-microbe .microbe-article-body table {
		display: block !important;
		width: 100% !important;
		max-width: 100% !important;
		overflow-x: auto !important;
		overscroll-behavior-inline: contain;
		scrollbar-width: thin;
		-webkit-overflow-scrolling: touch;
	}

	.entry-content pre,
	.entry-content code {
		max-width: 100%;
		overflow-wrap: anywhere;
	}

	.entry-content figure.wp-block-table {
		display: block !important;
		width: 100% !important;
		max-width: 100% !important;
		overflow-x: auto !important;
		overscroll-behavior-inline: contain;
		-webkit-overflow-scrolling: touch;
	}

	.entry-content figure.wp-block-table > table {
		display: table !important;
		max-width: none !important;
		overflow: visible !important;
	}

	.entry-content > table.entry-content-table {
		display: table !important;
		width: 100% !important;
		min-width: 100% !important;
		max-width: 100% !important;
		table-layout: fixed;
		overflow: visible !important;
	}

	/* Tighter single-plant introduction; content begins sooner on small screens. */
	.single-plant-header {
		padding: 28px 0 26px !important;
	}

	.single-plant-container {
		padding-top: 26px !important;
	}

	/* Keep the legacy plant TOC compact and full-width instead of a tall desktop sidebar. */
	.single-cay-trong .post-sidebar-area {
		width: 100% !important;
		min-width: 0 !important;
		max-width: none !important;
		gap: 16px !important;
	}

	.single-cay-trong .plant-toc-box {
		width: 100% !important;
		border-radius: 10px !important;
		box-shadow: none !important;
	}

	.single-cay-trong .plant-toc-box .sidebar-box-header {
		padding: 12px 14px !important;
	}

	.single-cay-trong .plant-toc-box .sidebar-box-header h3 {
		justify-content: flex-start !important;
		font-size: 14px !important;
	}

	.single-cay-trong .plant-toc-box .sidebar-box-content {
		padding: 12px !important;
	}

	.single-cay-trong .plant-toc-box .toc-list {
		display: grid !important;
		grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
		gap: 7px !important;
	}

	.single-cay-trong .plant-toc-box .toc-list li {
		min-width: 0 !important;
		gap: 8px !important;
		padding: 9px 8px !important;
		border: 1px solid #e3ebe5 !important;
		border-radius: 8px !important;
		background: #fff !important;
	}

	.single-cay-trong .plant-toc-box .toc-list li.active {
		border-color: #b8d7c0 !important;
		background: #f3f8f4 !important;
		box-shadow: inset 3px 0 0 var(--color-primary) !important;
	}

	.single-cay-trong .plant-toc-box .toc-list li span.num {
		display: grid !important;
		flex: 0 0 24px !important;
		place-items: center !important;
		width: 24px !important;
		height: 24px !important;
		border-radius: 7px !important;
		background: #d9f3e5 !important;
		font-size: 12px !important;
	}

	.single-cay-trong .plant-toc-box .toc-list li a {
		min-width: 0 !important;
		font-size: 12.5px !important;
		line-height: 1.35 !important;
	}

	/* Archive author pages have no toolbar, so the default gap is excessive. */
	body.author .archive-listing {
		padding-top: 28px !important;
	}

	/* Legacy information pages contain an oversized historical logo. */
	body.page-id-1602 .entry-content img,
	body.page-id-2568 .entry-content img {
		display: block;
		width: min(100%, 260px) !important;
		height: auto !important;
		margin: 24px auto !important;
	}

	body.page-id-1602 .entry-content,
	body.page-id-2568 .entry-content {
		font-size: 16px;
		line-height: 1.75;
	}
}

/* Clean, self-contained search icon for every directory filter. */
.filter-search-box button[type="submit"] {
	right: 6px !important;
	width: 36px !important;
	height: 36px !important;
	padding: 0 !important;
	border: 0 !important;
	border-radius: 9px !important;
	background-color: transparent !important;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23566b5e' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='10.8' cy='10.8' r='6.8'/%3E%3Cpath d='m16 16 4.2 4.2'/%3E%3C/svg%3E") !important;
	background-repeat: no-repeat !important;
	background-position: center !important;
	background-size: 20px 20px !important;
	box-shadow: none !important;
	transition: background-color .18s ease, transform .18s ease !important;
}

.filter-search-box button[type="submit"] svg {
	display: none !important;
}

.filter-search-box button[type="submit"]::before,
.filter-search-box button[type="submit"]::after {
	display: none !important;
	content: none !important;
}

.filter-search-box button[type="submit"]:hover,
.filter-search-box button[type="submit"]:focus-visible {
	background-color: #edf5ef !important;
	outline: none !important;
	box-shadow: 0 0 0 3px rgba(31, 94, 59, .10) !important;
}

.hub-search-bar .hub-search-submit[type="submit"] {
	width: 38px !important;
	height: 38px !important;
	border-radius: 10px !important;
	background-color: var(--hub-primary) !important;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='10.8' cy='10.8' r='6.8'/%3E%3Cpath d='m16 16 4.2 4.2'/%3E%3C/svg%3E") !important;
	background-size: 19px 19px !important;
}

.hub-search-bar .hub-search-submit[type="submit"]:hover,
.hub-search-bar .hub-search-submit[type="submit"]:focus-visible {
	background-color: var(--hub-accent) !important;
	box-shadow: 0 5px 14px var(--hub-glow) !important;
}

/* Nutrition & soil directory uses a standalone search button. */
.filter-search-btn[type="submit"] {
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='10.8' cy='10.8' r='6.8'/%3E%3Cpath d='m16 16 4.2 4.2'/%3E%3C/svg%3E") !important;
	background-repeat: no-repeat !important;
	background-position: center !important;
	background-size: 20px 20px !important;
	box-shadow: none !important;
}

.filter-search-btn[type="submit"] svg,
.filter-search-btn[type="submit"]::before,
.filter-search-btn[type="submit"]::after {
	display: none !important;
	content: none !important;
}

.filter-search-btn[type="submit"]:focus-visible {
	outline: none !important;
	box-shadow: 0 0 0 3px rgba(4, 120, 87, .18) !important;
}

/* Refined card titles on the microbe & process directory. */
.hub-vi-sinh .microbe-card .microbe-card-title {
	margin: 0 0 8px !important;
	font-size: clamp(20px, 1.55vw, 23px) !important;
	font-weight: 650 !important;
	line-height: 1.3 !important;
	letter-spacing: -.012em !important;
}

.hub-vi-sinh .microbe-card .microbe-card-title a {
	color: var(--hub-heading) !important;
}

@media (max-width: 380px) {
	.container,
	.narrow-content {
		width: min(calc(100% - 24px), var(--container)) !important;
	}

	.custom-logo-link {
		max-width: 148px !important;
	}

	.hero h1 {
		font-size: 34px !important;
	}

	.featured-grid .card-image {
		width: 36% !important;
		min-width: 36% !important;
	}

	.featured-grid .card-body {
		width: 64% !important;
		padding-inline: 12px !important;
	}

	.single-microbe .single-microbe-header h1,
	.single-nutrition .nutrition-single-title,
	.single-nutrition .nutrition-single-header h1 {
		font-size: 29px !important;
	}
}
