/* ============================================================================
   CITATIONS — Footnote Reference Styles
   ---------------------------------------------------------------------------
   SINGLE OWNER of .footnote-ref, .module-references and .references-list.
   reader.css deliberately declares none of them: when both files did, the
   later-loading rules here won partially and shredded every citation into
   flex columns. Keep all reference styling in this file.
   ============================================================================ */

/* --- Superscript reference link --- */
.footnote-ref {
  font-size: 0.7em;
  vertical-align: super;
  line-height: 0;
  text-decoration: none;
  color: var(--app-accent);
  font-weight: 700;
  cursor: pointer;
  padding: 0 2px;
  transition: color 0.15s ease;
}

.footnote-ref:hover {
  color: #1e40af;
  text-decoration: underline;
}

.footnote-ref:focus-visible {
  outline: 2px solid var(--app-accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* --- References section at page bottom --- */
.module-references {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 2px solid var(--app-border);
}

.module-references h2 {
  font-size: 1.3rem;
  color: #1e40af;
  margin-bottom: 1rem;
}

.references-list {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: ref-counter;
}

/* Hanging indent: marker sits in the gutter, wrapped lines align under the text.
   Must stay in normal block flow — flex would split each citation's inline
   children (text, <em> journal, <a> DOI) into separate columns. */
.references-list li {
  counter-increment: ref-counter;
  position: relative;
  padding: 0.55rem 0 0.55rem 2.4rem;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--app-muted);
  border-bottom: 1px solid #f1f5f9;
}

.references-list li:last-child {
  border-bottom: none;
}

.references-list li::before {
  content: "[" counter(ref-counter) "]";
  position: absolute;
  left: 0;
  top: 0.55rem;
  font-weight: 700;
  color: var(--app-accent);
  font-size: 0.85rem;
}

/* A loose markdown list wraps each item's text in <p>. */
.references-list li > p {
  margin: 0;
}

.references-list li > p + p {
  margin-top: 0.4rem;
}

/* Bare DOIs are unbreakable words and overflow narrow screens. */
.references-list li a {
  overflow-wrap: anywhere;
}

/* Highlight pulse when navigating to a reference.
   Background only — padding here would collapse the hanging indent. */
.references-list li:target {
  background: rgba(37, 99, 235, 0.06);
  border-radius: 4px;
  animation: ref-flash 1.5s ease;
}

@keyframes ref-flash {
  0%   { background: rgba(37, 99, 235, 0.15); }
  100% { background: rgba(37, 99, 235, 0.06); }
}

/* --- Citation preview tooltip (appears on hover/click of footnote ref) --- */
.citation-preview {
  position: absolute;
  z-index: 50;
  max-width: 360px;
  background: white;
  border: 1px solid var(--app-border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--app-text);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.citation-preview.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.citation-preview .citation-number {
  font-weight: 700;
  color: var(--app-accent);
  margin-right: 0.3rem;
}

.citation-preview .citation-link {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.8rem;
  color: var(--app-accent);
  text-decoration: underline;
  cursor: pointer;
}
