/* peeringmap.com — hand-written, no framework.
   Cool, technical palette: near-white paper, slate text, a deep blue accent. */

:root {
  --bg: #f7f8fa;
  --bg-raised: #ffffff;
  --bg-sunk: #eef1f5;
  --border: #e2e6ec;
  --border-strong: #cdd3dc;
  --text: #141a24;
  --text-dim: #5c6675;
  --accent: #1d5fd1;
  --accent-deep: #124199;
  --accent-soft: #e4edfc;
  --link: #124199;
  --good: #1f7a3a;
  --bad: #b7342b;
  --radius: 10px;
  --radius-sm: 6px;
  --max-width: 76rem;
  --header-h: 3.5rem;
  --sidebar-w: 24rem;
  --shadow: 0 1px 2px rgba(20, 26, 36, 0.04), 0 6px 20px rgba(20, 26, 36, 0.05);
  --shadow-hover: 0 2px 4px rgba(20, 26, 36, 0.06), 0 10px 28px rgba(20, 26, 36, 0.09);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  display: flex;
  min-height: 100vh;
  flex-direction: column;
}

main { flex: 1; }

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.25rem;
  width: 100%;
}

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

h1, h2, h3 { letter-spacing: -0.02em; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.92em; }

.muted { color: var(--text-dim); }
.small { font-size: 0.85em; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 0.5rem 1rem;
  z-index: 100;
}
.skip-link:focus { left: 0; }

/* Header */

.site-header {
  height: var(--header-h);
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(8px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.header-inner {
  height: 100%;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.25rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.03em;
  color: var(--text);
  white-space: nowrap;
}
.brand-mark { width: 1.5rem; height: 1.5rem; color: var(--accent); }
.brand-accent { color: var(--accent); }

.site-search {
  position: relative;
  display: flex;
  align-items: stretch;
  flex: 1 1 20rem;
  max-width: 34rem;
  background: var(--bg-sunk);
  border: 1px solid transparent;
  border-radius: 999px;
  height: 2.25rem;
  overflow: visible;
}
.site-search:focus-within { background: #fff; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.site-search select {
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dim);
  padding: 0 0.4rem 0 0.9rem;
  cursor: pointer;
  border-right: 1px solid var(--border);
  border-radius: 999px 0 0 999px;
}
.site-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  font: inherit;
  padding: 0 0.6rem;
  color: var(--text);
}
.site-search input:focus, .site-search select:focus { outline: none; }
.site-search button {
  border: 0;
  background: transparent;
  color: var(--text-dim);
  padding: 0 0.8rem 0 0.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
}
.site-search button:hover { color: var(--accent); }

.suggest {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  right: 0;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-hover);
  list-style: none;
  margin: 0;
  padding: 0.3rem;
  z-index: 30;
  max-height: 60vh;
  overflow-y: auto;
}
.suggest[hidden] { display: none; }
.suggest li a {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.45rem 0.7rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text);
}
.suggest li a:hover, .suggest li[aria-selected="true"] a { background: var(--accent-soft); }
.suggest .s-type {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-deep);
  flex: 0 0 3.2rem;
}
.suggest .s-label { font-weight: 600; }
.suggest .s-sub { color: var(--text-dim); font-size: 0.85rem; margin-left: auto; white-space: nowrap; }

.site-nav {
  margin-left: auto;
  display: flex;
  gap: 0.15rem;
}
.site-nav a {
  text-decoration: none;
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  white-space: nowrap;
}
.site-nav a:hover { color: var(--text); background: var(--bg-sunk); }
.site-nav a[aria-current] { color: var(--accent-deep); background: var(--accent-soft); }

@media (max-width: 60rem) {
  .site-header { height: auto; }
  .header-inner { flex-wrap: wrap; padding: 0.55rem 1rem; row-gap: 0.5rem; }
  .brand { order: 1; }
  .site-nav { order: 2; margin-left: auto; }
  .site-search { order: 3; flex-basis: 100%; max-width: none; }
}
@media (max-width: 40rem) {
  .site-nav a { padding: 0.3rem 0.45rem; font-size: 0.82rem; }
}

/* Map layout: sidebar beside a full-height map */

.page-map main { display: flex; flex-direction: column; }

.map-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  height: calc(100vh - var(--header-h));
  min-height: 28rem;
}

.sidebar {
  overflow-y: auto;
  padding: 1.25rem 1.25rem 2rem;
  border-right: 1px solid var(--border);
  background: var(--bg-raised);
}

.map-col { position: relative; min-width: 0; }
.map-col #map { position: absolute; inset: 0; }

@media (max-width: 60rem) {
  .page-map .site-header { position: static; }
  .map-layout {
    /* minmax(0, …) so long unbreakable text cannot widen the page. */
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 45vh auto;
    height: auto;
  }
  .map-col { order: -1; height: 45vh; }
  .sidebar { border-right: 0; border-top: 1px solid var(--border); overflow: visible; min-width: 0; }
}

.sidebar-title {
  font-size: 1.45rem;
  margin: 0 0 0.35rem;
  line-height: 1.2;
  font-weight: 800;
}
.sidebar-sub { color: var(--text-dim); margin: 0 0 1rem; font-size: 0.92rem; }
.sidebar-h2 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin: 1.5rem 0 0.6rem;
  font-weight: 700;
}
.sidebar-more { margin: 0.6rem 0 0; font-size: 0.9rem; }

.crumbs { font-size: 0.82rem; color: var(--text-dim); margin-bottom: 0.75rem; display: flex; flex-wrap: wrap; gap: 0.35rem; }
.crumbs a { text-decoration: none; color: var(--text-dim); font-weight: 600; }
.crumbs a:hover { color: var(--accent); }
.crumb-sep { opacity: 0.6; }

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin: 1rem 0 0.5rem;
}
.stat {
  display: flex;
  flex-direction: column;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  text-decoration: none;
  color: var(--text-dim);
  font-size: 0.8rem;
}
.stat b { font-size: 1.35rem; color: var(--text); font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
a.stat:hover { border-color: var(--accent); background: var(--accent-soft); }

.chip-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  font-size: 0.85rem;
  text-decoration: none;
  color: var(--text);
}
.chip b { color: var(--text-dim); font-weight: 600; font-size: 0.78rem; }
.chip:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-deep); }

.result-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.result {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border);
  padding: 0.15rem 0;
}
.result:last-child { border-bottom: 0; }
.result-link {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 0.5rem 0.25rem;
  text-decoration: none;
  color: var(--text);
  border-radius: var(--radius-sm);
}
.result-link:hover { background: var(--bg-sunk); }
.result-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-sub { color: var(--text-dim); font-size: 0.82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-badge { font-size: 0.75rem; color: var(--text-dim); white-space: nowrap; font-variant-numeric: tabular-nums; }
.locate {
  border: 0;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0.35rem;
  border-radius: 999px;
  display: flex;
}
.locate:hover { color: var(--accent); background: var(--accent-soft); }

.empty {
  color: var(--text-dim);
  padding: 1.25rem 1rem;
  background: var(--bg);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  text-align: center;
  font-size: 0.92rem;
}

/* Map */

#map { width: 100%; height: 100%; background: var(--bg-sunk); }
/* Detail-page maps sit in a card; the id rule above would otherwise win. */
#map.mini-map { height: 14rem; }
#map.mini-map-tall { height: 18rem; }
.maplibregl-popup-content {
  font: inherit;
  font-size: 0.88rem;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-hover);
}
.maplibregl-popup-content b { display: block; font-size: 0.98rem; margin-bottom: 0.1rem; }
.maplibregl-popup-content .p-sub { color: var(--text-dim); display: block; }
.maplibregl-popup-content .p-link { display: inline-block; margin-top: 0.4rem; font-weight: 600; }
.maplibregl-popup-close-button { font-size: 1.2rem; padding: 0 0.4rem; }

/* Footer */

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-raised);
  color: var(--text-dim);
  font-size: 0.88rem;
  margin-top: auto;
}
.site-footer .container { padding-top: 1.1rem; padding-bottom: 1.1rem; }

/* Detail pages */

.detail { padding-top: 1.5rem; padding-bottom: 3rem; }

.detail-grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: 1fr;
}
@media (min-width: 56rem) {
  .detail-grid {
    grid-template-columns: minmax(0, 1fr) 20rem;
    gap: 2.5rem;
    align-items: start;
  }
}

.detail-main { min-width: 0; }
.kicker {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-deep);
  font-weight: 700;
  margin: 0 0 0.3rem;
}
.detail-header h1 { margin: 0 0 0.25rem; font-size: clamp(1.6rem, 4vw, 2.2rem); line-height: 1.15; }
.detail-org { margin: 0 0 0.35rem; color: var(--text-dim); font-size: 1.05rem; }
.detail-address { margin: 0 0 0.85rem; color: var(--text-dim); display: flex; flex-wrap: wrap; gap: 0.2rem 0.75rem; }

.pill-row { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.pill {
  display: inline-flex;
  gap: 0.3rem;
  align-items: baseline;
  background: var(--bg-sunk);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
  font-size: 0.82rem;
  color: var(--text-dim);
}
.pill b { color: var(--text); }
.pill-ok { background: #e7f5ec; border-color: #bfe2cb; color: var(--good); font-weight: 600; }

.notice {
  background: #fdf1ef;
  border: 1px solid #f1c9c4;
  color: var(--bad);
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  margin: 1.25rem 0;
}

.detail-section { margin: 1.75rem 0; }
.detail-section h2 { font-size: 1.1rem; margin: 0 0 0.6rem; }

.detail-side { display: flex; flex-direction: column; gap: 1rem; }
@media (min-width: 56rem) {
  .detail-side { position: sticky; top: calc(var(--header-h) + 1rem); }
}
.side-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.side-link {
  display: block;
  padding: 0.65rem 1rem;
  border-top: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.88rem;
  text-decoration: none;
}
.side-meta { padding: 0.25rem 0 0; }
.side-meta h3 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); margin: 0.75rem 1rem 0.25rem; }
.side-meta .notes { margin: 0 1rem 0.9rem; font-size: 0.88rem; color: var(--text-dim); white-space: pre-line; }
.meta-list { margin: 0; padding: 0.5rem 1rem 0.75rem; display: grid; grid-template-columns: 1fr; gap: 0.5rem 0; }
.meta-list dt { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); font-weight: 700; }
.meta-list dd { margin: 0 0 0.35rem; font-size: 0.92rem; overflow-wrap: anywhere; }

/* Tables */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-raised); }
.data-table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
.data-table th, .data-table td {
  text-align: left;
  padding: 0.55rem 0.85rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.data-table thead th {
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--bg);
  white-space: nowrap;
  position: sticky;
  top: 0;
}
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover td { background: #fbfcfe; }
.data-table td a { text-decoration: none; font-weight: 600; }
.data-table td a:hover { text-decoration: underline; }
.data-table td a.muted { font-weight: 400; }
.data-table td .small { display: block; }
.data-table.small { font-size: 0.85rem; }
.empty-cell { text-align: center; color: var(--text-dim); padding: 2rem !important; }
.sort { color: inherit; text-decoration: none; }
.sort:hover, .sort.active { color: var(--accent-deep); }

/* Listing pages */

.listing { padding-top: 1.5rem; padding-bottom: 3rem; }
.listing-header { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem 2rem; margin-bottom: 1rem; }
.listing-header h1 { margin: 0; font-size: 1.7rem; }
.listing-header .muted { flex-basis: 100%; margin: -0.5rem 0 0; }

.list-filter { display: flex; gap: 0.5rem; align-items: center; margin-left: auto; flex: 1 1 18rem; max-width: 30rem; }
.list-filter input {
  flex: 1;
  min-width: 0;
  font: inherit;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--bg-raised);
}
.list-filter input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.list-filter button {
  font: inherit;
  font-weight: 600;
  border: 0;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 0.45rem 1rem;
  cursor: pointer;
}
.list-filter button:hover { background: var(--accent-deep); }
.list-filter .clear { font-size: 0.88rem; white-space: nowrap; }

.pager { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.5rem 1rem; margin: 0.75rem 0; font-size: 0.88rem; color: var(--text-dim); }
.pager-links { display: flex; gap: 1rem; align-items: center; }
.pager-links a { font-weight: 600; text-decoration: none; }

.country-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 0.6rem;
}
.country-card {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.8rem 1rem;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow);
}
.country-card:hover { border-color: var(--accent); box-shadow: var(--shadow-hover); }
.country-name { font-weight: 700; }
.country-stats { color: var(--text-dim); font-size: 0.82rem; }

/* Prose pages */

.prose { max-width: 46rem; padding-top: 1.75rem; padding-bottom: 3rem; }
.prose h1 { margin-top: 0; }
.prose h2 { font-size: 1.2rem; margin-top: 1.75rem; }
.prose .table-wrap { margin-top: 0.75rem; }
