:root {
  --status-ipv4-only-rgb: 255, 165, 0;
  --status-dual-stack-rgb: 0, 0, 255;
  --status-ipv6-only-rgb: 0, 128, 0;
  --color-ipv4-only: rgb(var(--status-ipv4-only-rgb));
  --color-dual: rgb(var(--status-dual-stack-rgb));
  --color-ipv6-only: rgb(var(--status-ipv6-only-rgb));
  --border-width: 6px;
}

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

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  line-height: 1.5;
  color: #111;
  background: #fafafa;
}

/* Client connection hint — orange IPv4, green IPv6, blue dual via JS class */
.border--ipv4 {
  border-top: var(--border-width) solid var(--color-ipv4-only);
}
.border--ipv6 {
  border-top: var(--border-width) solid var(--color-ipv6-only);
}
.border--dual {
  border-top: var(--border-width) solid var(--color-dual);
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem 1.25rem;
  padding: 1rem 1.25rem;
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
}

.site-header__lead {
  flex: 1 1 16rem;
  min-width: 0;
}

.site-header__conn {
  flex: 0 0 auto;
  align-self: flex-start;
}

.site-footer {
  padding: 1rem 1.25rem;
  background: #fff;
  border-top: 1px solid #e0e0e0;
  border-bottom: none;
  font-size: 0.9rem;
  color: #444;
}

h1 { font-size: 1.5rem; margin: 0.25rem 0; }
h2 { font-size: 1.15rem; margin-top: 1.5rem; }

.meta { font-size: 0.9rem; color: #555; margin: 0.25rem 0; }

.conn-status-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.35rem 0.65rem;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  color: inherit;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
}

.conn-status-btn:disabled {
  cursor: wait;
  opacity: 0.88;
}

.conn-status-btn:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

.conn-status-btn__swatch {
  width: 1rem;
  height: 1rem;
  border-radius: 3px;
  flex-shrink: 0;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: #94a3b8;
}

.conn-status-btn--ipv4 .conn-status-btn__swatch {
  background: var(--color-ipv4-only);
}

.conn-status-btn--ipv6 .conn-status-btn__swatch {
  background: var(--color-ipv6-only);
}

.conn-status-btn--dual .conn-status-btn__swatch {
  background: var(--color-dual);
}

.conn-status-dialog {
  padding: 0;
  border: none;
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  max-width: min(32rem, calc(100vw - 2rem));
}

.conn-status-dialog::backdrop {
  background: rgba(0, 0, 0, 0.35);
}

.conn-status-dialog__inner {
  padding: 1.25rem 1.35rem;
}

.conn-status-dialog__title {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
}

.conn-status-dialog__subtitle {
  margin: 0 0 0.75rem;
  color: #555;
  font-size: 0.95rem;
}

.conn-status-dialog__note {
  margin: 0 0 1rem;
  font-size: 0.82rem;
  color: #666;
  line-height: 1.45;
}

.conn-status-dialog__addrs {
  margin: 0 0 1.1rem;
}

.conn-status-dialog__row {
  display: grid;
  grid-template-columns: 4rem 1fr;
  gap: 0.35rem 0.75rem;
  margin-bottom: 0.5rem;
  font-size: 0.92rem;
}

.conn-status-dialog__row dt {
  font-weight: 600;
  margin: 0;
}

.conn-status-dialog__row dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
  word-break: break-all;
}

.conn-status-dialog__close {
  font: inherit;
  font-weight: 600;
  padding: 0.45rem 0.9rem;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  background: #fff;
  cursor: pointer;
}

.conn-status-dialog__close:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

.eez-map-wrap {
  margin-inline: auto;
  width: fit-content;
  max-width: 100%;
  border-radius: 6px;
  overflow: hidden;
  /* Same as ocean rect fill (#c6ecff) so letterboxing matches the map */
  background: #c6ecff;
  border: 1px solid #cfe0f0;
}
/* Sized from vw + vh so width does not collapse when .eez-map-wrap is width: fit-content
   (percentage bases can resolve too small). Height cap ~3× prior 520px / 70vh when space allows. */
.eez-map-wrap .eez-map-svg {
  display: block;
  margin-inline: auto;
  width: min(
    calc(100vw - 2.5rem),
    calc(min(1560px, 90vh) * 385 / 215)
  );
  height: auto;
  aspect-ratio: 385 / 215;
  max-height: min(1560px, 90vh);
}
.eez-map-wrap .eez-region--linked:focus {
  outline: 2px solid #0066cc;
  outline-offset: 0;
}
.eez-map-wrap .eez-region--linked:hover {
  filter: brightness(1.08);
}
.eez-map-wrap .eez-region--outside:hover {
  filter: none;
}
.eez-map-wrap .eez-iso-label {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-weight: 700;
  fill: #ffffff;
  stroke: #1a202c;
  stroke-width: 0.45px;
  paint-order: stroke fill;
}
.map-section { padding: 1rem 1.25rem; }
.notice { font-size: 0.85rem; color: #555; max-width: 70ch; }

/* Home: match .site-header / .map-section horizontal inset for heading + list */
.economies-section {
  padding: 0 1.25rem 2rem;
}

.economies-contrib {
  margin-top: 0.35rem;
  margin-bottom: 0.65rem;
  max-width: 70ch;
}

/* Country page: heading + table / empty state — same horizontal inset */
.country-detail-section {
  padding: 0 1.25rem 2rem;
}
.country-detail-section .empty-state {
  margin-left: 0;
  margin-right: 0;
}
.country-detail-section .table-wrap {
  padding-left: 0;
  padding-right: 0;
}

.country-detail-section .economies-contrib {
  margin-top: 1rem;
}
.country-legend-section {
  margin: 0 1.25rem 2rem;
  padding: 1rem 1.1rem;
  background: #fff;
  border: 1px solid #e8e8e8;
  border-radius: 8px;
}
.country-legend-section h2 {
  margin-top: 0;
}
.country-legend-intro {
  margin: 0 0 0.75rem;
  color: #333;
}
.legend-list {
  margin: 0.4rem 0 1rem;
  padding-left: 1.2rem;
}
.legend-list__item {
  margin: 0.3rem 0;
}
.legend-chip {
  display: inline-block;
  min-width: 6.2rem;
  margin-right: 0.35rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  font-weight: 600;
}
.legend-check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.7rem;
  margin-bottom: 1rem;
}
.legend-check-card {
  background: #fafafa;
  border: 1px solid #ececec;
  border-radius: 6px;
  padding: 0.7rem 0.8rem;
}
.legend-check-card h4 {
  margin: 0 0 0.45rem;
  font-size: 1rem;
}
.legend-check-card p {
  margin: 0.2rem 0;
}
.legend-check-card ul {
  margin: 0.4rem 0 0;
  padding-left: 1.1rem;
}

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

.economies-empty {
  margin: 0.5rem 0 0;
  color: #444;
}

.economies-table-wrap {
  overflow-x: auto;
  margin-top: 0.5rem;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
}

.economies-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.economies-table caption {
  padding: 0;
}

.economies-table th,
.economies-table td {
  padding: 0.5rem 0.65rem;
  border-bottom: 1px solid #eee;
  vertical-align: middle;
}

.economies-table thead th {
  background: #f9fafb;
  font-weight: 600;
  white-space: nowrap;
}

/* Deploy % / IPv6 pref. %: same red→green ramp as the map (see pct-color-ramp.js) */
.economies-table thead th.economies-th-pct {
  background-color: #f9fafb;
  background-image: linear-gradient(90deg, rgba(255, 0, 0, 0.14) 0%, rgba(143, 168, 34, 0.12) 50%, rgba(0, 255, 0, 0.12) 100%);
}

.economies-table td.economies-pct {
  font-weight: 600;
}

.economies-table tbody tr:last-child td {
  border-bottom: none;
}

.economies-table tbody tr:hover {
  background: #fafafa;
}

.economies-sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin: 0;
  padding: 0.15rem 0;
  font: inherit;
  font-weight: 600;
  color: inherit;
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: inherit;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
}

.economies-sort-btn:hover {
  color: #2563eb;
}

.economies-sort-btn:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

.economies-iso {
  color: #6b7280;
  font-size: 0.9em;
}

.economies-table .col-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.deploy-score-chip {
  font-size: 0.85rem;
  color: #374151;
}

.apnic-chip {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.1rem 0.45rem;
  background: #eef6ff;
  border-radius: 4px;
  font-size: 0.85rem;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: #fff;
  border: 1px solid #e8e8e8;
  border-radius: 8px;
  margin: 1rem 1.25rem;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.stat-label { font-size: 0.75rem; color: #555; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-value { font-size: 1.5rem; font-weight: 600; }
.stat-value--pct {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 6px;
}

.apnic-banner {
  margin: 0 1.25rem 1rem;
  padding: 0.75rem 1rem;
  background: #f0f7ff;
  border-radius: 6px;
  font-size: 0.95rem;
}

.table-wrap { overflow-x: auto; padding: 0 1.25rem 2rem; }

.results {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  background: #fff;
}
.results th, .results td {
  border: 1px solid #ddd;
  padding: 0.45rem 0.6rem;
  text-align: left;
  vertical-align: top;
}
.results thead { background: #f5f5f5; }

.results th.sortable {
  padding: 0;
  vertical-align: bottom;
}
.sort-trigger {
  width: 100%;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  margin: 0;
  padding: 0.45rem 0.6rem;
  border: 0;
  background: transparent;
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  color: inherit;
}
.sort-trigger:hover,
.sort-trigger:focus-visible {
  background: #eaeaea;
  outline: none;
}
.sort-trigger:focus-visible {
  box-shadow: inset 0 0 0 2px #0066cc;
}
.sort-indicator {
  flex-shrink: 0;
  font-size: 0.65rem;
  line-height: 1;
  opacity: 0.85;
  min-width: 0.75rem;
}

.results td.results__score {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
}

.cell--ipv4_only { background-color: rgba(var(--status-ipv4-only-rgb), 0.35); }
.cell--dual_stack { background-color: rgba(var(--status-dual-stack-rgb), 0.25); color: #111; }
.cell--ipv6_only { background-color: rgba(var(--status-ipv6-only-rgb), 0.35); }
.cell--unknown { background-color: #f0f0f0; }

.empty-state {
  padding: 1rem 1.25rem;
  background: #fff8e6;
  border: 1px solid #f0d090;
  border-radius: 6px;
  margin: 0 1.25rem;
}

.coming-soon-panel {
  margin: 1rem 1.25rem 2rem;
  padding: 1.25rem 1.5rem;
  background: #fff;
  border: 1px solid #e8e8e8;
  border-radius: 8px;
  max-width: 52ch;
}
.coming-soon-lead {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
  color: #333;
}
.coming-soon-body {
  margin: 0 0 1.25rem;
  color: #444;
  line-height: 1.55;
}
.coming-soon-actions {
  margin: 0;
}
.coming-soon-home {
  font-weight: 600;
}

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