/**
 * UHWO Language Toggle
 * Row visibility rules + subheader toggle + untranslated-page notice.
 */

/* ----------------------------------
  1. Row visibility
  ------------------------------------*/
/* English mode (default): Hawaiian rows hidden. */
html:not(.uhwo-lang-haw) .lang-haw {
	display: none !important;
}

/* Hawaiian mode: English rows hidden. Untagged rows always display. */
html.uhwo-lang-haw .lang-en {
	display: none !important;
}

/* ----------------------------------
  2. Toggle placement in the red bar
  ------------------------------------*/
#uhwo-subheader .container {
	position: relative;
}

/* The bar is a fixed 3.125rem tall and js/custom.js measures it to
   position the mega menu, so the toggle floats over the bar instead
   of participating in its layout. The right offset mirrors the
   container padding at each theme breakpoint. */
#uhwo-lang-toggle {
	position: absolute;
	top: 50%;
	right: 2rem;
	transform: translateY(-50%);
	z-index: 100000;
}

/* Keep the subnav links clear of the toggle (theme default is 0.75rem). */
@media (min-width: 768px) {
	#uhwo-subheader #subnav-container > .textwidget {
		margin-right: 4rem;
	}
}

@media (max-width: 1439.98px) {
	#uhwo-lang-toggle {
		right: 1.75rem;
	}
}

@media (max-width: 991.98px) {
	#uhwo-lang-toggle {
		right: 1.5rem;
	}
}

@media (max-width: 767.98px) {
	#uhwo-lang-toggle {
		right: 1rem;
	}
}

/* ----------------------------------
  3. Toggle button
  ------------------------------------*/
#uhwo-lang-toggle-btn {
	display: flex;
	align-items: center;
	padding: 0;
	background: none;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	cursor: pointer;
}

/* Keyboard focus only — mouse clicks should not leave a white box. */
#uhwo-lang-toggle-btn:focus {
	outline: none;
}

#uhwo-lang-toggle-btn:focus-visible {
	outline: 2px solid #ffffff;
	outline-offset: 3px;
}

.uhwo-lang-flag {
	display: block;
	width: 34px;
	height: 18px;
	border: 1px solid #6d6d6d;
}

#uhwo-lang-toggle-btn .uhwo-lang-flag-haw {
	display: none;
}

html.uhwo-lang-haw #uhwo-lang-toggle-btn .uhwo-lang-flag-en {
	display: none;
}

html.uhwo-lang-haw #uhwo-lang-toggle-btn .uhwo-lang-flag-haw {
	display: block;
}

.uhwo-lang-caret {
	margin-left: 0.4rem;
	border-left: 5px solid transparent;
	border-right: 5px solid transparent;
	border-top: 6px solid #ffffff;
}

/* ----------------------------------
  4. Dropdown panel
  ------------------------------------*/
#uhwo-lang-menu {
	position: absolute;
	top: calc(100% + 15px); /* (bar 50px - button 20px) / 2 = flush with bar bottom */
	right: 0;
	display: flex;
	align-items: center;
	/* The containing block is the ~52px toggle wrapper; without an
	   explicit max-content width the panel gets clamped to it and the
	   options squeeze and overflow the background. */
	width: -webkit-max-content;
	width: -moz-max-content;
	width: max-content;
	padding: 1.25rem 1.5rem;
	background: #e4e4e4;
	box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
	white-space: nowrap;
}

#uhwo-lang-menu[hidden] {
	display: none;
}

/* The #uhwo-lang-menu prefix outranks the theme's global button rules
   (style.css `button:hover, button:focus { background-color: #a71930 }`
   and the twentynineteen resets), which otherwise paint the options red. */
#uhwo-lang-menu .uhwo-lang-option,
#uhwo-lang-menu .uhwo-lang-option:hover,
#uhwo-lang-menu .uhwo-lang-option:focus,
#uhwo-lang-menu .uhwo-lang-option:active {
	display: flex;
	align-items: center;
	flex: 0 0 auto;
	margin: 0;
	padding: 0;
	background: transparent;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	cursor: pointer;
	font-family: inherit;
	font-size: 1.125rem;
	font-weight: 400;
	line-height: 1.2;
	color: #333333;
	text-transform: none;
	text-decoration: none;
}

/* IE11 has no flex gap; margin between options instead. */
#uhwo-lang-menu .uhwo-lang-option + .uhwo-lang-option {
	margin-left: 2rem;
}

#uhwo-lang-menu .uhwo-lang-option .uhwo-lang-flag {
	margin-right: 0.6rem;
}

#uhwo-lang-menu .uhwo-lang-option:hover span,
#uhwo-lang-menu .uhwo-lang-option:focus span {
	text-decoration: underline;
}

/* Sharp rectangular focus ring instead of the browser's glyph-hugging
   outline: auto. */
#uhwo-lang-menu .uhwo-lang-option:focus {
	outline: 2px solid #2271b1;
	outline-offset: 5px;
}

/* Bold the active language. */
html:not(.uhwo-lang-haw) #uhwo-lang-menu .uhwo-lang-option[data-lang="en"],
html.uhwo-lang-haw #uhwo-lang-menu .uhwo-lang-option[data-lang="haw"] {
	font-weight: 700;
}

/* ----------------------------------
  5. Untranslated-page notice
  ------------------------------------*/
#uhwo-lang-notice {
	padding: 0.75rem 2rem;
	background: #f7e8eb;
	border-bottom: 3px solid #a71930;
	color: #333333;
	text-align: center;
}

/* ----------------------------------
  6. Print
  ------------------------------------*/
@media print {
	#uhwo-lang-toggle,
	#uhwo-lang-notice {
		display: none !important;
	}
}
