/* Man page: the site as `man costa` shows it in a full-screen terminal. Black screen, one
   monospace grid edge to edge, a header and footer line, bold section names at column 0,
   bodies indented 5 columns and wrapping at the window's width, underlined links, hover in
   reverse video, and less's prompt on the last row (the layout switch sits at its right).
   layouts/manpage.js makes less's keys work: j/k, ^D/^U, space/b, g/G, /pattern, n/N, h, q. */
:root {
  --bg: #000000; --fg: #c7c7c7; --bold: #ffffff; --dim: #8a8a8a; --hair: #3a3a3a;
  --rev-bg: #c9c9c4; --rev-fg: #1c1c1c;

  --mono: "SF Mono", ui-monospace, Menlo, "DejaVu Sans Mono", Consolas, "Liberation Mono", monospace;
  --in: 5ch;          /* body indent, as mandoc draws it */
  --row: 1.25em;      /* one terminal row */
  --gap: 2.5em;       /* two blank rows before each section heading */
  --sub: 3ch;         /* subsection indent (.SS) */
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; background: var(--bg); }
html, body { overscroll-behavior: none; }   /* a terminal doesn't bounce past the top or bottom */
/* No scrollbar, like a terminal pager; the page still scrolls. */
html, .less-help { scrollbar-width: none; }
html::-webkit-scrollbar, .less-help::-webkit-scrollbar { display: none; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 14px/1.25 var(--mono); overflow-wrap: break-word; padding-bottom: var(--row); }
a { color: inherit; text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px; }
a:hover, a:focus-visible { background: var(--rev-bg); color: var(--rev-fg); outline: 0; text-decoration: none; }
b, strong, h1, h2, h3, .pub-venue, .meta dt { font-weight: 700; color: var(--bold); }
em, i:not([class]) { font-style: normal; text-decoration: underline; }
u.me { text-decoration: none; font-weight: 700; color: var(--bold); }
h1, h2, h3, p, ul, ol, dl, figure { margin: 0; font-size: inherit; }
table { border-collapse: collapse; }
img { max-width: 100%; }
::selection { background: var(--rev-bg); color: var(--rev-fg); }

.sheet { margin: 0; padding: 0 1ch; }

/* Header line: COSTA(1)   Concurrent Systems Manual   COSTA(1) */
.running-head { margin: 0; padding: 0 1ch; display: grid; grid-template-columns: 1fr auto 1fr; }
.running-head::before, .running-head::after { content: "COSTA(1)"; }
.running-head::after { text-align: right; }
.running-head > span { font-size: 0; }
.running-head > span::after { content: "Concurrent Systems Manual"; font-size: 14px; }

/* less's prompt on the last row (layouts/manpage.js writes it); the layout switch at the right */
.less-prompt { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; height: 1.25em; padding: 0 1ch; background: var(--bg); color: var(--fg); white-space: pre; overflow: hidden; }
.less-prompt[hidden] { display: none; }
.less-rev { background: var(--rev-bg); color: var(--rev-fg); }
.less-cursor { display: inline-block; width: 1ch; height: 1.1em; vertical-align: -0.2em; background: var(--fg); }
mark.less-hit { background: var(--rev-bg); color: var(--rev-fg); }
/* the match n/N last went to */
mark.less-hit.less-now { outline: 1px solid var(--rev-bg); outline-offset: 2px; }
.less-hit-before::before { background: var(--rev-bg); color: var(--rev-fg) !important; width: max-content; }
.less-help { position: fixed; inset: 0 0 1.25em 0; z-index: 9; margin: 0; padding: 0 1ch; overflow: auto; background: var(--bg); color: var(--fg); font: inherit; white-space: pre; }
.less-help[hidden] { display: none; }
.layout-switch {
  position: fixed; right: 1ch; bottom: 0; z-index: 12; height: 1.25em;
  font: inherit; color: var(--dim); background: var(--bg); border: 0;
  padding: 0; cursor: pointer; border-radius: 0; -webkit-appearance: none; appearance: none; text-align: right;
}
.layout-switch:hover, .layout-switch:focus-visible { background: var(--rev-bg); color: var(--rev-fg); outline: 0; }

/* Section headings hang out to column 0; everything else sits at the body indent. */
.title-block { margin-top: var(--row); }
section { margin-top: var(--gap); }
h2, .title-block::before, .contacts::before, .lede::before, .toc::before {
  display: block; font-weight: 700; color: var(--bold); text-transform: uppercase; margin-left: calc(-1 * var(--in));
}
h2 .sec { display: none; }
section > * { margin-left: var(--in); }
section > h2 { margin-left: 0; }

/* NAME, CONTACT, DESCRIPTION come out of the title block, in man-page order */
.title-block { display: flex; flex-wrap: wrap; align-items: baseline; padding-left: var(--in); }
.title-block::before { content: "NAME"; flex-basis: calc(100% + var(--in)); order: 0; }
.part, .title-main { display: contents; }
.part-no { display: none; }
.title-main h1 { order: 1; }
.part-kind { order: 2; }
.part-kind::before { content: "\00a0\2014\00a0"; }
.die-shot { order: 3; flex-basis: 100%; margin-top: var(--row); }
.die-shot img { display: block; width: 132px; height: auto; }
.contacts { order: 5; flex-basis: 100%; margin-top: var(--gap); }
.contacts::before { content: "CONTACT"; }
.contacts .dot { color: var(--dim); }
.rev-table { order: 6; margin-top: 0.3em; color: var(--dim); }
.rev-table tr { display: inline; }
.rev-table tr + tr::before { content: ",\00a0\00a0"; }
.rev-table th, .rev-table td { display: inline; padding: 0; font-weight: 400; text-align: left; }
.rev-table th::after { content: ": "; }
.rev-table tr:first-child { display: none; }
.rev-table tr:nth-child(2)::before { content: none; }
.tag-live { color: #8ec07c; }
.lede { order: 7; flex-basis: 100%; margin-top: var(--gap); }
.lede::before { content: "DESCRIPTION"; }

/* SYNOPSIS: the contents as a command line, costa [--research] [--publications] ...
   layouts/manpage.js moves the contents into the title block, between NAME and CONTACT. */
.toc { order: 4; flex-basis: 100%; display: flex; flex-wrap: wrap; column-gap: 1ch; margin: var(--gap) 0 0; padding-left: 0; text-indent: 0; }
.toc::before { content: "SYNOPSIS"; flex-basis: calc(100% + var(--in)); order: -2; }
.toc::after { content: "costa"; order: -1; font-weight: 700; color: var(--bold); }
.toc a { display: inline-flex; font-size: 0; text-decoration: none; }
.toc a::before { content: "["; font-size: 14px; order: 0; }
.toc a::after { content: "--" attr(data-id); font-size: 14px; order: 1; font-weight: 700; color: var(--bold); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
.toc a span { order: 2; font-size: 0; }
.toc a span::after { content: "]"; font-size: 14px; }
.toc a:hover::after, .toc a:hover::before, .toc a:hover span::after { background: var(--rev-bg); color: var(--rev-fg); }

/* the block diagram at a natural size, not the full width of the window */
.blocks { max-width: 92ch; }

/* subsections (.SS) and paragraphs */
section { scroll-margin-top: 0.5em; }
h3 { color: var(--bold); }
.caption-above { margin-bottom: var(--row); }
.note { margin-top: var(--gap); }
.entry { margin-top: var(--row); scroll-margin-top: 0.5em; }
/* research grouped by status: each group is a subsection (.SS) */
.group + .group { margin-top: var(--gap); }
.group-title { margin-left: calc(-1 * var(--in) + var(--sub)); text-decoration: underline; text-underline-offset: 2px; }
.group-title + .entry { margin-top: 0.3em; }
.meta { grid-template-columns: 8ch minmax(0, 1fr); }
.entry header, .card header { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 1ch; margin-left: calc(-1 * (var(--in) - var(--sub))); }
.entry p, .card p { margin: 0 0 0.6em; }
/* folded explanations, as [+] / [-] lines (za, zo, zc, zR, zM in layouts/manpage.js) */
details.more > summary { list-style: none; color: var(--fg); width: fit-content; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before { content: "[+] "; color: var(--dim); }
details.more[open] > summary::before { content: "[-] "; }
details.more > summary:hover, details.more > summary:focus-visible { background: var(--rev-bg); color: var(--rev-fg); outline: 0; }
details.more > summary:hover::before, details.more > summary:focus-visible::before { color: inherit; }
details.more[open] > summary { margin-bottom: 0.3em; }
.addr { color: var(--dim); }
.tag, .lang { color: var(--dim); white-space: nowrap; }
.tag::before, .lang::before { content: "["; } .tag::after, .lang::after { content: "]"; }
.unreleased { color: var(--dim); }
.unreleased::before { content: "<"; } .unreleased::after { content: ">"; }

/* tagged paragraphs (.TP): label at the indent, text in a column */
.meta { display: grid; grid-template-columns: 8ch 1fr; margin: 0; }
.meta dd { margin: 0; }

/* tables as aligned text */
.regmap, .spec { margin-bottom: var(--row); }
.regmap caption { caption-side: top; text-align: left; color: var(--dim); }
.regmap th, .spec th { text-align: left; font-weight: 700; color: var(--bold); text-decoration: underline; padding: 0 2ch 0 0; }
.regmap td, .spec td { padding: 0 2ch 0 0; vertical-align: top; }
.two-col { display: grid; gap: var(--row); }
.two-col h3 { margin-left: calc(-1 * (var(--in) - var(--sub))); }

/* block diagram drawn with box lines */
.blocks { display: flex; flex-direction: column; margin-bottom: var(--row); }
.blk { position: relative; display: block; padding: 0.9em 1ch 0.5em; border: 1px solid var(--fg); color: var(--fg); text-decoration: none; }
.blk-label { position: absolute; top: -0.75em; left: 1ch; padding: 0 1ch; background: var(--bg); color: var(--dim); text-transform: uppercase; white-space: nowrap; }
.blk-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1ch; }
.blk-row.three { grid-template-columns: repeat(3, 1fr); gap: 2ch; }
.blk-ds { text-align: center; }
.cell { display: flex; flex-direction: column; align-items: center; text-decoration: none; padding: 0.3em 0; }
.blk-app .cell { border: 1px dashed var(--dim); }
a.blk.cell { padding: 0.8em 1ch 0.4em; }
.blk-row.three .blk { margin-top: 0.75em; }
.cell small { color: var(--dim); font-size: inherit; }
a.cell:hover small, a.cell:hover b, a.blk:hover .blk-label { color: inherit; }
a.blk:hover .blk-label { background: var(--rev-bg); }
.bus { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 1ch; height: var(--row); padding: 0 calc(1ch + 1px); }
.bus span { justify-self: center; border-left: 1px solid var(--fg); }
/* one line per box below: same columns as .blk-row.three, reaching past the label's margin */
.bus.three { gap: 2ch; padding: 0; height: calc(var(--row) + 0.75em); margin-bottom: -0.75em; }

/* projects: one entry each, no boxes */
.filters { display: flex; flex-wrap: wrap; gap: 0 1ch; margin-bottom: var(--row); }
.filters button { font: inherit; color: var(--fg); background: none; border: 0; padding: 0; cursor: pointer; }
.filters button::before { content: "["; } .filters button::after { content: "]"; }
.filters button.on { background: var(--rev-bg); color: var(--rev-fg); }
.cards { display: block; }
.card { margin-bottom: var(--row); }
.card[hidden] { display: none; }
.card .go { word-break: break-all; }
/* a screenshot or logo beside the text, framed like a terminal window */
.card.has-shot { display: grid; grid-template-columns: minmax(0, 64ch) minmax(0, 60ch); justify-content: start; grid-template-rows: auto 1fr auto; grid-template-areas: "head head" "text shot" "go shot"; column-gap: 4ch; align-items: start; }
.card.has-shot > header { grid-area: head; }
.card.has-shot > p { grid-area: text; }
.card.has-shot { margin-bottom: calc(2 * var(--row)); }
/* the link sits on the screenshot's bottom edge */
.card.has-shot > .go, .card.has-shot > .unreleased { grid-area: go; justify-self: start; align-self: end; line-height: 1; }
.card .shot { grid-area: shot; margin: 0.3em 0 0; border: 1px solid var(--hair); }
.card .shot img { display: block; width: 100%; height: auto; }

/* Footer line, as man(1) prints it: source, date, source; (END) follows right below */
.sheet-foot { display: grid; grid-template-columns: 1fr auto 1fr; margin: var(--row) 0 0; }
.sheet-foot span:nth-child(2) { text-align: center; }
.sheet-foot span:nth-child(3) { text-align: right; }

@media (max-width: 640px) {
  :root { --in: 3ch; --sub: 1ch; }
  body { font-size: 13px; }
  .toc a::before, .toc a::after, .toc a span::after { font-size: 13px; }
  .running-head > span::after { font-size: 13px; }
  .regmap th:nth-child(3), .regmap td:nth-child(3) { display: none; }
  .card.has-shot { grid-template-columns: 1fr; grid-template-areas: "head" "shot" "text" "go"; }
  .card .shot { max-width: 44ch; margin-bottom: 0.6em; }
  .meta { grid-template-columns: 6ch 1fr; }
  .sheet-foot span:nth-child(3) { display: none; }
  .sheet-foot { grid-template-columns: 1fr auto; }
  .die-shot img { width: 112px; }
  .less-prompt { padding: 0 0.5ch; }
}
