/* Adapted from HamzehGhoreyshi/interactive-day-night-toggle (MIT). See LICENSE-day-night.txt. */
.sky-toggle {
  /* Page */
  --dn-page-day: radial-gradient(ellipse at 60% 35%, #fbfbfb 0%, #ededed 55%, #e2e2e2 100%);
  --dn-page-night: radial-gradient(ellipse at 60% 35%, #2a2c35 0%, #1c1d24 60%, #141519 100%);
  --dn-bezel-day: #f6f6f6;
  --dn-bezel-night: #2c2e37;

  /* Sky base = the outermost band. Bands closer to the knob are lighter. */
  --dn-sky-day: #3a77b6;
  --dn-sky-night: #1c1e27;

  /* Sun + moon */
  --dn-sun: #f3c22f;
  --dn-moon-hi: #e4e5e8;
  --dn-moon-lo: #a9abb2;
  --dn-crater: #8e96ac;

  /* Clouds: back → middle → front */
  --dn-cloud-1: #a9c8e7;
  --dn-cloud-2: #d2e4f5;
  --dn-cloud-3: #f1f7fc;

  --dn-star: #ffffff;

  /* Physical springs (damped-spring formula sampled into CSS linear()) */
  --dn-spring-soft: linear(0, 0.0454, 0.1554, 0.2976, 0.4484, 0.592, 0.7189, 0.8242, 0.9067, 0.9677, 1.0096, 1.0358, 1.0495, 1.0542, 1.0526, 1.0471, 1.0396, 1.0314, 1.0235, 1.0164, 1.0105, 1.0058, 1.0023, 0.9998, 0.9983, 0.9974, 0.9971, 0.9971, 0.9974, 0.9978, 0.9982, 0.9986, 0.999, 0.9994, 0.9996, 0.9998, 1, 1.0001, 1.0001, 1.0002, 1);
  --dn-spring-bouncy: linear(0, 0.0563, 0.1961, 0.3793, 0.5734, 0.7545, 0.9073, 1.024, 1.1031, 1.1475, 1.1628, 1.1562, 1.135, 1.1058, 1.0742, 1.0441, 1.0184, 0.9985, 0.9847, 0.9767, 0.9736, 0.9742, 0.9774, 0.982, 0.9872, 0.9921, 0.9964, 0.9998, 1.0022, 1.0037, 1.0043, 1.0043, 1.0038, 1.0031, 1.0022, 1.0014, 1.0007, 1.0001, 0.9997, 0.9994, 1);
  --dn-ease-out: cubic-bezier(.22, 1, .36, 1);
  --dn-ease-in: cubic-bezier(.55, 0, .75, .2);
}/* --dn--------- Toggle --dn--------- */
/* The button is only the size container + focus target. Everything visual lives in .dn-pill,
   so cqw units (1cqw = 1% of the button width) resolve against the button. */
.sky-toggle {
  --size: 80px;                     /* ← change this one value to resize the whole toggle */
  position: relative;
  width: min(var(--size), 80vw);
  aspect-ratio: 530 / 243;
  container-type: inline-size;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: none;
  cursor: pointer;
  outline: none;
  transition: transform 350ms var(--dn-spring-soft);
}
.sky-toggle:hover  { transform: translateY(-2px); }
.sky-toggle:active { transform: scale(.975); transition-duration: 120ms; }
.sky-toggle:focus-visible { outline: 3px solid #4c8af5; outline-offset: calc(min(var(--size), 80vw) * .035); }

.dn-pill {
  position: absolute; inset: 0;
  border-radius: inherit;
  overflow: hidden;
  isolation: isolate;
  background: var(--dn-sky-day);
  /* Raised bezel ring around a recessed slot */
  box-shadow:
    0 0 0 2.2cqw var(--dn-bezel-day),
    0 0 0 2.5cqw rgba(0, 0, 0, .05),
    0 -.8cqw 2cqw 2cqw rgba(255, 255, 255, .9),
    0 1.6cqw 3.5cqw 2cqw rgba(0, 0, 0, .14);
  transition: box-shadow 900ms var(--dn-ease-out);
}
html[data-mode="dark"] .dn-pill {
  box-shadow:
    0 0 0 2.2cqw var(--dn-bezel-night),
    0 0 0 2.5cqw rgba(0, 0, 0, .35),
    0 -.8cqw 2cqw 2cqw rgba(255, 255, 255, .04),
    0 1.6cqw 3.5cqw 2cqw rgba(0, 0, 0, .45);
}

/* Inner shadow on top of every layer: makes the slot look pressed into the bezel */
.dn-pill::after {
  content: "";
  position: absolute; inset: 0;
  border-radius: inherit;
  box-shadow:
    inset 0 1.6cqw 2.4cqw rgba(0, 0, 0, .32),
    inset 0 .3cqw .5cqw rgba(0, 0, 0, .25),
    inset 0 -.6cqw 1.2cqw rgba(255, 255, 255, .25);
  pointer-events: none;
  z-index: 10;
}

.dn-layer { position: absolute; inset: 0; display: block; pointer-events: none; }

.dn-sky-night {
  background: var(--dn-sky-night);
  opacity: 0;
  transition: opacity 700ms var(--dn-ease-out);
}
html[data-mode="dark"] .dn-sky-night { opacity: 1; }

/* --dn--------- Stars --dn--------- */
.dn-stars { width: 100%; height: 100%; }
.dn-star {
  transform-box: fill-box;
  transform-origin: center;
  opacity: 0;
  transform: translateY(-6px) scale(.2) rotate(-90deg);
  transition: transform 450ms var(--dn-ease-in), opacity 300ms var(--dn-ease-in);
  transition-delay: calc(var(--dn-i) * 15ms);
}
html[data-mode="dark"] .dn-star {
  opacity: 1;
  transform: none;
  transition: transform 1000ms var(--dn-spring-bouncy), opacity 500ms var(--dn-ease-out);
  transition-delay: calc(250ms + var(--dn-i) * 45ms);
}
.dn-star > * {
  fill: var(--dn-star);
  transform-box: fill-box;
  transform-origin: center;
  animation: dn-twinkle var(--dn-t, 3s) ease-in-out infinite;
  animation-delay: calc(var(--dn-i) * -0.37s);
}
@keyframes dn-twinkle {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .3; transform: scale(.55) rotate(45deg); }
}

.dn-shooting {
  position: absolute;
  left: 8cqw; top: 8cqw;
  width: 12cqw; height: .4cqw;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255,255,255,0), rgba(255,255,255,.95));
  opacity: 0;
  pointer-events: none;
}
html[data-mode="dark"] .dn-shooting { animation: dn-shoot 7s 1.1s linear infinite; }
@keyframes dn-shoot {
  0%   { opacity: 0; transform: rotate(16deg) translateX(-8cqw) scaleX(.3); }
  2%   { opacity: 1; }
  9%   { opacity: 0; transform: rotate(16deg) translateX(28cqw) scaleX(1); }
  100% { opacity: 0; transform: rotate(16deg) translateX(28cqw) scaleX(1); }
}

/* --dn--------- Knob (sun / moon) --dn--------- */
.dn-knob-track {
  position: absolute;
  top: 4.18cqw; left: 4.18cqw;
  width: 37.5cqw; height: 37.5cqw;
  transition: transform 900ms var(--dn-spring-soft);
  z-index: 2;
}
html[data-mode="dark"] .dn-knob-track { transform: translateX(54.14cqw); }

/* Concentric light bands that travel with the knob.
   Each ring adds 7% white, so the bands step lighter toward the sun/moon. */
.dn-halo {
  position: absolute; inset: 0;
  border-radius: 50%;
  box-shadow:
    0 0 0 7cqw  rgba(255, 255, 255, .075),
    0 0 0 15cqw rgba(255, 255, 255, .075),
    0 0 0 24cqw rgba(255, 255, 255, .075),
    0 0 0 34cqw rgba(255, 255, 255, .075);
  transition: transform 1000ms var(--dn-spring-bouncy);
}
/* Rings dn-ripple outward as the knob lands */
html[data-mode="dark"] .dn-halo { animation: dn-ripple 1100ms var(--dn-ease-out) 150ms; }
html[data-mode="light"]   .dn-halo { animation: dn-ripple2 1100ms var(--dn-ease-out) 150ms; }
@keyframes dn-ripple  { 0% { transform: scale(.75); } 100% { transform: scale(1); } }
@keyframes dn-ripple2 { 0% { transform: scale(.75); } 100% { transform: scale(1); } }

.dn-knob {
  position: absolute; inset: 0;
  border-radius: 50%;
  overflow: hidden;
  box-shadow:
    .8cqw 1.4cqw 2.2cqw rgba(0, 0, 0, .35),
    .2cqw .4cqw .5cqw rgba(0, 0, 0, .2);
}

.dn-sun, .dn-moon { position: absolute; inset: 0; border-radius: 50%; }

.dn-sun {
  background: var(--dn-sun);
  box-shadow:
    inset 0 0 0 .35cqw rgba(190, 120, 0, .22),
    inset 0 1cqw 1.2cqw rgba(255, 240, 170, .55),
    inset -.6cqw -1.4cqw 1.8cqw rgba(210, 130, 0, .35);
  transition: transform 900ms var(--dn-spring-soft);
}
/* Once the moon fully covers it, hide the sun so no yellow edge peeks out */
html[data-mode="dark"] .dn-sun { transform: rotate(120deg); opacity: 0; transition: transform 900ms var(--dn-spring-soft), opacity 0s 1000ms; }

/* The moon slides across the sun like an eclipse */
.dn-moon {
  background: radial-gradient(circle at 35% 30%, var(--dn-moon-hi) 0%, #c7c9ce 55%, var(--dn-moon-lo) 100%);
  box-shadow:
    inset 0 0 0 .35cqw rgba(0, 0, 0, .12),
    inset 0 1cqw 1.2cqw rgba(255, 255, 255, .5),
    inset -.6cqw -1.4cqw 1.8cqw rgba(60, 65, 80, .3);
  transform: translateX(105%) rotate(90deg);
  transition: transform 700ms var(--dn-ease-in);
}
html[data-mode="dark"] .dn-moon {
  transform: none;
  transition: transform 1000ms var(--dn-spring-soft) 80ms;
}

.dn-crater {
  position: absolute;
  border-radius: 50%;
  background: var(--dn-crater);
  box-shadow:
    inset .5cqw .7cqw .9cqw rgba(40, 50, 80, .45),
    0 .2cqw .2cqw rgba(255, 255, 255, .5);
}
.dn-c1 { left: 42%; top: 15%; width: 17%; height: 17%; }
.dn-c2 { left: 20%; top: 52%; width: 34%; height: 34%; }
.dn-c3 { left: 64%; top: 52%; width: 25%; height: 25%; }

/* --dn--------- Clouds (3 layers) --dn--------- */
.dn-cloud {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  overflow: visible;
}
.dn-cloud-1 { z-index: 3; transition: transform 1100ms var(--dn-spring-bouncy) 180ms; }
.dn-cloud-2 { z-index: 4; transition: transform 1100ms var(--dn-spring-bouncy) 110ms; }
.dn-cloud-3 { z-index: 5; transition: transform 1100ms var(--dn-spring-bouncy) 40ms; }

/* Night: each layer sinks away, front first */
html[data-mode="dark"] .dn-cloud-3 { transform: translate(6cqw, 50cqw);  transition: transform 600ms var(--dn-ease-in) 0ms; }
html[data-mode="dark"] .dn-cloud-2 { transform: translate(10cqw, 54cqw); transition: transform 650ms var(--dn-ease-in) 60ms; }
html[data-mode="dark"] .dn-cloud-1 { transform: translate(14cqw, 60cqw); transition: transform 700ms var(--dn-ease-in) 120ms; }

.dn-cloud g {
  transform-box: view-box;
  animation: dn-drift 8s ease-in-out infinite;
}
.dn-cloud-1 g { animation-duration: 11s; animation-delay: -4s; }
.dn-cloud-2 g { animation-duration: 9s;  animation-delay: -2s; animation-direction: reverse; }
@keyframes dn-drift {
  0%, 100% { transform: translateX(0); }
  50%      { transform: translateX(-7px); }
}


/* Adapted for the personal hub: quiet at rest, animated on interaction. */
.sky-toggle{flex:none;display:block;touch-action:manipulation;filter:saturate(.78)}
.sky-toggle .dn-star > *, .sky-toggle .dn-cloud g{animation-play-state:paused}
.sky-toggle:is(:hover,:focus-visible) .dn-star > *, .sky-toggle:is(:hover,:focus-visible) .dn-cloud g{animation-play-state:running}
html[data-mode="dark"] .dn-shooting{animation-iteration-count:1}
.dn-sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
.daynight-preview .sky-toggle{--size:112px}
@media(max-width:760px){.appearance-controls .sky-toggle{--size:68px}}
@media(prefers-reduced-motion:reduce){.sky-toggle,.sky-toggle *,.sky-toggle *::after{animation:none!important;transition:none!important}}
html[data-effects="off"] .sky-toggle,html[data-effects="off"] .sky-toggle *,html[data-effects="off"] .sky-toggle *::after{animation:none!important;transition:none!important}
