/* martiallaw.wiki -- v1 styles
 * Palette: #ffffff #1a1a1a #3b5998 #f8f9fa #72777d #a2a9b1 #eaf3ff
 * Fonts:   Merriweather (display), Open Sans (body), Roboto Mono (data)
 */

:root {
    --c-bg: #ffffff;
    --c-text: #1a1a1a;
    --c-link: #3b5998;
    --c-panel: #f8f9fa;
    --c-muted: #72777d;
    --c-border: #a2a9b1;
    --c-highlight: #eaf3ff;

    --f-serif: "Merriweather", Georgia, "Times New Roman", serif;
    --f-sans: "Open Sans", "Helvetica Neue", Arial, sans-serif;
    --f-mono: "Roboto Mono", "SFMono-Regular", Menlo, Consolas, monospace;

    --max-w: 1200px;
    --gap: 2rem;
    --side-w: 320px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    background: var(--c-bg);
    color: var(--c-text);
    font-family: var(--f-sans);
    font-size: 16px;
    line-height: 1.8;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--c-link);
    text-decoration: none;
}
a:hover { text-decoration: underline; }

::selection {
    background: var(--c-highlight);
    color: var(--c-text);
}

/* ---------- Site header ---------- */
.site-header {
    border-bottom: 1px solid var(--c-border);
    background: var(--c-bg);
    position: sticky;
    top: 0;
    z-index: 50;
}
.site-header-inner {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 0 1.25rem;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 2rem;
    height: 56px;
}
.site-logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--c-text);
}
.site-logo:hover { text-decoration: none; }
.logo-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 1px solid var(--c-border);
    border-radius: 2px;
    background: var(--c-panel);
    font-family: var(--f-mono);
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--c-link);
    letter-spacing: 0.5px;
}
.logo-text {
    font-family: var(--f-serif);
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.01em;
}
.site-nav {
    display: flex;
    gap: 1.4rem;
    font-size: 0.88rem;
}
.site-nav a {
    color: var(--c-text);
    padding: 0.25rem 0;
    border-bottom: 2px solid transparent;
    transition: border-color 120ms linear, color 120ms linear;
}
.site-nav a:hover {
    color: var(--c-link);
    border-bottom-color: var(--c-link);
    text-decoration: none;
}
.site-tools { display: flex; }
.search-input {
    width: 240px;
    padding: 0.4rem 0.7rem;
    border: 1px solid var(--c-border);
    border-radius: 2px;
    background: var(--c-bg);
    color: var(--c-text);
    font-family: var(--f-sans);
    font-size: 0.85rem;
    outline: none;
    transition: border-color 120ms linear, background 120ms linear;
}
.search-input:focus {
    border-color: var(--c-link);
    background: var(--c-highlight);
}

/* ---------- Page container ---------- */
.page {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 1.25rem 1.25rem 4rem;
}

.breadcrumb {
    font-size: 0.85rem;
    padding: 0.6rem 0 1.2rem;
    color: var(--c-muted);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    border-bottom: 1px solid var(--c-border);
    margin-bottom: 1.4rem;
}
.breadcrumb a { color: var(--c-link); }
.breadcrumb .sep {
    color: var(--c-muted);
    font-family: var(--f-mono);
    font-size: 0.85rem;
}
.breadcrumb .current {
    color: var(--c-text);
    font-weight: 600;
}

/* ---------- Layout grid ---------- */
.layout {
    display: grid;
    grid-template-columns: 1fr var(--side-w);
    gap: var(--gap);
    align-items: start;
}

/* ---------- Article ---------- */
.article {
    min-width: 0;
    max-width: 720px;
    width: 100%;
}
.article-header { margin-bottom: 1.2rem; }
.article-header h1 {
    margin: 0;
    font-family: var(--f-serif);
    font-weight: 700;
    font-size: clamp(1.75rem, 3vw, 2.4rem);
    line-height: 1.2;
    letter-spacing: -0.01em;
    border-bottom: 1px solid var(--c-border);
    padding-bottom: 0.4rem;
}
.article-subtitle {
    margin: 0.6rem 0 0.4rem;
    color: var(--c-muted);
    font-size: 0.95rem;
    font-style: italic;
}
.article-meta {
    margin-top: 0.6rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    color: var(--c-muted);
    font-family: var(--f-mono);
    font-size: 0.78rem;
    letter-spacing: 0.01em;
}
.article-meta .meta-divider { color: var(--c-border); }
.article-meta a { color: var(--c-link); }

/* TOC */
.toc {
    margin: 1.2rem 0 1.6rem;
    border: 1px solid var(--c-border);
    background: var(--c-panel);
    padding: 12px 16px;
    border-radius: 2px;
    font-size: 0.9rem;
    max-width: 520px;
}
.toc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--c-border);
    padding-bottom: 6px;
    margin-bottom: 8px;
}
.toc-title {
    font-family: var(--f-sans);
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--c-text);
    letter-spacing: 0.02em;
}
.toc-toggle {
    background: transparent;
    border: none;
    color: var(--c-link);
    font-family: var(--f-mono);
    font-size: 0.8rem;
    cursor: pointer;
    padding: 2px 6px;
}
.toc-toggle:hover { text-decoration: underline; }
.toc-list {
    margin: 0;
    padding-left: 1.2rem;
    list-style: decimal;
}
.toc-list ol {
    list-style: decimal;
    padding-left: 1.2rem;
    margin: 4px 0;
}
.toc-list li { margin: 2px 0; line-height: 1.5; }
.toc-list a { color: var(--c-link); }
.toc.collapsed .toc-list { display: none; }
.toc.collapsed .toc-header { border-bottom: none; padding-bottom: 0; margin-bottom: 0; }

/* Lede */
.lede {
    font-size: 1.02rem;
    margin-bottom: 1.2rem;
}
.lede p:first-child::first-letter {
    font-family: var(--f-serif);
    font-weight: 700;
}

/* Section structure */
hr {
    border: 0;
    border-top: 1px solid var(--c-border);
    margin: 1.6rem 0 1.4rem;
}
.article-section { margin-bottom: 1rem; scroll-margin-top: 80px; }
.article p { margin: 0 0 1rem; }
.article h2 {
    font-family: var(--f-serif);
    font-weight: 700;
    font-size: 1.5rem;
    line-height: 1.3;
    margin: 0.5rem 0 0.9rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--c-border);
    position: relative;
}
.article h3 {
    font-family: var(--f-serif);
    font-weight: 700;
    font-size: 1.18rem;
    line-height: 1.35;
    margin: 1.2rem 0 0.6rem;
    color: var(--c-text);
    scroll-margin-top: 80px;
}
.article h2 .anchor {
    position: absolute;
    left: -1.4rem;
    top: 0.05rem;
    color: var(--c-link);
    font-family: var(--f-mono);
    font-weight: 400;
    font-size: 0.95rem;
    opacity: 0;
    transition: opacity 120ms linear;
    text-decoration: none;
}
.article h2 .anchor::before { content: "#"; }
.article h2:hover .anchor { opacity: 1; }
.article h2 .anchor:hover { text-decoration: none; opacity: 1; }

/* Lists */
.prose-list, .seealso-list {
    padding-left: 1.4rem;
    margin: 0 0 1rem;
}
.prose-list li, .seealso-list li {
    margin: 0.3rem 0;
    line-height: 1.7;
}
.seealso-list {
    columns: 2;
    column-gap: 2rem;
    list-style: square;
}

/* Footnote markers */
sup.ref {
    font-family: var(--f-mono);
    font-size: 0.7rem;
    color: var(--c-link);
    cursor: pointer;
    padding: 0 1px;
    border-radius: 2px;
    transition: background 120ms linear;
    vertical-align: super;
    line-height: 0;
}
sup.ref::before { content: "["; }
sup.ref::after  { content: "]"; }
sup.ref:hover { background: var(--c-highlight); }
sup.ref.active { background: var(--c-highlight); }

/* Callout */
.callout {
    border-left: 3px solid var(--c-link);
    background: var(--c-panel);
    padding: 0.8rem 1rem;
    margin: 1rem 0 1.2rem;
    border-radius: 0 2px 2px 0;
}
.callout-label {
    font-family: var(--f-mono);
    font-size: 0.72rem;
    color: var(--c-link);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 0.3rem;
}
.callout p { margin: 0; }

/* Data table */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--c-border);
    border-radius: 2px;
    margin: 1rem 0 1.4rem;
    background: var(--c-bg);
}
.data-table {
    border-collapse: collapse;
    width: 100%;
    font-size: 0.9rem;
}
.data-table thead th {
    background: var(--c-highlight);
    border-bottom: 1px solid var(--c-border);
    text-align: left;
    padding: 8px 12px;
    font-family: var(--f-sans);
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--c-text);
}
.data-table tbody td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--c-border);
    vertical-align: top;
}
.data-table tbody tr:nth-child(even) td { background: var(--c-panel); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--c-highlight); }

/* References list */
.references-list {
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: refnum;
    font-size: 0.9rem;
}
.references-list li {
    padding: 0.4rem 0 0.4rem 2.2rem;
    border-bottom: 1px dotted var(--c-border);
    position: relative;
    line-height: 1.6;
    transition: background 120ms linear;
}
.references-list li:last-child { border-bottom: none; }
.references-list li.target { background: var(--c-highlight); }
.references-list .ref-num {
    position: absolute;
    left: 0;
    top: 0.4rem;
    width: 1.8rem;
    text-align: right;
    font-family: var(--f-mono);
    font-size: 0.78rem;
    color: var(--c-link);
}

/* Article footer */
.article-footer {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--c-border);
    font-family: var(--f-mono);
    font-size: 0.78rem;
    color: var(--c-muted);
}
.article-footer-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: space-between;
}
.article-footer a { color: var(--c-link); }

/* ---------- Sidebar ---------- */
.sidebar {
    position: sticky;
    top: 80px;
    align-self: start;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    padding-right: 4px;
    scrollbar-width: thin;
    scrollbar-color: var(--c-border) transparent;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--c-border); border-radius: 3px; }

/* Infobox */
.infobox {
    border: 1px solid var(--c-border);
    border-radius: 2px;
    background: var(--c-panel);
    overflow: hidden;
    font-size: 0.85rem;
}
.infobox-header {
    background: var(--c-highlight);
    padding: 8px 12px;
    border-bottom: 1px solid var(--c-border);
    font-family: var(--f-serif);
    font-weight: 700;
    font-size: 0.98rem;
    color: var(--c-text);
}
.infobox-subhead {
    padding: 6px 12px;
    border-bottom: 1px solid var(--c-border);
    font-family: var(--f-mono);
    font-size: 0.72rem;
    color: var(--c-muted);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    background: var(--c-bg);
}
.infobox-list { margin: 0; padding: 0; }
.infobox-row {
    display: grid;
    grid-template-columns: 120px 1fr;
    border-bottom: 1px solid var(--c-border);
}
.infobox-row:last-child { border-bottom: none; }
.infobox-row:nth-child(even) { background: var(--c-bg); }
.infobox-row dt {
    margin: 0;
    padding: 8px 10px;
    background: var(--c-panel);
    border-right: 1px solid var(--c-border);
    font-family: var(--f-sans);
    font-weight: 700;
    font-size: 0.78rem;
    color: var(--c-text);
    line-height: 1.3;
}
.infobox-row:nth-child(even) dt { background: var(--c-panel); }
.infobox-row dd {
    margin: 0;
    padding: 8px 10px;
    font-family: var(--f-mono);
    font-size: 0.78rem;
    color: var(--c-text);
    line-height: 1.4;
}
.dt-sub {
    display: block;
    font-family: var(--f-mono);
    font-size: 0.66rem;
    font-weight: 400;
    color: var(--c-muted);
    margin-top: 2px;
    letter-spacing: 0.02em;
}
.infobox-footer {
    background: var(--c-bg);
    padding: 6px 12px;
    border-top: 1px solid var(--c-border);
    display: flex;
    justify-content: space-between;
    font-family: var(--f-mono);
    font-size: 0.7rem;
    color: var(--c-muted);
    letter-spacing: 0.02em;
}
.infobox-footer .key { text-transform: uppercase; }
.infobox-footer .val { color: var(--c-text); }

/* Side cards */
.side-card {
    border: 1px solid var(--c-border);
    border-radius: 2px;
    background: var(--c-bg);
    overflow: hidden;
    font-size: 0.85rem;
}
.side-card-header {
    background: var(--c-panel);
    padding: 8px 12px;
    border-bottom: 1px solid var(--c-border);
    font-family: var(--f-sans);
    font-weight: 700;
    font-size: 0.78rem;
    color: var(--c-text);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.side-card-list, .lang-list, .rev-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.side-card-list li {
    padding: 6px 12px;
    border-bottom: 1px dotted var(--c-border);
    font-family: var(--f-sans);
    font-size: 0.85rem;
}
.side-card-list li:last-child { border-bottom: none; }
.side-card-list a {
    display: block;
    color: var(--c-link);
}
.side-card-list a.active {
    background: var(--c-highlight);
    margin: -6px -12px;
    padding: 6px 12px;
    border-left: 2px solid var(--c-link);
}
.side-card-list a:hover { text-decoration: underline; }

/* Languages */
.lang-list li {
    padding: 5px 12px;
    border-bottom: 1px dotted var(--c-border);
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
    font-size: 0.82rem;
}
.lang-list li:last-child { border-bottom: none; }
.lang-list a { color: var(--c-link); }
.lang-native {
    font-family: var(--f-mono);
    font-size: 0.74rem;
    color: var(--c-muted);
}

/* Revisions */
.rev-list li {
    padding: 8px 12px;
    border-bottom: 1px dotted var(--c-border);
    font-family: var(--f-mono);
    font-size: 0.74rem;
    color: var(--c-muted);
    line-height: 1.45;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 8px;
}
.rev-list li:last-child { border-bottom: none; }
.rev-list .rev-date { color: var(--c-link); }
.rev-list .rev-author { color: var(--c-text); }
.rev-list .rev-note {
    grid-column: 1 / -1;
    color: var(--c-muted);
}

/* ---------- Footnote popover ---------- */
.footnote-popover {
    position: absolute;
    z-index: 100;
    max-width: 320px;
    padding: 8px 12px;
    background: var(--c-bg);
    border: 1px solid var(--c-border);
    border-left: 3px solid var(--c-link);
    box-shadow: 0 2px 8px rgba(26, 26, 26, 0.08);
    font-family: var(--f-sans);
    font-size: 0.82rem;
    line-height: 1.5;
    color: var(--c-text);
    border-radius: 2px;
    pointer-events: none;
    opacity: 0;
    transform: translateY(-2px);
    transition: opacity 120ms linear, transform 120ms linear;
}
.footnote-popover.visible {
    opacity: 1;
    transform: translateY(0);
}
.footnote-popover .fp-label {
    font-family: var(--f-mono);
    font-size: 0.7rem;
    color: var(--c-link);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    display: block;
    margin-bottom: 3px;
}

/* ---------- Page footer ---------- */
.page-footer {
    background: var(--c-panel);
    border-top: 1px solid var(--c-border);
    margin-top: 3rem;
    padding: 2rem 1.25rem 1rem;
    font-size: 0.85rem;
    color: var(--c-text);
}
.page-footer-inner {
    max-width: var(--max-w);
    margin: 0 auto;
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 2rem;
}
.footer-col .footer-title {
    font-family: var(--f-serif);
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 0.6rem;
    color: var(--c-text);
}
.footer-col p {
    margin: 0;
    color: var(--c-muted);
    font-size: 0.85rem;
    line-height: 1.6;
}
.footer-col ul {
    list-style: none;
    margin: 0;
    padding: 0;
}
.footer-col li { margin: 0.25rem 0; }
.footer-col a { color: var(--c-link); }
.page-footer-meta {
    max-width: var(--max-w);
    margin: 1.5rem auto 0;
    padding-top: 1rem;
    border-top: 1px solid var(--c-border);
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    font-family: var(--f-mono);
    font-size: 0.74rem;
    color: var(--c-muted);
    letter-spacing: 0.02em;
}
.page-footer-meta a { color: var(--c-link); }

/* ---------- Reading progress (subtle) ---------- */
.reading-progress {
    position: fixed;
    top: 56px;
    left: 0;
    height: 2px;
    background: var(--c-link);
    width: 0;
    z-index: 60;
    transition: width 80ms linear;
}

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
    .layout {
        grid-template-columns: 1fr;
    }
    .sidebar {
        position: static;
        max-height: none;
    }
    .article { max-width: 100%; }
    .seealso-list { columns: 1; }
}

@media (max-width: 720px) {
    .site-header-inner {
        grid-template-columns: 1fr auto;
        gap: 1rem;
    }
    .site-nav { display: none; }
    .search-input { width: 160px; }
    .page-footer-inner {
        grid-template-columns: 1fr 1fr;
    }
    .article h2 .anchor {
        position: static;
        opacity: 1;
        margin-right: 0.4rem;
    }
    .article-meta { font-size: 0.72rem; }
    .infobox-row { grid-template-columns: 100px 1fr; }
}

@media (max-width: 480px) {
    .page-footer-inner {
        grid-template-columns: 1fr;
    }
    .breadcrumb { font-size: 0.78rem; }
}
