/* pac.fail — minimal, readable, works in Lynx */

:root {
  --ink:      #1a1a1a;
  --muted:    #555;
  --rule:     #ddd;
  --bg:       #fff;
  --link:     #0645ad;
  --link-vis: #551a8b;

  /* severity badge colors — WCAG AA on white */
  --critical: #b91c1c;
  --high:     #b45309;
  --medium:   #0369a1;
  --low:      #166534;
}

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

/* iOS Safari inflates text it deems too small inside wide scrollable
   blocks (our nowrap tables), and does it per-cell — link-bearing cells
   randomly render larger. Pin text size to what the stylesheet says. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  margin: 0;
  padding: 0 1rem;
}

/* ── Layout ── */

.page {
  max-width: 105ch;
  margin: 0 auto;
  padding: 1.5rem 0 4rem;
}

/* ── Logo (ported from pac.dog) ── */

.site-logo { margin: 0.25rem 0 0.5rem; }
.site-logo a {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  font-size: 2rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-decoration: none;
}
.logo-dog { margin-top: 0.2rem; }

/* ── Site-wide notice (above nav) — bootstrap alert-info palette ── */

.site-notice {
  background: #cfe2ff;
  border: 1px solid #9ec5fe;
  border-radius: 6px;
  padding: 0.6rem 0.85rem;
  margin: 0.75rem 0;
  font-size: 0.875rem;
  color: #052c65;
}

/* ── Nav ── */

nav {
  border-bottom: 1px solid var(--rule);
  padding: 0.5rem 0;
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
  color: var(--muted);
}

nav ul {
  margin: 0;
  padding-left: 1.5rem;
}

nav li { margin-bottom: 0.15rem; }

/* ── Typography ── */

h1 { font-size: 1.75rem; margin: 0 0 0.25rem; }
h2 { font-size: 1.25rem; margin: 1.75rem 0 0.5rem; border-bottom: 1px solid var(--rule); padding-bottom: 0.25rem; }
h3 { font-size: 1rem; margin: 1.25rem 0 0.25rem; }
p  { margin: 0 0 0.75rem; }

a            { color: var(--link); }
a:visited    { color: var(--link-vis); }

/* small is relative (0.85em) so it stays smaller than its surroundings even
   inside 0.875rem table cells; .muted keeps the absolute size for prose */
small  { color: var(--muted); font-size: 0.85em; }
.muted { color: var(--muted); font-size: 0.875rem; }

/* ── Infobox (Wikipedia-style, floated right) ── */

.infobox {
  float: right;
  clear: right;
  margin: 0 0 1rem 1.5rem;
  border: 1px solid var(--rule);
  border-collapse: collapse;
  font-size: 0.875rem;
  width: 22ch;
  background: #fafafa;
}

.infobox caption {
  font-weight: 600;
  padding: 0.4rem 0.5rem;
  background: #f0f0f0;
  border-bottom: 1px solid var(--rule);
  text-align: left;
}

.infobox td {
  padding: 0.3rem 0.5rem;
  vertical-align: top;
  border-bottom: 1px solid #ebebeb;
}

.infobox td:first-child {
  color: var(--muted);
  white-space: nowrap;
  width: 40%;
}

@media (max-width: 60ch) {
  .infobox { float: none; width: 100%; margin: 0 0 1rem; }
}

/* ── Tables ──
   Desktop: fit the page — text wraps inside cells, no horizontal overflow.
   Mobile (≤700px): cells stay on one line and the table scrolls
   horizontally instead of squishing (see media query below). */

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.875rem;
}
th    { text-align: left; padding: 0.45rem 1rem; border-bottom: 2px solid var(--ink); white-space: nowrap; }
td    { padding: 0.35rem 1rem; border-bottom: 1px solid var(--rule); }
tr:last-child td { border-bottom: none; }
tbody tr:nth-child(even) td { background: #f5f5f5; }
.num  { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ── Number veil (gate.js) ── */

.chart-redacted {
  border: 1px dashed var(--rule);
  border-radius: 6px;
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--muted);
  background: #fafafa;
  margin: 0.5rem 0 1rem;
}

.gate-bar {
  z-index: 10;
  border-radius: 6px;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: #052c65;
  color: #cfe2ff;
  font-size: 0.875rem;
}

.gate-bar a {
  padding: 0.2rem 0.9rem;
  border: 1px solid #9ec5fe;
  border-radius: 4px;
  color: #fff;
  text-decoration: none;
}
.gate-bar a:hover { background: #14417f; }

/* ── Interactive charts (lightweight-charts hydration) ── */

.tv-chart { position: relative; width: 100%; margin: 0.5rem 0 1rem; }
/* pan-y keeps one-finger page scroll; pinch is NOT ceded to browser page
   zoom, so two-finger gestures reach the chart (TradingView behavior) */
.tv-chart.tv-live { height: 340px; touch-action: pan-y; }
@media (max-width: 640px) { .tv-chart.tv-live { height: 260px; } }

/* ── Sortable headers + pager (tables.js) ── */

th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--link); }
th.sortable[data-dir="asc"]::after  { content: " ↑"; color: var(--muted); }
th.sortable[data-dir="desc"]::after { content: " ↓"; color: var(--muted); }

.table-pager {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin: 0.5rem 0 1rem;
  font-size: 0.8rem;
}

.table-pager button {
  font: inherit;
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: #fafafa;
  cursor: pointer;
}
.table-pager button:hover:not(:disabled) { border-color: var(--link); color: var(--link); }
.table-pager button:disabled { opacity: 0.45; cursor: default; }
.pager-info { color: var(--muted); font-variant-numeric: tabular-nums; }

/* ── Severity badges ── */

.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
}

.badge-critical { color: var(--critical); background: #fee2e2; }
.badge-high     { color: var(--high);     background: #fef3c7; }
.badge-medium   { color: var(--medium);   background: #e0f2fe; }
.badge-low      { color: var(--low);      background: #dcfce7; }

/* ── Confidence bar ── */

.conf-bar {
  display: inline-block;
  width: 5ch;
  height: 0.6rem;
  background: var(--rule);
  border-radius: 3px;
  overflow: hidden;
  vertical-align: middle;
}

.conf-bar-fill {
  height: 100%;
  background: var(--medium);
  border-radius: 3px;
}

/* ── Stats row (homepage) ── */

.stats {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
  border: 1px solid var(--rule);
  padding: 1rem;
  border-radius: 4px;
  margin-bottom: 1.5rem;
  background: #fafafa;
}

.stat { text-align: center; }
.stat-n { font-size: 1.5rem; font-weight: 700; display: block; }
.stat-l { font-size: 0.75rem; color: var(--muted); }

/* ── Details / accordion ── */

details { border: 1px solid var(--rule); border-radius: 3px; margin: 0.5rem 0; }
summary { cursor: pointer; padding: 0.4rem 0.75rem; font-size: 0.875rem; font-weight: 600; }
details > *:not(summary) { padding: 0 0.75rem 0.5rem; }

/* the generic details padding flattens the UA's list indent — restore a
   left margin so bullets sit inside the box instead of clipping */
details ul, details ol {
  padding-left: 2rem;
  margin: 0.25rem 0 0.5rem;
}
details li { margin-bottom: 0.25rem; }

/* ── What links here ── */

.backlinks { margin-top: 2rem; }
.backlinks ul { margin: 0; padding-left: 1.25rem; }
.backlinks li { margin-bottom: 0.25rem; font-size: 0.875rem; }

/* ── Provenance badges (how a finding was established) ── */

.badge-confirmed { color: var(--critical); background: #fee2e2; }
.badge-pattern   { color: var(--muted);    background: #f0f0f0; }
.badge-flagged   { color: var(--medium);   background: #e0f2fe; }

/* ── Legal citation block (violation pages) ── */

.citation {
  border-left: 3px solid var(--rule);
  padding: 0.5rem 0.75rem;
  margin: 0.75rem 0 1rem;
  background: #fafafa;
  font-size: 0.875rem;
}

/* ── Calendar ── */

tr.soon td { background: #fff7ed; }

/* ── Search page ── */

.search-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  margin-bottom: 1rem;
}

.search-status { font-size: 0.875rem; }
.search-results { margin: 0; padding-left: 0; list-style: none; }
.search-hit { margin-bottom: 0.75rem; }
.search-summary { font-size: 0.875rem; color: var(--muted); }

/* ── Footer ── */

footer {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  font-size: 0.8rem;
  color: var(--muted);
}

/* ── Mobile ── */

@media (max-width: 700px) {
  body { padding: 0 0.6rem; }
  .page { padding-top: 0.75rem; }
  h1 { font-size: 1.35rem; }
  h2 { font-size: 1.1rem; }
  nav { font-size: 0.8rem; line-height: 1.9; }
  .stats { gap: 1rem; padding: 0.75rem; }
  .stat-n { font-size: 1.15rem; }
  .infobox { float: none; width: 100%; margin: 0 0 1rem; }

  /* scroll, don't squish */
  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  td { white-space: nowrap; }
}
