/* article-html.css — full-text article view (article-html.php).
 *
 * Loaded only on full-text pages, not from style.css: it is ~250 rules that
 * every other page would download for nothing, and the theorem/equation
 * styling here has to target markup that tex-to-html.py generates rather than
 * anything hand-written. Colours and fonts come from the style.css :root
 * custom properties so the page stays in the site's palette.
 */

.ft-page {
    /* .nav-container is a centred flex row with no gutters (it was written for
       the navbar); as a page wrapper it has to lay its children out as normal
       blocks, centre itself and carry its own padding. The narrower max-width
       is deliberate: sidebar + a 46em measure is the whole of this layout. */
    display: block;
    max-width: 1100px;
    margin: 0 auto;
    padding: 32px 24px 80px;
}

.ft-crumb {
    font-size: 0.88rem;
    color: var(--color-text-light);
    margin-bottom: 24px;
}
.ft-crumb a { color: var(--color-primary); text-decoration: none; }
.ft-crumb a:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- header */

.ft-head {
    padding-bottom: 28px;
    margin-bottom: 32px;
    border-bottom: 2px solid var(--color-border);
}

.ft-type {
    display: inline-block;
    margin-bottom: 14px;
    padding: 4px 12px;
    border-radius: 999px;
    background: #eef2f7;
    color: var(--color-primary);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.ft-title {
    font-family: var(--font-serif);
    font-size: clamp(1.6rem, 1.1rem + 1.8vw, 2.3rem);
    line-height: 1.28;
    color: var(--color-primary-dark);
    margin: 0 0 16px;
}

.ft-byline {
    font-size: 1.05rem;
    color: var(--color-text-main);
    margin: 0 0 8px;
}
.ft-byline a { color: var(--color-primary); }
.ft-byline sup { font-size: 0.7em; margin-left: 1px; }

.ft-corr {
    font-size: 0.85rem;
    color: var(--color-text-light);
    margin: 0 0 12px;
}
.ft-corr a { color: var(--color-primary); }

.ft-affiliations {
    /* Explicit list-style: Tailwind's preflight strips markers from every ol,
       and these numbers are what the superscripts in the byline refer to. */
    list-style: decimal outside;
    margin: 0 0 14px;
    padding-left: 1.4em;
    font-size: 0.85rem;
    line-height: 1.55;
    color: var(--color-text-light);
}
.ft-affiliations li { margin-bottom: 2px; }

.ft-meta,
.ft-dates {
    font-size: 0.9rem;
    color: var(--color-text-light);
    margin: 0 0 6px;
}
.ft-meta a { color: var(--color-primary); }

.ft-actions {
    margin: 22px 0 0;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.ft-actions .btn { display: inline-flex; align-items: center; gap: 8px; }
.ft-actions .btn svg { width: 16px; height: 16px; }

.ft-draft {
    margin: 20px 0 0;
    padding: 12px 16px;
    border-radius: var(--border-radius);
    background: #fdf3e3;
    color: #8a5a00;
    font-size: 0.9rem;
}

/* ---------------------------------------------------------------- layout */

.ft-layout {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 48px;
    align-items: start;
}

.ft-toc {
    position: sticky;
    top: calc(var(--header-height) + 16px);
    max-height: calc(100vh - var(--header-height) - 40px);
    overflow-y: auto;
    padding-right: 8px;
    font-size: 0.86rem;
}
.ft-toc-title {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-text-light);
    margin: 0 0 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--color-border);
}
.ft-toc ol { list-style: none; margin: 0; padding: 0; }
.ft-toc li { margin: 0 0 2px; }
.ft-toc a {
    display: block;
    padding: 5px 10px;
    border-left: 2px solid transparent;
    color: var(--color-text-light);
    text-decoration: none;
    line-height: 1.4;
}
.ft-toc a:hover { color: var(--color-primary); background: var(--color-bg-light); }
.ft-toc a.is-current {
    color: var(--color-primary);
    border-left-color: var(--color-accent);
    font-weight: 600;
}
.ft-toc-l2 a { padding-left: 24px; font-size: 0.95em; }

/* ------------------------------------------------------------------ body */

.ft-body {
    max-width: 46em;
    font-family: var(--font-serif);
    font-size: 1.02rem;
    line-height: 1.78;
    color: var(--color-text-main);
}

.ft-section { margin-bottom: 40px; }

.ft-body h2.ft-h2 {
    font-family: var(--font-sans);
    font-size: 1.18rem;
    color: var(--color-primary);
    margin: 44px 0 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--color-border);
    scroll-margin-top: calc(var(--header-height) + 16px);
}
.ft-body h3.ft-h3 {
    font-family: var(--font-sans);
    font-size: 1.02rem;
    color: var(--color-primary);
    margin: 32px 0 10px;
    scroll-margin-top: calc(var(--header-height) + 16px);
}
.ft-section:first-child h2.ft-h2 { margin-top: 0; }
.ft-secnum { color: var(--color-accent); margin-right: 4px; }

.ft-body p { margin: 0 0 1.05em; }
.ft-body a { color: var(--color-primary); }

.ft-abstract {
    padding: 18px 22px;
    background: var(--color-bg-light);
    border-left: 4px solid var(--color-primary);
    border-radius: var(--border-radius);
}
.ft-abstract p:last-child { margin-bottom: 0; }

.ft-kw {
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--color-text-light);
    margin: 14px 0 0;
}
.ft-kw-label { font-weight: 700; color: var(--color-text-main); }

/* Theorem-like environments and proofs. */
.ft-block {
    /* flow-root, so the floated QED mark stays inside its own proof instead of
       escaping into whatever block follows. */
    display: flow-root;
    margin: 0 0 1.2em;
    padding: 14px 18px;
    border-radius: var(--border-radius);
    scroll-margin-top: calc(var(--header-height) + 16px);
}
.ft-thm {
    background: #f2f6fb;
    border-left: 3px solid var(--color-primary);
    font-style: italic;
}
.ft-rmk {
    background: var(--color-bg-light);
    border-left: 3px solid var(--color-border);
}
.ft-proof {
    padding: 0 0 0 18px;
    border-left: 3px solid #e6e9ee;
}
.ft-block > p:first-of-type { display: inline; }
.ft-block > p:last-of-type { margin-bottom: 0; }
.ft-block-head,
.ft-proof-head {
    font-family: var(--font-sans);
    font-style: normal;
    font-weight: 700;
    color: var(--color-primary-dark);
    margin-right: 6px;
}
.ft-proof-head { font-weight: 400; font-style: italic; }
.ft-qed { float: right; color: var(--color-text-light); }

.ft-list { margin: 0 0 1.05em; padding-left: 1.5em; }
ul.ft-list { list-style: disc outside; }
ol.ft-list { list-style: decimal outside; }
.ft-list li { margin-bottom: 0.4em; }
.ft-li-custom { list-style: none; }
.ft-li-custom::before {
    content: attr(data-marker) " ";
    font-weight: 600;
    margin-left: -1.5em;
    margin-right: 0.4em;
}

.ft-quote { margin: 0 0 1.05em; padding-left: 1.5em; color: var(--color-text-light); }
.ft-center { text-align: center; }
.ft-sc { font-variant: small-caps; }
.ft-note { font-size: 0.88em; color: var(--color-text-light); }

/* Display math: a span, not a div, so it can sit legally inside a <p>. */
.ft-eq {
    display: block;
    margin: 1.1em 0;
    overflow-x: auto;
    overflow-y: hidden;
    max-width: 100%;
}

.ft-cite,
.ft-xref { text-decoration: none; }
.ft-cite:hover,
.ft-xref:hover { text-decoration: underline; }
.ft-badref { color: var(--color-text-light); }

/* ------------------------------------------------------------ references */

.ft-refs {
    margin: 0;
    padding-left: 0;
    list-style: none;
    counter-reset: ft-ref;
    font-family: var(--font-sans);
    font-size: 0.92rem;
    line-height: 1.6;
}
.ft-refs li {
    counter-increment: ft-ref;
    position: relative;
    padding-left: 2.6em;
    margin-bottom: 0.7em;
    scroll-margin-top: calc(var(--header-height) + 16px);
}
/* [1], [2], … so the marker reads the same way as the \cite links in the text. */
.ft-refs li::before {
    content: "[" counter(ft-ref) "]";
    position: absolute;
    left: 0;
    color: var(--color-primary);
    font-weight: 600;
}
.ft-refs li:target { background: #fff6e8; }

.ft-cite-box {
    margin: 0;
    padding: 16px 20px;
    background: var(--color-bg-light);
    border-left: 4px solid var(--color-primary);
    border-radius: var(--border-radius);
    font-family: var(--font-sans);
    font-size: 0.94rem;
    line-height: 1.7;
}

/* MathJax's own overflow handling fights ours on narrow screens. */
.ft-body mjx-container[jax="CHTML"][display="true"] { margin: 0; }
.ft-body mjx-container { max-width: 100%; }

@media (max-width: 900px) {
    .ft-layout { grid-template-columns: minmax(0, 1fr); gap: 0; }
    .ft-toc {
        position: static;
        max-height: none;
        overflow: visible;
        margin-bottom: 32px;
        padding: 16px 18px;
        background: var(--color-bg-light);
        border-radius: var(--border-radius);
    }
    .ft-body { max-width: none; }
}

@media print {
    .ft-toc, .ft-actions, .ft-crumb { display: none; }
    .ft-layout { display: block; }
}
