/* The style of the whole site.
 *
 * The file is mobile first. Every rule outside a media query is the rule for
 * a telephone. The one media query adds the wide layout.
 *
 * The tokens are the shadcn reference: an achromatic palette, a pill for each
 * interactive shape, and a card that sits on a hairline.
 *
 * No font comes from the network. The content security policy permits no
 * other host, so the stack falls back to the font of the system.
 */

:root {
  --canvas: #f5f5f5;
  --paper: #ffffff;
  --surface-alt: #fafafa;
  --ink: #0a0a0a;
  --ink-soft: #171717;
  --mid: #737373;
  --hairline: #e5e5e5;
  --ember: #e7000b;

  --font: 'Geist', ui-sans-serif, system-ui, -apple-system,
    BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --r-pill: 18px;
  --r-card: 24px;
  --r-small: 6px;

  /* A finger needs 44 pixels. A mouse does not. */
  --tap: 44px;

  --shadow: rgba(23, 23, 23, 0.05) 0 0 0 1px,
    rgba(0, 0, 0, 0.1) 0 1px 3px 0,
    rgba(0, 0, 0, 0.1) 0 1px 2px -1px;
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;   /* No zoom of the text when it turns. */
}

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;          /* 16 stops iOS from zooming into a field. */
  line-height: 1.5;
  font-feature-settings: "ss01" on, "cv11" on;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}

a { color: inherit; }

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

/* ---------- shapes ---------- */

.badge {
  display: inline-block;
  background: var(--ink-soft);
  color: #fafafa;
  border-radius: var(--r-pill);
  padding: 2px 8px;
  font-size: 12px;
  line-height: 1.33;
  letter-spacing: 0.6px;
  font-weight: 500;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge--soft { background: var(--canvas); color: var(--ink-soft); }

.badge--outline {
  background: transparent;
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--hairline);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--tap);
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  font: 500 15px/1 var(--font);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  touch-action: manipulation;
}

.button--filled { background: var(--ink); color: #fafafa; }
.button--ghost { background: var(--canvas); color: var(--ink); }
.button--outline { background: transparent; border-color: var(--hairline); }

.input {
  width: 100%;
  min-height: var(--tap);
  padding: 0 14px;
  background: var(--canvas);
  color: var(--ink);
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  font: 400 16px/1 var(--font);
}

.input:focus {
  outline: none;
  border-color: var(--hairline);
  background: var(--paper);
}

.card {
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-radius: var(--r-card);
  box-shadow: var(--shadow);
  padding: 16px;
}

.muted { color: var(--mid); }
.mono { font-family: var(--mono); }

.caption {
  font-size: 12px;
  line-height: 1.33;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--mid);
}

/* ---------- application shell ---------- */

.shell { display: flex; flex-direction: column; min-height: 100vh; }

/* On a telephone the rail is a strip of chips that scrolls sideways. It
 * stays on the screen, so no tap is needed to reach a record set. */
.sidebar {
  background: var(--surface-alt);
  border-bottom: 1px solid var(--hairline);
  padding: 8px 12px 10px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.sidebar__brand {
  display: block;
  padding: 4px 0 8px;
  font-weight: 600;
  letter-spacing: -0.3px;
  text-decoration: none;
}

.sidebar__scroll {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.sidebar__scroll::-webkit-scrollbar { display: none; }

.sidebar__group { display: contents; }
.sidebar__group > .caption { display: none; }

.navlink {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  min-height: 38px;
  border-radius: var(--r-pill);
  background: var(--paper);
  border: 1px solid var(--hairline);
  text-decoration: none;
  color: var(--ink);
  white-space: nowrap;
  font-size: 14px;
}

.navlink--on { background: var(--ink); color: #fafafa; border-color: var(--ink); }
.navlink span:last-child { color: var(--mid); font-size: 12px; }
.navlink--on span:last-child { color: #d4d4d8; }

.main { flex: 1; min-width: 0; padding: 16px 12px 64px; }

.topbar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  margin-bottom: 14px;
}

.topbar h1 {
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: -0.6px;
  font-weight: 600;
  margin: 0;
}

.spacer { display: none; }

.crumbs { color: var(--mid); margin-bottom: 6px; font-size: 14px; }
.crumbs a { text-decoration: none; }

/* ---------- table ---------- */

.tablewrap {
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-radius: var(--r-card);
  box-shadow: var(--shadow);
  overflow: auto;
  max-height: 70vh;
  -webkit-overflow-scrolling: touch;
}

table { border-collapse: separate; border-spacing: 0; width: 100%; }

thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--hairline);
  padding: 10px 12px;
  text-align: left;
  font-size: 12px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--mid);
  font-weight: 500;
  white-space: nowrap;
}

thead th a { text-decoration: none; display: block; min-height: 24px; }

tbody td {
  border-bottom: 1px solid var(--hairline);
  padding: 10px 12px;
  vertical-align: top;
  font-size: 14px;
  min-width: 120px;
  max-width: 280px;
  overflow-wrap: anywhere;
}

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

/* The row number stays on the screen while the table scrolls sideways. */
th.num, td.num {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--paper);
  min-width: 56px;
  color: var(--mid);
  font-family: var(--mono);
  font-size: 12px;
  text-align: right;
  white-space: nowrap;
  border-right: 1px solid var(--hairline);
}

thead th.num { z-index: 3; background: var(--surface-alt); }
td.num a { display: block; min-height: 24px; text-decoration: none; }

/* ---------- record view ---------- */

.record { display: block; }

.record dt {
  padding: 10px 12px 0;
  color: var(--mid);
  font-size: 12px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

.record dd {
  margin: 0;
  padding: 2px 12px 10px;
  border-bottom: 1px solid var(--hairline);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  font-size: 14px;
}

/* ---------- bits ---------- */

.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

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

.stat__label { display: block; }

.stat__value {
  font-size: 30px;
  line-height: 1.2;
  letter-spacing: -0.75px;
  font-weight: 600;
}

.notice {
  border: 1px solid var(--hairline);
  border-radius: var(--r-card);
  background: var(--paper);
  padding: 16px;
  color: var(--mid);
}

.pager {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.pager .button { flex: 1; }
.pager span { flex-basis: 100%; text-align: center; order: -1; }

/* ---------- the wide layout ---------- */

@media (min-width: 861px) {
  body { font-size: 14px; line-height: 1.43; }

  .shell { flex-direction: row; }

  .sidebar {
    width: 248px;
    flex: 0 0 248px;
    height: 100vh;
    overflow-y: auto;
    padding: 20px 12px;
    border-bottom: 0;
    border-right: 1px solid var(--hairline);
  }

  .sidebar__brand { padding: 0 8px 16px; }

  .sidebar__scroll { display: block; overflow: visible; }

  .sidebar__group { display: block; margin-top: 16px; }

  .sidebar__group > .caption {
    display: block;
    padding: 0 8px 6px;
  }

  .navlink {
    display: flex;
    justify-content: space-between;
    min-height: 0;
    padding: 6px 8px;
    border: 0;
    border-radius: var(--r-small);
    background: transparent;
    font-size: 14px;
  }

  .navlink:hover { background: var(--canvas); }

  .navlink--on {
    background: var(--canvas);
    color: var(--ink);
    font-weight: 500;
  }

  .navlink--on span:last-child { color: var(--mid); }

  .main { padding: 24px 24px 64px; }

  .topbar {
    flex-direction: row;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
  }

  .topbar h1 { font-size: 24px; line-height: 1.33; }

  .spacer { display: block; flex: 1; }

  .button { min-height: 36px; padding: 0 14px; font-size: 14px; }
  .button--sm { min-height: 30px; padding: 0 10px; font-size: 13px; }
  .input { min-height: 36px; font-size: 14px; }
  .card { padding: 20px; }

  .tablewrap { max-height: calc(100vh - 220px); }
  tbody td { padding: 8px 12px; max-width: 340px; }
  tbody tr:hover { background: var(--surface-alt); }
  tbody tr:hover td.num { background: var(--surface-alt); }

  .grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }

  .record { display: grid; grid-template-columns: 220px 1fr; }
  .record dt { padding: 8px 12px; border-bottom: 1px solid var(--hairline); }
  .record dd { padding: 8px 12px; }

  .pager .button { flex: none; }
  .pager span { flex-basis: auto; order: 0; }
}

/* ---------- the search bar of the table view ---------- */

.searchbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.searchbar .input { flex: 1 1 100%; }

@media (min-width: 861px) {
  .searchbar .input { flex: 0 1 260px; }
}

/* ---------- the chip row of the catalogue ---------- */

.chips {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 12px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.chips::-webkit-scrollbar { display: none; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  min-height: 38px;
  border-radius: var(--r-pill);
  background: var(--paper);
  border: 1px solid var(--hairline);
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
  font-size: 14px;
}

.chip span { color: var(--mid); font-size: 12px; }
.chip--on { background: var(--ink); color: #fafafa; border-color: var(--ink); }
.chip--on span { color: #d4d4d8; }

@media (min-width: 861px) {
  .chips { flex-wrap: wrap; overflow: visible; }
  .chip { min-height: 30px; padding: 4px 10px; font-size: 13px; }
}
