/* AstronomyLive Night Mode
   Two light-filter layers over the whole page:
   1) takes away all colour and keeps only brightness,
   2) multiplies that brightness with dark red.
   Result: black stays black, everything else becomes dark red in its own strength,
   with no green or blue light at all – also for photos, video and embedded streams.
   Both layers fade in and out, so the change is gentle on dark-adapted eyes. */

html::before,
html::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 1.6s cubic-bezier(.45, 0, .2, 1), visibility 0s linear 1.6s;
}
html::before {
  z-index: 2147483645;
  background: #808080;
  mix-blend-mode: saturation;
}
html::after {
  z-index: 2147483646;
  background: #b30000;
  mix-blend-mode: multiply;
}
html.al-night::before,
html.al-night::after {
  opacity: 1;
  visibility: visible;
  transition: opacity 1.6s cubic-bezier(.45, 0, .2, 1), visibility 0s linear 0s;
}
html.al-night-instant::before,
html.al-night-instant::after,
html.al-night-instant .al-night-thumb,
html.al-night-instant .al-night-opt,
html.al-night-instant .al-night-opt svg,
html.al-night-instant .al-night-star,
html.al-night-instant .al-night-sun {
  transition: none !important;
}
html.al-night {
  color-scheme: dark;
  scrollbar-color: #3a0000 #000;
}
html.al-night ::selection { background: #4a0000; color: #ff3b3b; }

/* white sun above the red filter (placed by script exactly over the real sun) */
.al-night-sun {
  position: fixed;
  z-index: 2147483647;
  top: 0;
  left: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #fff;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 1.6s cubic-bezier(.45, 0, .2, 1), visibility 0s linear 1.6s;
  -webkit-tap-highlight-color: transparent;
}
.al-night-sun svg { display: block; flex: none; overflow: visible; filter: drop-shadow(0 0 3px rgba(255, 255, 255, .7)); }
.al-night-sun:hover svg { filter: drop-shadow(0 0 6px rgba(255, 255, 255, .95)); }
html.al-night .al-night-sun {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 1.6s cubic-bezier(.45, 0, .2, 1), visibility 0s linear 0s;
}

/* ------------------------------------------------------------ the switch */
html body .al-night-toggle {
  position: relative;
  transition: border-color .5s ease;
  display: inline-flex;
  align-items: center;
  flex: none;
  box-sizing: border-box;
  height: 38px;
  padding: 3px;
  margin: 0;
  gap: 0;
  border: 1px solid #3f5648;
  border-radius: 6px;
  background: transparent;
  vertical-align: middle;
  line-height: 1;
}
html body .al-night-toggle .al-night-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 30px;
  height: 30px;
  box-sizing: border-box;
  border-radius: 4px;
  /* day: warm sunlight */
  background: rgba(255, 206, 84, .14);
  box-shadow: inset 0 0 0 1px rgba(255, 206, 84, .42);
  transform: translateX(0);
  transition: transform .5s cubic-bezier(.45, 0, .2, 1), background-color .5s ease, box-shadow .5s ease;
  pointer-events: none;
}
/* night: white moonlight – the switch stays the brightest thing on the page, so it is easy to find again */
html.al-night body .al-night-toggle {
  border-color: rgba(255, 255, 255, .6);
}
html.al-night body .al-night-toggle .al-night-thumb {
  transform: translateX(30px);
  background: rgba(255, 255, 255, .18);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .75);
}

html body .al-night-toggle .al-night-opt {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 30px;
  height: 30px;
  min-width: 0;
  min-height: 0;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  box-shadow: none;
  color: rgba(201, 247, 223, .42);
  cursor: pointer;
  font: inherit;
  line-height: 1;
  transition: color .5s cubic-bezier(.45, 0, .2, 1);
  -webkit-tap-highlight-color: transparent;
}
html body .al-night-toggle .al-night-opt svg {
  display: block;
  flex: none;
  overflow: visible;
  transition: transform .6s cubic-bezier(.34, 1.4, .5, 1), filter .5s ease;
}
html body .al-night-toggle .al-night-opt:hover { color: rgba(201, 247, 223, .8); background: transparent; }

/* active sun: golden, glowing, rays turn into place */
html body .al-night-toggle .al-night-opt[data-mode="day"] { color: #ffd56a; }
html body .al-night-toggle .al-night-opt[data-mode="day"] svg { filter: drop-shadow(0 0 4px rgba(255, 200, 80, .55)); transform: rotate(0deg); }
html.al-night body .al-night-toggle .al-night-opt[data-mode="day"] svg { filter: none; transform: rotate(-45deg) scale(.92); }

/* moon: always white; when active it glows */
html body .al-night-toggle .al-night-opt[data-mode="night"] { color: rgba(255, 255, 255, .78); }
html body .al-night-toggle .al-night-opt[data-mode="night"]:hover { color: #fff; }
html body .al-night-toggle .al-night-opt[data-mode="night"] svg { transform: rotate(-18deg) scale(.92); }
html.al-night body .al-night-toggle .al-night-opt[data-mode="night"] { color: #fff; }
html.al-night body .al-night-toggle .al-night-opt[data-mode="night"] svg { filter: drop-shadow(0 0 4px rgba(255, 255, 255, .8)); transform: rotate(0deg); }
html body .al-night-toggle .al-night-star { opacity: .6; transition: opacity .6s ease; }
html.al-night body .al-night-toggle .al-night-star { opacity: 1; }
/* in night mode the sun stays clearly visible too, to switch back */
html.al-night body .al-night-toggle .al-night-opt[data-mode="day"] { color: rgba(255, 255, 255, .72); }
html.al-night body .al-night-toggle .al-night-opt[data-mode="day"]:hover { color: #fff; }

html body .al-night-toggle .al-night-opt:focus { outline: none; }
html body .al-night-toggle .al-night-opt:focus-visible { outline: 2px solid #39f8b1; outline-offset: 1px; }

@media (prefers-reduced-motion: reduce) {
  html::before, html::after { transition-duration: .4s; }
  html body .al-night-toggle .al-night-thumb,
  html body .al-night-toggle .al-night-opt svg { transition-duration: .2s; }
}
