/* ============================================================
   Mascot info blocks
   See docs/superpowers/specs/2026-05-16-mascot-scroll-info-boxes-design.md
   ============================================================ */

/* ──────────── Desktop: speech bubble inside the mascot rail ──────────── */

.jacar-mb-bubble {
  position: absolute;
  /* Sit directly under the mascot in the gutter. The mascot is at
     left:clamp(0.5rem,1.5vw,1.5rem) with width clamp(110px,12vw,160px)
     and aspect ratio 240:180 — so its height is 0.75× its width.
     Bubble's left matches mascot's left; top sits one mascot-height +
     12px gap below. Width may overflow into content on narrow viewports
     (handled by the same @media (max-width:880px) hide rule). */
  left: clamp(0.5rem, 1.5vw, 1.5rem);
  /* Gap between mascot bottom and bubble top = ~30px so the speech-bubble
     tail (16px tall) has clear space and isn't visually swallowed by the
     mascot's shadow ellipse below the laptop keyboard. */
  top: calc(clamp(110px, 12vw, 160px) * 0.75 + 30px);
  width: clamp(280px, 22vw, 360px);
  /* overflow lives on .jacar-mb-bubble__stack now — keep this box visible
     so the speech-bubble tail (::before at top:-18px) isn't clipped. */
  overflow: visible;
  /* Bubble outer is fully transparent — page content behind shows
     through clearly. Only the border + offset shadow + the active
     block's own fill keep the bubble visually anchored. */
  background: transparent;
  /* Comic-style outline: thick ink-line border + hard offset "panel" shadow
     in a darker brand tone, plus a soft secondary shadow for depth. */
  border: 2.5px solid var(--brand-teal);
  border-radius: 16px;
  box-shadow:
    4px 4px 0 var(--brand-teal-dk),
    0 8px 20px rgba(0, 0, 0, 0.08);
  font-size: 0.9rem;
  line-height: 1.45;
  pointer-events: auto;
  z-index: 50;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 240ms var(--ease-out), transform 240ms var(--ease-out);
}

.jacar-mb-bubble.is-revealed {
  opacity: 1;
  transform: translateY(0);
}

/* Comic speech-bubble tail — solid teal triangle pointing UP at the
   mascot. Solid (not outlined) so it reads cleanly against both light
   and dark page backgrounds. Horizontally aligned with the mascot's
   keyboard/eye center: mascot is at left:1.5rem with width clamp(110..160),
   so its center sits at ~80px (rendered-width-half) right of the rail
   left edge — bubble.left matches mascot.left, so we offset tail.left
   to align with that mid-point. */
.jacar-mb-bubble::before {
  content: '';
  position: absolute;
  top: -16px;
  /* Center tail apex roughly under the mascot's keyboard center.
     With mascot width clamp(110,12vw,160), half-width is 55-80px. */
  left: clamp(43px, 6vw, 68px);
  width: 0;
  height: 0;
  border-left:   14px solid transparent;
  border-right:  14px solid transparent;
  border-bottom: 16px solid var(--brand-teal);
  border-top: 0;
  filter: drop-shadow(3px 3px 0 var(--brand-teal-dk));
}

.jacar-mb-bubble__stack {
  list-style: none;
  padding: 0;
  margin: 0;
  /* Overflow lives here — bubble itself stays visible so the tail isn't
     clipped. Max-height fits viewport minus header + mascot + tail-gap. */
  overflow: auto;
  max-height: calc(100vh - clamp(72px, 9vh, 88px) - clamp(110px, 12vw, 160px) * 0.75 - 46px);
  /* Inner background — sits on top of the bubble's translucent backdrop
     so bullet text stays readable even with the see-through outer. */
  border-radius: 13px;
}

.jacar-mb-block + .jacar-mb-block {
  border-top: 1px solid color-mix(in srgb, var(--brand-teal) 30%, transparent);
}

.jacar-mb-block__head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  background: transparent;
  border: 0;
  cursor: pointer;
  color: var(--color-text-body);
  font: inherit;
  text-align: left;
}
.jacar-mb-block__title {
  font-weight: 700;
  letter-spacing: 0.01em;
}
/* Active block title gets a small comic-style accent: a thicker teal
   underline that runs under the title text only (not the chevron). */
.jacar-mb-block.is-active .jacar-mb-block__title {
  color: var(--brand-teal);
}
.jacar-mb-block__chevron {
  transition: transform 200ms var(--ease-out);
  opacity: 0.6;
}
.jacar-mb-block.is-active .jacar-mb-block__chevron {
  transform: rotate(90deg);
  opacity: 1;
}

.jacar-mb-block__body {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 220ms var(--ease-out),
              opacity 140ms var(--ease-out);
  padding: 0 14px;
  /* Only the EXPANDED body gets a fill — keeps bullets/links readable
     on top of whatever the user is reading underneath. Collapsed chips
     stay fully transparent against the page. --color-bg-elevated
     differentiates from page bg so the body reads as a distinct
     card (slightly lighter in dark mode, slightly cooler in light). */
  background: color-mix(in srgb, var(--color-bg-elevated) 95%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.jacar-mb-block.is-active .jacar-mb-block__body {
  max-height: 60vh;
  opacity: 1;
  padding: 0 14px 12px;
}

.jacar-mb__bullets,
.jacar-mb__links,
.jacar-mb__related {
  margin: 0;
  padding-left: 1.2rem;
}
.jacar-mb__bullets li,
.jacar-mb__links li { margin-bottom: 6px; }

.jacar-mb__related {
  list-style: none;
  padding-left: 0;
}
.jacar-mb__related a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}
.jacar-mb__related img {
  width: 56px; height: 56px; object-fit: cover; border-radius: 8px;
  flex-shrink: 0;
}

.jacar-mb-bubble__dismiss {
  position: absolute;
  right: 8px;
  bottom: 6px;
  width: 26px; height: 26px;
  background: transparent;
  border: 0;
  font-size: 14px;
  color: color-mix(in srgb, var(--color-text-body) 50%, transparent);
  cursor: pointer;
  border-radius: 50%;
}
.jacar-mb-bubble__dismiss:hover {
  background: color-mix(in srgb, var(--brand-teal) 12%, transparent);
  color: var(--color-text-body);
}

/* Hide bubble when mascot is hidden (existing rule: <=880px) or user
   has dismissed (JS sets `.jacar-mb-dismissed` on body). */
@media (max-width: 880px) {
  .jacar-mb-bubble { display: none; }
}
body.jacar-mb-dismissed .jacar-mb-bubble { display: none; }

/* ──────────── Mobile: inline accordion ──────────── */

.jacar-mb-accordion {
  display: none;
  margin: 18px 0;
  padding: 14px;
  background: var(--color-bg-elevated);
  border-left: 3px solid var(--brand-teal);
  border-radius: 8px;
}
.jacar-mb-accordion__title {
  font-size: 1rem;
  margin: 0 0 10px;
  color: var(--brand-teal-dk, var(--brand-teal));
}
.jacar-mb-accordion__item {
  border-top: 1px solid color-mix(in srgb, var(--brand-teal) 24%, transparent);
}
.jacar-mb-accordion__item:first-of-type { border-top: 0; }
.jacar-mb-accordion__item summary {
  padding: 10px 0;
  cursor: pointer;
  font-weight: 600;
  list-style: none;
}
.jacar-mb-accordion__item summary::-webkit-details-marker { display: none; }
.jacar-mb-accordion__item[open] summary::after { content: ' ▼'; }
.jacar-mb-accordion__item:not([open]) summary::after { content: ' ▶'; opacity: 0.5; }
.jacar-mb-accordion__body { padding-bottom: 10px; font-size: 0.95rem; }

@media (max-width: 880px) {
  .jacar-mb-accordion { display: block; }
}

/* ──────────── Reduced motion ──────────── */

@media (prefers-reduced-motion: reduce) {
  .jacar-mb-block__body,
  .jacar-mb-block__chevron,
  .jacar-mb-bubble { transition: none !important; }
}

/* ──────────── Mascot pulse on block switch ──────────── */

/* Mascot pulse — applied for 600ms when active block switches.
   Re-uses the existing .cp-hero__mascot__eye blink keyframe and adds
   a brief LED brightness boost on the antenna. */
.jacar-mb-pulse .cp-hero__mascot__eye {
  animation: cp-mascot-blink 320ms var(--ease-in-out);
}
.jacar-mb-pulse .cp-hero__mascot__body > g > circle[fill="var(--brand-lime)"] {
  /* the antenna LED is the topmost lime circle in the SVG */
  filter: drop-shadow(0 0 6px var(--brand-lime));
  animation: jacar-mb-led 400ms var(--ease-out);
}
@keyframes jacar-mb-led {
  0%   { filter: drop-shadow(0 0 0  var(--brand-lime)); }
  40%  { filter: drop-shadow(0 0 8px var(--brand-lime)); }
  100% { filter: drop-shadow(0 0 0  var(--brand-lime)); }
}

@media (prefers-reduced-motion: reduce) {
  .jacar-mb-pulse,
  .jacar-mb-pulse .cp-hero__mascot__eye,
  .jacar-mb-pulse .cp-hero__mascot__body > g > circle {
    animation: none !important;
    filter: none !important;
  }
}
