/* Fluid switch (15 Nov 2026): Sapta's on/off control for the whole site.
   A sunk pill track, a textured rounded-square knob, a colour that floods in from the knob, and an icon on the knob that
   changes shape when it flips. Works on three kinds of markup:
     <label class="fsw"><input type="checkbox"><span class="fsw-t"><span class="fsw-k">ICON</span></span><span class="fsw-l">Label</span></label>
     <button class="fsw" role="switch" aria-checked="false"><span class="fsw-t"><span class="fsw-k">ICON</span></span>…</button>
     any element with class "fsw" that gets class "on"
   js/site/fluid-switch.js builds the inner parts for [data-fsw] and adds the stretch while the knob travels.
   Colours: set --fsw-on (fill) and --fsw-glow per world; sizes scale with --fsw-h. */
.fsw{--fsw-h:34px;--fsw-w:calc(var(--fsw-h)*1.86);--fsw-pad:calc(var(--fsw-h)*.09);--fsw-on:#ff9a0a;--fsw-glow:#ffd21f;--fsw-off:#e7e3da;--fsw-rim:#f4f1ea;--fsw-knob:#efece6;
  display:inline-flex;align-items:center;gap:10px;cursor:pointer;-webkit-tap-highlight-color:transparent;user-select:none;background:none;border:0;padding:0;font:inherit;color:inherit;vertical-align:middle}
.fsw input{position:absolute;opacity:0;width:1px;height:1px;pointer-events:none}
.fsw-t{position:relative;flex:0 0 auto;display:block;width:var(--fsw-w);height:var(--fsw-h);border-radius:calc(var(--fsw-h)/2);
  background:var(--fsw-off);
  box-shadow:0 0 0 calc(var(--fsw-h)*.07) var(--fsw-rim),0 calc(var(--fsw-h)*.05) calc(var(--fsw-h)*.12) calc(var(--fsw-h)*.07) rgba(60,50,30,.16),inset 0 calc(var(--fsw-h)*.09) calc(var(--fsw-h)*.16) rgba(60,50,30,.28),inset 0 calc(var(--fsw-h)*-.04) calc(var(--fsw-h)*.08) rgba(255,255,255,.7);
  overflow:hidden;transition:background-color .5s ease}
/* the colour floods in from the knob's side */
.fsw-t::before{content:"";position:absolute;inset:0;border-radius:inherit;
  background:radial-gradient(120% 140% at 100% 50%,var(--fsw-glow) 0%,var(--fsw-on) 42%,color-mix(in srgb,var(--fsw-on) 82%,#7a3a00) 100%);
  clip-path:circle(0% at 22% 50%);transition:clip-path .62s cubic-bezier(.3,1.2,.4,1),filter .5s ease;
  box-shadow:inset 0 calc(var(--fsw-h)*.1) calc(var(--fsw-h)*.2) rgba(120,50,0,.35)}
.fsw-k{position:absolute;top:var(--fsw-pad);left:var(--fsw-pad);width:calc(var(--fsw-h) - var(--fsw-pad)*2);height:calc(var(--fsw-h) - var(--fsw-pad)*2);
  border-radius:38%;display:flex;align-items:center;justify-content:center;
  background-color:var(--fsw-knob);
  background-image:linear-gradient(135deg,rgba(255,255,255,.55) 25%,transparent 25%),linear-gradient(225deg,rgba(255,255,255,.55) 25%,transparent 25%),linear-gradient(45deg,rgba(120,110,95,.16) 25%,transparent 25%),linear-gradient(315deg,rgba(120,110,95,.16) 25%,transparent 25%);
  background-size:calc(var(--fsw-h)*.13) calc(var(--fsw-h)*.13);background-position:0 0,0 0,calc(var(--fsw-h)*.065) calc(var(--fsw-h)*.065),calc(var(--fsw-h)*.065) calc(var(--fsw-h)*.065);
  box-shadow:0 calc(var(--fsw-h)*.06) calc(var(--fsw-h)*.14) rgba(40,30,10,.35),0 0 0 1px rgba(120,110,95,.35),inset 0 1px 0 rgba(255,255,255,.9);
  transition:left .62s cubic-bezier(.3,1.5,.45,1),width .3s ease,border-radius .3s ease;will-change:left,width}
.fsw-k svg{width:58%;height:58%;fill:none;stroke:#4a4338;stroke-width:2.6;stroke-linecap:round;stroke-linejoin:round;overflow:visible;transition:transform .62s cubic-bezier(.3,1.5,.45,1),stroke .4s ease}
.fsw-k svg path{transition:d .55s cubic-bezier(.3,1.3,.45,1),opacity .3s ease}
.fsw-l{font:600 14px/1.2 'Inter Tight',system-ui,sans-serif}

/* on */
.fsw:has(input:checked) .fsw-t::before,.fsw[aria-checked="true"] .fsw-t::before,.fsw[aria-pressed="true"] .fsw-t::before,.fsw.on .fsw-t::before{clip-path:circle(150% at 78% 50%)}
.fsw:has(input:checked) .fsw-k,.fsw[aria-checked="true"] .fsw-k,.fsw[aria-pressed="true"] .fsw-k,.fsw.on .fsw-k{left:calc(100% - var(--fsw-h) + var(--fsw-pad))}
.fsw:has(input:checked) .fsw-k svg,.fsw[aria-checked="true"] .fsw-k svg,.fsw[aria-pressed="true"] .fsw-k svg,.fsw.on .fsw-k svg{transform:rotate(360deg);stroke:#a85a00}
/* the icon changes shape: each icon is one path with an "off" outline and an "on" outline of the same structure */
.fsw-k svg path{d:path(var(--fsw-d0))}
.fsw:has(input:checked) .fsw-k svg path,.fsw[aria-checked="true"] .fsw-k svg path,.fsw[aria-pressed="true"] .fsw-k svg path,.fsw.on .fsw-k svg path{d:path(var(--fsw-d1))}
/* icon sets: off shape, on shape */
.fsw,.fsw[data-icon="check"]{--fsw-d0:"M6 12 L12 12 L18 12";--fsw-d1:"M5.5 12.5 L10.5 17 L18.5 7.5"}
.fsw[data-icon="play"]{--fsw-d0:"M8 6 L8 18 M16 6 L16 18 L16 6";--fsw-d1:"M8 6 L8 18 M8 6 L18 12 L8 18"}
.fsw[data-icon="theme"]{--fsw-d0:"M17 14 A7 7 0 1 1 10 5 A5.5 5.5 0 0 0 17 14";--fsw-d1:"M17 12 A5 5 0 1 1 7 12 A5 5 0 0 0 17 12"}
.fsw[data-icon="sound"]{--fsw-d0:"M5 10 L9 10 L13 6 L13 18 L9 14 L5 14 Z M17 12 L17 12";--fsw-d1:"M5 10 L9 10 L13 6 L13 18 L9 14 L5 14 Z M17 8 L17 16"}
.fsw[data-icon="units"]{--fsw-d0:"M6 8 L18 8 M6 16 L12 16 L18 16";--fsw-d1:"M6 8 L18 16 M6 16 L12 12 L18 8"}
/* the knob stretches while it travels and is squeezed while pressed */
.fsw.moving .fsw-k{width:calc((var(--fsw-h) - var(--fsw-pad)*2)*1.34);border-radius:32%}
.fsw:active .fsw-k{width:calc((var(--fsw-h) - var(--fsw-pad)*2)*1.18)}
.fsw:has(input:checked):active .fsw-k,.fsw[aria-checked="true"]:active .fsw-k,.fsw.on:active .fsw-k{left:calc(100% - var(--fsw-h) + var(--fsw-pad) - (var(--fsw-h) - var(--fsw-pad)*2)*.18)}
.fsw.moving.on-going .fsw-k,.fsw.moving:has(input:checked) .fsw-k{left:calc(100% - var(--fsw-h) + var(--fsw-pad) - (var(--fsw-h) - var(--fsw-pad)*2)*.34)}
.fsw.moving .fsw-t::before{filter:brightness(1.12)}
.fsw:focus-visible .fsw-t,.fsw:has(input:focus-visible) .fsw-t{outline:2px solid #2b4bff;outline-offset:4px}
.fsw.fsw-lg{--fsw-h:48px}.fsw.fsw-sm{--fsw-h:26px}
/* on dark surfaces */
.fsw.fsw-dark{--fsw-off:#2a2d36;--fsw-rim:#1c1e25;--fsw-knob:#e9e6df}
@media (prefers-reduced-motion:reduce){.fsw-k,.fsw-k svg,.fsw-k svg path,.fsw-t::before{transition:none}}
