/**
 * aBit Global Presence — Asia Map Styles (v2)
 * File location: public/css/abit-map.css
 *
 * Company cards are now overlay panels on the left of the map,
 * mirroring the stats panels on the right.
 */

.abit-global-presence {
  --abit-blue: #2261AE;
  --abit-blue-light: #4A8BD8;
  --abit-accent: #00D4FF;
  --abit-gold: #FFD700;
  --abit-bg-deep: #050812;
  --abit-bg-panel: rgba(10, 18, 36, 0.85);
  --abit-bg-panel-hover: rgba(34, 97, 174, 0.25);
  --abit-text-primary: #E8F0FF;
  --abit-text-secondary: #8AA0C8;
  --abit-text-tertiary: #5d7399;
  --abit-border: rgba(74, 139, 216, 0.25);
  --abit-border-hover: rgba(0, 212, 255, 0.5);

  --abit-country-fill: #0e1a35;
  --abit-country-stroke: rgba(74, 139, 216, 0.35);
  --abit-country-home-fill: #1a3a6e;
  --abit-country-home-stroke: rgba(0, 212, 255, 0.6);

  padding: 80px 24px 100px;
  max-width: 1280px;
  margin: 0 auto;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ───────────────────────────────────────────────────────── */
/* Heading                                                   */
/* ───────────────────────────────────────────────────────── */
.abit-gp-header {
  text-align: center;
  margin-bottom: 48px;
}

.abit-gp-title {
  font-family: 'Montserrat', 'Inter', sans-serif;
  font-size: clamp(28px, 4vw, 42px);
  font-weight: 700;
  color: #0f172a;
  margin: 0 0 12px 0;
  letter-spacing: -0.5px;
}

.dark .abit-gp-title {
  color: #f1f5f9;
}

.abit-gp-subtitle {
  font-size: clamp(14px, 1.5vw, 16px);
  color: #64748b;
  max-width: 600px;
  margin: 0 auto;
  line-height: 1.6;
}

.dark .abit-gp-subtitle {
  color: #94a3b8;
}

/* ───────────────────────────────────────────────────────── */
/* Map wrapper — taller now that it contains the cards too   */
/* ───────────────────────────────────────────────────────── */
.abit-gp-map-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  min-height: 520px;
  max-height: 720px;
  border-radius: 20px;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 30% 30%, rgba(34, 97, 174, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 70%, rgba(0, 212, 255, 0.08) 0%, transparent 50%),
    linear-gradient(135deg, #0A1428 0%, var(--abit-bg-deep) 100%);
  border: 1px solid rgba(34, 97, 174, 0.2);
  box-shadow:
    0 20px 60px rgba(5, 8, 18, 0.3),
    inset 0 0 80px rgba(0, 212, 255, 0.04);
}

.abit-gp-map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.abit-gp-map svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Subtle grid overlay */
.abit-gp-map-wrapper::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(74, 139, 216, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(74, 139, 216, 0.04) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 1;
}

/* ───────────────────────────────────────────────────────── */
/* Country paths                                             */
/* ───────────────────────────────────────────────────────── */
.abit-gp-country {
  fill: var(--abit-country-fill);
  stroke: var(--abit-country-stroke);
  stroke-width: 0.5;
  stroke-linejoin: round;
  transition: fill 0.3s ease, stroke 0.3s ease, opacity 0.3s ease;
}

.abit-gp-country.home {
  fill: var(--abit-country-home-fill);
  stroke: var(--abit-country-home-stroke);
  stroke-width: 1;
}

.abit-gp-country.home.active {
  fill: #2261AE;
  stroke: var(--abit-accent);
  stroke-width: 1.5;
  filter: drop-shadow(0 0 12px rgba(0, 212, 255, 0.6));
}

.abit-gp-map.selecting .abit-gp-country:not(.home) {
  opacity: 0.5;
}

/* ───────────────────────────────────────────────────────── */
/* Markers                                                   */
/* ───────────────────────────────────────────────────────── */
.abit-gp-marker {
  cursor: pointer;
}

.abit-gp-marker-pulse {
  fill: var(--abit-accent);
  opacity: 0.5;
  transform-origin: center;
  transform-box: fill-box;
  animation: abit-gp-pulse 2.5s ease-out infinite;
}
.abit-gp-marker.hq .abit-gp-marker-pulse {
  fill: var(--abit-gold);
}

@keyframes abit-gp-pulse {
  0%   { transform: scale(1);   opacity: 0.7; }
  100% { transform: scale(3.5); opacity: 0; }
}

.abit-gp-marker-dot {
  fill: var(--abit-accent);
  stroke: #ffffff;
  stroke-width: 1.5;
  filter: drop-shadow(0 0 6px rgba(0, 212, 255, 0.8));
  transition: r 0.2s ease;
}
.abit-gp-marker.hq .abit-gp-marker-dot {
  fill: var(--abit-gold);
  filter: drop-shadow(0 0 8px rgba(255, 215, 0, 0.9));
}

.abit-gp-marker:hover .abit-gp-marker-dot,
.abit-gp-marker.selected .abit-gp-marker-dot {
  r: 8;
}

.abit-gp-marker-label {
  fill: var(--abit-text-primary);
  font-family: 'Montserrat', 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 700;
  paint-order: stroke;
  stroke: rgba(5, 8, 18, 0.85);
  stroke-width: 4;
  stroke-linejoin: round;
  pointer-events: none;
  user-select: none;
}

.abit-gp-marker-sublabel {
  fill: var(--abit-text-secondary);
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 1px;
  text-transform: uppercase;
  paint-order: stroke;
  stroke: rgba(5, 8, 18, 0.85);
  stroke-width: 3;
  stroke-linejoin: round;
  pointer-events: none;
  user-select: none;
}

.abit-gp-connection {
  fill: none;
  stroke: var(--abit-accent);
  stroke-width: 1.5;
  stroke-dasharray: 4 6;
  opacity: 0.4;
  animation: abit-gp-dash 1.5s linear infinite;
}
@keyframes abit-gp-dash { to { stroke-dashoffset: -20; } }

/* ───────────────────────────────────────────────────────── */
/* Loading state                                             */
/* ───────────────────────────────────────────────────────── */
.abit-gp-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--abit-text-secondary);
  font-size: 13px;
  letter-spacing: 2px;
  text-transform: uppercase;
  pointer-events: none;
  transition: opacity 0.4s ease;
  z-index: 3;
}
.abit-gp-loading.hidden {
  opacity: 0;
  pointer-events: none;
}

.abit-gp-loading-spinner {
  width: 36px;
  height: 36px;
  border: 2px solid rgba(74, 139, 216, 0.2);
  border-top-color: var(--abit-accent);
  border-radius: 50%;
  animation: abit-gp-spin 0.9s linear infinite;
}
@keyframes abit-gp-spin { to { transform: rotate(360deg); } }

/* ───────────────────────────────────────────────────────── */
/* LEFT SIDE: Company panels                                 */
/* ───────────────────────────────────────────────────────── */
.abit-gp-companies {
  position: absolute;
  top: 20px;
  left: 20px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 260px;
  max-height: calc(100% - 40px);
  overflow-y: auto;

  /* Custom scrollbar for overflow */
  scrollbar-width: thin;
  scrollbar-color: rgba(74, 139, 216, 0.3) transparent;
}
.abit-gp-companies::-webkit-scrollbar { width: 4px; }
.abit-gp-companies::-webkit-scrollbar-thumb {
  background: rgba(74, 139, 216, 0.3);
  border-radius: 2px;
}

.abit-gp-company {
  /* reset button */
  all: unset;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--abit-bg-panel);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--abit-border);
  border-radius: 10px;
  cursor: pointer;
  transition:
    transform 0.25s cubic-bezier(0.4, 0, 0.2, 1),
    background 0.25s ease,
    border-color 0.25s ease,
    box-shadow 0.25s ease,
    opacity 0.3s ease;
  position: relative;
  overflow: hidden;
  width: 100%;
  text-align: left;
}

.abit-gp-company::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px;
  background: var(--abit-accent);
  transform: scaleY(0);
  transform-origin: top;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.abit-gp-company:hover,
.abit-gp-company:focus-visible {
  transform: translateX(3px);
  background: var(--abit-bg-panel-hover);
  border-color: var(--abit-border-hover);
  box-shadow: 0 4px 20px rgba(0, 212, 255, 0.1);
  outline: none;
}
.abit-gp-company:hover::before,
.abit-gp-company:focus-visible::before {
  transform: scaleY(1);
}

.abit-gp-company.highlighted {
  background: rgba(34, 97, 174, 0.35);
  border-color: var(--abit-accent);
  box-shadow: 0 4px 24px rgba(0, 212, 255, 0.25);
}
.abit-gp-company.highlighted::before { transform: scaleY(1); }

.abit-gp-company.dimmed {
  opacity: 0.4;
}

.abit-gp-company-info {
  flex: 1;
  min-width: 0; /* allow ellipsis on overflow */
}

.abit-gp-company-name {
  font-family: 'Montserrat', 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 700;
  color: var(--abit-text-primary);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.abit-gp-company-desc {
  font-size: 10px;
  color: var(--abit-text-secondary);
  line-height: 1.3;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.abit-gp-company-flag {
  font-size: 14px;
  flex-shrink: 0;
  opacity: 0.7;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.abit-gp-company:hover .abit-gp-company-flag,
.abit-gp-company.highlighted .abit-gp-company-flag {
  opacity: 1;
  transform: scale(1.15);
}

/* ───────────────────────────────────────────────────────── */
/* RIGHT SIDE: Stats overlay                                 */
/* ───────────────────────────────────────────────────────── */
.abit-gp-stats {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.abit-gp-stat {
  background: var(--abit-bg-panel);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--abit-border);
  border-radius: 10px;
  padding: 10px 16px;
  text-align: center;
  min-width: 80px;
}

.abit-gp-stat-value {
  font-family: 'Montserrat', 'Inter', sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--abit-accent);
  line-height: 1;
}

.abit-gp-stat-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--abit-text-secondary);
  margin-top: 4px;
}

/* ───────────────────────────────────────────────────────── */
/* Hint text                                                 */
/* ───────────────────────────────────────────────────────── */
.abit-gp-hint {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: var(--abit-text-secondary);
  text-transform: uppercase;
  letter-spacing: 2px;
  opacity: 0.7;
  pointer-events: none;
  transition: opacity 0.4s ease;
  z-index: 5;
  background: rgba(5, 8, 18, 0.5);
  padding: 6px 14px;
  border-radius: 20px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.abit-gp-hint.hidden { opacity: 0; }

/* ───────────────────────────────────────────────────────── */
/* Tooltip                                                   */
/* ───────────────────────────────────────────────────────── */
.abit-gp-tooltip {
  position: absolute;
  background: var(--abit-bg-panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--abit-accent);
  border-radius: 10px;
  padding: 10px 14px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  transform: translateY(4px);
  z-index: 10;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.5),
    0 0 20px rgba(0, 212, 255, 0.15);
  color: var(--abit-text-primary);
  font-size: 12px;
  white-space: nowrap;
}
.abit-gp-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

.abit-gp-tooltip-country {
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.abit-gp-tooltip-city {
  color: var(--abit-text-secondary);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 2px;
}

/* ───────────────────────────────────────────────────────── */
/* Responsive                                                */
/* ───────────────────────────────────────────────────────── */

/* Tablet: shrink panels to fit */
@media (max-width: 1024px) {
  .abit-gp-companies { width: 220px; }
  .abit-gp-company-name { font-size: 11px; }
  .abit-gp-company-desc { font-size: 9px; }
}

/* Mobile: stack panels below the map, full width */
@media (max-width: 768px) {
  .abit-global-presence {
    padding: 56px 16px 72px;
  }
  .abit-gp-map-wrapper {
    aspect-ratio: auto;
    min-height: 0;
    max-height: none;
    height: auto;
    display: flex;
    flex-direction: column;
    overflow: visible;
    border-radius: 16px;
    background:
      radial-gradient(ellipse at 30% 30%, rgba(34, 97, 174, 0.15) 0%, transparent 50%),
      linear-gradient(135deg, #0A1428 0%, var(--abit-bg-deep) 100%);
  }
  .abit-gp-map {
    position: relative;
    inset: auto;
    height: 340px;
    width: 100%;
  }

  /* Stats: horizontal row at top, inside the map area */
  .abit-gp-stats {
    top: 12px;
    right: 12px;
    left: auto;
    flex-direction: row;
    gap: 6px;
  }
  .abit-gp-stat {
    min-width: 56px;
    padding: 6px 10px;
  }
  .abit-gp-stat-value { font-size: 15px; }
  .abit-gp-stat-label { font-size: 9px; letter-spacing: 1px; }

  /* Company panels: move below the map, grid layout */
  .abit-gp-companies {
    position: relative;
    top: auto;
    left: auto;
    width: auto;
    max-height: none;
    padding: 16px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .abit-gp-hint { display: none; }
  .abit-gp-marker-sublabel { display: none; }
  .abit-gp-marker-label { font-size: 11px; }
}

/* Very small screens: single column already, just tighten padding */
@media (max-width: 480px) {
  .abit-gp-map { height: 280px; }
  .abit-gp-companies { padding: 12px; gap: 6px; }
  .abit-gp-company { padding: 8px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .abit-gp-company,
  .abit-gp-company::before,
  .abit-gp-loading-spinner,
  .abit-gp-marker-pulse,
  .abit-gp-connection,
  .abit-gp-country {
    transition: none !important;
    animation: none !important;
  }
}
