:root {
  --bg: #fdfdfc;
  --fg: #1d1d1f;
  --muted: #6b6b70;
  --line: #e2e2e5;
  --poly-fill: rgba(47, 111, 186, 0.15);
  --poly-stroke: #2f6fba;
  --pt-int: #e67e22;
  --pt-vertex: #d0021b;
  --pt-bd: #2f6fba;
  --pt-out: #c9c9ce;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #18181a;
    --fg: #ececee;
    --muted: #9a9aa0;
    --line: #333337;
    --poly-fill: rgba(110, 160, 230, 0.18);
    --poly-stroke: #6ea0e6;
    --pt-int: #ffa040;
    --pt-vertex: #ff3030;
    --pt-bd: #6ea0e6;
    --pt-out: #4a4a50;
  }
}

body {
  margin: 0 auto;
  max-width: 1100px;
  padding: 0 16px;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 system-ui, sans-serif;
}

a { color: var(--poly-stroke); }

header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px 24px; padding: 20px 0; border-bottom: 1px solid var(--line); }
header a { color: inherit; text-decoration: none; }
header .home { font-weight: 600; font-size: 1.2em; }
header nav { display: flex; gap: 20px; }
header nav a:hover { color: var(--poly-stroke); }

main p, main li { max-width: 75ch; }
main li p { margin: 0.2em 0; }

footer { margin: 40px 0 20px; color: var(--muted); font-size: 0.85em; }

.search { display: grid; grid-template-columns: repeat(2, max-content max-content); gap: 8px 16px; align-items: center; margin-top: 20px; }
.search .name { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.search .wide { grid-column: span 3; }
.search input:not([type=checkbox]), .search select, .search button { font: inherit; padding: 4px 8px; }

/* A circled question mark whose explanation shows on hover, and on tap or keyboard focus. */
.help { position: relative; display: inline-flex; justify-content: center; align-items: center; flex-shrink: 0;
        width: 1.2em; height: 1.2em; border: 1px solid currentColor; border-radius: 50%; font-size: 0.75em; cursor: help; }
.help .tip { display: none; position: absolute; left: 0; top: calc(100% + 6px); z-index: 10; width: 300px;
             padding: 8px 10px; border-radius: 6px; background: var(--fg); color: var(--bg);
             font-size: 0.85rem; line-height: 1.4; white-space: normal; }
.help:hover .tip, .help:focus .tip { display: block; }
.help .tip { font-weight: normal; }
.polygon-page .help { margin-left: 4px; vertical-align: 0.1em; }

.hint { color: var(--muted); font-size: 0.85em; }
.coverage { padding: 6px 10px; border-radius: 4px; border-left: 4px solid; }
.coverage.complete { border-color: #2e9e5b; background: rgba(46, 158, 91, 0.12); }
.coverage.incomplete { border-color: #d9a400; background: rgba(217, 164, 0, 0.14); }
/* Tables in Markdown pages. */
main > table { border-collapse: collapse; }
main > table th, main > table td { padding: 4px 24px 4px 0; vertical-align: top; }
main > table th { font-weight: normal; color: var(--muted); }
main > table td:first-child { white-space: nowrap; }
.error { color: var(--pt-int); }
.references li, .comments li { margin-bottom: 6px; }
.comments p { margin: 0; }
.comments .by { color: var(--muted); font-size: 0.9em; }
.comments .by::before { content: "— "; }
.references li:target { background: var(--line); }

.grid { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.grid a { display: block; border: 1px solid var(--line); border-radius: 6px; padding: 8px; color: inherit; text-decoration: none; }
.grid a:hover { border-color: var(--poly-stroke); }
.grid svg { display: block; width: 100%; aspect-ratio: 1; }
.grid span { display: block; font-size: 0.75em; color: var(--muted); margin-top: 4px; }

.pages { display: flex; gap: 20px; }

.poly { fill: var(--poly-fill); stroke: var(--poly-stroke); stroke-width: 2px; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.pt-int { fill: var(--pt-int); }
.pt-bd { fill: var(--pt-bd); }
.pt-out { fill: var(--pt-out); }
.pt-vertex { fill: var(--pt-vertex); }

.polygon-page { margin-top: 24px; }
.polygon-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 32px; align-items: center; }
.polygon-page .figure svg { width: 100%; max-width: 440px; max-height: 70vh; }
.polygon-page th { text-align: left; font-weight: normal; color: var(--muted); padding-right: 16px; }
.polygon-page h2 { font-size: 1em; margin-top: 24px; }
/* Long Ehrhart quasipolynomials flow into columns. */
.polygon-page .ehrhart.columns { column-width: 20em; column-gap: 32px; }
.polygon-page .ehrhart div { break-inside: avoid; padding: 2px 0; }
.polygon-page .ehrhart .residue { display: inline-block; min-width: 7.5em; color: var(--muted); }
/* Labels in the colours of the corresponding points in the drawing. */
.polygon-page .c-int { color: var(--pt-int); }
.polygon-page .c-bd { color: var(--pt-bd); }
.polygon-page .c-vertex { color: var(--pt-vertex); }
.polygon-page pre { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--line); padding: 8px 40px 8px 8px; border-radius: 4px; font-size: 0.85em; }
.polygon-page pre span { white-space: nowrap; }
.polygon-page .code { position: relative; }
.polygon-page .copy { position: absolute; top: 4px; right: 4px; display: flex; padding: 4px; border: none; border-radius: 4px;
                      background: none; color: var(--muted); cursor: pointer; }
.polygon-page .copy:hover { color: var(--fg); }
.polygon-page .copy svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.polygon-page .copy .icon-done, .polygon-page .copy.copied .icon-copy { display: none; }
.polygon-page .copy.copied .icon-done { display: block; }

@media (max-width: 950px) {
  .search { grid-template-columns: max-content max-content; }
  .search .wide { grid-column: auto; }
}

@media (max-width: 700px) {
  .polygon-top { grid-template-columns: 1fr; }
  .search { grid-template-columns: 1fr; gap: 4px; }
  .search .wide { grid-column: auto; }
}
.identify { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 24px 0; }
.identify div { display: flex; gap: 8px; width: min(36em, 100%); }
.identify input { flex: 1; min-width: 0; font: inherit; padding: 4px 8px; }
.identify button { font: inherit; padding: 4px 8px; }
/* Code in Markdown pages. */
main > pre { background: var(--line); padding: 8px; border-radius: 4px; font-size: 0.85em; overflow-x: auto; }
