/* Labor Data — blocking sans, SEIU-adjacent type hierarchy.
   Compressed bold caps for display, sans for body, single red accent. */

@import url('https://fonts.googleapis.com/css2?family=Geist:wght@300;400;500;600;700;800;900&display=swap');

:root {
  --paper: #fafaf7;
  --paper-edge: #ededed;
  --ink: #15110d;
  --ink-soft: #3a3a36;
  --ink-mute: #8a8a8a;
  --rule: #d4d4d0;
  --rule-soft: #e6e6e3;
  --red: #c0023e;
  --red-deep: #8e0029;

  --display: "Geist", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --sans-body: "Geist", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --sans-label: "Geist", -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Page surface ----------------------------------------------------------- */

html, body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans-body);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.not-footer {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* Masthead --------------------------------------------------------------- */

header.hd {
  /* Mirror the footer's trim: at the top of the viewport, an ink hairline;
     under the masthead, an ink + paper-gap + red ornament identical to the
     footer's top trim (just inverted). */
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  box-shadow: 0 3px 0 var(--paper), 0 4px 0 var(--red);
  padding: 0.9rem 1.5rem 0.85rem;
  margin-top: 0;
  margin-bottom: 2rem;
  background: var(--paper);
  background-image: none;
  color: var(--ink);
  font-family: var(--sans-label);
  letter-spacing: 0.01em;
  min-height: 0;

  /* Break out of .not-footer's 1100px max-width so the masthead spans the
     full viewport like the footer does, while keeping its content column
     aligned with the rest of the page. */
  margin-inline: calc(50% - 50vw);
  padding-inline: max(1.5rem, calc(50vw - 50% + 1.5rem));
}

header.hd a,
header.hd a:link,
header.hd a:visited {
  color: var(--ink);
  text-decoration: none;
}

header.hd a:hover,
header.hd a:focus,
header.hd a:active {
  color: var(--red);
}

/* Breadcrumbs — uppercase tracked label */
.crumbs {
  font-family: var(--sans-label);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.72rem;
  color: var(--ink-mute);
}

.crumbs a {
  color: var(--ink-soft);
}

/* Headings --------------------------------------------------------------- */

h1, h2, .page-header h1 {
  font-family: var(--display);
  color: var(--ink);
  line-height: 1.05;
  font-weight: 800;
  letter-spacing: -0.02em;
}

/* Drop the per-db colored swatch beside table/db titles — the breadcrumbs
   and heading already identify which database we're in, and the swatch is
   just a hash-derived color with no semantic meaning. */
.page-header {
  border-left: none;
  padding-left: 0;
}

h1 {
  font-size: 3rem;
  margin: 0.3rem 0 0.7rem;
}

h1::after {
  content: "";
  display: block;
  width: 3rem;
  height: 4px;
  margin-top: 0.7rem;
  background: var(--red);
}

h2 {
  font-size: 1.6rem;
  margin: 1.8rem 0 0.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: inline-block; /* shrink-wrap so the rule below matches the text */
}

h2::after {
  content: "";
  display: block;
  width: 1.75rem;
  height: 2px;
  margin-top: 0.4rem;
  background: var(--red);
  transition: width 0.18s ease;
}

/* h3 — section-label treatment, EPI-style red sans bold */
h3 {
  font-family: var(--sans-label);
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--red);
  margin: 1.4rem 0 0.5rem;
}

/* Links ------------------------------------------------------------------ */

a,
a:link {
  color: var(--red-deep);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

a:visited {
  color: var(--red-deep);
  opacity: 0.78;
}

a:hover,
a:focus,
a:active {
  color: var(--red);
}

/* Database-index headings carry the link; keep them ink-black with the
   accent on hover. The colored db-slug bar at left is provided by
   app.css and we leave it alone. */
.index h2 a,
.index h2 a:link,
.index h2 a:visited {
  color: var(--ink);
  text-decoration: none;
}

.index h2 a:hover,
.index h2 a:focus {
  color: var(--red);
  text-decoration: none; /* the h2::after rule below carries the hover state */
}

/* Index of databases ----------------------------------------------------- */

.index {
  list-style: none;
  padding: 0;
}

.index li {
  border-bottom: 1px dotted var(--rule);
  padding: 0.9rem 0;
}

.index h2 {
  border: none !important; /* override Datasette's inline per-db swatch */
  padding-left: 0 !important;
  margin: 0 0 0.3rem;
  font-size: 1.5rem;
}

/* On the index, each h2 wraps a link — expand the rule on hover. */
.index h2:hover::after {
  width: 100%;
}

.metadata-description {
  color: var(--ink-soft);
  font-size: 0.95rem;
}

/* The column-list line under each table heading is a single long
   underscore_separated string. Let it wrap on narrow viewports —
   otherwise it pushes the document wider than the viewport on
   mobile and the masthead/footer line-art runs short. */
.db-table em {
  overflow-wrap: anywhere;
}

/* Datasette's default mobile stylesheet reflows tables into
   card-per-row at <=576px (display: block on every element, thead
   pushed off-screen, td:::before pulling the column name in). HCI
   research on result-set tables (NN/g, the search-UI literature)
   explicitly warns against responsive-collapse to cards — it
   destroys the find/scan task that's the whole point. Keep the
   real table on small viewports too; the .table-wrapper still
   horizontal-scrolls when the columns don't fit. */
@media only screen and (max-width: 576px) {
  table.rows-and-columns,
  .rows-and-columns thead,
  .rows-and-columns tbody,
  .rows-and-columns tr,
  .rows-and-columns th,
  .rows-and-columns td {
    display: revert;
  }

  .rows-and-columns thead tr {
    position: static;
    top: auto;
    left: auto;
  }

  table.rows-and-columns tr {
    border: none;
    margin-bottom: 0;
    border-radius: 0;
    background-color: transparent;
    padding: 0;
  }

  table.rows-and-columns td {
    border: none;
    border-right: 1px solid var(--rule-soft);
    padding: 0.45rem 0.75rem;
  }

  table.rows-and-columns td:before {
    content: none;
    display: none;
  }
}

/* Tables — HCI-grounded result-set table design.
   References: Few (Show Me the Numbers); Enders 2008 (zebra striping for wide
   tables); Rutter / Ström on numeric vs. ID alignment; NN/g on sticky headers
   and frozen identifier columns; tabular figures via OpenType "tnum"/"lnum". */

/* Sticky thead is delivered by static/sticky-thead.js (a fixed-position
   <thead> clone with widths kept in sync). The wrapper keeps Datasette's
   default horizontal scroll. The frozen leftmost column below stays put
   within the wrapper's horizontal-scroll context. */
.table-wrapper {
  border: 1px solid var(--rule);
}

/* The JS-injected clone overlay — overflow-x: auto so the cloned first-th's
   `position: sticky; left: 0` actually has a scroll container. We programmatically
   keep its scrollLeft synced to the real wrapper. Scrollbars hidden. */
.sticky-thead-clone {
  position: fixed;
  top: 0;
  z-index: 50;
  overflow-x: auto;
  overflow-y: hidden;
  pointer-events: none;
  scrollbar-width: none;
  background: var(--paper-edge);
  box-shadow: 0 1px 0 var(--rule);
}
.sticky-thead-clone::-webkit-scrollbar { display: none; }
.sticky-thead-clone table {
  margin: 0;
  background: transparent;
}


table {
  background: #ffffff;
  border: none;
  border-collapse: collapse;
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
}

/* Sticky column headers — biggest UX win on long tables.
   .table-wrapper has overflow-x: auto and overflow-y: visible, so sticky-top
   tracks the document's vertical scroll. */
table.rows-and-columns thead th {
  position: sticky;
  top: 0;
  z-index: 2;
}

th {
  background: var(--paper-edge);
  border-bottom: 2px solid var(--ink);
  font-family: var(--sans-label);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-align: left;
  padding: 0.55rem 0.7rem;
  color: var(--ink);
}

td,
table.rows-and-columns td {
  padding: 0.45rem 0.75rem;
  border: none;
  border-right: 1px solid var(--rule-soft);
  overflow: hidden;
}

tr td:last-child,
table.rows-and-columns tr td:last-child {
  border-right: none;
}

/* Match column separators on the header row too. */
th,
table.rows-and-columns th {
  border-right: 1px solid var(--rule-soft);
}
tr th:last-child,
table.rows-and-columns tr th:last-child {
  border-right: none;
}

/* Light zebra (Enders 2008): the stripe carries row tracking on wide tables,
   so we drop the per-row horizontal rule to keep the page quiet. */
tbody tr:nth-child(even) td {
  background: rgba(21, 17, 13, 0.035);
}

tbody tr:hover td {
  background: rgba(192, 2, 62, 0.06);
}

/* Row detail page has a single-row table — the hover tint, the frozen
   leftmost column, and the sticky-thead clone are all noise when there's
   nothing to scroll through. */
body.row tbody tr:hover td,
body.row table.rows-and-columns tbody tr:hover td:first-child {
  background: inherit;
}

body.row table.rows-and-columns thead th:first-child,
body.row table.rows-and-columns tbody td:first-child {
  position: static;
  border-right: none;
}

body.row .sticky-thead-clone {
  display: none;
}

/* Frozen leftmost (primary-key) column — preserves row identity on
   horizontal scroll. Must repaint a background or the scrolling cells
   show through. */
table.rows-and-columns thead th:first-child,
table.rows-and-columns tbody td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: #ffffff;
  border-right: 1px solid var(--rule-soft);
}

table.rows-and-columns tbody tr:nth-child(even) td:first-child {
  background: #f3eee9; /* near-paper, slightly stronger than the row stripe */
}

table.rows-and-columns tbody tr:hover td:first-child {
  background: #f4d6de;
}

table.rows-and-columns thead th:first-child {
  background: var(--paper-edge);
  z-index: 3; /* corner cell: above both row-sticky and column-sticky */
}

/* Alignment — Ström/Rutter: right-align quantitative numerics; leave
   identifiers, codes, ZIPs, years, dates left-aligned. Datasette's
   type-int / type-real type classes don't distinguish ID from quantity,
   so we right-align type-real (almost always quantitative) and use
   column-name substring matching for known quantitative integer columns. */
table.rows-and-columns td.type-real,
table.rows-and-columns th.col-amount,
table.rows-and-columns td[class*="size"],
table.rows-and-columns td[class*="count"],
table.rows-and-columns td[class*="number_of"],
table.rows-and-columns td[class*="votes"],
table.rows-and-columns td[class*="amount"],
table.rows-and-columns td[class*="total"] {
  text-align: right;
}

table.rows-and-columns th.col-amount,
table.rows-and-columns th[class*="size"],
table.rows-and-columns th[class*="count"],
table.rows-and-columns th[class*="number_of"],
table.rows-and-columns th[class*="votes"],
table.rows-and-columns th[class*="amount"],
table.rows-and-columns th[class*="total"] {
  text-align: right;
}

/* Error pages — let the heading + a calm body paragraph do the work,
   no angry red-bordered div. */
.error-message {
  font-size: 1.1rem;
  color: var(--ink-soft);
  margin: 1rem 0 1.5rem;
}

/* Download-this-data card — bordered block to pull the eye toward
   the CSV/JSON downloads after a long result set. */
.download-card {
  margin: 2rem 0 1.5rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--rule);
  background: var(--paper-edge);
}

.download-card h3 {
  margin: 0 0 0.5rem;
  color: var(--ink); /* override the red h3-label treatment here */
}

.download-card p {
  margin: 0;
  font-size: 1rem;
}

.download-card .download-link {
  font-weight: 700;
}

/* Collapsible table schema — keep the CREATE TABLE definition out of
   the way unless someone explicitly opens it. */
.schema-details {
  margin: 2rem 0;
}

.schema-details > summary {
  cursor: pointer;
  font-family: var(--sans-label);
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  padding: 0.4rem 0;
}

.schema-details > summary:hover {
  color: var(--red);
}

.schema-details[open] > summary {
  margin-bottom: 0.5rem;
}

/* Advanced db-page links (schema, download) — separated from the table
   list above by a short hairline rule echoing the h1/h2 ::after partials. */
.advanced-db-links {
  margin-top: 2.5rem;
  font-size: 0.9rem;
}

.advanced-db-links::before {
  content: "";
  display: block;
  width: 3.5rem;
  height: 1px;
  margin-bottom: 1rem;
  background: var(--rule);
}

.download-sqlite {
  font-size: 0.9rem;
  margin-top: 0.3rem;
}

/* Code & SQL ------------------------------------------------------------- */

/* Mono only on actual code, not on the .sql form wrapper (otherwise its
   Run SQL / Edit SQL buttons inherit Iosevka and look out of place). */
pre, code, .cm-editor, .sql.core pre, .sql.core textarea {
  font-family: "Iosevka", "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.88rem;
}

/* Treat .sql.core (and pre blocks) as a card on a slightly darker
   background, not a black slab. */
pre, .sql.core {
  background: var(--paper-edge);
  color: var(--ink);
  border: 1px solid var(--rule);
  padding: 0.85rem 1rem;
  border-radius: 0;
  margin-bottom: 1.5rem;
}

/* The "Edit SQL" link on a canned query is a navigation action equal in
   weight to "Run SQL" — render it as a ghost button to match. */
a.canned-query-edit-sql,
a.canned-query-edit-sql:link,
a.canned-query-edit-sql:visited {
  display: inline-block;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 0;
  padding: 0.45rem 1rem;
  font-family: var(--sans-label);
  font-size: 0.95rem;
  line-height: 1; /* match the button/input default so heights align */
  letter-spacing: 0.04em;
  text-decoration: none;
  vertical-align: middle; /* match input[type=submit] */
  cursor: pointer;
}

a.canned-query-edit-sql:hover {
  background: var(--ink);
  color: var(--paper);
}

/* CodeMirror editor: subtle look-and-feel adjustments for the read-only
   variant so it doesn't invite typing. */
.cm-editor.cm-readonly {
  background: #ffffff;
  opacity: 0.95;
}
.cm-editor.cm-readonly .cm-cursor {
  display: none !important;
}

/* Footer ----------------------------------------------------------------- */

footer.ft {
  margin-top: 3rem;
  padding: 1.2rem 1.5rem;
  border-top: 1px solid var(--ink);
  box-shadow: 0 -3px 0 var(--paper), 0 -4px 0 var(--red);
  background: var(--paper);
  background-image: none;
  font-family: var(--sans-label);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-mute);
  text-align: center;
  min-height: 0;
}

footer.ft a,
footer.ft a:link,
footer.ft a:visited {
  color: var(--ink-soft);
}

footer.ft a:hover,
footer.ft a:focus {
  color: var(--red);
}

/* Forms / inputs --------------------------------------------------------- */

input[type=text], input[type=search], textarea, select {
  background: #ffffff;
  border: 1px solid var(--rule);
  font-family: var(--sans-body);
  padding: 0.35rem 0.5rem;
}

button,
input[type=submit],
.core input[type=submit],
input.core[type=submit] {
  background: var(--ink);
  background-image: none;
  color: var(--paper);
  border: 1px solid var(--ink);
  border-radius: 0;
  padding: 0.45rem 1rem;
  font-family: var(--sans-label);
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  cursor: pointer;
}

button:hover,
input[type=submit]:hover,
.core input[type=submit]:hover,
input.core[type=submit]:hover {
  background: var(--red);
  background-image: none;
  border-color: var(--red);
}

/* "Ghost" buttons (Format SQL etc.) — inverted */
.core button[type=button],
button.core[type=button] {
  background: var(--paper);
  background-image: none;
  color: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 0;
  padding: 0.45rem 1rem;
  font-family: var(--sans-label);
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.core button[type=button]:hover,
button.core[type=button]:hover {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
