/* ИИ-помощник справки (src/components/ask.mjs, /static/ask.js): кнопка «Спросить» и окно, как у GitBook
   (faq.wanttopay.net), в стиле справки сайта (help.css): плоско, без свечений, градиентов и теней.
   Окно - лист снизу на телефоне и панель справа с 768 px. Темная тема окна - по теме системы
   (страницы справки всегда белые, кнопка на них светлая). Движение - только transform и opacity. */

/* ---------- кнопка «Спросить» ---------- */
.ask-open {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px 0 11px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 560;
  line-height: 1;
  letter-spacing: -.01em;
  white-space: nowrap;
  text-decoration: none;
  color: inherit;
  /* кромка - тенью: место кнопки не меняется */
  box-shadow: inset 0 0 0 1px color-mix(in srgb, currentColor 15%, transparent);
  -webkit-tap-highlight-color: transparent;
  transition: background-color .2s var(--ease), transform .35s var(--ease);
}
.ask-open:active { transform: scale(.96); }
@media (hover: hover) { .ask-open:hover { background-color: color-mix(in srgb, currentColor 5%, transparent); } }
.ask-open-ico { flex: none; width: 17px; height: 17px; color: #0088ff; }
/* С 1024 px кнопка с подписью стоит в шапке перед «Открыть» (как у GitBook). Ниже подпись в шапке не влезает:
   кнопка с подписью справа в строке пути над статьей (help.css .docs-bar), а в шапке значок 34 x 34 без подписи
   (имя для читалок из aria-label). Значок появляется, когда строка пути ушла под шапку (класс html.ask-hdr ставит
   ask.js): наверху страницы кнопка одна, а дочитав длинную статью, спросить можно, не прокручивая наверх */
@media (max-width: 1023.98px) {
  .ask-open.is-hdr {
    position: relative;
    justify-content: center;
    width: 34px;
    padding: 0;
    visibility: hidden;
    opacity: 0;
    transform: scale(.8);
    transition: opacity .2s var(--ease), transform .35s var(--ease), visibility 0s .35s;
  }
  .ask-open.is-hdr > span { display: none; }
  /* под палец 44 x 44, на вид кнопка прежняя */
  .ask-open.is-hdr::after { content: ""; position: absolute; inset: -5px; }
  html.ask-hdr .ask-open.is-hdr { visibility: visible; opacity: 1; transform: none; transition: opacity .2s var(--ease), transform .35s var(--ease), background-color .2s var(--ease); }
  html.ask-hdr .ask-open.is-hdr:active { transform: scale(.92); }
}
/* на экране меньше 350 px значок рядом с логотипом и «Открыть» не влезает: остается кнопка в строке пути */
@media (max-width: 349.98px) { .ask-open.is-hdr { display: none; } }
@media (min-width: 1024px) { .ask-open.is-top { display: none; } }

/* ---------- окно ---------- */
/* под окном страница не прокручивается; вместо полосы прокрутки - отступ той же ширины (ask.js, --ask-sb),
   страница не сдвигается, а затемнение закрывает экран целиком */
html.ask-lock { overflow: hidden; padding-right: var(--ask-sb, 0px); }

.ask {
  --ask-bg: #fff;
  --ask-fg: #1d1d1f;
  --ask-fg2: #6e6e73;
  --ask-fg3: #8e8e93;
  --ask-line: #e5e5ea;
  --ask-fill: #f2f2f7;
  /* синий справки мини-аппа, как у ссылок справки сайта */
  --ask-link: #0088ff;
  --ask-warn: #ff9500;
  --ask-scrim: rgb(0 0 0 / .32);
  position: fixed;
  inset: 0;
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  overflow: hidden;
  overscroll-behavior: contain;
  background: transparent;
  color: var(--ask-fg);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: -.012em;
  color-scheme: light;
}
.ask::backdrop { background: transparent; }
@media (prefers-color-scheme: dark) {
  .ask {
    --ask-bg: #1c1c1e;
    --ask-fg: #f5f5f7;
    --ask-fg2: #aeaeb2;
    --ask-fg3: #8e8e93;
    --ask-line: #38383a;
    --ask-fill: #2c2c2e;
    --ask-link: #0a84ff;
    --ask-warn: #ff9f0a;
    --ask-scrim: rgb(0 0 0 / .56);
    color-scheme: dark;
  }
}
/* телефон: окно по видимой части экрана (над клавиатурой), размеры ставит ask.js по visualViewport */
.ask.is-vv { top: var(--ask-vt, 0px); bottom: auto; height: var(--ask-vh, 100%); }

/* затемнение: нажатие мимо листа закрывает окно */
.ask-scrim {
  position: absolute;
  inset: 0;
  background: var(--ask-scrim);
  opacity: 0;
  touch-action: none;
  transition: opacity .32s var(--ease);
}
.ask.is-open .ask-scrim { opacity: 1; }
.ask.is-closing .ask-scrim { transition-duration: .3s; }

/* лист: снизу во всю ширину; до скрипта скругление обычное, скрипт делает суперэллипс (clip-path) */
.ask-box {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  border-radius: 20px 20px 0 0;
  background: var(--ask-bg);
  transform: translate3d(0, 100%, 0);
  transition: transform .5s var(--ease);
}
.ask.is-open .ask-box { transform: none; }
.ask.is-closing .ask-box { transition-duration: .36s; transition-timing-function: var(--ease-io); }
/* с 768 px - панель справа во всю высоту, как у GitBook */
@media (min-width: 768px) {
  .ask-box {
    top: 12px;
    right: 12px;
    bottom: 12px;
    left: auto;
    width: min(420px, calc(100vw - 24px));
    border-radius: 20px;
    transform: translate3d(calc(100% + 24px), 0, 0);
  }
}

/* ---------- шапка окна ---------- */
.ask-head {
  position: relative;
  z-index: 1;
  flex: none;
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 56px;
  padding: 10px 12px 10px 20px;
  touch-action: none;
  transition: box-shadow .2s;
}
/* линия под шапкой - когда лента прокручена */
.ask-box.is-scrolled .ask-head { box-shadow: 0 1px 0 var(--ask-line); }
.ask-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; margin: 0; font-size: 17px; line-height: 1.3; font-weight: 600; letter-spacing: -.015em; }
.ask-title-ico { flex: none; width: 20px; height: 20px; color: var(--ask-link); }
.ask-clear {
  flex: none;
  height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ask-link);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.ask-x {
  flex: none;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--ask-fill);
  color: var(--ask-fg2);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform .35s var(--ease);
}
.ask-x:active { transform: scale(.92); }
.ask-x-ico { width: 13px; height: 13px; }

/* ---------- лента ---------- */
.ask-feed {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 2px 20px 20px;
}
.ask-hello-t { margin: 10px 0 6px; font-size: 26px; line-height: 1.15; font-weight: 600; letter-spacing: -.025em; }
.ask-hello-p { margin: 0; font-size: 16px; line-height: 1.5; color: var(--ask-fg2); text-wrap: pretty; }
/* подписи разделов (как разделы меню справки): «Например», «Статьи» */
.ask-cap { margin: 24px 0 4px; font-size: 12px; line-height: 1.3; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ask-fg3); }
.ask-sug { margin: 0; padding: 0; list-style: none; }
.ask-sug li + li { border-top: 1px solid var(--ask-line); }
.ask-sug button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 12px 0;
  border: 0;
  background: transparent;
  color: var(--ask-fg);
  font-size: 16px;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color .2s;
}
@media (hover: hover) { .ask-sug button:hover { color: var(--ask-link); } }
.ask-sug .ask-chev { color: var(--ask-fg3); }
/* шеврон ссылок - как у ссылок справки (help.css .d-link-chev) */
.ask-chev { flex: none; width: 7.9px; height: 11px; }

/* вопрос - пузырь справа, ответ - текстом во всю ширину, как у GitBook */
.ask-q {
  --sq-r: 18px;
  width: fit-content;
  max-width: 85%;
  margin: 20px 0 0 auto;
  padding: 9px 14px;
  border-radius: 18px;
  background: var(--ask-fill);
  font-size: 16px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.ask-a { margin: 14px 0 0; font-size: 16px; line-height: 1.55; overflow-wrap: anywhere; }
.ask-a p { margin: 0 0 10px; text-wrap: pretty; }
.ask-a p:last-child { margin-bottom: 0; }
.ask-a b { font-weight: 600; }
.ask-arts { margin: 16px 0 0; }
.ask-arts .ask-cap { margin: 0; }
.ask-arts-l { display: grid; gap: 6px; margin: 6px 0 0; padding: 0; list-style: none; }
/* ссылка-действие как в справке: полужирная, синяя, с шевроном */
.ask-link { display: inline-flex; align-items: center; gap: 5px; font-size: 15px; line-height: 1.35; font-weight: 600; color: var(--ask-link); text-decoration: none; }
@media (hover: hover) { .ask-link:hover { text-decoration: underline; text-underline-offset: 3px; } }
.ask-sup { margin: 14px 0 0; }

/* ищу ответ: три точки и подпись с бликом */
.ask-wait { display: flex; align-items: center; gap: 10px; margin: 16px 0 0; font-size: 15px; color: var(--ask-fg3); }
.ask-dots { display: inline-flex; gap: 4px; }
.ask-dots i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .3; animation: ask-dot 1.2s var(--ease-io) infinite; }
.ask-dots i:nth-child(2) { animation-delay: .15s; }
.ask-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes ask-dot {
  0%, 70%, 100% { opacity: .3; transform: scale(.8); }
  35% { opacity: 1; transform: none; }
}
/* подпись «Ищу ответ» с бегущим бликом, как «Thinking» в ChatGPT */
.ask-wait > span:not(.ask-dots) {
  background: linear-gradient(90deg, var(--ask-fg3) 0%, var(--ask-fg3) 40%, var(--ask-fg) 50%, var(--ask-fg3) 60%, var(--ask-fg3) 100%) 0 0 / 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: ask-shine 1.8s linear infinite;
}
@keyframes ask-shine {
  from { background-position: 100% 0; }
  to { background-position: 0 0; }
}

/* ответ печатается потоком: слово проявляется из легкого размытия (ask.js, typeIn) */
.ask-w { opacity: 0; filter: blur(3px); transition: opacity .34s cubic-bezier(.2, .7, .2, 1), filter .34s cubic-bezier(.2, .7, .2, 1); }
.ask-w.on { opacity: 1; filter: none; }
/* статьи и поддержка - после текста */
.ask-rise { animation: ask-rise .42s cubic-bezier(.2, .7, .2, 1) both; }
.ask-rise + .ask-rise { animation-delay: .06s; }
@keyframes ask-rise {
  from { opacity: 0; transform: translateY(6px); }
}
@media (prefers-reduced-motion: reduce) {
  .ask-wait > span:not(.ask-dots) { animation: none; color: var(--ask-fg3); background: none; }
  .ask-w { opacity: 1; filter: none; transition: none; }
  .ask-rise { animation: none; }
}

/* ошибка, лимит, недоступно: подсказка как в справке (help.css .d-hint.is-warning) */
.ask-err {
  --sq-r: 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 16px 0 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--ask-warn) 12%, var(--ask-bg));
  font-size: 15px;
  line-height: 1.45;
}
.ask-err-ico { flex: none; width: 18px; height: 18px; margin-top: 2px; color: var(--ask-warn); }
.ask-err-x { min-width: 0; }
.ask-err-p { margin: 0; text-wrap: pretty; }
.ask-err .ask-link { margin-top: 6px; }

/* ---------- поле вопроса ---------- */
.ask-compose { position: relative; flex: none; padding: 8px 12px calc(10px + env(safe-area-inset-bottom, 0px)); }
.ask-field {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 5px 5px 5px 16px;
  border: 1px solid var(--ask-line);
  border-radius: 23px;
  background: var(--ask-bg);
  transition: border-color .2s;
}
.ask-field:focus-within { border-color: var(--ask-link); }
/* 16 px: iPhone не увеличивает страницу при вводе */
.ask-in {
  flex: 1;
  min-width: 0;
  height: 34px;
  max-height: 132px;
  margin: 0;
  padding: 6px 0;
  border: 0;
  outline: 0;
  resize: none;
  overflow-y: auto;
  background: transparent;
  color: var(--ask-fg);
  font: inherit;
  font-size: 16px;
  line-height: 22px;
  letter-spacing: -.012em;
}
.ask-in::placeholder { color: var(--ask-fg3); }
.ask-send {
  flex: none;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--ask-link);
  color: #fff;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color .2s, color .2s, transform .35s var(--ease);
}
.ask-send:active:not(:disabled) { transform: scale(.92); }
.ask-send:disabled { background: var(--ask-fill); color: var(--ask-fg3); cursor: default; }
.ask-send-ico { width: 17px; height: 17px; }
.ask-foot { margin: 8px 0 0; font-size: 12px; line-height: 1.4; text-align: center; color: var(--ask-fg3); }
.ask-foot a { color: var(--ask-link); text-decoration: none; }
@media (hover: hover) { .ask-foot a:hover { text-decoration: underline; text-underline-offset: 2px; } }
/* поле-ловушка: не видно ни глазу, ни экранной читалке (aria-hidden, inert), на месте не занимает */
.ask-hp { position: absolute; top: 0; left: 0; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); opacity: 0; pointer-events: none; }
