/* A community's analytics (/manage/analytics): the period switch, the headline tiles, the
   charts and the ranked lists. It sits inside the owner interface and borrows its cards,
   tiles (.m-stats) and card headings from manage.css.

   Mobile first: the rules outside a query lay the page out for a phone. The charts and
   lists go side by side by the width of the page (min-width), and a chart's columns get
   wider by the width of ITS OWN CARD (a container query), because the same chart is a
   whole row on a phone and half a row on a desktop.

   Every color is a custom property from site.css. The two chart colors (--chart-1,
   --chart-2) were added there for this file, each with a light and a dark value picked
   for that surface. Text is never drawn in a chart color: a colored mark sits beside it. */

/* ---- The period switch: three links, the one in use filled ---- */
.an-period { display: flex; flex-wrap: wrap; gap: 8px; }
.an-period a {
  display: inline-flex; align-items: center; justify-content: center; min-width: 76px; min-height: 44px; padding: 0 14px;
  border: 1px solid var(--button-line); border-radius: var(--radius-small);
  background: var(--surface); color: var(--ink); font-weight: 600; text-decoration: none; box-shadow: var(--elev-1);
  transition: border-color var(--ease), box-shadow var(--ease);
}
.an-period a:hover { border-color: var(--control-line); box-shadow: var(--elev-2); }
.an-period a[aria-current="true"] { border-color: var(--ink); background: var(--ink); color: var(--on-ink); }

/* ---- The headline tiles: the number, then how it compares with the period before, in
   words. The arrow only repeats the words; neither is told by color. ---- */
.an-tiles .m-stat { display: flex; flex-direction: column; }
.m-stat dd.an-change { margin-top: 4px; color: var(--muted); font-family: var(--font); font-size: 13px; font-weight: 400; line-height: 1.35; letter-spacing: 0; }
.an-arrow { margin-right: 2px; color: var(--ink); font-weight: 700; }

/* The quieter numbers at the foot of the page. */
.an-group { margin: 0 0 10px; font-size: 17px; font-weight: 700; }
.an-small .m-stat dd { font-size: 20px; }

/* ---- A chart's card: title and total, legend, the picture, the numbers ---- */
.an-figure { container-type: inline-size; display: flex; flex-direction: column; gap: 12px; padding: 16px; }
.an-figure-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 16px; }
.an-title { margin: 0; font-size: 17px; font-weight: 700; }
.an-sum { margin: 0; color: var(--muted); font-size: 14px; }
.an-sum strong, .an-legend strong { color: var(--ink); }

.an-legend { margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 4px 20px; color: var(--muted); font-size: 13px; }
.an-legend li { display: flex; align-items: flex-start; gap: 6px; }
.an-key { flex: none; width: 12px; height: 12px; margin-top: 3px; border-radius: 3px; }
.an-key-1 { background: var(--chart-1); }
.an-key-2 { background: var(--chart-2); }

.an-chart { display: flex; flex-direction: column; gap: 6px; }
/* The name of one plot of two that share their days ("Posts", "Threads"). */
.an-panel { margin: 4px 0 6px; color: var(--label); font-size: 13px; font-weight: 700; }

/* ---- The plot (Manage/_DayPlot): values up the side as text, then the picture. Up and
   down the picture is in real pixels; left to right it is percentages of its own width,
   so it fills the card at any width and its text never scales. ---- */
.ch { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 8px; padding-right: 4px; }
/* The values: evenly spaced from the top of the plot to its baseline, each one a line of
   no height so it is centered on the gridline it names. */
.ch-y { display: flex; flex-direction: column; justify-content: space-between; min-width: 14px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; text-align: right; }
.ch-y span { display: block; height: 0; line-height: 0; white-space: nowrap; }
.ch-plot { position: relative; min-width: 0; }
.ch-svg { display: block; overflow: visible; }
.ch-grid { stroke: var(--line); stroke-width: 1; shape-rendering: crispEdges; }
.ch-axis { stroke: var(--control-line); stroke-width: 1; shape-rendering: crispEdges; }
.ch-date text { fill: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.ch-date.ch-wide { display: none; }

/* A column: centered on its day whatever its width, rounded at its top end only (the
   baseline end stays square), in its series' color. */
.ch-bar { width: var(--ch-bar, 4px); transform-box: fill-box; transform: translateX(-50%); }
.ch-bar.ch-top { clip-path: inset(0 round 4px 4px 0 0); }
.ch-s1 { fill: var(--chart-1); }
.ch-s2 { fill: var(--chart-2); }
/* The band behind a day shows under the pointer, so it is plain which day the browser's
   tooltip is about. */
.ch-hit { fill: var(--ink); opacity: 0; }
.ch-day:hover .ch-hit { opacity: 0.07; }

/* How wide a column is, by how many days share the plot and how wide the card is. The
   numbers leave air between neighbors at every width; a week's columns stop at 24 px. */
.ch.n7 { --ch-bar: 20px; }
.ch.n30 { --ch-bar: 5px; }
.ch.n90 { --ch-bar: 2px; }
@container (min-width: 440px) {
  .ch.n7 { --ch-bar: 24px; }
  .ch.n30 { --ch-bar: 8px; }
  .ch.n90 { --ch-bar: 2.5px; }
  .ch-date.ch-wide { display: inline; }
}
@container (min-width: 660px) {
  .ch.n30 { --ch-bar: 12px; }
  .ch.n90 { --ch-bar: 4px; }
}
@container (min-width: 920px) {
  .ch.n30 { --ch-bar: 16px; }
  .ch.n90 { --ch-bar: 6px; }
}

/* A plot with nothing in it says so across itself. */
.ch-empty { position: absolute; inset: 0 0 22px; display: flex; align-items: center; justify-content: center; margin: 0; padding: 0 12px; color: var(--muted); font-size: 14px; text-align: center; }

/* ---- "Show the numbers": the same days as a table, in a box that scrolls inside itself ---- */
.an-numbers { border-top: 1px solid var(--line-soft); margin: 0 -16px -16px; }
.an-numbers summary { display: flex; align-items: center; min-height: 44px; padding: 0 16px; color: var(--accent); font-weight: 600; cursor: pointer; list-style-position: inside; }
.an-numbers summary:hover { text-decoration: underline; }
.an-numbers summary:focus-visible, .an-table-box:focus-visible, .an-period a:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: var(--radius-chip); }
.an-table-box { max-height: 320px; overflow: auto; border-top: 1px solid var(--line-soft); }
.an-table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.an-table th, .an-table td { padding: 8px 6px; border-top: 1px solid var(--line-soft); text-align: right; white-space: nowrap; }
.an-table th:first-child { padding-left: 16px; text-align: left; font-weight: 400; }
.an-table th:last-child, .an-table td:last-child { padding-right: 16px; }
.an-table thead th { position: sticky; top: 0; border-top: 0; background: var(--surface-head); color: var(--label); font-size: 13px; font-weight: 700; }
.an-table tbody tr:first-child th, .an-table tbody tr:first-child td { border-top: 0; }

/* ---- The ranked lists: a name, its number, and a thin bar as long as its share of the
   list's largest. One color for every bar: the length is the measure. ---- */
.an-rank { margin: 0; padding: 0; list-style: none; }
.an-rank li { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 0 12px; padding: 4px 16px 12px; border-top: 1px solid var(--line-soft); }
.an-rank li:first-child { border-top: 0; }
.an-rank-name { display: inline-flex; align-items: center; min-height: 44px; min-width: 0; color: var(--ink); font-weight: 600; text-decoration: none; overflow-wrap: anywhere; }
.an-rank-name:hover { color: var(--accent); text-decoration: underline; }
.an-rank-count { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; text-align: right; }
/* A thread's title is long: its numbers go on a line of their own under it. */
.an-rank-stacked li { grid-template-columns: minmax(0, 1fr); }
.an-rank-stacked .an-rank-count { margin: -4px 0 8px; text-align: left; }
.an-rank-bar { grid-column: 1 / -1; display: block; }
.an-rank-bar rect { fill: var(--chart-1); clip-path: inset(0 round 0 3px 3px 0); }
/* With a face: the avatar, then the name. */
.an-rank-faces li { grid-template-columns: auto minmax(0, 1fr) auto; }

/* ---- The small print under everything ---- */
.an-notes { color: var(--muted); font-size: 14px; }
.an-notes p { margin: 0 0 6px; max-width: 760px; }

.an-pair, .an-lists { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; align-items: start; }

/* Tablet and up: more air, and the lists side by side where three fit. */
@media (min-width: 768px) {
  .an-figure { padding: 20px; gap: 14px; }
  .an-numbers { margin: 0 -20px -20px; }
  .an-numbers summary, .an-table th:first-child { padding-left: 20px; }
  .an-table th, .an-table td { padding-right: 12px; }
  .an-table th:last-child, .an-table td:last-child { padding-right: 20px; }
  .an-rank li { padding-left: 20px; padding-right: 20px; }
  .an-pair, .an-lists { gap: 16px; }
  .an-small { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1000px) {
  .an-pair { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .an-lists { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
