/* System 2 wiki_viewer theme — pure CSS, no JS.
 * Familien-Chrome (Gestaltungsantrag 08.09., Kanon-Port 28.09.): dunkler
 * Kopf-/Fussbalken full-bleed, weisse Karte im 1060-Track buendig an beide
 * Balken. Kanon 28.09.: Karteninneres ohne Dunkelblau und ohne Hellblau,
 * Tinte #16191c, Linien neutral #d8d6d0, Leder #001028 nur im Chrome,
 * Gold nur als Linie, hover = gold underline statt Farbwechsel. Typo:
 * Georgia-Koerper, Grotesk fuer Chrome und Kleintypo.
 * Styling for the living vault renderer: wikilinks, statement refs,
 * [SYNTH]/as-of badges, A-Z listings, search results, breadcrumbs and
 * the source-view verbatim highlight (mark:target). */

:root {
    /* Kanon 28.09. (E1, Owner abgenommen): Tinte #16191c, Linien neutral
       #d8d6d0, Feld/Band #f2f1ee, Gold #c98a32 nur als Linie, hover = goldener
       Unterstrich statt Farbwechsel. Drift-Farben (Marine, Stahl, Rot) raus. */
    --ink: #16191c;
    --ink-mid: #16191c;
    --chrome: #16191c;
    --world: #f1ead9;
    --bund: #d8d6d0;
    --tint: #f2f1ee;
    --gold-line: #c98a32;
    --gold-text: #8a5a16;
    /* uebernommene Tokens (abwaertskompatibel) */
    --bg: #ffffff;
    --surface: #ffffff;
    --border: #d8d6d0;
    --text: var(--ink);
    --text-muted: var(--ink-mid);
    --accent: var(--gold-line);
    --synth-bg: #fff4d6;
    --synth-ink: var(--gold-text);
    --synth-border: #ecd9a0;
    --asof-ink: #5d646e; /* >=4.5:1 on white (UI-audit #30) */
    --missing-ink: var(--ink);
    --highlight: #ffe066;
    --serif: Georgia, "Times New Roman", "Liberation Serif", serif;
    --sans: "Helvetica Neue", Helvetica, Arial, sans-serif;
    --maxw: 1060px;
}

* { box-sizing: border-box; }

html { background: var(--world); }

body {
    font-family: var(--serif);
    max-width: none;
    margin: 0;
    padding: 0;
    line-height: 1.5;
    font-size: 17px;
    background: var(--world);
    color: var(--text);

    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--ink); text-decoration: underline; text-underline-offset: .13em; }
/* Kanon 28.09.: hover = gold underline statt Farbwechsel */
a:hover { text-decoration-color: var(--gold-line); }

/* --- Kopf: full-bleed-Chrome, Track zentriert --------------------------- */
.site-top {
    background: var(--chrome);
    color: #fff;
    padding: .7rem 1rem;
    padding-inline: max(1rem, calc((100% - var(--maxw)) / 2));
}
.top-inner {
    max-width: var(--maxw);
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    gap: .5rem 1.2rem;
    align-items: center;
    justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: .55rem; text-decoration: none; color: #fff; }
.brand img { width: 38px; height: 38px; display: block; }
.bname { font-family: var(--serif); font-size: 1.2rem; letter-spacing: .02em; line-height: 1.15; }
.btld { display: block; font-family: var(--sans); font-size: .7rem; font-weight: 400; letter-spacing: .11em; text-transform: uppercase; color: #fff; }
.world-nav { display: flex; flex-wrap: wrap; align-self: center; margin-bottom: 0 !important; }
.world-nav a {
    font-family: var(--sans);
    color: #dcdcdc;
    margin-left: 1rem;
    font-size: .88rem;
    letter-spacing: .04em;
    text-decoration: none;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    border-bottom: 2px solid transparent;
}
.world-nav a:hover { color: #fff; border-bottom-color: var(--gold-line); }
.world-nav a.on { color: #fff; border-bottom-color: var(--gold-line); }
.world-nav a:not(.nav-search) { line-height: 40px; transform: translateY(1px); }
.world-nav a.nav-search { border: 1px solid #5a5f66; border-radius: 3px; padding: .3rem .8rem; margin-left: 1rem; }
.world-nav a.nav-search:hover { border-color: var(--gold-line); }

/* --- Karte: buendig unter dem Kopf, Welt nur seitlich -------------------- */
.container {
    background: var(--surface);
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 1.6rem clamp(1.4rem, 4vw, 2.6rem) 2.4rem;
    border-left: 1px solid var(--bund);
    border-right: 1px solid var(--bund);
    border-radius: 0;
    box-shadow: none;
}

/* --- Fuss: full-bleed-Chrome, in der Karte buendig ----------------------- */
/* Kurze Seiten: das Fuss-Band wachst bis zur Viewport-Unterkante, damit unten
   nie Feld-Farbe unter dem Band steht (Footer schliesst die Seite ab). */
.bot { background: var(--chrome);
    flex-shrink: 0;
    padding: 1rem;
    padding-inline: max(1rem, calc((100% - var(--maxw)) / 2));
    border-top: 3px double var(--gold-line); }
/* Kurze Seiten: der Fueller uebernimmt den Rest bis Viewport-Unterkante und
   zeigt genau dort eine goldene Hairline unter dem Fussband. Auf langen Seiten
   ist er 0px hoch und die Linie ist per overflow hidden abgeschnitten. */
.bot-fill { flex: 1 0 0px; min-height: 0; position: relative; overflow: hidden;
    background: var(--chrome); }
/* Kurze Seiten: der Füller wächst und füllt Navy bis Viewport-Unterkante, die
   Gold-Hairline sitzt oben auf. Lange Seiten: flex-Basis 0 und kein freier Raum
   => 0px hoch, nichts sichtbar, Dokumentende exakt wie vorher. */
.bot-fill::before { content: ""; position: absolute; top: 0; left: 0; right: 0;
    border-top: 1px solid var(--gold-line); }
.bot-inner { max-width: var(--maxw); margin: 0 auto; }
.foot-brand { margin: 0 0 .5rem; color: #b9bcc2; font-family: var(--sans); font-size: .82rem; max-width: 60em; }
footer.site-footer {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    margin-top: 0; padding-top: 0;
    border-top: none;
    color: #dcdcdc; font-family: var(--sans); font-size: .84rem; line-height: 1.5;
}
footer.site-footer a, footer.site-footer .footer-stand { color: #fff; }
footer.site-footer a { text-decoration: none; border-bottom: 1px solid transparent; }
footer.site-footer a:hover { border-bottom-color: var(--gold-line); }
footer.site-footer a + a { margin-left: 1.2rem; }
.footer-stand, .generated-stamp { color: #9ea3aa; }

/* --- Masthead within content pages -------------------------------------- */
h1 {
    font-size: 1.65rem; font-weight: 400; line-height: 1.22;
    margin: 0 0 .8rem; padding-bottom: .5rem;
    border-bottom: 2px solid var(--ink);
    overflow-wrap: anywhere;
}
h2 {
    font-size: 1.13rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
    margin: 2rem 0 .5rem; padding-bottom: .3rem;
    border-bottom: 1px solid var(--gold-line);
}
h3 { font-size: 1.02rem; margin: 1.5rem 0 .4rem; }
p { overflow-wrap: break-word; }

nav { margin-bottom: 20px; }
nav a { color: var(--ink); text-decoration: none; }
nav a:hover { text-decoration: underline; }

/* --- breadcrumbs -------------------------------------------------------- */
.breadcrumbs {
    font-family: var(--sans);
    font-size: .8rem;
    color: var(--ink-mid);
    border-bottom: 0;
    padding-bottom: 0;
    margin-bottom: 1.1rem;
}
.breadcrumbs a { color: var(--ink-mid); text-decoration: underline; text-underline-offset: .13em; }
.breadcrumbs a:hover { text-decoration-color: var(--gold-line); }
.breadcrumbs .crumb-current { color: var(--ink); }

/* --- wikilinks ---------------------------------------------------------- */
a.wikilink { color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--bund); }
a.wikilink:hover { border-bottom-color: var(--gold-line); text-decoration: none; }

/* target .md missing: link kept, styled as dangling */
a.wikilink.missing-link {
    color: var(--missing-ink);
    text-decoration-style: dotted;
    border-bottom: 1px dotted var(--missing-ink);
}

/* --- statement refs [s<id>] → /quelle/<id>.html#stmt-<n> ----------------- */
a.stmt-ref {
    color: var(--gold-text);
    font-family: var(--sans);
    font-size: .86em;
    text-decoration: none;
    font-weight: 600;
    border-bottom: 1px dotted var(--gold-text);
}
a.stmt-ref:hover { text-decoration: underline; color: var(--gold-text); border-bottom-color: var(--gold-line); }

/* --- W3-B: ## Auslegung reading-budget fold ------------------------------ */
/* Clusters beyond the budget land in <details class="auslegung-more">
   (wv_fold_auslegung_more); the seed tags the bullet list itself
   .auslegung-bullets. Native <details> only — zero JS. */
details.auslegung-more {
    margin: 0.5rem 0 1rem;
    border: 1px solid var(--bund);
    border-radius: 0;
    padding: 0.25rem 0.75rem;
    background: rgba(241, 234, 217, 0.4);
}
details.auslegung-more > summary {
    cursor: pointer;
    font-family: var(--sans);
    font-weight: 600;
    font-size: .9em;
    color: var(--gold-text);
    padding: 0.25rem 0;
}
details.auslegung-more > summary::marker { color: var(--gold-text); }
details.auslegung-more[open] > summary { margin-bottom: 0.25rem; }
ul.auslegung-bullets { margin-top: 0.4rem; }

/* --- badges / notes ------------------------------------------------------ */
span.synth-badge {
    font-family: var(--sans);
    background: var(--synth-bg);
    color: var(--synth-ink);
    border: 1px solid var(--synth-border);
    border-radius: 0;
    padding: 0 4px;
    font-size: .78em;
    font-weight: 600;
    letter-spacing: .04em;
    white-space: nowrap;
}

span.asof-note {
    font-family: var(--sans);
    color: var(--asof-ink);
    font-size: .84em;
    font-style: italic;
    white-space: nowrap;
}

/* --- source views (pre-generated, /quelle/<id>.html) ----------------------
 * All statement marks are INVISIBLE by default — the source text stays
 * clean (user feedback 2026-08-26: no highlight noise); only the
 * fragment-target mark (the clicked passage) is highlighted. */
mark { background: transparent; color: inherit; }
mark:target {
    background: var(--highlight);
    outline: 2px solid var(--gold-line);
    border-radius: 2px;
}

/* Cross-decision deep links land on a claim wrapped by the viewer as
   <span class="xref-target" id="sN"> — highlight it exactly like the
   source-view verbatim mark above (visual parity by the same tokens). */
.xref-target:target {
    background: var(--highlight);
    outline: 2px solid var(--gold-line);
    border-radius: 2px;
}

/* Multi-claim spans ("…[s1201]. …[s1217]") wrap as ONE outer span whose
   id is the first sid; later sids are zero-size inner anchors. :has()
   lifts the highlight to the visible claim when a deep link lands on an
   inner anchor. */
.xref-target:has(> .xref-sub:target) {
    background: var(--highlight);
    outline: 2px solid var(--gold-line);
    border-radius: 2px;
}

/* --- landing / search ----------------------------------------------------- */
.landing { border-bottom: 1px solid var(--bund); margin-bottom: 24px; padding-bottom: 16px; }

/* UI-audit R3 U1: the landing H1 is one long German composite — keep
   overflow-wrap:anywhere (width-safe at 390px). */
.landing h1 { overflow-wrap: anywhere; font-size: 1.9rem; }

.landing-sub { color: var(--ink-mid); font-size: 1.08rem; font-style: italic; max-width: 42em; }
.landing-hubs { font-family: var(--sans); font-size: .9rem; letter-spacing: .04em; text-transform: uppercase; }
.landing-hubs a { color: var(--ink); border-bottom: 2px solid var(--gold-line); }
.landing-updated { font-family: var(--sans); color: var(--ink-mid); font-size: .84rem; }

.search-form { margin: 1.2rem 0; display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.search-form input[type="search"] {
    font-family: var(--sans);
    padding: 8px 12px;
    font-size: .95rem;
    border: 1px solid var(--bund);
    border-radius: 0;
    min-height: 44px;
    width: 55%;
    max-width: 360px;
    background: #fff;
    color: var(--ink);
}
.search-form input[type="search"]:focus { outline: 2px solid var(--gold-line); outline-offset: 1px; }
.search-form button {
    font-family: var(--sans);
    padding: 8px 16px;
    font-size: .95rem;
    min-height: 44px;
    border: 1px solid var(--ink);
    background: var(--ink);
    color: #fff;
    border-radius: 0;
    cursor: pointer;
    letter-spacing: .04em;
}
.search-form button:hover { background: var(--chrome); border-color: var(--chrome); }

.result-count { color: var(--text-muted); font-family: var(--sans); }
.search-results { list-style: none; padding-left: 0; }
.search-results li { margin-bottom: 14px; }
.result-title {
    color: var(--ink);
    font-family: var(--serif);
    font-weight: 400;
    font-size: 1.05em;
    text-decoration: none;
    border-bottom: 1px solid var(--bund);
}
.result-title:hover { border-bottom-color: var(--gold-line); }
.result-rel { color: var(--text-muted); font-family: var(--sans); font-size: .8em; margin-left: 8px; overflow-wrap: anywhere; }
.result-snippet { margin: 4px 0 0; color: var(--text-muted); font-size: .92em; }

/* UI-audit #14: did-you-mean suggestions on a zero-result search */
.search-suggestions { margin: 4px 0 12px; padding-left: 20px; }
.search-suggestions a { font-weight: 700; color: var(--gold-text); }

.empty-listing { color: var(--text-muted); font-style: italic; }

/* --- A–Z directory listing ------------------------------------------------ */
.az-listing .az-letter {
    font-family: var(--sans);
    border-bottom: 1px solid var(--gold-line);
    margin: 18px 0 8px;
    color: var(--ink);
    font-size: .95em;
    letter-spacing: .08em;
    text-transform: uppercase;
}
.az-items { list-style: none; padding-left: 0; margin: 0; columns: 2; }
.az-items li { margin-bottom: 4px; }
.az-items a { color: var(--ink); text-decoration: none; border-bottom: 1px solid transparent; }
.az-items a:hover { text-decoration: none; border-bottom-color: var(--gold-line); }

/* --- generic markdown ------------------------------------------------------ */
table { border-collapse: collapse; width: 100%; margin: 20px 0; font-size: .95em; }
th, td { border: 1px solid var(--border); padding: 10px 12px; text-align: left; vertical-align: top; }
th { background: var(--world); font-family: var(--sans); font-size: .88em; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-mid); }

blockquote {
    border-left: 3px solid var(--gold-line);
    padding-left: 15px;
    margin-left: 20px;
    color: var(--ink-mid);
    font-style: italic;
}

pre {
    background: #f2f1ee;
    border: 1px solid var(--bund);
    border-radius: 0;
    padding: 10px;
    overflow-x: auto;
}
code { background: #f2f1ee; border-radius: 0; padding: 0 3px; }
pre code { background: none; padding: 0; }

/* --- source view structure (UI-audit Cluster B, 2026-09-03) -------------- */
/* UI-audit R3 U7 (finding #14): dl.source-header keeps its compact card —
   label column muted, tight rows, long URLs may break. */
dl.source-header {
    border: 1px solid var(--bund);
    border-radius: 0;
    background: rgba(241, 234, 217, 0.45);
    padding: 10px 14px;
    margin: 0 0 1.2em 0;
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 2px 12px;
    font-size: .93em;
}
dl.source-header dt { color: var(--ink-mid); font-weight: 700; font-family: var(--sans); font-size: .88em; letter-spacing: .04em; text-transform: uppercase; }
dl.source-header dd { margin: 0; overflow-wrap: anywhere; }

.source-toc {
    border: 1px solid var(--bund);
    border-radius: 0;
    padding: 10px 16px;
    margin-bottom: 20px;
    font-size: .92em;
    font-family: var(--sans);
}
.source-toc h2 {
    font-size: .95em; margin: 0 0 6px; color: var(--ink-mid);
    border-bottom: 0; padding-bottom: 0; letter-spacing: .1em;
}
.source-toc ol { margin: 0; padding-left: 20px; columns: 2; column-gap: 24px; }
.source-toc li { margin: 2px 0; }
h2.src-erw, h2.src-part {
    margin-top: 1.6em;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    text-transform: none; letter-spacing: 0; font-weight: 400; font-size: 1.25em;
    font-family: var(--serif);
}
h2.src-erw { border-bottom: 1px solid var(--gold-line); }
h2.src-erwN { margin-top: 1.4em; }
h3.src-erwN { margin-top: 1.1em; font-size: 1.05em; }
/* UI-audit R3 P1-10: old exports separate blocks with "*****…" fills;
   rendered as a real rule instead of a literal asterisk paragraph. */
hr.src-sep { border: 0; border-top: 1px solid var(--border); margin: 1.6em auto; }
/* jump targets need breathing room */
[id^="erw"], [id^="part-"], [id^="stmt-"], .xref-target { scroll-margin-top: 12px; }

.source-footer {
    margin-top: 32px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.9em;
}
.mark-legend { font-style: italic; }

/* A4: deep link to a non-existent stmt-N shows a notice (2026-09-03) */
.anchor-missing {
    border: 1px solid var(--gold-line);
    background: rgba(212, 168, 0, 0.12);
    border-radius: 0;
    padding: 10px 14px;
    margin: 0 0 1em 0;
    font-size: 0.95em;
}
/* UI-audit R3 K4: per-anchor Rücklink "↩ zitiert in …#sN" (source view) */
.src-backlink { font-size: 0.85em; font-style: italic; white-space: nowrap; font-family: var(--sans); }
.src-backlink a { margin-left: 0.25em; }
/* UI-audit R3 K4 banner: «Sie sind hier wegen Aussage X» */
.stmt-banner {
    border-left: 4px solid var(--gold-line);
    background: rgba(212, 168, 0, 0.08);
    padding: 8px 12px;
    margin: 0 0 1em 0;
}
/* UI-audit R3 U6b: aria-live region is visually hidden but SR-visible */
.sr-live {
    position: absolute; width: 1px; height: 1px; margin: -1px;
    clip: rect(0 0 0 0); clip-path: inset(50%); overflow: hidden;
    white-space: nowrap;
}
/* UI-audit R3 K5: "Zitat kopieren" button after each marked statement */
.cite-copy {
    font-family: var(--sans); font-size: 0.8em; cursor: pointer;
    border: 1px solid var(--bund); border-radius: 0;
    background: #f2f1ee; padding: 1px 8px; margin: 0 0 0.6em 0;
}
.cite-copy:focus-visible { outline: 2px solid var(--gold-line); outline-offset: 2px; }
/* A5: stmt-ref links are touch targets and announce themselves */
a.stmt-ref { padding: 2px 4px; margin: -2px -4px; border-radius: 0; }
@media (pointer: coarse) {
    a.stmt-ref { padding: 12px 6px; margin: -12px -6px; }
}

/* --- UI-audit Cluster E/F pass (2026-09-03) ------------------------------ */

/* #30: in-text deep-link target highlight (wiki pages mark ids too) */
mark:target, span[id^="s"]:target {
    scroll-margin-top: 12px;
}

/* #26 + UI-audit R3 U9-Mini: measure — the body text column stays at
   66ch inside the 1060 card; with margin-inline:auto it is optically
   left-aligned by the card's generous padding instead of floating. */
main {
    max-width: 66ch;
    margin-inline: auto;
}

/* #27: touch targets — breadcrumbs, footer and search controls reach 44px
   on coarse pointers without growing the visual box on desktop. */
@media (pointer: coarse) {
    .breadcrumbs a, .site-footer a {
        display: inline-block;
        padding: 10px 8px;
        margin: -10px -8px;
    }
    .search-form input[type="search"],
    .search-form button {
        padding: 10px 14px;
        min-height: 44px;
    }
    .az-items a {
        display: inline-block;
        padding: 8px 4px;
    }
    .world-nav a { min-height: 44px; }
}

/* #30 + #24: real responsive pass. */
@media (max-width: 640px) {
    body { font-size: 16px; }
    .container { padding-inline: 1.1rem; }
    .top-inner { gap: .4rem .8rem; }
    .world-nav { flex: 1 1 100%; justify-content: space-between; }
    .world-nav a { margin-left: 0; font-size: .84rem; }
    .site-footer { flex-direction: column; gap: .35rem; }
    .az-items { columns: 1; }
    .source-toc ol { columns: 1; }
    .search-form input[type="search"] { width: 100%; max-width: none; }
}

/* #30: print — no shadows, no chrome, expanded links */
@media print {
    html, body { background: #fff; }
    .site-top, .bot, .bot-fill, .search-form, .source-footer nav, .breadcrumbs { display: none; }
    .container { border: 0; padding: 0; max-width: none; }
    a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.8em; color: #555; }
    mark:target { outline: none; background: #ffeb3b; }
}

/* #31: skip link — offscreen until focused */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--ink);
    color: #fff;
    padding: 10px 16px;
    z-index: 10;
}
.skip-link:focus {
    left: 8px;
    border-radius: 0 0 6px 0;
}

/* --- Beratung-Welt (beratung.bacsol.ch): Kanon 28.09. (E1 abgenommen)
   Aussenraum = Graphit-Feld #b7c1cc, Balken = Leder #001028 (nur Chrome),
   Karte weiss. Karteninneres: Tinte #16191c, Band #f2f1ee, Linien neutral
   #d8d6d0, Gold #c98a32 nur als Linie, hover = gold underline. Kein
   Dunkelblau, kein Hellblau, kein Leder als Flaeche im Content. */
html.beratung { --world: #b7c1cc; --chrome: #001028; --ink: #16191c; --text: #16191c; --gold-text: #16191c; }
html.beratung body { background: var(--world); }
/* BacSol-Wappen auf Leder: die marineblauen Strahlen bleiben sichtbar,
   Kanon 28.09. verlangt keinen goldenen Heiligenschein. */
html.beratung .world-nav a { color: #fff; }
html.beratung .world-nav a.nav-search { border-color: #fff; }
html.beratung .world-nav a.nav-search:hover { border-color: var(--gold-line); }
html.beratung footer.site-footer { border-top: none; }
html.beratung .foot-brand { color: #fff; }
html.beratung .footer-stand, html.beratung .generated-stamp { color: #fff; }
/* Karten-Seitenkante im kuehlen Feld: neutrale Linie, kein kuehles Bund */
html.beratung .container { border-left-color: #d8d6d0; border-right-color: #d8d6d0; }
/* th-Flaeche = Band-Tint (Basis nutzt --world, waere hier eine blaue Flaeche) */
html.beratung th { background: var(--tint); }
/* Track-Test wide 09.09. verworfen: Standard 1060 bleibt.
   Brüder-Entscheid 09.09.: Der Fliesstext geht über die ganze Karte wie auf
   electioninfo.ch — keine 66ch-Mittelspalte, keine Randfelder links/rechts
   (die wie ein Seitenmenü wirkten). Gilt nur für die Beratung-Welt; die Wiki-
   Basis behält ihren 66ch-Spiegel. BEIM Wiederkopieren des Wiki-CSS diese
   Override-Zeile wieder anhängen. */
html.beratung main { max-width: none; }
