/*
 * Phone layout for the store. Everything lives inside this one media query, so
 * nothing here can reach the desktop view. The theme is a fixed 960px grid; on a
 * phone the same pieces are stacked in one column, with the same colours, fonts
 * and artwork.
 */
@media (max-width: 767px) {

	html {
		-webkit-text-size-adjust: 100%;
		text-size-adjust: 100%;
	}

	/* let go of the 960px grid */
	body,
	div.full-width {
		min-width: 0;
	}
	#page [class*="grid16-"] {
		float: none;
		width: auto;
	}
	#page .block {
		float: none;
		width: auto;
	}

	/* header: logo, store name, then the search box */
	#header-site-info {
		float: none;
		width: auto;
	}
	#logo,
	#site-name-wrapper {
		float: none;
		width: auto;
	}
	#logo img {
		width: 100%;
		max-width: 330px;
		height: auto;
	}
	/* the store name stays on one line, shrinking with the screen */
	#site-name {
		font-size: min(26px, 6.4vw);
		line-height: 1.15;
		margin-bottom: 4px;
		white-space: nowrap;
	}

	/*
	 * The search box moves below the page content. It lives inside the header, so the
	 * header wrappers dissolve (display: contents) and the page stacks its sections in
	 * the order given here. The white header background moves onto the logo block.
	 */
	#page-inner {
		display: flex;
		flex-direction: column;
	}
	#header-group-wrapper,
	#header-group,
	#header-group-inner {
		display: contents;
	}
	#header-site-info {
		background: #fff;
		padding-bottom: 12px;
	}
	#block-search-form {
		order: 1;
		float: none;
		width: auto;
		margin: 0 10px 20px;
	}
	#postscript-wrapper {
		order: 2;
	}
	#footer-wrapper {
		order: 3;
	}
	#edit-search-block-form--2 {
		width: 100%;
		box-sizing: border-box;
	}

	/* tabs: two equal columns, three even rows */
	#main-menu ul.menu {
		display: grid;
		grid-template-columns: 1fr 1fr;
		grid-auto-rows: 1fr;
		gap: 4px;
	}
	#main-menu ul.menu li {
		float: none;
		margin: 0;
		display: flex;
	}
	#main-menu ul.menu li a {
		flex: 1;
		display: flex;
		align-items: center;
		justify-content: center;
		text-align: center;
		min-height: 30px;
		padding: 5px 6px;
		border-radius: 5px;
	}
	#main-menu-wrapper {
		background: #fff;
		padding-bottom: 6px;
	}

	/* the blue band: same words, less of the screen */
	.preface-top-outer {
		padding-top: 12px;
	}
	#preface-top-wrapper {
		font-size: 15px;
	}
	#page #block-block-9 {
		margin-bottom: 0;
	}
	#preface-top-inner p {
		margin: 0 0 12px;
		line-height: 1.4;
	}

	/* page content first, then the sidebar blocks */
	#main-inner {
		display: flex;
		flex-direction: column;
	}
	#main-group {
		order: 1;
	}
	#sidebar-first {
		order: 2;
		margin-top: 20px;
	}
	#main-content,
	#content-group,
	#content {
		float: none;
		width: auto;
	}

	/* readable without pinching */
	#main-wrapper,
	#postscript-wrapper,
	#footer-wrapper {
		font-size: 15px;
	}
	/* room for a thumb; the » marker moves down with the text */
	#sidebar-first li {
		padding-top: 6px;
		padding-bottom: 4px;
		background-position: 0 16px;
	}

	/* shop list view keeps its desktop shape: picture left, details right */
	.woocommerce #content ul.products li.berocket_lgv_list,
	.woocommerce-page #content ul.products li.berocket_lgv_list {
		float: left;
		clear: left;
		width: 30%;
		margin-right: 4%;
	}
	#content ul.products li.berocket_lgv_list .button {
		font-size: 11px;
		white-space: nowrap;
		margin: 10px 0 0;
	}
	#content ul.products div.berocket_lgv_additional_data {
		float: left;
		width: 66%;
	}

	/* each product gets air and a hairline under it; long course names no longer shout */
	#content ul.products div.berocket_lgv_additional_data h3 {
		font-size: 16px;
		line-height: 1.3;
		margin: 0 0 8px;
		overflow-wrap: anywhere;
	}
	#content ul.products div.berocket_lgv_additional_data .lgv_meta,
	#content ul.products div.berocket_lgv_additional_data .lgv_description {
		font-size: 13px;
		line-height: 1.5;
	}
	#content ul.products div.berocket_lgv_additional_data .sku_wrapper,
	#content ul.products div.berocket_lgv_additional_data .posted_in {
		display: block;
	}
	#content ul.products div.berocket_lgv_additional_data .lgv_price {
		font-size: 16px;
		line-height: 1.4;
		margin-top: 8px;
	}
	#content ul.products div.berocket_lgv_after_additional {
		/* padding, not margin: this element clears floats, which swallows a top margin */
		height: 0;
		padding-top: 16px;
		margin: 0 0 18px;
		border-bottom: 1px solid rgba(60, 90, 20, 0.18);
	}

	/* WooCommerce turns the totals rows into blocks on a phone; the table has to follow or the rows shrink */
	#content .cart_totals table.shop_table,
	#content .cart_totals table.shop_table tbody {
		display: block;
	}

	/* search results: the form and heading sat flush against the column edge */
	#content-region #search-block-form {
		margin: 0 10px;
	}
	#content-region h2.search-results-title {
		float: none;
		clear: both;
		width: auto;
		margin-left: 10px;
		margin-right: 10px;
	}
	#content {
		clear: both;
	}

	/* a floated picture leaves no room for the words beside it */
	#content img.alignleft,
	#content img.alignright {
		float: none;
		display: block;
		margin: 0 0 12px;
	}

	/* contact and account forms use the full column */
	#content .form-item input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]),
	#content .wpcf7 input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]),
	#content .wpcf7 textarea {
		width: 100%;
	}

	/* nothing wider than the screen */
	#page img,
	#content img[class*="wp-image-"] {
		max-width: 100%;
		height: auto;
		box-sizing: border-box;
	}
	#page iframe,
	#page video,
	#page embed,
	#page object {
		max-width: 100%;
	}
	#content .field-item table {
		display: block;
		max-width: 100%;
		overflow-x: auto;
	}
	#content {
		overflow-wrap: break-word;
	}

	/* iOS zooms the page when a field under 16px takes focus */
	#page input[type="text"],
	#page input[type="email"],
	#page input[type="tel"],
	#page input[type="password"],
	#page input[type="number"],
	#page input[type="search"],
	#page select,
	#page textarea {
		font-size: 16px;
		max-width: 100%;
		box-sizing: border-box;
	}

	#postscript-top {
		float: none;
		width: auto;
	}
}
