/* Night theme. Colours live beside their day values as light-dark() pairs (night-palette.py);
   this file maps the colour-scheme override and adds the night-only sky. */
:root {
  color-scheme: light dark;
  &:has(> head > meta[name="color-scheme"][content="dark"]) { color-scheme: dark; }
  &:has(> head > meta[name="color-scheme"][content="light"]) { color-scheme: light; }
}

.quiet-hero { position: relative; }
.night-sky { display: none; position: absolute; inset: 0 0 auto; height: min(56%, 520px); pointer-events: none; z-index: 0; }
.night-moon {
  position: absolute; top: 40px; left: clamp(24px, calc(50% - 470px), 300px);
  width: 46px; height: 46px; border-radius: 50%;
  /* A crescent: a lit disc with its shadowed part cut away by the sky colour. */
  background: #efe6c8;
  box-shadow: 0 0 22px 4px rgb(239 230 200 / .16), 0 0 70px 18px rgb(239 230 200 / .07);
  mask: radial-gradient(circle at 70% 36%, transparent 0 15px, #000 16px);
}
.night-stars {
  position: absolute; inset: 0; opacity: .75;
  background:
    radial-gradient(circle at 8% 38%, #e9e4cf 0 1px, transparent 1.6px),
    radial-gradient(circle at 18% 12%, #d9dfe6 0 .8px, transparent 1.4px),
    radial-gradient(circle at 24% 54%, #d9dfe6 0 .7px, transparent 1.3px),
    radial-gradient(circle at 31% 22%, #e9e4cf 0 1.1px, transparent 1.7px),
    radial-gradient(circle at 37% 6%, #d9dfe6 0 .8px, transparent 1.4px),
    radial-gradient(circle at 44% 9%, #d9dfe6 0 .7px, transparent 1.3px),
    radial-gradient(circle at 53% 4%, #e9e4cf 0 1px, transparent 1.6px),
    radial-gradient(circle at 61% 10%, #d9dfe6 0 .8px, transparent 1.4px),
    radial-gradient(circle at 67% 3%, #d9dfe6 0 .7px, transparent 1.3px),
    radial-gradient(circle at 72% 14%, #e9e4cf 0 1px, transparent 1.6px),
    radial-gradient(circle at 79% 6%, #d9dfe6 0 .8px, transparent 1.4px),
    radial-gradient(circle at 88% 9%, #e9e4cf 0 1.1px, transparent 1.7px),
    radial-gradient(circle at 94% 4%, #d9dfe6 0 .7px, transparent 1.3px),
    radial-gradient(circle at 3% 16%, #d9dfe6 0 .8px, transparent 1.4px),
    radial-gradient(circle at 13% 66%, #d9dfe6 0 .7px, transparent 1.3px);
}

.theme-toggle .theme-sun { display: none; }

/* Night: an explicit override, or the system preference when nothing is pinned. Kept as two
   identical blocks because a media query and a :has() override cannot share one selector. */
:root:has(> head > meta[name="color-scheme"][content="dark"]) {
  .night-sky { display: block; }
  .theme-toggle .theme-moon { display: none; }
  .theme-toggle .theme-sun { display: block; }
}
@media (prefers-color-scheme: dark) {
  :root:not(:has(> head > meta[name="color-scheme"][content="light"])) {
    .night-sky { display: block; }
    .theme-toggle .theme-moon { display: none; }
    .theme-toggle .theme-sun { display: block; }
  }
}
@media (max-width: 600px) { .night-moon { left: auto; right: 26px; top: 58px; width: 36px; height: 36px; mask: radial-gradient(circle at 70% 36%, transparent 0 12px, #000 13px); } }
@media (forced-colors: active) { .night-sky { display: none !important; } }
/* At night the dialog scrim darkens the moonlit scene further instead of greying it. */
#detail::backdrop { background: light-dark(rgb(36 41 36 / 35%), rgb(5 9 13 / 62%)); }

/* Theme change: a slow, even cross-fade of the whole page (theme.js starts it). Only theme
   changes set data-theme-fade, so no other view transition inherits this timing. */
:root[data-theme-fade]::view-transition-old(root),
:root[data-theme-fade]::view-transition-new(root) {
  animation-duration: 1.4s;
  animation-timing-function: cubic-bezier(.45, 0, .25, 1);
}
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}

/* Night window light: hidden until the scene turns it on (workplace.js sets opacity). */
.workplace-windows { visibility: hidden; opacity: 0; }
