/* ==========================================================================
   Footnotes
   Styles the markup Ghost's Markdown card produces from [^1] syntax
   (markdown-it-footnote): sup.footnote-ref, hr.footnotes-sep,
   section.footnotes > ol.footnotes-list > li.footnote-item, a.footnote-backref.
   Loaded directly from default.hbs, outside the Gulp build.
   Selectors are written at ol.footnotes-list / li.footnote-item specificity
   so they win over the older footnote rules in Ghost's Code Injection.
   ========================================================================== */

/* Reference markers in the running text
   ------------------------------------------------------------------------ */

.gh-content .footnote-ref {
    font-size: 0.7em;
    line-height: 0; /* keep superscripts from opening up the line */
    vertical-align: baseline;
    position: relative;
    top: -0.75em;
}

.gh-content .footnote-ref a {
    padding: 0 0.2em;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0;
    color: var(--ghost-accent-color);
    text-decoration: none;
    border-radius: 2px;
    transition: background-color 0.15s ease;
}

.gh-content .footnote-ref a:hover,
.gh-content .footnote-ref a:focus-visible {
    background-color: color-mix(in srgb, var(--ghost-accent-color) 12%, transparent);
    text-decoration: none;
}

/* Marker highlighted when the reader returns from a note */
.gh-content .footnote-ref a:target {
    background-color: color-mix(in srgb, var(--ghost-accent-color) 22%, transparent);
}

/* Separator and heading
   ------------------------------------------------------------------------ */

.gh-content hr.footnotes-sep {
    width: 96px;
    height: 0;
    margin: calc(3em * var(--content-spacing-multiplier, 1)) 0 0;
    border: 0;
    border-top: 1px solid var(--color-darker-gray);
}

.gh-content .footnotes-title {
    margin-top: calc(1.2em * var(--content-spacing-multiplier, 1)) !important;
    font-size: 1.05em;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-darker-gray);
}

/* Notes list
   ------------------------------------------------------------------------ */

.gh-content .footnotes {
    font-size: 0.82em;
    line-height: 1.55;
    color: var(--color-dark-gray);
}

.gh-content hr.footnotes-sep + .footnotes {
    margin-top: calc(1.4em * var(--content-spacing-multiplier, 1));
}

.gh-content ol.footnotes-list {
    margin: 0;
    padding-left: 0;
    list-style: none;
    counter-reset: footnote;
}

.gh-content ol.footnotes-list > li.footnote-item {
    position: relative;
    list-style: none;
    margin: 0;
    padding-left: 2.6em;
    counter-increment: footnote;
    scroll-margin-top: 32px;
}

.gh-content .footnote-item::before {
    content: counter(footnote) ".";
    position: absolute;
    left: 0;
    width: 2em;
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: var(--color-darker-gray);
}

.gh-content ol.footnotes-list > li.footnote-item + li.footnote-item {
    margin-top: 0.7em;
}

.gh-content .footnote-item p {
    margin: 0;
}

.gh-content .footnote-item p + p {
    margin-top: 0.4em;
}

.gh-content .footnote-item a {
    color: inherit;
    text-decoration: underline;
    text-decoration-color: var(--color-mid-gray);
    text-underline-offset: 0.15em;
}

.gh-content .footnote-item a:hover {
    color: var(--ghost-accent-color);
    text-decoration-color: currentColor;
}

/* Note highlighted when the reader arrives from a marker */
.gh-content .footnote-item:target {
    background-color: var(--color-lighter-gray);
    box-shadow: 0 0 0 8px var(--color-lighter-gray);
    border-radius: 2px;
}

/* Back-reference arrow
   ------------------------------------------------------------------------ */

.gh-content .footnote-backref {
    margin-left: 0.3em;
    font-size: 0.9em;
    color: var(--color-secondary-text) !important;
    text-decoration: none !important;
}

.gh-content .footnote-backref:hover {
    color: var(--ghost-accent-color) !important;
}

/* Reduced motion / print
   ------------------------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
    .gh-content .footnote-ref a {
        transition: none;
    }
}

@media print {
    .gh-content .footnote-backref {
        display: none;
    }

    .gh-content .footnote-item:target {
        background: none;
        box-shadow: none;
    }
}
