/* Ask's button at the top right of every page, and the panel on the right it opens. SPDX-License-Identifier: Apache-2.0 */

@layer components {
  /* the button, beside Improve this; pressed while the panel is open */
  .btn.oa-ask-corner { z-index: 5; flex: none; box-shadow: var(--shadow); }
  .btn.oa-ask-corner[aria-pressed="true"] { --btn-bg: var(--accent-soft); --btn-ink: var(--accent); }
  .oa-ask-corner :is(.icon, .icon svg) { width: 15px; height: 15px; }
  .oa-ask-corner .icon { transform: translateY(-1px); }
  /* in a phone's top bar: as tall as the bar's other buttons, so the bar keeps its height, and the
     icon alone until there is room for the word */
  .btn.oa-ask-top { min-width: 44px; min-height: 40px; padding-inline: var(--space-4); box-shadow: none; }
  .oa-ask-top :is(.icon, .icon svg) { width: 16px; height: 16px; }
  .oa-ask-top .oa-ask-corner-words { display: none; }
  @media (min-width: 768px) {
    .btn.oa-ask-top { padding-inline: var(--space-7); }
    .oa-ask-top .oa-ask-corner-words { display: inline; }
  }

  /* The panel: on a phone it covers the page under the top bar. It never scrolls as a whole; what
     it holds lays itself out inside the body. */
  .oa-askpanel {
    --panel-pad-y: 0;
    --panel-pad-x: 0;
    position: fixed;
    z-index: 40;
    inset: 56px 0 0 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 0;
  }
  .oa-askpanel-head {
    display: flex;
    flex: none;
    align-items: center;
    gap: var(--space-5);
    padding: var(--space-5) var(--space-6) var(--space-5) var(--space-8);
    border-bottom: var(--hairline) solid var(--line);
    color: var(--ink);
  }
  .oa-askpanel-title { flex: 1 1 auto; min-width: 0; margin: 0; color: var(--ink); font-size: var(--text-base); font-weight: var(--weight-strong); }
  .oa-askpanel-tools { display: flex; flex: none; align-items: center; gap: var(--space-2); }
  .oa-askpanel-body { display: flex; flex: 1 1 auto; flex-direction: column; min-width: 0; min-height: 0; padding: var(--space-8); overflow: hidden; }

  /* the panel's left edge, dragged to resize it: only from 1024 px, where the page is beside it */
  .oa-askpanel-grip { display: none; }

  /* From 1024 px: under the top right's buttons to the window's foot, a little less than the right
     half of the window, and the page makes room for it. */
  @media (min-width: 1024px) {
    html[data-ask-panel] { --ask-panel-w: clamp(360px, 40vw, 760px); }
    .oa-askpanel { z-index: 12; inset: 68px var(--space-11) var(--page-foot) auto; width: var(--ask-panel-w); border-radius: var(--radius); }
    html[data-ask-panel] .frame-page { padding-right: calc(var(--ask-panel-w) + var(--space-11) + var(--space-8)); }
    .oa-askpanel-grip {
      display: block;
      position: absolute;
      z-index: 1;
      inset: 0 auto 0 0;
      width: var(--space-4);
      cursor: col-resize;
      touch-action: none;
      outline: none;
    }
    .oa-askpanel-grip::after {
      content: '';
      position: absolute;
      inset: 0 auto 0 0;
      width: 3px;
      background: var(--accent);
      opacity: 0;
    }
    .oa-askpanel-grip:is(:hover, :focus-visible)::after, html[data-ask-drag] .oa-askpanel-grip::after { opacity: 1; }
    /* while it is dragged nothing is selected and the pointer keeps its shape off the edge */
    html[data-ask-drag] { cursor: col-resize; user-select: none; }
  }
}
