/* Ask chat (engine.siteask.chat_tail, the SPEC of 29 November): the round button and its window.  Class prefix askc- only; colours
   from the component's own variables with the site's as fallbacks (FiveBar sets its own on #plchat); no percent sign
   and no decimal in this file (the house rule).  z: --askc-z (PitchLab 25: above the header 6, the sticky bars 1-6
   and the install bar 20; under the search sheet 30, the lifted menu panel 40 and the lightbox 100). */
/* the defaults at zero specificity (:where): a site's own #plchat { --askc-…: … } wins wherever it stands */
:where(#plchat) {
  --askc-accent: var(--green, var(--accent));
  --askc-on-accent: #04140A;
  --askc-panel: var(--panel);
  --askc-bubble: var(--panel-2, var(--panel));
  --askc-line: var(--line-2);
  --askc-text: var(--text);
  --askc-muted: var(--muted);
  --askc-link: var(--accent);
  --askc-bottom: 16px;
  --askc-lift: 0px;
  --askc-z: 25;
}
.askc-btn, .askc-win { position: fixed; z-index: var(--askc-z); }
#plchat.askc-under .askc-btn, #plchat.askc-under .askc-win { z-index: 5; }   /* a header dropdown is open */
.askc-btn {
  right: calc(16px + env(safe-area-inset-right, 0px));
  bottom: max(calc(var(--askc-bottom) + env(safe-area-inset-bottom, 0px)), calc(var(--askc-lift) + 12px));
  display: inline-grid; place-items: center; width: 56px; height: 56px; padding: 0; margin: 0;
  border: 0; border-radius: 999px; background: var(--askc-accent); color: var(--askc-on-accent);
  box-shadow: 0 8px 24px -8px #0000008C; cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: transform 160ms ease, bottom 200ms ease;
}
.askc-btn:hover { transform: translateY(-2px); }
.askc-btn:focus-visible { outline: 3px solid var(--focus, var(--askc-accent)); outline-offset: 3px; }
.askc-btn svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round;
  stroke-linejoin: round; }
#plchat.askc-open .askc-btn { visibility: hidden; }

.askc-win {
  display: flex; flex-direction: column; box-sizing: border-box; overflow: hidden;
  background: var(--askc-panel); color: var(--askc-text); border: 1px solid var(--askc-line);
  box-shadow: 0 24px 60px -20px #000000A6; font-size: 15px; line-height: 22px;
}
.askc-win[hidden] { display: none; }
.askc-win * { box-sizing: border-box; }
.askc-head { display: flex; align-items: center; gap: 8px; min-height: 56px; padding: 6px 6px 6px 16px;
  border-bottom: 1px solid var(--askc-line); flex: none; }
.askc-title { flex: 1 1 auto; min-width: 0; margin: 0; font-size: 17px; line-height: 24px; font-weight: 750;
  color: var(--askc-text); overflow-wrap: anywhere; }
.askc-x, .askc-send { display: inline-grid; place-items: center; flex: none; width: 44px; height: 44px; padding: 0;
  margin: 0; border: 0; border-radius: 999px; cursor: pointer; }
.askc-x { background: none; color: var(--askc-muted); }
.askc-x:hover { color: var(--askc-text); background: var(--hover-2, var(--askc-bubble)); }
.askc-x svg, .askc-send svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round; }
.askc-x:focus-visible, .askc-send:focus-visible, .askc-in:focus-visible, .askc-b a:focus-visible {
  outline: 2px solid var(--focus, var(--askc-accent)); outline-offset: 2px; }

.askc-log { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 14px 12px;
  display: flex; flex-direction: column; gap: 10px; }
.askc-m { display: flex; flex-direction: column; max-width: calc(100vw - 72px); }
.askc-q { align-self: flex-end; align-items: flex-end; }
.askc-a { align-self: flex-start; align-items: flex-start; }
.askc-b { padding: 9px 13px; border-radius: 16px; white-space: pre-line; overflow-wrap: anywhere; min-width: 0; }
.askc-q .askc-b { background: var(--askc-accent); color: var(--askc-on-accent); border-bottom-right-radius: 4px; }
.askc-a .askc-b { background: var(--askc-bubble); color: var(--askc-text); border: 1px solid var(--askc-line);
  border-bottom-left-radius: 4px; }
.askc-b a { color: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }
.askc-a .askc-b a { color: var(--askc-link); }
.askc-wait .askc-b { color: var(--askc-muted); font-style: italic; }
.askc-bad .askc-b { color: var(--askc-muted); }
.askc-t { margin: 3px 6px 0; font-size: 12px; line-height: 16px; color: var(--askc-muted); }

.askc-form { display: flex; align-items: flex-end; gap: 8px; padding: 10px 10px 4px 12px; flex: none;
  border-top: 1px solid var(--askc-line); }
.askc-in { flex: 1 1 auto; min-width: 0; min-height: 44px; max-height: 120px; margin: 0; padding: 10px 12px;
  font: inherit; font-size: 16px; line-height: 22px; color: var(--askc-text); background: var(--askc-bubble);
  border: 1px solid var(--askc-line); border-radius: 12px; resize: none; }
.askc-in::placeholder { color: var(--askc-muted); }
.askc-send { background: var(--askc-accent); color: var(--askc-on-accent); }
.askc-send[disabled] { cursor: progress; background: var(--askc-bubble); color: var(--askc-muted); }
.askc-note { margin: 0; padding: 4px 14px 10px; flex: none; font-size: 12px; line-height: 16px;
  color: var(--askc-muted); }

/* desktop: a window at the bottom right, 380 x 560, 16 px from the edges, above a bottom bar */
@media (min-width: 601px) {
  .askc-win { right: 16px;
    bottom: max(16px, calc(var(--askc-lift) + 12px));
    width: 380px; height: min(560px, calc(100vh - 32px - var(--askc-lift)));
    border-radius: 16px; }
  .askc-m { max-width: 300px; }
}
/* phone: the whole screen, inside the safe areas; the page under it does not scroll */
@media (max-width: 600px) {
  .askc-win { inset: 0; width: 100vw; height: 100vh; height: 100dvh; border: 0; border-radius: 0;
    padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px)
      env(safe-area-inset-left, 0px); }
  html.askc-lock, html.askc-lock body { overflow: hidden; overscroll-behavior: none; }
}
/* a free place when a tappable thing is under the button (askchat.js dodge, the PM, 2 December): higher by --askc-up,
   the left corner, a 44 px button; out of reach only when none is free */
#plchat .askc-btn { translate: 0 calc(0px - var(--askc-up, 0px)); }
#plchat.askc-left .askc-btn { right: auto; left: calc(16px + env(safe-area-inset-left, 0px)); }
#plchat.askc-small .askc-btn { width: 44px; height: 44px; }
#plchat.askc-small .askc-btn svg { width: 22px; height: 22px; }
#plchat.askc-dodge .askc-btn { transform: translateX(96px); visibility: hidden; pointer-events: none;
  transition: transform 160ms ease, visibility 0s linear 160ms; }
@media (prefers-reduced-motion: reduce) { .askc-btn { transition: none; } .askc-btn:hover { transform: none; } }
@media print { #plchat { display: none; } }
