/**
 * OCTEC "Translate this page" language picker.
 *
 * Structural CSS only — inherits typography and colour from the theme wherever
 * possible. Colours are mapped to the Blocksy palette so the Customiser stays
 * authoritative; hex values are fallbacks only. Everything is namespaced under
 * `octec-translate`. Square corners throughout, per brand.
 *
 * There is no overlay, panel, header or close button here: [octec_translate]
 * renders content only and the Blocksy popup supplies the dialog around it.
 * Padding, width, background and shadow therefore belong in the popup's own
 * settings, not in this file — anything added here would fight them.
 *
 * Written with logical properties (inline-start/end, margin-inline) so the
 * picker is already correct if the document direction is ever flipped to RTL.
 */

.octec-translate,
.octec-translate-trigger {
	--octec-tr-teal: var(--theme-palette-color-1, #007A6E);
	--octec-tr-teal-dark: var(--theme-palette-color-9, #005A4F);
	--octec-tr-charcoal: var(--theme-palette-color-4, #2D2D2D);
	--octec-tr-warm: var(--theme-palette-color-5, #F5F5F0);
	--octec-tr-white: var(--theme-palette-color-8, #ffffff);
	--octec-tr-border: var(--theme-palette-color-15, #E4E4E4);

	/* Not the palette's grey (#757575): that measures 4.21:1 on the warm hover
	   background, which fails WCAG AA for normal text. #6B6B6B is 4.87:1. */
	--octec-tr-muted: #6B6B6B;

	--octec-tr-radius: 0;
}

/* ---- Trigger ------------------------------------------------------------- */

/* Blocksy's HTML header element wraps content in
   `.ct-header-text > .entry-content.is-layout-flow`, whose block-layout margins
   otherwise push the button out of line with the contacts and socials beside it. */
.ct-header-text .entry-content > .octec-translate-trigger {
	margin-block: 0;
}

.octec-translate-trigger {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
	/* Inherit the header row / drawer colour so the trigger always matches the
	   items next to it and introduces no contrast risk of its own. */
	color: inherit;
	font: inherit;
	line-height: 1.2;
	cursor: pointer;
	text-decoration: none;
	border-radius: var(--octec-tr-radius);
	transition: opacity .2s ease;
}

/* The mockup hovers this to accent-gold (#A86800). On the navy utility bar
   (#005389) that is 1.79:1 — a WCAG failure, and colour-only signalling. An
   underline carries the state instead and keeps the 8.08:1 white text. */
.octec-translate-trigger:hover,
.octec-translate-trigger:focus-visible {
	color: inherit;
	text-decoration: underline;
	text-underline-offset: 3px;
}

.octec-translate-trigger:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.octec-translate-trigger__icon {
	width: 16px;
	height: 16px;
	flex: none;
}

.octec-translate-trigger--drawer {
	width: 100%;
	justify-content: flex-start;
	padding-block: 10px;
}

.octec-translate-trigger--drawer .octec-translate-trigger__icon {
	width: 20px;
	height: 20px;
}

/* ---- Content area -------------------------------------------------------- */

.octec-translate {
	display: flex;
	flex-direction: column;
	gap: 16px;
}

/* ---- Search -------------------------------------------------------------- */

/* Blocksy styles inputs aggressively (transparent background, 2px border,
   15px padding), so these need to win on specificity. */
.octec-translate .octec-translate-search {
	box-sizing: border-box;
	width: 100%;
	padding: 12px 16px;
	border: 1px solid var(--octec-tr-border);
	border-radius: var(--octec-tr-radius);
	background: var(--octec-tr-white);
	color: var(--octec-tr-charcoal);
	font-size: 14px;
	line-height: 1.4;
}

.octec-translate .octec-translate-search:focus {
	outline: 2px solid var(--octec-tr-teal);
	outline-offset: -1px;
	border-color: transparent;
}

/* ---- Language grid ------------------------------------------------------- */

.octec-translate-grid {
	display: grid;
	/* Responsive equivalent of the mockup's 1 / 2 / 3 columns. */
	grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
	gap: 4px;

	/* No inner scroller by default — the popup scrolls as one piece, which is
	   the right behaviour for a short list and avoids nested scrollbars. Set
	   --octec-tr-grid-max-height on the popup (e.g. 55vh) to pin the search
	   field and scroll only the languages once the list gets long. */
	max-height: var(--octec-tr-grid-max-height, none);
	overflow-y: auto;
	overscroll-behavior: contain;
}

.octec-translate-lang {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px 12px;
	text-align: start;
	text-decoration: none;
	border-radius: var(--octec-tr-radius);
	transition: background-color .2s ease;
}

.octec-translate-lang:hover {
	background: var(--octec-tr-warm);
	text-decoration: none;
}

.octec-translate-lang:focus-visible {
	outline: 2px solid var(--octec-tr-teal);
	outline-offset: 2px;
}

.octec-translate-lang[hidden] {
	display: none;
}

.octec-translate-lang.is-current {
	background: var(--octec-tr-warm);
	box-shadow: inset 3px 0 0 var(--octec-tr-teal);
}

.octec-translate-lang__flag {
	flex: none;
	/* TranslatePress ships 18x12 PNGs, so this is displayed at native size —
	   scaling them up is visibly soft. See trp_flags_path to swap the source. */
	width: 18px;
	height: 12px;
	object-fit: cover;
	box-shadow: 0 0 0 1px rgba(0, 0, 0, .12);
}

.octec-translate-lang__names {
	display: flex;
	flex-direction: column;
	line-height: 1.3;
	min-width: 0;
}

.octec-translate-lang__english {
	font-size: 14px;
	font-weight: 500;
	color: var(--octec-tr-charcoal);
}

.octec-translate-lang__native {
	font-size: 12px;
	color: var(--octec-tr-muted);
}

/* ---- Empty state and disclosure ------------------------------------------ */

.octec-translate-empty {
	margin: 0;
	font-size: 14px;
	color: var(--octec-tr-muted);
	text-align: center;
}

.octec-translate-empty[hidden] {
	display: none;
}

.octec-translate-disclosure {
	margin: 0;
	padding: 12px 16px;
	background: var(--octec-tr-warm);
	font-size: 12px;
	line-height: 1.5;
	color: var(--octec-tr-muted);
	text-align: center;
}

/* ---- Utilities ----------------------------------------------------------- */

.octec-translate-sr {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

@media (prefers-reduced-motion: reduce) {
	.octec-translate-trigger,
	.octec-translate-lang {
		transition: none;
	}
}
