/*
 * Header layout fixes (black bar, grey bar, red category bar) for desktop, tablet and phone.
 * Loaded after the theme CSS; markup and behaviour are unchanged.
 */

#common-bar {
	position: relative;
}

/* The black bar was pulled 7px up, clipping the top of the logo */
#common-bar .first-header-bar {
	margin-top: 0;
	height: 40px;
}
#common-bar .first-header-bar .content {
	position: relative;
}
/* the theme positions this wrapper absolutely, which threw the language selector out of the bar */
#common-bar .kpi-login {
	position: static !important;
	width: 0;
	height: 0;
}
#common-bar .kpilogo img {
	display: block;
	margin-top: 10px;
}

/* Top links stay on one line ("CONTACT US" wrapped out of the bar) */
#common-bar .kpi-navbar li a {
	white-space: nowrap;
}

/* Language selector: readable on the black bar, aligned right, not a full-width block */
#common-bar #google_translate_element {
	position: absolute;
	top: 8px;
	right: 0;
	width: auto;
	padding: 0 !important;
	z-index: 2;
}
#google_translate_element .goog-te-gadget-simple {
	background: transparent !important;
	border: 0 !important;
	padding: 0 !important;
	font-size: 12px !important;
	line-height: 24px;
	white-space: nowrap;
}
#google_translate_element .goog-te-gadget-simple a,
#google_translate_element .goog-te-gadget-simple span {
	color: #d5d5d5 !important;
	border-color: #d5d5d5 !important;
}
#google_translate_element .goog-te-gadget-icon {
	display: none;
}

/* Red category bar: one case for every item and items vertically centred (one- and two-line) */
.tm-navbar .uk-navbar-nav > li > a {
	display: flex;
	align-items: center;
	justify-content: center;
	height: 36px;
	line-height: 1.2;
	text-align: center;
	text-transform: uppercase;
}

/* ---------- below 960px the category links do not fit: toggle + search share the red bar ---------- */
@media (max-width: 959px) {
	.tm-navbar .uk-navbar-nav {
		display: none !important;
	}
	/* the grey-bar copy of the search is replaced by the one in the red bar */
	#common-bar .before8 {
		display: none !important;
	}
	.uk-container-center {
		position: relative;
	}
	/* UIkit draws the hamburger icon in ::after; the label goes in ::before, shown after the icon */
	.tm-navbar .uk-navbar-toggle {
		display: flex !important;
		flex-direction: row-reverse;
		justify-content: flex-end;
		align-items: center;
		height: 34px;
		color: #fff;
		text-decoration: none;
	}
	.tm-navbar .uk-navbar-toggle::after,
	.tm-navbar .uk-navbar-toggle::before {
		line-height: 1;
	}
	.tm-navbar .uk-navbar-toggle::before {
		content: "MENU";
		margin-left: 8px;
		font-size: 12px;
		font-weight: bold;
		letter-spacing: 0.05em;
		/* the FontAwesome bars glyph sits low in its box: bring the label to the same optical line */
		position: relative;
		top: 5px;
	}
	/* search sits inside the red bar, right side (it was drawn over the menu toggle) */
	.uk-container > .after8 {
		display: flex !important;
		align-items: center;
		position: absolute;
		top: 0;
		left: auto;
		right: 35px;
		width: auto !important;
		height: 34px;
		z-index: 3;
	}
	.uk-container > .after8 .uk-navbar-content {
		position: static !important;
		float: none !important;
		width: auto !important;
		margin: 0 !important;
	}
	/* the theme pulls the phone search form 377px to the left with absolute positioning */
	.uk-container > .after8 .uk-search,
	.uk-container > .after8 .uk-search-field {
		position: static !important;
		left: auto !important;
		right: auto !important;
		margin: 0;
	}
	/* the black bar is full of links here: the language selector moves to the grey bar, right side */
	#common-bar #google_translate_element {
		top: 48px;
		right: 12px;
	}
	#google_translate_element .goog-te-gadget-simple a,
	#google_translate_element .goog-te-gadget-simple span {
		color: #222 !important;
		border-color: #222 !important;
	}
	.uk-container > .after8 input[type="search"],
	.uk-container > .after8 input[type="text"] {
		width: 200px;
		max-width: calc(100vw - 175px);
	}
}

/* ---------- phones ---------- */
@media (max-width: 767px) {
	/* both hamburger buttons: same size, vertically centred in their bar */
	#common-bar #drop_menu,
	#common-bar #drop_menu1 {
		top: 4px;
		right: 12px;
		width: 32px;
		height: 32px;
		background-position: center;
		background-size: 22px auto;
		border-radius: 4px;
	}
	#common-bar #drop_menu1 {
		top: 43px;
	}
	/* position the language selector against the whole header on phones */
	#common-bar .first-header-bar .content {
		position: static;
	}
	#common-bar .kpilogo img {
		margin-top: 11px;
		max-width: calc(100vw - 70px);
		height: auto;
	}
	/* language selector moves to the grey bar, between the social icons and its menu button */
	#common-bar #google_translate_element {
		top: 48px;
		right: 56px;
	}
	#google_translate_element .goog-te-gadget-simple a,
	#google_translate_element .goog-te-gadget-simple span {
		color: #222 !important;
		border-color: #222 !important;
	}
	.uk-container > .after8 {
		right: 25px;
	}
}

@media (max-width: 360px) {
	#common-bar .kpi_social li {
		margin-right: 2px;
	}
	#google_translate_element .goog-te-gadget-simple {
		font-size: 11px !important;
	}
}

/* ---------- small desktops / landscape tablets: keep the category bar on one row ---------- */
@media (min-width: 960px) and (max-width: 1230px) {
	/* the theme gives each item a fixed width (122-135px) that adds up to more than the bar */
	.tm-navbar .uk-navbar-nav > li,
	.tm-navbar .uk-navbar-nav > li > a {
		width: auto !important;
		min-width: 0 !important;
	}
	.tm-navbar .uk-navbar-nav > li > a {
		max-width: 96px;
		padding-left: 7px;
		padding-right: 7px;
		font-size: 10px;
		letter-spacing: 0;
		white-space: normal;
	}
}

/* the bars' inner boxes have fixed widths at some breakpoints (up to ~1000px): never wider than the screen */
@media (max-width: 1230px) {
	/* grey-bar links: the list had a fixed width that pushed "Resources" onto a hidden second row */
	#common-bar .kpi-navbar-two > ul.menu {
		width: max-content !important;
	}
	#common-bar .content,
	#common-bar .content1 {
		min-width: 0 !important;
		max-width: 100%;
		box-sizing: border-box;
	}
}

/* Off-canvas category menu (MENU button): above the cookie banner and the "Advertise with us" tab,
   same letter case as the desktop category bar */
.uk-offcanvas {
	z-index: 100001;
}
.uk-offcanvas-bar {
	z-index: 100002;
}
.uk-offcanvas-bar .uk-nav-offcanvas > li > a {
	text-transform: uppercase;
	font-size: 13px;
}

/* The header's own drop-down menus (phone hamburgers) were clipped by the theme's overflow:hidden
   on #common-bar once it became their positioning context */
#common-bar {
	overflow: visible !important;
}

/* "Advertise with us" side tab: the text was cut (18px tall box with 12px of padding).
   Rotated 90deg around its centre, so right = -(width - height) / 2 keeps it flush with the screen edge;
   the open/close animation moves it by a relative +/-290px and is unaffected. */
.slider-arrow {
	box-sizing: border-box;
	width: 168px !important;
	height: 30px !important;
	padding: 0 16px !important;
	line-height: 30px !important;
	white-space: nowrap;
	text-align: center;
	right: -69px;
}

/* phone menus: keep some room between the longest entries and the screen edge */
@media (max-width: 767px) {
	#common-bar #nav,
	#common-bar .kpi-navbar ul {
		box-sizing: border-box;
		max-width: calc(100vw - 8px);
		padding-right: 14px;
	}
}
