/* 4 Sensei — one popover pointer / surface convention.
   Language, account and instruction lifecycle menu share a single pointer style.
   This file is loaded on public AND authenticated pages, after module styles.
   Do not style drawers, confirmations or AI dialogs as popovers. */

/* Local variables preserve the current component's palette without global
   color overrides or duplicated arrow implementations. */
.sensei-language-picker__menu,
.sensei-ai-shell .account-menu,
.iw-app .iw-actions-menu {
  --sensei-popover-surface: #fff;
  --sensei-popover-border: #dfe6ef;
}
.sensei-language-picker__menu { --sensei-popover-border: #dbe4f1; }
.iw-app .iw-actions-menu {
  --sensei-popover-surface: var(--iw-panel, #fff);
  --sensei-popover-border: var(--iw-line, #dfe6ef);
}

/* Account panel used to be semi-transparent; text from the page below
   was visible through the dropdown. Use a solid surface, preserve the card. */
.sensei-ai-shell .account-menu { overflow: visible; }
html:not([data-theme='dark']) .sensei-ai-shell .account-menu { background: #fff !important; }

.sensei-language-picker__menu::before,
.sensei-ai-shell .account-menu::before,
.iw-app .iw-actions-menu::before {
  content: '';
  position: absolute;
  box-sizing: border-box;
  top: -6px;
  right: 23px;
  width: 11px;
  height: 11px;
  transform: rotate(45deg);
  background: var(--sensei-popover-surface);
  border-top: 1px solid var(--sensei-popover-border);
  border-left: 1px solid var(--sensei-popover-border);
  pointer-events: none;
}

/* The account dropdown is wider than its trigger. Align the pointer with
   the TRIGGER CENTER, not the popover's right edge (which pointed at the
   adjacent “New instruction” CTA). */
.sensei-ai-shell .account-menu {
  right: calc(50% - 28px);
}
.sensei-global-actions .account-menu-wrap { z-index: 2; }
@media (max-width: 750px) {
  .sensei-ai-shell .account-menu { right: 0; width: min(310px, calc(100vw - 84px)); }
  .sensei-ai-shell .account-menu::before { right: 11px; }
}

/* A three-dot action menu opens toward the right of its button on desktop. */
.iw-app .iw-actions-menu::before { left: 12px; right: auto; }
@media(max-width:520px) {
  /* On phones its menu is right-aligned to avoid clipping. */
  .iw-app .iw-actions-menu::before { left: auto; right: 12px; }
}
html[data-theme='dark'] .sensei-language-picker:not(.sensei-language-picker--public) .sensei-language-picker__menu {
  --sensei-popover-surface: #1b293c;
  --sensei-popover-border: #34445a;
}
html[data-theme='dark'] .sensei-ai-shell .account-menu {
  --sensei-popover-surface: var(--sx-elevated, #1b293c);
  --sensei-popover-border: var(--sx-line, #34445a);
}
html[data-theme='dark'] .iw-app .iw-actions-menu {
  --sensei-popover-surface: var(--iw-panel, #1b293c);
  --sensei-popover-border: var(--iw-line, #34445a);
}
