/* Misaligned Agent Activity Survey.
   The design language of Alecto's Minima site without its paintings:
   raw paper ground, warm sumi ink, old-style serifs. Here the data is
   the colour: four route inks, and nothing else on the page competes
   with them. Host names are literals, so they are set in monospace. */

:root {
  --paper: #ece5d6;       /* xuan paper, measured from the paintings */
  --paper-deep: #e4dccb;  /* the band that holds what is live */
  --paper-lift: #f3eee3;  /* a raised sheet: tooltips, the table view */
  --sumi: #2f2624;        /* warm black of the ink: text */
  --sumi-soft: #6a5f59;   /* secondary text */
  --sumi-faint: #8f847c;  /* axis labels, notes */
  --wash: #c9bfb2;        /* hairlines, gridlines */
  --wash-soft: #dcd3c4;   /* the faintest rules: month lines, shading */

  /* The four routes, in their order everywhere: indigo, gamboge,
     vermilion, and a neutral grey for what is on no list. Checked as a
     set on this paper for colour-blind separation (deutan, protan,
     tritan) and normal-vision distinctness. Gamboge and grey are under
     3:1 against the paper, so every chart has a legend and a table. */
  --direct: #2a5c9e;
  --relay: #c99a2e;
  --carrier: #b8402e;
  --other: #958a80;

  --live: #b8402e;

  --serif-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --serif-text: Charter, "Bitstream Charter", "Iowan Old Style", Georgia, serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --measure: 38rem;
  --gutter: clamp(16px, 4vw, 48px);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--paper);
  color: var(--sumi);
  font-family: var(--serif-text);
  font-size: 1.0625rem;
  line-height: 1.6;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--serif-display);
  font-weight: 400;
  line-height: 1.15;
  margin: 0 0 0.6em;
  text-wrap: balance;
}
h1 { font-size: clamp(2rem, 4.6vw, 3.1rem); letter-spacing: -0.01em; }
h2 { font-size: clamp(1.5rem, 3vw, 2.1rem); }
h3 { font-size: 1.15rem; }
h4 { font-size: 1rem; }
p { margin: 0 0 1em; text-wrap: pretty; }
[id] { scroll-margin-top: 1.5rem; }

a { color: inherit; text-decoration-color: var(--wash); text-underline-offset: 0.2em; }
a:hover { text-decoration-color: var(--sumi); }

code, .host { font-family: var(--mono); font-size: 0.86em; letter-spacing: -0.01em; }

.wrap { width: min(72rem, 100% - 2 * var(--gutter)); margin-inline: auto; position: relative; }
.narrow { width: min(44rem, 100% - 2 * var(--gutter)); }
.scroll { overflow-x: auto; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.kicker {
  font-size: 0.76rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--sumi-soft);
  margin-bottom: 1.1em;
}
.kicker .host { text-transform: none; letter-spacing: 0; font-size: 0.95em; }

.stamp { font-size: 0.85rem; color: var(--sumi-faint); }

/* A route's key: a square in its ink; `.line` makes it a short stroke,
   for the legends of line charts. */
.key { display: inline-block; width: 0.62em; height: 0.62em; border-radius: 1px; margin-right: 0.45em; vertical-align: 0.02em; background: var(--sumi-faint); }
.key.line { width: 1em; height: 2px; vertical-align: 0.3em; border-radius: 1px; }
.key.direct { background: var(--direct); }
.key.relay { background: var(--relay); }
.key.carrier { background: var(--carrier); }
.key.other { background: var(--other); }

/* ---------- header, footer ---------- */

.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1rem var(--gutter);
}
.brand { display: inline-flex; align-items: center; gap: 0.55rem; text-decoration: none; font-family: var(--serif-display); font-size: 1.02rem; }
.brand .short { display: none; }
.bar nav { display: flex; gap: clamp(0.9rem, 2.5vw, 1.8rem); font-size: 0.92rem; }
.bar nav a { text-decoration: none; color: var(--sumi-soft); }
.bar nav a:hover { color: var(--sumi); }

.foot { padding: 2.5rem 0 3rem; font-size: 0.85rem; color: var(--sumi-soft); }
.foot-row { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem 2rem; flex-wrap: wrap; border-top: 1px solid var(--wash); padding-top: 1.4rem; }
.colophon { max-width: 34rem; }
.colophon p, .foot .stamp { margin: 0; }

/* ---------- home ---------- */

.lede { padding: clamp(2.5rem, 7vh, 4.5rem) 0 clamp(2rem, 5vh, 3rem); }
.lede h1 { max-width: 20ch; }
.lede h1 + p { max-width: var(--measure); font-size: 1.15rem; color: var(--sumi-soft); }

.band { background: var(--paper-deep); padding: clamp(2.5rem, 6vh, 4rem) 0; }

[data-listed]:not(.is-live) :is(.live, .live-word) { display: none; }
.kicker .live { display: inline-block; width: 0.55em; height: 0.55em; border-radius: 50%; background: var(--live); margin-right: 0.6em; vertical-align: 0.05em; }
@media (prefers-reduced-motion: no-preference) {
  .kicker .live { animation: breathe 2.4s ease-in-out infinite; }
  @keyframes breathe { 50% { opacity: 0.35; } }
}
.amap-copy { max-width: var(--measure); }
.amap-copy p { color: var(--sumi-soft); }
.amap-foot { display: grid; grid-template-columns: 9rem 1fr; gap: 0 2rem; margin-top: 2rem; border-top: 1px solid var(--wash); padding-top: 1.2rem; }
.amap-foot h3 { font-size: 1rem; margin-top: 0.15rem; }
.amap-foot .pages { grid-column: 2; font-size: 0.9rem; color: var(--sumi-soft); margin: 1rem 0 0; }
.amap-foot .pages a + a::before { content: " · "; color: var(--sumi-faint); }

.targets { padding: clamp(3rem, 8vh, 5rem) 0 1rem; }
.targets > p { color: var(--sumi-soft); max-width: var(--measure); }
.reading { padding: 2rem 0 clamp(3rem, 8vh, 5rem); }
.reading ul { max-width: 46rem; padding-left: 1.1rem; color: var(--sumi-soft); }
.reading li { margin-bottom: 0.6em; }
.reading strong { color: var(--sumi); font-weight: 600; }

/* ---------- the stats ---------- */

/* Figures are lining and proportional; columns of them are tabular. */
.stats { display: flex; flex-wrap: wrap; gap: 1.2rem clamp(1.5rem, 4vw, 3rem); margin: 1.6rem 0; font-variant-numeric: lining-nums; }
.stats .stat-group { display: flex; flex-wrap: wrap; gap: 1.2rem clamp(1.2rem, 3vw, 2.2rem); }
.stats dt { font-size: 0.8rem; color: var(--sumi-soft); white-space: nowrap; }
.stats dd { margin: 0; font-family: var(--serif-display); font-size: 1.45rem; line-height: 1.2; }
.stats .lead dd { font-size: clamp(2rem, 4vw, 2.7rem); line-height: 1.05; }
.stats dd.note { font-family: var(--serif-text); font-size: 0.74rem; color: var(--sumi-faint); margin-top: 0.15rem; }
.stats .stat-group:last-child { padding-left: clamp(1.5rem, 4vw, 3rem); border-left: 1px solid var(--wash); }

.facts { display: flex; flex-wrap: wrap; gap: 0.4rem 2rem; margin: -0.4rem 0 2rem; font-size: 0.9rem; font-variant-numeric: lining-nums; }
.facts div { display: flex; gap: 0.5rem; }
.facts dt { color: var(--sumi-soft); }
.facts dt::after { content: ":"; }
.facts dd { margin: 0; }

/* ---------- the overview of targets ---------- */

.overview { width: 100%; border-collapse: collapse; margin: 1.5rem 0 1.2rem; font-variant-numeric: lining-nums tabular-nums; }
.overview th, .overview td { padding: 0.55rem 0.7rem; text-align: left; font-weight: 400; vertical-align: middle; }
.overview thead th { font-size: 0.78rem; color: var(--sumi-soft); border-bottom: 1px solid var(--wash); vertical-align: bottom; white-space: nowrap; }
.overview tbody tr { border-bottom: 1px solid var(--wash-soft); }
.overview tbody tr:hover { background: color-mix(in srgb, var(--paper-deep) 60%, transparent); }
.overview .t { padding-left: 0; min-width: 13rem; }
.overview .t .host { display: block; font-size: 0.86rem; text-decoration: none; }
.overview .t a:hover { text-decoration: underline; text-decoration-color: var(--sumi); }
.overview .what { display: block; font-size: 0.8rem; color: var(--sumi-soft); line-height: 1.3; }
.overview .num { text-align: right; white-space: nowrap; }
.overview tr.group th { padding: 1.6rem 0 0.4rem; font-size: 0.86rem; color: var(--sumi-soft); border-bottom: 1px solid var(--wash); }
.overview tr.group p { margin: 0; }
.overview tr.group strong { font-family: var(--serif-display); font-weight: 400; font-size: 1.1rem; color: var(--sumi); }
.overview tbody tr.group:hover { background: none; }
.overview td.total { font-family: var(--serif-display); font-size: 1.05rem; }
.overview td.route { color: var(--sumi-soft); }
.overview td.peak { color: var(--sumi-soft); font-size: 0.85rem; }
.overview .year { width: 34%; min-width: 14rem; position: relative; }
.overview td.year { padding-block: 0.4rem; }
.overview th.year { padding-bottom: 0.4rem; }
.months { position: relative; height: 1.1em; font-size: 0.72rem; color: var(--sumi-faint); }
.months span { position: absolute; top: 0; transform: translateX(2px); }
/* A month begun less than two weeks before the latest listing keeps its
   line but not its label, which would run into the one before. */

.overview td.uncounted, p.uncounted { color: var(--sumi-faint); font-style: italic; font-size: 0.85rem; }
p.uncounted { margin: 1.5rem 0; }
.spark { display: block; width: 100%; height: 2.1rem; overflow: visible; }
.spark rect { fill: var(--sumi); }
.spark rect.window { fill: var(--wash-soft); }
.spark line { vector-effect: non-scaling-stroke; stroke-width: 1px; }
.spark .month { stroke: var(--wash-soft); }
.spark .base { stroke: var(--wash); }

/* The definitions of the routes double as the legend: a markdown list
   whose items open with the route's name, in the routes' order
   (bin/postbuild checks the order). */
.routes ul { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.8rem 1.6rem; font-size: 0.86rem; color: var(--sumi-soft); }
.routes li { position: relative; padding-left: 1.05rem; line-height: 1.4; }
.routes li::before { content: ""; position: absolute; left: 0; top: 0.42em; width: 0.62em; height: 0.62em; border-radius: 1px; }
.routes li:nth-child(1)::before { background: var(--direct); }
.routes li:nth-child(2)::before { background: var(--relay); }
.routes li:nth-child(3)::before { background: var(--carrier); }
.routes li:nth-child(4)::before { background: var(--other); }
.routes strong { color: var(--sumi); font-weight: 600; }
.routes.compact { margin: 1.8rem 0 0; }

/* ---------- a chart ---------- */

.chart { margin: 1.5rem 0 0; position: relative; }
.chart-controls { display: flex; flex-wrap: wrap; gap: 0.6rem 1.4rem; margin-bottom: 0.9rem; }
.chart-controls[hidden] { display: none; }
.seg { display: inline-flex; border: 1px solid var(--wash); border-radius: 4px; overflow: hidden; }
.seg button {
  font: inherit; font-size: 0.8rem; color: var(--sumi-soft); background: transparent;
  border: 0; padding: 0.28rem 0.7rem; cursor: pointer; line-height: 1.3;
}
.seg button + button { border-left: 1px solid var(--wash); }
.seg button:hover { color: var(--sumi); background: color-mix(in srgb, var(--paper-lift) 70%, transparent); }
.seg button[aria-pressed="true"] { color: var(--paper); background: var(--sumi); }
.seg button:disabled { color: var(--wash); cursor: default; background: transparent; }
.seg button:focus-visible { outline: 2px solid var(--direct); outline-offset: -2px; }

.chart-legend { display: flex; flex-wrap: wrap; gap: 0.3rem 1.2rem; font-size: 0.8rem; color: var(--sumi-soft); margin-bottom: 0.4rem; }
.chart-plot { position: relative; min-height: 2rem; }
.chart-plot svg { display: block; overflow: visible; }
.chart figcaption { font-size: 0.8rem; color: var(--sumi-faint); margin-top: 0.5rem; }

/* The tooltip: values lead, route names follow, keyed by a stroke. */
.tip {
  position: absolute; top: 0; pointer-events: none; z-index: 3;
  background: var(--paper-lift); border: 1px solid var(--wash); border-radius: 4px;
  box-shadow: 0 2px 10px rgb(47 38 36 / 0.08);
  padding: 0.5rem 0.7rem; font-size: 0.8rem; line-height: 1.45; min-width: 10rem;
  font-variant-numeric: lining-nums tabular-nums;
}
.tip .when { color: var(--sumi-soft); margin-bottom: 0.25rem; white-space: nowrap; }
.tip .row { display: grid; grid-template-columns: 1.3rem auto 1fr; align-items: center; gap: 0 0.4rem; }
.tip .row b { font-weight: 600; text-align: right; }
.tip .row span:last-child { color: var(--sumi-soft); }
.tip .total { border-top: 1px solid var(--wash); margin-top: 0.25rem; padding-top: 0.2rem; }
.tip .key.line { width: 1.1rem; margin: 0; }

.chart-table { margin-top: 0.8rem; font-size: 0.82rem; }
.chart-table summary { cursor: pointer; color: var(--sumi-soft); width: max-content; }
.chart-table summary:hover { color: var(--sumi); }
.chart-table table { border-collapse: collapse; margin-top: 0.6rem; font-variant-numeric: lining-nums tabular-nums; background: var(--paper-lift); }
.chart-table th, .chart-table td { padding: 0.2rem 0.75rem; text-align: left; font-weight: 400; white-space: nowrap; }
.chart-table thead th { color: var(--sumi-soft); border-bottom: 1px solid var(--wash); }
.chart-table .num { text-align: right; }
.chart-table tr.empty td { color: var(--sumi-faint); }

/* ---------- a target ---------- */

.target { padding: clamp(2rem, 6vh, 3.5rem) 0 clamp(3rem, 8vh, 5rem); }
.target h1.host { font-family: var(--mono); font-size: clamp(1.5rem, 3.6vw, 2.4rem); letter-spacing: -0.02em; word-break: break-word; margin-bottom: 0.25em; }
.target .what { font-family: var(--serif-display); font-size: 1.25rem; color: var(--sumi-soft); margin-bottom: 0.8em; }
.prose { max-width: var(--measure); }
.prose:empty { display: none; }
.about p { color: var(--sumi); }
.notes { margin-top: 2rem; color: var(--sumi-soft); font-size: 0.95rem; }

.year-strip { margin: 1.8rem 0 0; max-width: 46rem; }
.year-strip .spark { height: 1.6rem; }
.year-strip .months { margin-top: 0.15rem; }
.year-strip figcaption { font-size: 0.78rem; color: var(--sumi-faint); margin-top: 0.2rem; }

.submitted { margin-top: 2.5rem; border-top: 1px solid var(--wash); padding-top: 1.4rem; }
.submitted h2 { font-size: 1.25rem; }
.on { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: 1.2rem 2.4rem; align-items: start; }
.on h4 { font-family: var(--serif-text); font-size: 0.85rem; color: var(--sumi-soft); margin-bottom: 0.35rem; }
.on table { width: 100%; border-collapse: collapse; font-size: 0.85rem; font-variant-numeric: lining-nums tabular-nums; }
.on td { padding: 0.12rem 0; border-bottom: 1px solid var(--wash-soft); }
.on td.host { font-size: 0.78rem; padding-right: 0.8rem; word-break: break-all; }
.on td.num { text-align: right; }
.on tr.unnamed td { color: var(--sumi-faint); font-style: italic; }
.on details.more summary { cursor: pointer; font-size: 0.78rem; color: var(--sumi-soft); padding: 0.2rem 0; }
.on details.more summary:hover { color: var(--sumi); }
.chart-note { font-size: 0.8rem; color: var(--sumi-soft); margin: 0.4rem 0 0; max-width: var(--measure); }

.pager { display: flex; justify-content: space-between; gap: 1rem; margin-top: 3rem; border-top: 1px solid var(--wash); padding-top: 1rem; font-size: 0.85rem; }
.pager a { text-decoration: none; color: var(--sumi-soft); display: flex; flex-direction: column; }
.pager a:hover { color: var(--sumi); }
.pager .next { margin-left: auto; text-align: right; }
.pager a > span:first-child { font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--sumi-faint); }

/* ---------- prose pages ---------- */

.page { padding: clamp(2.5rem, 7vh, 4rem) 0 clamp(3rem, 8vh, 5rem); }
.page h2 { font-size: 1.35rem; margin-top: 2rem; }
.page li { margin-bottom: 0.5em; }

/* ---------- #draft ---------- */

.show-draft [data-draft] { outline: 1px dashed var(--carrier); outline-offset: 6px; }

/* ---------- narrow screens ---------- */

@media (max-width: 900px) {
  .routes ul { grid-template-columns: 1fr 1fr; }
  .overview th.route, .overview td.route { display: none; }
  .amap-foot { grid-template-columns: 1fr; }
  .amap-foot .pages { grid-column: 1; }
}

@media (max-width: 640px) {
  .brand .long { display: none; }
  .brand .short { display: inline; }
  .routes ul { grid-template-columns: 1fr; }
  .stats .stat-group:last-child { padding-left: 0; border-left: 0; }
  /* Each target becomes two lines: its name and total, then its year
     across the full width. */
  .overview .peak { display: none; }
  .overview tr { display: grid; grid-template-columns: 1fr auto; column-gap: 1rem; }
  .overview tr.group { display: block; }
  .overview .t { grid-row: 1; grid-column: 1; min-width: 0; }
  .overview .total { grid-row: 1; grid-column: 2; }
  .overview .year { grid-row: 2; grid-column: 1 / -1; width: auto; min-width: 0; padding-left: 0; }
  .overview thead th.year { padding-top: 0.2rem; }
  .overview thead tr { border-bottom: 1px solid var(--wash); }
  .overview thead th { border-bottom: 0; }
  .overview td.year { padding-top: 0; }
}
