/* ===========================================================================
   seahorse-buddy.css — styles for the "Seahorse Buddy" site mascot.
   A nostalgic BonziBuddy-style desktop-pal Easter egg, reimagined as an
   ORIGINAL seahorse tied to jacobrakai.org's "seahorse emoji" lore.

   Self-contained. Uses the site's design tokens (var(--…)) so it is
   automatically dark-mode aware (data-theme + prefers-color-scheme). All
   tokens carry light-mode fallbacks so the component still renders if the
   design system changes underneath it.

   Only loaded on pages with front-matter `buddy: true` (the 6 doodle pages).
   =========================================================================== */

/* Root container: fixed to the bottom-right corner. JS sets left/top when the
   user drags, promoting it out of the corner anchor. */
.shb {
  --shb-accent: var(--accent, #e0503a);
  --shb-bg: var(--bg, #faf6f0);
  --shb-ink: var(--text, #211d18);
  --shb-muted: var(--text-muted, #6f665a);
  --shb-line: var(--line, #ece3d6);
  --shb-shadow: var(--shadow-hover, 0 6px 16px rgba(33, 29, 24, 0.14));

  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 2147483000;   /* above site chrome, below nothing that matters */
  width: 190px;
  font-family: var(--font-body, Georgia, serif);
  color: var(--shb-ink);
  /* Container itself is click-through except for its children. */
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
}
.shb * { box-sizing: border-box; }
.shb.shb-dragging { transition: none; }

/* When JS pins an absolute position (after a drag) it adds this class so the
   corner anchor no longer applies. */
.shb.shb-pinned { right: auto; bottom: auto; }

/* --- Speech bubble ------------------------------------------------------- */
.shb-bubble {
  pointer-events: auto;
  position: relative;
  background: var(--shb-bg);
  border: 2px solid var(--shb-ink);
  border-radius: 14px;
  padding: 12px 30px 12px 14px;
  margin-bottom: 10px;
  font-size: 0.9rem;
  line-height: 1.4;
  box-shadow: var(--shb-shadow);
  min-height: 20px;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.shb-bubble.shb-hidden {
  opacity: 0;
  transform: translateY(6px) scale(0.96);
  pointer-events: none;
}
/* Little tail on the bubble, pointing down toward the seahorse. */
.shb-bubble::after {
  content: "";
  position: absolute;
  left: 34px;
  bottom: -9px;
  width: 14px;
  height: 14px;
  background: var(--shb-bg);
  border-right: 2px solid var(--shb-ink);
  border-bottom: 2px solid var(--shb-ink);
  transform: rotate(45deg);
}
.shb-text { display: block; }
.shb-text p { margin: 0 0 8px; }
.shb-text p:last-child { margin-bottom: 0; }

/* Buttons inside the bubble (e.g. "Show me"). */
.shb-btn {
  pointer-events: auto;
  display: inline-block;
  margin-top: 4px;
  padding: 4px 12px;
  font-family: var(--font-mono, monospace);
  font-size: 0.78rem;
  color: var(--shb-bg);
  background: var(--shb-accent);
  border: 2px solid var(--shb-accent);
  border-radius: 8px;
  cursor: pointer;
  transition: filter 0.15s ease;
}
.shb-btn:hover { filter: brightness(1.08); }
.shb-btn:focus-visible {
  outline: 2px solid var(--shb-ink);
  outline-offset: 2px;
}

/* The triumphant "seahorse emoji" reveal: a big empty bordered glyph box. */
.shb-emojibox {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 68px;
  height: 68px;
  margin: 6px 0 2px;
  font-size: 2.6rem;
  line-height: 1;
  color: var(--shb-muted);
  border: 2px dashed var(--shb-muted);
  border-radius: 6px;
  background:
    repeating-linear-gradient(
      45deg,
      transparent, transparent 7px,
      color-mix(in srgb, var(--shb-muted) 12%, transparent) 7px,
      color-mix(in srgb, var(--shb-muted) 12%, transparent) 9px
    );
}

/* --- Corner controls (speaker + dismiss), sit above the seahorse --------- */
.shb-controls {
  pointer-events: auto;
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-bottom: 4px;
}
.shb-ctl {
  pointer-events: auto;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 0.85rem;
  line-height: 1;
  color: var(--shb-ink);
  background: var(--shb-bg);
  border: 2px solid var(--shb-ink);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: var(--shb-shadow);
  transition: filter 0.15s ease, background 0.15s ease;
}
.shb-ctl:hover { filter: brightness(1.05); }
.shb-ctl:focus-visible {
  outline: 2px solid var(--shb-accent);
  outline-offset: 2px;
}
.shb-ctl[aria-pressed="true"] {
  background: var(--shb-accent);
  color: var(--shb-bg);
  border-color: var(--shb-accent);
}

/* --- The seahorse itself ------------------------------------------------- */
.shb-horse {
  pointer-events: auto;
  width: 120px;
  margin-left: auto;         /* keep it aligned to the right edge */
  cursor: grab;
  color: var(--shb-accent);  /* SVG strokes use currentColor */
  filter: drop-shadow(0 4px 6px var(--shadow-color, rgba(33, 29, 24, 0.14)));
  touch-action: none;
  animation: shb-bob 3.6s ease-in-out infinite;
  transform-origin: 50% 90%;
}
.shb-horse:active { cursor: grabbing; }
.shb-horse svg { display: block; width: 100%; height: auto; overflow: visible; }
.shb-horse .shb-fin {
  transform-origin: 42px 78px;
  animation: shb-fin 1.1s ease-in-out infinite;
}

/* Wave animation triggered on greeting. */
.shb-horse.shb-wave { animation: shb-wave 0.9s ease-in-out 2; }

@keyframes shb-bob {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50%      { transform: translateY(-8px) rotate(-2deg); }
}
@keyframes shb-fin {
  0%, 100% { transform: rotate(0deg); }
  50%      { transform: rotate(14deg); }
}
@keyframes shb-wave {
  0%, 100% { transform: rotate(0deg); }
  25%      { transform: rotate(-7deg); }
  75%      { transform: rotate(7deg); }
}

/* --- "Bring back the seahorse" recall tab (shown after dismissal) -------- */
.shb-recall {
  position: fixed;
  right: 0;
  bottom: 24px;
  z-index: 2147483000;
  pointer-events: auto;
  padding: 6px 10px 6px 12px;
  font-family: var(--font-mono, monospace);
  font-size: 0.72rem;
  color: var(--bg, #faf6f0);
  background: var(--accent, #e0503a);
  border: none;
  border-radius: 12px 0 0 12px;
  cursor: pointer;
  box-shadow: var(--shadow-hover, 0 6px 16px rgba(33, 29, 24, 0.14));
  opacity: 0.85;
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.shb-recall:hover { opacity: 1; transform: translateX(-2px); }
.shb-recall:focus-visible { outline: 2px solid var(--text, #211d18); outline-offset: 2px; }

/* --- Accessibility: honour reduced-motion by killing all animation ------- */
@media (prefers-reduced-motion: reduce) {
  .shb-horse,
  .shb-horse .shb-fin,
  .shb-horse.shb-wave { animation: none !important; }
  .shb-bubble { transition: none; }
}

/* Small screens: shrink so the buddy never covers content on mobile. */
@media (max-width: 480px) {
  .shb { width: 160px; right: 12px; bottom: 12px; }
  .shb-horse { width: 96px; }
  .shb-bubble { font-size: 0.82rem; }
}
