/* Hover quote bubbles (plugins/quote-pop).
 *
 * Source syntax: a blockquote starting with 🗨; plugins/quote-pop/index.js
 * turns it into
 *
 *   <span class="quote-pop" tabindex="0">
 *     <span class="quote-pop-label">论文原文(§II)</span>
 *     <span class="quote-pop-body">
 *       <span class="quote-pop-para">…original paragraph…</span>
 *     </span>
 *   </span>
 *
 * and lifts the trigger to the end of the preceding paragraph, so it reads
 * inline like a link (dashed underline below the text). By default the body
 * is hidden; hovering / focusing the trigger opens the floating quote card.
 * Tune per page with the variables below. */

.markdown-section .quote-pop {
  --qpp-fg: #4183c4;
  --qpp-fg-hover: #2d6cb3;
  --qpp-line: rgba(65, 131, 196, 0.55);
  --qpp-panel-bg: #ffffff;
  --qpp-panel-border: #e2e8f0;
  --qpp-panel-fg: #1f2937;
  --qpp-bar: #64748b;

  position: relative;
  display: inline;
  padding: 0 1px;
  color: var(--qpp-fg);
  cursor: help;
  border-bottom: 1px dashed var(--qpp-line);
}

.markdown-section .quote-pop:hover,
.markdown-section .quote-pop:focus {
  color: var(--qpp-fg-hover);
  border-bottom-style: solid;
  outline: none;
}

.markdown-section .quote-pop .quote-pop-body {
  display: none;
  position: absolute;
  z-index: 80;
  top: calc(100% + 9px);
  right: -1em;
  width: 560px;
  max-width: min(92vw, 640px);
  max-height: 70vh;
  overflow: auto;
  padding: 0.85em 1.15em;
  border: 1px solid var(--qpp-panel-border);
  border-left: 3px solid var(--qpp-bar);
  border-radius: 6px;
  background: var(--qpp-panel-bg);
  color: var(--qpp-panel-fg);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.75;
  text-align: left;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.18);
  cursor: auto;
}

.markdown-section .quote-pop:hover .quote-pop-body,
.markdown-section .quote-pop:focus .quote-pop-body {
  display: block;
}

/* paragraphs live as block-displayed spans, so the popup body stays valid
   inside a surrounding <p> after lifting */
.markdown-section .quote-pop .quote-pop-para {
  display: block;
  margin: 0 0 0.6em;
}

.markdown-section .quote-pop .quote-pop-para:last-child {
  margin-bottom: 0;
}

.markdown-section .quote-pop .quote-pop-body code {
  font-size: 11.5px;
}

/* ---------- print / PDF: no hover, always show the quote ---------- */

@media print {
  .markdown-section .quote-pop {
    display: block;
    margin: 0.4em 0;
    padding: 0.7em 1em;
    border: 1px solid var(--qpp-panel-border);
    border-left: 3px solid var(--qpp-bar);
    border-radius: 4px;
    color: inherit;
    border-bottom: 1px solid var(--qpp-panel-border);
    cursor: auto;
  }

  .markdown-section .quote-pop .quote-pop-label {
    display: block;
    margin-bottom: 0.35em;
    font-weight: 600;
  }

  .markdown-section .quote-pop .quote-pop-body {
    display: block;
    position: static;
    width: auto;
    max-width: none;
    max-height: none;
    overflow: visible;
    padding: 0;
    border: none;
    box-shadow: none;
    background: none;
  }

  .markdown-section .quote-pop .quote-pop-para {
    display: block;
  }
}
