/* ==========================================================================
   Language switcher — The Sri COM
   Markup: partials/language-switcher.hbs   Logic: assets/js/translate.js
   ========================================================================== */

/* --- Suppress Google's own chrome -----------------------------------------
   The widget injects a grey banner iframe at the top of the page and pushes
   the body down with an inline `top`. Both are hidden here so the switcher in
   the header is the only visible control. */

.goog-te-banner-frame,
.goog-te-gadget-icon,
#goog-gt-tt,
.goog-tooltip,
.skiptranslate iframe {
  display: none !important;
}

body { top: 0 !important; }

#google-translate-host {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* Google wraps translated runs in <font> tags; keep them inheriting. */
font { background: transparent !important; box-shadow: none !important; color: inherit !important; }

/* --- The switcher --------------------------------------------------------- */

.lang { position: relative; }

.lang-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, .38);
  border-radius: 99px;
  background: transparent;
  color: #fff;
  font-family: inherit;
  font-size: .8rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color .2s ease, background-color .2s ease;
}

.lang-toggle:hover {
  border-color: #fff;
  background: rgba(255, 255, 255, .16);
}

.lang-toggle:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

/* --- Round flags -----------------------------------------------------------
   The wrapper does the clipping: border-radius on an inline <svg> is not
   reliably honoured by its contents, but overflow:hidden on a block wrapper
   always is. */

.flag-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.lang-flag {
  display: block;
  flex: none;
  width: 18px;
  height: 18px;
  overflow: hidden;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .22);
}

.lang-flag svg {
  display: block;
  width: 100%;
  height: 100%;
}

.lang-menu .lang-flag {
  width: 17px;
  height: 17px;
}

.lang-caret {
  width: 13px;
  height: 13px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform .2s ease;
}

.lang.is-open .lang-caret { transform: rotate(180deg); }

/* --- The menu ------------------------------------------------------------- */

.lang-menu {
  position: absolute;
  z-index: 60;
  top: calc(100% + 9px);
  inset-inline-end: 0;
  display: none;
  min-width: 190px;
  padding: 7px;
  border: 1px solid var(--lang-line, rgba(180, 204, 237, .18));
  border-radius: 12px;
  background: var(--lang-panel, #101f36);
  box-shadow: 0 18px 44px rgba(3, 12, 28, .45);
}

.lang.is-open .lang-menu { display: block; }

html[data-theme="light"] .lang-menu {
  --lang-line: #dbe3ef;
  --lang-panel: #ffffff;
  box-shadow: 0 18px 44px rgba(20, 40, 75, .16);
}

.lang-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--lang-text, #dbe6f7);
  font-family: inherit;
  font-size: .86rem;
  font-weight: 500;
  text-align: start;
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}

html[data-theme="light"] .lang-menu button { --lang-text: #243753; }

.lang-menu button:hover { background: rgba(36, 117, 232, .16); color: #2475e8; }

.lang-menu button[aria-current="true"] {
  background: #2475e8;
  color: #fff;
  font-weight: 650;
}

.lang-menu button:focus-visible {
  outline: 2px solid #2475e8;
  outline-offset: -2px;
}

html[data-theme="light"] /* --- Right-to-left (Arabic) ------------------------------------------------
   Most of the layout is flex/grid with `gap`, which mirrors automatically once
   dir="rtl" is set. These are the places that pinned a physical side. */

html[dir="rtl"] .latest-column {
  padding-right: 0;
  padding-left: 26px;
  border-right: 0;
  border-left: 1px solid rgba(180, 204, 237, .14);
}

html[dir="rtl"] .spotlight-column {
  padding-left: 0;
  padding-right: 26px;
  border-left: 0;
  border-right: 1px solid rgba(180, 204, 237, .14);
}

html[dir="rtl"] .gh-content blockquote {
  padding: 3px 22px 3px 0;
  border-left: 0;
  border-right: 3px solid var(--blue);
}

html[dir="rtl"] .comment-trap { left: auto; right: -9999px; }

html[dir="rtl"] .article-image { transform: translateX(50%); }

@media (max-width: 650px) {
  html[dir="rtl"] .latest-column,
  html[dir="rtl"] .spotlight-column {
    padding-left: 0;
    padding-right: 0;
    border-left: 0;
    border-right: 0;
  }
}

/* --- Small screens --------------------------------------------------------- */

@media (max-width: 860px) {
  /* Header is tight — drop to a flag-only button. The flag still says which
     language is active, so nothing is lost. */
  .lang-current,
  .lang-caret { display: none; }

  .lang-toggle {
    width: 34px;
    padding: 0;
    justify-content: center;
    border-radius: 50%;
  }

  .lang-toggle .lang-flag {
    width: 20px;
    height: 20px;
  }

  .lang-menu {
    inset-inline-end: 0;
    min-width: 172px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .lang-caret,
  .lang-toggle,
  .lang-menu button { transition: none; }
}
