/* Open beside (FORUM_OPEN_BESIDE_ENABLED, open_beside.js). */

/* The mode's toggle, at the window's right edge on the reading-margins ruler.
   The ruler is as wide as the normal column and centred, so half the
   difference from the window's width reaches the window's edge; the extra
   1.5rem keeps clear of a scrollbar. */
.reading-margins .reading-margins__beside {
  position: absolute;
  /* Centred on the ruler by auto margins, not a transform: some themes move
     their buttons with a transform on hover (Sticker), which would replace a
     centring transform and throw the button out from under the pointer. */
  top: 0;
  bottom: 0;
  right: calc((100% - 100vw) / 2 + 1.5rem);
  width: auto;
  height: max-content;
  min-width: 0;
  min-height: 0;
  margin: auto 0;
  padding: 0.1rem 0.6rem;
  border: 1.5px solid var(--ink-soft, var(--line, currentColor));
  border-radius: 999px;
  /* The page's own background and ink, which every theme keeps readable
     together; the ruler's hairline stops behind the label. */
  background: var(--page-bg, Canvas);
  color: inherit;
  font: inherit;
  font-size: 0.75rem;
  line-height: 1.3;
  box-shadow: none;
  cursor: pointer;
}

.reading-margins .reading-margins__beside:hover {
  border-color: var(--active-line, currentColor);
}

/* On: the off state's two colours swapped, plus a check mark so the state does
   not rest on colour alone. Off is the page's ink on the page's background,
   which every theme keeps readable, so the swap is readable too. The fill is
   a layer of the button's own ink (currentColor) under the label, and the
   label takes the background colour. The fill is a layer, not the button's
   background, because themes set button backgrounds with selectors that
   outrank this one (Sticker). Theme accents are not used: in Arena and
   Sticker --active-line, --panel and --page-bg coincide in ways that left a
   blank pill. open_beside.mjs checks the contrast in every theme. */
.reading-margins .reading-margins__beside[aria-pressed="true"] {
  isolation: isolate;
  overflow: hidden;
  border-color: currentColor;
  font-weight: 700;
}

.reading-margins .reading-margins__beside[aria-pressed="true"]::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: currentColor;
}

.reading-margins .reading-margins__beside[aria-pressed="true"] .reading-margins__beside-label {
  color: var(--page-bg, Canvas);
}

.reading-margins .reading-margins__beside[aria-pressed="true"] .reading-margins__beside-label::before {
  content: "\2713\00a0";
}

.reading-margins .reading-margins__beside:focus-visible {
  outline: 2px solid var(--active-line, currentColor);
  outline-offset: 2px;
}

/* The pane: fixed to the window so it keeps its place while the page scrolls.
   open_beside.js sets left, width and top from the column and the ruler. */
.open-beside {
  position: fixed;
  bottom: 0.5rem;
  z-index: 20;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line, currentColor);
  border-radius: 6px;
  background: var(--page-bg, Canvas);
  overflow: hidden;
}

.open-beside[hidden] {
  display: none;
}

/* The pane's bar. */
.open-beside__bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.3rem 0.6rem;
  border-bottom: 1px solid var(--line, currentColor);
  background: var(--panel, Canvas);
  font-size: 0.85rem;
}

.open-beside__title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* `.open-beside` in the selector outranks themes' general button and link
   styling, so both actions look alike in every theme. */
.open-beside .open-beside__action {
  flex: 0 0 auto;
  width: auto;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0.15rem 0.5rem;
  border: 1px solid var(--line, currentColor);
  border-radius: 4px;
  background: transparent;
  color: inherit;
  font: inherit;
  line-height: 1.3;
  text-decoration: none;
  box-shadow: none;
  cursor: pointer;
}

.open-beside .open-beside__action:hover {
  border-color: var(--active-line, currentColor);
}

.open-beside .open-beside__action:focus-visible {
  outline: 2px solid var(--active-line, currentColor);
  outline-offset: 2px;
}

.open-beside__frame {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  border: 0;
  background: var(--page-bg, Canvas);
}

/* A pane whose page could not be loaded shows a line of text in its place. */
.open-beside__note {
  margin: 0;
  padding: 1rem 0.75rem;
  color: inherit;
}

.open-beside__note[hidden] {
  display: none;
}

.open-beside--failed .open-beside__frame {
  display: none;
}
