/* ATLAS - Global Data Center Map
   Minimal black & white. Light + dark. */

:root {
  color-scheme: light;
  --bg:     #fff;
  --panel:  #fff;
  --sunk:   #f6f6f6;
  --text:   #111;
  --muted:  #767676;
  --line:   #e4e4e4;
  --ink:    #111;
  --on-ink: #fff;
  --shadow: 0 4px 24px rgba(0, 0, 0, .10);
  --r:      10px;
  --font:   ui-sans-serif, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* Robinson view - same palette as the Global ccTLD Map */
  --robinson-paper: #ffffff;
  --robinson-land:  #e4e4e4;
  --robinson-ink:   #000000;
}

/* Light is the default and does NOT follow the OS. Dark is opt-in only,
   via the Appearance button, so the site reads white on a dark-mode machine. */

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101010; --panel: #181818; --sunk: #1e1e1e;
  --text: #ededed; --muted: #909090; --line: #2a2a2a;
  --ink: #ededed; --on-ink: #101010;
  --shadow: 0 4px 24px rgba(0, 0, 0, .5);
}

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

body {
  margin: 0;
  /* Scrollable: the map is the hero at full height, with real content below
     it. The page used to be overflow:hidden with 157 visible words, which is
     thin for search and for ad review. */
  overflow-y: auto;
  overflow-x: hidden;
  font: 14px/1.55 var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ---------- shell ---------- */

#container { display: flex; flex-direction: column; height: 100vh; }

#header {
  flex: none;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}

#header h1 {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -.01em;
}

/* Acronym expansion: the bold letters spell ATLAS back. */
.wordmark {
  margin-left: 10px;
  font-weight: 400;
  font-size: 13px;
  color: var(--muted);
}

.wordmark b { font-weight: 600; color: var(--text); }

@media (max-width: 640px) { .wordmark { display: none; } }

.subtitle { margin: 0 0 12px; color: var(--muted); font-size: 13px; }

/* ---------- controls ---------- */

#controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.search-row { display: flex; flex: 1 1 340px; gap: 8px; }
.button-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.btn-group  { display: flex; gap: 6px; }
.btn-separator { display: none; }

input, select, button, .support-link {
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
}

#search { flex: 1; min-width: 0; }
#search::placeholder { color: var(--muted); }

/* These two fill with country and operator names, and a native select sizes
   itself to its longest option - which stretched the control bar right out.
   Cap them and let the label truncate. */
#country-filter, #company-filter {
  width: 132px;
  max-width: 132px;
  text-overflow: ellipsis;
}

button, select, .support-link {
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: background .12s, border-color .12s;
}

button:hover, select:hover, .support-link:hover { background: var(--sunk); }

input:focus, select:focus, button:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: -1px;
  border-color: var(--ink);
}

button[aria-pressed="true"], button.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--on-ink);
}

#menu-toggle { display: none; }

/* ---------- stats strip ---------- */

#stats {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.stat span {
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---------- map ---------- */

#map-container { position: relative; flex: 1; min-height: 0; }
#globe, #globe-3d, #robinson { position: absolute; inset: 0; background: var(--sunk); }
#globe-3d, #robinson { display: none; }

body.view-3d #globe    { visibility: hidden; }
body.view-3d #globe-3d { display: block; }

body.view-robinson #globe    { visibility: hidden; }
body.view-robinson #robinson { display: block; background: var(--bg); }

.robinson-tip {
  position: absolute;
  z-index: 1100;
  padding: 6px 9px;
  font-size: 12px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
  box-shadow: var(--shadow);
  pointer-events: none;
  white-space: nowrap;
}

#loading {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 900;
  padding: 12px 18px;
  color: var(--muted);
  background: var(--panel);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}

/* ---------- panels ---------- */

#results-panel, #info-panel, #radius-panel, #distance-panel,
#proximity-panel, #export-modal, #share-modal, #stats-dashboard, .legend {
  position: absolute;
  z-index: 1000;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  font-size: 13px;
}

#results-panel, #info-panel, #radius-panel, #distance-panel,
#proximity-panel, #export-modal, #share-modal, #stats-dashboard { display: none; }

#results-panel   { top: 16px;    left: 16px;  width: 320px; max-height: 62vh; overflow-y: auto; }
#info-panel      { bottom: 16px; left: 16px;  width: 320px; }
#radius-panel    { bottom: 16px; left: 16px;  width: 280px; }
#distance-panel  { bottom: 16px; right: 16px; width: 300px; }
#proximity-panel { top: 16px;    right: 16px; width: 300px; max-height: 62vh; overflow-y: auto; }

h3, .modal-title {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}

#info-panel p { margin: 0 0 6px; color: var(--muted); }
#info-panel p strong { color: var(--text); font-weight: 600; }

.panel-hint, .modal-sub, .panel-result { color: var(--muted); font-size: 12px; }
.panel-field { margin-bottom: 12px; }
.panel-label { display: block; margin-bottom: 6px; font-size: 12px; font-weight: 600; }
.panel-field input, .panel-field select { width: 100%; }

.panel-readout {
  padding: 12px;
  text-align: center;
  font-size: 17px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: var(--sunk);
  border-radius: 8px;
}

/* ---------- close button ---------- */

.close-btn, .stats-close-btn {
  position: absolute;
  top: 12px; right: 12px;
  width: 26px; height: 26px;
  display: grid;
  place-items: center;
  font-size: 17px;
  line-height: 1;
  color: var(--muted);
  background: none;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
}

.close-btn::before, .stats-close-btn::before { content: "\00d7"; }
.close-btn:hover, .stats-close-btn:hover { color: var(--text); background: var(--sunk); }

/* ---------- results list ---------- */

#results-list { display: flex; flex-direction: column; gap: 2px; }

.result-item { padding: 10px 12px; border-radius: 8px; cursor: pointer; }
.result-item:hover { background: var(--sunk); }
.result-name { display: block; font-weight: 600; }
.result-details { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }

/* ---------- modals ---------- */

#export-modal, #share-modal {
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2000;
  width: 320px;
  padding: 24px;
}

.modal-title, .modal-sub { text-align: center; }
.modal-actions { display: flex; flex-direction: column; gap: 8px; }
.modal-actions button { width: 100%; padding: 11px; }

/* ---------- stats dashboard ---------- */

#stats-dashboard {
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1900;
  width: min(880px, 92vw);
  max-height: 86vh;
  overflow-y: auto;
  padding: 28px;
}

#stats-dashboard h2 {
  margin: 0 0 24px;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -.01em;
}

.stats-section { margin-bottom: 32px; }
.stats-section:last-child { margin-bottom: 0; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.metric-item { padding: 18px; background: var(--sunk); border-radius: var(--r); }

.metric-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}

.metric-value {
  margin-top: 6px;
  font-size: 30px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.chart-container {
  height: 260px;
  padding: 16px;
  background: var(--sunk);
  border-radius: var(--r);
}

/* ---------- legend ---------- */

.legend { bottom: 16px; right: 16px; z-index: 900; padding: 14px; font-size: 12px; }
.legend-item { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.legend-item:last-child { margin-bottom: 0; }
.legend-color { width: 12px; height: 12px; flex: none; border-radius: 3px; }

/* ---------- leaflet ---------- */

.leaflet-control-attribution {
  font: 11px var(--font) !important;
  color: var(--muted) !important;
  background: var(--panel) !important;
}

.leaflet-control-attribution a { color: var(--muted) !important; }

.leaflet-bar a {
  color: var(--text) !important;
  background: var(--panel) !important;
  border-bottom-color: var(--line) !important;
}

.leaflet-bar a:hover { background: var(--sunk) !important; }

.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  color: var(--text);
  background: var(--panel);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}

.leaflet-popup-content { font: 13px/1.55 var(--font); }

.marker-cluster { background: none; }

.marker-cluster div {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  margin: 0 auto;
  font: 600 12px var(--font);
  font-variant-numeric: tabular-nums;
  color: var(--on-ink);
  background: var(--ink);
  border: 2px solid var(--panel);
  border-radius: 50%;
}

.marker-cluster-small  div { width: 30px; height: 30px; }
.marker-cluster-large  div { width: 40px; height: 40px; }
.marker-cluster-xlarge div { width: 48px; height: 48px; font-size: 13px; }

/* ---------- footer ---------- */

.privacy-footer { font-size: 11px; color: var(--muted); }
.privacy-footer a { color: var(--muted); }

/* ---------- responsive ---------- */

@media (max-width: 640px) {
  #header { padding: 12px 16px; }
  #menu-toggle { display: block; }

  .button-row {
    display: none;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }

  .button-row.open { display: flex; }
  .btn-group { flex-wrap: wrap; }
  .btn-group > * { flex: 1; min-width: 92px; }

  #results-panel, #info-panel, #radius-panel,
  #distance-panel, #proximity-panel {
    left: 12px; right: 12px; width: auto;
  }

  #stats-dashboard { width: 94vw; padding: 20px; }
  .metric-value { font-size: 24px; }
}

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

/* --------------------------------------------------------------------------
   Content section below the map.
   The page previously carried 157 visible words with everything else in
   script tags - thin for search and for ad review.
   -------------------------------------------------------------------------- */

.page {
  border-top: 1px solid var(--line);
  background: var(--bg);
}

.page-inner {
  max-width: 760px;
  margin: 0 auto;
  padding: 56px 24px 72px;
}

.page-inner h2 {
  margin: 44px 0 14px;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -.01em;
}

.page-inner h2:first-child { margin-top: 0; }

.page-inner h3 {
  margin: 26px 0 8px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text);
}

.page-inner p  { margin: 0 0 14px; font-size: 15px; line-height: 1.65; }
.page-inner ul { margin: 0 0 14px; padding-left: 20px; }
.page-inner li { margin-bottom: 10px; font-size: 15px; line-height: 1.65; }
.page-inner a  { color: var(--text); text-decoration: underline; text-underline-offset: 2px; }
.page-inner em { color: var(--muted); font-style: italic; }

.page-foot {
  margin-top: 44px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 640px) {
  .page-inner { padding: 36px 18px 52px; }
  .page-inner h2 { font-size: 18px; }
}
