/* The myna (static/js/dhwani-bird.js). Loaded by the console, the landing page and
   anything else that shows Dhwani. Its colours follow the theme: a dark bird with
   a yellow beak on light pages, a yellow bird with an orange beak on dark ones. */
.dh-bird, .dh-note {
    --bird-body: #131315;
    --bird-band: #ffffff;
    --bird-beak: #ffc21a;
}
[data-theme="dark"] .dh-bird,
[data-theme="dark"] .dh-note {
    --bird-body: #ffc21a;
    --bird-band: #0a0a0c;
    --bird-beak: #f26b1d;
}

/* Three kinds of layer (see dhwani-bird.js). top: fixed, above everything, where it
   flies. doc: in the document, so a perched bird scrolls with the page. in: inside
   a drawer or scrolling panel, so it scrolls and slides with that. */
.dh-bird-layer { pointer-events: none; }
.dh-bird-top { position: fixed; inset: 0; z-index: 10001; overflow: hidden; transition: opacity .18s ease; }
.dh-bird-doc { position: absolute; left: 0; top: 0; width: 0; height: 0; z-index: 90; }
.dh-bird-in { position: absolute; left: 0; top: 0; width: 0; height: 0; z-index: 6; }
body.app-preloading .dh-bird-top, .dh-bird-top.dh-hide { opacity: 0; }

/* A tap mark: where the bird pecked, which is where something was pressed. */
.dh-tap { position: absolute; left: 0; top: 0; width: 0; height: 0; z-index: 3; transform: translate(var(--x), var(--y)); pointer-events: none; }
.dh-tap i {
    position: absolute; left: -17px; top: -17px; width: 34px; height: 34px; border-radius: 50%;
    border: 2px solid #ffc21a; opacity: 0; animation: dhTap .52s cubic-bezier(.2, .7, .3, 1) forwards;
}
.dh-tap i + i { border-color: currentColor; color: #131315; animation-delay: .1s; animation-duration: .6s; }
[data-theme="dark"] .dh-tap i + i { color: #f3f3f5; }
@keyframes dhTap { 0% { opacity: .95; transform: scale(.15); } 70% { opacity: .5; } 100% { opacity: 0; transform: scale(1.25); } }

/* The page loader: the bird flying in place, air streaming past. */
.dh-loader-bird { position: relative; display: block; width: 190px; height: 104px; }
.dh-loader-bird s {
    position: absolute; left: 100%; height: 2px; border-radius: 2px; background: currentColor; opacity: 0;
    animation: dhAir 1s linear infinite; animation-play-state: paused;
}
.dh-loader-bird s:nth-of-type(1) { top: 22%; width: 34px; }
.dh-loader-bird s:nth-of-type(2) { top: 58%; width: 22px; animation-delay: .34s; animation-duration: .8s; }
.dh-loader-bird s:nth-of-type(3) { top: 84%; width: 46px; animation-delay: .62s; animation-duration: 1.15s; }
body.app-busy .dh-loader-bird s, body.app-preloading .dh-loader-bird s { animation-play-state: running; }
@keyframes dhAir { 0% { transform: translateX(0); opacity: 0; } 20% { opacity: .22; } 80% { opacity: .22; } 100% { transform: translateX(-240px); opacity: 0; } }

.dh-bird { position: absolute; left: 0; top: 0; width: 0; height: 0; z-index: 5; will-change: transform; }
.dh-bird-s { position: absolute; left: 0; top: 0; width: 0; height: 0; transform-origin: 0 0; }
.dh-bird-s svg { position: absolute; left: -47px; top: -55.5px; display: block; overflow: visible; pointer-events: none; }
/* Only the painted bird takes the pointer (press it and it hops); its empty box never blocks a button. */
.dh-bird-s svg g { pointer-events: visiblePainted; cursor: pointer; }

/* Notes that float up while a recording plays. */
.dh-note {
    position: absolute; left: 0; top: 0; z-index: 4; width: 18px; height: 18px;
    color: var(--bird-body); pointer-events: none; opacity: 0;
    animation: dhNoteUp 1.5s cubic-bezier(.2, .7, .3, 1) forwards;
}
.dh-note.alt { color: var(--bird-beak); }
.dh-note svg { display: block; width: 100%; height: 100%; fill: currentColor; }
@keyframes dhNoteUp {
    0%   { opacity: 0; transform: translate(var(--x), var(--y)) scale(calc(.5 * var(--s, 1))); }
    14%  { opacity: 1; }
    55%  { transform: translate(calc(var(--x) + var(--dx) * .6 - 4px), calc(var(--y) - 30px)) rotate(calc(var(--rot) * -.5)) scale(var(--s, 1)); }
    100% { opacity: 0; transform: translate(calc(var(--x) + var(--dx)), calc(var(--y) - 58px * var(--s, 1))) rotate(var(--rot)) scale(calc(.9 * var(--s, 1))); }
}

/* Build with Dhwani: the orb keeps its place and size but shows the bird instead. */
.pb-orb.dh-bird-stage { background: none !important; border: 0 !important; animation: none !important; overflow: visible; }
.pb-orb.dh-bird-stage::after { display: none !important; }

@media (prefers-reduced-motion: reduce) {
    .dh-note, .dh-tap, .dh-loader-bird s { display: none; }
}
