/* Tux mascot, shared by the home page and the blog. Built by assets/js/mascot.js */
:root,
[data-theme="light"] {
  --mascot-white: #4a6a46;
  --mascot-accent: #4e7d1f;
}

[data-theme="dark"] {
  --mascot-white: #d4ecd0;
  --mascot-accent: #b7d96a;
}

/* A fixed layer the script moves around the screen with transform */
.mascot-box {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 40;
  pointer-events: none;
  color: var(--text-color);
  will-change: transform;
}

.mascot {
  /* Larger than his box, so hopping and somersaulting never reach the edges */
  position: absolute;
  left: -30%;
  top: -30%;
  display: block;
  width: 160%;
  height: 160%;
  color: var(--text-color);
  pointer-events: none;
}

/* The clickable area stays the size of his box */
.mascot-hit {
  position: absolute;
  inset: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  outline: none;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
}

.mascot-hit:focus-visible {
  outline: 2px dashed var(--text-color);
  outline-offset: 6px;
}

/* Speech bubble, shown when Tux waits at the end of the home page. The script draws it as a pixel-art ellipse */
.mascot-bubble {
  position: absolute;
  left: 0;
  top: 0;
  color: var(--text-color);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), visibility 0s 0.25s;
}

.mascot-bubble:not(.is-on) {
  opacity: 0;
  visibility: hidden;
  transform: scale(0.5);
}

.mascot-bubble.is-on {
  transition-delay: 0s;
}

.mascot-bubble-art {
  position: absolute;
  left: 0;
  top: 0;
  overflow: visible;
  shape-rendering: crispEdges;
}

.mascot-bubble-art .b {
  fill: var(--text-color);
}

.mascot-bubble-art .f {
  fill: var(--bg-color);
}

.mascot-bubble-text {
  position: absolute;
  left: 50%;
  top: 50%;
  width: max-content;
  max-width: 9rem;
  transform: translate(-50%, -50%);
  font-size: 0.8rem;
  line-height: 1.25;
  text-align: center;
  color: inherit;
  text-decoration: none;
  pointer-events: none;
}

a.mascot-bubble-text {
  pointer-events: auto;
}

.mascot-bubble-text:is(a):hover,
.mascot-bubble-text:is(a):focus-visible {
  text-decoration: underline;
}

/* The unspoken part of the text keeps the bubble's size while it types */
.mascot-bubble .off {
  visibility: hidden;
}

@media (max-width: 500px) {
  .mascot-bubble-text {
    max-width: 7.5rem;
  }
}

/* A solid background above the transition canvas would show the new theme before the wave arrives */
body.is-transitioning .mascot-bubble-art .f {
  fill: transparent;
}

/* Where Tux waits at the end of a page: the script follows this block as the page scrolls */
.mascot-spot {
  width: 100%;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .mascot-bubble {
    transition: none;
  }
}
