/* content/citations.css */

/* --------------------------------------------------------------------------
   Citations (citations.go): [1] sources, [a] notes, Wikipedia style
   -------------------------------------------------------------------------- */

sup.reference {
    font-size: 0.7em;
    line-height: 0;
    vertical-align: super;
    white-space: nowrap;
    font-style: normal;
    font-weight: 500;
}

.main-content sup.reference a {
    color: var(--link-color);
    text-decoration: none;
    padding: 0 0.05em;
}

.main-content sup.reference a:hover {
    text-decoration: underline;
}

/* The Notes / References headings: grey and italic, so the back matter
   reads as apart from the post. */
.main-content h2.cite-heading {
    color: var(--text-muted);
    font-style: italic;
}

/* Where a jump lands: the entry, or the marker you came back to. */
ol.references li:target,
sup.reference:target {
    background: color-mix(in srgb, var(--accent-color) 14%, transparent);
    border-radius: 4px;
}

ol.references li,
sup.reference {
    scroll-margin-top: 30vh;
}

ol.references {
    font-size: 0.88em;
    line-height: 1.55;
    padding-left: 2.2em;
}

ol.references.notes {
    list-style-type: lower-alpha;
}

/* A titled note ([^*Label]): the label is a word of the sentence, linked
   like a term on Wikipedia, and its list entry leads with it, unlettered. */
.main-content span.reference.term a {
    color: var(--link-color);
    text-decoration: none;
}

.main-content span.reference.term a:hover {
    text-decoration: underline;
}

span.reference.term {
    scroll-margin-top: 30vh;
}

span.reference.term:target {
    background: color-mix(in srgb, var(--accent-color) 14%, transparent);
    border-radius: 4px;
}

ol.references li.cite-titled {
    list-style-type: none;
}

.cite-term-head {
    font-weight: 700;
}

/* A long reference list flows into columns where there's room. */
@media (min-width: 1000px) {
    ol.references:has(> li:nth-child(10)) {
        columns: 2 22em;
        column-gap: 2.5em;
    }
    ol.references li {
        break-inside: avoid;
    }
}

ol.references li {
    margin-bottom: 0.45em;
    padding: 0.1em 0.3em;
}

ol.references li::marker {
    color: var(--text-muted);
}

.cite-backlinks {
    margin-right: 0.4em;
    color: var(--text-muted);
    font-weight: 700;
}

.main-content .cite-backlinks a {
    color: var(--link-color);
    text-decoration: none;
}

.cite-backlinks sup {
    font-style: italic;
    font-weight: 700;
}

.reference-text {
    display: inline;
}

.reference-text > p {
    margin: 0 0 0.4em;
    text-indent: 0;
}

.reference-text > p:first-child {
    display: inline;
}

.reference-text > p:first-child + p {
    margin-top: 0.4em;
}

/* Hover/tap preview of a citation (theme.js) */
.cite-popup {
    position: absolute;
    z-index: 60;
    max-width: min(26rem, calc(100vw - 16px));
    padding: 0.7rem 0.9rem;
    background: var(--sidebar-bg);
    color: var(--text-color);
    border: 1px solid var(--sidebar-border);
    border-radius: 10px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);
    font-family: var(--font-primary);
    font-size: 0.86rem;
    line-height: 1.5;
}

.cite-popup[hidden] {
    display: none;
}

.cite-popup-label {
    margin-bottom: 0.3rem;
    font-family: var(--font-heading);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-muted);
}

.cite-popup p {
    margin: 0 0 0.4em;
    text-indent: 0;
}

.cite-popup p:last-child {
    margin-bottom: 0;
}

.cite-popup a {
    color: var(--link-color);
    overflow-wrap: anywhere;
}
