/* =============================================================================
   HITESH H. VIRDA — ADVOCATE | LANGUAGE
   -----------------------------------------------------------------------------
   Loaded last, after style.css and insights.css, so the script overrides in
   section 3 win on equal specificity without reaching for !important.

     1. The switch in the header
     2. The paint guard
     3. Devanagari and Gujarati typography

   Nothing here applies while the site is in English: every rule below section 2
   is behind html[data-lang="hi"] or html[data-lang="gu"].
   ========================================================================== */


/* ═════════════════════════════════════ 1. THE SWITCH IN THE HEADER ══ */
/* Three states, always all visible: a visitor who cannot read the current
   language must be able to find their own without opening anything. Each
   label is written in its own script, so it is legible whatever is on screen. */

.langswitch {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  flex: none;
  background: rgba(255, 255, 255, .5);
}

.langswitch__btn {
  appearance: none;
  -webkit-appearance: none;
  min-width: 34px;
  min-height: 34px;
  padding: 0 .34rem;
  display: grid;
  place-items: center;
  background: transparent;
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 0;
  color: var(--text-3);
  font-family: var(--font-sans);
  font-size: .75rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: .04em;
  cursor: pointer;
  transition: background-color var(--dur) var(--ease),
              color var(--dur) var(--ease);
}
.langswitch__btn:first-child { border-left: 0; }
.langswitch__btn:hover { color: var(--text); background: var(--paper-2); }

.langswitch__btn[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
}

/* The Devanagari and Gujarati labels sit lower than the Latin one at the same
   font-size, and they carry matras above and below. A touch more room and a
   slightly larger size keeps all three optically level. */
.langswitch__btn[lang="hi"],
.langswitch__btn[lang="gu"] {
  font-size: .8125rem;
  letter-spacing: 0;
  font-family: "Noto Sans Devanagari", "Noto Sans Gujarati", "Nirmala UI",
               "Shruti", "Mangal", var(--font-sans);
}
.langswitch__btn[lang="gu"] {
  font-family: "Noto Sans Gujarati", "Nirmala UI", "Shruti", var(--font-sans);
}

@media (min-width: 480px) {
  .langswitch__btn { min-width: 38px; padding: 0 .5rem; }
}
@media (min-width: 1024px) {
  .langswitch__btn { min-width: 42px; font-size: .78125rem; }
  .langswitch__btn[lang="hi"],
  .langswitch__btn[lang="gu"] { font-size: .875rem; }
}

/* Below 340px the lockup, the switch and the toggle are genuinely tight. */
@media (max-width: 339px) {
  .langswitch__btn { min-width: 30px; padding: 0 .2rem; }
}


/* ══════════════════════════════════════════════ 2. THE PAINT GUARD ══ */
/* The HTML is written in English; Hindi and Gujarati are applied by
   js/i18n.js once the document has parsed. For those two, the page is held
   back for that one frame so a returning visitor never sees English flash
   past. The head script adds .i18n-ready itself after 1.5s if the script
   never arrives, so a failure shows the English page rather than a blank one.
   English visitors are never affected: the class is stamped immediately. */

html.js[data-lang="hi"]:not(.i18n-ready) body,
html.js[data-lang="gu"]:not(.i18n-ready) body {
  visibility: hidden;
}


/* ══════════════════════════ 3. DEVANAGARI AND GUJARATI TYPOGRAPHY ══ */
/* Cinzel and Manrope have no Devanagari or Gujarati glyphs, so both faces are
   swapped for the matching Noto pair. The web fonts are fetched by the head
   script only when one of these languages is actually chosen; the system faces
   that follow them cover the gap while they load and stand in if Google Fonts
   is blocked. */

html[data-lang="hi"] {
  --font-display: "Noto Serif Devanagari", "Tiro Devanagari Hindi", "Nirmala UI",
                  "Mangal", "Times New Roman", serif;
  --font-sans: "Noto Sans Devanagari", "Nirmala UI", "Mangal", "Segoe UI",
               system-ui, sans-serif;
}

html[data-lang="gu"] {
  --font-display: "Noto Serif Gujarati", "Nirmala UI", "Shruti",
                  "Times New Roman", serif;
  --font-sans: "Noto Sans Gujarati", "Nirmala UI", "Shruti", "Segoe UI",
               system-ui, sans-serif;
}

/* Neither script has letter case, so every uppercase label on the site would
   simply render unchanged — but the tracking that goes with those labels
   pushes the matras away from the letters they belong to. Both are dropped. */
html[data-lang="hi"] *,
html[data-lang="gu"] * {
  text-transform: none;
  letter-spacing: normal;
}

/* Matras sit above and below the base line, so both scripts need more leading
   than Latin at the same size before they stop touching. */
html[data-lang="hi"] body,
html[data-lang="gu"] body { line-height: 1.8; }

html[data-lang="hi"] .hero__title,
html[data-lang="gu"] .hero__title,
html[data-lang="hi"] .section__title,
html[data-lang="gu"] .section__title,
html[data-lang="hi"] .amast__title,
html[data-lang="gu"] .amast__title,
html[data-lang="hi"] .ihero__title,
html[data-lang="gu"] .ihero__title { line-height: 1.35; }

html[data-lang="hi"] .nav__link,
html[data-lang="gu"] .nav__link,
html[data-lang="hi"] .eyebrow,
html[data-lang="gu"] .eyebrow,
html[data-lang="hi"] .btn,
html[data-lang="gu"] .btn { line-height: 1.5; }

/* The Noto faces run a little smaller on the body than Cinzel and Manrope do
   at the same size, and the two smallest labels on the site become hard work.
   Nudging just those keeps everything else exactly where it was. */
html[data-lang="hi"] .brand__tagline,
html[data-lang="gu"] .brand__tagline { font-size: .5625rem; line-height: 1.5; }

html[data-lang="hi"] .quickbar__label,
html[data-lang="gu"] .quickbar__label { font-size: .625rem; }

html[data-lang="hi"] .hero__factlabel,
html[data-lang="gu"] .hero__factlabel { font-size: .625rem; }

/* Seven nav items in Devanagari or Gujarati are wider than seven in Latin.
   Letting the row wrap keeps the header from forcing a horizontal scrollbar
   at the width where the inline nav first appears. */
@media (min-width: 1024px) {
  html[data-lang="hi"] .nav__list,
  html[data-lang="gu"] .nav__list { flex-wrap: wrap; justify-content: center; }

  html[data-lang="hi"] .nav__link,
  html[data-lang="gu"] .nav__link { font-size: .8125rem; }
}

/* Long compound words in either script will not break on their own, so a
   narrow column can otherwise be forced wider than the screen. */
html[data-lang="hi"] .practice__title,
html[data-lang="gu"] .practice__title,
html[data-lang="hi"] .pillar__title,
html[data-lang="gu"] .pillar__title,
html[data-lang="hi"] .ireg__title,
html[data-lang="gu"] .ireg__title,
html[data-lang="hi"] .hcard__title,
html[data-lang="gu"] .hcard__title { overflow-wrap: break-word; }

/* The article prose carries the same leading as the rest of the page, and the
   figures and step lists inside it need it just as much. */
html[data-lang="hi"] .aprose,
html[data-lang="gu"] .aprose { line-height: 1.9; }

html[data-lang="hi"] .aprose h2,
html[data-lang="gu"] .aprose h2,
html[data-lang="hi"] .aprose h3,
html[data-lang="gu"] .aprose h3 { line-height: 1.45; }
