/* ==========================================================================
   Simon Connect: the drifting sky behind every page with the top bar
   (Home, Apps & forms, Employee Hub, Users). Built by static/js/sc-sky.js,
   loaded from templates/navbar.html.

   The sky follows the time of day (t-morning, t-afternoon, t-evening, t-night
   on .sc-sky): clouds drift slowly through the margins, a small flock of birds
   crosses now and then, the sun glows softly, and at night the stars twinkle
   with the odd shooting star. It sits behind everything (z-index -1), so it
   only shows in the gaps between cards. Light and dark versions; everything
   stands still for "reduce motion".
   ========================================================================== */

/* the body's own background would paint over the sky, so it steps aside once the sky is there
   (sc-sky.js adds has-sky; without it the page keeps its plain background) */
html.sx body.has-sky { background: transparent; }

html.sx .sc-sky {
    display: block; /* sc-theme.css still hides the old retired colour wash, which used this class */
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
    background: var(--sky);
    --cloud: rgba(255, 255, 255, 0.85);
    --bird: rgba(60, 80, 110, 0.45);
    --star: rgba(110, 125, 190, 0.55);
    --shoot: rgba(120, 140, 210, 0.8);
    --moon: #b7c2e6;
}

html.sx[data-theme="dark"] .sc-sky {
    --cloud: rgba(255, 255, 255, 0.055);
    --bird: rgba(200, 215, 235, 0.35);
    --star: rgba(230, 236, 255, 0.8);
    --shoot: rgba(255, 255, 255, 0.9);
    --moon: #dfe6ff;
}

/* --------------------------------------------------------------------------
   The sky through the day
   -------------------------------------------------------------------------- */
html.sx .sc-sky.t-morning {
    --sky: radial-gradient(700px 480px at 6% 4%, rgba(255, 196, 140, 0.5), rgba(255, 196, 140, 0) 70%),
           radial-gradient(900px 520px at 90% 0%, rgba(150, 205, 245, 0.3), rgba(150, 205, 245, 0) 70%),
           linear-gradient(180deg, #fff6ee 0%, #f5f8fc 60%);
}
html.sx .sc-sky.t-afternoon {
    --sky: radial-gradient(900px 560px at 88% -6%, rgba(110, 190, 245, 0.5), rgba(110, 190, 245, 0) 70%),
           radial-gradient(700px 500px at 0% 100%, rgba(80, 190, 175, 0.14), rgba(80, 190, 175, 0) 70%),
           linear-gradient(180deg, #e6f3fd 0%, #f6fafe 70%);
}
html.sx .sc-sky.t-evening {
    --sky: radial-gradient(800px 520px at 96% 100%, rgba(255, 170, 110, 0.38), rgba(255, 170, 110, 0) 70%),
           radial-gradient(900px 520px at 10% 0%, rgba(185, 160, 230, 0.34), rgba(185, 160, 230, 0) 70%),
           linear-gradient(180deg, #f6f0fa 0%, #fbf3ec 100%);
}
/* night: a dusky blue-violet, darker at the top, still light enough for the page text;
   white stars with a soft glow and a warm moon so they show against it */
html.sx .sc-sky.t-night {
    --sky: radial-gradient(900px 560px at 88% 0%, rgba(84, 98, 178, 0.42), rgba(84, 98, 178, 0) 70%),
           radial-gradient(800px 500px at 0% 100%, rgba(120, 100, 190, 0.18), rgba(120, 100, 190, 0) 70%),
           linear-gradient(180deg, #c3cbe6 0%, #d3d9ee 55%, #dfe3f2 100%);
    --star: rgba(255, 255, 255, 0.95);
    --shoot: rgba(255, 255, 255, 0.95);
    --moon: #fff7dc;
}
html.sx .t-night .sc-star { box-shadow: 0 0 6px rgba(255, 255, 255, 0.9); }
html.sx .t-night .sc-sky-orb { filter: drop-shadow(0 0 10px rgba(255, 246, 214, 0.9)); }

html.sx[data-theme="dark"] .sc-sky.t-morning {
    --sky: radial-gradient(700px 480px at 6% 4%, rgba(255, 170, 110, 0.2), rgba(255, 170, 110, 0) 70%),
           linear-gradient(180deg, #151820 0%, #0f131a 70%);
}
html.sx[data-theme="dark"] .sc-sky.t-afternoon {
    --sky: radial-gradient(900px 560px at 88% -6%, rgba(60, 150, 220, 0.28), rgba(60, 150, 220, 0) 70%),
           linear-gradient(180deg, #0f1722 0%, #0d121a 70%);
}
html.sx[data-theme="dark"] .sc-sky.t-evening {
    --sky: radial-gradient(800px 520px at 96% 100%, rgba(255, 140, 80, 0.16), rgba(255, 140, 80, 0) 70%),
           radial-gradient(900px 520px at 10% 0%, rgba(150, 120, 220, 0.2), rgba(150, 120, 220, 0) 70%),
           linear-gradient(180deg, #15131d 0%, #100f16 100%);
}
html.sx[data-theme="dark"] .sc-sky.t-night {
    --sky: radial-gradient(900px 560px at 88% 0%, rgba(90, 110, 200, 0.22), rgba(90, 110, 200, 0) 70%),
           linear-gradient(180deg, #0b0f1c 0%, #0a0d16 70%);
}

/* --------------------------------------------------------------------------
   Sun and moon
   -------------------------------------------------------------------------- */
html.sx .sc-sky-orb {
    position: absolute;
    right: 4vw;
    top: 108px;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    animation: scSkyGlow 8s ease-in-out infinite;
}
html.sx .t-morning .sc-sky-orb { left: 4vw; right: auto; background: radial-gradient(circle, #ffd29a 0 40%, rgba(255, 210, 154, 0.35) 41% 60%, rgba(255, 210, 154, 0) 61%); }
html.sx .t-afternoon .sc-sky-orb { background: radial-gradient(circle, #ffe7a6 0 34%, rgba(255, 231, 166, 0.4) 35% 58%, rgba(255, 231, 166, 0) 59%); }
html.sx .t-evening .sc-sky-orb { top: auto; bottom: 22vh; background: radial-gradient(circle, #ffb27a 0 38%, rgba(255, 178, 122, 0.35) 39% 60%, rgba(255, 178, 122, 0) 61%); }
html.sx .t-night .sc-sky-orb { width: 42px; height: 42px; background: transparent; box-shadow: -11px 6px 0 0 var(--moon); transform: rotate(-12deg); animation: none; }

/* --------------------------------------------------------------------------
   Clouds (very slow), birds (now and then), stars and a shooting star (night)
   -------------------------------------------------------------------------- */
html.sx .sc-cloud {
    position: absolute;
    left: 0;
    width: 180px;
    height: 44px;
    border-radius: 40px;
    background: var(--cloud);
    filter: blur(1px);
    animation: scSkyDrift var(--dur, 200s) linear var(--del, 0s) infinite;
}
html.sx .sc-cloud::before,
html.sx .sc-cloud::after { content: ""; position: absolute; border-radius: 50%; background: inherit; }
html.sx .sc-cloud::before { left: 28px; bottom: 18px; width: 70px; height: 56px; }
html.sx .sc-cloud::after { left: 82px; bottom: 14px; width: 56px; height: 44px; }
html.sx .t-night .sc-cloud { display: none; }

html.sx .sc-birds {
    position: absolute;
    left: 0;
    top: 150px;
    width: 70px;
    height: 30px;
    overflow: visible;
    color: var(--bird);
    opacity: 0;
    animation: scSkyFly 75s linear 6s infinite;
}
html.sx .sc-birds path {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    transform-box: fill-box;
    transform-origin: center;
    animation: scSkyFlap 0.9s ease-in-out infinite;
}
html.sx .sc-birds path:nth-child(2) { animation-delay: -0.3s; }
html.sx .sc-birds path:nth-child(3) { animation-delay: -0.6s; }
html.sx .t-night .sc-birds { display: none; }

html.sx .sc-star {
    position: absolute;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--star);
    animation: scSkyTwinkle var(--tw, 3s) ease-in-out var(--del, 0s) infinite;
}
html.sx .sc-shoot {
    position: absolute;
    left: 82vw;
    top: 15vh;
    width: 90px;
    height: 2px;
    border-radius: 2px;
    background: linear-gradient(90deg, transparent, var(--shoot));
    opacity: 0;
    animation: scSkyShoot 26s ease-in 8s infinite;
}
html.sx .sc-sky:not(.t-night) .sc-star,
html.sx .sc-sky:not(.t-night) .sc-shoot { display: none; }

@keyframes scSkyGlow { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }
@keyframes scSkyDrift {
    from { transform: translateX(-260px) scale(var(--s, 1)); }
    to   { transform: translateX(calc(100vw + 260px)) scale(var(--s, 1)); }
}
/* a 75-second cycle: the flock crosses in about 17 seconds, then the sky is clear */
@keyframes scSkyFly {
    0%        { opacity: 0; transform: translate(-80px, 40px); }
    1%        { opacity: 1; }
    22%       { opacity: 1; transform: translate(calc(100vw + 40px), -30px); }
    23%, 100% { opacity: 0; transform: translate(calc(100vw + 40px), -30px); }
}
@keyframes scSkyFlap { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(-0.4); } }
@keyframes scSkyTwinkle { 0%, 100% { opacity: 0.25; } 50% { opacity: 1; } }
@keyframes scSkyShoot {
    0%        { opacity: 0; transform: translate(0, 0) rotate(-24deg); }
    1%        { opacity: 1; }
    5%        { opacity: 0; transform: translate(-220px, 100px) rotate(-24deg); }
    6%, 100%  { opacity: 0; transform: translate(-220px, 100px) rotate(-24deg); }
}

/* phones: a smaller sun and moon, under the top bar */
@media (max-width: 720px) {
    html.sx .sc-sky-orb { top: 80px; width: 46px; height: 46px; }
    html.sx .t-night .sc-sky-orb { width: 32px; height: 32px; box-shadow: -8px 5px 0 0 var(--moon); }
}

/* reduce motion: the same sky, standing still (clouds spread out, no birds or shooting star) */
@media (prefers-reduced-motion: reduce) {
    html.sx .sc-sky *,
    html.sx .sc-sky *::before,
    html.sx .sc-sky *::after { animation: none !important; }
    html.sx .sc-cloud { transform: translateX(var(--still, 10vw)) scale(var(--s, 1)); }
    html.sx .sc-birds,
    html.sx .sc-shoot { display: none; }
}
