/* farm.lukealbertson.com
   A working tool, not a landing page. Read in a truck cab, in sunlight, on a phone.

   Design notes for whoever touches this next:
   - The display face IS the monospace face. This document's world is fixed-width USDA
     market news and scale tickets, so the numbers are the typography.
   - Two functional colours only: NET is green (money you keep), FREIGHT is rust (money
     the truck eats). Everything else is ink on paper. Colour is never decoration here.
   - The signature element is .bite: a shared price axis where a solid green bar ends at
     NET and a hatched rust bar runs on to the headline BID. Sorted by net, you can see
     a high far-away bid getting dragged behind a close one. That picture is the product.
   - No @import, no webfonts, no external anything. The page must load with the radio on
     and one bar of signal.
*/

/* ------------------------------------------------------------------ tokens */

:root {
  color-scheme: light dark;

  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, "DejaVu Sans Mono", Consolas,
    "Liberation Mono", monospace;

  --wrap: 76rem;
  --gap: 1rem;
  --tap: 2.875rem; /* 46px minimum interactive height */
  --radius: 3px;

  /* Light: neutral paper, not cream. Maximum contrast wins in sunlight. */
  --paper: #fcfcf9;
  --panel: #f2f3ec;
  --panel-2: #e7e9de;
  --ink: #10130c;
  --ink-2: #464b3d;
  --ink-3: #6b7160;
  --rule: #ccd0c0;
  --rule-2: #99a089;
  --net: #14622f;
  --net-tint: #dcecdf;
  --freight: #9a3d12;
  --freight-tint: #f7e2d6;
  --flag: #7a5300;
  --flag-tint: #fbf0d3;
  --bad: #96231b;
  --link: #16548f;
  --focus: #16548f;
  --shadow: 0 1px 0 rgb(16 19 12 / 0.06);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0e110d;
    --panel: #171b15;
    --panel-2: #222720;
    --ink: #eef1e7;
    --ink-2: #b0b7a5;
    --ink-3: #838a76;
    --rule: #313828;
    --rule-2: #575f4b;
    --net: #5fc97e;
    --net-tint: #16301d;
    --freight: #e5895b;
    --freight-tint: #3a2117;
    --flag: #dcb54c;
    --flag-tint: #33290e;
    --bad: #ee7a6e;
    --link: #78b6f0;
    --focus: #8cc4ff;
    --shadow: none;
  }
}

:root[data-theme="dark"] {
  --paper: #0e110d;
  --panel: #171b15;
  --panel-2: #222720;
  --ink: #eef1e7;
  --ink-2: #b0b7a5;
  --ink-3: #838a76;
  --rule: #313828;
  --rule-2: #575f4b;
  --net: #5fc97e;
  --net-tint: #16301d;
  --freight: #e5895b;
  --freight-tint: #3a2117;
  --flag: #dcb54c;
  --flag-tint: #33290e;
  --bad: #ee7a6e;
  --link: #78b6f0;
  --focus: #8cc4ff;
  --shadow: none;
}

/* ------------------------------------------------------------------- reset */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

img,
svg {
  max-width: 100%;
}

a {
  color: var(--link);
  text-underline-offset: 2px;
}

a:hover {
  text-decoration-thickness: 2px;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 1px;
}

::selection {
  background: var(--net-tint);
  color: var(--ink);
}

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: clamp(0.875rem, 3vw, 1.75rem);
}

.vh {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* The skip link is the one visually-hidden thing that must come back on focus. */
.skip:focus-visible {
  position: fixed;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 10;
  width: auto;
  height: auto;
  clip-path: none;
  padding: 0.6rem 0.9rem;
  background: var(--paper);
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  font-weight: 700;
  text-decoration: none;
}

[hidden] {
  display: none !important;
}

/* --------------------------------------------------------------- numerals */

.num,
table,
input[type="number"],
.big,
.tag {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "zero" 1;
}

/* ------------------------------------------------------------------ header */

.masthead {
  border-bottom: 1px solid var(--rule);
  background: var(--panel);
}

.masthead-in {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 3.5rem;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: inherit;
  text-decoration: none;
  margin-right: auto;
  padding-block: 0.4rem;
}

.brand-mark {
  width: 30px;
  height: 30px;
  flex: none;
}

.brand-name {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 1.0625rem;
  letter-spacing: 0.02em;
  display: block;
  line-height: 1.1;
}

.brand-sub {
  display: block;
  font-size: 0.75rem;
  color: var(--ink-3);
  line-height: 1.3;
}

.masthead-tools {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.stamp {
  font-family: var(--mono);
  font-size: 0.6875rem;
  line-height: 1.25;
  text-align: right;
  color: var(--ink-2);
  border-left: 2px solid var(--rule-2);
  padding-left: 0.5rem;
}

.stamp b {
  display: block;
  font-weight: 700;
  color: var(--ink);
}

.icon-btn {
  min-width: var(--tap);
  min-height: var(--tap);
  display: inline-grid;
  place-items: center;
  background: transparent;
  border: 1px solid var(--rule-2);
  border-radius: var(--radius);
  color: var(--ink);
  cursor: pointer;
  padding: 0;
}

.icon-btn:hover {
  background: var(--panel-2);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

/* Exactly one of these two glyphs is ever visible. Every rule below carries the same
   `.icon-btn svg` specificity as the sizing rule above, or the sizing rule wins and both
   icons paint. */
.icon-btn svg.theme-light-only {
  display: block;
}

.icon-btn svg.theme-dark-only {
  display: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-btn svg.theme-dark-only {
    display: block;
  }
  :root:not([data-theme="light"]) .icon-btn svg.theme-light-only {
    display: none;
  }
}

:root[data-theme="dark"] .icon-btn svg.theme-dark-only {
  display: block;
}

:root[data-theme="dark"] .icon-btn svg.theme-light-only {
  display: none;
}

:root[data-theme="light"] .icon-btn svg.theme-dark-only {
  display: none;
}

:root[data-theme="light"] .icon-btn svg.theme-light-only {
  display: block;
}

/* -------------------------------------------------------------- typography */

.lede {
  font-size: clamp(1.0625rem, 1rem + 0.6vw, 1.3125rem);
  line-height: 1.4;
  max-width: 46ch;
  margin: 1.5rem 0 1.25rem;
  font-weight: 450;
  text-wrap: balance;
}

.lede b {
  font-weight: 700;
}

.sec {
  margin-block: 2.5rem;
  scroll-margin-top: 1rem;
}

.sec-h {
  font-family: var(--mono);
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
  margin: 0 0 0.5rem;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--ink);
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.sec-h .sec-n {
  color: var(--ink-3);
  font-weight: 400;
}

.sec-note {
  color: var(--ink-2);
  font-size: 0.9375rem;
  margin: 0.6rem 0 1rem;
  max-width: 68ch;
}

h3 {
  font-size: 1rem;
  margin: 1.25rem 0 0.5rem;
}

/* -------------------------------------------------------------- disclosure */

/* The single most repeated honesty line. It goes next to numbers, every time. */
.range-note {
  font-size: 0.8125rem;
  line-height: 1.4;
  color: var(--ink-2);
  border-left: 3px solid var(--rule-2);
  padding: 0.1rem 0 0.1rem 0.6rem;
  margin: 0.75rem 0 0;
  max-width: 62ch;
}

.range-note b {
  color: var(--ink);
}

.tag {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.15rem 0.4rem;
  border-radius: 2px;
  border: 1px solid currentColor;
  white-space: nowrap;
}

.tag-net {
  color: var(--net);
}
.tag-freight {
  color: var(--freight);
}
.tag-flag {
  color: var(--flag);
}
.tag-ok {
  color: var(--ink-2);
}
.tag-bad {
  color: var(--bad);
}

.note {
  border: 1px solid var(--rule);
  border-left: 4px solid var(--flag);
  background: var(--flag-tint);
  padding: 0.75rem 0.875rem;
  border-radius: var(--radius);
  font-size: 0.9375rem;
  margin: 1rem 0;
}

.note.is-bad {
  border-left-color: var(--bad);
  background: var(--freight-tint);
}

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

/* A note whose body is worth reading once, not on every visit. The summary line stays
   visible, so the limitation is never hidden - only its four paragraphs are. */
.note-fold > summary {
  cursor: pointer;
  list-style: none;
  font-weight: 600;
}
.note-fold > summary::-webkit-details-marker {
  display: none;
}
.note-fold > summary::before {
  content: "\25B8";
  display: inline-block;
  width: 1em;
  transition: transform 0.15s ease;
}
.note-fold[open] > summary::before {
  transform: rotate(90deg);
}
.note-fold > summary:focus-visible {
  outline: 2px solid var(--accent, currentColor);
  outline-offset: 2px;
}
.note-fold p {
  margin: 0.6rem 0 0;
}

.note-h {
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  display: block;
  margin-bottom: 0.3rem;
}

/* ---------------------------------------------------------------- controls */

.panel {
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 0.875rem;
}

.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 0.75rem;
  align-items: end;
}

.ctl {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

.ctl-wide {
  grid-column: span 2;
}

.ctl > label,
.field > label {
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-2);
}

input,
select,
button,
textarea {
  font: inherit;
  color: inherit;
}

input[type="text"],
input[type="search"],
input[type="number"],
select {
  min-height: var(--tap);
  width: 100%;
  padding: 0.4rem 0.55rem;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--rule-2);
  border-radius: var(--radius);
  font-size: 1rem;
}

select {
  cursor: pointer;
  /* keep native affordance; no custom arrow that could clash with the theme */
}

input:hover,
select:hover {
  border-color: var(--ink-3);
}

.btn {
  min-height: var(--tap);
  padding: 0.5rem 1rem;
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 0.9375rem;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover {
  background: var(--ink-2);
  border-color: var(--ink-2);
}

.btn:active {
  transform: translateY(1px);
}

.btn-quiet {
  background: transparent;
  color: var(--ink);
  border-color: var(--rule-2);
  font-weight: 500;
}

.btn-quiet:hover {
  background: var(--panel-2);
  color: var(--ink);
  border-color: var(--ink-3);
}

.btn-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 0.875rem;
}

/* region + confidence strip, sits directly under the controls */

.regionbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-top: 0.5rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--rule);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  background: var(--panel-2);
  font-size: 0.875rem;
}

.regionbar .num {
  font-weight: 700;
}

.conf {
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.15rem 0.4rem;
  border-radius: 2px;
}

.conf-sourced {
  background: var(--net-tint);
  color: var(--net);
}
.conf-high {
  background: var(--net-tint);
  color: var(--net);
}
.conf-medium {
  background: var(--flag-tint);
  color: var(--flag);
}
.conf-low {
  background: var(--freight-tint);
  color: var(--freight);
}

.regionbar select {
  min-height: var(--tap);
  width: auto;
  max-width: 100%;
  font-size: 0.875rem;
}

.regionbar-why {
  color: var(--ink-2);
  font-size: 0.8125rem;
  flex-basis: 100%;
}

/* ------------------------------------------------------------- the answer */

.answer {
  margin-top: 1.5rem;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: var(--paper);
  overflow: hidden;
}

.answer-top {
  padding: 1rem 1.125rem 1.125rem;
  border-bottom: 1px solid var(--rule);
}

.eyebrow {
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin: 0 0 0.35rem;
}

.big {
  font-size: clamp(3.25rem, 15vw, 5.25rem);
  font-weight: 700;
  line-height: 0.92;
  letter-spacing: -0.045em;
  color: var(--net);
  display: block;
  margin: 0;
}

.big-unit {
  font-size: 0.28em;
  letter-spacing: 0.06em;
  font-weight: 700;
  color: var(--ink-2);
  margin-left: 0.35em;
  letter-spacing: 0.02em;
}

.answer-where {
  font-size: clamp(1.125rem, 1rem + 1vw, 1.5rem);
  font-weight: 700;
  line-height: 1.25;
  margin: 0.5rem 0 0.15rem;
  text-wrap: balance;
}

.answer-sub {
  color: var(--ink-2);
  font-size: 0.9375rem;
  margin: 0;
}

/* the receipt: bid, freight, net as an arithmetic strip */
.receipt {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 0;
  margin: 1rem 0 0;
  border: 1px solid var(--rule-2);
  border-radius: var(--radius);
  overflow: hidden;
}

.receipt-cell {
  flex: 1 1 7rem;
  padding: 0.55rem 0.7rem;
  border-right: 1px solid var(--rule);
  min-width: 0;
}

.receipt-cell:last-child {
  border-right: none;
}

.receipt-op {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  padding-inline: 0.35rem;
  font-family: var(--mono);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--ink-3);
  border-right: 1px solid var(--rule);
  background: var(--panel);
}

.receipt-k {
  font-family: var(--mono);
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-2);
  display: block;
}

.receipt-v {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 1.0625rem;
  font-weight: 700;
  display: block;
  line-height: 1.3;
}

.receipt-x {
  font-size: 0.75rem;
  color: var(--ink-3);
  display: block;
  font-family: var(--mono);
}

.receipt-cell.is-freight {
  background: var(--freight-tint);
}
.receipt-cell.is-freight .receipt-v,
.receipt-cell.is-freight .receipt-k {
  color: var(--freight);
}

.receipt-cell.is-net {
  background: var(--net-tint);
}
.receipt-cell.is-net .receipt-v,
.receipt-cell.is-net .receipt-k {
  color: var(--net);
}

.answer-margin {
  padding: 0.875rem 1.125rem;
  background: var(--panel);
  font-size: 0.9375rem;
  border-bottom: 1px solid var(--rule);
}

.answer-margin:last-child {
  border-bottom: none;
}

.answer-margin strong {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.answer-caveats {
  padding: 0.75rem 1.125rem;
  font-size: 0.875rem;
  color: var(--ink-2);
  background: var(--paper);
}

.answer-caveats ul {
  margin: 0.25rem 0 0;
  padding-left: 1.1rem;
}

.answer.is-in {
  animation: rise 0.22s ease-out both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}

/* --------------------------------------------- the bite bar (the signature) */

/*
  One shared price axis for every row. Solid green runs to NET. Hatched rust runs
  on from NET to the headline BID: the money the truck takes. Two custom properties
  drive the geometry, both already clamped percentages set from JS.

  The -pct suffix is load bearing: --net and --bid are colour tokens, and a geometry
  property sharing either name inherits down into the children and silently poisons
  every `background: var(--net)` beneath it.
*/
.bite {
  position: relative;
  height: 1.5rem;
  background: var(--panel-2);
  border-radius: 2px;
  overflow: hidden;
  min-width: 8rem;
}

.bite-fill {
  position: absolute;
  inset-block: 0;
  left: 0;
  width: var(--net-pct, 0%);
  background: var(--net);
  opacity: 0.9;
}

.bite-cut {
  position: absolute;
  inset-block: 0;
  left: var(--net-pct, 0%);
  width: calc(var(--bid-pct, 0%) - var(--net-pct, 0%));
  background: repeating-linear-gradient(
    135deg,
    var(--freight) 0 2px,
    transparent 2px 5px
  );
  border-right: 2px solid var(--freight);
}

.bite-tick {
  position: absolute;
  inset-block: 0;
  left: var(--net-pct, 0%);
  width: 2px;
  background: var(--paper);
}

.bite-legend {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: center;
  font-size: 0.75rem;
  color: var(--ink-2);
  margin: 0.5rem 0 0.75rem;
}

.key {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.key::before {
  content: "";
  width: 1.25rem;
  height: 0.7rem;
  border-radius: 2px;
  flex: none;
}

.key-net::before {
  background: var(--net);
  opacity: 0.85;
}

.key-freight::before {
  background: repeating-linear-gradient(135deg, var(--freight) 0 2px, transparent 2px 5px);
  border: 1px solid var(--freight);
}

.axis {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 0.6875rem;
  color: var(--ink-3);
  border-top: 1px solid var(--rule);
  padding-top: 0.2rem;
  margin-top: 0.2rem;
}

/* Example diagram in the empty state. Capped in width so the "nets $X" label stays
   next to the bar it belongs to instead of drifting to the far side of a wide screen. */
.demo {
  margin: 0;
  display: grid;
  gap: 0.5rem;
  max-width: 42rem;
}

.demo-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.2rem;
}

.demo-lbl {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.8125rem;
  font-family: var(--mono);
}

.demo-lbl b {
  font-weight: 700;
}

/* ------------------------------------------------------------------ tables */

.tablewrap {
  overflow-x: auto;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

caption {
  text-align: left;
  font-size: 0.8125rem;
  color: var(--ink-2);
  padding: 0.5rem 0.6rem;
}

th,
td {
  padding: 0.5rem 0.6rem;
  text-align: right;
  border-bottom: 1px solid var(--rule);
  vertical-align: middle;
  white-space: nowrap;
}

th:first-child,
td:first-child,
th.left,
td.left {
  text-align: left;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel);
  border-bottom: 2px solid var(--ink);
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
  padding: 0;
}

thead th .sortbtn {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.4rem 0.6rem;
  background: none;
  border: 0;
  font: inherit;
  color: inherit;
  text-align: inherit;
  cursor: pointer;
  display: block;
}

thead th .plain {
  display: block;
  padding: 0.55rem 0.6rem;
}

thead th .sortbtn:hover {
  background: var(--panel-2);
  color: var(--ink);
}

thead th[aria-sort] .sortbtn {
  color: var(--ink);
}

thead th[aria-sort="descending"] .sortbtn::after {
  content: " \2193";
}

thead th[aria-sort="ascending"] .sortbtn::after {
  content: " \2191";
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr.is-best td {
  background: var(--net-tint);
}

tbody tr.is-dim td {
  color: var(--ink-3);
}

.rank-n {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.8125rem;
  display: inline-grid;
  place-items: center;
  min-width: 1.6rem;
  height: 1.6rem;
  border: 1px solid var(--rule-2);
  border-radius: 2px;
  background: var(--paper);
}

tr.is-best .rank-n {
  background: var(--net);
  color: var(--paper);
  border-color: var(--net);
}

.cell-region {
  font-weight: 700;
}

.cell-sub {
  display: block;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--ink-2);
  white-space: normal;
}

.cell-net {
  font-weight: 700;
  font-size: 1.0625rem;
  color: var(--net);
}

.cell-freight {
  color: var(--freight);
}

.cell-null {
  color: var(--ink-3);
}

.cell-delta {
  font-size: 0.8125rem;
  color: var(--ink-2);
}

.cell-delta.is-loss {
  color: var(--bad);
}

.col-bite {
  width: 30%;
  min-width: 11rem;
}

.tbl-tools {
  display: flex;
  gap: 0.75rem;
  align-items: end;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.mobile-sort {
  display: none;
  flex: 1 1 12rem;
}

/* NET is the ranking key, so it gets a rule of its own. */
th.net-col,
td.net-col {
  border-left: 2px solid var(--ink);
  background: var(--panel);
}

tbody tr.is-best td.net-col {
  background: var(--net-tint);
}

/* --------------------------------------------------- mobile: rows -> cards */

@media (max-width: 51.25rem) {
  .mobile-sort {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
  }

  /* Only the ranking table turns into cards. Every other .tablewrap keeps its own
     horizontal scroll, or it pushes the whole page sideways. */
  .tablewrap-cards {
    border: none;
    background: none;
    overflow: visible;
  }

  .rank-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  .rank-table,
  .rank-table tbody,
  .rank-table tr,
  .rank-table td {
    display: block;
    width: auto;
  }

  .rank-table tr {
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    background: var(--paper);
    margin-bottom: 0.6rem;
    padding: 0.5rem 0.65rem 0.65rem;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.15rem 0.6rem;
  }

  .rank-table tr.is-best {
    border: 2px solid var(--net);
  }

  .rank-table tr.is-best td {
    background: none;
  }

  .rank-table td {
    border-bottom: none;
    padding: 0.15rem 0;
    text-align: right;
    grid-column: 2;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.75rem;
    white-space: normal;
  }

  .rank-table td::before {
    content: attr(data-label);
    font-family: var(--mono);
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-2);
    text-align: left;
    flex: none;
  }

  .rank-table td.col-rank {
    grid-column: 1;
    grid-row: 1 / span 2;
    padding-top: 0.15rem;
    display: block;
  }

  .rank-table td.col-rank::before {
    content: none;
  }

  .rank-table td.col-region {
    text-align: left;
    display: block;
  }

  .rank-table td.col-region::before {
    content: none;
  }

  .rank-table td.col-bite {
    grid-column: 1 / -1;
    display: block;
    margin-top: 0.4rem;
    width: auto;
  }

  .rank-table td.col-bite::before {
    content: none;
  }

  .rank-table td.net-col {
    border-left: none;
    border-top: 1px solid var(--rule);
    background: none;
    margin-top: 0.3rem;
    padding-top: 0.4rem;
  }

  .receipt-cell {
    flex-basis: 5.5rem;
  }
}

/* Narrow enough that the three terms cannot sit side by side: stack them into a till
   receipt instead of letting the operators wrap off on their own. */
@media (max-width: 30rem) {
  .receipt {
    flex-direction: column;
  }

  .receipt-cell {
    flex: 1 1 auto;
    border-right: none;
    border-bottom: 1px solid var(--rule);
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.75rem;
    flex-wrap: wrap;
  }

  .receipt-cell:last-child {
    border-bottom: none;
  }

  .receipt-k {
    order: 1;
  }
  .receipt-v {
    order: 2;
    font-size: 1.25rem;
  }
  .receipt-x {
    order: 3;
    flex-basis: 100%;
  }

  .receipt-op {
    border-right: none;
    border-bottom: 1px solid var(--rule);
    padding-block: 0.1rem;
    font-size: 1rem;
    line-height: 1;
  }
}

/* -------------------------------------------------------- freight controls */

.fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
  gap: 0.75rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.field-why {
  font-size: 0.75rem;
  color: var(--ink-2);
}

.field-why summary {
  cursor: pointer;
  color: var(--link);
  min-height: 1.75rem;
  display: flex;
  align-items: center;
}

.field-why p {
  margin: 0.25rem 0 0;
  line-height: 1.45;
}

.derived {
  margin-top: 1rem;
  padding: 0.75rem 0.875rem;
  border: 1px solid var(--rule-2);
  border-left: 4px solid var(--freight);
  border-radius: var(--radius);
  background: var(--freight-tint);
  font-size: 0.9375rem;
}

.derived .num {
  font-weight: 700;
  color: var(--freight);
}

/* ------------------------------------------------------------------ buyers */

.buyers {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
  gap: 0.6rem;
  list-style: none;
  padding: 0;
  margin: 0.75rem 0 0;
}

.buyer {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 0.7rem 0.8rem;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.buyer-name {
  font-weight: 700;
  line-height: 1.25;
}

.buyer-meta {
  font-size: 0.8125rem;
  color: var(--ink-2);
}

.buyer-badges {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
}

.call {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: var(--tap);
  padding: 0.4rem 0.8rem;
  margin-top: auto;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  color: var(--ink);
  font-family: var(--mono);
  font-weight: 700;
  font-size: 1rem;
  text-decoration: none;
  letter-spacing: 0.01em;
}

.call:hover {
  background: var(--ink);
  color: var(--paper);
}

.call svg {
  width: 15px;
  height: 15px;
  flex: none;
}

/* ------------------------------------------------------------------- store */

.store-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}

.stat {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 0.6rem 0.75rem;
  background: var(--panel);
}

.stat-k {
  font-family: var(--mono);
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-2);
  display: block;
}

.stat-v {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 1.25rem;
  font-weight: 700;
  display: block;
  line-height: 1.3;
}

.verdict {
  font-size: clamp(1.25rem, 1.05rem + 1vw, 1.625rem);
  font-weight: 700;
  line-height: 1.25;
  margin: 0.5rem 0 0;
  text-wrap: balance;
}

.sens-table tbody tr.is-flip td {
  background: var(--flag-tint);
}

.sens-table tbody tr.is-current td {
  outline: 2px solid var(--ink);
  outline-offset: -2px;
}

.sens-table td.pos {
  color: var(--net);
  font-weight: 700;
}

.sens-table td.neg {
  color: var(--bad);
  font-weight: 700;
}

.signflip td {
  background: var(--panel-2);
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--bad);
  text-align: center !important;
  border-top: 2px dashed var(--bad);
  border-bottom: 2px dashed var(--bad);
}

/* ----------------------------------------------------------------- futures */

.curve {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 0.75rem;
  overflow-x: auto;
}

.curve svg {
  display: block;
  width: 100%;
  height: auto;
  min-width: 20rem;
}

.curve-line {
  fill: none;
  stroke: var(--ink);
  stroke-width: 2;
  stroke-linejoin: round;
}

.curve-dot {
  fill: var(--paper);
  stroke: var(--ink);
  stroke-width: 2;
}

.curve-grid {
  stroke: var(--rule);
  stroke-width: 1;
}

.curve-lbl {
  font-family: var(--mono);
  font-size: 10px;
  fill: var(--ink-2);
}

.curve-val {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  fill: var(--ink);
}

/* ------------------------------------------------------------ empty/status */

.empty {
  margin-top: 1.5rem;
  border: 2px dashed var(--rule-2);
  border-radius: var(--radius);
  padding: 1.125rem;
  background: var(--panel);
}

.empty h2 {
  font-size: 1.125rem;
  margin: 0 0 0.5rem;
}

.empty p {
  margin: 0 0 0.75rem;
  max-width: 60ch;
  font-size: 0.9375rem;
}

.example-flag {
  font-family: var(--mono);
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--freight);
  border: 1px solid var(--freight);
  border-radius: 2px;
  padding: 0.1rem 0.35rem;
  display: inline-block;
  margin-bottom: 0.5rem;
}

.alerts:empty {
  display: none;
}

.alerts {
  margin-top: 1rem;
  display: grid;
  gap: 0.5rem;
}

.spinner {
  display: inline-block;
  width: 0.9rem;
  height: 0.9rem;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -1px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.is-busy {
  opacity: 0.55;
}

/* ------------------------------------------------------------------ footer */

.foot {
  margin-top: 3rem;
  border-top: 2px solid var(--ink);
  background: var(--panel);
  padding-block: 1.5rem 2.5rem;
  font-size: 0.875rem;
  color: var(--ink-2);
}

.foot h2 {
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
  margin: 0 0 0.5rem;
}

.foot-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1.5rem;
}

.foot ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.foot li {
  margin-bottom: 0.4rem;
  line-height: 1.4;
}

.foot .num {
  color: var(--ink);
}

.disclaimer {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule-2);
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--ink);
  letter-spacing: 0.01em;
}

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

.prose {
  max-width: 68ch;
}

.prose h2 {
  font-family: var(--mono);
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin: 2.25rem 0 0.6rem;
  padding-bottom: 0.35rem;
  border-bottom: 2px solid var(--ink);
}

.prose h3 {
  font-size: 1.0625rem;
  margin: 1.5rem 0 0.35rem;
}

.prose p,
.prose li {
  line-height: 1.6;
}

.prose ul,
.prose ol {
  padding-left: 1.2rem;
}

.prose li {
  margin-bottom: 0.45rem;
}

.prose dt {
  font-weight: 700;
  margin-top: 0.75rem;
}

.prose dd {
  margin: 0.15rem 0 0;
  color: var(--ink-2);
}

.backlink {
  display: inline-block;
  margin: 1.5rem 0 0;
  font-family: var(--mono);
  font-size: 0.875rem;
}

/* ------------------------------------------------------------------ motion */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ------------------------------------------------------------------- print */

@media print {
  .masthead-tools,
  .controls,
  .tbl-tools,
  .btn-row {
    display: none;
  }
  body {
    background: #fff;
    color: #000;
  }
}
