/* analytics.cfr.org — executive overview.
   Colors and type stacks come from cfr_brand.css; nothing here hardcodes a hex from the
   palette. Light mode: none of the brand's dark-mode justifications apply to an internal
   reporting surface. */

:root {
  --line: rgba(0, 0, 0, 0.09);
  --line-strong: rgba(0, 0, 0, 0.14);
  --ink-muted: rgba(0, 0, 0, 0.62);
  --ink-faint: rgba(0, 0, 0, 0.45);
  --surface: #ffffff;
  --canvas: #fbfaf9;
  --radius: 6px;
  --gutter: 24px;
  --max-width: 1140px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--cfr-black);
  font-family: var(--cfr-font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 56px;
  padding: 0 var(--gutter);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 12px; }

/* Height only: the monogram is portrait (1201x1521) and setting both dimensions
   independently would stretch it. */
.monogram { height: 22px; width: auto; display: block; }
.monogram-sm { height: 18px; }

.brand-divider { width: 1px; height: 20px; background: var(--line-strong); }

.brand-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.topbar-controls { display: flex; align-items: center; gap: 10px; }

.control-label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
}

.select {
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 6px 30px 6px 10px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%23000' stroke-opacity='.55' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 10px;
  cursor: pointer;
}

.select:disabled { opacity: 0.5; cursor: default; }
.select:focus-visible { outline: 2px solid var(--cfr-copper); outline-offset: 1px; }

/* ---------- layout ---------- */

main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 36px var(--gutter) 56px;
}

.page-head { margin-bottom: 24px; }

.accent-rule {
  display: block;
  width: 28px;
  height: 2px;
  background: var(--cfr-copper);
  margin-bottom: 14px;
}

/* The one editorial moment on the page. Caslon italic is reserved for headlines. */
.page-head h1 {
  font-family: var(--cfr-font-serif);
  font-style: italic;
  font-weight: 500;
  font-size: 27px;
  line-height: 1.15;
  margin: 0;
}

.page-sub {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--ink-muted);
}

/* ---------- KPI cards ---------- */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(232px, 1fr));
  gap: 14px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  min-height: 156px;
  display: flex;
  flex-direction: column;
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  min-height: 32px;
}

.card-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  margin: 0;
}

/* DM Mono, used the way the brand reserves it: a small categorical stamp. */
.chip {
  font-family: var(--cfr-font-mono);
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 6px;
  border-radius: 3px;
  white-space: nowrap;
}

.chip-interim { background: var(--cfr-sand); color: var(--cfr-black); }
.chip-certified { background: var(--cfr-water); color: var(--cfr-data-viridian); }

.card-value {
  font-size: 38px;
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  margin: 12px 0 0;
}

.card-value.is-missing { color: var(--ink-faint); }

/* Direction is carried by both the arrow and the colour, so the movement still
   reads for anyone who cannot separate the two hues. */
.card-delta {
  margin: 6px 0 0;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.delta-down { color: var(--cfr-data-copper); }
.delta-up { color: var(--cfr-data-viridian); }
.delta-flat { color: var(--ink-muted); }

.delta-arrow { font-size: 11px; }

.delta-context {
  font-weight: 400;
  color: var(--ink-faint);
}

.card-foot {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- panels ---------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  margin-top: 20px;
}

.panel-head { margin-bottom: 18px; }

.panel-title { font-size: 15px; font-weight: 600; margin: 0; }

.panel-sub {
  margin: 5px 0 0;
  font-size: 13px;
  color: var(--ink-muted);
  max-width: 68ch;
}

.panel-source {
  margin: 18px 0 0;
  font-size: 10px;
  font-weight: 500;
  color: var(--cfr-source);
}

/* Two trend charts side by side, stacking on a narrow screen. */
.panel-pair {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 20px;
}

.panel-pair .panel { margin-top: 20px; }

/* ---------- charts ---------- */

/* The chart carries its own aspect through the viewBox, so it scales with the
   column without a resize listener. */
.chart { display: block; width: 100%; height: auto; }

.chart-with-legend {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 24px;
  align-items: start;
}

.chart-holder { min-width: 0; }

.chart-empty {
  margin: 0;
  padding: 28px 0;
  font-size: 13px;
  color: var(--ink-faint);
}

/* The span a chart covers, which is not the period selected above it. */
.chart-span {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--ink-faint);
}

.grid-line {
  stroke: var(--cfr-gridline);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.axis-label {
  font-family: var(--cfr-font-sans);
  font-size: 11px;
  fill: var(--cfr-tick-label);
}

/* A hairline in the panel colour between bands. Web and Social are both coppers and
   sit next to each other in the stack, so without a separator the boundary between
   the two largest legs is the hardest thing on the chart to see. */
.area {
  stroke: var(--surface);
  stroke-width: 0.75;
}

.line {
  fill: none;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

/* ---------- legend ---------- */

.legend {
  border-left: 1px solid var(--line);
  padding-left: 18px;
}

.legend-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  margin: 0 0 10px;
}

.legend-row {
  display: grid;
  grid-template-columns: 10px 1fr auto auto auto;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  font-size: 13px;
}

.legend-swatch { width: 10px; height: 10px; border-radius: 2px; }

.legend-value { font-variant-numeric: tabular-nums; font-weight: 600; }

.legend-share {
  font-variant-numeric: tabular-nums;
  color: var(--ink-muted);
  min-width: 34px;
  text-align: right;
}

.legend-delta {
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 56px;
  text-align: right;
}

/* ---------- property composition ---------- */

.bars { display: grid; }

/* One part-to-whole bar. A bar per row cannot show both that one site carries most
   of the traffic and how the smaller sites compare with each other. */
.composition {
  display: flex;
  height: 14px;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 20px;
  gap: 1px;
  background: var(--surface);
}

.composition-segment { display: block; height: 100%; }

.property-row {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) 116px 52px 92px;
  align-items: center;
  gap: 12px;
  padding: 7px 0;
  font-size: 13px;
  border-top: 1px solid var(--line);
}

.property-row:first-of-type { border-top: 0; }

.property-name { font-weight: 500; }

.property-value {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  text-align: right;
}

.property-share {
  font-variant-numeric: tabular-nums;
  color: var(--ink-muted);
  text-align: right;
}

.property-delta {
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* ---------- notes ---------- */

/* The caveats run to roughly 2,600 characters. Stacked in one column they set a narrow
   ribbon of text down the left of a card twice as wide, so the groups tile instead. Each
   column lands near 65 characters, which is a readable measure for the serif. */
.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 24px 34px;
  align-items: start;
}

.note-group {
  border-left: 2px solid var(--line);
  padding-left: 15px;
}

.note-group h3 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  margin: 0 0 8px;
}

.note-list { margin: 0; padding: 0; list-style: none; }

.note-list li {
  font-family: var(--cfr-font-serif);
  font-size: 15.5px;
  line-height: 1.55;
  max-width: 68ch;
}

.note-list li + li { margin-top: 10px; }

/* ---------- definitions ---------- */

.subhead {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  margin: 26px 0 10px;
}

/* Columns rather than a grid: a definition list alternates dt and dd, so grid cells
   would put every term in one column and every definition in another, leaving the
   two halves of a pair at opposite ends of the panel. */
.definition-list {
  margin: 0;
  columns: 2;
  column-gap: 34px;
}

.definition-list dt {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  margin-bottom: 4px;
  break-after: avoid;
}

.definition-list dd {
  margin: 0 0 18px;
  font-family: var(--cfr-font-serif);
  font-size: 15.5px;
  line-height: 1.55;
  break-inside: avoid;
}

@media (max-width: 720px) {
  .definition-list { columns: 1; }
}

/* ---------- states ---------- */

.error-banner {
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--cfr-copper);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 20px;
  font-size: 14px;
}

.skeleton {
  background: rgba(0, 0, 0, 0.05);
  border-radius: 3px;
  color: transparent;
}

/* ---------- footer ---------- */

.footer {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 20px var(--gutter) 40px;
  border-top: 1px solid var(--line);
}

.footer-text p { margin: 0; }

.footer-org { font-size: 12px; font-weight: 500; }

.footer-meta { font-size: 11px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }

@media (max-width: 860px) {
  .chart-with-legend { grid-template-columns: minmax(0, 1fr); }
  .legend { border-left: 0; border-top: 1px solid var(--line); padding: 14px 0 0; }
}

@media (max-width: 560px) {
  .property-row { grid-template-columns: 10px minmax(0, 1fr) 88px 44px 72px; gap: 8px; }
  .card-value { font-size: 32px; }
  .notes-grid { gap: 20px; }
}
