/* Styles for the looking glass.
 *
 * The site is a reference tool: someone arrives with an AS number or an
 * address, and the faster the answer is legible the better the page is. That
 * pushes nearly every decision here towards density and away from decoration.
 * Data is set in a monospaced face at a size that stays readable in a long
 * table, prose is set in the system UI face, and colour is reserved for things
 * that carry meaning -- RPKI state, relationship direction, announce against
 * withdraw -- so that a coloured cell is always worth looking at.
 */

:root {
  /* Dark is the default rather than a preference: this kind of tool is read
   * in a terminal-shaped context, and the light theme below exists for people
   * who have asked their system for one. */
  --bg: #0b0f16;
  --bg-raised: #121824;
  --bg-inset: #0e131d;
  --panel: #131a27;
  --border: #222d40;
  --border-strong: #31405a;

  --text: #dde3ec;
  --text-dim: #8d9aae;
  --text-faint: #5f6b7d;

  --accent: #5aa9f8;
  --accent-dim: #2d6cb5;
  --accent-bg: rgba(90, 169, 248, 0.12);

  --green: #46c05f;
  --green-bg: rgba(70, 192, 95, 0.13);
  --red: #f4655c;
  --red-bg: rgba(244, 101, 92, 0.13);
  --amber: #e0a32e;
  --amber-bg: rgba(224, 163, 46, 0.13);
  --violet: #a983f5;
  --violet-bg: rgba(169, 131, 245, 0.13);

  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Menlo,
          Consolas, "Liberation Mono", monospace;
  --ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --radius: 7px;
  --radius-sm: 4px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px -12px rgba(0, 0, 0, 0.6);

  --wrap: 1440px;
  --gutter: 20px;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f5f7fa;
    --bg-raised: #ffffff;
    --bg-inset: #eef1f6;
    --panel: #ffffff;
    --border: #d8dee9;
    --border-strong: #b9c3d3;

    --text: #1a2231;
    --text-dim: #5b6779;
    --text-faint: #8b97a8;

    --accent: #1b62c4;
    --accent-dim: #4b8ada;
    --accent-bg: rgba(27, 98, 196, 0.09);

    --green: #1a7f37;
    --green-bg: rgba(26, 127, 55, 0.1);
    --red: #cf222e;
    --red-bg: rgba(207, 34, 46, 0.1);
    --amber: #9a6700;
    --amber-bg: rgba(154, 103, 0, 0.11);
    --violet: #6639ba;
    --violet-bg: rgba(102, 57, 186, 0.1);

    --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 8px 24px -14px rgba(16, 24, 40, 0.2);
  }
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--ui);
  font-size: 15px;
  line-height: 1.55;
  /* Long AS names and whois output would otherwise force a horizontal
   * scrollbar across the whole page. */
  overflow-wrap: break-word;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

h1, h2, h3 { line-height: 1.25; margin: 0; font-weight: 640; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.06rem; }
h3 { font-size: 0.95rem; }

p { margin: 0 0 0.75rem; }
p:last-child { margin-bottom: 0; }

.wrap {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 var(--gutter);
  /* Grid children default to min-content:auto, which lets a wide table push
   * the whole page wider than the viewport. This is the fix. */
  min-width: 0;
}

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

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--accent); color: #fff; padding: 10px 16px;
}
.skip:focus { left: 8px; top: 8px; }

/* ---------------------------------------------------------------- header */

.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-top: 11px;
  padding-bottom: 11px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 10px; color: var(--text); flex: none; }
.brand:hover { text-decoration: none; }
.brand-mark {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  background: var(--accent-bg);
  color: var(--accent);
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  line-height: 1;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-family: var(--mono); font-size: 0.95rem; letter-spacing: 0.02em; }
.brand-text span { font-size: 0.7rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.08em; }

.search {
  position: relative;
  display: flex;
  gap: 8px;
  flex: 1 1 340px;
  min-width: 0;
}
.search input {
  flex: 1 1 auto;
  min-width: 0;
  font-family: var(--mono);
  font-size: 0.86rem;
  padding: 9px 12px;
  color: var(--text);
  background: var(--bg-inset);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
}
.search input::placeholder { color: var(--text-faint); }
.search input:focus { border-color: var(--accent); }
.search button {
  flex: none;
  font-family: var(--ui);
  font-size: 0.85rem;
  font-weight: 560;
  padding: 9px 16px;
  color: #fff;
  background: var(--accent-dim);
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius);
  cursor: pointer;
}
.search button:hover { background: var(--accent); border-color: var(--accent); }

.suggestions {
  position: absolute;
  top: calc(100% + 6px); left: 0; right: 0;
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  z-index: 60;
  max-height: 60vh;
  overflow-y: auto;
}
.suggestions[hidden] { display: none; }
.suggestion {
  display: flex; align-items: baseline; gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
}
.suggestion:last-child { border-bottom: 0; }
.suggestion:hover, .suggestion.active { background: var(--accent-bg); text-decoration: none; }
.suggestion .s-label { font-family: var(--mono); font-size: 0.84rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.suggestion .s-detail { font-size: 0.76rem; color: var(--text-dim); margin-left: auto; white-space: nowrap; }

.nav-toggle {
  display: none;
  flex: none;
  width: 38px; height: 34px;
  background: var(--bg-inset);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  cursor: pointer;
  position: relative;
}
.nav-toggle .bars,
.nav-toggle .bars::before,
.nav-toggle .bars::after {
  position: absolute; left: 50%; transform: translateX(-50%);
  width: 16px; height: 2px; background: var(--text); border-radius: 2px;
}
.nav-toggle .bars { top: 50%; margin-top: -1px; }
.nav-toggle .bars::before { content: ""; top: -5px; }
.nav-toggle .bars::after { content: ""; top: 5px; }

.site-nav { display: flex; gap: 4px; flex: none; }
.site-nav a {
  font-size: 0.85rem;
  padding: 7px 11px;
  border-radius: var(--radius);
  color: var(--text-dim);
}
.site-nav a:hover { color: var(--text); background: var(--bg-raised); text-decoration: none; }
.site-nav a.active { color: var(--accent); background: var(--accent-bg); }

/* ------------------------------------------------------------------ main */

main { padding: 24px 0 56px; }

.page-head { margin-bottom: 20px; }
.page-head h1 { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-head .lede { color: var(--text-dim); margin-top: 6px; font-size: 0.92rem; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 18px;
  overflow: hidden;
}
.panel-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-raised);
  flex-wrap: wrap;
}
.panel-head h2 { font-size: 0.95rem; }
.panel-head .subtitle { font-size: 0.8rem; color: var(--text-dim); margin: 3px 0 0; }
.panel-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.panel > .empty { padding: 22px 16px; color: var(--text-dim); text-align: center; margin: 0; }
.panel-body { padding: 16px; }

/* ---------------------------------------------------------------- tables */

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
thead th {
  position: sticky; top: 0;
  text-align: left;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  color: var(--text-dim);
  background: var(--bg-raised);
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td { padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--bg-raised); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); white-space: nowrap; }
td.nowrap, th.nowrap { white-space: nowrap; }

.mono, td .mono { font-family: var(--mono); font-size: 0.83rem; }
a.as { font-family: var(--mono); font-size: 0.83rem; white-space: nowrap; }
.dim { color: var(--text-faint); }
.cc { white-space: nowrap; font-size: 0.8rem; color: var(--text-dim); }

/* ----------------------------------------------------------- definitions */

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 1px;
  /* Separators are drawn by each cell, not by showing a background through the
   * gaps: a row whose last cells are empty would otherwise render them as
   * stray coloured blocks. */
  background: transparent;
}
.fact {
  background: var(--panel);
  box-shadow: 0 0 0 1px var(--border);
  padding: 12px 16px;
  min-width: 0;
}
.fact dt {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-dim); margin-bottom: 4px;
}
.fact dd { margin: 0; font-family: var(--mono); font-size: 0.88rem; word-break: break-word; }
.fact dd.plain { font-family: var(--ui); }

/* --------------------------------------------------------------- numbers */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  min-width: 0;
}
.stat .label {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-dim);
}
.stat .value {
  font-family: var(--mono); font-size: 1.5rem; font-weight: 600;
  margin-top: 4px; font-variant-numeric: tabular-nums; line-height: 1.1;
}
.stat .note { font-size: 0.76rem; color: var(--text-faint); margin-top: 3px; }
.stat.v4 .value { color: var(--accent); }
.stat.v6 .value { color: var(--violet); }
.stat.good .value { color: var(--green); }
.stat.bad .value { color: var(--red); }

/* --------------------------------------------------------------- badges */

.badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
  line-height: 1.5;
}
.rpki-valid { color: var(--green); background: var(--green-bg); border-color: var(--green); }
.rpki-invalid { color: var(--red); background: var(--red-bg); border-color: var(--red); }
.rpki-unknown { color: var(--text-dim); background: var(--bg-inset); border-color: var(--border-strong); }
.badge.v4 { color: var(--accent); background: var(--accent-bg); border-color: var(--accent-dim); }
.badge.v6 { color: var(--violet); background: var(--violet-bg); border-color: var(--violet); }
.badge.kind-upstream { color: var(--amber); background: var(--amber-bg); border-color: var(--amber); }
.badge.kind-peer { color: var(--accent); background: var(--accent-bg); border-color: var(--accent-dim); }
.badge.kind-downstream { color: var(--green); background: var(--green-bg); border-color: var(--green); }
.badge.inferred { color: var(--text-dim); background: var(--bg-inset); border-color: var(--border-strong); }
.badge.announce { color: var(--green); background: var(--green-bg); border-color: var(--green); }
.badge.withdraw { color: var(--red); background: var(--red-bg); border-color: var(--red); }
.badge.new_prefix { color: var(--accent); background: var(--accent-bg); border-color: var(--accent-dim); }
.badge.origin_change { color: var(--amber); background: var(--amber-bg); border-color: var(--amber); }
.badge.ok { color: var(--green); background: var(--green-bg); border-color: var(--green); }
.badge.error { color: var(--red); background: var(--red-bg); border-color: var(--red); }
.badge.running { color: var(--amber); background: var(--amber-bg); border-color: var(--amber); }

/* ----------------------------------------------------------- AS path */

.path { display: inline-flex; flex-wrap: wrap; gap: 3px; align-items: center; font-family: var(--mono); font-size: 0.78rem; }
.path .hop {
  background: var(--bg-inset);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 1px 5px;
  color: var(--text-dim);
}
.path .hop:hover { color: var(--accent); border-color: var(--accent-dim); text-decoration: none; }
.path .hop.origin { color: var(--text); border-color: var(--accent-dim); background: var(--accent-bg); font-weight: 600; }

/* --------------------------------------------------------------- tabs */

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tabs a, .tabs button {
  font-family: var(--ui);
  font-size: 0.85rem;
  padding: 9px 14px;
  color: var(--text-dim);
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
}
.tabs a:hover, .tabs button:hover { color: var(--text); text-decoration: none; }
.tabs a.active, .tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }

/* --------------------------------------------------------------- charts */

.chart { width: 100%; height: auto; display: block; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .axis-label { fill: var(--text-faint); font-size: 10px; font-family: var(--mono); }
.chart .series-v4 { stroke: var(--accent); fill: none; stroke-width: 2; }
.chart .series-v6 { stroke: var(--violet); fill: none; stroke-width: 2; }
.chart .area-v4 { fill: var(--accent-bg); stroke: none; }
.chart .bar { fill: var(--accent); }
.chart .bar-v6 { fill: var(--violet); }
.legend { display: flex; gap: 16px; font-size: 0.78rem; color: var(--text-dim); padding: 0 16px 14px; flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 11px; height: 3px; border-radius: 2px; display: inline-block; }

/* ------------------------------------------------------------- coverage */

.bar-track {
  display: flex; height: 8px; border-radius: 999px; overflow: hidden;
  background: var(--bg-inset); margin: 8px 0 6px;
}
.bar-track i { display: block; height: 100%; }
.bar-track .b-valid { background: var(--green); }
.bar-track .b-invalid { background: var(--red); }
.bar-track .b-unknown { background: var(--border-strong); }
.bar-key { display: flex; gap: 14px; font-size: 0.76rem; color: var(--text-dim); flex-wrap: wrap; }
.bar-key span { display: inline-flex; align-items: center; gap: 5px; }
.bar-key i { width: 9px; height: 9px; border-radius: 2px; }

/* ------------------------------------------------------------------ pre */

pre.whois, pre.code {
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.5;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 15px;
  margin: 0;
  overflow-x: auto;
  white-space: pre;
  color: var(--text-dim);
  max-height: 560px;
}

code.inline {
  font-family: var(--mono); font-size: 0.82rem;
  background: var(--bg-inset); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 1px 5px;
}

/* ---------------------------------------------------------------- misc */

.notice {
  padding: 11px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--bg-inset);
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 16px;
}
.notice.warn { border-color: var(--amber); background: var(--amber-bg); color: var(--text); }
.notice.bad { border-color: var(--red); background: var(--red-bg); color: var(--text); }

.pager { display: flex; gap: 8px; align-items: center; justify-content: center; padding: 13px; flex-wrap: wrap; }
.pager a, .pager span {
  font-size: 0.82rem; padding: 6px 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  color: var(--text-dim);
}
.pager a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.pager .current { background: var(--accent-bg); color: var(--accent); border-color: var(--accent-dim); }

.cols-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 18px; align-items: start; }
.cols-2 > * { min-width: 0; }

.hero { text-align: center; padding: 40px 0 28px; }
.hero h1 { font-size: 1.9rem; }
.hero p { color: var(--text-dim); max-width: 660px; margin: 10px auto 0; }
.hero-search { max-width: 640px; margin: 22px auto 0; }
.examples { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 14px; font-size: 0.82rem; }
.examples a {
  font-family: var(--mono); font-size: 0.78rem;
  padding: 4px 10px; border: 1px solid var(--border-strong);
  border-radius: 999px; color: var(--text-dim);
}
.examples a:hover { color: var(--accent); border-color: var(--accent-dim); text-decoration: none; }

.feed { font-family: var(--mono); font-size: 0.8rem; max-height: 620px; overflow-y: auto; }
.feed-row { display: flex; gap: 10px; padding: 5px 16px; border-bottom: 1px solid var(--border); align-items: baseline; }
.feed-row:hover { background: var(--bg-raised); }
.feed-row .t { color: var(--text-faint); flex: none; font-size: 0.74rem; }
.feed-row .p { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-row .o { flex: none; color: var(--text-dim); }

.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); margin-right: 6px; }
.live-dot.on { background: var(--green); box-shadow: 0 0 0 3px var(--green-bg); }
.live-dot.off { background: var(--red); box-shadow: 0 0 0 3px var(--red-bg); }

.site-footer { border-top: 1px solid var(--border); padding: 22px 0 36px; font-size: 0.82rem; color: var(--text-dim); }
.site-footer p { margin-bottom: 8px; }

/* --------------------------------------------------------- narrow screens */

@media (max-width: 900px) {
  .header-inner { gap: 10px; }
  .search { order: 3; flex-basis: 100%; }
  .nav-toggle { display: block; margin-left: auto; }
  .site-nav {
    order: 4; flex-basis: 100%;
    flex-direction: column; gap: 2px;
    display: none;
    padding-bottom: 6px;
  }
  .site-nav.open { display: flex; }
}

@media (max-width: 640px) {
  :root { --gutter: 14px; }
  body { font-size: 14px; }
  main { padding: 16px 0 40px; }
  .hero { padding: 24px 0 18px; }
  .hero h1 { font-size: 1.45rem; }
  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
  .stat .value { font-size: 1.25rem; }
  .facts { grid-template-columns: 1fr 1fr; }
  table { font-size: 0.8rem; }
  thead th, tbody td { padding: 7px 9px; }
  .panel-head { padding: 11px 13px; }
}

@media (max-width: 420px) {
  .facts { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
