/* Shared “reading pane” surface: full article pages and home magazine headline strip bodies. */
:root {
    --article-reading-pane-bg: color-mix(in srgb, var(--color-bg) 70%, #ffffff 30%);
    --article-reading-prose-color: color-mix(in srgb, var(--color-text-mid) 35%, var(--color-text) 65%);
    /* Whole-pixel sizes avoid wavy serif hinting (fractional rem × line-height on Linux/Firefox). */
    --article-prose-size: 22px;
    --article-prose-leading: 32px;
    --article-quote-size: 26px;
    --article-quote-leading: 40px;
    --article-table-size: 21px;
    --article-table-leading: 30px;
}

.article-page-root > .card,
.article-page-root > .card-body {
    background-color: var(--article-reading-pane-bg);
}

.article-page-root > .card {
    margin-bottom: 0;
    padding: 0.75rem max(1rem, env(safe-area-inset-left, 0px)) 0;
    box-sizing: border-box;
    border-bottom: 1px solid color-mix(in srgb, var(--color-border) 55%, var(--article-reading-pane-bg) 45%);
}

.article-page-root > .card-body {
    padding: 1rem max(1rem, env(safe-area-inset-left, 0px)) 2rem max(1rem, env(safe-area-inset-right, 0px));
    margin-bottom: 0;
    box-sizing: border-box;
}

.article-main {
    margin-top: 30px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Prose figures only — exclude inline profile avatars (user badges, highlight authors). */
.article-main img:not(.user-badge__avatar-img):not(.user-highlight__author-avatar-img) {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 1.25rem auto;
}

.article-main .user-badge__avatar-img,
.article-main .user-highlight__author-avatar-img {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    margin: 0;
    display: block;
    object-fit: cover;
    border-radius: 50%;
}

.article-main h2, .article-main h3,
.article-main h4, .article-main h5, .article-main h6 {
    margin-top: 2em;
}

.article-main p,
.article-main ul,
.article-main ol,
.article-main blockquote,
.article-main table {
    font-family: var(--main-body-font), serif;
    color: var(--color-text-mid);
    font-size: var(--article-prose-size);
    line-height: var(--article-prose-leading);
}

.article-page-root .article-main p,
.article-page-root .article-main ul,
.article-page-root .article-main ol,
.article-page-root .article-main li,
.article-page-root .article-main blockquote,
.article-page-root .article-main table,
.home-curation-landmark .article-main p,
.home-curation-landmark .article-main ul,
.home-curation-landmark .article-main ol,
.home-curation-landmark .article-main li,
.home-curation-landmark .article-main blockquote,
.home-curation-landmark .article-main table {
    color: var(--article-reading-prose-color);
}

.article-main table {
    font-size: var(--article-table-size);
    line-height: var(--article-table-leading);
}

.article-main table th,
.article-main table td {
    border-bottom: 1px solid var(--color-text);
}

.card-header--article {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    flex-wrap: wrap;
    /* .card-header { overflow: hidden } would clip the ⋯ dropdown; following siblings can paint on top. */
    overflow: visible;
    position: relative;
    z-index: 5;
}

.card-header--article .card-title {
    flex: 1 1 12rem;
    min-width: 0;
    margin: 0;
    font-family: var(--heading-font), serif;
    font-weight: 700;
    line-height: 1.12;
    color: var(--color-primary);
}

/* Article + category page headers: global h1 is 300 weight; titles should read as the clear focal point. */
.card-header--article h1.card-title {
    font-size: clamp(1.85rem, 2.8vw, 2.75rem);
}

/* Hero summary: same “excerpt” level as list cards, not .lede’s 1.6rem body scale */
.card > .card-body > .lede {
    font-family: var(--main-body-font), serif;
    font-size: 1.1rem;
    line-height: 1.55;
    font-weight: 400;
    color: var(--color-text-mid);
    margin: 0 0 1.25rem;
    max-width: none;
}

.article-page-root > .card-body > .lede {
    color: var(--article-reading-prose-color);
}

/* Sibling .category-body would paint over the ⋯ popover; lift the title card above the list. */
.category-page__header-card {
    position: relative;
    z-index: 6;
}

.card.comment .metadata.comment-card__head {
    align-items: flex-start;
}

.card.comment .metadata__end {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
}

.byline {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 2rem 0;
    padding-top: 0.5rem;
    border-top: 1px solid var(--color-border);
    font-size: 1rem;
    font-weight: 400;
    color: var(--color-text-mid);
    font-family: var(--font-family), sans-serif;
}

.byline__author {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35em;
}

/* Article body only — avoid 50px vertical margins on comment / quote cards (Atoms:Content markdown). */
.article-main blockquote {
    border-left: 6px solid var(--color-bg-light);
    padding-left: 3px;
    margin: 50px 0 50px 3px;
}

.article-main blockquote p {
    font-size: var(--article-quote-size);
    line-height: var(--article-quote-leading);
    font-style: italic;
    color: var(--color-text-mid);
    padding-left: 30px;
}

.article-page-root .article-main blockquote p,
.home-curation-landmark .article-main blockquote p {
    color: var(--article-reading-prose-color);
}

/* Home curated headline stack: one reading pane behind cover + headline + body (not only .__body). */
.home-curation-landmark .curation-article-display__pane {
    background-color: var(--article-reading-pane-bg);
    padding: 1rem 1.15rem 1.5rem;
    box-sizing: border-box;
    border-radius: 0.35rem;
}

.home-curation-landmark .curation-article-display__body {
    padding: 0;
    background: transparent;
}

.home-curation-landmark .curation-article-display__media {
    background: transparent;
}

.table-of-contents {
    border-left: var(--color-secondary) 6px solid;
    margin: 2em 0;
}

.table-of-contents li {
    list-style: none;
    margin-left: 0;
}

.embedded-content iframe {
    width: 100%;
    height: auto;
    aspect-ratio: 16/9;
}

.article-comments-async .comments--pending {
    margin: 1rem 0;
    min-height: 3.5rem;
}

.card.comment.comment--arriving {
    animation: comment-arrive 0.45s ease-out;
}

@keyframes comment-arrive {
    from {
        opacity: 0;
        transform: translateY(0.35rem);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.comments-loading {
    margin: 1.25rem 0 2rem;
    padding: 1rem 0;
}

.comments-loading__text {
    margin: 0 0 0.35rem;
    color: var(--color-text);
}

.comments-loading__hint {
    margin: 0;
    font-size: 0.9rem;
}

.comments-quotes {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border);
}

.comments-quotes__title {
    font-size: 1.25rem;
    margin: 0 0 0.9rem;
}

.comments-quotes__sep {
    margin: 0 0.25rem;
    color: var(--color-text-mid);
}


.comment--quote .metadata {
    flex-wrap: wrap;
    gap: 0.35rem;
}

/* Tracebacks: same flex+gap as .comments so spacing isn’t lost to margin collapse or .card { margin } from app.css */
.comments-quotes__list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    min-height: 0;
}

.comments-quotes__list > .card.comment--quote {
    margin: 0; /* override app.css .card { margin-bottom: 50px } */
    flex-shrink: 0;
}

.comments-quotes__list .card.comment--quote .card-footer.nostr-previews {
    margin-top: 0.75rem;
}

/* Thread: no depth indent; one accent color for all replies */
.comments {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

/* Empty-state label when the relay fetch returned zero comments */
.comments__empty {
    font-size: 0.9rem;
    color: var(--color-text-mid);
    margin: 0.5rem 0;
}

.comments .card.comment,
.comments-quotes__list .card.comment {
    margin-left: 0;
    margin-bottom: 0;
    padding: 0.75rem 0.9rem 0.85rem;
    border-radius: 6px;
    border: 1px solid var(--color-border);
    border-left: 3px solid var(--color-primary);
    gap: 0.5rem;
}

.comments .card.comment--depth-0,
.comments .card.comment--depth-1,
.comments .card.comment--depth-2,
.comments .card.comment--depth-3 {
    margin-left: 0;
    border-left-color: var(--color-primary);
}

.comments .card.comment .metadata,
.comments-quotes__list .card.comment .metadata {
    margin-bottom: 0;
}

.comment__reply-blurb {
    padding: 0.4rem 0.55rem 0.45rem 0.55rem;
    margin: 0 0 0 0.2rem;
    border-left: 2px solid color-mix(in srgb, var(--color-border) 50%, transparent);
    background: color-mix(in srgb, var(--color-bg-light) 55%, transparent);
    border-radius: 0 3px 3px 0;
    font-size: 0.9em;
    line-height: 1.45;
    color: var(--color-text-mid);
}

/* Markdown blockquotes inside note bodies: tight rhythm (not .article-main blockquote). */
.comments .card.comment .card-body blockquote,
.comments-quotes__list .card.comment .card-body blockquote {
    margin: 0.35rem 0 0.5rem;
    padding: 0.3rem 0 0.35rem 0.65rem;
    border-left: 3px solid color-mix(in srgb, var(--color-primary) 40%, var(--color-border));
}

.comments .card.comment .card-body blockquote p,
.comments-quotes__list .card.comment .card-body blockquote p {
    font-size: 1em;
    line-height: 1.45;
    font-style: italic;
    color: var(--color-text-mid);
    margin: 0;
    padding-left: 0;
}

.comments .card.comment .card-body > :first-child,
.comments-quotes__list .card.comment .card-body > :first-child {
    margin-top: 0;
}

.comments .card.comment .card-body > :last-child,
.comments-quotes__list .card.comment .card-body > :last-child {
    margin-bottom: 0;
}

.comments .card.comment .card-body,
.comments-quotes__list .card.comment .card-body {
    line-height: 1.52;
    overflow: visible;
}

.comment__reply-blurb blockquote,
.comment__reply-blurb :where(blockquote) {
    border-left: none;
    margin: 0;
    padding-left: 0;
}

.comment__reply-blurb blockquote p,
.comment__reply-blurb :where(blockquote) p {
    font-size: inherit;
    line-height: inherit;
    font-style: normal;
    margin: 0;
    padding-left: 0;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
    white-space: nowrap;
}

.comment-reply {
    margin-top: 0.45rem;
    padding-top: 0.45rem;
    border-top: 1px solid var(--color-border);
}

.comment-reply--article {
    margin-bottom: 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    border-top: 1px solid var(--color-border);
}

.comment-reply--article__inner {
    padding: 0.9rem 1rem 1rem;
}

.comment-reply__toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 0.75rem;
    margin-bottom: 0.35rem;
}

.comment-reply__lede {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.35;
    flex: 1 1 12rem;
    min-width: 0;
}

.comment-reply__toolbar--inline {
    margin-bottom: 0.15rem;
    margin-top: 0.3rem;
    justify-content: flex-end;
}

.comment-reply__heading {
    font-size: 1.05rem;
    margin: 0;
}

.comment-reply__panel {
    margin-top: 0.6rem;
    padding: 0.75rem 0.8rem 0.85rem;
    border-radius: 6px;
    background: var(--color-bg-light, rgba(0, 0, 0, 0.2));
    border: 1px solid var(--color-border);
    box-sizing: border-box;
}

.comment-reply__panel--hidden {
    display: none;
}

.comment-reply--nested {
    margin-top: 0.3rem;
}

.comment-reply__head {
    font-size: 0.9rem;
    margin-bottom: 0.35rem;
}

.comment-reply__body .form-control {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding: 0.6rem 0.75rem;
    margin: 0;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: var(--color-bg);
    color: var(--color-text);
    font: inherit;
    line-height: 1.5;
    min-height: 4.5rem;
    resize: vertical;
}

.comment-reply__actions {
    margin-top: 0.5rem;
}

.comment-reply__hint {
    font-size: 0.9rem;
    margin: 0.5rem 0 0;
}

.reply-toast {
    position: fixed;
    left: 50%;
    bottom: 1.2rem;
    transform: translateX(-50%) translateY(8px);
    z-index: 1200;
    min-width: 16rem;
    max-width: min(92vw, 32rem);
    padding: 0.55rem 0.85rem;
    border: 1px solid var(--color-border);
    color: var(--color-text);
    background: var(--color-bg);
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
}

.reply-toast--visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.reply-toast--success {
    border-color: #2f7a4b;
    background: #e7f5eb;
}

.reply-toast--error {
    border-color: #a12b2b;
    background: #fdecec;
}

/* NIP-84: kind-9802 marks in .article-main (fragment id highlight-<event id> for deep links) */

/* Full `context` quote + optional <mark> on the `content` substring (body copy, not a box) */
.user-highlight__body {
    margin: 0.35rem 0 0;
    font-size: var(--article-prose-size);
    line-height: var(--article-prose-leading);
    color: var(--color-text);
    font-family: var(--main-body-font), serif;
}

/* In-flow: NIP-84 mark treatment on article pages only (scroll-margin for #highlight-… links below). */
.article-main mark.user-highlight__marker {
    margin: 0;
    padding: 0.08em 0.1em 0.12em;
    border: none;
    border-radius: 0.12em;
    font: inherit;
    line-height: inherit;
    color: var(--color-highlight-mark-fg);
    background: color-mix(in srgb, #7ad67a 30%, #f0e8a0 70%);
    box-shadow: none;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}

/* Home highlights feed: same <mark> markup, no highlight fill — reads as body copy. */
.home-aside-highlights__quote--html mark.user-highlight__marker {
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 0;
    font: inherit;
    line-height: inherit;
    color: inherit;
    background: transparent;
    box-shadow: none;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}

.article-main mark.user-highlight__marker,
.article-main .user-highlight__fragment-target {
    scroll-margin-top: calc(var(--site-fixed-header-offset, 112px) + 0.75rem);
}

/* Invisible #highlight-{eid} anchors (same group as an older mark) — zero visual footprint. */
.article-main .user-highlight__fragment-target {
    display: inline;
    font-size: 0;
    line-height: 0;
    width: 0.01em;
    height: 0;
    overflow: hidden;
    margin: 0;
    padding: 0;
    border: 0;
    vertical-align: baseline;
}

/* When `content` is not a substring of `context` (rare) */
.user-highlight__marker-orphan {
    margin: 0.5rem 0 0;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--color-text-mid);
}

/* Inline author avatars after each highlight mark */
.user-highlight__authors {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    margin-left: 0.25rem;
    vertical-align: middle;
    white-space: nowrap;
}

.user-highlight__author {
    display: inline-flex;
    text-decoration: none;
    line-height: 0;
}

.user-highlight__author:hover,
.user-highlight__author:focus-visible {
    outline: none;
    transform: translateY(-1px);
}

.user-highlight__author-avatar {
    position: relative;
    display: inline-block;
    width: 1.35rem;
    height: 1.35rem;
    border-radius: 50%;
    overflow: hidden;
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--color-border) 80%, transparent);
    background: color-mix(in srgb, var(--color-text-mid) 12%, var(--color-bg) 88%);
}

.user-highlight__author-avatar-img {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 50%;
}

.user-highlight__author-avatar-img.is-broken {
    display: none;
}

.user-highlight__author-avatar-fallback {
    position: absolute;
    inset: 0;
    z-index: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.62rem;
    font-weight: 600;
    font-family: var(--font-family), sans-serif;
    color: var(--color-text-mid);
    line-height: 1;
}

/* Community publication reader + cards */
.publication-reader__header-card {
    position: relative;
    z-index: 5;
}

.publication-meta {
    margin: 0 0 1.25rem;
    display: grid;
    gap: 0.75rem 1.25rem;
}

.publication-meta__group {
    display: grid;
    grid-template-columns: minmax(7.5rem, 10rem) 1fr;
    gap: 0.35rem 1rem;
    align-items: start;
    margin: 0;
}

.publication-meta__label {
    margin: 0;
    font-family: var(--font-family), system-ui, sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--color-text-mid);
}

.publication-meta__value {
    margin: 0;
    font-family: var(--font-family), system-ui, sans-serif;
    font-size: 0.95rem;
    line-height: 1.45;
    color: var(--color-text);
}

.publication-meta__value--prose {
    font-family: var(--main-body-font), serif;
    font-size: var(--article-prose-size, 22px);
    line-height: var(--article-prose-leading, 32px);
    color: var(--article-reading-prose-color, var(--color-text-mid));
}

.publication-meta__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.publication-meta__list--npub {
    gap: 0.35rem;
}

.publication-meta__topics {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.publication-meta__topics li {
    list-style: none;
}

.publication-meta__code {
    font-size: 0.88em;
    word-break: break-all;
}

@media (max-width: 520px) {
    .publication-meta__group {
        grid-template-columns: 1fr;
    }
}

.publication-reader__layout {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.publication-reader__main {
    width: 100%;
    min-width: 0;
}

.publication-reader__toc {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--color-border, #ddd);
    border-radius: 0.35rem;
    background: var(--article-reading-pane-bg, var(--color-bg));
}

.publication-reader__comments-divider {
    margin-top: 2rem;
}

.publication-reader__comments {
    margin-top: 1rem;
}

.publication-toc,
.publication-toc ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.publication-toc__item,
.publication-toc li {
    margin: 0.35rem 0;
}

.publication-toc a {
    display: block;
    font-size: 0.95rem;
    text-decoration: none;
    color: var(--color-link, var(--color-primary));
}

.publication-toc a:hover,
.publication-toc a:focus-visible {
    text-decoration: underline;
    color: var(--color-link-hover, var(--color-primary));
}

.publication-toc ul ul {
    margin-left: 1rem;
    padding-left: 0.5rem;
    border-left: 1px solid var(--color-border-soft, var(--color-border));
}

.publications-grid {
    display: grid;
    gap: 1rem;
}

@media (min-width: 640px) {
    .publications-grid {
        grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
    }
}

.publication-card {
    display: block;
    text-decoration: none;
    color: inherit;
    height: 100%;
}

.publication-card:hover {
    text-decoration: none;
}

.publication-actions {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.35rem;
    align-items: stretch;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border-soft, var(--color-border));
    max-width: 36rem;
}

.publication-actions__select {
    flex: 1 1 auto;
    min-width: 0;
    font: inherit;
    padding: 0.45rem 0.65rem;
    border: 1px solid var(--color-border);
    border-radius: 0.25rem;
    background: var(--color-bg);
    color: var(--color-text);
}

.publication-actions__go {
    flex: 0 0 auto;
    min-width: 2.75rem;
    padding-left: 0.65rem;
    padding-right: 0.65rem;
    font-size: 1.15rem;
    line-height: 1;
}

.publication-full {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.publication-section {
    scroll-margin-top: calc(var(--site-fixed-header-offset, 112px) + 0.75rem);
}

.publication-section__title {
    margin: 0 0 0.75rem;
    font-family: var(--heading-font), serif;
    color: var(--color-text);
}

.publication-section__body,
.publication-section__intro {
    margin: 0;
}

.publication-section + .publication-section,
.publication-section--index + .publication-section {
    padding-top: 0.5rem;
    border-top: 1px solid var(--color-border-soft, var(--color-border));
}

.nostr-preview-card-link {
    display: block;
    text-decoration: none;
    color: inherit;
}

.nostr-preview-card-link:hover {
    text-decoration: none;
}

.nostr-preview-card-link .card {
    transition: box-shadow 0.15s ease;
}

.nostr-preview-card-link:hover .card {
    box-shadow: 0 2px 8px color-mix(in srgb, var(--color-text) 12%, transparent);
}

.article-main .paragraph,
.article-main .olist,
.article-main .ulist,
.article-main .dlist,
.article-main .quoteblock {
    margin: 0 0 1.25rem;
}

.article-main .sect1,
.article-main .sect2 {
    margin-top: 1.5rem;
}

.article-main .admonitionblock {
    border-left: 3px solid var(--color-brand, #333);
    padding: 0.5rem 1rem;
    margin: 1rem 0;
    background: color-mix(in srgb, var(--color-bg) 85%, var(--color-text-mid) 15%);
}
