@font-face {
  font-family: "Archivo";
  src: url("/static/fonts/archivo-latin-var.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
}

:root {
  --ground: #f6f7f5;
  --cell: #ffffff;
  --head: #eceeeb;
  --ink: #111412;
  --muted: #4a524c;
  --grid: #d5dad5;
  --select: #c8f23a;
  --deep: #0d5c3d;
  --gutter: 3rem;
  --tabs-h: 2.75rem;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  color-scheme: light;
}

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

html { scrollbar-color: var(--grid) var(--ground); }

body {
  margin: 0;
  font-family: "Archivo", system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  background: var(--ground);
  color: var(--ink);
  padding-bottom: var(--tabs-h);
  caret-color: var(--deep);
}

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

a {
  color: var(--deep);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}
a:hover { text-decoration-thickness: 2px; }

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px var(--select);
}

h1, h2, h3 { margin: 0; line-height: 1.1; text-wrap: balance; }
h1 { font-size: clamp(2rem, 4.5vw, 3.5rem); font-weight: 800; letter-spacing: -0.03em; }
h2 { font-size: 1.375rem; font-weight: 750; letter-spacing: -0.01em; }
h3 { font-size: 1.0625rem; font-weight: 700; }
p { margin: 0 0 0.75rem; }
p:last-child { margin-bottom: 0; }

.skip-link {
  position: absolute;
  left: 0.5rem;
  top: -3rem;
  z-index: 20;
  background: var(--ink);
  color: var(--cell);
  padding: 0.5rem 0.75rem;
}
.skip-link:focus { top: 0.5rem; }

/* Title bar and formula bar */
.titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 1rem 0.5rem calc(var(--gutter) + 0.75rem);
  background: var(--ink);
  color: var(--cell);
}
.brand {
  color: var(--cell);
  font-weight: 800;
  font-stretch: 112%;
  letter-spacing: -0.01em;
  text-decoration: none;
}
.tools { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.tool {
  color: var(--cell);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.35rem 0.7rem;
  border: 1px solid #3a413c;
}
.tool:hover { background: var(--select); color: var(--ink); border-color: var(--select); }

.formula-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: var(--gutter) 3rem 2.5rem 1fr;
  align-items: stretch;
  min-height: 2.25rem;
  background: var(--cell);
  border-bottom: 1px solid var(--grid);
  font-size: 0.875rem;
}
.formula-bar > * {
  display: flex;
  align-items: center;
  padding: 0.4rem 0.6rem;
  border-right: 1px solid var(--grid);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.formula-bar > :first-child { background: var(--head); }
.namebox { font-weight: 700; justify-content: center; }
.fx { font-style: italic; color: var(--muted); justify-content: center; }
.formula { border-right: 0; color: var(--ink); min-width: 0; }
.formula-text { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* The sheet: rows on a 12-column grid with a row-number gutter */
.sheet {
  position: relative;
  overflow-x: clip;
  counter-reset: row;
  background: var(--cell);
  border-bottom: 1px solid var(--grid);
}
.colhead, .r {
  display: grid;
  grid-template-columns: var(--gutter) repeat(12, minmax(0, 1fr));
  border-bottom: 1px solid var(--grid);
  background-color: var(--cell);
  background-image: linear-gradient(to left, var(--grid) 1px, transparent 1px);
  background-size: calc((100% - var(--gutter)) / 12) 100%;
  background-position: var(--gutter) 0;
  background-repeat: repeat-x;
}
.colhead {
  background-color: var(--head);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
}
.colhead span { padding: 0.25rem 0; }
.colhead span:first-child { border-right: 1px solid var(--grid); }
.r::before {
  counter-increment: row;
  content: counter(row);
  grid-column: 1;
  padding-top: 0.6rem;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--head);
  border-right: 1px solid var(--grid);
}
.c {
  position: relative;
  min-width: 0;
  padding: 0.85rem 1rem;
  background: var(--cell);
  border-right: 1px solid var(--grid);
}
.s2 { grid-column: span 2; }
.s3 { grid-column: span 3; }
.s4 { grid-column: span 4; }
.s6 { grid-column: span 6; }
.s8 { grid-column: span 8; }
.s9 { grid-column: span 9; }
.s12 { grid-column: span 12; }
.c.blank { background: transparent; border-right: 0; }

/* Comment marker: a sourced cell carries the green corner triangle */
.sourced::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  border-style: solid;
  border-width: 0 9px 9px 0;
  border-color: transparent var(--deep) transparent transparent;
}

/* The moving selection outline (the one authored motion) */
.selection {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 5;
  pointer-events: none;
  border: 2px solid var(--ink);
  visibility: hidden;
  transition: transform 220ms var(--ease);
}
.selection.instant { transition: none; }
.selection::after {
  content: "";
  position: absolute;
  right: -5px;
  bottom: -5px;
  width: 8px;
  height: 8px;
  background: var(--ink);
  border: 1px solid var(--cell);
}

/* Home */
.name-cell { padding-top: clamp(1.5rem, 4vw, 3.5rem); padding-bottom: 1.25rem; }
.name-cell h1 {
  font-size: clamp(2.75rem, 7.6vw, 6rem);
  font-weight: 850;
  font-stretch: 112%;
  letter-spacing: -0.04em;
  line-height: 0.92;
}
.role { margin-top: 1rem; font-size: clamp(1.0625rem, 1.6vw, 1.375rem); font-weight: 600; color: var(--muted); }
.r.selected .c { background: var(--select); }
.r.selected::before { background: #b3d92f; color: var(--ink); }
.seeking { font-size: clamp(1.0625rem, 1.8vw, 1.5rem); font-weight: 750; letter-spacing: -0.01em; margin: 0; }
.fact strong { display: block; font-size: 1.25rem; font-weight: 800; letter-spacing: -0.01em; line-height: 1.2; }
.fact span { display: block; margin-top: 0.35rem; font-size: 0.875rem; color: var(--muted); }
.actions { display: grid; gap: 0.5rem; align-content: center; }
.lede { font-size: 1.125rem; line-height: 1.6; max-width: 62ch; }
.meta-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.35rem; }
.head-cell { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; background: var(--head); }

/* Buttons: square ink blocks */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: 0.6rem 1rem;
  font-weight: 700;
  text-decoration: none;
  border: 1px solid var(--ink);
  background: var(--cell);
  color: var(--ink);
  transition: background-color 120ms var(--ease), color 120ms var(--ease);
}
.btn:hover { background: var(--select); }
.btn.primary { background: var(--ink); color: var(--cell); }
.btn.primary:hover { background: var(--deep); border-color: var(--deep); }
.btn-row { display: flex; flex-wrap: wrap; align-items: flex-start; align-content: flex-start; gap: 0.5rem; }

/* Data tables */
.table-cell { padding: 0; overflow-x: auto; }
table.xl { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
.xl th, .xl td { padding: 0.6rem 1rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--grid); border-right: 1px solid var(--grid); }
.xl th:last-child, .xl td:last-child { border-right: 0; }
.xl thead th { background: var(--head); font-size: 0.8125rem; font-weight: 700; }
.xl .num { text-align: right; white-space: nowrap; }
.xl tbody tr:last-child td { border-bottom: 0; }
.xl tfoot td { font-weight: 800; border-top: 2px solid var(--ink); border-bottom: 0; }

.bullets { margin: 0; padding-left: 1.1rem; display: grid; gap: 0.35rem; max-width: 60ch; }
.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; }
.fact[tabindex] { cursor: default; }
.fact[tabindex]:focus-visible { outline-offset: -4px; box-shadow: none; }
.who strong { display: block; }
.who span { display: block; color: var(--muted); font-size: 0.875rem; }
.prose p { font-size: 1.0625rem; line-height: 1.7; max-width: 66ch; }
.tags { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.75rem 0 0; padding: 0; list-style: none; }
.tags li { font-size: 0.8125rem; font-weight: 600; padding: 0.15rem 0.5rem; border: 1px solid var(--grid); background: var(--ground); }
.err { color: #b3261e; font-stretch: 112%; }
.empty { color: var(--muted); }

/* Status bar and sheet tabs */
.statusbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  padding: 0.6rem 1rem 0.6rem calc(var(--gutter) + 0.75rem);
  font-size: 0.875rem;
  color: var(--muted);
}
.statusbar p { margin: 0; }
.footer-links { display: flex; gap: 1rem; }

.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: flex;
  height: var(--tabs-h);
  padding-left: var(--gutter);
  background: var(--head);
  border-top: 1px solid var(--grid);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs a {
  display: flex;
  align-items: center;
  padding: 0 1.1rem;
  white-space: nowrap;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  border-right: 1px solid var(--grid);
}
.tabs a:hover { color: var(--ink); background: var(--cell); }
.tabs a[aria-current="page"] {
  background: var(--cell);
  color: var(--deep);
  font-weight: 800;
  box-shadow: inset 0 -3px 0 var(--deep);
}

/* Analytics consent banner: sits on the sheet tabs until a choice is made */
.consent {
  position: fixed;
  left: 0;
  right: 0;
  bottom: var(--tabs-h);
  z-index: 11;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  padding: 0.75rem 1rem 0.75rem calc(var(--gutter) + 0.75rem);
  background: var(--cell);
  border-top: 2px solid var(--ink);
}
.consent[hidden] { display: none; }
.consent p { margin: 0; max-width: 66ch; }
button.btn { font: inherit; font-weight: 700; cursor: pointer; }

@media (max-width: 760px) {
  :root { --gutter: 2.25rem; }
  .colhead, .r { grid-template-columns: var(--gutter) minmax(0, 1fr); }
  .r {
    background-image: linear-gradient(to right, var(--head) calc(var(--gutter) - 1px), var(--grid) calc(var(--gutter) - 1px) var(--gutter), transparent var(--gutter));
    background-size: 100% 100%;
    background-position: 0 0;
  }
  .r::before { background: transparent; border-right: 0; }
  .colhead { background-image: none; }
  .colhead span:nth-child(n + 3) { display: none; }
  .r > .c { grid-column: 2 / -1; border-right: 0; }
  .r > .c + .c { border-top: 1px solid var(--grid); }
  .r > .c.blank { display: none; }
  .titlebar { flex-direction: column; align-items: flex-start; padding-left: calc(var(--gutter) + 0.5rem); }
  .tool { padding: 0.55rem 0.8rem; }
  .formula-bar { grid-template-columns: var(--gutter) 2.75rem 1fr; }
  .formula-bar .fx { display: none; }
  .xl.stack thead { display: none; }
  .xl.stack, .xl.stack tbody, .xl.stack tfoot, .xl.stack tr, .xl.stack td { display: block; width: 100%; }
  .xl.stack tr { border-bottom: 1px solid var(--grid); padding: 0.4rem 0; }
  .xl.stack td { border: 0; padding: 0.2rem 1rem; text-align: left; }
  .xl.stack td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-weight: 600; }
  .xl.stack tfoot tr { border-top: 2px solid var(--ink); border-bottom: 0; }
  .xl.stack tfoot td { border-top: 0; }
  .tabs { padding-left: 0; }
  .consent { padding-left: 1rem; }
  .tabs a { flex: 1 0 auto; justify-content: center; padding: 0 0.5rem; font-size: 0.75rem; }
}

@media (prefers-reduced-motion: reduce) {
  .selection, .btn { transition: none; }
}
