/* Delirium bubbles (bubbles.js): translucent circles in the frog's colors, saying the content is toxic to whoever takes it.
   Layers never take a tap, and only transform and opacity animate. */
/* The blend sits on the layer: each layer is its own stacking context, so a bubble's blend would only see the layer. */
.bubble-layer { position: absolute; inset: 0; pointer-events: none; mix-blend-mode: screen; }
/* After .hero-media in the hero's stacking order: over the footage, under the copy. */
.bubble-layer--hero, .bubble-layer--field { z-index: -1; }
.bubble-layer--flood { position: fixed; z-index: 4; overflow: hidden; transition: opacity 0.35s ease; }
.bubble-layer--page { position: fixed; z-index: 4; overflow: hidden; }
.bubble-layer--flood.is-leaving { opacity: 0; }
.bubble-layer--flood.is-paused .bubble { animation-play-state: paused; }
.ruling, #enforce .stage-orb { position: relative; }
[data-bubble-field] { position: relative; isolation: isolate; overflow: clip; }

/* The pre-redesign treatment: a faint ring, a hollow core, a soft glint and glow, a slightly uneven outline and
   a low peak opacity, so they read as queasy film over the page rather than as cartoon balls. bubbles.js sets
   --r, --h, --b and --peak per bubble. */
.bubble {
  position: absolute; width: var(--s); height: var(--s);
  margin: calc(var(--s) / -2) 0 0 calc(var(--s) / -2);
  border: 1px solid rgba(var(--c), 0.5); border-radius: var(--r, 50%); /* taste-skill-ignore: the thin ring that makes it a bubble */
  background: radial-gradient(circle at 34% 28%, rgba(var(--g), 0.5) 0%, transparent 22%, rgba(var(--c), 0.13) 48%, transparent 72%);
  box-shadow: 0 0 var(--h, 8px) rgba(var(--c), 0.2), inset 0 0 calc(var(--h, 8px) * 0.55) rgba(var(--c), 0.13);
  filter: blur(var(--b, 0px));
  opacity: calc(var(--peak, 0.22) * var(--boost, 1));
}
.bubble--blue { --c: 46, 134, 222; --g: 220, 238, 255; }
.bubble--yellow { --c: 245, 208, 0; --g: 255, 249, 190; }
.bubble--red { --c: 232, 67, 32; --g: 255, 220, 212; }
.bubble--lavender { --c: 123, 143, 200; --g: 231, 235, 255; }
/* A tap on the frog and the Enforce puff answer the reader, so they need to show over the footage. */
.bubble-layer--hero, .bubble-layer--orb, .bubble-layer--page { --boost: 2.2; }

/* A bubble without --t (reduced motion) computes to no animation at all. */
.bubble-layer--hero .bubble, .bubble-layer--orb .bubble, .bubble-layer--flood .bubble, .bubble-layer--page .bubble { animation: bubble-rise var(--t) ease-out var(--d) both; }
.bubble-layer--quote .bubble, .bubble-layer--field .bubble { animation: bubble-wander var(--t) ease-in-out var(--d) infinite alternate; }
.bubble-layer--quote.is-popping .bubble { animation: bubble-pop 0.45s ease-out both; }
.bubble-layer--quote.is-popping .bubble:nth-child(odd) { animation-delay: 0.12s; }
.bubble-layer--quote.is-popping .bubble:nth-child(3n) { animation-delay: 0.22s; }

@keyframes bubble-rise {
  from { transform: translate(0, 0) scale(0.5); opacity: 0; }
  15%, 75% { opacity: calc(var(--peak, 0.22) * var(--boost, 1)); }
  to { transform: translate(var(--dx), var(--dy)) scale(1); opacity: 0; }
}
@keyframes bubble-wander { to { transform: translate(var(--dx), var(--dy)); } }
@keyframes bubble-pop { to { transform: translate(calc(var(--dx) * 3), calc(var(--dy) * 3 - 24px)) scale(1.7); opacity: 0; } }

/* ---------- frog caption: pinned to the footage once the hero stacks ---------- */
.frog-caption { color: var(--ink); }
@media (max-width: 760px), (max-width: 1100px) and (orientation: portrait) {
  .frog-caption {
    position: absolute; left: calc(var(--gutter) - 8px); bottom: calc(100% - max(62vw, 230px) + 10px);
    max-width: min(36ch, 100% - var(--gutter) - 60px);
    padding: 4px 8px; border-radius: 4px;
    background: rgba(13, 17, 23, 0.72);
    font-size: 0.8125rem; line-height: 1.4;
  }
  /* bubbles.js hides the caption here until the first tap on the frog, then fades it in with the bubbles. */
  .frog-caption-tap .frog-caption { opacity: 0; visibility: hidden; transition: opacity 0.35s ease, visibility 0s 0.35s; }
  .frog-caption-tap .frog-caption.is-open { opacity: 1; visibility: visible; transition: opacity 0.35s ease; }
}

/* ---------- view as AI ---------- */
.ai-view-toggle {
  padding: 0; border: 0; background: none; color: var(--ink-muted); cursor: pointer;
  font: 600 1rem/1.5 var(--font-text);
  text-decoration: underline; text-decoration-color: rgba(139, 148, 158, 0.5);
  text-decoration-thickness: 2px; text-underline-offset: 0.22em;
}
.ai-view-toggle::before {
  content: ""; display: inline-block; width: 9px; height: 9px; margin-right: 9px;
  border: 1.5px solid currentColor; border-radius: 50%; vertical-align: 0.05em;
}
.ai-view-toggle:hover { color: var(--ink); text-decoration-color: currentColor; }
.ai-view-toggle[aria-pressed="true"] { color: var(--ink); }
.ai-view-toggle[aria-pressed="true"]::before { border-color: var(--vermillion); background: var(--vermillion); }
.ai-view-toggle--quote { margin-top: 14px; font-size: 0.875rem; }
@media (pointer: coarse) and (max-width: 760px) { .ai-view-toggle { min-height: 44px; } }
/* Beside the stacked layout the switches hang outside the flow: the hero keeps the height its footage is
   framed for, and the hero switch sits under the button, clear of the frog. */
@media (min-width: 761px) {
  .hero-actions { position: relative; }
  .hero-actions .ai-view-toggle { position: absolute; top: 100%; left: 0; margin-top: 10px; }
  .ai-view-toggle--quote { position: absolute; }
}

.ai-view-pill {
  position: fixed; left: 16px; bottom: 16px; z-index: 6; max-width: calc(100% - 32px);
  padding: 10px 16px;
  border: 1.5px solid var(--vermillion); border-radius: 22px;
  background: var(--frog-black); color: var(--ink); cursor: pointer;
  font: 500 0.8125rem/1.4 var(--font-text); text-align: left;
}
.ai-view-pill strong { font-weight: 700; white-space: nowrap; text-decoration: underline; text-underline-offset: 0.2em; }
/* Beside the stacked layout the hero foot runs along the bottom left, so the pill sits right of it, over the
   caption and clear of the video toggle. */
@media (min-width: 761px) {
  .ai-view-pill { left: auto; right: calc(var(--gutter) + 56px); bottom: 24px; max-width: 24rem; padding: 12px 18px; font-size: 0.875rem; }
}
/* Keyboard focus stops above the pill. */
html.is-ai-view { scroll-padding-bottom: 110px; }
.is-ai-view .hero-video { filter: saturate(2.6) contrast(1.25) brightness(1.08); }

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