/* ZippyOddsAPI shared stylesheet: design tokens and shared components.
   site/app/ builds on these names, so tokens and class names here are a contract: add, do not rename.
   The look is dark, dense and loud where it counts: warm charcoal, fine light rules, and one bright lead colour. */

@font-face {
  font-family: "Bricolage Grotesque";
  src: url("/assets/shared/fonts/bricolage-grotesque.woff2") format("woff2-variations");
  font-weight: 200 800;
  font-display: swap;
}

@font-face {
  font-family: "Instrument Sans";
  src: url("/assets/shared/fonts/instrument-sans.woff2") format("woff2-variations");
  font-weight: 400 700;
  font-display: swap;
}

:root {
  color-scheme: dark;

  /* Type. Our own two faces, served from here, with no third-party requests. */
  --font-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --font-body: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-md: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.375rem;
  --text-2xl: 1.875rem;
  --text-3xl: clamp(2.125rem, 1.45rem + 3.2vw, 3.625rem);

  /* Space. */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.5rem;
  --sp-6: 2rem;
  --sp-7: 3rem;
  --sp-8: 4.5rem;

  --radius: 0.6rem;
  --wrap: 76rem;
  --header-h: 3.5rem;

  /* Colour. One dark scheme, with one neon lead colour. ZippyOdds swaps the accent in /assets/ev/tools.css. */
  --bg: #0f0c0b;
  --surface: #1a1614;
  --surface-2: #221d1a;
  --ink: #fff8f0;
  --ink-2: #d2c6ba;
  --ink-3: #a09184;
  --rule: rgba(255, 240, 225, 0.09);
  --rule-strong: rgba(255, 240, 225, 0.22);
  --grid: rgba(255, 240, 225, 0.035);
  --accent: #ff2f92;
  --accent-hover: #ff6cb1;
  --accent-ink: #200010;
  --accent-soft: rgba(255, 47, 146, 0.13);
  --focus: #ff2f92;

  /* State colours. These mark a glyph, tick or bar; text beside them stays in ink. */
  --good: #ffb81c;
  --warn: #ff6b3d;
  --bad: #ff4f5e;
  --off: #8a7d74;

  --code-bg: #141110;
  --code-ink: #fff3e8;
  --code-dim: #a09184;
  --code-key: #ff6cb1;
  --code-str: #ffc95c;
  --code-num: #ffe3c2;
  --code-rule: rgba(255, 240, 225, 0.1);
}

/* ---------- Base ---------- */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + var(--sp-4));
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-md);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

main {
  flex: 1 0 auto;
  min-width: 0;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -0.025em;
}

h1 {
  font-size: var(--text-3xl);
}

h2 {
  font-size: var(--text-2xl);
}

h3 {
  font-size: var(--text-xl);
}

h4 {
  font-size: var(--text-lg);
}

p {
  margin: 0;
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 0.16em;
  text-decoration-thickness: 1px;
}

a:hover {
  color: var(--accent-hover);
  text-decoration-thickness: 2px;
}

code,
kbd,
pre,
.mono {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

:not(pre) > code {
  padding: 0 0.28em;
  background: var(--surface-2);
  border-radius: var(--radius);
  overflow-wrap: anywhere;
}

ul,
ol {
  margin: 0;
  padding-left: 1.25rem;
}

li + li {
  margin-top: var(--sp-1);
}

hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 0;
}

svg {
  display: block;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- Layout helpers ---------- */

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: var(--sp-4);
}

@media (min-width: 48rem) {
  .wrap {
    padding-inline: var(--sp-6);
  }
}

/* For pages built around a wide table. */
.page-wide .wrap {
  max-width: 96rem;
}

.stack > * + * {
  margin-top: var(--sp-4);
}

.stack-sm > * + * {
  margin-top: var(--sp-2);
}

.stack-lg > * + * {
  margin-top: var(--sp-6);
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-3);
}

.row-between {
  justify-content: space-between;
}

.grow {
  flex: 1 1 auto;
  min-width: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: var(--sp-3);
  top: -4rem;
  z-index: 50;
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface);
  color: var(--ink);
  border: 2px solid var(--focus);
}

.skip-link:focus {
  top: var(--sp-2);
}

/* ---------- Type helpers ---------- */

.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.lede {
  font-size: var(--text-lg);
  line-height: 1.5;
  color: var(--ink-2);
  max-width: 44rem;
}

.muted {
  color: var(--ink-2);
}

.small {
  font-size: var(--text-sm);
}

.xsmall {
  font-size: var(--text-xs);
}

.num {
  font-variant-numeric: tabular-nums lining-nums;
}

.nowrap {
  white-space: nowrap;
}

/* ---------- Site header and footer ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(15, 12, 11, 0.8);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--rule);
}

.site-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  min-height: var(--header-h);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  color: var(--ink);
  text-decoration: none;
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  min-width: 0;
}

.brand:hover {
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  flex: none;
  width: 1.75rem;
  height: 1.75rem;
}

.brand-api {
  color: var(--accent);
}

.mark-bob {
  fill: var(--accent);
  filter: drop-shadow(0 0 3px var(--accent));
}

.site-nav {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
}

/* A phone has room for the mark or the links on one row, not both. */
@media (max-width: 47.99rem) {
  .site-header {
    position: static;
  }

  .site-header-inner {
    flex-wrap: wrap;
    gap: var(--sp-1) var(--sp-3);
    padding-block: var(--sp-2);
  }

  .site-nav {
    flex: 1 1 100%;
    flex-wrap: wrap;
    margin-inline: calc(var(--sp-2) * -1);
  }
}

.site-nav a {
  text-transform: lowercase;
  display: inline-block;
  padding: var(--sp-2) var(--sp-3);
  color: var(--ink-2);
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 500;
  text-decoration: none;
  border-radius: 0.55rem;
}

.site-nav a:hover {
  background: rgba(255, 240, 225, 0.05);
  color: var(--ink);
}

@media (max-width: 47.99rem) {
  .site-nav a {
    padding-inline: var(--sp-2);
  }
}

.site-nav a[aria-current="page"] {
  color: var(--accent);
}

.site-footer {
  flex: none;
  margin-top: var(--sp-8);
  border-top: 1px solid var(--rule);
  background: #141110;
  font-size: var(--text-sm);
}

.site-footer-inner {
  display: grid;
  gap: var(--sp-5);
  padding-block: var(--sp-6);
}

@media (min-width: 48rem) {
  .site-footer-inner {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: start;
  }
}

.footer-legal {
  max-width: 40rem;
  color: var(--ink-2);
}

.footer-legal strong {
  color: var(--ink);
  font-weight: 600;
}

.footer-links a {
  color: var(--ink-2);
  text-decoration: none;
}

.footer-links a:hover {
  color: var(--accent);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-4);
  list-style: none;
  margin: 0;
  padding: 0;
}

.footer-links li + li {
  margin-top: 0;
}

/* ---------- Tick scale: the page rule used between large sections ---------- */

.scale {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent) 20%, var(--accent) 80%, transparent);
  box-shadow: 0 0 12px var(--accent);
  opacity: 0.55;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 2.5rem;
  padding: var(--sp-2) var(--sp-4);
  background: rgba(255, 240, 225, 0.035);
  color: var(--ink);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
}

.btn:hover {
  background: var(--surface-2);
  color: var(--ink);
  text-decoration: none;
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 0 18px -4px var(--accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--accent-ink);
  box-shadow: 0 0 26px -4px var(--accent);
}

.btn-danger {
  border-color: var(--bad);
  color: var(--bad);
}

.btn-danger:hover {
  background: var(--bad);
  border-color: var(--bad);
  color: var(--surface);
}

.btn-ghost {
  border-color: transparent;
}

.btn-sm {
  min-height: 2rem;
  padding: var(--sp-1) var(--sp-3);
  font-size: var(--text-xs);
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  min-width: 0;
}

.field-label {
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-2);
}

.field-hint {
  font-size: var(--text-xs);
  color: var(--ink-2);
}

.field-error {
  font-size: var(--text-sm);
  color: var(--ink);
  border-left: 3px solid var(--bad);
  padding-left: var(--sp-2);
}

.input,
.select {
  width: 100%;
  min-height: 2.5rem;
  padding: var(--sp-2) var(--sp-3);
  background: rgba(255, 240, 225, 0.035);
  color: var(--ink);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  font: inherit;
  font-size: var(--text-sm);
}

.input:focus-visible,
.select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.select option {
  background: var(--surface);
  color: var(--ink);
}

.input::placeholder {
  color: var(--ink-3);
  opacity: 1;
}

.form-grid {
  display: grid;
  gap: var(--sp-3);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr));
  align-items: start;
}

/* A submit button lines up with the inputs beside it, below their labels. */
.form-grid > .btn {
  justify-self: start;
  margin-top: 1.25rem;
}

/* ---------- Panels ---------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  min-width: 0;
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2) var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--rule);
}

.panel-title {
  font-size: var(--text-lg);
}

.panel-body {
  padding: var(--sp-4);
}

/* ---------- Tables ---------- */

.table-scroll {
  max-width: 100%;
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  line-height: 1.4;
}

.table caption {
  caption-side: top;
  text-align: left;
}

.table th,
.table td {
  padding: var(--sp-2) var(--sp-3);
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--rule);
}

.table tbody tr:last-child > * {
  border-bottom: 0;
}

.table thead th {
  background: var(--surface);
  border-bottom: 1px solid var(--rule-strong);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--ink-3);
}

.table tbody tr:hover > * {
  background: rgba(255, 240, 225, 0.025);
}

.table tbody th {
  font-weight: 600;
}

.table .num {
  text-align: right;
  white-space: nowrap;
}

/* Keys and values in a table stay whole; the table scrolls in its own container instead. */
.table code {
  overflow-wrap: normal;
  white-space: nowrap;
}

/* For tables with a prose column: wide enough that the prose isn't squeezed when the table scrolls. */
.table-wide {
  min-width: 46rem;
}

.table-tight th,
.table-tight td {
  padding: var(--sp-1) var(--sp-2);
}

.th-sort {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 0;
  background: none;
  border: 0;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
}

.th-sort::after {
  content: "";
  display: inline-block;
  width: 0.55em;
  height: 0.55em;
  border-right: 1.5px solid var(--ink-3);
  border-bottom: 1.5px solid var(--ink-3);
  transform: rotate(45deg) translate(-1px, -1px);
  opacity: 0.45;
}

th[aria-sort="ascending"] .th-sort::after {
  border-color: var(--accent);
  opacity: 1;
  transform: rotate(-135deg) translate(-1px, -1px);
}

th[aria-sort="descending"] .th-sort::after {
  border-color: var(--accent);
  opacity: 1;
}

/* ---------- Badges: state shown by glyph shape and word, never colour alone ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  font-size: var(--text-sm);
  color: var(--ink);
  white-space: nowrap;
}

.badge-glyph {
  flex: none;
  width: 0.72em;
  height: 0.72em;
  border: 2px solid var(--off);
  border-radius: 50%;
}

/* Filled disc. */
.tone-good .badge-glyph {
  background: var(--good);
  border-color: var(--good);
}

/* Half-filled disc. */
.tone-warn .badge-glyph {
  border-color: var(--warn);
  background: linear-gradient(90deg, var(--warn) 50%, transparent 50%);
}

/* Square. */
.tone-bad .badge-glyph {
  border-color: var(--bad);
  border-radius: 0;
  background: var(--bad);
}

/* Empty ring. */
.tone-empty .badge-glyph {
  border-color: var(--ink-2);
  background: transparent;
}

/* Short dash. */
.tone-off .badge-glyph {
  height: 0;
  border-width: 1px;
  border-color: var(--off);
  border-radius: 0;
}

/* ---------- Notices and states ---------- */

.notice {
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-left: 4px solid var(--ink-3);
  font-size: var(--text-sm);
  overflow-wrap: anywhere;
}

.notice-error {
  border-left-color: var(--bad);
}

.notice-warn {
  border-left-color: var(--warn);
}

.notice-ok {
  border-left-color: var(--good);
}

.notice-title {
  display: block;
  margin-bottom: var(--sp-1);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-md);
}

.empty {
  padding: var(--sp-6) var(--sp-4);
  text-align: center;
  color: var(--ink-2);
  font-size: var(--text-sm);
}

.loading {
  padding: var(--sp-6) var(--sp-4);
  text-align: center;
  color: var(--ink-2);
  font-size: var(--text-sm);
}

.loading::before {
  content: "";
  display: block;
  width: 6rem;
  height: 2px;
  margin: 0 auto var(--sp-3);
  background: linear-gradient(90deg, var(--accent) 0 30%, var(--rule) 30% 100%);
  background-size: 200% 100%;
  animation: loading-slide 1.1s linear infinite;
}

@keyframes loading-slide {
  from {
    background-position: 100% 0;
  }

  to {
    background-position: -100% 0;
  }
}

/* ---------- Stat tiles and the title block they sit in ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 9.5rem), 1fr));
  gap: 1px;
  overflow: hidden;
  background: var(--rule);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}

.stat {
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface);
  min-width: 0;
}

.stat-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.stat-value {
  display: block;
  margin-top: var(--sp-1);
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums lining-nums;
}

.stat-sub {
  display: block;
  margin-top: var(--sp-1);
  font-size: var(--text-xs);
  color: var(--ink-2);
}

/* ---------- Code ---------- */

.code {
  position: relative;
  margin: 0;
  padding: var(--sp-3) var(--sp-4);
  max-width: 100%;
  overflow-x: auto;
  background: var(--code-bg);
  color: var(--code-ink);
  border: 1px solid var(--code-rule);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.55;
  tab-size: 2;
}

.code code {
  font-size: inherit;
  background: none;
  padding: 0;
}

.code a {
  color: inherit;
}

.tok-key {
  color: var(--code-key);
}

.tok-str {
  color: var(--code-str);
}

.tok-num {
  color: var(--code-num);
}

.tok-dim {
  color: var(--code-dim);
}

.code-wrap {
  position: relative;
  min-width: 0;
}

.code-label {
  display: block;
  padding: var(--sp-1) var(--sp-4);
  background: var(--code-bg);
  color: var(--code-dim);
  border: 1px solid var(--code-rule);
  border-bottom: 0;
  border-radius: var(--radius) var(--radius) 0 0;
  font-family: var(--font-display);
  font-size: var(--text-xs);
  letter-spacing: 0.05em;
}

.code-label + .code {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.code-copy {
  position: absolute;
  top: var(--sp-1);
  right: var(--sp-1);
  min-height: 1.625rem;
  padding: 0 var(--sp-2);
  background: var(--code-bg);
  color: var(--code-ink);
  border: 1px solid var(--code-dim);
  border-radius: var(--radius);
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: pointer;
}

.code-copy:hover {
  background: var(--code-rule);
}

/* ---------- Dialog ---------- */

.dialog {
  width: min(36rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  padding: 0;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
}

.dialog::backdrop {
  background: rgba(6, 14, 26, 0.62);
}

.dialog-head {
  padding: var(--sp-4) var(--sp-4) var(--sp-2);
}

.dialog-body {
  padding: var(--sp-2) var(--sp-4) var(--sp-4);
}

.dialog-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--rule);
}

/* ---------- Book logos ---------- */

.book-tile {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 1.25rem;
  height: 1.25rem;
  overflow: hidden;
  border-radius: 0.3rem;
  background: var(--surface-2);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1;
  vertical-align: -0.28em;
}

.book-tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cov-name .book-tile {
  margin-right: 0.4rem;
}

/* ---------- Phones and touch screens (10 Nov): 44px thumb targets and readable small print. Sizes only. ---------- */

@media (max-width: 47.99rem), (pointer: coarse) {
  .btn, .input, .select { min-height: 44px; }
  .btn-sm { min-height: 44px; min-width: 44px; }
  .code-copy { min-height: 44px; min-width: 44px; }
  /* The taller Copy button sits over the code's top-right corner: the code starts below it, never under it. */
  .code-wrap > .code { padding-top: calc(44px + var(--sp-2)); }
  .th-sort { min-height: 44px; min-width: 44px; }
  .book-tile { font-size: 0.75rem; }
  .brand { min-height: 44px; }
  .site-nav a { display: inline-flex; align-items: center; min-height: 44px; }
  .footer-links a { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; }
  .footer-links { gap: 0 var(--sp-4); }
  .stat-label, .table th, .table thead th { font-size: 0.75rem; }
}

@supports (padding: env(safe-area-inset-top)) {
  .site-header { padding-top: env(safe-area-inset-top); }
  .site-footer { padding-bottom: env(safe-area-inset-bottom); }
}

/* Same as ZippyOdds: no live blur under a sticky header on a phone, the same colour nearly opaque instead. */
@media (max-width: 47.99rem) {
  .site-header { -webkit-backdrop-filter: none; backdrop-filter: none; background: rgb(15 12 11 / 0.96); }
}
