/* Blink's spoken words use comic lettering; the caption keeps the conversation controls. */
@font-face {
  font-family: 'Blink Comic';
  src: url('assets/fonts/ComicNeue-BoldItalic.ttf') format('truetype');
  font-style: italic;
  font-weight: 700;
  font-display: swap;
}

.immersive .blink-balloon {
  --blink-ink: #121716;
  --blink-stock: #fff2d4;
  position: fixed;
  z-index: 249;
  top: 190px;
  right: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(350px, calc(100vw - 28px));
  max-height: var(--blink-balloon-max-height, 280px);
  padding: 24px 30px 25px;
  color: var(--blink-ink);
  isolation: isolate;
  pointer-events: none;
  --scrollbar-thumb: #81704e;
  --scrollbar-track: #f0dfba;
}
.immersive .balloon-shape {
  position: absolute;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  overflow: visible;
  fill: var(--blink-stock);
  stroke: var(--blink-ink);
  stroke-width: 4.3px;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}
.immersive .balloon-shape path { vector-effect: non-scaling-stroke; }
.immersive .blink-balloon .reply {
  flex: 1 1 auto;
  min-height: 0;
  max-height: calc(var(--blink-balloon-max-height, 280px) - 49px);
  margin: 0;
  padding: 1px 3px 2px;
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-y pinch-zoom;
  pointer-events: auto;
  color: var(--blink-ink);
  font-family: 'Blink Comic', 'Comic Sans MS', 'Chalkboard SE', cursive;
  font-size: var(--blink-font-size, 21px);
  font-style: italic;
  font-weight: 700;
  font-synthesis: none;
  -webkit-text-stroke: .2px currentColor;
  line-height: 1.17;
  letter-spacing: .1px;
  text-transform: uppercase;
  text-align: center;
  text-wrap: pretty;
  overflow-wrap: break-word;
}
.immersive .blink-balloon .reply:focus-visible { outline: 2px dashed var(--blink-ink); outline-offset: 2px; }
.immersive .blink[aria-expanded='true'] .object-tag { opacity: 0; }

.immersive .speech {
  top: calc(max(12px, env(safe-area-inset-top)) + var(--blink-viewport-top, 0px));
  right: calc(max(12px, env(safe-area-inset-right)) + var(--blink-viewport-right, 0px));
  width: min(340px, calc(var(--blink-viewport-width, 100vw) - 24px));
  max-height: min(270px, calc(var(--blink-viewport-height, 100dvh) - 110px));
  padding: 6px 11px 8px;
  touch-action: pan-y pinch-zoom;
}
.immersive .speech .panel-top { position: sticky; top: -6px; z-index: 2; min-height: 32px; margin-bottom: 4px; background: var(--paper-light); }
.immersive .speech .speaker { font-size: 10px; letter-spacing: .7px; white-space: nowrap; }
.immersive .conversation-actions { display: flex; align-items: center; gap: 3px; }
.immersive .history-toggle { min-height: 36px; padding: 7px 9px; font-size: 11px; --paper-inset-y: 4px; cursor: pointer; }
.immersive .history-toggle[aria-expanded='true'] { color: #244d41; font-weight: 700; }
.immersive .speech .close-button { flex: 0 0 36px; width: 36px; height: 36px; }
.immersive .speech .suggestions { gap: 3px; margin-bottom: 5px; }
.immersive .speech .suggestions button { min-height: 32px; padding: 5px 6px; }
.immersive .speech .last-message { max-height: 2.8em; margin: 2px 0 5px; font-size: 11px; }
.immersive .speech:has(.conversation-history:not([hidden])) .last-message { display: none; }
.immersive .conversation-history {
  max-height: min(125px, 20dvh);
  margin: 2px 0 8px;
  padding: 0 3px 3px;
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-y pinch-zoom;
  list-style: none;
  color: var(--ink);
  font: 13px/1.4 var(--comic-lettering);
  overflow-wrap: anywhere;
}
.immersive .conversation-history li { margin: 0; padding: 6px 2px; }
.immersive .conversation-history li + li { background: var(--comic-ink-rule) left top / 100% 2px no-repeat; }
.immersive .conversation-history strong { color: #704d2a; }
.immersive .conversation-history:focus-visible { outline: 2px dashed var(--ink); outline-offset: -2px; }
.immersive .speech[data-compact-viewport='true'] { max-height: min(180px, calc(var(--blink-viewport-height, 100dvh) - 100px)); }
.immersive .speech[data-compact-viewport='true'] :is(.suggestions, .last-message) { display: none; }

/* Network feedback stays in the caption. An outage never becomes a line of
   invented dialogue, and busy controls keep their normal footprint. */
.immersive .speech .chat-feedback { display: flex; align-items: center; gap: 4px; min-height: 36px; margin-top: 2px; }
.immersive .speech .chat-feedback .chat-status { flex: 1 1 auto; min-width: 0; margin: 0; font-size: 12px; line-height: 1.3; overflow-wrap: anywhere; }
.immersive .speech .chat-status[data-kind='error'] { color: var(--ink); font-weight: 700; }
.immersive .speech .chat-secondary { flex: 0 0 auto; min-height: 36px; padding: 6px 9px; font-size: 12px; --paper-inset-y: 3px; }
.immersive .speech .chat-offer { min-height: 36px; max-width: 100%; padding: 7px 10px; font-size: 12px; text-align: left; --paper-inset-y: 3px; }
.immersive .speech .fineprint { margin-top: 4px; font-size: 11px; line-height: 1.3; }
.immersive .speech input[aria-invalid='true'] { outline: 2px dashed var(--ink); outline-offset: -3px; }

/* Immediate real-world support is full-size, plain text at the top. It is
   allowed more room than an ordinary speech balloon and always scrolls. */
.immersive .speech[data-reply-mode='urgent_support'] {
  width: min(420px, calc(var(--blink-viewport-width, 100vw) - 24px));
  max-height: calc(var(--blink-viewport-height, 100dvh) - 28px);
}
.immersive .speech[data-reply-mode='urgent_support'] :is(.suggestions, .last-message) { display: none; }
.immersive .urgent-support { margin: 3px 0 9px; padding: 4px 2px 10px; background: var(--comic-ink-rule) left bottom / 100% 2px no-repeat; }
.immersive .urgent-support p { margin: 0; color: var(--ink); font: 18px/1.45 var(--comic-lettering); text-transform: none; white-space: pre-wrap; overflow-wrap: anywhere; }

@media (max-width: 700px) {
  .immersive .speech {
    top: calc(max(9px, env(safe-area-inset-top)) + var(--blink-viewport-top, 0px));
    right: calc(max(10px, env(safe-area-inset-right)) + var(--blink-viewport-right, 0px));
    width: min(340px, calc(var(--blink-viewport-width, 100vw) - 20px));
    padding: 5px 9px 7px;
  }
  .immersive .blink-balloon { width: min(340px, calc(100vw - 28px)); padding: 20px 26px 21px; }
  .immersive .blink-balloon .reply { font-size: var(--blink-font-size, 20px); max-height: calc(var(--blink-balloon-max-height, 280px) - 41px); }
  .immersive .speech[data-reply-mode='urgent_support'] { width: min(420px, calc(var(--blink-viewport-width, 100vw) - 20px)); }
}
@media (forced-colors: active) {
  .immersive .blink-balloon { --blink-stock: Canvas; --blink-ink: CanvasText; }
  .immersive .history-toggle[aria-expanded='true'] { color: Highlight; }
}
