/* PolySEO AI RC17 STAGING PILOT — scoped compact selector, left by default. */
#psai-language-choice.psai-language {
  box-sizing:border-box; position:fixed; left:16px; bottom:calc(16px + env(safe-area-inset-bottom, 0px)); right:auto; z-index:99990;
  width:max-content; max-width:min(94vw,350px); border-radius:12px;
  background:#fff; color:#172033; border:1px solid #d1d5db;
  box-shadow:0 3px 18px rgba(0,0,0,.14); font:14px/1.45 system-ui,sans-serif;
}
#psai-language-choice.psai-language[data-position="right"] { left:auto; right:16px; }
#psai-language-choice *, #psai-language-choice *::before, #psai-language-choice *::after { box-sizing:border-box; }
#psai-language-choice .psai-language-trigger {
  display:flex; align-items:center; gap:7px; width:100%; border:0; background:transparent;
  color:inherit; padding:9px 12px; font:600 14px/1.4 system-ui,sans-serif; cursor:pointer;
  text-align:left; border-radius:11px;
}
#psai-language-choice .psai-language-short { display:none; }
#psai-language-choice .psai-language-chevron { margin-left:auto; font-size:18px; line-height:1; }
#psai-language-choice[data-open="1"] .psai-language-chevron { transform:rotate(180deg); }
#psai-language-choice .psai-language-flag { display:inline-block; min-width:1.35em; line-height:1; }
#psai-language-choice .psai-language-options { border-top:1px solid #e5e7eb; padding:6px; }
#psai-language-choice .psai-language-options[hidden], #psai-language-choice .psai-language-suggestion[hidden] { display:none!important; }
#psai-language-choice .psai-language-options a, #psai-language-choice .psai-language-options span.psai-language-active {
  display:block; padding:8px 9px; color:#172033; border-radius:8px;
  font:500 14px/1.4 system-ui,sans-serif; text-decoration:none; margin:0;
}
#psai-language-choice .psai-language-options a:hover { background:#eef4ff; color:#144a95; }
#psai-language-choice .psai-language-options .psai-language-active { font-weight:700; background:#f3f4f6; }
#psai-language-choice .psai-language-suggestion { border-top:1px solid #e5e7eb; padding:10px 12px; max-width:320px; }
#psai-language-choice .psai-language-suggestion span { display:block; margin-bottom:8px; }
#psai-language-choice .psai-language-suggestion a { display:inline-block; color:#1456aa; text-decoration:underline; margin-right:10px; }
#psai-language-choice .psai-language-dismiss { padding:0; border:0; background:transparent; cursor:pointer; text-decoration:underline; color:#374151; font:inherit; }
#psai-language-choice a:focus-visible, #psai-language-choice button:focus-visible { outline:2px solid #155bb5; outline-offset:2px; }
@media(max-width:768px) {
  /* Fallback mobile position; Blocksy mobile-header overrides it below. */
  #psai-language-choice.psai-language,
  #psai-language-choice.psai-language[data-position="right"] { left:8px; right:auto; bottom:calc(8px + env(safe-area-inset-bottom, 0px)); max-width:calc(100vw - 16px); }
  #psai-language-choice.psai-language[data-placement="header"] { position:fixed; left:8px; right:auto; bottom:calc(8px + env(safe-area-inset-bottom, 0px)); }
}
@media(prefers-reduced-motion:reduce) { #psai-language-choice * { transition:none!important; } }

/* The header placement occurs only when a real shortcode mount exists.
 * No scroll listener, no animation, no change to document content or SEO tags. */
.psai-language-header-slot { position:relative; display:inline-flex; align-items:center; flex:0 0 auto; }
@media (min-width: 769px) {
  #psai-language-choice.psai-language[data-placement="header"] {
    position:relative; inset:auto; left:auto; right:auto; bottom:auto;
    z-index:99990; max-width:min(340px, 42vw); width:max-content;
  }
  #psai-language-choice.psai-language[data-placement="header"] .psai-language-options,
  #psai-language-choice.psai-language[data-placement="header"] .psai-language-suggestion {
    position:absolute; top:calc(100% + 6px); right:0; left:auto;
    z-index:99991; min-width:max(100%, 190px);
    background:#fff; border:1px solid #d1d5db; border-radius:10px;
    box-shadow:0 3px 18px rgba(0,0,0,.14);
  }
}

/* RC16: unsupported language choices are visible but never clickable. */
#psai-language-choice .psai-language-options span.psai-language-unavailable {
  display:flex; align-items:center; gap:5px; padding:8px 9px; margin:0;
  border-radius:8px; font:500 14px/1.4 system-ui,sans-serif;
  color:#6b7280; cursor:not-allowed;
}
#psai-language-choice .psai-language-unavailable-note {
  margin-left:auto; padding-left:10px; font:400 11px/1.4 system-ui,sans-serif;
  color:#6b7280; white-space:nowrap;
}

/* RC3.2.1 mobile: a single compact, fixed control in the bottom-left
 * viewport corner. It is not inserted into or positioned over the header.
 * The dropdown opens upward, instead of expanding the fixed control over
 * the article. Respect safe-area on devices with a home indicator. */
@media (max-width: 768px) {
  #psai-language-choice.psai-language,
  #psai-language-choice.psai-language[data-placement="floating"],
  #psai-language-choice.psai-language[data-position="right"] {
    position:fixed; inset:auto; top:auto; right:auto;
    left:calc(10px + env(safe-area-inset-left, 0px));
    bottom:calc(12px + env(safe-area-inset-bottom, 0px));
    width:max-content; max-width:calc(100vw - 20px);
    z-index:9990; border-radius:10px;
  }
  #psai-language-choice.psai-language .psai-language-trigger {
    min-width:44px; min-height:44px; width:44px; max-width:44px;
    padding:8px 4px; gap:3px; justify-content:center;
    font-size:12px; line-height:1.2; white-space:nowrap;
  }
  #psai-language-choice.psai-language .psai-language-name { display:none; }
  #psai-language-choice.psai-language .psai-language-short { display:inline; font-size:12px; }
  #psai-language-choice.psai-language .psai-language-flag { display:none; }
  #psai-language-choice.psai-language .psai-language-chevron { font-size:16px; margin-left:0; }
  #psai-language-choice.psai-language .psai-language-options,
  #psai-language-choice.psai-language .psai-language-suggestion {
    position:absolute; left:0; right:auto; top:auto;
    bottom:calc(100% + 6px); z-index:9991;
    min-width:180px; max-width:min(calc(100vw - 20px), 310px);
    max-height:min(60vh, 320px); overflow-y:auto;
    background:#fff; color:#172033; border:1px solid #d1d5db;
    box-shadow:0 3px 18px rgba(0,0,0,.17); border-radius:10px;
  }
  #psai-language-choice.psai-language .psai-language-options a,
  #psai-language-choice.psai-language .psai-language-options .psai-language-active,
  #psai-language-choice.psai-language .psai-language-options .psai-language-unavailable {
    min-height:44px; display:flex; align-items:center;
  }
}

/* RC3.2.3: During downward reading scrolls (including the footer),
 * hide the closed floating trigger so it cannot cover article/copyright.
 * Restore it on upward scroll; JS protects open menus and keyboard focus.
 * The one accessible trigger remains anchored bottom-left when visible. */
@media (max-width: 768px) {
  #psai-language-choice.psai-language {
    transition:opacity 140ms ease,transform 140ms ease;
  }
  #psai-language-choice.psai-language[data-scroll-hidden="1"]:not([data-open="1"]) {
    opacity:0; pointer-events:none;
    transform:translateX(-12px);
  }
}
@media (max-width: 768px) and (prefers-reduced-motion:reduce) {
  #psai-language-choice.psai-language {transition:none!important;}
}
