/* Extensions to landscape-shared.css for the rich landscape app:
   stat bar + always-on map + "Group by" toggle. No filter chips, no view
   toggle — the page has one knob ("Group by"), and the map is always
   visible at the top.

   Layout from top to bottom:
     title-row → subtitle → stat-bar → map → group-by → masonry → footer */

/* ---------- Map density legend ---------- */
.map-legend {
  position: absolute;
  top: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(6px);
  padding: 8px 10px;
  border-radius: 10px;
  box-shadow: 0 2px 6px rgba(15,23,42,0.06);
  z-index: 2;
}
[data-theme="dark"] .map-legend {
  background: rgba(15,33,71,0.8);
  color: rgba(255,255,255,0.8);
}
.map-legend-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.7;
  margin-bottom: 2px;
}
.map-legend-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.map-legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ---------- Map ---------- */
.map-container {
  position: relative;
  margin: 0 4px 18px;
  border-radius: 16px;
  padding: 14px;
  overflow: hidden;
}
[data-theme="light"] .map-container {
  background:
    radial-gradient(ellipse 70% 60% at 30% 0%, rgba(59,130,246,0.05), transparent 60%),
    radial-gradient(ellipse 60% 50% at 80% 100%, rgba(139,92,246,0.04), transparent 60%),
    #FFFFFF;
  border: 1px solid rgba(15,23,42,0.08);
  box-shadow: 0 1px 2px rgba(15,23,42,0.04), 0 8px 24px -8px rgba(15,23,42,0.10);
}
[data-theme="dark"] .map-container {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.10);
}
.map-svg { width: 100%; height: 380px; display: block; }
.city-dot { cursor: pointer; transition: stroke-width 0.15s ease; }
.city-dot:hover { stroke-width: 2.5px; }
.city-dot.dimmed { opacity: 0.18; }
.city-count {
  pointer-events: none;
  font-size: 10px;
  font-weight: 700;
  fill: #fff;
  text-anchor: middle;
  dominant-baseline: central;
  paint-order: stroke;
  stroke: rgba(15,23,42,0.35);
  stroke-width: 0.5px;
}
.city-count.dimmed { opacity: 0.18; }
.country {
  fill: #EEF2F8;
  stroke: #DDE3EC;
  stroke-width: 0.5;
}
[data-theme="dark"] .country {
  fill: rgba(255,255,255,0.05);
  stroke: rgba(255,255,255,0.08);
}
.map-glow { transition: opacity 0.2s ease; }
.map-dot {
  transition: r 0.18s ease, opacity 0.2s ease;
  cursor: pointer;
}
.map-dot.dimmed, .map-glow.dimmed { opacity: 0.12 !important; }

@keyframes dotPulse {
  0%, 100% { opacity: 0.7; }
  50%      { opacity: 1.0; }
}
.dot-pulse { animation: dotPulse 2.5s ease-in-out infinite; }

.map-tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(15,23,42,0.95);
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
  white-space: nowrap;
  box-shadow: 0 6px 18px rgba(0,0,0,0.25);
  opacity: 0;
  transform: translate(-50%, -110%);
  transition: opacity 0.12s ease;
  z-index: 10;
}
.map-tooltip::after {
  content: "";
  position: absolute;
  bottom: -4px;
  left: 50%;
  width: 8px;
  height: 8px;
  background: rgba(15,23,42,0.95);
  transform: translateX(-50%) rotate(45deg);
}
.map-tooltip strong { font-weight: 700; }
.map-tooltip .meta { opacity: 0.7; font-size: 11px; margin-top: 2px; font-weight: 400; }

/* ---------- Group-by pills ---------- */
.group-by-bar {
  display: inline-flex;
  margin: 0 12px 18px;
  padding: 4px;
  border-radius: 999px;
  gap: 2px;
}
[data-theme="light"] .group-by-bar {
  background: rgba(15,23,42,0.06);
  border: 1px solid rgba(15,23,42,0.06);
}
[data-theme="dark"] .group-by-bar {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
}
.group-by-btn {
  appearance: none;
  background: transparent;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 8px 16px;
  border-radius: 999px;
  transition: background 0.18s ease, color 0.18s ease;
  white-space: nowrap;
  flex-shrink: 0;
}
/* Mobile: tighten padding so 5 buttons fit in 360px viewport */
@media (max-width: 480px) {
  .group-by-bar {
    max-width: calc(100% - 24px);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .group-by-bar::-webkit-scrollbar { display: none; }
  .group-by-btn { padding: 7px 10px; font-size: 12px; }
}
.group-by-btn:hover { color: var(--text); }
[data-theme="light"] .group-by-btn.active {
  background: #FFFFFF;
  color: var(--text);
  box-shadow: 0 1px 3px rgba(15,23,42,0.10), 0 1px 2px rgba(15,23,42,0.06);
}
[data-theme="dark"] .group-by-btn.active {
  background: rgba(255,255,255,0.12);
  color: var(--text);
}

/* ---------- Treemap view ---------- */
.landscape-treemap {
  margin: 0 4px 18px;
  border-radius: 16px;
  padding: 14px;
}
[data-theme="light"] .landscape-treemap {
  background: #FFFFFF;
  border: 1px solid rgba(15,23,42,0.08);
  box-shadow: 0 1px 2px rgba(15,23,42,0.04), 0 8px 24px -8px rgba(15,23,42,0.10);
}
[data-theme="dark"] .landscape-treemap {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.10);
}
.treemap-surface {
  position: relative;
  width: 100%;
  min-height: 520px;
}
.tm-sec-bg, .tm-sec-hdr, .tm-child {
  position: absolute;
  overflow: hidden;
}
.tm-sec-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 10px;
  font-weight: 700;
}
.tm-sec-name {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 auto;
}
.tm-sec-stat {
  font-size: 12px;
  font-weight: 800;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.tm-sec-pct { opacity: 0.75; font-weight: 600; }
.tm-child {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4px 6px;
  border-radius: 4px;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
[data-theme="light"] .tm-child { background: #FFFFFF; }
[data-theme="dark"]  .tm-child { background: rgba(255,255,255,0.08); }
.tm-child:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(15,23,42,0.12);
  z-index: 5;
}
.tm-child-title {
  font-weight: 700;
  font-size: 12px;
  line-height: 1.2;
  letter-spacing: -0.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  margin-bottom: 2px;
}
.tm-child-count {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- Paywalled pills + demo CTA ---------- */
/* Wrapper so the tooltip can anchor to an absolutely-positioned peer
   without breaking the masonry pill flow. */
.pill-wrap {
  position: relative;
  display: inline-flex;
}
button.company-pill {
  appearance: none;
  font-family: inherit;
  cursor: default;
}
button.company-pill:focus-visible {
  outline: 2px solid var(--accent, #3B82F6);
  outline-offset: 2px;
}

/* Blurred pills — the logo fades to a muted placeholder, the name goes
   behind a CSS blur so the shape is visible but the word isn't. */
.company-pill.blurred {
  cursor: not-allowed;
  pointer-events: none;
  user-select: none;
}
.company-pill.blurred .pill-logo,
.company-pill.blurred .pill-initial {
  filter: grayscale(0.6) saturate(0.6);
  opacity: 0.55;
}
.company-pill.blurred .pill-name {
  filter: blur(4.5px);
  color: var(--text-muted);
  opacity: 0.9;
  letter-spacing: -0.01em;
}

/* Book-a-demo CTA that takes the place of "and N more". */
.book-demo-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1;
  padding: 7px 12px 7px 11px;
  border-radius: 999px;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  white-space: nowrap;
}
[data-theme="light"] .book-demo-btn {
  background: var(--text);
  color: var(--page-bg);
}
[data-theme="dark"] .book-demo-btn {
  background: #fff;
  color: #0F2147;
}
.book-demo-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(15,23,42,0.18);
}
.book-demo-btn svg { width: 12px; height: 12px; flex-shrink: 0; }

/* ---------- Company tooltip (hover reveals rich info) ---------- */
/* Uses position: fixed to escape .group-card overflow:hidden and CSS
   column clipping in masonry. Positioned by JS relative to viewport. */
.pill-tooltip {
  position: fixed;
  /* Park off-screen by default so hidden tooltips don't contribute to
     page scroll width (fixed-position elements can still extend the
     viewport scroll bounds). JS repositions on hover. */
  top: -9999px;
  left: -9999px;
  z-index: 10000;
  min-width: 240px;
  max-width: 320px;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.4;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.12s ease, visibility 0.12s;
  white-space: normal;
  text-align: left;
}
[data-theme="light"] .pill-tooltip {
  background: #FFFFFF;
  color: var(--text);
  border: 1px solid rgba(15,23,42,0.10);
  box-shadow: 0 10px 30px -8px rgba(15,23,42,0.25), 0 2px 6px rgba(15,23,42,0.06);
}
[data-theme="dark"] .pill-tooltip {
  background: #132A55;
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 12px 32px -8px rgba(0,0,0,0.5);
}
/* JS toggles .visible on mouseenter — position: fixed means it escapes
   any overflow: hidden ancestor. */
.pill-tooltip.visible {
  opacity: 1;
  visibility: visible;
}

.pill-tt-name { font-size: 14px; font-weight: 800; margin-bottom: 4px; letter-spacing: -0.01em; }
.pill-tt-tagline {
  font-size: 12.5px;
  font-weight: 400;
  color: var(--text-muted);
  margin-bottom: 10px;
  line-height: 1.4;
}
.pill-tt-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.pill-tt-row { display: flex; align-items: flex-start; gap: 6px; line-height: 1.35; }
.pill-tt-ico { flex-shrink: 0; width: 14px; text-align: center; font-size: 11px; }
.pill-tt-site {
  display: inline-block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent, #3B82F6);
  text-decoration: none;
  margin-top: 2px;
}
.pill-tt-site:hover { text-decoration: underline; }


/* ---------- Cross-highlight from map → cards ---------- */
.company-pill { transition: box-shadow 0.15s ease, transform 0.15s ease, border-color 0.15s ease; }
.company-pill.highlighted {
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--text);
  transform: translateY(-1px);
}
[data-theme="dark"] .company-pill.highlighted {
  border-color: #fff;
  box-shadow: 0 0 0 2px #fff;
}

/* Preview mode: when embedded in a small iframe (resources page thumbnails),
   hide excess pills to prevent the browser from choking on 1000+ elements.
   The iframe is 320% scaled to a 200px container, so effective height is ~640px. */
@media (max-height: 760px) {
  .map-container { display: none !important; }
  .group-by-bar { display: none !important; }
  .stat-bar { display: none !important; }
  .pills-wrap .company-pill:nth-child(n+9) { display: none !important; }
  .pills-wrap .more-btn { display: none !important; }
  .subgroup-card .pills-wrap .company-pill:nth-child(n+5) { display: none !important; }
  .group-card:nth-child(n+5) { content-visibility: hidden; height: 0; overflow: hidden; }
}
