/* InsightiC language switcher — "EN ▾" button + PT / EN dropdown.
   Lettering, dropdown panel and current-item highlight match the phone burger
   popup (insightic-site-navigation-and-design/assets/mobile-menu.css).
   Astra styles every <button>, so the button rules use !important. */

/* ── Shared: button ─────────────────────────────────────────────────────── */

.ic-lang {
  position: relative;
}

.ic-lang .ic-lang-btn {
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  margin: 0 !important;
  padding: 10px 14px !important;
  border: 0 !important;
  border-radius: 8px !important;
  background: transparent !important;
  box-shadow: none !important;
  color: var(--ic-text, #F0F5FA) !important;
  font-family: var(--ic-font-lexend, 'Lexend', sans-serif) !important;
  font-size: 15px !important;
  font-weight: 400 !important;
  line-height: 1.4 !important;
  letter-spacing: normal !important;
  text-transform: none !important;
  cursor: pointer;
  transition: background 0.15s ease;
}

.ic-lang .ic-lang-btn:hover,
.ic-lang .ic-lang-btn:focus-visible,
.ic-lang.is-open .ic-lang-btn {
  background: rgba(240, 245, 250, 0.06) !important;
  color: #FFFFFF !important;
  outline: none;
}

.ic-lang .ic-lang-btn {
  position: relative;
}

/* While open, the selected language (the button's row) carries the same
   violet→cyan bar as the current item in the burger menu */
.ic-lang.is-open .ic-lang-btn::before {
  content: "";
  position: absolute;
  left: 0;
  top: 9px;
  bottom: 9px;
  width: 3px;
  border-radius: 3px;
  background: linear-gradient(var(--ic-violet, #7B5EFB), var(--ic-cyan, #22D3EE));
}

.ic-lang-chev {
  transition: transform 0.15s ease;
}

.ic-lang.is-open .ic-lang-chev {
  transform: rotate(180deg);
}

/* ── Shared: dropdown (same panel as the burger popup) ──────────────────── */

.ic-lang-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;  /* exactly as wide as the button, no wider */
  padding: 6px;
  background: var(--ic-bg, #1E293B);
  border: 1px solid rgba(240, 245, 250, 0.2);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  box-sizing: border-box;
  animation: ic-lang-open 0.16s ease-out;
}

.ic-lang-menu[hidden] {
  display: none;
}

.ic-lang .ic-lang-opt {
  position: relative;
  display: block !important;
  width: 100% !important;
  margin: 0 !important;
  padding: 11px 14px !important;
  border: 0 !important;
  border-radius: 8px !important;
  background: transparent !important;
  box-shadow: none !important;
  color: var(--ic-text, #F0F5FA) !important;
  font-family: var(--ic-font-lexend, 'Lexend', sans-serif) !important;
  font-size: 15px !important;
  font-weight: 400 !important;
  line-height: 1.4 !important;
  letter-spacing: normal !important;
  text-align: left !important;
  text-transform: none !important;
  cursor: pointer;
  transition: background 0.15s ease;
}

.ic-lang .ic-lang-opt:hover,
.ic-lang .ic-lang-opt:focus-visible {
  background: rgba(240, 245, 250, 0.06) !important;
  color: #FFFFFF !important;
  outline: none;
}

/* Current language: tint + brand gradient bar, as the current page item */
.ic-lang .ic-lang-opt[aria-checked="true"] {
  background: rgba(93, 200, 230, 0.12) !important;
  color: #FFFFFF !important;
}

.ic-lang .ic-lang-opt[aria-checked="true"]::before {
  content: "";
  position: absolute;
  left: 0;
  top: 9px;
  bottom: 9px;
  width: 3px;
  border-radius: 3px;
  background: linear-gradient(var(--ic-violet, #7B5EFB), var(--ic-cyan, #22D3EE));
}

@keyframes ic-lang-open {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes ic-lang-grow {
  from { opacity: 0; transform: scaleY(0.6); }
  to   { opacity: 1; transform: scaleY(1); }
}

/* ── Desktop: last item of the menu panel ───────────────────────────────── */

@media (min-width: 922px) {

  /* Astra makes every .menu-item a column flex box (justify-content: center,
     flex-direction: column) — without a row the divider becomes a bar above
     the button. Specificity beats Astra's `.main-header-menu .menu-item`. */
  #ast-desktop-header .main-header-menu > .ic-lang-item {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: stretch;
    justify-content: flex-start;
  }

  /* Gradient divider, inset so it doesn't touch the panel border */
  #ast-desktop-header .main-header-menu > .ic-lang-item::before {
    content: "";
    flex: 0 0 3px;
    /* 2px + the menu's 2px item gap and 8px put the bar midway between the
       last link's text and "EN" (links have 18px side padding, the button 14px) */
    margin: 7px 8px 7px 2px;
    border-radius: 3px;
    background: linear-gradient(var(--ic-violet, #7B5EFB), var(--ic-cyan, #22D3EE));
  }

  .ic-lang--mobile {
    display: none !important;
  }

  /* While open the selected language carries its own bar (above), which would
     sit right next to the divider: the divider steps aside until it closes */
  #ast-desktop-header .main-header-menu.ic-lang-open > .ic-lang-item::before {
    visibility: hidden;
  }

  /* The menu panel grows downward under the EN pill (an L-shaped outline)
     and lists only the other language. The panel has 6px padding + 1px border
     (desktop-menu.css), so the extension starts on the panel's bottom border
     row (hiding it), runs from 6px left of the pill to the panel's outer right
     edge, and the panel's bottom-right corner squares off while it is open
     (switcher.js sets .ic-lang-open on the panel). */
  #ast-desktop-header .main-header-menu.ic-lang-open {
    border-bottom-right-radius: 0;
  }

  .ic-lang--desktop .ic-lang-menu {
    top: calc(100% + 6px);
    left: -6px;
    right: -7px;
    width: auto;
    gap: 0;
    padding: 2px 6px 6px 5px; /* the option lines up under the EN pill */
    border-top: 0;
    border-radius: 0 0 12px 12px;
    box-shadow: 0 12px 20px -8px rgba(0, 0, 0, 0.4);
    transform-origin: top;
    animation: ic-lang-grow 0.16s ease-out;
  }

  .ic-lang.ic-lang--desktop .ic-lang-opt {
    padding: 10px 14px !important; /* same size and lettering as the EN button */
  }

  /* The button already shows the current language */
  .ic-lang.ic-lang--desktop .ic-lang-opt[aria-checked="true"] {
    display: none !important;
  }
}

/* ── Phone: dark button right of the burger ─────────────────────────────── */

@media (max-width: 921px) {

  /* The desktop item, if Astra prints the same menu in the burger popup */
  #ast-mobile-header .ic-lang-item,
  .ic-lang--mobile:not(.is-placed) {
    display: none !important;
  }

  /* The switcher sits in the burger's own wrapper (switcher.js), so the gap
     between them is set here and not by Astra's header spacing */
  #ast-mobile-header .ast-button-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
  }

  .ic-lang--mobile {
    flex: 0 0 auto;
  }

  .ic-lang--mobile .ic-lang-btn {
    height: 48px !important;
    padding: 0 14px !important;
    background: var(--ic-bg, #1E293B) !important;
    border: 1px solid rgba(240, 245, 250, 0.2) !important;
    border-radius: 12px !important;
    box-sizing: border-box !important;
  }

  .ic-lang--mobile .ic-lang-btn:hover,
  .ic-lang--mobile .ic-lang-btn:focus-visible,
  .ic-lang--mobile.is-open .ic-lang-btn {
    background: #263449 !important;
  }

  /* Open: the button's own outline grows downward (as the desktop panel does)
     and lists only the other language. The button squares off its bottom
     corners and drops its bottom border; the extension below it carries the
     side and bottom borders, exactly as wide as the button. */
  .ic-lang--mobile.is-open .ic-lang-btn {
    border-radius: 12px 12px 0 0 !important;
    border-bottom-width: 0 !important; /* not transparent: that leaves a mitred notch at the side borders */
  }

  /* The bar is inset from the button's border (desktop keeps it at the pill's
     edge); the text starts at 14px */
  .ic-lang--mobile.is-open .ic-lang-btn::before {
    left: 6px;
  }

  .ic-lang--mobile .ic-lang-menu {
    top: 100%;
    left: 0;
    right: 0;
    width: auto;
    gap: 0;
    padding: 0 6px 6px;
    border-top: 0;
    border-radius: 0 0 12px 12px;
    box-shadow: 0 12px 20px -8px rgba(0, 0, 0, 0.4);
    transform-origin: top;
    animation: ic-lang-grow 0.16s ease-out;
  }

  .ic-lang.ic-lang--mobile .ic-lang-opt {
    padding: 10px 8px !important; /* its letters line up with the button's */
  }

  /* The button already shows the current language */
  .ic-lang.ic-lang--mobile .ic-lang-opt[aria-checked="true"] {
    display: none !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ic-lang-menu {
    animation: none;
  }
  .ic-lang-chev,
  .ic-lang .ic-lang-btn,
  .ic-lang .ic-lang-opt {
    transition: none;
  }
}
