/* Azul, the whale from the Azulweb logo, swimming freely around the page (markup and movement in mascot.js) */
.aw-mascot {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 18;
  width: 124px;
  height: 124px;
  pointer-events: none;
  translate: -200px 60vh;
  opacity: 0;
  transition: opacity 900ms var(--sm-ease);
  --tilt: 0deg;
}

.aw-mascot[data-state="in"] { opacity: 1; }

.aw-whale {
  position: absolute;
  inset: 0;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
}

.aw-whale:focus-visible { outline: 3px solid var(--aw-sky); outline-offset: 4px; border-radius: 30px; }

/* Turning around: the logo faces left, so swimming right mirrors it */
.aw-whale-turn {
  position: absolute;
  inset: 0;
  rotate: var(--tilt);
  scale: 1 1;
  filter: drop-shadow(0 12px 14px #173d6033);
  transition: scale 700ms var(--sm-ease), rotate 600ms var(--sm-ease);
}

.aw-mascot.is-right .aw-whale-turn { scale: -1 1; }

.aw-whale-swim {
  position: absolute;
  inset: 0;
  transform-origin: 40% 60%;
  animation: aw-whale-undulate 1.9s ease-in-out infinite;
  transition: scale 600ms var(--sm-ease);
}

@keyframes aw-whale-undulate {
  0%, 100% { transform: skewY(-1.5deg) scaleY(1); }
  50% { transform: skewY(1.5deg) scaleY(.98); }
}

.aw-mascot.is-fast .aw-whale-swim { animation-duration: .7s; }

.aw-whale:hover .aw-whale-swim { scale: 1.08; }

/* The logo cut in three layers: body, tail and flipper share the same image */
.aw-whale-part {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  user-select: none;
  -webkit-user-drag: none;
}

.aw-whale-body {
  clip-path: polygon(0 0, 58% 0, 58% 30%, 64% 36%, 78% 37%, 100% 37%, 100% 100%, 0 100%);
}

.aw-whale-tail {
  clip-path: polygon(58% 0, 100% 0, 100% 40%, 78% 40%, 64% 39%, 58% 33%);
  transform-origin: 71% 37%;
  animation: aw-whale-tail 1.9s ease-in-out infinite;
}

@keyframes aw-whale-tail {
  0%, 100% { rotate: -6deg; }
  50% { rotate: 7deg; }
}

.aw-mascot.is-fast .aw-whale-tail { animation-duration: .7s; }

/* Blink: a lid in the body colour slides over the logo's eye (centred at 38.4% / 59.4%)
   and leaves the curve of a closed eye. mascot.js decides when, at random. */
.aw-whale-lid {
  position: absolute;
  left: 34.2%;
  top: 55.2%;
  width: 8.4%;
  height: 8.4%;
  border-radius: 50%;
  background: #35a6e3;
  transform-origin: 50% 0;
  scale: 1 0;
  transition: scale 70ms ease-in;
}

.aw-whale-lid::after {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  top: 22%;
  height: 40%;
  border-bottom: 2px solid #225b8a;
  border-radius: 0 0 50% 50%;
  opacity: 0;
  transition: opacity 50ms;
}

.aw-mascot.is-blinking .aw-whale-lid { scale: 1 1; transition-duration: 60ms; }
.aw-mascot.is-blinking .aw-whale-lid::after { opacity: 1; transition-delay: 40ms; }

/* Carried by the visitor: a grab hand, a little lift and a happy fast tail */
.aw-whale { cursor: grab; touch-action: none; }
.aw-mascot.is-dragging .aw-whale { cursor: grabbing; }
.aw-mascot.is-dragging .aw-whale-turn { filter: drop-shadow(0 22px 22px #173d6040); transition: scale 700ms var(--sm-ease); }
.aw-mascot.is-dragging .aw-whale-swim { scale: 1.12; animation-duration: .6s; }
.aw-mascot.is-dragging .aw-whale-tail { animation-duration: .45s; }

/* Water spout from the head every so often, and when tapped */
.aw-whale-spout {
  position: absolute;
  left: -5%;
  top: 42%;
  width: 16%;
  height: 26%;
  translate: 0 -100%;
  transform-origin: 50% 100%;
  scale: 1 0;
  opacity: 0;
  animation: aw-whale-spout 11s var(--sm-ease) infinite 4s;
}

.aw-whale-spout b {
  position: absolute;
  bottom: 0;
  left: 44%;
  width: 12%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(0deg, #7fcaf0, #bfe3f7);
}

.aw-whale-spout b:nth-child(2) { rotate: -32deg; transform-origin: 50% 100%; height: 80%; }
.aw-whale-spout b:nth-child(3) { rotate: 32deg; transform-origin: 50% 100%; height: 80%; }

.aw-whale-spout b::after {
  content: "";
  position: absolute;
  top: -10%;
  left: 50%;
  width: 260%;
  aspect-ratio: 1;
  translate: -50% 0;
  border-radius: 50%;
  background: #7fcaf0;
}

@keyframes aw-whale-spout {
  0%, 86%, 100% { scale: 1 0; opacity: 0; }
  90% { scale: 1 1.1; opacity: 1; }
  97% { scale: 1.1 .9; opacity: 0; }
}

.aw-mascot.is-splashing .aw-whale-spout { animation: aw-whale-splash 1400ms var(--sm-ease) both; }

@keyframes aw-whale-splash {
  0% { scale: 1 0; opacity: 0; }
  30% { scale: 1.15 1.3; opacity: 1; }
  100% { scale: 1 .8; opacity: 0; }
}

.aw-mascot.is-splashing .aw-whale-swim { animation: aw-whale-jump 900ms var(--sm-ease); }

@keyframes aw-whale-jump {
  0%, 100% { translate: 0 0; rotate: 0deg; }
  35% { translate: 0 -22px; rotate: -6deg; }
  65% { translate: 0 3px; rotate: 3deg; }
}

/* Bubbles the whale leaves behind (appended to body by mascot.js) */
.aw-sea-bubble {
  position: fixed;
  z-index: 17;
  border-radius: 50%;
  border: 1.5px solid #7fcaf0cc;
  background: radial-gradient(circle at 30% 30%, #ffffffcc 0 18%, #bfe3f733 40%, transparent 70%);
  pointer-events: none;
  animation: aw-sea-bubble 3.4s ease-in forwards;
}

@keyframes aw-sea-bubble {
  0% { opacity: 0; translate: 0 0; scale: .4; }
  15% { opacity: .9; scale: 1; }
  100% { opacity: 0; translate: var(--drift, 0px) -120px; scale: 1.15; }
}

/* Speech bubble that travels with the whale */
.aw-mascot-bubble {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 19;
  max-width: min(280px, calc(100vw - 24px));
  padding: 13px 36px 13px 16px;
  border-radius: 20px;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
  box-shadow: 0 16px 40px #173d6026, inset 0 0 0 1px #35a6e326;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 500ms var(--sm-ease), visibility 0s linear 500ms;
  --tail-x: 50%;
}

.aw-mascot-bubble::before {
  content: "";
  position: absolute;
  left: var(--tail-x);
  bottom: -7px;
  width: 16px;
  height: 16px;
  translate: -50% 0;
  rotate: 45deg;
  border-radius: 0 0 4px 0;
  background: #fff;
  box-shadow: 1px 1px 0 #35a6e326;
}

.aw-mascot-bubble.is-below::before { bottom: auto; top: -7px; border-radius: 4px 0 0 0; box-shadow: -1px -1px 0 #35a6e326; }

.aw-mascot-bubble.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 500ms var(--sm-ease), visibility 0s;
}

.aw-mascot-text { position: relative; margin: 0; }
.aw-mascot-text b { color: var(--aw-deep); }
.aw-mascot-text a { color: var(--aw-deep); font-weight: 650; text-decoration: underline; text-decoration-color: var(--aw-sky); text-underline-offset: 3px; }

.aw-mascot-close {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
}

.aw-mascot-close:hover { background: var(--aw-mist); color: var(--aw-deep); }

@media (max-width: 800px) {
  .aw-mascot { width: 82px; height: 82px; }
  .aw-mascot-bubble { font-size: 13px; max-width: min(250px, calc(100vw - 24px)); }
}

/* Still versions: Azul rests in a corner, without moving parts, and keeps talking */
body.motion-off .aw-mascot *,
body.motion-off .aw-sea-bubble { animation: none !important; transition: none !important; }
body.motion-off .aw-sea-bubble { display: none; }

@media (prefers-reduced-motion: reduce) {
  .aw-mascot *, .aw-mascot-bubble { animation: none !important; transition: none !important; }
  .aw-sea-bubble { display: none; }
}
