/* loader.css — the gecko loading screen, on every page (markup: base.html, timing: static/loader.js).
   html.gk-splash  when the app opens (once per app open; ~0.8 s, then it fades onto the page)
   html.gk-wait    the same scene when a tap takes longer than 0.3 s to bring the next page
   The Monsoon look in one still moment: the theme's sky over the sheet (its top edge the water line, as on every
   page), one cloud, a few slanted drops landing as rings, the gecko sitting on the water. Colours are the theme
   tokens from monsoon.css (html[data-theme]); the fallbacks are the day theme. No fake progress: browsers don't
   report real loading progress. Motion: transform / opacity only; "Reduce Motion" gets the still frame and a
   quick fade. */

#gk-loader { display: none; }
html.gk-splash #gk-loader, html.gk-wait #gk-loader {
    display: block; position: fixed; inset: 0; z-index: 9999; overflow: hidden;
    --gk-line: 62%;                                                  /* the water line, from the top */
    background: var(--band, linear-gradient(180deg, #A8CAE6, #CFE4EE 62%, #F5D6BE));
    color: var(--text, #0F242B);
    font-family: "Kantumruy Pro", system-ui, sans-serif; -webkit-font-smoothing: antialiased;
}

/* the page waits underneath, so its own fade-ins play as the loader fades (not hidden behind the splash) */
html.gk-splash .sky *, html.gk-splash .sky { animation-play-state: paused !important; }

/* the sheet: the page's own colour, with the lapping water edge the app's sheet has */
.gk-sheet { position: absolute; left: 0; right: 0; top: var(--gk-line); bottom: 0; background: var(--bg, #F1EFE4); }
.gk-sheet::before, .gk-sheet::after { content: ""; position: absolute; left: 0; right: 0; top: -13px; height: 14px;
    -webkit-mask: var(--gk-wave) repeat-x 50% 0 / 400px 14px; mask: var(--gk-wave) repeat-x 50% 0 / 400px 14px; }
.gk-sheet::before { background: var(--bg, #F1EFE4);
    --gk-wave: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='14' viewBox='0 0 400 14'%3E%3Cpath d='M0 7Q45 3 100 6.5Q150 10 200 7Q260 4 310 7.5Q360 10.5 400 7V14H0Z'/%3E%3C/svg%3E"); }
.gk-sheet::after { background: var(--water-hi, #fff); opacity: .9;
    --gk-wave: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='14' viewBox='0 0 400 14'%3E%3Cpath d='M0 7Q45 3 100 6.5Q150 10 200 7Q260 4 310 7.5Q360 10.5 400 7' fill='none' stroke='%23000' stroke-width='1.4'/%3E%3C/svg%3E"); }

/* one cloud: soft overlapping blobs that melt into one shape (the scene's lit-cloud colour) */
.gk-cloud { position: absolute; left: 50%; top: calc(var(--gk-line) - 250px); width: 220px; height: 96px; margin-left: -110px; }
.gk-cloud i { position: absolute; border-radius: 50%;
    background: radial-gradient(closest-side, var(--cloud-lit, #F7F9F6) 62%, color-mix(in srgb, var(--cloud-lit, #F7F9F6) 0%, transparent) 100%); }
.gk-cloud i:nth-child(1) { left: 0; top: 34px; width: 104px; height: 64px; }
.gk-cloud i:nth-child(2) { left: 44px; top: 0; width: 120px; height: 96px; }
.gk-cloud i:nth-child(3) { left: 116px; top: 22px; width: 104px; height: 76px; }
.gk-cloud i:nth-child(4) { left: 26px; top: 52px; width: 170px; height: 44px; }

/* a few slanted drops between the cloud and the water */
.gk-rain { position: absolute; left: 50%; top: calc(var(--gk-line) - 168px); width: 150px; height: 162px; margin-left: -75px; overflow: hidden; }
.gk-rain i { position: absolute; top: 0; left: var(--x); width: 1.5px; height: 18px; border-radius: 1px;
    background: rgba(var(--drop, 59, 86, 98), .6); transform: translateY(var(--y, 40px)) rotate(14deg); }
.gk-rain i:nth-child(1) { --x: 10%; --y: 96px;  --d: .1s; }
.gk-rain i:nth-child(2) { --x: 26%; --y: 30px;  --d: .7s; }
.gk-rain i:nth-child(3) { --x: 40%; --y: 120px; --d: .35s; }
.gk-rain i:nth-child(4) { --x: 55%; --y: 58px;  --d: 1s; }
.gk-rain i:nth-child(5) { --x: 70%; --y: 10px;  --d: .55s; }
.gk-rain i:nth-child(6) { --x: 83%; --y: 80px;  --d: .2s; }
.gk-rain i:nth-child(7) { --x: 94%; --y: 136px; --d: .85s; }

/* rings where the drops land (left and right of the gecko) */
.gk-rings { position: absolute; left: 50%; top: var(--gk-line); width: 180px; height: 0; margin-left: -90px; }
.gk-rings i { position: absolute; top: -5px; left: var(--x); width: 28px; height: 8px; margin-left: -14px; border-radius: 50%;
    box-shadow: inset 0 0 0 1.5px rgba(var(--drop, 59, 86, 98), .5); transform: scale(.9); opacity: .5; }
.gk-rings i:nth-child(1) { --x: 8%;  --d: .5s; }
.gk-rings i:nth-child(2) { --x: 86%; --d: 1.1s; }
.gk-rings i:nth-child(3) { --x: 98%; --d: .8s; opacity: .3; }

/* the gecko, sitting on the water */
.gk-gecko { position: absolute; left: 50%; top: var(--gk-line); width: 72px; height: 72px; margin: -78px 0 0 -36px; border-radius: 20px; z-index: 2;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .08), 0 12px 28px rgba(0, 0, 0, .18); }

/* the name, on the sheet */
.gk-word { position: absolute; left: 16px; right: 16px; top: calc(var(--gk-line) + 28px); margin: 0; text-align: center;
    font: 700 24px/1.4 "Kantumruy Pro", system-ui, sans-serif; color: var(--text, #0F242B); }
.gk-word small { display: block; margin-top: 2px; font: 400 14px/1.5 "Kantumruy Pro", system-ui, sans-serif; color: var(--text-muted, #2E4046); }
html.gk-wait:not(.gk-splash) .gk-word { font-size: 20px; }

/* ---- motion (only when the person allows it): drops fall and land, the scene settles in, the loader fades out ---- */
@media (prefers-reduced-motion: no-preference) {
    html:not(.still) .gk-rain i { animation: gk-fall 1.3s linear var(--d) infinite backwards; }
    html:not(.still) .gk-rings i { animation: gk-ring 1.3s var(--ease-out, ease-out) var(--d) infinite backwards; }
    html:not(.still) .gk-cloud { animation: gk-drift 12s ease-in-out infinite alternate; }
    html:not(.still) .gk-gecko { animation: gk-in 400ms cubic-bezier(.215, .61, .355, 1) 80ms backwards, gk-float 6s ease-in-out .5s infinite; }
    html:not(.still) .gk-word { animation: gk-in 400ms cubic-bezier(.215, .61, .355, 1) 160ms backwards; }
    html.gk-wait:not(.gk-splash) #gk-loader { animation: gk-fadein 250ms ease-out; }
    html.gk-out #gk-loader { animation: gk-fade 360ms ease-out 100ms forwards; }
    html.gk-out .gk-gecko { animation: gk-sink 360ms ease-in 100ms forwards; }
}
@keyframes gk-fall { from { transform: translateY(-20px) rotate(14deg); opacity: 0; }
                     15% { opacity: 1; } 90% { opacity: 1; }
                     to { transform: translateY(160px) rotate(14deg); opacity: 0; } }
@keyframes gk-ring { 0%, 70% { transform: scale(.2); opacity: 0; } 72% { opacity: .9; } 100% { transform: scale(1.5); opacity: 0; } }
@keyframes gk-drift { from { transform: translateX(-6px); } to { transform: translateX(6px); } }
@keyframes gk-float { 50% { transform: translateY(-3px); } }
@keyframes gk-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes gk-sink { to { transform: translateY(6px); opacity: 0; } }
@keyframes gk-fade { to { opacity: 0; } }
@keyframes gk-fadein { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
    #gk-loader *, #gk-loader *::before, #gk-loader *::after { animation: none !important; }
    html.gk-out #gk-loader { animation: gk-fade .25s forwards !important; }
}
