/* Theme switcher (sandbox test, 4 Dec). Colours come from --th-* (r, g, b triplets) set by xv-theme.js.
   :root[data-xv-theme][data-xv-theme] doubles the attribute so these rules beat the Information page's
   html.xv-dark and the Playground's html.xv-blue without !important. */

/* The switcher: a cap-height square right after the name in the header, filled with the next theme's colour.
   The faint ring keeps it visible when the square matches the page (black on Information, blue on Playground).
   ::after widens the hit area to 32px without moving the layout. */
.xv-theme { position: relative; display: inline-block; width: .62em; height: .62em; margin-left: .55em; padding: 0; border: 0;
  vertical-align: baseline; background: none; cursor: pointer; appearance: none; }
.xv-theme::before { content: ""; position: absolute; inset: 0; box-shadow: inset 0 0 0 1px rgba(128, 128, 128, .45);
  transition: background-color .35s ease, border-radius .4s cubic-bezier(.16, 1, .3, 1), transform .25s cubic-bezier(.16, 1, .3, 1); }
.xv-theme::after { content: ""; position: absolute; left: 50%; top: 50%; width: 32px; height: 32px; transform: translate(-50%, -50%); }
/* Hover: the square morphs into a circle. !important because xv.css forces square corners on everything. */
.xv-theme:hover::before, .xv-theme:focus-visible::before { border-radius: 50% !important; }
.xv-theme:active::before { transform: scale(.85); }
.xv-theme:focus-visible { outline: 1px solid currentColor; outline-offset: 3px; }
.xv-theme[data-next="dark"]::before { background: #000; }
/* Brand blue #0026FF, lifted slightly: a 9px square of it on black reads darker than the full blue page,
   so this compensates to make the square feel like the site's blue (Xander, 4 Dec). No grey ring. */
.xv-theme[data-next="blue"]::before { background: #2D55FF; box-shadow: none; }
.xv-theme[data-next="light"]::before { background: #fff; }
/* Fallback if a page has no header */
.xv-theme--float { position: fixed; z-index: 8000; right: var(--pageMarginTotal); bottom: var(--pageMarginTotal); width: 10px; height: 10px; margin: 0; }

/* The base stylesheet's colour triplets follow the theme */
:root[data-xv-theme][data-xv-theme] {
  --black: var(--th-fg); --grey-100: var(--th-fg); --grey-80: var(--th-fg); --white: var(--th-bg); --grey-10: var(--th-card);
  --grey-60: var(--th-muted); --grey-40: var(--th-muted); --secondary: var(--th-muted); --tertiary: var(--th-muted);
  --grey-20: var(--th-line); --border-subtle: var(--th-line);
}

/* Surfaces */
:root[data-xv-theme][data-xv-theme], :root[data-xv-theme][data-xv-theme] body,
:root[data-xv-theme][data-xv-theme] header.xv-header { background: rgb(var(--th-bg)); color: rgb(var(--th-fg)); }
:root[data-xv-theme][data-xv-theme] nav { background-color: rgba(var(--th-bg), .9); }
:root[data-xv-theme][data-xv-theme] .media { background-color: rgb(var(--th-card)); }

/* Text */
:root[data-xv-theme][data-xv-theme] :is(header, main, footer, a, span, p, h1, h2, h3, h4, li, dt, dd, figcaption) { color: rgb(var(--th-fg)); }
:root[data-xv-theme][data-xv-theme] :is(.thin, .color-grey-40, .color-grey-60, .xv-file, .media-caption) { color: rgb(var(--th-muted)); }
:root[data-xv-theme][data-xv-theme] :is(.color-black, .color-green-100) { color: rgb(var(--th-fg)); }
:root[data-xv-theme][data-xv-theme] .xv-contact-row a:hover { color: rgb(var(--th-muted)); }

/* Lines */
:root[data-xv-theme][data-xv-theme] :is(header.xv-header, footer, .footer-bottom, .grid-overlay, hr) { border-color: rgb(var(--th-line)); }

/* Selection */
:root[data-xv-theme][data-xv-theme] ::selection { background: rgb(var(--th-fg)); color: rgb(var(--th-bg)); }

/* Keep brand pieces as they are: the blue loader, tooltips and the image viewer */
:root[data-xv-theme][data-xv-theme] :is(.loader, .xv-tip) :is(a, span, p) { color: #fff; }
