/* NRF switches (3 Dec 2026): "Stretch" for dark/light and "Slider" for Bangla/English, used on the website,
   /go, the admin panel, the newsroom and the Task Board.
   Smoothness: both switches move only with transform (the graphics card draws it, on its own layer), so the motion
   stays smooth while the page underneath repaints for the new theme or language. Their size never changes. */

/* ---------- Stretch (theme) ----------
   --t = knob size. Track = knob + 1.75 knobs of travel + 3px inset and 1px edge on each side. */
.nsw-theme{
  --t:20px; --x:calc(var(--t) * 1.75);
  --track:rgba(255,255,255,.08); --edge:rgba(255,255,255,.3);
  --k-light:#f2b632; --k-dark:#ffffff; --ico:rgba(255,255,255,.62); --ico-on-light:#0b0f39; --ico-on-dark:#0b0f39;
  position:relative; flex:none; box-sizing:border-box; width:calc(var(--t) * 2.75 + 8px); height:calc(var(--t) + 8px);
  padding:0; margin:0; border:1px solid var(--edge); border-radius:999px; background:var(--track); cursor:pointer;
  -webkit-tap-highlight-color:transparent; touch-action:manipulation; contain:layout paint; vertical-align:middle;
}
.nsw-theme .k{
  position:absolute; top:3px; left:3px; width:var(--t); height:var(--t); border-radius:999px; background:var(--k-light);
  transform-origin:0 50%; transform:translateX(0); will-change:transform; backface-visibility:hidden;
  transition:background-color .45s;
}
.nsw-theme .ic{position:absolute; top:3px; z-index:1; width:var(--t); height:var(--t); display:grid; place-items:center; color:var(--ico); pointer-events:none; transition:color .3s .12s}
.nsw-theme .ic svg{width:62%; height:62%; fill:none; stroke:currentColor; stroke-width:2.2; stroke-linecap:round; stroke-linejoin:round}
.nsw-theme .i1{left:3px} .nsw-theme .i2{left:calc(3px + var(--x))}
.nsw-theme .i1{color:var(--ico-on-light)}
/* dark: knob on the right. Before the script has run, the page's own theme decides, so there is no jump on load. */
.nsw-theme[aria-checked="true"] .k,:root[data-theme="dark"] .nsw-theme:not([aria-checked]) .k{transform:translateX(var(--x)); background:var(--k-dark)}
.nsw-theme[aria-checked="true"] .i1,:root[data-theme="dark"] .nsw-theme:not([aria-checked]) .i1{color:var(--ico)}
.nsw-theme[aria-checked="true"] .i2,:root[data-theme="dark"] .nsw-theme:not([aria-checked]) .i2{color:var(--ico-on-dark)}
/* the stretch plays only after a click (never on page load) */
.nsw-theme[data-anim="r"] .k{animation:nswR .5s both}
.nsw-theme[data-anim="l"] .k{animation:nswL .5s both}
@keyframes nswR{
  0%{transform:translateX(0) scaleX(1); animation-timing-function:cubic-bezier(.65,0,.35,1)}
  45%{transform:translateX(0) scaleX(2.75); animation-timing-function:cubic-bezier(.65,0,.35,1)}
  100%{transform:translateX(var(--x)) scaleX(1)}
}
@keyframes nswL{
  0%{transform:translateX(var(--x)) scaleX(1); animation-timing-function:cubic-bezier(.65,0,.35,1)}
  45%{transform:translateX(0) scaleX(2.75); animation-timing-function:cubic-bezier(.65,0,.35,1)}
  100%{transform:translateX(0) scaleX(1)}
}
.nsw-theme:focus-visible,.nsw-lang button:focus-visible{outline:2px solid #5ccf7e; outline-offset:3px}

/* ---------- Slider (language) ----------
   Two equal columns sized to the longer word, so the switch keeps one width in both languages. */
.nsw-lang{
  --h:28px; --track:rgba(255,255,255,.1); --edge:rgba(255,255,255,.3); --k:#0b9444; --on:#ffffff; --off:#d6d8f5; --fs:12.5px;
  position:relative; flex:none; box-sizing:border-box; display:inline-grid; grid-auto-flow:column; grid-auto-columns:1fr;
  height:var(--h); padding:2px; border:1px solid var(--edge); border-radius:999px; background:var(--track); contain:layout paint; vertical-align:middle;
}
.nsw-lang .k{
  position:absolute; top:2px; bottom:2px; left:2px; width:calc(50% - 2px); border-radius:999px; background:var(--k);
  transform:translateX(0); will-change:transform; backface-visibility:hidden; pointer-events:none;
  transition:transform .42s cubic-bezier(.3,1.18,.5,1);
}
.nsw-lang button{
  position:relative; z-index:1; min-width:0; height:100%; margin:0; padding:0 12px; border:0; border-radius:999px; background:none;
  color:var(--off); font:600 var(--fs)/1 var(--sans,system-ui,sans-serif); white-space:nowrap; cursor:pointer;
  -webkit-tap-highlight-color:transparent; touch-action:manipulation; transition:color .3s;
}
.nsw-lang button[lang="bn"]{font-family:"Noto Sans Bengali","Hind Siliguri",var(--sans,system-ui),sans-serif; font-size:calc(var(--fs) + 1.5px)}
.nsw-lang button[aria-pressed="true"]{color:var(--on)}
.nsw-lang button:not([aria-pressed="true"]):hover{color:#fff}
.nsw-lang[data-i="1"] .k{transform:translateX(100%)}
/* before the script has run: the page's language decides (English is always the second button) */
:root:lang(en) .nsw-lang:not([data-i]) .k{transform:translateX(100%)}

/* While the page changes theme, every other colour change is switched off (hundreds at once make a page stutter);
   the theme switch keeps its own. */
html.theme-flip *,html.theme-flip *::before,html.theme-flip *::after{transition:none!important}
html.theme-flip .nsw-theme .k{transition:background-color .45s!important}
html.theme-flip .nsw-theme .ic{transition:color .3s .12s!important}

/* calm reading mode and "reduce motion": the switches change without moving */
html.calm .nsw-theme .k,html.calm .nsw-theme .ic,html.calm .nsw-lang .k,html.calm .nsw-lang button{animation:none!important; transition:none!important}
@media (prefers-reduced-motion:reduce){
  .nsw-theme .k,.nsw-theme .ic,.nsw-lang .k,.nsw-lang button{animation:none!important; transition:none!important}
}

/* ---------- where they sit ---------- */
/* website top bar (navy in both themes) */
.topbar .site-sw.nsw-theme{--t:20px}
.topbar .site-sw.nsw-lang{--h:28px}
@media (pointer:coarse),(max-width:760px){
  .topbar .site-sw.nsw-theme{--t:28px}
  .topbar .site-sw.nsw-lang{--h:36px; --fs:13px}
}
/* admin panel (always dark) */
.ax-sw.nsw-lang{--h:36px; --track:#1d1e23; --edge:var(--ax-edge,rgba(255,255,255,.06)); --k:var(--ax-g2,#12a150); --on:#fff; --off:#9ea1ab; --fs:12.5px}
/* the name block beside it keeps one width in both languages, so the switch never shifts sideways */
.ax-me > span:last-child{min-width:120px}
/* newsroom bar (navy) */
.nbar .nsw-theme{--t:20px}
/* /go top bar (navy) */
.go-top .nsw-theme{--t:28px; --edge:rgba(255,255,255,.35); --track:transparent}
.go-top .nsw-lang{--h:40px; --edge:rgba(255,255,255,.35); --track:transparent; --off:#fff; --fs:15px}
.go-top .nsw-lang button[lang="bn"]{font-size:15px}
/* Task Board header (follows its own light/dark colours) */
.tb-sw.nsw-theme{--t:26px; --track:var(--bg); --edge:var(--line); --ico:var(--mut); --k-dark:var(--ink); --ico-on-dark:var(--card); --ico-on-light:#1b2a22}

/* The header keeps one height in both languages, so nothing below it jumps when the language changes.
   (Bangla keeps its slightly larger letters; only the line heights are fixed, at the Bangla values.) */
.tbl-pill > span{line-height:16px}
.head .search input,.head .search button{line-height:25.6px}
#navIn .ni > a{line-height:23.2px}

/* phones: the top-bar row stays one row (Aa, Facebook, YouTube, theme, language) */
@media screen and (max-width:560px){
  .topbar .site-sw.nsw-theme{--t:21px}
  .topbar .site-sw.nsw-lang{--h:36px; --fs:13px}
  .topbar .site-sw.nsw-lang button{padding:0 7px}
}
/* /go on phones: smaller switches; the NRF logo stays and the name beside it gives way */
@media screen and (max-width:440px){
  .go-top .nsw-theme{--t:24px}
  .go-top .nsw-lang{--h:38px; --fs:14px}
  .go-top .nsw-lang button{padding:0 10px}
  .go-top .nsw-lang button[lang="bn"]{font-size:14.5px}
  .go-brand > span{display:none}
}
