/* The token layer both sites load after pico.classless.min.css. Roughly a hundred lines of
 * things Pico does not do, and nothing else. Register is technical publication: typography and
 * tables first, no cards, no elevation, nothing that moves.
 *
 * The accent is per site. Each site emits one line of its own before this file loads:
 *
 *   <style>:root{--accent-light:#2a78d6;--accent-dark:#3987e5}</style>
 *
 * bitcoinpricedata.com is blue (#2a72cc light, #3987e5 dark), bitcoincalc.com is green
 * (#008300 light, #35a94c dark). All four clear 4.5:1 as text against their surface (the
 * accent reaches link text through --pico-primary, so 3:1 graphical contrast is not
 * enough), and the pair is separable under every simulated colour vision deficiency,
 * checked with the dataviz validator rather than by eye.
 *
 * Light and dark ride on Pico's own scheme handling, so this file only follows it. */

:root {
  --accent: var(--accent-light, #2a78d6);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent: var(--accent-dark, #3987e5);
  }
}

[data-theme="dark"] {
  --accent: var(--accent-dark, #3987e5);
}

/* Pico routes every link, focus ring and mark through --pico-primary, so the accent only has to
 * be handed to those four variables to reach the whole page. The selector pair matches every
 * root at specificity 0,2,0, because Pico defines these variables at that specificity too and a
 * plain :root hand-off silently loses to it in every theme state. Equal specificity, later
 * file, this wins. */
:root:not([data-theme="dark"]),
:root[data-theme="dark"] {
  --pico-primary: var(--accent);
  --pico-primary-hover: var(--accent);
  --pico-primary-focus: color-mix(in srgb, var(--accent) 25%, transparent);
  --pico-primary-underline: color-mix(in srgb, var(--accent) 40%, transparent);
  --pico-font-size: 100%;
}

/* Numbers. Every figure on this site is meant to be compared against the one above it, which
 * proportional digits make needlessly hard. */
table,
code,
kbd,
pre,
samp,
time,
.num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* Tables. Pico's defaults are roomy for a marketing page and wasteful for a manifest listing
 * forty rows, so the padding comes down and the header gets a rule instead of a fill. */
table {
  --pico-font-size: 0.875rem;
  margin-bottom: var(--pico-typography-spacing-vertical);
}

th,
td {
  padding: 0.3rem 0.75rem 0.3rem 0;
  border-bottom: 1px solid var(--pico-table-border-color);
  vertical-align: top;
}

thead th {
  background: none;
  border-bottom-width: 2px;
  font-weight: 600;
  white-space: nowrap;
}

tbody tr:hover > * {
  background: var(--pico-table-row-stripped-background-color);
}

/* Right-align anything that is a quantity. Marked in the markup, never guessed from content. */
td.num,
th.num {
  text-align: right;
  padding-right: 1.25rem;
}

td code,
th code {
  font-size: 0.8125em;
}

/* A checksum is 64 characters of nothing, so it breaks anywhere rather than setting the
 * width of the table it sits in. */
td.hash code {
  word-break: break-all;
}

/* Tables of identifiers and dates, where a wrapped token reads as two tokens. These scroll
 * inside their figure instead of wrapping. */
table.tight th,
table.tight td,
td.nowrap,
th.nowrap {
  white-space: nowrap;
}

/* Any wide block scrolls inside itself. */
figure,
.scroll-x {
  overflow-x: auto;
}

/* The prose column. Pico's container is generous, a methodology page reads better narrower. */
main {
  max-width: 46rem;
}

main > section {
  margin-bottom: calc(var(--pico-block-spacing-vertical) * 1.5);
}

/* A quiet aside for provenance notes and empty states. A left rule, not a card. */
.note {
  border-left: 3px solid var(--accent);
  padding: 0.1rem 0 0.1rem 1rem;
  margin: var(--pico-typography-spacing-vertical) 0;
  color: var(--pico-muted-color);
}

.note > :last-child {
  margin-bottom: 0;
}

/* Site chrome. */
body > header nav a {
  --pico-nav-link-spacing-horizontal: 0.5rem;
}

body > footer {
  border-top: 1px solid var(--pico-muted-border-color);
  font-size: 0.875rem;
  color: var(--pico-muted-color);
}

/* The landing chart. The plot area is a fixed 320px in the chart script, uPlot's legend sits
 * under it inside this box, so the box reserves the space and never caps it. Capping it would
 * clip the legend, which is also the hover readout. */
.chart {
  min-height: 340px;
}

/* The three fee index panels. Unlike .chart above, these carry NO legend inside the box: all
 * three are lifted out into .chart-readout below the group, so the box holds the canvas and
 * nothing else.
 *
 * That makes the reserve exact rather than generous, and it has to be. The three panels are
 * stacked flush to read as one chart, so every pixel a box reserves beyond its canvas becomes a
 * visible band between two panels and breaks the very continuity the stacking is for. Each value
 * below is its panel's height in chart-feeindex.js exactly: HEIGHT, QUANTITY_HEIGHT,
 * SPOT_HEIGHT. Change one there and change it here, or a seam opens up. */
.chart-tall {
  min-height: 340px;
}

/* The quantity panel, about a third of the height of the one above. */
.chart-short {
  min-height: 120px;
}

/* The spot price panel at the foot. Taller than the quantity panel above it: that one is bars
 * read against their own baseline and 120px is plenty, while this is a line over six and a half
 * decades of log axis, where height is resolution. Kept well under .chart-tall so the order of
 * the three still says which panel is the subject. */
.chart-spot {
  min-height: 220px;
}

/* Three legends now, not two, and the top panel's runs to four or five series. Reserved rather
 * than capped, for the same reason as .chart: too little here and the prose under the chart jumps
 * when the fetch resolves. */
.chart-readout {
  min-height: 5rem;
  margin-top: 0.25rem;
}

.u-legend {
  font-size: 0.8125rem;
}

/* The resolution toggle above a chart. Two buttons, pressed state carried on aria-pressed so the
 * markup says which one is current rather than a class saying it only to the stylesheet. */
.chart-res {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: var(--pico-typography-spacing-vertical);
}

/* The period presets, a second row under the resolution and quantity toggles. Closer to the row
 * above than that row is to the chart, because the two are one control block: the gap says these
 * belong together and the chart is what they act on. They do the same thing as dragging across
 * the chart, which stays available and is the only option a preset cannot express. */
.chart-range {
  margin-top: calc(var(--pico-typography-spacing-vertical) * -0.5);
}

.chart-res button {
  width: auto;
  margin: 0;
  padding: 0.25rem 0.75rem;
  font-size: 0.8125rem;
  background: none;
  color: var(--pico-muted-color);
  border-color: var(--pico-muted-border-color);
}

.chart-res button[aria-pressed="true"] {
  color: var(--accent);
  border-color: var(--accent);
}

/* Two groups of buttons in one row, resolution then quantity. The gap says they are separate
 * choices without needing a second row or a fieldset legend. */
.chart-res-gap {
  width: 1rem;
}

@media (max-width: 34rem) {
  .chart-res {
    flex-wrap: wrap;
  }

  .chart-res-gap {
    width: 100%;
    height: 0;
  }
}

/* Print, aimed at the methodology page, which is the one people actually print. Chrome goes,
 * links keep their targets, tables do not break across pages mid row. */
@media print {
  body > header,
  body > footer nav,
  .chart,
  .no-print {
    display: none;
  }

  body,
  main {
    max-width: none;
    font-size: 10.5pt;
    color: #000;
    background: #fff;
  }

  /* Paper has no scrollbar, so the horizontal-scroll containers and the no-wrap cells that
   * rely on them both have to give way, or the right-hand columns print off the sheet. */
  figure,
  .scroll-x {
    overflow: visible;
  }

  table {
    font-size: 9pt;
    width: 100%;
  }

  table.tight th,
  table.tight td,
  td.nowrap,
  th.nowrap {
    white-space: normal;
  }

  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    word-break: break-all;
  }

  h2,
  h3 {
    break-after: avoid;
  }

  tr,
  figure,
  .note {
    break-inside: avoid;
  }
}
