/* =========================================================
   GOPA – Global reach (interactive world map)
   D3-rendered SVG world atlas with brand-styled markers,
   filters and side panel.
   ========================================================= */

:root {
  /* The map's own palette (dark, on top of the existing brand tokens) */
  --reach-bg:        #081A24;        /* matches --com-dark-black so wave-tops meet seamlessly */
  --reach-bg-elev:   #0c1f2c;
  --reach-line:      rgba(255,255,255,0.06);
  --reach-line-strong: rgba(255,255,255,0.14);
  --reach-text:      #f7f8f9;
  --reach-text-muted: rgba(255,255,255,0.62);
  --reach-text-dim:   rgba(255,255,255,0.40);
  --reach-country:    #1a2c39;       /* inactive country fill */
  --reach-country-hover: #2a3e4d;
  --reach-country-active: #3a4f60;   /* GOPA-active country */
  --reach-marker:     var(--gopa-yellow);
  --reach-marker-hq:  #FFE066;       /* slightly brighter for HQ */
}

.reach-body {
  background: var(--reach-bg);
  color: var(--reach-text);
  margin: 0;
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

/* ---------- Header ---------- */
.reach-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 32px;
  border-bottom: 1px solid var(--reach-line);
  background: var(--reach-bg);
  position: sticky;
  top: 0;
  z-index: 20;
}
.reach-header__logo img { height: 28px; display: block; }
.reach-header__back {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--reach-text-muted);
  text-decoration: none;
  transition: color 120ms;
}
.reach-header__back:hover { color: var(--gopa-yellow); }

/* ---------- Layout ---------- */
.reach {
  padding: 32px 0 64px;
  background: var(--reach-bg);
  color: var(--reach-text);
}
@media (min-width: 900px) { .reach { padding: 56px 0 96px; } }
.reach__container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 24px;
}
@media (min-width: 768px) { .reach__container { padding: 0 48px; } }

/* ---------- Intro ---------- */
.reach__intro {
  max-width: 880px;
  margin: 0 0 32px;
}
.reach__intro .eyebrow {
  color: var(--gopa-yellow);
  margin: 0 0 16px;
}
.reach__intro h1 {
  font-family: var(--font-display);
  font-size: clamp(36px, 5vw, 64px);
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin: 0 0 16px;
  color: #fff;
}
.reach__intro h1 em {
  font-weight: 300;
  font-style: italic;
  color: var(--gopa-yellow);
}
.reach__intro .lead {
  font-size: clamp(15px, 1.2vw, 18px);
  line-height: 1.55;
  color: var(--reach-text-muted);
  font-weight: 300;
  margin: 0;
  max-width: 64ch;
}

/* ---------- Filters – compact single-bar layout ---------- */
.reach__filters {
  border: 1px solid var(--reach-line);
  border-radius: 999px;
  padding: 6px 8px;
  background: rgba(255,255,255,0.025);
  margin-bottom: 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  position: relative;
  z-index: 5;
}
@media (max-width: 768px) {
  .reach__filters {
    border-radius: 16px;
    padding: 10px;
    gap: 8px;
  }
}

.filter-bar__item {
  display: inline-flex;
  align-items: center;
}
.filter-bar__item[hidden] { display: none; }
.filter-bar__item--grow {
  flex: 1 1 220px;
  min-width: 200px;
}

.filter-row__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 1px solid var(--reach-line-strong);
  color: var(--reach-text-muted);
  padding: 7px 14px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background 140ms, color 140ms, border-color 140ms;
  white-space: nowrap;
}
.chip:hover { color: #fff; border-color: rgba(255,255,255,0.30); }
.chip:focus-visible {
  outline: 2px solid var(--gopa-yellow);
  outline-offset: 2px;
}
.chip.is-active {
  background: var(--gopa-yellow);
  color: var(--com-dark-black);
  border-color: var(--gopa-yellow);
}
.chip__count {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  color: var(--reach-text-muted);
}
.chip.is-active .chip__count {
  background: rgba(0,0,0,0.16);
  color: var(--com-dark-black);
}
.chip.is-disabled {
  opacity: 0.32;
  pointer-events: none;
}

/* Dropdown buttons (used for Region and Sector) */
.filter-dropdown { position: relative; }
.filter-dropdown__btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid var(--reach-line-strong);
  color: var(--reach-text-muted);
  padding: 7px 14px;
  border-radius: 999px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 120ms, color 120ms, border-color 120ms;
}
.filter-dropdown__btn:hover { color: #fff; border-color: rgba(255,255,255,0.30); }
.filter-dropdown__btn:focus-visible { outline: 2px solid var(--gopa-yellow); outline-offset: 2px; }
.filter-dropdown__label { color: var(--reach-text-dim); }
.filter-dropdown__value { color: #fff; font-weight: 700; }
.filter-dropdown__chevron {
  width: 10px; height: 7px;
  transition: transform 180ms;
  margin-left: 2px;
  color: var(--reach-text-dim);
}
.filter-dropdown.is-open .filter-dropdown__btn {
  background: var(--gopa-yellow);
  color: var(--com-dark-black);
  border-color: var(--gopa-yellow);
}
.filter-dropdown.is-open .filter-dropdown__label,
.filter-dropdown.is-open .filter-dropdown__value,
.filter-dropdown.is-open .filter-dropdown__chevron { color: var(--com-dark-black); }
.filter-dropdown.is-open .filter-dropdown__chevron { transform: rotate(180deg); }
/* When a non-default value is selected, give the button a subtle active style */
.filter-dropdown.has-value:not(.is-open) .filter-dropdown__btn {
  border-color: var(--gopa-yellow);
  color: #fff;
}
.filter-dropdown.has-value:not(.is-open) .filter-dropdown__value { color: var(--gopa-yellow); }

/* Popover panel */
.filter-dropdown__popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 30;
  min-width: 320px;
  max-width: 560px;
  max-height: 60vh;
  overflow-y: auto;
  padding: 14px;
  background: var(--reach-bg-elev);
  border: 1px solid var(--reach-line-strong);
  border-radius: 12px;
  box-shadow: 0 18px 40px rgba(0,0,0,0.45);
  animation: popover-in 140ms cubic-bezier(0.2, 0, 0, 1);
}
@keyframes popover-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (max-width: 600px) {
  .filter-dropdown__popover {
    left: 0;
    right: 0;
    min-width: 0;
    max-width: none;
    width: calc(100vw - 48px);
  }
}

/* Search input */
.reach__search {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: 1 1 220px;
}
.reach__search__icon {
  position: absolute;
  left: 12px;
  width: 14px;
  height: 14px;
  color: var(--reach-text-dim);
  pointer-events: none;
}
.reach__search input {
  font: inherit;
  font-size: 13px;
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  color: var(--reach-text);
  padding: 7px 14px 7px 32px;
  border-radius: 999px;
  outline: none;
  transition: border-color 120ms, background 120ms;
}
.reach__search input::placeholder { color: var(--reach-text-dim); }
.reach__search input:focus {
  border-color: var(--reach-line-strong);
  background: rgba(255,255,255,0.05);
}

/* Count badge */
.reach__count {
  font-size: 13px;
  color: var(--reach-text-muted);
  margin: 0 8px 0 0;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.reach__count strong {
  color: #fff;
  font-weight: 800;
}

/* Reset button – only shown when filters are active */
.reach__reset {
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  background: transparent;
  border: 1px solid var(--reach-line-strong);
  color: var(--reach-text-muted);
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: color 120ms, border-color 120ms, background 120ms;
}
.reach__reset:hover { color: var(--com-dark-black); background: var(--gopa-yellow); border-color: var(--gopa-yellow); }
.reach__reset:focus-visible { outline: 2px solid var(--gopa-yellow); outline-offset: 2px; }

/* ---------- Map + side panel ---------- */
.reach__main {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}
@media (min-width: 1024px) {
  .reach__main { grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; }
}

.reach__map {
  position: relative;
  background: var(--reach-bg-elev);
  border: 1px solid var(--reach-line);
  border-radius: 16px;
  overflow: hidden;
  /* Without an explicit width, aspect-ratio + min-height resolve the
     WIDTH from the height (480px × 2/1 = 960px) once the grid track is
     narrower than that – on 1024–1440px viewports the map then paints
     over the side panel. width: 100% pins the width to the grid area
     so the ratio only ever derives the height. */
  width: 100%;
  min-width: 0;
  /* Mobile-first: taller, room for thumbs. Wider on bigger screens. */
  aspect-ratio: 4 / 5;
  min-height: 460px;
}
@media (min-width: 600px) { .reach__map { aspect-ratio: 3 / 2; min-height: 360px; } }
@media (min-width: 1024px) { .reach__map { aspect-ratio: 2 / 1; min-height: 480px; } }

.reach__map svg {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
}
.reach__map svg:active { cursor: grabbing; }

/* Country shapes */
.country {
  fill: var(--reach-country);
  stroke: var(--reach-bg);
  stroke-width: 0.4;
  stroke-linejoin: round;
  transition: fill 180ms;
}
.country.is-active { fill: var(--reach-country-active); }
.country.is-hover  { fill: var(--reach-country-hover); }
.country.is-out    { fill: var(--reach-country); opacity: 0.4; }

/* Graticule (subtle latitude/longitude lines) */
.graticule {
  fill: none;
  stroke: rgba(255,255,255,0.03);
  stroke-width: 0.5;
}

/* Office markers – drawn as SVG groups by D3 */
.marker {
  cursor: pointer;
  transition: opacity 200ms;
}
.marker__halo {
  fill: var(--reach-marker);
  fill-opacity: 0.18;
  transform-origin: center;
  transform-box: fill-box;
  animation: marker-halo 3.6s ease-in-out infinite;
}
@keyframes marker-halo {
  0%,100% { transform: scale(1.0); fill-opacity: 0.18; }
  50%     { transform: scale(1.5); fill-opacity: 0.05; }
}
.marker__dot {
  fill: var(--reach-marker);
  stroke: var(--com-dark-black);
  stroke-width: 1.5;
  transition: r 180ms, fill 180ms;
}
.marker--hq .marker__dot {
  fill: var(--reach-marker-hq);
  stroke-width: 2;
}
.marker.is-out {
  opacity: 0.18;
  pointer-events: none;
}
.marker.is-out .marker__halo { animation: none; }
.marker:hover .marker__dot,
.marker:focus .marker__dot,
.marker.is-selected .marker__dot {
  r: 8;
  fill: #fff;
}
.marker--hq:hover .marker__dot,
.marker--hq:focus .marker__dot,
.marker--hq.is-selected .marker__dot {
  r: 10;
}
@media (prefers-reduced-motion: reduce) {
  .marker__halo { animation: none; }
}

/* Zoom controls (drawn as HTML overlay on the map container) */
.zoom-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 2;
}
.zoom-controls button {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid var(--reach-line-strong);
  background: rgba(8,26,36,0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 120ms, border-color 120ms;
}
.zoom-controls button:hover {
  background: rgba(252,194,0,0.15);
  border-color: var(--gopa-yellow);
}
.zoom-controls button:focus-visible {
  outline: 2px solid var(--gopa-yellow);
  outline-offset: 2px;
}

/* The legend pinned to the bottom-left of the map */
.legend {
  position: absolute;
  bottom: 12px;
  left: 12px;
  display: flex;
  gap: 16px;
  z-index: 2;
  background: rgba(8,26,36,0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--reach-line-strong);
}
.legend__item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--reach-text-muted);
  font-weight: 600;
}
.legend__dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--reach-marker);
  display: inline-block;
}
.legend__dot--hq {
  background: var(--reach-marker-hq);
  width: 12px;
  height: 12px;
  box-shadow: 0 0 0 2px rgba(255,224,102,0.25);
}

/* ---------- Side panel ---------- */
.reach__panel {
  background: var(--reach-bg-elev);
  border: 1px solid var(--reach-line);
  border-radius: 16px;
  padding: 24px;
  min-height: 320px;
  outline: none;
}
@media (min-width: 1024px) { .reach__panel { padding: 28px; } }

.panel-card { display: flex; flex-direction: column; gap: 14px; }

.panel-card__eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gopa-yellow);
  margin: 0;
}

.panel-card__title {
  font-family: var(--font-display);
  font-size: clamp(22px, 2.4vw, 30px);
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: -0.01em;
  color: #fff;
  margin: 0;
}
.panel-card__title em { font-weight: 300; font-style: italic; color: var(--gopa-yellow); }

.panel-card__stats {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px 12px;
}
.panel-card__stats li { display: flex; flex-direction: column; }
.panel-card__stats strong {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 900;
  line-height: 1;
  color: #fff;
}
.panel-card__stats strong em { color: var(--gopa-yellow); font-style: normal; }
.panel-card__stats span {
  font-size: 11px;
  color: var(--reach-text-muted);
  margin-top: 4px;
}

.panel-card__hint {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--reach-text-dim);
  font-style: italic;
  font-weight: 300;
}

/* Office card (replaces summary on hover/click) */
.panel-card--office .panel-card__brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
}
.panel-card__badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid currentColor;
}
.panel-card__badge--hq {
  color: var(--gopa-yellow);
  background: rgba(252,194,0,0.10);
  border-color: rgba(252,194,0,0.55);
}
.panel-card__badge--country {
  color: var(--reach-text-muted);
  border-color: var(--reach-line-strong);
}
.panel-card__badge--brand-tech { color: var(--tech-sky); border-color: rgba(130,161,202,0.5); }
.panel-card__badge--brand-pro  { color: var(--pro-mint); border-color: rgba(84,162,114,0.5); }
.panel-card__badge--brand-com  { color: #fff;          border-color: rgba(255,255,255,0.4); }

.panel-card__city {
  font-family: var(--font-display);
  font-size: clamp(24px, 2.6vw, 32px);
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: -0.01em;
  margin: 0;
  color: #fff;
}
.panel-card__country {
  font-size: 14px;
  font-weight: 600;
  color: var(--reach-text-muted);
  letter-spacing: 0.04em;
  margin: 4px 0 0;
}
.panel-card__address {
  font-size: 14px;
  line-height: 1.55;
  color: var(--reach-text-muted);
  margin: 0;
}

.panel-card__sectors {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.panel-card__sector {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--reach-line);
  color: var(--reach-text-muted);
}

.panel-card__divider {
  height: 1px;
  background: var(--reach-line);
  border: 0;
  margin: 4px 0;
}

.panel-card__cta {
  display: inline-flex;
  align-self: flex-start;
  align-items: center;
  gap: 8px;
  background: var(--gopa-yellow);
  color: var(--com-dark-black);
  font-size: 14px;
  font-weight: 800;
  padding: 10px 20px;
  border-radius: 999px;
  text-decoration: none;
  transition: background 120ms, transform 120ms;
}
.panel-card__cta:hover { background: var(--gopa-yellow-amber); transform: translateY(-1px); }
.panel-card__cta:focus-visible {
  outline: 2px solid var(--gopa-yellow);
  outline-offset: 2px;
}

/* ---------- Attribution ---------- */
.reach__attribution {
  margin-top: 32px;
  font-size: 12px;
  color: var(--reach-text-dim);
  text-align: right;
}
.reach__attribution a {
  color: var(--reach-text-muted);
  text-decoration: underline;
  text-decoration-color: var(--reach-line-strong);
  text-underline-offset: 3px;
}
.reach__attribution a:hover { color: var(--gopa-yellow); text-decoration-color: var(--gopa-yellow); }

/* ---------- Tooltip ---------- */
.reach-tooltip {
  position: fixed;
  pointer-events: none;
  background: rgba(8,26,36,0.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--reach-line-strong);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  color: #fff;
  z-index: 10;
  transform: translate(-50%, -100%) translateY(-8px);
  opacity: 0;
  transition: opacity 120ms;
  white-space: nowrap;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.reach-tooltip.is-visible { opacity: 1; }
.reach-tooltip__sub {
  font-size: 10px;
  font-weight: 600;
  color: var(--gopa-yellow);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 2px;
  display: block;
}
