/* Atlas orb: flat look, colour choice, and the tap game (tap = react, quick taps = heat, sixth quick tap = bursts into flames).
   Markup: <button type="button" class="..." data-bot-tap aria-label="Atlas. Tap me.">
             <span class="bot-rocket"><span class="bot-flame"></span><span class="atlas-bot"><i></i><i></i></span></span></button>
   The tile's ::before and ::after are the side flames, so the tile must not use its own pseudo-elements.
   orb-tap.js sets data-heat="1".."5", restarts .bot-tap on each tap and adds .bot-fire for 1600ms. Motion is transform and opacity only. */

/* colour: one var, chosen in Settings (html[data-orb]); palette colours only */
.atlas-bot { --orb: #2563EB; }
html[data-orb="violet"] .atlas-bot { --orb: #8B5CF6; }
html[data-orb="teal"] .atlas-bot { --orb: #14B8A6; }
html[data-orb="amber"] .atlas-bot { --orb: #D97706; }
html[data-orb="black"] .atlas-bot { --orb: #18181B; }
/* the black orb keeps a faint rim so it still reads on the dark glass */
html[data-orb="black"] [data-bot-tap] .atlas-bot, html [data-orb-pick="black"] .atlas-bot { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .16); }
html[data-orb="ai"] .atlas-bot { --orb: linear-gradient(135deg, #2563EB, #8B5CF6); }
/* a picker swatch always shows its own colour */
html [data-orb-pick="blue"] .atlas-bot { --orb: #2563EB; } html [data-orb-pick="violet"] .atlas-bot { --orb: #8B5CF6; } html [data-orb-pick="teal"] .atlas-bot { --orb: #14B8A6; }
html [data-orb-pick="amber"] .atlas-bot { --orb: #D97706; } html [data-orb-pick="black"] .atlas-bot { --orb: #18181B; } html [data-orb-pick="ai"] .atlas-bot { --orb: linear-gradient(135deg, #2563EB, #8B5CF6); }

[data-bot-tap] { --s: 40px; --out: cubic-bezier(.23, 1, .32, 1); --inout: cubic-bezier(.77, 0, .175, 1);
  position: relative; display: inline-grid; place-items: center; overflow: visible; isolation: isolate;
  cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; user-select: none; }
.bot-rocket { position: relative; display: grid; place-items: center; width: var(--s); height: var(--s); isolation: isolate; }

/* the flat orb: one colour, white pill eyes. Eyes use currentColor so the glass look keeps them white */
[data-bot-tap] .atlas-bot { position: relative; display: block; width: var(--s); height: var(--s); border-radius: 50%; background: var(--orb);
  color: #FFFFFF; box-shadow: none; isolation: isolate; }
/* heat: an amber glow behind (::before) and an amber wash over the colour (::after), both opacity only */
[data-bot-tap] .atlas-bot::before, [data-bot-tap] .atlas-bot::after { content: ""; position: absolute; border-radius: 50%; opacity: 0; pointer-events: none;
  transition: opacity 320ms var(--out); }
[data-bot-tap] .atlas-bot::before { inset: -45%; z-index: -1; background: radial-gradient(closest-side, rgba(217, 119, 6, .55), rgba(217, 119, 6, .2) 60%, transparent); }
[data-bot-tap] .atlas-bot::after { inset: 0; z-index: 1; background: #D97706; }
[data-bot-tap] .atlas-bot i { position: absolute; z-index: 3; top: 35%; width: 11.5%; height: 25%; }
[data-bot-tap] .atlas-bot i:first-child { left: 33.5%; } [data-bot-tap] .atlas-bot i:last-child { right: 33.5%; left: auto; }
[data-bot-tap] .atlas-bot i::before { content: ""; position: absolute; inset: 0; border-radius: 99px; background: currentColor; transform-origin: 50% 60%;
  animation: bot-blink 5.2s infinite; transition: opacity 160ms var(--out), scale 200ms var(--out); }
[data-bot-tap] .atlas-bot i::after { content: ""; position: absolute; left: -34%; right: -34%; top: 26%; height: 30%; border: max(2px, calc(var(--s) * .055)) solid currentColor;
  border-bottom: 0; border-radius: 99px 99px 0 0; opacity: 0; scale: 1 .6; translate: 0 18%; transition: opacity 160ms var(--out), scale 200ms var(--out), translate 200ms var(--out); }
@keyframes bot-blink { 0%, 92%, 100% { transform: scaleY(1); } 94.5% { transform: scaleY(.1); } }

/* faces by heat: 1-2 happy, 3 wide-eyed, 4-5 squinting hard */
[data-heat="1"] .atlas-bot i::before, [data-heat="2"] .atlas-bot i::before { opacity: 0; scale: 1 .15; }
[data-heat="1"] .atlas-bot i::after, [data-heat="2"] .atlas-bot i::after { opacity: 1; scale: 1; translate: 0; }
[data-heat="3"] .atlas-bot i::before { scale: 1.25 1.2; }
[data-heat="4"] .atlas-bot i::before, [data-heat="5"] .atlas-bot i::before { scale: 1.1 .45; }

/* glow and wash by heat */
[data-heat="1"] .atlas-bot::before { opacity: .2; }
[data-heat="2"] .atlas-bot::before { opacity: .38; } [data-heat="2"] .atlas-bot::after { opacity: .14; }
[data-heat="3"] .atlas-bot::before { opacity: .56; } [data-heat="3"] .atlas-bot::after { opacity: .34; }
[data-heat="4"] .atlas-bot::before { opacity: .76; } [data-heat="4"] .atlas-bot::after { opacity: .6; }
[data-heat="5"] .atlas-bot::before { opacity: .95; } [data-heat="5"] .atlas-bot::after { opacity: .85; }

/* each tap: squash, hop, land. The hop grows with heat */
[data-bot-tap] { --hop: -14%; }
[data-heat="3"] { --hop: -20%; } [data-heat="4"], [data-heat="5"] { --hop: -26%; }
.bot-tap .bot-rocket { animation: bot-boop 440ms; }
@keyframes bot-boop {
  0% { transform: none; animation-timing-function: var(--out); }
  16% { transform: scale(1.1, .88); animation-timing-function: cubic-bezier(.2, .8, .3, 1); }
  46% { transform: translateY(var(--hop)) scale(.94, 1.06); animation-timing-function: cubic-bezier(.5, 0, .8, .4); }
  72% { transform: scale(1.06, .94); animation-timing-function: var(--out); }
  100% { transform: none; } }

/* hot: a shiver at 4, a hard shake and a peek of flame at 5 */
[data-heat="4"] .atlas-bot { --jit: 2.5%; animation: bot-jit 150ms linear infinite; }
[data-heat="5"] .atlas-bot { --jit: 4.5%; animation: bot-jit 110ms linear infinite; }
@keyframes bot-jit { 25% { translate: var(--jit) 0; } 75% { translate: calc(var(--jit) * -1) 0; } }

/* fire: the orb bursts into flames. Three pointed tongues behind it (.bot-flame in the middle, the tile's ::before and ::after either side)
   roar up, flicker, then die down while the orb cools back to its colour. 1600ms, no launch. */
.bot-flame, [data-bot-tap]::before, [data-bot-tap]::after { content: ""; position: absolute; z-index: -1; pointer-events: none; opacity: 0;
  border-radius: 50% 0 50% 50%; rotate: -45deg; transform-origin: 30% 70%; transform: scale(.2);
  background: radial-gradient(circle at 32% 68%, #FEF3C7 0 16%, #F7D08F 32%, #D97706 66%); }
/* middle tongue, tip well above the orb */
.bot-flame { width: 88%; height: 88%; left: 6%; top: -38%; transition: opacity 220ms var(--out), transform 260ms var(--out); }
.bot-flame::after { content: ""; position: absolute; inset: 30% 30% 12% 12%; border-radius: inherit; background: #FEF3C7; opacity: .8;
  transform-origin: 30% 70%; animation: bot-flicker 110ms linear infinite alternate; }
/* side tongues on the tile, leaning out */
[data-bot-tap]::before, [data-bot-tap]::after { width: calc(var(--s) * .62); height: calc(var(--s) * .62); top: calc(50% - var(--s) * .52); }
[data-bot-tap]::before { left: calc(50% - var(--s) * .66); rotate: -70deg; }
[data-bot-tap]::after { left: calc(50% + var(--s) * .04); rotate: -20deg; }
@keyframes bot-flicker { to { scale: .86; } }
/* at heat 5 the middle tongue peeks over the top: about to go */
[data-heat="5"] .bot-flame { opacity: .95; transform: scale(.42); }
[data-heat="5"] .bot-flame { animation: bot-flicker 140ms linear infinite alternate; }

.bot-fire .atlas-bot::after { opacity: 1; }
.bot-fire .atlas-bot::before { opacity: 1; animation: bot-blaze 1600ms both; transition: none; }
@keyframes bot-blaze { 0%, 10% { transform: scale(1); } 20% { transform: scale(1.5); } 30%, 70% { transform: scale(1.3); } 100% { transform: scale(1); } }
.bot-fire .atlas-bot { animation: none; }
/* the orb tenses, bursts, trembles in the flames, then gives a little shake-off */
.bot-fire .bot-rocket { animation: bot-burst 1600ms both; }
@keyframes bot-burst {
  0% { transform: none; animation-timing-function: var(--inout); }
  12% { transform: scale(.88); animation-timing-function: var(--out); }
  20% { transform: scale(1.14); animation-timing-function: var(--out); }
  28% { transform: scale(1); }
  34% { transform: translateX(-3%); } 40% { transform: translateX(3%); } 46% { transform: translateX(-3%); } 52% { transform: translateX(3%); }
  58% { transform: translateX(-2%); } 64% { transform: translateX(2%); } 70% { transform: none; animation-timing-function: var(--out); }
  84% { transform: scale(1.06, .94); animation-timing-function: var(--out); }
  100% { transform: none; } }
.bot-fire .bot-flame { animation: bot-roar 1600ms both; transition: none; }
.bot-fire::before { animation: bot-roar-side 1600ms both, bot-flicker 130ms linear infinite alternate; }
.bot-fire::after { animation: bot-roar-side 1600ms both, bot-flicker 120ms linear infinite alternate-reverse; }
@keyframes bot-roar {
  0% { opacity: .95; transform: scale(.42); }
  12% { opacity: .95; transform: scale(.3); }
  20% { opacity: 1; transform: scale(1.18); }
  28% { opacity: 1; transform: scale(1); }
  70% { opacity: 1; transform: scale(1.04); }
  88% { opacity: 0; transform: scale(.35); }
  100% { opacity: 0; transform: scale(.2); } }
@keyframes bot-roar-side {
  0%, 14% { opacity: 0; transform: scale(.2); }
  22% { opacity: 1; transform: scale(1.15); }
  30% { opacity: 1; transform: scale(.95); }
  66% { opacity: 1; transform: scale(1); }
  84% { opacity: 0; transform: scale(.3); }
  100% { opacity: 0; transform: scale(.2); } }
/* eyes: squeezed shut in the flames, happy once they die down */
.bot-fire .atlas-bot i::before { animation: bot-eye-grit 1600ms both; transition: none; }
.bot-fire .atlas-bot i::after { animation: bot-eye-joy 1600ms both; transition: none; }
@keyframes bot-eye-grit { 0%, 70% { opacity: 1; scale: 1.1 .35; } 76%, 94% { opacity: 0; scale: 1 .15; } 100% { opacity: 1; scale: 1; } }
@keyframes bot-eye-joy { 0%, 70% { opacity: 0; scale: 1 .6; translate: 0 18%; } 76%, 94% { opacity: 1; scale: 1; translate: 0; } 100% { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  /* no movement: the colour, glow, faces and flames still change, as fades at a fixed size */
  .bot-tap .bot-rocket, .bot-fire .bot-rocket, [data-heat] .atlas-bot, [data-bot-tap] .atlas-bot i::before, .bot-flame::after, .bot-flame,
  .bot-fire .atlas-bot::before { animation: none; }
  .bot-fire .bot-flame, .bot-fire::before, .bot-fire::after { animation: bot-burn-still 1600ms both; }
  @keyframes bot-burn-still { 0% { opacity: 0; transform: scale(1); } 15%, 70% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(1); } }
  [data-bot-tap] .atlas-bot i::after, [data-bot-tap] .atlas-bot i::before { scale: 1; translate: 0; }
  .bot-fire .atlas-bot i::before { opacity: 0; } .bot-fire .atlas-bot i::after { animation: none; opacity: 1; }
}
