/* ==========================================================================
   STYLE INTERAKTYWNEJ MAPY HISTORYCZNEJ - BIBLIOTEKA SŁOWIAŃSKA
   ========================================================================== */

.map-section-wrapper {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 1.6rem;
  align-items: start;
}

@media (max-width: 1024px) {
  .map-section-wrapper {
    grid-template-columns: 1fr;
  }
}

.map-container {
  background: radial-gradient(circle at center, #102219 0%, #08120d 100%);
  border: 1px solid var(--border-highlight);
  border-radius: var(--radius-xl);
  position: relative;
  overflow: hidden;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  min-height: 620px;
  display: flex;
  flex-direction: column;
}

.map-toolbar-top {
  position: absolute;
  top: 1rem;
  left: 1rem;
  z-index: 10;
  display: flex;
  gap: 0.5rem;
  background: rgba(15, 23, 42, 0.75);
  padding: 0.35rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  backdrop-filter: blur(8px);
}

.map-tool-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  font-size: 1.1rem;
  font-weight: 700;
  transition: all var(--transition-fast);
}

.map-tool-btn:hover {
  background: var(--amber-gold);
  color: #0f172a;
  border-color: var(--amber-gold);
  transform: translateY(-2px);
}

.map-canvas-container {
  flex: 1;
  position: relative;
  width: 100%;
  height: 560px;
  cursor: grab;
  overflow: hidden;
}

.map-canvas-container:active {
  cursor: grabbing;
}

.slavic-svg-map {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.5));
}

/* ==========================================================================
   REGIONY PLEMION (TRIBES POLYGONS)
   ========================================================================== */

.tribe-polygon {
  fill-opacity: 0.18;
  stroke-width: 2.2;
  stroke-dasharray: 5 3;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.tribe-polygon:hover,
.tribe-polygon.active {
  fill-opacity: 0.45;
  stroke-width: 3.5;
  stroke-dasharray: none;
  filter: drop-shadow(0 0 12px rgba(212, 163, 89, 0.75));
}

.tribe-label {
  font-family: var(--font-heading);
  font-size: 11.5px;
  font-weight: 700;
  fill: var(--text-gold);
  text-anchor: middle;
  pointer-events: none;
  text-shadow: 0 1px 4px #000, 0 0 10px #000;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ==========================================================================
   RZEKI I HYDROGRAFIA (RIVERS)
   ========================================================================== */

.map-river-main {
  fill: none;
  stroke: #38bdf8;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.75;
  filter: drop-shadow(0 0 3px rgba(56, 189, 248, 0.4));
}

.map-river {
  fill: none;
  stroke: #4895ef;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.65;
}

.map-river-minor {
  fill: none;
  stroke: #4895ef;
  stroke-width: 1.2;
  stroke-linecap: round;
  opacity: 0.45;
}

/* ==========================================================================
   SZLAKI HANDLOWE (TRADE ROUTES ANIMATED)
   ========================================================================== */

.map-trade-route {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 8 5;
  animation: routeAnim 25s linear infinite;
}

@keyframes routeAnim {
  to { stroke-dashoffset: -130; }
}

.route-amber {
  opacity: 0.85;
  filter: drop-shadow(0 0 4px rgba(245, 158, 11, 0.6));
}

.route-via-regia {
  opacity: 0.85;
  filter: drop-shadow(0 0 4px rgba(96, 165, 250, 0.6));
}

.route-baltic {
  opacity: 0.8;
  filter: drop-shadow(0 0 4px rgba(192, 132, 252, 0.6));
}

/* ==========================================================================
   PUNKTY GRODÓW I SANKTUARIÓW (PINS)
   ========================================================================== */

.map-pin {
  cursor: pointer;
  pointer-events: all;
}

.map-pin .pin-core {
  transition: r 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), stroke-width 0.2s ease, filter 0.2s ease;
}

.map-pin .pin-halo {
  transition: r 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), fill-opacity 0.2s ease;
  animation: pinPulse 2.8s infinite ease-in-out;
}

.map-pin .pin-label {
  transition: fill 0.2s ease, font-size 0.2s ease;
}

.map-pin:hover .pin-core,
.map-pin.selected .pin-core {
  r: 12px;
  stroke: #ffffff;
  stroke-width: 2.4px;
}

.map-pin:hover .pin-halo,
.map-pin.selected .pin-halo {
  r: 22px;
  fill-opacity: 0.45;
}

.map-pin:hover .pin-label,
.map-pin.selected .pin-label {
  fill: #ffd56b;
  font-size: 11px;
  font-weight: 700;
}

@keyframes pinPulse {
  0%, 100% { transform: scale(1); opacity: 0.25; }
  50% { transform: scale(1.3); opacity: 0.05; }
}

.pin-power .pin-core {
  filter: drop-shadow(0 0 6px rgba(245, 158, 11, 0.85));
}

.pin-cult .pin-core {
  filter: drop-shadow(0 0 6px rgba(168, 85, 247, 0.85));
}

.pin-ports .pin-core {
  filter: drop-shadow(0 0 6px rgba(6, 182, 212, 0.85));
}

.pin-forts .pin-core {
  filter: drop-shadow(0 0 6px rgba(239, 68, 68, 0.85));
}

.pin-graves .pin-core {
  filter: drop-shadow(0 0 6px rgba(16, 185, 129, 0.85));
}

.pin-label {
  font-family: var(--font-body);
  font-size: 10px;
  fill: #ffffff;
  text-anchor: middle;
  pointer-events: none;
  text-shadow: 0 1px 3px #000, 0 0 6px #000;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* ==========================================================================
   PASEK CZASU (TIMELINE SLIDER)
   ========================================================================== */

.map-timeline-bar {
  background: var(--bg-card);
  border-top: 1px solid var(--border-subtle);
  padding: 0.9rem 1.4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.2rem;
  backdrop-filter: blur(8px);
}

.timeline-slider-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 1.2rem;
}

.timeline-slider-label {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  color: var(--amber-light);
  font-weight: 700;
  min-width: 130px;
}

.map-slider {
  flex: 1;
  -webkit-appearance: none;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--bg-secondary);
  outline: none;
}

.map-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--amber-gold);
  cursor: pointer;
  box-shadow: 0 0 10px var(--amber-gold);
  transition: transform var(--transition-fast);
}

.map-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* ==========================================================================
   PANEL BOCZNY MAPY (SIDEBAR & DETAILS)
   ========================================================================= */

.map-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
}

.map-layer-panel,
.map-detail-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.4rem;
  box-shadow: var(--shadow-sm);
}

.map-layer-panel h3,
.map-detail-panel h3 {
  font-size: 1.1rem;
  color: var(--amber-light);
  margin-bottom: 0.9rem;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 0.5rem;
  font-family: var(--font-heading);
}

.layer-toggle-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.layer-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  font-size: 0.88rem;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.2rem 0;
  transition: color var(--transition-fast);
}

.layer-item:hover {
  color: var(--text-primary);
}

.layer-item input[type="checkbox"] {
  accent-color: var(--amber-gold);
  width: 17px;
  height: 17px;
  cursor: pointer;
}

.legend-color-box {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  display: inline-block;
  flex-shrink: 0;
}

.sidebar-detail-card h3 {
  font-size: 1.25rem;
  color: var(--amber-light);
  margin-bottom: 0.3rem;
  font-family: var(--font-heading);
  line-height: 1.25;
}

/* ==========================================================================
   TOOLTIP MAPY
   ========================================================================= */

.map-tooltip {
  position: absolute;
  z-index: 60;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid var(--border-highlight);
  border-radius: var(--radius-md);
  padding: 0.9rem 1.1rem;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  max-width: 290px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.map-tooltip.visible {
  opacity: 1;
}

.tooltip-badge {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--amber-light);
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.map-tooltip h4 {
  color: var(--text-primary);
  font-size: 1rem;
  margin: 0 0 0.3rem 0;
  font-family: var(--font-heading);
}

.map-tooltip p {
  color: var(--text-secondary);
  font-size: 0.82rem;
  margin: 0.15rem 0;
  line-height: 1.4;
}

/* ==========================================================================
   RESPONSYWNOŚĆ MOBILNA MAPY
   ========================================================================= */

@media (max-width: 768px) {
  .map-container {
    min-height: 460px;
    border-radius: var(--radius-lg);
  }

  .map-canvas-container {
    height: 400px;
  }

  .map-timeline-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
    padding: 0.8rem 1rem;
  }

  .timeline-slider-label {
    min-width: 100px;
    font-size: 0.8rem;
  }

  .map-sidebar {
    margin-top: 1.2rem;
  }
}

@media (max-width: 480px) {
  .map-container {
    min-height: 380px;
  }

  .map-canvas-container {
    height: 320px;
  }

  .map-toolbar-top {
    top: 0.5rem;
    left: 0.5rem;
    padding: 0.25rem;
  }

  .map-tool-btn {
    width: 32px;
    height: 32px;
    font-size: 0.95rem;
  }
}
