/* DGS Community Companion — an annotated reference. The margin belongs to the readers. */
@font-face { font-family: "Literata"; font-style: normal; font-weight: 200 900; font-display: swap; src: url(../fonts/literata-latin-opsz-normal.woff2) format("woff2"); }
@font-face { font-family: "Literata"; font-style: italic; font-weight: 200 900; font-display: swap; src: url(../fonts/literata-latin-opsz-italic.woff2) format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible"; font-style: normal; font-weight: 400; font-display: swap; src: url(../fonts/atkinson-hyperlegible-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible"; font-style: normal; font-weight: 700; font-display: swap; src: url(../fonts/atkinson-hyperlegible-latin-700-normal.woff2) format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible"; font-style: italic; font-weight: 400; font-display: swap; src: url(../fonts/atkinson-hyperlegible-latin-400-italic.woff2) format("woff2"); }
:root {
  --paper: #F7F8F6;
  --surface: #FFFFFF;
  --ink: #1D2220;
  --graphite: #59615E;
  --rule: #D9DEDB;
  --focus: #2E5BD8;

  --kudos-bg: #D6EBD0;     --kudos-ink: #2E6A3A;
  --correction-bg: #F6CFC6; --correction-ink: #9C3524;
  --idea-bg: #F5E3A3;      --idea-ink: #7E5F00;
  --question-bg: #DDD7F3;  --question-ink: #4B3C8C;

  --serif: "Literata", Georgia, "Times New Roman", serif;
  --sans: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;

  --step--1: 0.875rem;
  --step-0: 1.0625rem;
  --step-1: 1.3125rem;
  --step-2: 1.75rem;
  --step-3: 2.5rem;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 1.5rem; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { animation: none !important; transition: none !important; } }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: var(--step-0);
  line-height: 1.7;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration-color: var(--graphite); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-color: var(--ink); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--graphite); }
.skip { position: absolute; left: -999px; top: 0; background: var(--ink); color: var(--paper); padding: .5rem 1rem; z-index: 50; font-family: var(--sans); }
.skip:focus { left: 1rem; top: 1rem; }

/* ---------- Layout ---------- */
.shell { display: grid; grid-template-columns: 17.5rem minmax(0, 1fr); min-height: 100vh; }
.rail { border-right: 1px solid var(--rule); background: var(--paper); font-family: var(--sans); font-size: var(--step--1); line-height: 1.45; }
.rail-inner { position: sticky; top: 0; max-height: 100vh; overflow-y: auto; padding: 1.75rem 1.25rem 2rem 1.5rem; }
main { min-width: 0; padding: 0 2rem 4rem 3rem; outline: none; }
.page { display: grid; grid-template-columns: minmax(0, 40rem) 18.5rem; column-gap: 3rem; position: relative; }

/* ---------- Rail ---------- */
.brand { margin: 0; font-family: var(--serif); font-weight: 700; font-size: 1.25rem; letter-spacing: -0.01em; }
.brand a { text-decoration: none; }
.brand-sub { margin: .25rem 0 1.25rem; color: var(--graphite); }
.rail-toggle { display: none; font: inherit; font-weight: 700; font-size: .9rem; padding: .45rem .9rem; border: 1px solid var(--ink); border-radius: 999px; background: var(--surface); color: var(--ink); cursor: pointer; }
.rail-toggle[aria-expanded="true"] { background: var(--ink); color: var(--paper); }
.search input {
  width: 100%; font: inherit; font-size: var(--step--1); padding: .55rem .7rem; border: 1px solid var(--rule);
  border-radius: 6px; background: var(--surface); color: var(--ink);
}
.view-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: .25rem; margin: .9rem 0 1.4rem; padding: .2rem; background: #ECEFEC; border-radius: 8px; }
.view-btn { flex: 1; font: inherit; font-size: .8rem; padding: .4rem .3rem; border: 0; border-radius: 6px; background: transparent; color: var(--graphite); cursor: pointer; }
.view-btn.is-on { background: var(--surface); color: var(--ink); font-weight: 700; box-shadow: 0 1px 2px rgba(29,34,32,.12); }

.toc { list-style: none; margin: 0; padding: 0; }
.toc li a { display: block; padding: .32rem .5rem; margin-left: -.5rem; border-radius: 5px; text-decoration: none; color: var(--graphite); }
.toc li a:hover { color: var(--ink); background: #ECEFEC; }
.toc li a.is-here { color: var(--ink); font-weight: 700; }
.toc li a.is-dim { opacity: .35; }
.toc-label { margin: 1.1rem 0 .3rem; color: var(--graphite); font-size: .8rem; }

.busy { margin-top: 1.6rem; padding-top: 1.1rem; border-top: 1px solid var(--rule); }
.busy h2 { font-family: var(--sans); font-size: var(--step--1); margin: 0 0 .5rem; }
.busy-list { list-style: none; margin: 0; padding: 0; }
.busy-list li { margin-bottom: .55rem; }
.busy-list button { all: unset; cursor: pointer; display: block; color: var(--ink); }
.busy-list button:focus-visible { outline: 3px solid var(--focus); }
.busy-list .q { display: block; font-family: var(--serif); font-size: .85rem; line-height: 1.4; }
.busy-list .n { color: var(--graphite); font-size: .78rem; }
.rail-foot { margin-top: 1.6rem; padding-top: 1rem; border-top: 1px solid var(--rule); }

/* ---------- Masthead ---------- */
.masthead { max-width: 40rem; padding: 4.5rem 0 2.5rem; }
.masthead h1 {
  font-family: var(--serif); font-weight: 700; font-size: var(--step-3); line-height: 1.08;
  letter-spacing: -0.022em; margin: 0 0 .7rem; text-wrap: balance; color: var(--ink);
}
.masthead .deck {
  font-family: var(--serif); font-weight: 400; font-size: 1.6rem; line-height: 1.25;
  letter-spacing: -0.01em; margin: 0 0 1.1rem; text-wrap: balance; color: #333A37;
}
.lede { font-size: 1.15rem; line-height: 1.6; color: #333A37; margin: 0 0 1.4rem; max-width: 36rem; }
.legend { display: flex; flex-wrap: wrap; gap: .5rem; font-family: var(--sans); font-size: .8rem; }
.k { padding: .15rem .55rem; border-radius: 3px; }
.k-kudos { background: var(--kudos-bg); color: var(--kudos-ink); }
.k-correction { background: var(--correction-bg); color: var(--correction-ink); }
.k-idea { background: var(--idea-bg); color: var(--idea-ink); }
.k-question { background: var(--question-bg); color: var(--question-ink); }

/* ---------- Prose ---------- */
.prose { min-width: 0; }
.sec { padding-top: 1.5rem; }
.sec + .sec { border-top: 1px solid var(--rule); margin-top: 2rem; }
.prose h2 { font-family: var(--serif); font-size: var(--step-2); line-height: 1.2; letter-spacing: -0.012em; margin: .5rem 0 1rem; text-wrap: balance; }
.prose p, .prose ul, .prose ol { margin: 0 0 1.05rem; }
.prose ul, .prose ol { padding-left: 1.3rem; }
.prose li { margin-bottom: .45rem; }
.prose strong { font-weight: 600; }

.disclaimer {
  margin: 0 0 1.5rem; padding: 1.1rem 1.25rem; background: var(--surface);
  border: 1px solid var(--rule); border-left: 4px solid var(--ink); border-radius: 0 6px 6px 0;
  font-family: var(--sans); font-size: .95rem; line-height: 1.55;
}
.disclaimer p { margin: 0 0 .6rem; }
.disclaimer p:last-child { margin-bottom: 0; }

/* Rule / practice / flags */
.prose p.rule { padding-left: 1rem; border-left: 2px solid var(--ink); }
.prose p.practice { color: #2C3330; }
.prose p.flag { position: relative; background: var(--surface); border: 1px solid var(--rule); border-radius: 6px; padding: .9rem 1.1rem; }
.chip {
  display: inline-block; font-family: var(--sans); font-weight: 700; font-size: .72rem; line-height: 1;
  padding: .32rem .5rem .28rem; margin-right: .35rem; border-radius: 3px; vertical-align: .12em;
  background: var(--ink); color: var(--paper); letter-spacing: .01em;
}
.chip-removed { background: transparent; color: var(--ink); border: 1px solid var(--ink); text-decoration: line-through; }
.chip-link-dead { background: transparent; color: var(--correction-ink); border: 1px dashed var(--correction-ink); }

/* Tables */
.table-wrap { overflow-x: auto; margin: 0 0 1.4rem; border: 1px solid var(--rule); border-radius: 6px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-family: var(--sans); font-size: .86rem; line-height: 1.45; }
th, td { text-align: left; vertical-align: top; padding: .6rem .75rem; border-bottom: 1px solid var(--rule); }
th { font-weight: 700; background: #F0F2EF; }
tr:last-child td { border-bottom: 0; }

/* Views */
body.view-changes .prose .sec > *:not(h2):not(.flag),
body.view-practice .prose .sec > *:not(h2):not(.practice),
body.view-waiting .prose .sec > *:not(h2):not(.waiting),
body.view-ask .prose .sec > *:not(h2):not(.ask) { opacity: .22; transition: opacity .2s; }

/* Search hits */
mark.hit { background: #CFE0FF; color: inherit; border-radius: 2px; }

/* ---------- Annotations ---------- */
mark.hl { color: inherit; border-radius: 2px; cursor: pointer; padding: .05em 0; transition: filter .15s; }
mark.hl[data-kind="kudos"] { background: color-mix(in srgb, var(--kudos-bg) calc(var(--heat, .6) * 100%), transparent); }
mark.hl[data-kind="correction"] { background: color-mix(in srgb, var(--correction-bg) calc(var(--heat, .6) * 100%), transparent); }
mark.hl[data-kind="idea"] { background: color-mix(in srgb, var(--idea-bg) calc(var(--heat, .6) * 100%), transparent); }
mark.hl[data-kind="question"] { background: color-mix(in srgb, var(--question-bg) calc(var(--heat, .6) * 100%), transparent); }
mark.hl:hover, mark.hl.is-active { filter: saturate(1.6) brightness(.96); }
mark.hl.is-new { animation: ink-in .7s ease-out; }
@keyframes ink-in { from { background-size: 0% 100%; filter: brightness(1.2); } to { filter: none; } }

.margin { position: relative; min-height: 100%; }
.pin {
  position: absolute; left: 0; width: 100%; text-align: left; cursor: pointer;
  font-family: var(--sans); font-size: .8rem; line-height: 1.35; color: var(--ink);
  background: var(--surface); border: 1px solid var(--rule); border-radius: 6px; padding: .55rem .7rem;
  transition: border-color .15s, transform .15s;
}
.pin:hover, .pin.is-active { border-color: var(--ink); }
.pin-kinds { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: .25rem; }
.pin-kinds .k { font-size: .72rem; padding: .05rem .4rem; }
.pin-text { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: #333A37; }
.pin-meta { color: var(--graphite); font-size: .74rem; margin-top: .2rem; }

/* Picker */
.picker {
  position: absolute; z-index: 30; display: flex; gap: .2rem; padding: .25rem; background: var(--ink);
  border-radius: 8px; box-shadow: 0 6px 20px rgba(29,34,32,.25);
}
.picker[hidden] { display: none; }
.pk { font-family: var(--sans); font-size: .8rem; font-weight: 700; border: 0; border-radius: 5px; padding: .45rem .65rem; cursor: pointer; }
.pk-kudos { background: var(--kudos-bg); color: var(--kudos-ink); }
.pk-correction { background: var(--correction-bg); color: var(--correction-ink); }
.pk-idea { background: var(--idea-bg); color: var(--idea-ink); }
.pk-question { background: var(--question-bg); color: var(--question-ink); }

/* Panel */
.panel {
  position: fixed; right: 1.25rem; top: 1.25rem; bottom: 1.25rem; width: min(26rem, calc(100vw - 2.5rem)); z-index: 40;
  background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; box-shadow: 0 12px 40px rgba(29,34,32,.18);
  display: flex; flex-direction: column; font-family: var(--sans); font-size: .92rem; line-height: 1.5; overflow: hidden;
}
.panel[hidden] { display: none; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: .9rem 1.1rem; border-bottom: 1px solid var(--rule); }
.panel-head h2 { font-size: 1rem; margin: 0; }
.panel-close { font: inherit; border: 0; background: none; color: var(--graphite); cursor: pointer; padding: .25rem .4rem; }
.panel-quote { margin: 0; padding: .9rem 1.1rem; font-family: var(--serif); font-size: .95rem; color: #333A37; border-bottom: 1px solid var(--rule); max-height: 8rem; overflow: auto; }
.thread { list-style: none; margin: 0; padding: .4rem 1.1rem; overflow-y: auto; flex: 1; }
.note { padding: .8rem 0; border-bottom: 1px solid var(--rule); }
.note:last-child { border-bottom: 0; }
.note-head { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; margin-bottom: .25rem; }
.note-who { font-weight: 700; }
.note-when { color: var(--graphite); font-size: .8rem; }
.note-body { white-space: pre-wrap; margin: .2rem 0 .4rem; }
.note-status { font-size: .74rem; font-weight: 700; padding: .05rem .4rem; border-radius: 3px; border: 1px solid currentColor; }
.note-status.accepted { color: var(--kudos-ink); }
.note-status.declined { color: var(--graphite); }
.editor-note { margin: .3rem 0 .4rem; padding: .45rem .6rem; background: #F0F2EF; border-radius: 5px; font-size: .86rem; }
.note-actions { display: flex; gap: .4rem; }
.vote, .reply-btn { font: inherit; font-size: .8rem; border: 1px solid var(--rule); background: var(--surface); border-radius: 999px; padding: .2rem .65rem; cursor: pointer; color: var(--ink); }
.vote[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.replies { list-style: none; margin: .5rem 0 0 .9rem; padding: 0 0 0 .8rem; border-left: 2px solid var(--rule); }
.replies .note { padding: .5rem 0; }

.composer { padding: .9rem 1.1rem 1.1rem; border-top: 1px solid var(--rule); background: #FAFBFA; }
.composer[hidden] { display: none; }
.composer-kind { margin: 0 0 .5rem; font-weight: 700; }
.composer textarea { width: 100%; font: inherit; padding: .6rem .7rem; border: 1px solid var(--rule); border-radius: 6px; resize: vertical; background: var(--surface); color: var(--ink); }
.composer-actions { display: flex; gap: .5rem; margin-top: .6rem; }
.composer-error, .who-error { color: var(--correction-ink); margin: .5rem 0 0; min-height: 1em; font-size: .85rem; }
.hp { position: absolute; left: -5000px; }
.btn { font: inherit; font-size: .88rem; padding: .5rem .9rem; border-radius: 6px; border: 1px solid var(--rule); background: var(--surface); color: var(--ink); cursor: pointer; }
.btn-primary { background: var(--ink); color: var(--paper); border-color: var(--ink); font-weight: 700; }
.btn[disabled] { opacity: .5; cursor: progress; }

.who { border: 1px solid var(--rule); border-radius: 10px; padding: 1.4rem 1.5rem; max-width: 26rem; font-family: var(--sans); font-size: .92rem; line-height: 1.5; color: var(--ink); }
.who::backdrop { background: rgba(29,34,32,.35); }
.who h2 { font-family: var(--serif); margin: 0 0 .5rem; font-size: 1.3rem; }
.who label { display: block; margin-top: .8rem; font-weight: 700; }
.who input { display: block; width: 100%; margin-top: .3rem; font: inherit; font-weight: 400; padding: .55rem .7rem; border: 1px solid var(--rule); border-radius: 6px; }

.toast { visibility: hidden; opacity: 0; position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%) translateY(1rem); background: var(--ink); color: var(--paper); font-family: var(--sans); font-size: .88rem; padding: .6rem 1rem; border-radius: 8px; transition: transform .25s, opacity .25s, visibility .25s; z-index: 60; }
.toast.is-on { visibility: visible; opacity: 1; transform: translateX(-50%) translateY(0); }

.colophon { max-width: 40rem; margin-top: 4rem; padding-top: 1.5rem; border-top: 1px solid var(--rule); font-family: var(--sans); font-size: .85rem; line-height: 1.55; }

/* ---------- Narrower screens: margin notes move inline ---------- */
@media (max-width: 1180px) {
  .page { grid-template-columns: minmax(0, 40rem); }
  .margin { display: none; }
  mark.hl::after { content: attr(data-count); font-family: var(--sans); font-size: .68rem; font-weight: 700; vertical-align: super; margin-left: .1em; color: var(--graphite); }
}
@media (max-width: 1024px) and (min-width: 641px) {
  .shell { grid-template-columns: 15rem minmax(0, 1fr); }
  .rail-inner { padding: 1.25rem .9rem 2rem 1rem; }
  main { padding-left: 1.5rem; padding-right: 1.5rem; }
  .masthead h1 { font-size: 2.2rem; }
  .masthead .deck { font-size: 1.35rem; }
}
@media (max-width: 640px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: sticky; top: 0; z-index: 60; border-right: 0; border-bottom: 1px solid var(--rule); background: var(--paper); }
  .rail-inner { position: static; max-height: none; padding: .6rem 1.25rem; display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; }
  .brand { flex: 1; font-size: 1.1rem; }
  .brand-sub { display: none; }
  .rail-toggle { display: inline-block; }
  .rail-drawer { display: none; flex-basis: 100%; }
  .rail.is-open .rail-drawer { display: block; max-height: calc(100vh - 4rem); overflow-y: auto; padding: .5rem 0 1.25rem; }
  main { padding: 0 1.25rem 3rem; }
  .masthead { padding-top: 2rem; }
  .masthead h1 { font-size: 2rem; }
  .masthead .deck { font-size: 1.3rem; }
  .panel { top: auto; left: .5rem; right: .5rem; bottom: .5rem; width: auto; max-height: 75vh; }
  .sec, .sec h2, .masthead { scroll-margin-top: 4.5rem; }
}

@page { size: letter; margin: 0.85in 0.9in 0.9in; @bottom-center { content: "DGS Community Companion · unofficial community guide · page " counter(page) " of " counter(pages); font-family: "Atkinson Hyperlegible", sans-serif; font-size: 8pt; color: #59615E; } }
@media print {
  .rail, .picker, .panel, .margin, .toast, .skip, .legend, dialog { display: none !important; }
  .masthead { padding: 0 0 1rem; }
  .masthead h1 { font-size: 24pt; }
  .masthead .deck { font-size: 15pt; }
  .lede { font-size: 11.5pt; }
  .prose h2 { font-size: 16pt; break-after: avoid; }
  .sec + .sec { margin-top: 1.2rem; }
  .table-wrap { overflow: visible; }
  table { font-size: 8.5pt; }
  tr, .flag, .disclaimer { break-inside: avoid; }
  a { text-decoration: none; }
  .shell, .page { display: block; }
  main { padding: 0; }
  mark.hl { background: none !important; }
  body { background: #fff; font-size: 11pt; }
}

/* Community notes list */
.all-notes-btn { display: block; width: 100%; margin: 0 0 1.2rem; font: inherit; font-weight: 700; text-align: left; padding: .6rem .75rem; border: 1px solid var(--ink); border-radius: 6px; background: var(--surface); color: var(--ink); cursor: pointer; }
.all-notes-btn span { font-weight: 400; color: var(--graphite); }
.list-filters { padding: .7rem 1.1rem; border-bottom: 1px solid var(--rule); display: grid; gap: .5rem; }
.list-filters[hidden] { display: none; }
.chips { display: flex; flex-wrap: wrap; gap: .3rem; }
.fchip { font: inherit; font-size: .8rem; padding: .2rem .6rem; border-radius: 999px; border: 1px solid var(--rule); background: var(--surface); cursor: pointer; color: var(--ink); }
.fchip.is-on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.status-pick { font-size: .82rem; color: var(--graphite); display: flex; gap: .5rem; align-items: center; }
.status-pick select { font: inherit; padding: .25rem .4rem; border: 1px solid var(--rule); border-radius: 5px; }
.note-quote { all: unset; cursor: pointer; display: block; margin: .25rem 0 .35rem; padding-left: .6rem; border-left: 3px solid var(--rule); font-family: var(--serif); font-size: .88rem; color: #333A37; }
.note-quote:hover { border-left-color: var(--ink); }
.note-quote:focus-visible { outline: 3px solid var(--focus); }
.note-orphan { font-size: .78rem; color: var(--graphite); }

/* Not yet in writing */
.prose p.waiting { background: #FFFDF4; border: 1px dashed #B8A15A; border-radius: 6px; padding: .9rem 1.1rem; }
.chip-waiting { background: #7E5F00; color: #FFF; }
.prose p.ask { background: #F6F4FC; border: 1px dashed #8C7FC4; border-radius: 6px; padding: .9rem 1.1rem; }
.chip-ask { background: #4B3C8C; color: #FFF; }
.view-btn:last-child:nth-child(odd) { grid-column: span 2; }

/* Clarity pass */
.how { font-family: var(--sans); font-size: .95rem; line-height: 1.75; color: #333A37; max-width: 36rem; margin: 0; }
.how .k { white-space: nowrap; }
.note-head .k { width: .7rem; height: .7rem; padding: 0; border-radius: 50%; display: inline-block; }
.note-head .k-kudos { background: var(--kudos-ink); } .note-head .k-correction { background: var(--correction-ink); }
.note-head .k-idea { background: var(--idea-ink); } .note-head .k-question { background: var(--question-ink); }
.quote-label { display: block; font-family: var(--sans); font-size: .75rem; font-weight: 700; color: var(--graphite); margin-bottom: .2rem; }
.add-own { border-bottom: 0; }
.add-own-h { margin: 0 0 .5rem; font-weight: 700; font-size: .88rem; }
.note-actions.wrap { flex-wrap: wrap; }
.who-list { margin: .3rem 0 0; padding-left: 1.1rem; }
.picker { flex-wrap: wrap; max-width: min(34rem, calc(100vw - 16px)); }
.toast-btn { margin-left: .9rem; font: inherit; font-weight: 700; color: var(--paper); background: none; border: 1px solid rgba(247,248,246,.5); border-radius: 5px; padding: .15rem .55rem; cursor: pointer; }
.del-btn { font: inherit; font-size: .8rem; border: 0; background: none; color: var(--correction-ink); cursor: pointer; padding: .2rem .4rem; text-decoration: underline; text-underline-offset: .15em; }
