:root {
  color-scheme: light;
  --tap: 40px;
  --gutter: 20px;
  --gutter-l: max(var(--gutter), env(safe-area-inset-left));
  --gutter-r: max(var(--gutter), env(safe-area-inset-right));
  --ink: #000;
  --paper: #fff;
  --muted: #3a3a3a;
  --soft: #d8d8d8;
  --dither: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='4' height='4' shape-rendering='crispEdges'><rect width='1' height='1' fill='%23000'/><rect x='2' y='2' width='1' height='1' fill='%23000'/></svg>");
  --checker: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='4' height='4' shape-rendering='crispEdges'><rect width='2' height='2' fill='%23000'/><rect x='2' y='2' width='2' height='2' fill='%23000'/></svg>");
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
}

body {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  font-family: ui-monospace, "SFMono-Regular", "Cascadia Mono", "Segoe UI Mono", Menlo, Consolas, monospace;
  font-size: 14px;
  line-height: 1.45;
  min-height: 100vh;
  padding-bottom: var(--foot-h, 88px);
}

a {
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--ink);
  border-radius: 0;
}

button {
  cursor: pointer;
  padding: 8px 12px;
}

button:hover,
button.on {
  background: var(--ink);
  color: var(--paper);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='8' height='6' shape-rendering='crispEdges'><polygon points='0,0 8,0 4,6' fill='%23000'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 24px;
}

input[type="checkbox"] {
  accent-color: #000;
  width: 14px;
  height: 14px;
}

::selection {
  color: #fff;
  background: #000;
}

.band {
  height: 10px;
  background-color: var(--paper);
  background-image: var(--checker);
  background-size: 4px 4px;
  image-rendering: pixelated;
}

header {
  background: var(--ink);
  color: var(--paper);
  padding: 28px 0;
}

header a,
footer a {
  color: var(--paper);
}

header a:focus-visible,
footer a:focus-visible {
  outline: 2px solid var(--paper);
  outline-offset: 3px;
}

.hero-bar {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 var(--gutter-r) 0 var(--gutter-l);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.hero-copy {
  min-width: 0;
}

.brand {
  flex: 0 0 auto;
  line-height: 0;
}

.brand img {
  display: block;
  height: 56px;
  width: auto;
}

.kicker {
  margin: 0 0 8px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 12px;
}

header h1 {
  margin: 0;
  font-size: clamp(28px, 16px + 3vw, 42px);
  text-wrap: balance;
  line-height: 0.95;
  font-weight: 700;
  letter-spacing: -0.04em;
  max-width: 16ch;
}

.sub {
  margin: 14px 0 0;
  max-width: 46ch;
}

p {
  overflow-wrap: anywhere;
}

.wrap {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 var(--gutter-r) 48px var(--gutter-l);
}

.tabbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin: 18px 0;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

/* Columns sit on the paper. No box around a column of controls or results. */
.panel {
  min-width: 0;
}

/* Results switch between a table and cards by the width they get. */
.out {
  container: fdout / inline-size;
  overflow-x: auto;
  overscroll-behavior-x: contain;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

label {
  display: block;
  margin: 0 0 10px;
}

label span {
  display: block;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

input,
select {
  width: 100%;
  padding: 7px 8px;
  font-size: 16px;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 10px;
}

.venues {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin: 0 0 12px;
}

.venues label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}

.venues label span {
  margin: 0;
  letter-spacing: 0;
  text-transform: none;
  font-size: 13px;
}

.venues input {
  width: auto;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

/* Explanatory notes are serif body copy, not mono prose. */
.hint {
  max-width: 36rem;
  margin: 24px 0 0;
  color: var(--muted);
  font-family: "Newsreader", Georgia, "Times New Roman", serif;
  font-size: 16px;
  line-height: 1.5;
  text-wrap: pretty;
}

.out .hero {
  font-size: 34px;
  line-height: 1;
  letter-spacing: -0.04em;
  margin: 0 0 4px;
}

.out .hero-label {
  margin: 0 0 12px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
}

th,
td {
  text-align: left;
  border-top: 1px solid var(--ink);
  padding: 6px 6px 6px 0;
  font-weight: 400;
  vertical-align: top;
}

th {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-top: none;
}

td.num,
th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ---------- Results ---------- */

.out .hero,
.fd-summary,
.fd-cards,
.fd-table {
  font-variant-numeric: tabular-nums;
}

.fd-summary {
  margin: 0 0 4px;
}

.fd-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.fd-tag {
  display: inline-block;
  padding: 2px 5px 1px;
  background: var(--ink);
  color: var(--paper);
  font-size: 10px;
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  vertical-align: 1px;
}

/* Cost bar: ink for a cost, hatched outline for funding you receive.
   The left edge is the zero line. */
.fd-bar {
  position: relative;
  display: block;
  height: 8px;
  border-left: 1px solid var(--ink);
  background: var(--soft);
}

.fd-bar i {
  display: block;
  height: 100%;
  background: var(--ink);
}

.fd-bar.neg i {
  border: 1px solid var(--ink);
  background: repeating-linear-gradient(-45deg, var(--ink) 0 1px, var(--paper) 1px 4px);
}

/* Cards: the phone view. */
.fd-cards {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
}

.fd-card + .fd-card {
  margin-top: 24px;
}

.fd-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
}

.fd-rank {
  min-width: 1.4em;
  color: var(--muted);
  font-size: 12px;
}

.fd-venue {
  font-weight: 700;
  white-space: nowrap;
}

.fd-cost {
  margin-left: auto;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.fd-card .fd-bar {
  margin: 9px 0 10px;
}

.fd-kv {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  margin: 0;
}

.fd-kv dt {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.fd-kv dd {
  margin: 1px 0 0;
  font-size: 13px;
  white-space: nowrap;
}

.fd-kv small {
  color: var(--muted);
  font-size: 11px;
}

/* Table: the wide view. Nothing inside a cell wraps. */
.fd-table {
  display: none;
}

.fd-table td,
.fd-table th {
  white-space: nowrap;
  vertical-align: baseline;
}

.fd-table td.fd-venue .fd-tag {
  margin-left: 6px;
}

.fd-fund {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.fd-fund .fd-bar {
  flex: 0 0 48px;
  height: 6px;
}

.fd-takeaway {
  margin: 14px 0 0;
  font-weight: 700;
  line-height: 1.5;
}

@media (min-width: 560px) {
  .fd-cards {
    display: none;
  }

  .fd-table {
    display: table;
  }
}

/* A narrow results panel (two columns on a small laptop) gets cards too. */
@container fdout (max-width: 419.98px) {
  .fd-cards {
    display: block;
  }

  .fd-table {
    display: none;
  }
}

footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  background: var(--ink);
  color: var(--paper);
  font-size: 12px;
}

.foot-bar {
  max-width: 1040px;
  margin: 0 auto;
  padding: 10px var(--gutter-r) calc(12px + env(safe-area-inset-bottom)) var(--gutter-l);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.foot-bar p {
  margin: 0;
}

.foot-bar a {
  text-decoration-line: underline;
  text-decoration-style: wavy;
  text-underline-offset: 3px;
}

[hidden] {
  display: none !important;
}

@media (max-width: 800px) {
  :root {
    --gutter: 14px;
  }

  header {
    padding: 18px 0;
  }

  header h1 {
    max-width: 100%;
  }

  .brand img {
    height: 40px;
  }

  .layout,
  .grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .out .hero {
    font-size: 28px;
  }

  .foot-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  /* A pinned two-paragraph footer eats a phone screen. Keep it in flow. */
  body {
    padding-bottom: 0;
  }

  footer {
    position: static;
  }
}

@media (max-width: 560px) {
  .hero-bar {
    flex-direction: column-reverse;
    align-items: flex-start;
    gap: 14px;
  }
}

/* Touch screens: 40px targets, and 16px fields so iOS does not zoom. */
@media (pointer: coarse), (max-width: 800px) {
  input:not([type="checkbox"]),
  select {
    font-size: 16px;
    min-height: var(--tap);
  }

  button {
    min-height: var(--tap);
  }

  .venues label {
    min-height: var(--tap);
  }

  input[type="checkbox"] {
    width: 18px;
    height: 18px;
  }
}
