/*
 * The filter column of the search results page on a phone (blocks/search).
 *
 * On a wide screen the column keeps its desktop shape and this file changes nothing except the size of
 * the facet rows. On a phone the column becomes the site's own accordion — the one the mobile main menu
 * uses (smartyV2/templates/general-includes/tab-content.html, opened by common.v2.js with
 * .mobile_menu_trigger / .mobile_menu_wrapper and the .plus box) — opened from an orange «فیلترها»
 * button above the results, one item open at a time. The markup is in
 * blocks/search/templates/gp/search/includes/expand-limit.html, the state is set by
 * blocks/search/assets/js/mobile-filters.js.
 */

/* Nothing below this point reaches a browser that never ran mobile-filters.js: the accordion heads stay
   hidden and the filter column simply stacks, so a browser without JS still has every facet. */

/* The phone chrome is off at every width by default; only the media query below puts it on, and only
   when mobile-filters.js has marked the document. */
.search-mobile-bar,
.search-acc-head {
	display: none;
}

/* The sort slot is empty whenever the sort controls were not moved into it — at a wide screen, and on a
   page that draws no sort row above its results. It carries the product-filter class so the CSS of the
   switch reaches it, and that class makes an empty div an 11px box with a 20px margin under it. */
#search-drawer-sort-slot:empty {
	display: none;
}

@media (max-width: 767px) {
	/* ---- the bar above the results: the button and the two view icons ---- */
	.search-mobile-bar {
		align-items: center;
		display: flex;
		justify-content: space-between;
		margin-bottom: 10px;
		width: 100%;
	}

	/* The line the wide row draws under itself — .product-filter carries border-bottom: 1px solid #f0f0f0.
	   It belongs to the closed state: once the panel is open it frames itself, and a line between the bar
	   and that frame is one line too many. */
	html.search-js .search-mobile-bar {
		border-bottom: 1px solid #f0f0f0;
		padding-bottom: 10px;
	}

	html.search-js body.search-filters-open .search-mobile-bar {
		border-bottom: 0;
		padding-bottom: 0;
	}

	.search-filter-button {
		align-items: center;
		background-color: #ff9900;
		border: 1px solid #ff9900;
		border-radius: 6px;
		color: #ffffff;
		display: flex;
		font-family: inherit;
		font-size: 14px;
		height: 42px;
		padding: 0 14px;
	}

	.search-filter-button:hover,
	.search-filter-button:focus {
		background-color: #ffffff;
		border-color: #ff9900;
		color: #ff9900;
	}

	.search-filter-button i.fa-filter {
		font-size: 15px;
		margin-left: 7px;
	}

	/* the caret of the button is the other half of «it opens downwards» */
	.search-filter-caret {
		font-size: 14px;
		margin-left: 0;
		margin-right: 8px;
	}

	html.search-js body.search-filters-open .search-filter-caret {
		transform: rotate(180deg);
	}

	.search-mobile-view .display {
		display: inline-block;
		margin: 0;
	}

	.search-mobile-view #grid_view_icon,
	.search-mobile-view #list_view_icon {
		display: inline-block;
		font-size: 16px;
		height: 40px;
		line-height: 38px;
		margin-left: 4px;
		margin-right: 0;
		width: 40px;
	}

	/* The row above the results on the wide screen; on a phone its two controls live in the accordion
	   and what is left of it (.limit, .compare-link) is .mobile_hide anyway. */
	html.search-js #content > .product-filter {
		display: none;
	}

	/* ---- the panel: closed until the button opens it, and framed like the desktop column's own box ----
	   The same 1px #eee / 5px radius as the frame .search-drawer-body carries inline at a wide screen, with
	   10px inside it; that inline frame is zeroed below, so this is the only frame around the stack. */
	html.search-js .search-filters-panel {
		border: 1px solid #eee;
		border-radius: 5px;
		display: none;
		padding: 10px;
	}

	/* the desktop frame and the desktop titles: the accordion heads say the same words. The -7px top
	   margin of .box-content and the inline padding-top of the first one are what put an uneven gap
	   between two heads, so here the heads sit flush against each other the way .mobile_menu li do. */
	html.search-js #column-left .box,
	html.search-js #column-left .box .box-content {
		margin: 0;
		padding: 0 !important;
	}

	html.search-js #column-left .box-heading,
	html.search-js #column-left .search-legacy-label,
	html.search-js #column-left .search-drawer-body hr {
		display: none;
	}

	html.search-js .search-drawer-body {
		border: 0 !important;
		border-radius: 0 !important;
		padding: 0 !important;
	}

	/* a page that draws no sort row above its results has nothing to put in that item */
	html.search-js .search-acc-none {
		display: none !important;
	}

	/* ---- the accordion heads, in the mobile main menu's own look ---- */
	.search-acc-head {
		align-items: center;
		background-color: #F0F0F2;
		border: 0;
		border-top: 1px solid #ffffff;
		color: #222222;
		cursor: pointer;
		font-family: inherit;
		font-size: inherit; /* the size a .mobile_menu li gets: the page's own */
		min-height: 50px;
		padding: 12px 20px 12px 60px; /* room for the .plus box */
		position: relative;
		text-align: right;
		width: 100%;
	}

	html.search-js .search-acc-head {
		display: flex;
	}

	.search-acc-head .plus {
		align-items: center;
		border-left: 1px solid #ffffff;
		display: flex;
		font-size: 14px;
		height: 100%;
		justify-content: center;
		left: 0;
		position: absolute;
		top: 0;
		width: 50px;
	}

	/* the two glyphs swap on the open item, as .mobile_menu .plus does */
	.search-acc-head .plus .fa-minus {
		font-size: 0;
	}

	.search-acc-item.is-open > .search-acc-head .plus .fa-plus {
		font-size: 0;
	}

	.search-acc-item.is-open > .search-acc-head .plus .fa-minus {
		font-size: 14px;
	}

	.search-acc-head .res-count {
		color: #888888;
		margin-right: 6px;
	}

	html.search-js .search-acc-body {
		display: none;
		padding: 8px 12px 16px;
	}

	/* ---- the sort select and the availability switch, moved into the first item ---- */
	.search-drawer-sort .sort {
		float: none;
		line-height: 2;
		margin: 0;
		white-space: normal;
	}

	/* the wide layout asks for display:inline in an attribute */
	.search-drawer-sort .sortByForm {
		align-items: center;
		display: inline-flex !important;
		flex-wrap: wrap;
		gap: 8px;
	}

	.search-drawer-sort select {
		height: 40px;
		max-width: 150px;
	}

	/* the availability switch keeps the 44x20 track of stylesheet.css, which is already thumb-sized;
	   the slot carries the product-filter class so those rules still reach it inside the panel */

	/* ---- the facet rows themselves: taller rows for a thumb, and every font size left exactly what
	   the page gives it at a wide screen (the removal links keep their inline font-size: small) ---- */
	#column-left .box-category li a {
		display: block;
		padding-bottom: 12px;
		padding-top: 12px;
	}

	#column-left input[type="text"] {
		height: 42px;
	}

	/* ---- no recolouring under a finger ----
	   A tap fires :hover (and :focus) before the link is followed, and on a phone the row stays painted that
	   way until something else is tapped. stylesheet.css gives a facet link #276658 on :hover/:focus and a
	   #f7f7f7 background from .box-content ul li a:hover, and carries both over 300ms; at this width a row
	   keeps its still colours instead. #222222 is the colour a, a b already gives these links. */
	#column-left .box-category li a:hover,
	#column-left .box-category li a:focus,
	#column-left .box-category li a:active {
		background-color: transparent;
		color: #222222;
		transition: none;
	}

	/* the heads are buttons, which no rule of the site repaints, but a touch browser paints its own tap
	   highlight over them */
	.search-filters-panel,
	.search-mobile-bar {
		-webkit-tap-highlight-color: transparent;
	}

	/* ---- the pager's boxes, the size of the bar's controls ----
	   .pagination > li > a is a 30px box on a 26px line, while the filter button is 42px tall and the
	   grid/list icons are 40px squares: at this width the pager grows to that height, its arrow glyph takes
	   the 16px those icons use, and the digits stay the 13px the row inherits from .pagination_holder. */
	.pagination_holder .pagination > li > a,
	.pagination_holder .pagination > li > span {
		height: 42px;
		line-height: 40px;
		min-width: 42px;
		padding: 0 10px;
	}

	.pagination_holder .pagination > li > a i {
		font-size: 16px;
	}

	/* The subjects facet is the long one — 58 rows for one query, and it lies fully open at this width —
	   so its type and its row are smaller than the other facets: otherwise that one list is a screen and a
	   half of page. */
	#column-left .search-subjects-list li a {
		font-size: 12px;
		padding-bottom: 5px;
		padding-top: 5px;
	}

	/* the magnifier of «جستجو در میان نتایج» sits at an inline top: 10px, measured against the input
	   height the wide screen gives it */
	#in_results_search_input_button {
		top: 13px !important;
	}

	/* The subjects list does not scroll on a phone: it was the nearest scroller, so a touch that began on
	   it moved the list instead of the page. The facet lies fully open here and only the page scrolls. */
	.search-subjects-list {
		max-height: none !important;
		overflow: visible !important;
	}
}
