/* Citation term underline styling */
.gh-content a.citation-term,
.post-content a.citation-term {
  text-decoration-line: underline;
  text-decoration-style: dashed;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  text-decoration-color: currentColor;
  cursor: help;
  border-bottom: none !important;
}

/* On hover / focus, make the dashed line slightly darker */
.gh-content a.citation-term:hover,
.gh-content a.citation-term:focus,
.post-content a.citation-term:hover,
.post-content a.citation-term:focus {
  text-decoration-color: rgba(0,0,0,0.6);
}

/* Global tooltip container (one per page) */
#citation-tooltip {
    position: fixed;
    max-width: min(480px, 80vw);
    padding: 0;
    font-size: 0.9em;
    line-height: 1.5;

    background: #ffffff;
    border: 1px solid rgba(0,0,0,0.18);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    color: #222;

    z-index: 99999;
    opacity: 0;
    pointer-events: none;
    transform: translateY(4px);
    transition: opacity 0.12s ease-out, transform 0.12s ease-out;
}

/* Visible state */
#citation-tooltip.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* Base arrow – horizontal position set via JS */
#citation-tooltip::after {
    content: "";
    position: absolute;
    left: var(--arrow-x, 20px);
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
}

/* Tooltip is below the term → arrow on top, pointing up */
#citation-tooltip.tooltip-below::after {
    top: -6px;
    bottom: auto;
    border-bottom: 6px solid #ffffff;
    border-top: none;
    filter: drop-shadow(0 -1px 1px rgba(0,0,0,0.15));
}

/* Tooltip is above the term → arrow on bottom, pointing down */
#citation-tooltip.tooltip-above::after {
    bottom: -6px;
    top: auto;
    border-top: 6px solid #ffffff;
    border-bottom: none;
    filter: drop-shadow(0 1px 1px rgba(0,0,0,0.15));
}

/* Card layout inside the tooltip: body scrolls, header/footer fixed */
#citation-tooltip .citation-card {
    max-height: min(300px, 60vh);
    display: flex;
    flex-direction: column;
}

.citation-card-header {
    display: flex;
    align-items: baseline;
    gap: 0.5em;
    padding: 0.75em 1em 0.25em 1em;
    flex: 0 0 auto;
}

.citation-card-title {
    font-weight: 600;
    font-size: 0.95em;
}

.citation-card-tag {
    font-size: 0.7em;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: #f1f3f5;
    color: #555;
    padding: 0.1em 0.4em;
    border-radius: 999px;
}

/* Scrollable body */
.citation-card-body {
    font-size: 0.9em;
    padding: 0 1em 0.5em 1em;
    overflow-y: auto;
    flex: 1 1 auto;
}

.citation-bib-text {
    font-size: 0.85em;
    color: #555;
    margin-top: 0.5em;
    padding-top: 0.5em;
    border-top: 1px dashed rgba(0,0,0,0.15);
}

/* Footer: fixed at bottom */
.citation-card-footer {
    padding: 0.35em 1em 0.6em 1em;
    border-top: 1px solid rgba(0,0,0,0.12);
    font-size: 0.8em;
    display: flex;
    flex-direction: column;
    gap: 0.25em;
    color: #555;
    flex: 0 0 auto;
}

.citation-card-footer a {
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid rgba(0,0,0,0.15);
}

.citation-card-footer a:hover {
    border-bottom-color: rgba(0,0,0,0.4);
}

/* --- New Reference Typography --- */

#citation-tooltip .citation-card-header {
    display: flex;
    flex-direction: column; /* Stack the text vertically */
    align-items: flex-start;
    gap: 0.2em;
    padding: 0.75em 1em 0.5em 1em;
    flex: 0 0 auto;
}

.citation-header-authors {
    font-size: 0.85em;
    color: #666;
}

.citation-header-title {
    font-weight: 700;
    font-size: 1.05em;
    line-height: 1.3;
    color: #111;
}

.citation-header-journal {
    font-size: 0.85em;
    font-style: italic;
    color: #555;
}

/* Section Headings inside the scrollable body */
.citation-section-title {
    font-weight: 600;
    font-size: 0.8em;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #444;
    margin-top: 1em;
    margin-bottom: 0.3em;
    border-bottom: 1px solid rgba(0,0,0,0.1);
    padding-bottom: 0.2em;
}
.citation-section-title:first-child {
    margin-top: 0.2em; /* Less margin if it's the very first item */
}

/* Footer layout for two links */
#citation-tooltip .citation-card-footer {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 0.5em 1em;
}

/* Zotero Icon */
.citation-zotero-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4em;
    font-weight: 500;
    border-bottom: none !important;
}

.zotero-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #cc2936; /* Zotero Brand Red */
    color: #ffffff;
    font-weight: bold;
    font-family: serif;
    font-size: 0.75em;
    width: 1.5em;
    height: 1.5em;
    border-radius: 3px;
}