/*
 * Kannada glyph support. Loaded only when the site is being served in Kannada
 * (see IA29K_I18N::enqueue_font), so the English site's payload is untouched.
 *
 * ## This file must not change the design
 *
 * The requirement for the language switch was that type size and layout stay
 * exactly as they are. So this file declares `font-family` and nothing else.
 * There is deliberately no font-size, font-weight, line-height, letter-spacing,
 * margin, width or `size-adjust` anywhere in it — adding any of those is how a
 * translated page starts drifting away from the original.
 *
 * ## Why Optima and Mulish stay first in the stack
 *
 * Optima has no Kannada glyphs at all, so Kannada text in it renders as tofu
 * boxes. The fix is not to replace the site's typefaces but to *append* a
 * Kannada one after them. A browser resolves font-family per character, so:
 *
 *   - Latin characters — the digits in "1.25%", "SEBI", "29k", the whole English
 *     page — still hit Optima or Mulish first and look exactly as they do today.
 *   - Kannada characters find nothing in Optima or Mulish and fall through to
 *     Noto, which is the only thing that changes.
 *
 * The `unicode-range` descriptors below make that guarantee structural rather
 * than a matter of ordering: these faces are declared for the Kannada block
 * only, so the browser will not use them to render a Latin character even if the
 * cascade somehow put them first. The files are Google's Kannada subsets, which
 * is why they are ~90KB and ~120KB rather than the full multi-script fonts.
 *
 * Both files are variable fonts (wght 100-900 — verified with fontTools), so one
 * file covers every weight the site uses and the browser never has to synthesise
 * a bold.
 */

@font-face {
	font-family: 'Noto Sans Kannada';
	src: url('../font/kannada/noto-sans-kannada.woff2') format('woff2-variations'),
	     url('../font/kannada/noto-sans-kannada.woff2') format('woff2');
	font-weight: 100 900;
	font-style: normal;
	font-display: swap;
	/* Kannada block, plus the joiners, the rupee sign and the dotted circle that
	   Kannada text rendering relies on. Nothing Latin. */
	unicode-range: U+0951-0952, U+0964-0965, U+0C80-0CF3, U+1CD0, U+1CD2-1CD3,
	               U+1CDA, U+1CF2, U+1CF4, U+200C-200D, U+20B9, U+25CC,
	               U+A830-A835;
}

@font-face {
	font-family: 'Noto Serif Kannada';
	src: url('../font/kannada/noto-serif-kannada.woff2') format('woff2-variations'),
	     url('../font/kannada/noto-serif-kannada.woff2') format('woff2');
	font-weight: 100 900;
	font-style: normal;
	font-display: swap;
	unicode-range: U+0951-0952, U+0964-0965, U+0C80-0CF3, U+1CD0, U+1CD2-1CD3,
	               U+1CDA, U+1CF2, U+1CF4, U+200C-200D, U+20B9, U+25CC,
	               U+A830-A835;
}

/*
 * The whole switch, in two declarations.
 *
 * header.php sets these two custom properties on :root, and every rule in the
 * theme reads them through var(). Appending to them here reaches all of the
 * site's typography at once without restating a single selector, and without
 * this file needing to know which elements are headings.
 *
 * Optima is a humanist sans with serif-ish proportions, so its Kannada
 * counterpart is the serif face — Noto Serif Kannada carries the same
 * higher-contrast, more formal weight that Optima gives the headings. Mulish is
 * a low-contrast geometric sans, which is what Noto Sans Kannada is.
 *
 * `:root[lang="kn"]` also out-specifies the plain `:root` in header.php, so this
 * holds regardless of stylesheet order.
 */
:root[lang="kn"] {
	--font-heading: "Optima", "Noto Serif Kannada", serif;
	--font-body: "Mulish", "Noto Sans Kannada", sans-serif;
}

/*
 * A handful of rules in header.php name the typefaces literally instead of going
 * through the custom properties (`font-family: var(--font-body), system-ui,
 * sans-serif` resolves fine, but the compiled Tailwind utilities `font-heading`
 * and `font-sans` do not always). Re-point those two utilities as well so a
 * heading marked up with the utility class gets the same treatment as one styled
 * from the variable.
 */
:root[lang="kn"] .font-heading {
	font-family: "Optima", "Noto Serif Kannada", serif;
}

:root[lang="kn"] .font-sans,
:root[lang="kn"] .font-body {
	font-family: "Mulish", "Noto Sans Kannada", sans-serif;
}

/*
 * The language switch itself.
 *
 * Styled to match the login call to action beside it in the header — 14px bold
 * uppercase with wide tracking in the site navy — so it reads as part of the
 * existing control group rather than as something bolted on. The Kannada label
 * is exempt from `uppercase` because Kannada has no letter case and the property
 * would do nothing but is misleading to leave on.
 *
 * This block styles a new element, so it cannot disturb existing layout. It is
 * in this file rather than header.php because it is only ever rendered
 * alongside the switch, and keeping the two together means one file to look at.
 */
.ia29k-lang-switch {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
}

.ia29k-lang-switch__link {
	/* 24px minimum box, for 2.5.8 Target Size (Minimum). The two links sit next to
	   each other, so the spacing exception is not available: measured at 21x20 and
	   34x20 before this. The header's height is unchanged, because the login control
	   beside them is already 32px. */
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 24px;
	min-height: 24px;
	padding: 2px 4px;
	font-size: 14px;
	font-weight: 700;
	letter-spacing: 0.1em;
	color: #000036;
	text-decoration: none;
	transition: color 300ms;
	white-space: nowrap;
}

.ia29k-lang-switch__link--en {
	text-transform: uppercase;
}

.ia29k-lang-switch__link:hover,
.ia29k-lang-switch__link:focus-visible {
	color: #80809b;
}

/* The inactive language is the actionable one, so the current language is
   dimmed rather than the other way round. aria-current carries the same
   information to a screen reader. */
.ia29k-lang-switch__link[aria-current="true"] {
	/* #80809b measures 3.83:1 on white at 14px, which fails 1.4.3. #6f6f7a is the
	   theme's own dimmed-link colour, used in the footer, and measures 4.97:1. The
	   current language still reads as the quieter of the two. */
	color: #6f6f7a;
	cursor: default;
}

/* 1.59:1 as delivered. aria-hidden decoration, so arguably exempt, but it is
   visible text and #6f6f7a costs nothing at 4.97:1, matching the dimmed
   current-language item. The first attempt used #6f6f7a at 4.18:1, which is the
   1.4.11 non-text bar and not the 4.5:1 that text requires. */
.ia29k-lang-switch__separator {
	color: #6f6f7a;
}

/*
 * Machine-translation disclosure.
 *
 * Shown only on Kannada pages. This site is a SEBI-registered investment
 * adviser's, and its disclosure, privacy and terms pages carry statutory
 * meaning; a reader is entitled to know that the Kannada they are reading was
 * machine-translated and that the English text is the one that governs. Placed
 * in the flow at the top of the page rather than fixed over it, so it cannot
 * obscure content or trap focus.
 */
.ia29k-translation-notice {
	background: #f5f5f8;
	border-bottom: 1px solid rgba(0, 0, 54, 0.08);
	color: #000036;
	font-size: 13px;
	line-height: 1.5;
	padding: 0.75rem 25px;
	text-align: center;
}

@media (min-width: 768px) {
	.ia29k-translation-notice {
		padding-left: 50px;
		padding-right: 50px;
	}
}

.ia29k-translation-notice a {
	/* #228be7 on this #f5f5f8 panel is 3.26:1 at 13px, which fails 1.4.3. #1668B5 is
	   what ia29k_fix_text_contrast() already substitutes for this exact pairing
	   elsewhere on the site, and measures 5.24:1 here. */
	color: #1668B5;
	text-decoration: underline;
}
