/* The rulebook reader's panel (code/reader.js). */

@layer modules {

  /* Full-page blur behind the panel, as behind the card panels. A click on it closes the reader. */
  .rd-scrim {
    position: fixed;
    inset: 0;
    z-index: 700;               /* over card panels (21); under tips, sign-in and the on-screen keyboard */
    background: var(--scrim);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
  }

  .rd-scrim[hidden] {
    display: none;
  }

  /* Centred, as tall as the screen allows. Side by side, it's twice as wide if the screen has room. */
  .rd {
    --rd-width: 960px;
    position: fixed;
    inset: 2%;
    z-index: 701;
    width: min(var(--rd-width), 96%);
    margin-inline: auto;
    display: flex;
    flex-direction: column;
    background: var(--surface-solid);
    border: 1px solid var(--glass-border-hi);
    box-shadow: var(--shadow-drop);
    touch-action: pan-x pan-y;  /* a pinch here zooms the book (reader.js), not the page */
  }

  .rd.is-spread {
    --rd-width: 1920px;
  }

  /* A browser tab opened for a book (Ctrl-click): only the reader, filling the page. */
  .rd.rd--full {
    inset: 0;
    width: 100%;
    border: none;
  }

  .rd--full [data-act="close"] {
    display: none;
  }

  .is-reader-tab #topbar,
  .is-reader-tab #viewport {
    display: none;
  }

  .rd[hidden] {
    display: none;
  }

  .rd__title {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 8px 6px 16px;
    user-select: none;
    border-bottom: 1px solid var(--glass-border);
  }

  .rd__name {
    font-size: var(--fs-sm);
    letter-spacing: var(--tracking);
    text-transform: uppercase;
    color: var(--c-ice-bright);
  }

  .rd__tools {
    flex: none;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 20px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--glass-border);
  }

  .rd__group {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
  }

  .rd__find {
    flex: 1 1 240px;
    justify-content: flex-end;
  }

  .rd__label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: var(--fs-xs);
    letter-spacing: var(--tracking);
    text-transform: uppercase;
    white-space: nowrap;
    color: var(--c-text-muted);
  }

  .rd__page {
    width: 60px;
    height: var(--control-h);
    font-family: var(--font-mono);
    text-align: center;
    appearance: textfield;
  }

  .rd__page::-webkit-inner-spin-button,
  .rd__page::-webkit-outer-spin-button {
    appearance: none;
    margin: 0;
  }

  .rd__zoom {
    justify-content: center;
    width: 46px;
    font-family: var(--font-mono);
    letter-spacing: 0;
  }

  .rd__count {
    font-family: var(--font-mono);
    letter-spacing: 0;
  }

  .rd__count.is-none {
    color: var(--c-orange);
  }

  .rd__body {
    position: relative;
    flex: 1;
    min-height: 0;
  }

  .rd__scroller {
    position: absolute;
    inset: 0;
    overflow: auto;
    outline: none;
    background: var(--c-void);
  }

  .rd__scroller .pdfViewer .page {
    margin-block: 12px;
    box-shadow: var(--shadow-drop);
  }

  .rd__scroller .textLayer {
    user-select: text;
  }

  .rd__status {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: var(--pad);
    background: var(--c-void);
  }

  .rd__status[hidden] {
    display: none;
  }

  .rd__status-text {
    margin: 0;
    font-size: var(--fs-sm);
    letter-spacing: var(--tracking);
    text-align: center;
    text-transform: uppercase;
    color: var(--c-ice);
  }

  .rd__status.is-error .rd__status-text {
    color: var(--c-orange);
  }

  .rd__progress {
    width: min(420px, 100%);
    height: 6px;
    background: var(--well);
    border: 1px solid var(--glass-border);
  }

  .rd__progress[hidden] {
    display: none;
  }

  .rd__progress span {
    display: block;
    width: 0;
    height: 100%;
    background: var(--c-ice);
  }
}
