/* REFERENCES — BibInject-injected research references.
 *
 * Covers both placements:
 *   - `.references-sidebar` — the compact TRACTATUS "Index of Research" panel
 *     on the portfolio homepage (date • DOI / title, two lines per entry).
 *   - `.reference-list`     — the full list on the /research page.
 *
 * The DOI link is auto-prepended by BibInject right after the opening <p>; the
 * date/title spans come from the `mini` refspec (sidebar) or the built-in APA
 * refspec (research page). */

/* ------------------------------------------------------------------ *
 * Sidebar (homepage TRACTATUS panel)                                 *
 * ------------------------------------------------------------------ */

.references-sidebar {
  margin-top: 12px;
}

.references-sidebar p:first-child {
  padding-top: 0;
  margin-top: 12px;
  border-top: 1px dashed var(--light-border);
}

.references-sidebar p {
  margin: 0 0 12px;
  padding: 12px 0 10px;
  margin-bottom: 0;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--light-border);
  font-family: var(--font-serif);
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text-subtle);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 8px;
}

.references-sidebar p:last-of-type {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

/* DATE (year), like `.post-date` */
.references-sidebar p .ref-date {
  order: 1;
  font-family: var(--font-serif);
  font-size: 0.75rem;
  color: var(--burgundy);
  display: block;
  margin-bottom: 2px;
}

/* SEPARATOR (•) between the date and the DOI */
.references-sidebar p .ref-sep {
  order: 2;
  color: var(--burgundy);
  margin: 0;
  display: inline;
}

/* DOI, sits on the same line right after the date */
.references-sidebar p a.doi-link {
  order: 3;
  text-decoration: none;
  font-family: var(--font-serif);
  font-size: 0.75rem;
  color: var(--burgundy);
  display: block;
  margin-bottom: 2px;
}

.references-sidebar p a.doi-link:hover {
  text-decoration: underline;
}

/* TITLE, wrapped onto its own line like `.article-link` */
.references-sidebar p .ref-title {
  order: 4;
  flex-basis: 100%;
  font-family: var(--font-serif);
  color: var(--text-subtle);
  font-size: 0.9rem;
  text-decoration: none;
}

/* TITLE LINK — the whole title links to its DOI */
.references-sidebar p .ref-title a {
  color: inherit;
  text-decoration: none;
}

.references-sidebar p .ref-title a:hover {
  color: var(--burgundy);
  text-decoration: underline;
}

/* ------------------------------------------------------------------ *
 * Research page (/research)                                          *
 * ------------------------------------------------------------------ */

.reference-list {
  counter-reset: ref;
  margin: 0 0 40px;
  overflow: visible;
}

/* LANGUAGE — show only the list matching the active site language: English
 * renders APA, Portuguese renders ABNT. English is the default; lang.js mirrors
 * the toggle onto <html lang> so this works on load and on every switch. */
.reference-list[data-ref-lang="pt"] {
  display: none;
}

html[lang="pt"] .reference-list[data-ref-lang="en"] {
  display: none;
}

html[lang="pt"] .reference-list[data-ref-lang="pt"] {
  display: block;
}

.reference-list p {
  position: relative;
  display: block;
  margin: 0;
  padding: 0.25rem 0 2rem 2.6rem;
  border-bottom: 1px dashed var(--light-border);
  font-family: var(--font-serif);
  font-size: 0.95rem;
  line-height: 1.75;
  text-align: left;
  overflow-wrap: anywhere;
}

.reference-list p:last-of-type {
  border-bottom: none;
}

/* ENTRY NUMBER — mono index set in the gutter, outside the citation. */
.reference-list p::before {
  counter-increment: ref;
  content: counter(ref, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 0.3rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--burgundy);
}

/* CITATION — flows as normal inline text (no flexbox, which would split
 * the citation around every <em>). */

/* ACTIONS — BibInject emits the DOI/BibTeX controls ahead of the citation;
 * position them at the entry's bottom-right, out of the text flow, so the
 * APA/ABNT citation stays intact and in sequence. */
.reference-list a.doi-link,
.reference-list .bibtex-btn {
  position: absolute;
  bottom: 0.55rem;
  line-height: 1;
  font-family: var(--font-serif);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--burgundy);
}

.reference-list .bibtex-btn {
  right: 0;
  width: 3.4rem;
  text-align: right;
  background: transparent;
  padding: 0;
  border: none;
  cursor: pointer;
  transition: color 0.15s ease;
}

.reference-list a.doi-link {
  right: 3.6rem;
}

.reference-list a.doi-link:hover,
.reference-list a.doi-link:focus,
.reference-list .bibtex-btn:hover,
.reference-list .bibtex-btn:focus {
  text-decoration: underline;
  color: var(--burgundy-hover);
}

/* EMPTY STATE — only visible when the list has not been filled at build
 * time (a plain `zola build` without BibInject). */
.reference-list p.reference-empty {
  display: block;
  margin: 0;
  padding: 0.25rem 0 1rem;
  border-bottom: none;
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--text-subtle);
}

.reference-list p.reference-empty::before {
  content: none;
  counter-increment: none;
}

/* The TEX button is only meant for the /research list, not the compact
 * portfolio sidebar ("Index of Research" panel). */
.references-sidebar .bibtex-btn {
  display: none;
}
