/* ─────────────── the margin — site-wide reference + discuss drawer ───────────────
   Present on every page (injected by base.html). Brutalist, matches the shell. */

:root { --margin-w: 380px; }

/* the launcher — prominent tabs jutting from the right edge */
#margin-launcher {
    position: fixed; right: 0; top: 50%; transform: translateY(-50%);
    z-index: 900; display: flex; flex-direction: column; gap: 10px;
}
#margin-launcher button {
    writing-mode: vertical-rl; text-orientation: mixed;
    background: #fffacd; color: #000; border: 2px solid #000; border-right: 0;
    cursor: pointer; font-family: ui-monospace, Menlo, monospace; font-size: 13px;
    font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase;
    padding: 18px 11px; border-radius: 7px 0 0 7px;
    box-shadow: -3px 3px 0 rgba(0, 0, 0, 0.85);
    transition: background 0.12s ease, color 0.12s ease, transform 0.12s ease;
}
#margin-launcher button::before {
    content: "◆"; writing-mode: horizontal-tb; display: block;
    font-size: 11px; margin-bottom: 7px; text-align: center;
}
#margin-launcher button:hover { background: #000; color: #fff; transform: translateX(-3px); }
/* a one-time attention pulse so first-time visitors notice the tabs */
@keyframes margin-nudge {
    0%, 100% { transform: translateX(0); }
    50%      { transform: translateX(-6px); }
}
#margin-launcher.nudge button { animation: margin-nudge 0.5s ease-in-out 2; }
@media (prefers-reduced-motion: reduce) {
    #margin-launcher.nudge button { animation: none; }
}

/* the drawer */
#margin-drawer {
    position: fixed; top: 0; right: 0; height: 100vh; width: var(--margin-w);
    max-width: 92vw; background: #fff; border-left: 2px solid #000; z-index: 1000;
    transform: translateX(100%); transition: transform 0.18s ease-out;
    display: flex; flex-direction: column; box-shadow: -6px 0 0 rgba(0,0,0,0.08);
}
#margin-drawer.open { transform: translateX(0); }
#margin-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,0.18); z-index: 999;
    opacity: 0; pointer-events: none; transition: opacity 0.18s;
}
#margin-backdrop.open { opacity: 1; pointer-events: auto; }

.margin-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 14px; border-bottom: 2px solid #000; flex: 0 0 auto;
}
.margin-head .mh-title { font-family: ui-monospace, Menlo, monospace; font-size: 13px;
    font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; }
.margin-head .mh-close { background: none; border: 0; font-size: 20px; cursor: pointer;
    line-height: 1; padding: 0 4px; }
.margin-head .mh-close:hover { background: #fffacd; }

.margin-tabs { display: flex; border-bottom: 1px solid #000; flex: 0 0 auto; }
.margin-tabs button { flex: 1; background: #fff; border: 0; border-right: 1px solid #000;
    padding: 9px 8px; cursor: pointer; font-family: ui-monospace, Menlo, monospace;
    font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.margin-tabs button:last-child { border-right: 0; }
.margin-tabs button.active { background: #000; color: #fff; }
.margin-tabs button:not(.active):hover { background: #fffacd; }

.margin-body { flex: 1 1 auto; overflow-y: auto; padding: 14px; }
.margin-pane { display: none; }
.margin-pane.active { display: block; }

/* witness line */
.margin-witness { font-family: ui-monospace, Menlo, monospace; font-size: 11px;
    color: #555; margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid #ddd; }
.margin-witness a { color: #000; }

/* reference search */
.margin-search-input { width: 100%; padding: 8px 10px; border: 1px solid #000;
    font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
.margin-results { list-style: none; padding: 0; margin: 12px 0 0; }
.margin-results li { border-bottom: 1px solid #000; }
.margin-results li:first-child { border-top: 1px solid #000; }
.margin-result { display: block; padding: 8px 6px; text-decoration: none; color: #000; }
.margin-result:hover { background: #fffacd; }
.margin-result .mr-label { font-weight: 700; font-size: 14px; }
.margin-result .mr-kind { font-family: ui-monospace, Menlo, monospace; font-size: 10px;
    text-transform: uppercase; letter-spacing: 0.4px; color: #555; margin-left: 6px; }
.margin-result .mr-one { display: block; font-size: 12px; color: #444; line-height: 1.4; margin-top: 2px; }
.margin-hint { font-size: 12px; color: #777; font-style: italic; margin-top: 10px; }

/* discuss pane */
.margin-topic { font-size: 12px; color: #555; margin-bottom: 12px; }
.margin-topic strong { color: #000; }
.margin-topic .mt-kind { display: inline-block; border: 1px solid #000; padding: 0 5px;
    font-family: ui-monospace, Menlo, monospace; font-size: 10px; text-transform: uppercase;
    letter-spacing: 0.4px; margin-left: 4px; }

.margin-threads { list-style: none; padding: 0; margin: 0 0 14px; }
.margin-thread { padding: 9px 0; border-bottom: 1px solid #000; }
.margin-thread:first-child { border-top: 1px solid #000; }
.margin-thread a.mt-title { font-weight: 700; color: #000; text-decoration: none; font-size: 14px; }
.margin-thread a.mt-title:hover { background: #fffacd; }
.margin-thread .mt-meta { font-family: ui-monospace, Menlo, monospace; font-size: 10.5px;
    color: #555; margin-top: 3px; }
.margin-thread .mt-rel { border: 1px solid #000; padding: 0 4px; margin-left: 4px; }
.margin-thread .mt-rel.mention { border-style: dashed; }

.margin-compose { position: relative; }  /* anchor the [[ autocomplete popup */
.margin-compose label { display: block; font-family: ui-monospace, Menlo, monospace;
    font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.4px; margin: 12px 0 4px; }
.margin-compose textarea, .margin-compose input[type=text] {
    width: 100%; padding: 7px 9px; border: 1px solid #000; background: #fff;
    font-family: "Times New Roman", Times, serif; font-size: 14px; }
.margin-compose input[type=text] { font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
.margin-compose textarea { min-height: 84px; resize: vertical; }
.margin-compose button.post { background: #000; color: #fff; border: 0; padding: 9px 16px;
    font-family: ui-monospace, Menlo, monospace; font-size: 12px; font-weight: 700; cursor: pointer;
    text-transform: uppercase; letter-spacing: 0.5px; margin-top: 12px; }
.margin-compose button.post:hover { background: #fffacd; color: #000; outline: 2px solid #000; }
.margin-compose button.post:disabled { opacity: 0.5; cursor: default; }
.margin-newtopic { margin-top: 8px; font-size: 11px; }
.margin-newtopic summary { cursor: pointer; font-family: ui-monospace, Menlo, monospace;
    text-transform: uppercase; letter-spacing: 0.4px; color: #555; }
.margin-flash { margin-top: 10px; padding: 8px 10px; border: 1px solid #000; background: #fffacd;
    font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.margin-empty { font-size: 12.5px; color: #777; font-style: italic; }

@media (max-width: 640px) {
    #margin-launcher button { font-size: 10px; padding: 10px 5px; }
}
