/* The Light / System / Dark switch (standing-rules reference), collapsed form for AideaMaker sites (owner, 2026-11-22).
   At rest: ONE round button showing the current setting (sun = Light, monitor = System, moon = Dark), a filled circle in the site's ACTION colour
   with a white icon. Open (pointer over it, keyboard focus inside, or a tap): a white pill with a soft shadow holding all three round buttons, the
   chosen one filled, the others grey line icons. Only transform and opacity animate (about 200 ms): nothing on the page moves, because the control is
   fixed-position and every option is absolutely placed. Reduced motion turns the animation off. No script library; no inline style.
   Map the tokens below to the site's own tokens (keep the names, or replace the var() names). */
.theme-switch { --ts-size: 40px; display: block; padding: 0; border: 0; background: transparent; gap: 0; box-shadow: none; --ts-gap: 4px; --ts-pad: 4px; --ts-dur: 200ms; --ts-ease: cubic-bezier(.2, .7, .2, 1);
  position: relative; isolation: isolate; width: var(--ts-size); height: var(--ts-size); flex: none; }

/* the open pill: a surface behind the three buttons; hidden at rest and never takes the pointer at rest, so the hover area at rest is the one button */
.theme-switch::before { content: ""; position: absolute; z-index: -1; box-sizing: border-box;
  top: calc(var(--ts-pad) * -1); right: calc(var(--ts-pad) * -1);
  width: calc(3 * var(--ts-size) + 2 * var(--ts-gap) + 2 * var(--ts-pad)); height: calc(var(--ts-size) + 2 * var(--ts-pad));
  border: 1px solid var(--ts-line); border-radius: 999px; background: var(--ts-surface); box-shadow: 0 4px 16px rgba(0, 0, 0, .16);
  opacity: 0; transform: scaleX(.4); transform-origin: right center; pointer-events: none;
  transition: transform var(--ts-dur) var(--ts-ease), opacity var(--ts-dur) var(--ts-ease); }

/* the three buttons are stacked at the right edge; --ts-k is how many steps each one slides left when open (Light, System, Dark left to right) */
.theme-opt { --ts-k: 0; appearance: none; -webkit-appearance: none; position: absolute; top: 0; right: 0; display: grid; place-items: center;
  width: var(--ts-size); height: var(--ts-size); margin: 0; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--ts-muted); cursor: pointer;
  opacity: 0; visibility: hidden; pointer-events: none; transform: translateX(0);
  transition: transform var(--ts-dur) var(--ts-ease), opacity var(--ts-dur) var(--ts-ease), visibility 0s linear var(--ts-dur), background-color var(--ts-dur) ease, color var(--ts-dur) ease; }
.theme-opt[data-theme-set="dark"] { --ts-k: 0; }
.theme-opt[data-theme-set="system"] { --ts-k: 1; }
.theme-opt[data-theme-set="light"] { --ts-k: 2; }
.theme-opt .i, .theme-opt svg { display: block; width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }

/* at rest only the chosen one shows */
.theme-opt[aria-checked="true"] { z-index: 1; background: var(--ts-action); color: var(--ts-on-action); opacity: 1; visibility: visible; pointer-events: auto; box-shadow: 0 4px 16px rgba(0, 0, 0, .16); }
.theme-opt:focus-visible { outline: 2px solid var(--ts-focus); outline-offset: 2px; }
.theme-opt[aria-checked="true"]:focus-visible { outline-offset: 3px; box-shadow: 0 0 0 2px var(--ts-surface); }

/* open: .is-open (script: keyboard focus inside, or a tap) and, on devices that hover, :hover */
.theme-switch.is-open::before { opacity: 1; transform: none; pointer-events: auto; }
.theme-switch.is-open .theme-opt { opacity: 1; visibility: visible; pointer-events: auto; transition-delay: 0s;
  transform: translateX(calc(var(--ts-k) * (var(--ts-size) + var(--ts-gap)) * -1)); }
.theme-switch.is-open .theme-opt[aria-checked="true"] { box-shadow: none; }
.theme-switch.is-open .theme-opt:not([aria-checked="true"]):hover { background: var(--ts-wash); color: var(--ts-ink); }
@media (hover: hover) {
  .theme-switch:hover::before { opacity: 1; transform: none; pointer-events: auto; }
  .theme-switch:hover .theme-opt { opacity: 1; visibility: visible; pointer-events: auto; transition-delay: 0s;
    transform: translateX(calc(var(--ts-k) * (var(--ts-size) + var(--ts-gap)) * -1)); }
  .theme-switch:hover .theme-opt[aria-checked="true"] { box-shadow: none; }
  .theme-switch:hover .theme-opt:not([aria-checked="true"]):hover { background: var(--ts-wash); color: var(--ts-ink); }
}
/* Escape (or a choice) closes it even while the pointer is over it or focus is inside: the script adds .is-dismissed until the pointer leaves or focus moves out */
.theme-switch.is-dismissed:not(.is-open)::before { opacity: 0; transform: scaleX(.4); pointer-events: none; }
.theme-switch.is-dismissed:not(.is-open) .theme-opt { transform: translateX(0); }
.theme-switch.is-dismissed:not(.is-open) .theme-opt:not([aria-checked="true"]) { opacity: 0; visibility: hidden; pointer-events: none; }
.theme-switch.is-dismissed:not(.is-open) .theme-opt[aria-checked="true"] { box-shadow: 0 4px 16px rgba(0, 0, 0, .16); }

@media (pointer: coarse), (max-width: 640px) { .theme-switch { --ts-size: 44px; } }   /* 44 px on a phone (design look pass, T-114) */
@media (prefers-reduced-motion: reduce) { .theme-switch::before, .theme-opt { transition: none !important; } }

/* The site's tokens (--ts-action and the rest) are mapped in base.css; this file loads after it and replaces its always-open pill.
   Floating: bottom-right corner over the page, above content, below dialogs, drawers and toasts (give those a higher z-index).
   The page's own last row is never hidden behind it: give the footer (or main) about 56px of bottom padding.
   Sharing the corner with the floating AI assistant button (ai-providers): the assistant keeps the corner, the switch sits directly above it.
   Set --ts-lift to the assistant button's height plus its gap (for example 72px) on <html> when the assistant exists. */
.theme-float .theme-switch { box-shadow: none; }
.theme-float { position: fixed; z-index: 90; right: max(16px, env(safe-area-inset-right, 0px)); bottom: calc(max(16px, env(safe-area-inset-bottom, 0px)) + var(--ts-lift, 0px)); margin: 0; }

/* the switch needs the script: without it the buttons would do nothing */
html:not(.theme-js) .theme-switch { display: none; }
@media print { .theme-switch, .theme-float { display: none; } }
@media (forced-colors: active) { .theme-opt[aria-checked="true"] { outline: 2px solid Highlight; } .theme-switch::before { border-color: CanvasText; } }
