/* The community language picker (social_community_switcher in inc/social_lib.php): an oval button (globe + the community's code) and a menu with
 * Global on top and the local communities below: a popover on desktop, a bottom sheet on phones. Linked by the function itself, so every page
 * that shows the picker gets it. */
.cl-switch{flex:none; position:relative; margin-inline-start:2px;}

/* closed button: a quiet circle ring with the globe and a small code badge on its corner */
.cl-switch > summary.cl-pill{list-style:none; position:relative; display:inline-flex; align-items:center; justify-content:center; gap:0; width:34px !important; height:34px !important; min-width:0; padding:0; box-sizing:border-box; border:0; border-radius:50% !important; background:transparent; box-shadow:inset 0 0 0 1px var(--border-soft); color:var(--navy); cursor:pointer; user-select:none; -webkit-tap-highlight-color:transparent; transition:background .2s, box-shadow .2s, transform .12s;}
.cl-switch > summary.cl-pill::before{content:""; position:absolute; inset:-4px; border-radius:50%;}   /* a little more room to tap */
.cl-switch > summary.cl-pill::-webkit-details-marker{display:none;}
.cl-switch > summary.cl-pill svg{width:17px; height:17px; flex:none; color:var(--navy-soft); transition:color .2s;}
.cl-switch > summary.cl-pill:active{transform:scale(.96);}
.cl-switch > summary.cl-pill:hover,.cl-switch[open] > summary.cl-pill{background:var(--blue-tint); color:var(--navy);}
.cl-switch > summary.cl-pill:hover svg,.cl-switch[open] > summary.cl-pill svg{color:var(--navy);}
.cl-switch > summary.cl-pill:focus-visible{outline:2px solid var(--blue); outline-offset:2px;}
.cl-badge{position:absolute; inset-inline-end:-4px; bottom:-4px; display:grid; place-items:center; min-width:0; height:auto; padding:3px 4px; box-sizing:border-box; border-radius:999px; background:var(--navy); color:var(--white); font:700 8.5px/1 'JetBrains Mono',monospace; letter-spacing:.03em; font-style:normal; box-shadow:0 0 0 2px var(--white);}
.cl-badge[lang="ar"]{font:700 11px/1 'Inter',sans-serif; letter-spacing:0; padding:2px 5px;}
.cl-pill.is-global .cl-badge{background:var(--teal); color:#06231c;}

/* menu (desktop: a popover under the button) */
.cl-switch .lang-menu.cl-menu{display:block; width:320px; max-width:calc(100vw - 24px); box-sizing:border-box; padding:10px; margin:0; z-index:90; border-radius:18px; transform-origin:top right;}
html[dir="rtl"] .cl-switch .lang-menu.cl-menu{transform-origin:top left;}
.cl-switch[open] .lang-menu.cl-menu{animation:cl-in .22s cubic-bezier(.3,1.3,.5,1);}
@keyframes cl-in{from{opacity:0; transform:translateY(-6px) scale(.98);} to{opacity:1; transform:none;}}
.cl-menu .cl-title{margin:6px 8px 0; font:800 15px/1.3 'Sora',sans-serif; color:var(--navy);}
html[lang="ar"] .cl-title,html[lang="ja"] .cl-title{font-family:inherit;}
.cl-menu .cl-hint{margin:4px 8px 10px; font:500 12.5px/1.45 'Inter',sans-serif; color:var(--navy-soft);}
.cl-menu button{display:flex; align-items:center; gap:12px; width:100%; box-sizing:border-box; border:0; color:var(--navy); font-family:inherit; text-align:start; cursor:pointer; -webkit-tap-highlight-color:transparent;}
.cl-hero{padding:10px; margin:0 0 6px; border-radius:14px; border:1.5px solid var(--border-soft) !important; background:transparent;}
.cl-hero:hover{background:var(--blue-tint);}
.cl-hero.is-current{border-color:var(--teal) !important; background:var(--mint-tint);}
.cl-ht{width:40px; height:40px; border-radius:12px; background:var(--teal); color:#06231c; display:flex; align-items:center; justify-content:center; flex:none;}
.cl-hx,.cl-rx{flex:1; min-width:0; display:flex; flex-direction:column; gap:2px;}
.cl-hx b{font:700 14.5px/1.2 'Sora',sans-serif;}
html[lang="ar"] .cl-hx b,html[lang="ja"] .cl-hx b{font-family:inherit;}
.cl-hx small,.cl-rx small{font:500 12px/1.3 'Inter',sans-serif; color:var(--navy-soft);}
.cl-menu .cl-sep{margin:12px 8px 4px; font:700 10px/1 'JetBrains Mono',monospace; letter-spacing:.12em; text-transform:uppercase; color:var(--navy-soft);}
html[lang="ar"] .cl-menu .cl-sep,html[lang="ja"] .cl-menu .cl-sep{letter-spacing:0; text-transform:none; font-family:inherit; font-size:12px;}
.cl-row{padding:9px 10px; border-radius:14px; background:transparent;}
.cl-row:hover{background:var(--blue-tint);}
.cl-row.is-current{background:var(--mint-tint);}
.cl-lc{width:40px; height:40px; border-radius:12px; background:var(--blue-tint); box-shadow:inset 0 0 0 1px var(--border-soft); display:flex; align-items:center; justify-content:center; flex:none; font:700 12px/1 'JetBrains Mono',monospace; color:var(--navy);}
.cl-lc[lang="ar"]{font:700 17px/1 'Inter',sans-serif;}
.cl-rx b{font:700 14.5px/1.2 'Inter',sans-serif;}
html[lang="ar"] .cl-rx b,html[lang="ja"] .cl-rx b{font-family:inherit;}
/* the choice marker: an empty ring, filled with a check on the current community */
.cl-ck{display:inline-grid; place-items:center; width:22px; height:22px; border-radius:50%; box-sizing:border-box; border:1.5px solid var(--border-soft); color:transparent; flex:none; transition:background .2s, border-color .2s;}
.cl-ck svg{width:13px; height:13px;}
.is-current > .cl-ck{background:var(--teal); border-color:var(--teal); color:#06231c;}
.cl-menu button:focus-visible{outline:2px solid var(--blue); outline-offset:1px;}

/* phone: the menu is a bottom sheet over a dimmed page; the dim layer is the open <details> itself, so tapping it closes the picker */
@media (max-width:720px){
  .cl-switch > summary.cl-pill{width:36px !important; height:36px !important;}
  .cl-switch[open]::after{content:""; position:fixed; inset:0; background:rgba(0,0,0,.42); z-index:89; animation:cl-fade .2s ease;}
  .cl-switch .lang-menu.cl-menu{position:fixed; inset:auto 0 0 0; top:auto; width:auto; max-width:none; max-height:86dvh; overflow-y:auto; overscroll-behavior:contain; border-radius:22px 22px 0 0; border-width:1px 0 0; padding:6px 12px calc(16px + env(safe-area-inset-bottom, 0px)); transform-origin:bottom;}
  .cl-switch .lang-menu.cl-menu::before{content:""; display:block; width:38px; height:4px; border-radius:4px; background:var(--border-soft); margin:4px auto 8px;}
  .cl-switch[open] .lang-menu.cl-menu{animation:cl-sheet .3s cubic-bezier(.3,1.1,.5,1);}
  .cl-row{padding:11px 10px;}
}
@keyframes cl-fade{from{opacity:0;} to{opacity:1;}}
@keyframes cl-sheet{from{transform:translateY(100%);} to{transform:none;}}
@media (prefers-reduced-motion:reduce){ .cl-switch > summary.cl-pill{transition:none;} .cl-switch[open] .lang-menu.cl-menu,.cl-switch[open]::after{animation:none;} }
