/* A link's preview (reader/public/preview.js): a box under the link with the text it names, and for
   another act its heading and first meta line on top. The mouse can enter it to select text or follow
   its links, which keep the site's link look. Every page loads this file. The site's style sizes
   the article's blocks for the page (large margins, deep indents); here they are made compact. */

.preview {
  position: fixed;
  z-index: 10;
  box-sizing: border-box;
  width: min(30rem, calc(100vw - 32px));
  /* (under half the window, so it fits on the larger side of the link, where place() puts it) */
  max-height: min(24rem, 45vh);
  overflow: hidden;
  padding: 0.55rem 0.8rem;
  background: #fff;
  border: 1px solid #d6d6d6;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.14);
  color: #1d1d1f;
  font:
    14px/1.45 Georgia,
    serif;
  text-align: left;
}
.preview > :first-child {
  margin-top: 0;
}
.preview p {
  margin: 0.25rem 0;
}
.preview h2,
.preview h3,
.preview h4 {
  font-size: 14px;
  margin: 0.45rem 0 0.2rem;
}
.preview h2,
.preview h3,
.preview p.name {
  text-align: center;
}
.preview p.letter,
.preview p.subpoint {
  margin-left: 0.8rem;
}
.preview p.indent,
.preview p.letter + p.subpoint,
.preview p.subpoint ~ p.letter {
  margin-left: 1.6rem;
}
.preview table {
  font-size: 12px;
  margin: 0.3rem 0;
}
.preview td,
.preview th {
  padding: 0.1rem 0.3rem;
}

/* The act's heading and its first meta line, as a caption over the part. */
.preview > h1,
.preview > h1 + div {
  margin: 0;
  font:
    12px/1.4 system-ui,
    sans-serif;
  color: #555;
}
.preview > h1 {
  font-weight: 600;
  color: #1d1d1f;
}
.preview > h1 + div {
  margin-bottom: 0.4rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid #eee;
}

/* A file's text (`.file`): converted from a Word or Excel document, often a table with no borders of
   its own, so the cells get a light grid; the cells' paragraphs and the lists sit tight. Only here:
   an act's preview keeps its own look. */
.preview .file table {
  border-collapse: collapse;
}
.preview .file td,
.preview .file th {
  border: 1px solid #ddd;
  vertical-align: top;
}
.preview .file td p,
.preview .file th p {
  margin: 0;
}
.preview .file ul,
.preview .file ol {
  margin: 0.25rem 0;
  padding-left: 1.2rem;
}
.preview .file pre {
  overflow: hidden;
  font:
    11px/1.35 ui-monospace,
    monospace;
}
/* (where the document had a picture, which a text leaves out) */
.preview .file span.picture {
  color: #888;
}

/* A picture among the files: whole, as large as the box allows (its height less its padding). */
.preview > img {
  display: block;
  max-width: 100%;
  max-height: calc(min(24rem, 45vh) - 1.3rem);
  margin: 0 auto;
}
/* A PDF's first page: at the box's width, so its top is readable; the box's height cuts it and the
   fade marks the cut. */
.preview > img.page {
  width: 100%;
  max-height: none;
}

/* An archive's files: a compact list of names under the caption. */
.preview > ul {
  margin: 0.25rem 0;
  padding-left: 1.2rem;
  font:
    13px/1.5 system-ui,
    sans-serif;
}

/* The link's own note, then the text. */
.preview p.note {
  margin: 0 0 0.4rem;
  font:
    12px/1.4 system-ui,
    sans-serif;
  color: #666;
}
.preview p.more {
  margin: 0.2rem 0 0;
  color: #888;
}

/* Text cut off by the box's height fades out. */
.preview.clipped::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2.5rem;
  border-radius: 0 0 6px 6px;
  background: linear-gradient(rgba(255, 255, 255, 0), #fff);
  /* (the text under the fade can still be selected and its links followed) */
  pointer-events: none;
}

/* A note of the site (site.css, [data-tip]:hover::after) would be cut off by the box's edge: none in it. */
.preview [data-tip]:hover::after,
.preview [data-tip]:focus::after {
  content: none;
}

/* The link's CSS tooltip (site.css, [data-tip]:hover::after) gives way to the box, which shows its note. */
a.ref.previewing[data-tip]:hover::after,
a.ref.previewing[data-tip]:focus::after {
  content: none;
}
