/**
 * Z2W Multi-Lingual — Public Styles
 *
 * Language switcher (list + dropdown) and frontend translation UI.
 */

/* ------------------------------------------------------------------ */
/* Language Switcher — Shared                                         */
/* ------------------------------------------------------------------ */

.z2w-language-switcher {
	font-size: 14px;
	line-height: 1.4;
}

/* ------------------------------------------------------------------ */
/* Language Switcher — Inline List                                    */
/* ------------------------------------------------------------------ */

.z2w-switcher-list {
	display: inline-flex;
	flex-wrap: wrap;
	gap: 2px;
	padding: 3px;
	border-radius: 6px;
	background: rgba(0, 0, 0, 0.04);
}

.z2w-switcher-list .z2w-lang-link {
	display: inline-block;
	padding: 5px 10px;
	text-decoration: none;
	border-radius: 4px;
	color: inherit;
	transition: background-color 0.15s ease, color 0.15s ease;
}

.z2w-switcher-list .z2w-lang-link:hover {
	background-color: rgba(0, 0, 0, 0.08);
}

.z2w-switcher-list .z2w-lang-link:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: -2px;
}

.z2w-switcher-list .z2w-lang-link.active {
	background-color: #fff;
	font-weight: 600;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* ------------------------------------------------------------------ */
/* Language Switcher — Dropdown                                       */
/* ------------------------------------------------------------------ */

.z2w-switcher-dropdown {
	display: inline-block;
}

.z2w-switcher-dropdown .z2w-lang-dropdown {
	padding: 6px 28px 6px 10px;
	font-size: 14px;
	line-height: 1.4;
	border: 1px solid #ccc;
	border-radius: 4px;
	background-color: #fff;
	color: inherit;
	cursor: pointer;
	appearance: none;
	-webkit-appearance: none;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23666' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 8px center;
}

.z2w-switcher-dropdown .z2w-lang-dropdown:hover {
	border-color: #999;
}

.z2w-switcher-dropdown .z2w-lang-dropdown:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: -2px;
	border-color: #666;
}

/* ------------------------------------------------------------------ */
/* Translation Loading State                                          */
/* ------------------------------------------------------------------ */

.z2w-translate-loading {
	opacity: 0.6;
	pointer-events: none;
	transition: opacity 0.3s;
}

/* ------------------------------------------------------------------ */
/* Untranslated Page Notice                                           */
/* ------------------------------------------------------------------ */

.z2w-untranslated-notice {
	background: #fef3cd;
	border: 1px solid #ffc107;
	border-left-width: 4px;
	border-radius: 4px;
	padding: 12px 16px;
	margin-bottom: 20px;
	font-size: 14px;
	line-height: 1.5;
	color: #664d03;
}

.z2w-untranslated-notice p {
	margin: 0;
}

/* ------------------------------------------------------------------ */
/* Language Switcher — Flag Modal Trigger                             */
/* ------------------------------------------------------------------ */

/*
 * The trigger is a button that shows the current language flag.
 * Emoji flags fill the circle via overflow:hidden + a font-size set
 * larger than the container (1.15×) so the character glyph edge-fills
 * the clipping circle without leaving blank canvas around it.
 *
 * shape=circle  → border-radius:50%  (default)
 * shape=pill    → border-radius:6px, auto width, gap for label text
 */
.z2w-flag-trigger {
	/* reset all default browser button chrome */
	-webkit-appearance: none;
	appearance: none;
	margin: 0;
	padding: 0;
	border: none;
	outline: none;
	background: transparent;

	/* layout */
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	gap: 6px;

	/*
	 * Emoji regional-indicator pairs often report a wide min-content width.
	 * As a flex/grid item, min-width:auto can then expand the button past
	 * the intended diameter -> stadium / D-shaped clips with border-radius:50%.
	 * Lock min/max to the design size and clip with circle() for a true disk.
	 */
	box-sizing: border-box;
	width: var(--z2w-flag-size, 36px);
	height: var(--z2w-flag-size, 36px);
	min-width: var(--z2w-flag-size, 36px);
	max-width: var(--z2w-flag-size, 36px);
	min-height: var(--z2w-flag-size, 36px);
	max-height: var(--z2w-flag-size, 36px);
	aspect-ratio: 1;
	border-radius: 50%;
	overflow: hidden;
	clip-path: circle(closest-side at 50% 50%);

	/* align with adjacent inline text/icons without being pushed up */
	vertical-align: middle;
	line-height: 1;

	cursor: pointer;
	transition: transform 0.15s ease, opacity 0.15s ease;
	/* 1px black ring inside the circle (inset avoids changing layout vs border) */
	box-shadow: inset 0 0 0 1px #000000;
}

.z2w-flag-trigger:hover {
	transform: scale(1.1);
	opacity: 0.9;
}

/* Keyboard focus ring — only visible on keyboard navigation */
.z2w-flag-trigger:focus-visible {
	outline: 3px solid currentColor;
	outline-offset: 2px;
}

/*
 * Emoji flag sized to *slightly* exceed the container so that the
 * glyph edge reaches the circle boundary (overflow:hidden clips the rest).
 * 1.15× gives a full bleed effect on all common OS emoji fonts.
 */
.z2w-flag-trigger .z2w-flag-emoji {
	display: block;
	font-size: calc(var(--z2w-flag-size, 36px) * 1.15);
	line-height: 1;
	user-select: none;
	pointer-events: none;
	/* Do not let glyph intrinsic width stretch the flex container */
	max-width: 100%;
	overflow: hidden;
	text-align: center;
}

/* PNG flags (bundled or media library): fill the circular trigger */
.z2w-flag-trigger .z2w-flag-emoji--image {
	font-size: 0;
	line-height: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
}

.z2w-flag-trigger .z2w-flag-img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

/* ── Pill variant ────────────────────────────────────────────────── */
/* style="modal" trigger_shape="pill" → shows flag + language label  */

.z2w-flag-trigger.z2w-trigger-pill {
	width: auto;
	min-width: 0;
	max-width: none;
	min-height: var(--z2w-flag-size, 36px);
	max-height: none;
	aspect-ratio: auto;
	border-radius: 6px;
	padding: 0 10px;
	overflow: visible; /* don't clip the label text */
	clip-path: none;
}

.z2w-flag-trigger.z2w-trigger-pill .z2w-flag-emoji {
	font-size: calc(var(--z2w-flag-size, 36px) * 0.8);
}

/* Pill + PNG: small circle next to label (pill container is not circular) */
.z2w-flag-trigger.z2w-trigger-pill .z2w-flag-emoji--image {
	width: calc(var(--z2w-flag-size, 36px) * 0.85);
	height: calc(var(--z2w-flag-size, 36px) * 0.85);
	border-radius: 50%;
	overflow: hidden;
	flex-shrink: 0;
	box-shadow: inset 0 0 0 1px #000000;
}

.z2w-trigger-label {
	font-size: 14px;
	font-weight: 500;
	line-height: 1;
	white-space: nowrap;
	color: currentColor;
}

/* ------------------------------------------------------------------ */
/* Language Switcher — Modal Backdrop                                 */
/* ------------------------------------------------------------------ */

.z2w-lang-modal-backdrop {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(0, 0, 0, 0.5);
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.2s ease, visibility 0.2s ease;
}

.z2w-lang-modal-backdrop[hidden] {
	display: none;
}

.z2w-lang-modal-backdrop.z2w-modal-open {
	opacity: 1;
	visibility: visible;
}

/* ------------------------------------------------------------------ */
/* Language Switcher — Modal Card                                     */
/* ------------------------------------------------------------------ */

/*
 * CSS custom properties injected as inline style on the backdrop element:
 *   --z2w-modal-bg             (default #fff)
 *   --z2w-modal-border-color   (default transparent)
 *   --z2w-modal-border-width   (default 0px)
 *   --z2w-modal-border-radius  (default 12px)
 */
.z2w-lang-modal {
	position: relative;
	width: 90vw;
	max-width: 600px;
	max-height: 80vh;
	overflow-y: auto;
	background: var(--z2w-modal-bg, #fff);
	border: var(--z2w-modal-border-width, 0px) solid var(--z2w-modal-border-color, transparent);
	border-radius: var(--z2w-modal-border-radius, 12px);
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.24);
	padding: 16px 20px 20px;
	transform: scale(0.95);
	transition: transform 0.2s ease;
}

.z2w-modal-open .z2w-lang-modal {
	transform: scale(1);
}

.z2w-lang-modal-header {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	margin-bottom: 12px;
}

.z2w-lang-modal-close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	padding: 0;
	border: none;
	border-radius: 50%;
	background: transparent;
	font-size: 22px;
	line-height: 1;
	color: #666;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
	transition: background-color 0.15s ease, color 0.15s ease;
}

.z2w-lang-modal-close:hover {
	background: rgba(0, 0, 0, 0.08);
	color: #333;
}

.z2w-lang-modal-close:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: -2px;
}

/* ------------------------------------------------------------------ */
/* Language Switcher — Modal Grid                                     */
/* ------------------------------------------------------------------ */

.z2w-lang-modal-grid {
	display: grid;
	grid-template-columns: repeat(var(--z2w-modal-cols, 4), 1fr);
	gap: 6px;
}

@media (max-width: 560px) {
	.z2w-lang-modal-grid {
		grid-template-columns: repeat(3, 1fr);
	}
}

@media (max-width: 380px) {
	.z2w-lang-modal-grid {
		grid-template-columns: repeat(2, 1fr);
	}
}

.z2w-lang-modal-item {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 10px 12px;
	border-radius: 8px;
	text-decoration: none;
	color: #333;
	font-size: 14px;
	line-height: 1.3;
	transition: background-color 0.15s ease;
}

.z2w-lang-modal-item:hover {
	background: rgba(0, 0, 0, 0.06);
	text-decoration: none;
	color: #111;
}

.z2w-lang-modal-item:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: -2px;
	border-radius: 8px;
}

.z2w-lang-modal-item--active {
	background: rgba(0, 0, 0, 0.06);
	font-weight: 600;
	box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.15);
}

/* Emoji-only flags (PNG uses .z2w-flag-emoji--image below) */
.z2w-lang-modal-item .z2w-flag-emoji:not(.z2w-flag-emoji--image) {
	box-sizing: border-box;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	min-width: 28px;
	min-height: 28px;
	border-radius: 50%;
	overflow: hidden;
	font-size: 22px;
	line-height: 1;
	flex-shrink: 0;
	user-select: none;
	box-shadow: inset 0 0 0 1px #000000;
}

.z2w-lang-modal-item .z2w-flag-emoji--image {
	font-size: 0;
	line-height: 0;
	width: 28px;
	height: 28px;
	border-radius: 50%;
	overflow: hidden;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: inset 0 0 0 1px #000000;
}

.z2w-lang-modal-item .z2w-flag-img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.z2w-lang-modal-name {
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
