/**
 * World Reviews Map - Embeddable Interactive Map Component
 * https://github.com/yourusername/world-reviews-map
 * 
 * All styles are scoped to .wrm-* prefix to avoid conflicts with host site styles
 */

/* Theme Variables - Customize these to change the entire color scheme */

:root {
  /* Primary Colors - CRIMSON THEME TO MATCH PORTFOLIO */
  --wrm-primary-color: #DC143C;
  --wrm-primary-hover: #FF5670;
  --wrm-accent-color: #B8102F;
  
  /* Background Colors - DARK CHARCOAL TO MATCH PORTFOLIO */
  --wrm-bg-dark: #1A1A1A;
  --wrm-bg-medium: #2C2C2C;
  --wrm-bg-light: #2C2C2C;
  --wrm-bg-overlay: rgba(26, 26, 26, 0.98);
  --wrm-bg-overlay-alt: rgba(44, 44, 44, 0.98);
  
  /* Border Colors - CRIMSON BORDERS */
  --wrm-border-primary: rgba(220, 20, 60, 0.3);
  --wrm-border-secondary: rgba(220, 20, 60, 0.2);
  --wrm-border-dark: #1A1A1A;
  --wrm-border-medium: #404040;
  
  /* Text Colors - OFF-WHITE TO MATCH PORTFOLIO */
  --wrm-text-primary: #F5F5F5;
  --wrm-text-secondary: #E0E0E0;
  --wrm-text-muted: #B0B0B0;
  --wrm-text-dark: #808080;
  
  /* Country Colors - CRIMSON THEME */
  --wrm-country-default: #2C2C2C;
  --wrm-country-stroke: #1A1A1A;
  --wrm-country-active: var(--wrm-primary-color);
  --wrm-country-hover: var(--wrm-accent-color);
  
  /* UI Element Colors */
  --wrm-white: #fff;
  --wrm-transparent: transparent;
  
  /* Opacity Values */
  --wrm-opacity-high: 0.95;
  --wrm-opacity-medium: 0.05;
}

/* Container */
.wrm-container {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  box-sizing: border-box;
}

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

/* Map Container */
.wrm-map-wrapper {
  background: rgba(26, 26, 26, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 20px;
  padding: 24px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.6);
  border: none;
}

.wrm-map-wrapper::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, 
    transparent 0%, 
    var(--wrm-primary-color) 50%, 
    transparent 100%);
}

/* SVG Map */
.wrm-map-svg {
  width: 100%;
  height: auto;
  cursor: grab;
  display: block;
}

.wrm-map-svg:active {
  cursor: grabbing;
}

/* Country Paths */
.wrm-country {
  fill: var(--wrm-country-default);
  stroke: var(--wrm-country-stroke);
  stroke-width: 0.5px;
  transition: all 0.3s ease;
}

.wrm-country.wrm-has-reviews {
  fill: var(--wrm-country-active);
  cursor: pointer;
}

.wrm-country.wrm-has-reviews:hover {
  fill: var(--wrm-country-hover);
  stroke: var(--wrm-white);
  stroke-width: 0.8px;
  filter: drop-shadow(0 0 15px rgba(220, 20, 60, 0.9));
  animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% { 
    filter: drop-shadow(0 0 10px rgba(220, 20, 60, 0.7));
  }
  50% { 
    filter: drop-shadow(0 0 20px rgba(220, 20, 60, 1));
  }
}

/* Tooltip - Modern Minimalist Design */
.wrm-tooltip {
  position: fixed;
  background: rgba(28, 28, 28, 0.98);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(220, 20, 60, 0.4);
  border-radius: 16px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1), 
              transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 10000;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  width: min(380px, calc(100vw - 24px));
  max-height: min(420px, 65vh);
  overflow: hidden;
}

.wrm-tooltip.wrm-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.wrm-tooltip-header {
  padding: 16px 20px 14px 20px;
  border-bottom: 1px solid rgba(220, 20, 60, 0.2);
  background: linear-gradient(135deg, 
    rgba(0, 0, 0, 0.3) 0%, 
    rgba(28, 28, 28, 0.2) 100%);
  position: relative;
  overflow: hidden;
}

.wrm-tooltip-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, 
    transparent 0%, 
    var(--wrm-primary-color) 50%, 
    transparent 100%);
  opacity: 0.5;
}

.wrm-tooltip-country {
  color: var(--wrm-text-primary);
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0 0 6px 0;
  display: flex;
  align-items: center;
  gap: 12px;
  line-height: 1.3;
}

.wrm-tooltip-country .fi {
  font-size: 1.6rem;
  line-height: 1;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s ease;
}

.wrm-tooltip:hover .wrm-tooltip-country .fi {
  transform: scale(1.05);
}

.wrm-tooltip-stats {
  color: var(--wrm-text-muted);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0; /* FIX: Removes extra space after "X reviews" */
  font-weight: 500;
  letter-spacing: 0.02em;
}

.wrm-tooltip-stats .wrm-count {
  color: var(--wrm-primary-color);
  font-weight: 500;
  font-size: 0.9rem;
}

/* Reviews Scroll - Enhanced */
.wrm-reviews-scroll {
  height: min(280px, 45vh);
  overflow: hidden;
  position: relative;
}

.wrm-reviews-scroll::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 30px;
  background: linear-gradient(180deg, 
    var(--wrm-bg-dark) 0%, 
    transparent 100%);
  z-index: 2;
  pointer-events: none;
}

.wrm-reviews-scroll::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 40px;
  background: linear-gradient(0deg, 
    var(--wrm-bg-medium) 0%, 
    transparent 100%);
  z-index: 2;
  pointer-events: none;
}

.wrm-reviews-track {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 0;
  animation: wrm-scroll-up linear infinite;
}

/* Disable scrolling animation for 1-2 reviews */
.wrm-reviews-track.wrm-no-scroll {
  animation: none;
  padding-bottom: 16px;
}

@keyframes wrm-scroll-up {
  0% { transform: translateY(0); }
  100% { transform: translateY(-50%); }
}

/* Review Card - Enhanced */
.wrm-review {
  background: rgba(28, 28, 28, 0.98);
  border-radius: 12px;
  padding: 16px;
  border: none;
  margin: 0 16px 12px 16px;
  transition: all 0.25s ease;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  position: relative;
  overflow: hidden;
}

.wrm-review::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 10px;
  background: linear-gradient(to right, rgba(220, 20, 60, 0.4), transparent);
  pointer-events: none;
  transition: all 0.25s ease;
}

.wrm-review:hover {
  transform: translateY(-2px);
}

.wrm-review:hover::before {
  background: linear-gradient(to right, rgba(220, 20, 60, 0.6), transparent);
  width: 12px;
}

.wrm-review-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.wrm-review-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  border: 2px solid rgba(220, 20, 60, 0.3);
  background: linear-gradient(135deg, 
    var(--wrm-primary-color) 0%, 
    var(--wrm-primary-hover) 100%);
}

.wrm-review-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.wrm-avatar-placeholder {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, 
    var(--wrm-primary-color) 0%, 
    var(--wrm-primary-hover) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--wrm-white);
  font-weight: 700;
  font-size: 0.9rem;
}

.wrm-review-info {
  flex: 1;
  min-width: 0;
}

.wrm-review-name {
  color: var(--wrm-text-primary);
  font-weight: 700;
  font-size: 0.9rem;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.wrm-review-industry {
  color: var(--wrm-primary-color);
  font-size: 0.75rem;
  text-transform: capitalize;
  margin: 4px 0 0 0;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.wrm-review-text {
  color: var(--wrm-text-secondary);
  font-size: 0.85rem;
  line-height: 1.6;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Legend */
.wrm-legend {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 24px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.wrm-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--wrm-text-muted);
  font-size: 0.85rem;
}

.wrm-legend-color {
  width: 16px;
  height: 16px;
  border-radius: 4px;
}

.wrm-legend-color.wrm-inactive {
  background: var(--wrm-country-default);
  border: 1px solid var(--wrm-border-medium);
}

.wrm-legend-color.wrm-active {
  background: var(--wrm-primary-color);
}

/* Stats */
.wrm-stats {
  position: absolute;
  bottom: 20px;
  left: 20px;
  display: flex;
  gap: 40px;
  background: rgba(26, 26, 26, 0.95);
  padding: 16px 24px;
  border-radius: 12px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  z-index: 10;
}

.wrm-stat {
  text-align: center;
}

.wrm-stat-value {
  color: #f8fafc;
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
}

.wrm-stat-label {
  color: var(--wrm-text-dark);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

/* Zoom Controls */
.wrm-zoom-controls {
  position: absolute;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.wrm-zoom-btn {
  width: 36px;
  height: 36px;
  background: rgba(26, 26, 26, 0.95);
  border: 1px solid var(--wrm-border-primary);
  border-radius: 6px;
  color: var(--wrm-text-primary);
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.wrm-zoom-btn:hover {
  background: var(--wrm-primary-color);
  border-color: var(--wrm-primary-color);
}

/* Loading */
.wrm-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  color: var(--wrm-text-muted);
}

.wrm-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--wrm-border-secondary);
  border-top-color: var(--wrm-primary-color);
  border-radius: 50%;
  animation: wrm-spin 0.8s cubic-bezier(0.68, -0.55, 0.27, 1.55) infinite;
  margin-bottom: 12px;
}

@keyframes wrm-spin {
  to { transform: rotate(360deg); }
}

.wrm-loading-text {
  font-size: 0.9rem;
  margin: 0;
}

/* Responsive */
@media (max-width: 768px) {
  .wrm-map-wrapper {
    padding: 12px;
    border-radius: 12px;
  }
  
  .wrm-legend {
    gap: 16px;
  }
  
  .wrm-legend-item {
    font-size: 0.8rem;
  }
  
  .wrm-stats {
    gap: 24px;
    bottom: 12px;
    left: 12px;
    padding: 12px 20px;
  }
  
  .wrm-stat-value {
    font-size: 1.4rem;
  }
  
  .wrm-zoom-controls {
    bottom: 12px;
    right: 12px;
  }
  
  .wrm-zoom-btn {
    width: 32px;
    height: 32px;
  }
  
  .wrm-tooltip {
    width: calc(100vw - 32px);
    max-width: 320px;
    max-height: 55vh;
    border-radius: 14px;
    left: 50% !important;
    transform: translateX(-50%) scale(0.98) !important;
    bottom: 10px !important;
    top: auto !important;
  }
  
  .wrm-tooltip.wrm-visible {
    transform: translateX(-50%) scale(1) !important;
  }
  
  .wrm-reviews-scroll {
    height: 35vh;
  }
  
  .wrm-tooltip-header {
    padding: 14px 16px 12px 16px;
  }
  
  .wrm-tooltip-country {
    font-size: 1.05rem;
    gap: 10px;
  }
  
  .wrm-tooltip-country .fi {
    font-size: 1.4rem;
  }
  
  .wrm-tooltip-stats {
    font-size: 0.85rem;
  }
  
  .wrm-tooltip-stats .wrm-count {
    font-size: 0.85rem;
  }
  
  .wrm-review {
    padding: 14px;
    margin: 0 12px 10px 12px;
    border-radius: 10px;
  }
  
  .wrm-review-avatar {
    width: 32px;
    height: 32px;
  }
  
  .wrm-review-name {
    font-size: 0.85rem;
  }
  
  .wrm-review-text {
    font-size: 0.8rem;
    -webkit-line-clamp: 2;
  }
}
