/*
 * Samay launcher: the floating mascot link on the landing and guide pages
 * (markup in templates/_samay_mascot.html). Loaded after landing.css and
 * reuses the Saffron Almanac tokens from theme-saffron.css.
 *
 * z-index 40 keeps it under the sticky nav (50). Any cookie or consent banner
 * added to these pages must sit at 50 or above so it covers the launcher.
 */

.samay-dock {
  position: fixed;
  right: max(16px, env(safe-area-inset-right, 0px));
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  /* The dock's box must not swallow taps between the tip and the launcher. */
  pointer-events: none;
}

.samay-dock > * {
  pointer-events: auto;
}

/* ── Launcher ────────────────────────────────────────────────────── */
.samay-launcher {
  display: block;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  box-shadow:
    0 10px 24px rgba(34, 26, 17, 0.26),
    0 2px 6px rgba(34, 26, 17, 0.18);
  -webkit-tap-highlight-color: transparent;
  transition:
    opacity 160ms ease,
    visibility 0s linear 0s,
    transform 160ms ease,
    box-shadow 160ms ease;
}

.samay-launcher:hover {
  transform: translateY(-2px);
  box-shadow:
    0 14px 30px rgba(34, 26, 17, 0.3),
    0 3px 8px rgba(34, 26, 17, 0.2);
}

/* Ivory gap + bronze ring: visible over the ivory page and the dark charts. */
.samay-launcher:focus-visible {
  outline: 3px solid var(--accent-bronze, #7a5a28);
  outline-offset: 3px;
  box-shadow:
    0 0 0 3px var(--surface-1, #fdfbf7),
    0 10px 24px rgba(34, 26, 17, 0.26);
}

.samay-art {
  display: block;
  width: 100%;
  height: 100%;
  animation: samay-float 5s ease-in-out infinite;
}

.samay-launcher:hover .samay-art,
.samay-launcher:focus-visible .samay-art {
  animation-play-state: paused;
}

.samay-eyes {
  transform-box: fill-box;
  transform-origin: center;
  animation: samay-blink 5.5s ease-in-out infinite;
}

.samay-spark {
  transform-box: fill-box;
  transform-origin: center;
  animation: samay-twinkle 3.2s ease-in-out infinite;
}

/* ── First-visit tip ─────────────────────────────────────────────── */
.samay-bubble {
  display: flex;
  align-items: center;
  gap: 2px;
  max-width: min(280px, calc(100vw - 32px));
  margin-right: 4px;
  padding: 4px 4px 4px 14px;
  background: var(--surface-1, #fdfbf7);
  border: 1px solid var(--gold-hairline, rgba(201, 162, 94, 0.45));
  /* Tight bottom-right corner points the tip at the launcher below it. */
  border-radius: 16px 16px 4px 16px;
  box-shadow:
    0 12px 28px rgba(34, 26, 17, 0.16),
    0 2px 6px rgba(34, 26, 17, 0.08);
  color: var(--text-primary, #221a11);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.3;
  transition:
    opacity 160ms ease,
    visibility 0s linear 0s;
  animation: samay-pop 240ms ease-out;
}

/* display:flex above would otherwise beat the [hidden] attribute. */
.samay-bubble[hidden] {
  display: none;
}

/* Matches the (0,2,1) of landing.css's `.lp a:not(.lp-btn)` and loads later. */
.samay-dock a.samay-bubble-link {
  padding: 8px 0;
  color: inherit;
  text-decoration: none;
}

.samay-bubble-close {
  flex: none;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-secondary, #5f5445);
  font: inherit;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}

.samay-bubble-close:hover {
  background: var(--surface-3, #f1eadd);
  color: var(--text-primary, #221a11);
}

.samay-bubble-close:focus-visible {
  outline: 2px solid var(--accent-bronze, #7a5a28);
  outline-offset: 1px;
}

/* ── CTA guard (set by samay-mascot.js) ──────────────────────────── */
/* Fade out while a CTA button is underneath, unless the keyboard is inside. */
.samay-dock--tucked:not(:focus-within) .samay-launcher,
.samay-dock--tucked:not(:focus-within) .samay-bubble,
.samay-bubble--tucked:not(:focus-within) {
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 160ms ease,
    visibility 0s linear 160ms;
}

/* Room under the last footer line so the launcher never rests on it. */
.lp-footer {
  padding-bottom: calc(100px + env(safe-area-inset-bottom, 0px));
}

@media (min-width: 900px) {
  .samay-dock {
    right: max(28px, env(safe-area-inset-right, 0px));
    bottom: calc(28px + env(safe-area-inset-bottom, 0px));
  }

  .samay-launcher {
    width: 64px;
    height: 64px;
  }
}

@media (max-width: 359px) {
  .samay-launcher {
    width: 56px;
    height: 56px;
  }
}

@keyframes samay-float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-4px);
  }
}

@keyframes samay-blink {
  0%,
  92%,
  100% {
    transform: scaleY(1);
  }
  95% {
    transform: scaleY(0.1);
  }
}

@keyframes samay-twinkle {
  0%,
  100% {
    opacity: 0.55;
    transform: scale(0.8);
  }
  50% {
    opacity: 1;
    transform: scale(1.1);
  }
}

@keyframes samay-pop {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .samay-art,
  .samay-eyes,
  .samay-spark,
  .samay-bubble {
    animation: none;
  }

  .samay-launcher,
  .samay-launcher:hover,
  .samay-bubble {
    transform: none;
    transition: none;
  }
}

@media print {
  .samay-dock {
    display: none;
  }
}
