/* ==========================================
   SISTEMA DE DISEÑO — VERSIÓN LIGHT
   Paleta:
     Primario  #0070D7  (azul institucional)
     Acento    #D68500  (naranja dorado)
     Oscuro    #2B4257  (navy slate — textos, bordes)
     Fondo     #ffffff / #f5f7fa
   ========================================== */
:root {
  /* Colores base */
  --color-bg:           #f5f7fa;
  --color-surface:      #ffffff;
  --color-surface-alt:  #eef2f7;

  /* Paleta principal */
  --color-blue:         #0070D7;
  --color-blue-dim:     rgba(0, 112, 215, 0.1);
  --color-blue-glow:    rgba(0, 112, 215, 0.3);
  --color-blue-border:  rgba(0, 112, 215, 0.25);

  --color-amber:        #D68500;
  --color-amber-dim:    rgba(214, 133, 0, 0.12);
  --color-amber-glow:   rgba(214, 133, 0, 0.35);
  --color-amber-border: rgba(214, 133, 0, 0.3);

  --color-navy:         #2B4257;
  --color-navy-dim:     rgba(43, 66, 87, 0.08);

  /* Textos */
  --color-text:         #1a2a38;
  --color-text-muted:   #5a7491;

  /* Bordes */
  --color-border:       rgba(43, 66, 87, 0.14);

  /* Fuentes */
  --font-headers:       'Outfit', sans-serif;
  --font-text:          'Inter', sans-serif;
  --gap:                14px;
}

/* ==========================================
   RESET BASE
   ========================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html { font-size: 16px; }

body {
  background-color: var(--color-bg);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  padding: 16px;
  font-family: var(--font-text);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ==========================================
   CONTENEDOR PRINCIPAL
   ========================================== */
.infographic-wrapper {
  width: 100%;
  max-width: 960px;
  background-color: var(--color-surface);
  border-radius: 14px;
  border: 1px solid var(--color-border);
  box-shadow:
    0 4px 6px rgba(43, 66, 87, 0.06),
    0 12px 32px rgba(43, 66, 87, 0.1),
    0 0 0 1px rgba(0, 112, 215, 0.05);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* Desktop: relación 4:3 */
@media (min-width: 769px) {
  body {
    align-items: center;
    padding: 20px;
  }
  .infographic-wrapper {
    aspect-ratio: 4 / 3;
    max-height: 720px;
  }
}

/* ==========================================
   ENCABEZADO
   ========================================== */
.info-header {
  padding: 12px 18px 10px;
  border-bottom: 1px solid var(--color-border);
  background: linear-gradient(180deg, rgba(0,112,215,0.04) 0%, transparent 100%);
  flex-shrink: 0;
}

.header-badge {
  display: inline-block;
  font-family: var(--font-headers);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--color-blue);
  background-color: var(--color-blue-dim);
  padding: 3px 10px;
  border-radius: 4px;
  margin-bottom: 5px;
  border: 1px solid var(--color-blue-border);
  text-transform: uppercase;
}

.info-title {
  font-family: var(--font-headers);
  font-size: clamp(15px, 3.5vw, 22px);
  font-weight: 800;
  line-height: 1.15;
  color: var(--color-navy);
  letter-spacing: -0.4px;
}

.info-subtitle {
  font-size: clamp(12px, 2vw, 14px);
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* ==========================================
   CARRUSEL
   ========================================== */
.carousel-viewport {
  flex: 1 1 auto;
  overflow: hidden;
  position: relative;
  width: 100%;
  min-height: 0;
}

.carousel-track {
  display: flex;
  height: 100%;
  width: 100%;
  transition: transform 0.5s cubic-bezier(0.25, 1, 0.5, 1);
}

.carousel-slide {
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  overflow: hidden;
  opacity: 0.2;
  transition: opacity 0.5s ease;
  will-change: opacity;
}

.carousel-slide.active { opacity: 1; }

/* ==========================================
   GRILLA DEL SLIDE — DESKTOP
   ========================================== */
.slide-grid {
  display: grid;
  grid-template-columns: 230px 1fr;
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "controls visual"
    "panel    visual";
  height: 100%;
  gap: var(--gap);
  padding: 12px 18px;
}

/* Botones de fase */
.map-controls {
  grid-area: controls;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--color-border);
}

/* Descripción textual */
.slide-panel {
  grid-area: panel;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--color-border);
  padding-right: 14px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(43,66,87,0.15) transparent;
}

.slide-panel::-webkit-scrollbar { width: 4px; }
.slide-panel::-webkit-scrollbar-thumb {
  background: rgba(43,66,87,0.15);
  border-radius: 2px;
}

.slide-description {
  font-size: clamp(12px, 1.6vw, 13.5px);
  line-height: 1.65;
  color: var(--color-text-muted);
}

/* Contenedor del mapa */
.slide-visual {
  grid-area: visual;
  position: relative;
  background-color: var(--color-surface-alt);
  border-radius: 10px;
  border: 1px solid var(--color-border);
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
}

/* ==========================================
   BOTONES DE FASE
   ========================================== */
.map-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background-color: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--color-text);
  cursor: pointer;
  text-align: left;
  transition: background-color 0.25s, border-color 0.25s, box-shadow 0.25s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  width: 100%;
}

.map-btn:hover {
  background-color: var(--color-blue-dim);
  border-color: var(--color-blue-border);
}

.map-btn.active {
  background-color: var(--color-blue-dim);
  border-color: var(--color-blue);
  box-shadow: 0 0 0 3px rgba(0,112,215,0.1), inset 0 1px 0 rgba(255,255,255,0.8);
}

.phase-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background-color: rgba(43,66,87,0.1);
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  transition: background-color 0.25s, color 0.25s;
  color: var(--color-text-muted);
}

.map-btn.active .phase-indicator {
  background-color: var(--color-blue);
  color: #ffffff;
}

.btn-text-group {
  display: flex;
  flex-direction: column;
}

.btn-label {
  font-size: clamp(12px, 1.6vw, 13.5px);
  font-weight: 600;
  color: var(--color-navy);
}

.btn-sub {
  font-size: 10.5px;
  color: var(--color-text-muted);
  margin-top: 1px;
}

/* ==========================================
   INFO OVERLAY DEL MAPA
   ========================================== */
.map-info-overlay {
  position: absolute;
  bottom: 10px;
  left: 10px;
  right: 10px;
  background-color: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 14px 18px;
  font-size: clamp(12px, 1.5vw, 14px);
  line-height: 1.65;
  color: var(--color-text);
  z-index: 10;
  pointer-events: none;
  transition: border-color 0.3s;
  box-shadow: 0 4px 16px rgba(43,66,87,0.12);
}

.map-info-overlay strong { color: var(--color-amber); }

/* ==========================================
   SVG — MAPA
   ========================================== */
.radar-map {
  width: 100%;
  height: 100%;
  display: block;
}

.radar-map-image {
  opacity: 0.22;
  filter: sepia(0.2) hue-rotate(190deg) saturate(0.8) brightness(0.75) contrast(1.15);
  pointer-events: none;
}

.map-river-path {
  fill: none;
  stroke: rgba(0, 112, 215, 0.3);
  stroke-width: 1.6px;
  stroke-dasharray: 2 3;
}

/* Rutas animadas — base */
.flight-path,
.land-path,
.export-path {
  fill: none;
  stroke-linecap: round;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

@keyframes dash-flow {
  to { stroke-dashoffset: 0; }
}

.flight-path {
  stroke: var(--color-amber);
  stroke-width: 1.6px;
  stroke-dasharray: 5 4;
  stroke-dashoffset: 40;
}

.land-path {
  stroke: var(--color-amber);
  stroke-width: 2px;
  stroke-dasharray: 7 3;
  stroke-dashoffset: 50;
}

.export-path {
  stroke: var(--color-blue);
  stroke-width: 1.8px;
  stroke-dasharray: 5 3;
  stroke-dashoffset: 45;
}

/* Activación por fase */
.infographic-wrapper[data-active-phase="1"] .flight-path {
  opacity: 1;
  animation: dash-flow 1.5s linear infinite;
}

.infographic-wrapper[data-active-phase="2"] .land-path {
  opacity: 1;
  animation: dash-flow 2s linear infinite;
}

.infographic-wrapper[data-active-phase="3"] .export-path {
  opacity: 1;
  animation: dash-flow 1.2s linear infinite;
}

/* ==========================================
   NODOS SVG
   ========================================== */
.map-node {
  cursor: pointer;
  pointer-events: auto;
}

.node-core {
  fill: var(--color-amber);
  transition: fill 0.3s;
}

.node-core--cyan { fill: var(--color-blue); }

.node-pulse {
  fill: var(--color-amber-dim);
  transform-origin: center;
  animation: pulse-ring 2.5s infinite ease-out;
  pointer-events: none;
}

.node-pulse--cyan { fill: var(--color-blue-dim); }

@keyframes pulse-ring {
  0%   { transform: scale(0.5); opacity: 0.9; }
  100% { transform: scale(2.2); opacity: 0; }
}

/* Nodos de destino: atenuados hasta fase 3 */
.node-ports,
.node-pacific {
  opacity: 0.3;
  transition: opacity 0.4s ease;
}

.node-ports .node-pulse,
.node-pacific .node-pulse {
  opacity: 0;
  visibility: hidden;
}

.infographic-wrapper[data-active-phase="3"] .node-ports,
.infographic-wrapper[data-active-phase="3"] .node-pacific {
  opacity: 1;
}

.infographic-wrapper[data-active-phase="3"] .node-ports .node-pulse,
.infographic-wrapper[data-active-phase="3"] .node-pacific .node-pulse {
  opacity: 1;
  visibility: visible;
}

/* Hover */
.map-node:hover .node-core { fill: var(--color-navy); }

/* Etiquetas SVG */
.node-label {
  font-family: var(--font-text);
  font-size: 13px;
  font-weight: 700;
  fill: var(--color-navy);
  paint-order: stroke fill;
  stroke: rgba(255, 255, 255, 0.95);
  stroke-width: 4px;
  stroke-linejoin: round;
  pointer-events: none;
  transition: fill 0.3s;
}

.node-label--cyan  { fill: var(--color-blue); }
.node-label--bold  { font-weight: 800; }
.node-center       { text-anchor: middle; }
.node-right        { text-anchor: end; }

.map-node:hover .node-label { fill: var(--color-blue); }

/* ==========================================
   PIE DE PÁGINA — NAVEGACIÓN
   ========================================== */
.info-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 18px;
  border-top: 1px solid var(--color-border);
  background-color: var(--color-surface-alt);
  flex-shrink: 0;
}

.nav-arrow-btn {
  background: none;
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.25s, color 0.25s, border-color 0.25s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.nav-arrow-btn:hover:not(:disabled) {
  background-color: var(--color-blue-dim);
  color: var(--color-blue);
  border-color: var(--color-blue-border);
}

.nav-arrow-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.nav-arrow-btn svg {
  width: 15px;
  height: 15px;
}

.carousel-dots {
  display: flex;
  gap: 8px;
  align-items: center;
}

.dot-btn {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: rgba(43,66,87,0.2);
  border: none;
  cursor: pointer;
  transition: background-color 0.3s, width 0.3s, border-radius 0.3s;
  padding: 0;
  touch-action: manipulation;
}

.dot-btn:hover { background-color: rgba(43,66,87,0.4); }

.dot-btn.active {
  background-color: var(--color-blue);
  width: 18px;
  border-radius: 3.5px;
  box-shadow: 0 0 8px var(--color-blue-glow);
}

/* ==========================================
   RESPONSIVE — TABLET (601px – 900px)
   ========================================== */
@media (max-width: 900px) and (min-width: 601px) {
  .slide-grid {
    grid-template-columns: 195px 1fr;
    gap: 10px;
    padding: 12px 14px;
  }

  .slide-description { font-size: 12px; }
  .btn-label          { font-size: 12px; }
  .btn-sub            { font-size: 10px; }

  .map-info-overlay {
    font-size: 12px;
    padding: 10px 14px;
    bottom: 8px;
  }

  .node-label { font-size: 12px; }

  .node-ports,
  .node-pacific { opacity: 0.6; }
}

/* ==========================================
   RESPONSIVE — MÓVIL (≤ 600px)
   ========================================== */
@media (max-width: 600px) {
  body {
    padding: 0;
    align-items: flex-start;
  }

  .infographic-wrapper {
    aspect-ratio: unset;
    max-height: none;
    height: auto;
    border-radius: 0;
    border-left: none;
    border-right: none;
    min-height: 100svh;
  }

  .info-header { padding: 14px 16px 12px; }
  .info-title  { font-size: 18px; }
  .info-subtitle { font-size: 13px; }

  .carousel-viewport {
    overflow: visible;
    height: auto;
    flex: none;
  }

  .carousel-track {
    height: auto;
    flex-direction: column;
    transition: none;
  }

  .carousel-slide {
    flex: none;
    width: 100%;
    height: auto;
    opacity: 1;
    overflow: visible;
  }

  /* Orden: botones → mapa → descripción */
  .slide-grid {
    display: flex;
    flex-direction: column;
    height: auto;
    padding: 14px;
    gap: 14px;
    grid-template-columns: unset;
    grid-template-rows: unset;
    grid-template-areas: unset;
  }

  .map-controls { order: 1; }
  .slide-visual { order: 2; }
  .slide-panel  { order: 3; }

  /* Botones: grilla de 3 columnas */
  .map-controls {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    border-bottom: none;
    padding-bottom: 0;
  }

  .map-btn {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 5px;
    padding: 10px 6px;
    border-radius: 10px;
    min-height: 56px;
  }

  .phase-indicator {
    width: 26px;
    height: 26px;
    font-size: 12px;
  }

  .btn-text-group { align-items: center; }
  .btn-label { font-size: 12px; }
  .btn-sub   { display: none; }

  /* Mapa */
  .slide-visual {
    height: auto;
    min-height: 320px;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    padding: 0;
    border: 1px solid var(--color-border);
    background-color: var(--color-surface-alt);
  }

  .radar-map {
    width: 100%;
    height: 280px;
    display: block;
  }

  /* Info overlay acoplado debajo del mapa */
  .map-info-overlay {
    position: relative;
    bottom: auto;
    left: auto;
    right: auto;
    width: 100%;
    margin: 0;
    border-radius: 0 0 10px 10px;
    border-top: 1px solid var(--color-border);
    padding: 14px 16px;
    font-size: 13px;
    line-height: 1.65;
    background-color: var(--color-surface);
    box-shadow: none;
    pointer-events: auto;
  }

  /* Descripción */
  .slide-panel {
    height: auto;
    overflow: visible;
    border-right: none;
    border-top: 1px solid var(--color-border);
    padding-right: 0;
    padding-top: 14px;
    padding-bottom: 4px;
  }

  .slide-description {
    font-size: 14px;
    line-height: 1.65;
    color: var(--color-text-muted);
  }

  /* Etiquetas SVG más grandes */
  .node-label {
    font-size: 15px;
    stroke-width: 5px;
  }

  /* Footer */
  .info-footer {
    padding: 10px 16px;
    background-color: var(--color-surface-alt);
  }

  .nav-arrow-btn {
    width: 36px;
    height: 36px;
  }

  .nav-arrow-btn svg {
    width: 17px;
    height: 17px;
  }

  .dot-btn.active { width: 22px; }
}

/* ==========================================
   TELÉFONOS MUY PEQUEÑOS (≤ 380px)
   ========================================== */
@media (max-width: 380px) {
  .info-title { font-size: 16px; }

  .map-btn {
    padding: 8px 4px;
    min-height: 50px;
  }

  .btn-label { font-size: 11px; }
  .node-label { font-size: 13px; }
  .slide-visual { min-height: 270px; }
  .radar-map { height: 240px; }
}
