/* Ported for the case-study sites (3 Dec 2026) from 1. Brand & Website/site/src/components/theme-switch/theme-switch.css:
   only its size and place changed (it sits in normal flow, --ts-w by --ts-h), and its focus ring takes the brand colour.
   The original:
   ---------- THE THEME SWITCH (ThemeSwitch.tsx): the castle, one illustration ----------
   A sky, a castle in two layers (theme-art.ts), and the knob (a cartoon sun by day, a cartoon moon
   at night) that slides from the left (light) to the right (dark), passing behind the towers.
   By day one warm family of golds (so the light mode sits calmly); by night purple-navy, the castle
   near-black and its windows lit. Colours change by crossfading the skies and transitioning fills.
   Earlier switches: backups/2026-11-09-cinematic/theme-switch-v1/, -v2/, -v3-photo/. */
.ts {
  position: relative;
  flex: none;
  width: var(--ts-w, 120px);
  height: var(--ts-h, 44px);
  padding: 0;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  background: none;
  pointer-events: auto;
  overflow: hidden;
  isolation: isolate;
  -webkit-tap-highlight-color: transparent;
  /* the knob's disc 22 px, centred on the pill's end circle, so the sun's rays (a fifth past it) fit inside */
  --ks: 22px;
  --kl: 9px;
  --kt: 9px;
  --ease: cubic-bezier(0.65, 0, 0.35, 1);
  box-shadow:
    inset 0 0 0 1px var(--edge),
    0 3px 10px -3px rgba(120, 45, 10, 0.45);
  transition: box-shadow 0.7s var(--ease);
}
/* light mode's palettes (ThemeSwitch.tsx): an orange sky the yellow sun stands out on, so the
   switch reads against the cream page; the castle a deeper tone of it. Two kept of four tried:
   4 Brand fire (the default) and 1 Sunset orange (?sky=1). TODO BEFORE PRODUCTION: keep one,
   delete the other (here and in ThemeSwitch.tsx). 2 Amber gold and 3 Coral dusk:
   backups/2026-11-09-cinematic/theme-switch-v5-palettes/ */
.ts-p1 {
  /* 1 SUNSET ORANGE */
  --s1: #ffc56c;
  --s2: #ff9d47;
  --s3: #f2732d;
  --far: #ec8d45;
  --wall: #c4561f;
  --roof: #93351a;
  --gate: #7c2a12;
  --bars: #5a1d0b;
  --shade: #6a2208;
  --win: #ffe0ae;
  --cloud: #fff4e4;
  --edge: rgba(170, 70, 20, 0.5);
}
.ts-p4 {
  /* 4 BRAND FIRE: the site's own red-orange */
  --s1: #ffb05e;
  --s2: #f77d2f;
  --s3: #d84a1f;
  --far: #df6a32;
  --wall: #902b14;
  --roof: #661b0c;
  --gate: #4c1408;
  --bars: #330d05;
  --shade: #3a0f05;
  --win: #ffcf96;
  --cloud: #ffeedd;
  --edge: rgba(140, 40, 15, 0.55);
}
:root[data-theme='dark'] .ts {
  box-shadow:
    inset 0 0 0 1px rgba(245, 183, 10, 0.32),
    0 4px 14px -6px rgba(0, 0, 0, 0.6);
}
.ts:focus-visible {
  outline: 2px solid var(--brand, #f5b70a);
  outline-offset: 3px;
}
.ts-track {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  overflow: hidden;
}
.ts-day,
.ts-night {
  position: absolute;
  inset: 0;
  transition: opacity 0.7s var(--ease);
}
.ts-day {
  background: linear-gradient(180deg, var(--s1) 0%, var(--s2) 52%, var(--s3) 100%);
}
.ts-night {
  background: linear-gradient(180deg, #110c31 0%, #271d58 58%, #46295a 100%);
  opacity: 0;
}
:root[data-theme='dark'] .ts-night {
  opacity: 1;
}
:root[data-theme='dark'] .ts-day {
  opacity: 0;
}

/* the stars, twinkling at night */
.ts-star {
  position: absolute;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: #fffaf0;
  box-shadow: 0 0 3px #fff;
  opacity: 0;
  transition: opacity 0.6s;
}
:root[data-theme='dark'] .ts-star {
  opacity: 1;
  animation: ts-twinkle 2.8s ease-in-out infinite;
}
.ts-s0 {
  left: 10%;
  top: 22%;
}
.ts-s1 {
  left: 22%;
  top: 50%;
  width: 1.5px;
  height: 1.5px;
  animation-delay: -0.7s !important;
}
.ts-s2 {
  left: 33%;
  top: 14%;
  animation-delay: -1.3s !important;
}
.ts-s3 {
  left: 46%;
  top: 30%;
  width: 1.5px;
  height: 1.5px;
  animation-delay: -1.9s !important;
}
.ts-s4 {
  left: 57%;
  top: 12%;
  animation-delay: -0.4s !important;
}
.ts-s5 {
  left: 27%;
  top: 32%;
  width: 1px;
  height: 1px;
  animation-delay: -2.2s !important;
}
.ts-s6 {
  left: 64%;
  top: 34%;
  width: 1px;
  height: 1px;
  animation-delay: -1.1s !important;
}
@keyframes ts-twinkle {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.3;
    transform: scale(0.6);
  }
}

/* the clouds, drifting by day: three soft puffs on a flat base */
.ts-cloud {
  position: absolute;
  width: 20px;
  height: 6px;
  border-radius: 6px;
  background: var(--cloud);
  box-shadow: 0 1.5px 0 rgba(150, 60, 20, 0.22);
  transition: opacity 0.6s;
  animation: ts-drift 8s ease-in-out infinite alternate;
}
.ts-cloud::before,
.ts-cloud::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  background: inherit;
}
.ts-cloud::before {
  left: 3px;
  bottom: 2px;
  width: 8px;
  height: 8px;
}
.ts-cloud::after {
  left: 8.5px;
  bottom: 2.5px;
  width: 10px;
  height: 10px;
}
.ts-cl1 {
  left: 46%;
  top: 22%;
}
.ts-cl2 {
  left: 70%;
  top: 40%;
  transform: scale(0.72);
  animation-duration: 10s;
  animation-delay: -4s;
}
:root[data-theme='dark'] .ts-cloud {
  opacity: 0;
}
@keyframes ts-drift {
  from {
    translate: -5px 0;
  }
  to {
    translate: 5px 0;
  }
}

/* the knob: its art is drawn a third bigger all round, so the disc fills the knob and the sun's
   rays reach past it */
.ts-knob {
  position: absolute;
  z-index: 1;
  top: var(--kt);
  left: var(--kl);
  width: var(--ks);
  height: var(--ks);
  transition: transform 0.7s var(--ease);
}
:root[data-theme='dark'] .ts .ts-knob {
  transform: translateX(calc(var(--ts-w, 120px) - var(--ks) - 2 * var(--kl)));
}
.ts-sun,
.ts-moon {
  position: absolute;
  left: calc(var(--ks) / -3);
  top: calc(var(--ks) / -3);
  width: calc(var(--ks) * 5 / 3);
  height: calc(var(--ks) * 5 / 3);
  overflow: visible;
  transition: opacity 0.6s var(--ease);
}
.ts-sun {
  filter: drop-shadow(0 0 3px rgba(255, 180, 50, 0.7));
}
.ts-rays {
  transform-box: view-box;
  transform-origin: 50% 50%;
  animation: ts-turn 40s linear infinite;
}
.ts-moon {
  opacity: 0;
  filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.75)) drop-shadow(0 0 8px rgba(215, 220, 255, 0.45));
}
:root[data-theme='dark'] .ts-sun {
  opacity: 0;
}
:root[data-theme='dark'] .ts-moon {
  opacity: 1;
}
.ts-sparkle {
  transform-box: fill-box;
  transform-origin: 50% 50%;
  animation: ts-sparkle 3.2s ease-in-out infinite;
}
@keyframes ts-turn {
  to {
    transform: rotate(360deg);
  }
}
@keyframes ts-sparkle {
  0%,
  100% {
    opacity: 0.25;
    transform: scale(0.6);
  }
  45%,
  55% {
    opacity: 1;
    transform: scale(1);
  }
}

/* the castle, in front: far hills and towers lighter, the castle itself a deeper tone of the sky,
   roofs deeper still, a pale-gold pennant (a red one vanished on the red-orange castle); at night
   near-black, the windows lit, the pennant dark red */
.ts-keep {
  position: absolute;
  z-index: 2;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.ts-keep path {
  transition:
    fill 0.7s var(--ease),
    stroke 0.7s var(--ease),
    opacity 0.7s var(--ease);
}
.ts-far {
  fill: var(--far);
}
.ts-wall {
  fill: var(--wall);
}
.ts-shade {
  fill: var(--shade);
  opacity: 0.22;
}
.ts-roof {
  fill: var(--roof);
}
.ts-pole {
  fill: none;
  stroke: var(--roof);
  stroke-width: 0.9;
  stroke-linecap: round;
}
.ts-flag {
  fill: #ffe7a6;
  transform-box: fill-box;
  transform-origin: 0% 50%;
  animation: ts-wave 2.4s ease-in-out infinite;
}
.ts-gate {
  fill: var(--gate);
}
.ts-bars {
  fill: none;
  stroke: var(--bars);
  stroke-width: 0.8;
  opacity: 0.8;
}
.ts-win {
  fill: var(--win);
  opacity: 0.9;
}
:root[data-theme='dark'] .ts-far {
  fill: #2c225f;
}
:root[data-theme='dark'] .ts-wall {
  fill: #161131;
}
:root[data-theme='dark'] .ts-shade {
  fill: #000;
  opacity: 0.35;
}
:root[data-theme='dark'] .ts-roof {
  fill: #0d0a22;
}
:root[data-theme='dark'] .ts-pole {
  stroke: #0d0a22;
}
:root[data-theme='dark'] .ts-flag {
  fill: #7d1a12;
}
:root[data-theme='dark'] .ts-gate {
  fill: #06041a;
}
:root[data-theme='dark'] .ts-bars {
  stroke: #2a2148;
}
:root[data-theme='dark'] .ts-win {
  fill: #ffd46b;
  opacity: 1;
  filter: drop-shadow(0 0 1.6px #ffaa2a);
  animation: ts-candle 3s ease-in-out infinite;
}
@keyframes ts-wave {
  0%,
  100% {
    transform: skewY(0deg) scaleX(1);
  }
  50% {
    transform: skewY(-6deg) scaleX(0.92);
  }
}
@keyframes ts-candle {
  0%,
  100% {
    opacity: 1;
  }
  40% {
    opacity: 0.78;
  }
  60% {
    opacity: 0.95;
  }
}

/* the phone's round button: the knob alone, as its icon */
.ts-mini {
  --ks: 22px;
}
.ts-mini .ts-knob {
  position: relative;
  top: auto;
  left: auto;
  width: var(--ks);
  height: var(--ks);
  transform: none !important;
}
@media (prefers-reduced-motion: reduce) {
  .ts *,
  .ts *::before,
  .ts *::after,
  .ts-mini * {
    transition: none !important;
    animation: none !important;
  }
}

/* a page with one theme only (theme.ts forceTheme: the portfolio): the switch is disabled until it is left */
.ts[aria-disabled='true'],
.ts-mini[aria-disabled='true'] {
  opacity: 0.4;
  cursor: not-allowed;
}

/* the phone's round button (TMV's .nav-theme): the knob alone, in a round button the size of a thumb */
.ts-mini {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--ts-mini-line, rgb(128 128 128 / 0.28));
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}
.ts-mini:focus-visible {
  outline: 2px solid var(--brand, #f5b70a);
  outline-offset: 3px;
}
