/* humanverse.com
 *
 * One stylesheet, no framework, no webfont. The whole point of the site is
 * that a page is cheap to render and cheap to load; a 200KB CSS bundle would
 * undo the work the server-rendered chart is doing.
 */

:root {
  --hv-bg: #ffffff;
  --hv-panel: #f6f7f9;
  --hv-ink: #16181d;
  --hv-ink-soft: #5b6270;
  --hv-line: #dfe3ea;
  --hv-link: #1a5fb4;
  --hv-f: #b5479b;
  --hv-m: #2a7fb8;
  /* Compare lines. c1 and c2 are the sex colours, so a two-name chart
     reads the same way round as a name page. c3 and c4 only appear on a
     three- or four-name comparison. */
  --hv-c1: #2a7fb8;
  --hv-c2: #b5479b;
  --hv-c3: #2f8f5b;
  --hv-c4: #b0701a;
  /* The header ribbon. Its defaults are what the header already looked
     like - the body background showing through, with the ordinary ink
     and link colours - so declaring them changes nothing until a name
     theme overrides them. See the theme/ directory. */
  --hv-ribbon: var(--hv-bg);
  --hv-ribbon-ink: var(--hv-ink);
  --hv-ribbon-link: var(--hv-link);
  /* The search field and its button sit inside the ribbon. On a coloured
     ribbon they are the whole difficulty: a white input on a pink band
     cuts the band in half, which is exactly what it looks like. These
     default to the ordinary field colours, so an unthemed header is
     unchanged. */
  --hv-ribbon-field: var(--hv-bg);
  --hv-ribbon-field-ink: var(--hv-ink);
  --hv-ribbon-field-soft: var(--hv-ink-soft);
  --hv-ribbon-field-line: var(--hv-line);
  --hv-ribbon-btn: var(--hv-link);
  --hv-ribbon-btn-ink: #fff;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --hv-bg: #14161a;
    --hv-panel: #1c1f26;
    --hv-ink: #e8eaee;
    --hv-ink-soft: #9aa2b1;
    --hv-line: #2c313b;
    --hv-link: #7cb0f0;
    --hv-f: #e07ac4;
    --hv-m: #5aa9dd;
    --hv-c1: #5aa9dd;
    --hv-c2: #e07ac4;
    --hv-c3: #5cc08c;
    --hv-c4: #dda13f;
  }
}

:root[data-theme="dark"] {
  --hv-bg: #14161a;
  --hv-panel: #1c1f26;
  --hv-ink: #e8eaee;
  --hv-ink-soft: #9aa2b1;
  --hv-line: #2c313b;
  --hv-link: #7cb0f0;
  --hv-f: #e07ac4;
  --hv-m: #5aa9dd;
  --hv-c1: #5aa9dd;
  --hv-c2: #e07ac4;
  --hv-c3: #5cc08c;
  --hv-c4: #dda13f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--hv-bg);
  color: var(--hv-ink);
  font: 17px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

a { color: var(--hv-link); }

/* Three columns: brand | search | section links. The outer columns size
 * to their content and the middle takes the rest, so the search sits
 * centred and the links stay hard right no matter how wide the brand
 * or the link list gets. Column placement is explicit, so the front
 * page - which omits the search - still puts the links hard right
 * against an empty middle column. */
.hv-top {
  display: grid;
  /* Equal side columns, content-sized middle: that is what actually puts
   * the search on the page centre. With auto|1fr|auto it centres within
   * the middle column instead, which drifts off-centre whenever the brand
   * and the link list are different widths - and they always are. */
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  padding: .85rem 1.25rem;
  background: var(--hv-ribbon);
  border-bottom: 1px solid var(--hv-line);
}
.hv-brand {
  grid-column: 1;
  font-weight: 700;
  text-decoration: none;
  color: var(--hv-ribbon-ink);
  letter-spacing: -.01em;
}
.hv-topsearch { grid-column: 2; }
/* flex + gap rather than margins on the links: it drops the leading margin
 * and the whitespace between inline elements, which together were nine
 * pixels more than a 375px screen has and wrapped "Tools" onto its own
 * line. */
.hv-nav {
  grid-column: 3;
  justify-self: end;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}
.hv-nav a { text-decoration: none; font-size: .95rem; color: var(--hv-ribbon-link); }

.hv-wrap { max-width: 780px; margin: 0 auto; padding: 1.25rem 1.25rem 3rem; }

.hv-crumbs { font-size: .85rem; color: var(--hv-ink-soft); margin: 0 0 .75rem; }
.hv-crumbs a { color: var(--hv-ink-soft); }

h1 { font-size: 2.4rem; line-height: 1.15; margin: 0 0 .5rem; letter-spacing: -.02em; }
h2 { font-size: 1.2rem; margin: 0 0 .75rem; letter-spacing: -.01em; }

.hv-lede { font-size: 1.1rem; margin: 0 0 1.5rem; }

.hv-section {
  border-top: 1px solid var(--hv-line);
  padding-top: 1.5rem;
  margin-top: 1.5rem;
}

/* Chart -------------------------------------------------------------- */

.hv-chart { display: block; width: 100%; height: auto; overflow: visible; }
.hv-grid { stroke: var(--hv-line); stroke-width: 1; }
.hv-axis-line { stroke: var(--hv-line); stroke-width: 1; }
.hv-peak { stroke: var(--hv-ink-soft); stroke-width: 1; stroke-dasharray: 3 3; opacity: .7; }
.hv-axis { fill: var(--hv-ink-soft); font-size: 11px; }
.hv-axis-y { text-anchor: end; }
.hv-axis-x { text-anchor: middle; }

.hv-legend { font-size: .9rem; color: var(--hv-ink-soft); margin: .5rem 0 0; }
.hv-key { display: inline-block; width: .8rem; height: .2rem; vertical-align: middle; margin: 0 .3rem 0 1rem; }
.hv-legend .hv-key:first-child { margin-left: 0; }
.hv-key-f { background: var(--hv-f); }
.hv-key-m { background: var(--hv-m); }

/* Stats -------------------------------------------------------------- */

.hv-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: .75rem;
  margin: 0;
}
.hv-stats div { background: var(--hv-panel); border-radius: 8px; padding: .7rem .85rem; }
.hv-stats dt { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--hv-ink-soft); }
.hv-stats dd { margin: .15rem 0 0; font-size: 1.35rem; font-weight: 600; font-variant-numeric: tabular-nums; }

/* State bars --------------------------------------------------------- */

.hv-bars { list-style: none; margin: 0; padding: 0; }
.hv-bars li { display: grid; grid-template-columns: 2.2rem 1fr 4.5rem; align-items: center; gap: .6rem; padding: .18rem 0; }
.hv-bar-label { font-size: .85rem; color: var(--hv-ink-soft); font-weight: 600; }
.hv-bar-track { background: var(--hv-panel); border-radius: 3px; height: .7rem; }
.hv-bar-fill { display: block; height: 100%; border-radius: 3px; background: var(--hv-link); }
.hv-bar-value { font-size: .85rem; text-align: right; font-variant-numeric: tabular-nums; color: var(--hv-ink-soft); }

/* Link chips --------------------------------------------------------- */

.hv-chips { list-style: none; display: flex; flex-wrap: wrap; gap: .45rem; margin: 0 0 .75rem; padding: 0; }
.hv-chips li { background: var(--hv-panel); border-radius: 999px; padding: .3rem .8rem; font-size: .92rem; }
.hv-chips a { text-decoration: none; }
.hv-rel { color: var(--hv-ink-soft); font-size: .8rem; margin-left: .35rem; }

.hv-tools ul { padding-left: 1.1rem; margin: 0; }
.hv-tools li { margin: .3rem 0; }

.hv-source { font-size: .82rem; color: var(--hv-ink-soft); margin-top: 1rem; }
.hv-meaning { font-size: 1.05rem; }

/* Ads ---------------------------------------------------------------- */

/* Reserve the height before the unit loads, or the layout shift costs more
 * ranking than the impression earns. */
.hv-ad { min-height: 280px; margin: 1.5rem 0; }
.hv-ad:empty { display: block; }

.hv-foot {
  border-top: 1px solid var(--hv-line);
  padding: 1.25rem;
  text-align: center;
  font-size: .85rem;
  color: var(--hv-ink-soft);
}

@media (max-width: 480px) {
  h1 { font-size: 1.9rem; }
  body { font-size: 16px; }
}

/* Tools ---------------------------------------------------------------- */

.hv-tool-list { list-style: none; margin: 0; padding: 0; }
.hv-tool-list li { padding: .55rem 0; border-bottom: 1px solid var(--hv-line); }
.hv-tool-list li:last-child { border-bottom: 0; }
.hv-tool-list a { font-size: 1.05rem; }
.hv-tool-list span { display: block; font-size: .88rem; color: var(--hv-ink-soft); }

.hv-tool-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: .75rem;
  background: var(--hv-panel);
  border-radius: 10px;
  padding: 1rem;
  margin: 0 0 1.5rem;
}
.hv-tool-form > div { display: flex; flex-direction: column; gap: .25rem; flex: 1 1 8rem; }
.hv-tool-form label { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--hv-ink-soft); }
.hv-tool-form input,
.hv-tool-form select {
  padding: .5rem .6rem;
  font-size: 1rem;
  color: var(--hv-ink);
  background: var(--hv-bg);
  border: 1px solid var(--hv-line);
  border-radius: 8px;
  width: 100%;
}
.hv-tool-form button {
  flex: 0 0 auto;
  padding: .6rem 1.2rem;
  font-size: 1rem;
  color: #fff;
  background: var(--hv-link);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.hv-result { border-top: 1px solid var(--hv-line); padding-top: 1.25rem; margin-top: 1.25rem; }
.hv-result-big {
  font-size: 2.6rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -.02em;
  margin: 0 0 .75rem;
  font-variant-numeric: tabular-nums;
}
.hv-result-big span {
  display: block;
  font-size: 1rem;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--hv-ink-soft);
  margin-top: .25rem;
}
.hv-result-empty .hv-result-big { font-size: 1.2rem; }

@media (max-width: 480px) {
  .hv-result-big { font-size: 2rem; }
}

/* Year pages ----------------------------------------------------------- */

.hv-year-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: .6rem 0;
  border-top: 1px solid var(--hv-line);
  border-bottom: 1px solid var(--hv-line);
  font-size: .95rem;
}
.hv-year-nav a { text-decoration: none; }

.hv-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
@media (max-width: 620px) { .hv-two-col { grid-template-columns: 1fr; } }

.hv-rank-table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.hv-rank-table th {
  text-align: left;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--hv-ink-soft);
  font-weight: 600;
  padding: 0 .5rem .35rem 0;
  border-bottom: 1px solid var(--hv-line);
}
.hv-rank-table td { padding: .28rem .5rem .28rem 0; border-bottom: 1px solid var(--hv-line); }
.hv-rank-table tr:last-child td { border-bottom: 0; }
.hv-rank-table td:first-child,
.hv-rank-table th:first-child { width: 3rem; color: var(--hv-ink-soft); font-variant-numeric: tabular-nums; }
.hv-rank-table td:last-child,
.hv-rank-table th:last-child { text-align: right; font-variant-numeric: tabular-nums; color: var(--hv-ink-soft); }
.hv-rank-table a { text-decoration: none; }

.hv-movers { list-style: none; margin: 0; padding: 0; }
.hv-movers li {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: baseline;
  gap: .75rem;
  padding: .3rem 0;
  border-bottom: 1px solid var(--hv-line);
}
.hv-movers li:last-child { border-bottom: 0; }
.hv-mover-move { font-size: .85rem; color: var(--hv-ink-soft); font-variant-numeric: tabular-nums; }
.hv-mover-gain { font-size: .85rem; font-weight: 600; color: var(--hv-f); font-variant-numeric: tabular-nums; }

/* The two-column year lists sit directly under the year nav, which already
 * draws a rule - a second border-top there reads as an empty band. */
.hv-two-col .hv-section { border-top: 0; margin-top: 0; padding-top: 1rem; }
@media (max-width: 620px) {
  .hv-two-col .hv-section + .hv-section {
    border-top: 1px solid var(--hv-line);
    padding-top: 1.25rem;
  }
}

/* Surnames -------------------------------------------------------------- */

/* The ethnicity labels are sentences, not two-letter state codes, so the
 * shared bar grid needs a wider first column when they are in use. */
.hv-bars li:has(.hv-bar-label-wide) { grid-template-columns: 13rem 1fr 4rem; }
.hv-bar-label-wide { font-weight: 400; }

@media (max-width: 560px) {
  .hv-bars li:has(.hv-bar-label-wide) {
    grid-template-columns: 1fr auto;
    grid-template-areas: "label value" "track track";
    row-gap: .15rem;
  }
  .hv-bars li:has(.hv-bar-label-wide) .hv-bar-label-wide { grid-area: label; }
  .hv-bars li:has(.hv-bar-label-wide) .hv-bar-value { grid-area: value; }
  .hv-bars li:has(.hv-bar-label-wide) .hv-bar-track { grid-area: track; }
}

/* Etymology ------------------------------------------------------------ */

.hv-meaning-label {
  display: inline-block;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--hv-ink-soft);
  margin-right: .4rem;
}
.hv-meaning { margin: 0 0 .6rem; }

/* Header search -------------------------------------------------------- */

/* The ribbon is brand | nav | search. Below 720px the search drops to its
 * own full-width row rather than being squeezed to nothing. */
.hv-topsearch {
  display: flex;
  gap: .4rem;
  width: 26rem;
  max-width: 100%;
}
.hv-topsearch input {
  flex: 1 1 auto;
  min-width: 0;
  padding: .4rem .65rem;
  font-size: .95rem;
  color: var(--hv-ribbon-field-ink);
  background: var(--hv-ribbon-field);
  border: 1px solid var(--hv-ribbon-field-line);
  border-radius: 999px;
}
.hv-topsearch input::placeholder { color: var(--hv-ribbon-field-soft); }
/* Same on the ribbon box, so the two search fields behave alike. */
.hv-topsearch input:focus::placeholder { color: transparent; }
.hv-topsearch input:focus-visible {
  outline: 2px solid var(--hv-ribbon-field-ink);
  outline-offset: 1px;
}
.hv-topsearch button {
  flex: 0 0 auto;
  padding: .4rem .9rem;
  font-size: .9rem;
  color: var(--hv-ribbon-btn-ink);
  background: var(--hv-ribbon-btn);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}

@media (max-width: 720px) {
  /* One column, three rows: brand, then the section links, then the
   * search. It used to be two rows, with the brand and all seven links
   * sharing the first one - which was written when there were four links
   * and had become a wall of small type by the time States, World and
   * Compare were added. A phone screen has height to spare and width it
   * does not, so the fix is to spend a row rather than shrink the type
   * any further. Desktop is untouched: it keeps the single ribbon. */
  .hv-top {
    grid-template-columns: minmax(0, 1fr);
    row-gap: .55rem;
  }
  .hv-brand     { grid-column: 1; grid-row: 1; }
  .hv-nav       { grid-column: 1; grid-row: 2; justify-self: start; }
  /* With a row to itself the list no longer has to squeeze past the
   * brand, so the spacing goes back up rather than down. It still wraps
   * if it has to - seven links do not fit on one line of a small phone,
   * and a second line of links is better than a scrollbar or an
   * abbreviation. */
  .hv-nav       { gap: .55rem .9rem; }
  .hv-nav a     { font-size: .9rem; }
  .hv-topsearch {
    grid-column: 1;
    grid-row: 3;
    justify-self: stretch;
    /* width:auto, not the 26rem set for the centred desktop layout -
     * an explicit width beats justify-self:stretch and overflows. */
    width: auto;
    max-width: none;
    min-width: 0;
  }
}

/* Visible to screen readers only - the search input needs a label even
 * though the placeholder makes its purpose obvious on screen. */
.hv-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Front-page hero ------------------------------------------------------ */

.hv-hero {
  padding: 2.5rem 0 2rem;
  text-align: center;
}
/* Not a brand shout: the h1 is a short instruction, so it sits close in
 * size to the text around it rather than dominating the page. */
.hv-hero h1 {
  font-size: 1.9rem;
  margin: 0 0 .4rem;
  letter-spacing: -.015em;
}
.hv-hero-lede {
  font-size: 1.1rem;
  color: var(--hv-ink-soft);
  max-width: 34rem;
  margin: 0 auto 1.6rem;
}

.hv-herosearch {
  display: flex;
  gap: .5rem;
  max-width: 34rem;
  margin: 0 auto;
}
.hv-herosearch input {
  flex: 1 1 auto;
  min-width: 0;
  padding: .85rem 1.1rem;
  font-size: 1.15rem;
  color: var(--hv-ink);
  background: var(--hv-panel);
  border: 1px solid var(--hv-line);
  border-radius: 999px;
}
/* The placeholder is a set of examples, not a label, and it has done its
 * job the moment somebody clicks in. Kept visible until focus, then out
 * of the way, so nobody is typing over the top of "Emma, Cooper". CSS
 * rather than script: the site runs no JavaScript of its own, and a
 * browser too old for this simply shows the placeholder as before. */
.hv-herosearch input::placeholder { color: var(--hv-ink-soft); }
.hv-herosearch input:focus::placeholder { color: transparent; }
.hv-herosearch input:focus-visible {
  outline: 2px solid var(--hv-link);
  outline-offset: 2px;
  background: var(--hv-bg);
}
.hv-herosearch button {
  flex: 0 0 auto;
  padding: .85rem 1.6rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: #fff;
  background: var(--hv-link);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}

.hv-hero-hint {
  font-size: .9rem;
  color: var(--hv-ink-soft);
  margin: .9rem 0 0;
}

/* The first section after the hero already reads as a break. */
.hv-hero + .hv-section { border-top: 0; margin-top: 1.25rem; padding-top: 0; }

@media (max-width: 560px) {
  .hv-hero { padding: 1.5rem 0 1.25rem; }
  .hv-hero h1 { font-size: 1.55rem; }
  .hv-hero-lede { font-size: 1rem; margin-bottom: 1.2rem; }
  .hv-herosearch { flex-wrap: wrap; }
  .hv-herosearch input { flex: 1 0 100%; font-size: 1.05rem; }
  .hv-herosearch button { flex: 1 0 100%; }
}

/* Sub-headings inside a two-column block. */
.hv-two-col h3 {
  font-size: .95rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--hv-ink-soft);
  margin: 0 0 .5rem;
}

/* Notable people ------------------------------------------------------- */

.hv-people { list-style: none; margin: 0; padding: 0; }
.hv-people li {
  padding: .5rem 0;
  border-bottom: 1px solid var(--hv-line);
}
.hv-people li:last-child { border-bottom: 0; }
.hv-person-name { font-weight: 600; }
.hv-person-years { color: var(--hv-ink-soft); font-size: .9rem; font-variant-numeric: tabular-nums; }
.hv-person-desc {
  display: block;
  font-size: .9rem;
  color: var(--hv-ink-soft);
  margin-top: .1rem;
}

/* Comparisons ---------------------------------------------------------- */

.hv-key-c1 { background: var(--hv-c1); }
.hv-key-c2 { background: var(--hv-c2); }
.hv-key-c3 { background: var(--hv-c3); }
.hv-key-c4 { background: var(--hv-c4); }

/* The side-by-side table: a row per measure, a column per name. It is not
   .hv-rank-table - that one right-aligns its last column, which here would
   be one name of four set differently from the rest. */
.hv-vs { width: 100%; border-collapse: collapse; font-size: .95rem; }
.hv-vs th {
  text-align: left;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--hv-ink-soft);
  font-weight: 600;
  padding: .4rem .5rem .4rem 0;
  border-bottom: 1px solid var(--hv-line);
}
.hv-vs thead th { font-size: 1rem; text-transform: none; letter-spacing: 0; color: var(--hv-ink); }
.hv-vs thead th a { text-decoration: none; }
.hv-vs td {
  padding: .4rem .5rem .4rem 0;
  border-bottom: 1px solid var(--hv-line);
  font-variant-numeric: tabular-nums;
}
.hv-vs tr:last-child td, .hv-vs tr:last-child th { border-bottom: 0; }
.hv-vs .hv-vs-lead { font-weight: 600; }
.hv-vs-wrap { overflow-x: auto; }

/* Who was ahead, and when. */
.hv-runs { list-style: none; margin: 0; padding: 0; font-size: .95rem; }
.hv-runs li {
  display: grid;
  grid-template-columns: 7.5rem 1fr;
  gap: .6rem;
  padding: .3rem 0;
  border-bottom: 1px solid var(--hv-line);
}
.hv-runs li:last-child { border-bottom: 0; }
.hv-run-years { color: var(--hv-ink-soft); font-variant-numeric: tabular-nums; }

@media (max-width: 560px) {
  .hv-runs li { grid-template-columns: 6rem 1fr; }
}

/* The share chart's half-way line, which is the thing it is about. */
.hv-half { stroke: var(--hv-ink-soft); stroke-width: 1; stroke-dasharray: 4 3; opacity: .8; }

/* A split bar reads as a proportion, not a magnitude, so it is filled the
   whole way and the fill marks the girls' share of it. */
.hv-split { background: var(--hv-m); }
.hv-split .hv-bar-fill { background: var(--hv-f); }
.hv-flips th[scope="row"] { font-weight: 600; }
.hv-flips td { text-align: right; }

/* Born, and still here. The fill is the living; the thin line above it is
   what was born, so the space between them is the loss. */
.hv-alive-fill { fill: var(--hv-link); opacity: .18; }
.hv-alive-line { stroke: var(--hv-link); stroke-width: 2; stroke-linejoin: round; }
.hv-born-line { stroke: var(--hv-ink-soft); stroke-width: 1; stroke-dasharray: 3 2; opacity: .9; }
.hv-key-alive { background: var(--hv-link); }
.hv-key-born { background: var(--hv-ink-soft); }
