/* Calczora shared sky effects: used by every page.
   The page sets <html data-theme="light|dark" data-sky="sunny|clear|cloudy">.
   Each page keeps its own sky colours and clouds; this file adds the touches
   that set the three skies apart: soft sunbeams, wisps, twinkling stars,
   a shooting star, and an overcast cloud deck. All kept gentle on purpose.

   Smooth switching rule: every layer shows and hides ONLY by fading its
   opacity. Loops (spin, drift, twinkle) run all the time on an inner part,
   so nothing jumps when the sky or theme changes. */

.fx { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.fx > i { position: absolute; display: block; opacity: 0; transition: opacity 1.1s ease; }

/* ---------- Sunbeams (sunny day) — they sit inside the sun's .orb ---------- */
.rays {
  position: absolute; left: 50%; top: 50%; width: 560px; height: 560px; margin: -280px 0 0 -280px;
  border-radius: 50%; pointer-events: none; opacity: 0; transition: opacity .35s ease;
  background: repeating-conic-gradient(from 0deg, rgba(255, 238, 180, .16) 0deg 4deg, rgba(255, 238, 180, 0) 4deg 16deg);
  -webkit-mask: radial-gradient(circle, #000 0%, rgba(0, 0, 0, .4) 20%, transparent 56%);
          mask: radial-gradient(circle, #000 0%, rgba(0, 0, 0, .4) 20%, transparent 56%);
}
[data-sky="sunny"]:not([data-theme="dark"]) .rays { opacity: 1; transition: opacity 1s ease; }
/* Night to day: the beams wait until the sun has fully risen (~1.5s), then fade in.
   Day to night: the base rule fades them out fast, before the sun starts to set. */
.theming[data-theme="light"][data-sky="sunny"] .rays { transition: opacity 1.2s ease 1.5s; }
@media (max-width: 760px) { .rays { width: 300px; height: 300px; margin: -150px 0 0 -150px; } }

/* ---------- Wisps (clear day): thin, high streaks ---------- */
.fx .wisp {
  height: 22px; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 255, 255, .7), rgba(255, 255, 255, .25) 55%, rgba(255, 255, 255, 0));
}
.fx .w1 { top: 13%; left: 6%; width: 46vw; max-width: 560px; rotate: -6deg; }
.fx .w2 { top: 24%; right: 4%; width: 34vw; max-width: 420px; height: 16px; rotate: -4deg; }
.fx .w3 { top: 38%; left: 30%; width: 26vw; max-width: 320px; height: 12px; rotate: -7deg; }
/* (Wisps are kept off: Clear means a cloudless sky.) */

/* ---------- Twinkling stars (night): the layer fades; its ::before twinkles ---------- */
.fx .tw1, .fx .tw2 { inset: 0; }
.fx .tw1::before, .fx .tw2::before { content: ""; position: absolute; inset: 0; background-repeat: repeat; }
.fx .tw1::before {
  background-image:
    radial-gradient(2px 2px at 40px 50px, #fff 50%, transparent), radial-gradient(1.5px 1.5px at 150px 20px, #fff 50%, transparent),
    radial-gradient(2px 2px at 260px 140px, #fff 50%, transparent), radial-gradient(1.5px 1.5px at 90px 210px, #fff 50%, transparent),
    radial-gradient(1.5px 1.5px at 330px 70px, #dce8ff 50%, transparent);
  background-size: 380px 300px;
}
.fx .tw2::before {
  background-image:
    radial-gradient(1.5px 1.5px at 110px 100px, #fff 50%, transparent), radial-gradient(2px 2px at 210px 40px, #dce8ff 50%, transparent),
    radial-gradient(1px 1px at 300px 230px, #fff 50%, transparent), radial-gradient(1.5px 1.5px at 20px 160px, #fff 50%, transparent);
  background-size: 340px 320px;
  -webkit-mask: linear-gradient(180deg, #000 0%, #000 50%, transparent 85%);
          mask: linear-gradient(180deg, #000 0%, #000 50%, transparent 85%);
}
[data-theme="dark"][data-sky="sunny"] .tw1 { opacity: .35; }
[data-theme="dark"][data-sky="clear"] .tw1 { opacity: .7; }
[data-theme="dark"][data-sky="clear"] .tw2 { opacity: .5; }

/* ---------- Shooting star (clear night, now and then) ---------- */
.fx .shoot { inset: 0; }
.fx .shoot::before {
  content: ""; position: absolute; top: 12%; left: 62%; width: 110px; height: 1.5px; border-radius: 2px; opacity: 0;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, .7));
  transform: rotate(-24deg);
}
[data-theme="dark"][data-sky="clear"] .shoot { opacity: 1; }
.fx .shoot.s2::before { top: 30%; left: 20%; width: 80px; }

/* ---------- Overcast deck (cloudy): a light layer hanging from the top ---------- */
.fx .deck {
  left: -10%; top: -6%; width: 220%; height: 58%;
  background:
    radial-gradient(18% 46% at 4% 30%, var(--deck-a) 0 60%, transparent 61%),
    radial-gradient(14% 40% at 15% 46%, var(--deck-b) 0 60%, transparent 61%),
    radial-gradient(20% 52% at 27% 26%, var(--deck-a) 0 60%, transparent 61%),
    radial-gradient(13% 38% at 39% 50%, var(--deck-b) 0 60%, transparent 61%),
    radial-gradient(19% 48% at 52% 30%, var(--deck-a) 0 60%, transparent 61%),
    radial-gradient(15% 42% at 65% 44%, var(--deck-b) 0 60%, transparent 61%),
    radial-gradient(20% 50% at 77% 28%, var(--deck-a) 0 60%, transparent 61%),
    radial-gradient(14% 40% at 90% 46%, var(--deck-b) 0 60%, transparent 61%),
    linear-gradient(180deg, var(--deck-a) 0%, var(--deck-a) 18%, transparent 44%);
  --deck-a: rgba(232, 237, 243, .9); --deck-b: rgba(206, 215, 226, .88);
}
.fx .deck.d2 { top: 6%; height: 42%; left: -60%; --deck-a: rgba(214, 222, 232, .7); --deck-b: rgba(190, 201, 214, .66); }
[data-theme="dark"] .fx .deck { --deck-a: rgba(62, 72, 94, .92); --deck-b: rgba(48, 58, 78, .9); }
[data-theme="dark"] .fx .deck.d2 { --deck-a: rgba(72, 82, 104, .6); --deck-b: rgba(56, 65, 86, .58); }
[data-sky="cloudy"] .deck { opacity: .5; }
[data-sky="cloudy"] .deck.d2 { opacity: .4; }

/* sun or moon dimmed by cloud: a soft pale patch around it */
.fx .veil {
  top: 2%; right: -6%; width: 46vmax; height: 30vmax; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 250, 232, .5), rgba(255, 250, 232, 0));
}
[data-theme="dark"] .fx .veil { background: radial-gradient(closest-side, rgba(220, 228, 255, .2), rgba(220, 228, 255, 0)); }
[data-sky="cloudy"] .veil { opacity: .6; }

/* ---------- Motion: always running underneath, so switching never jumps ---------- */
@media (prefers-reduced-motion: no-preference) {
  .rays { animation: raysTurn 140s linear infinite; }
  @keyframes raysTurn { to { transform: rotate(360deg); } }
  .fx .wisp { animation: wispDrift 44s ease-in-out infinite alternate; }
  .fx .w2 { animation-duration: 56s; animation-delay: -20s; }
  .fx .w3 { animation-duration: 50s; animation-delay: -9s; }
  @keyframes wispDrift { to { translate: 5vw 0; } }
  .fx .tw1::before { animation: twinkle 4.6s ease-in-out infinite alternate; }
  .fx .tw2::before { animation: twinkle 3.4s ease-in-out infinite alternate-reverse; }
  @keyframes twinkle { from { opacity: .5; } to { opacity: 1; } }
  .fx .shoot::before { animation: shoot 14s cubic-bezier(.3, .6, .4, 1) 3s infinite; }
  .fx .shoot.s2::before { animation-duration: 19s; animation-delay: 10s; }
  @keyframes shoot {
    0% { opacity: 0; transform: rotate(-24deg) translateX(0) scaleX(.3); }
    3% { opacity: 1; }
    8% { opacity: 0; transform: rotate(-24deg) translateX(-220px) scaleX(1); }
    100% { opacity: 0; transform: rotate(-24deg) translateX(-220px); }
  }
  .fx .deck { animation: deckDrift 160s linear infinite; }
  .fx .deck.d2 { animation-duration: 110s; animation-direction: reverse; }
  @keyframes deckDrift { to { transform: translateX(-45%); } }
}

/* ---------- Sky picker (same three choices on every page) ---------- */
.skypick { position: relative; }
.skypick-menu {
  position: absolute; z-index: 30; top: calc(100% + 8px); right: 0; display: grid; gap: 2px; width: 168px; padding: 6px;
  border-radius: 16px; background: #fff; color: #12214e;
  border: 1px solid rgba(18, 33, 78, .12); box-shadow: 0 18px 36px -14px rgba(10, 30, 70, .55);
  transform-origin: 85% 0; animation: skypickIn .18s cubic-bezier(.22, 1, .36, 1);
}
.skypick-menu[hidden] { display: none; }
@keyframes skypickIn { from { opacity: 0; transform: translateY(-4px) scale(.97); } }
.skypick-menu button {
  display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; border: 0; border-radius: 11px;
  background: none; color: inherit; font: 650 15px/1 var(--font, system-ui); text-align: left; cursor: pointer;
}
.skypick-menu button svg { flex: none; }
.skypick-menu button[aria-pressed="true"] { background: #e3effb; }
.skypick-menu button[aria-pressed="true"]::after { content: ""; margin-left: auto; width: 7px; height: 12px; border: solid #2a6fd2; border-width: 0 2.2px 2.2px 0; transform: rotate(45deg) translate(-2px, -2px); }
@media (hover: hover) { .skypick-menu button:hover { background: #f0f6fc; } .skypick-menu button[aria-pressed="true"]:hover { background: #e3effb; } }
[data-theme="dark"] .skypick-menu { background: #1a2b56; color: #eaf2ff; border-color: rgba(220, 232, 255, .16); box-shadow: 0 18px 36px -14px rgba(0, 0, 0, .8); }
[data-theme="dark"] .skypick-menu button[aria-pressed="true"] { background: rgba(125, 165, 235, .24); }
[data-theme="dark"] .skypick-menu button[aria-pressed="true"]::after { border-color: #ffd66b; }
@media (hover: hover) { [data-theme="dark"] .skypick-menu button:hover { background: rgba(125, 165, 235, .14); } [data-theme="dark"] .skypick-menu button[aria-pressed="true"]:hover { background: rgba(125, 165, 235, .24); } }

/* While someone is typing in or picking from a calculator, the sky holds still. The frosted cards
   then no longer have to be redrawn behind every moving cloud, so boxes, sliders and pickers stay smooth.
   It starts again a moment after they leave the box. (Set by /header.js.) */
html.still .sky, html.still .sky *, html.still .sky *::before, html.still .sky *::after,
html.still .result-mascot { animation-play-state: paused !important; }
