/**
 * Bitumix Chile Map — estilos
 * Desktop: Chile rotado (norte izquierda). Mobile: vertical.
 */

.bcm-map {
  --bcm-fill: #1a232e;
  --bcm-fill-active: #f3b23e;
  --bcm-stroke: #2a3544;
  --bcm-stroke-active: #d49a2a;
  --bcm-hover: #ffc857;
  --bcm-marker: #f3b23e;
  --bcm-marker-size: 14px;
  --bcm-wm: #e8eaed;
  --bcm-sub: #1a232e;
  --bcm-modal-bg: #ffffff;
  --bcm-modal-title: #3a3a3a;
  --bcm-modal-text: #5a5a5a;
  --bcm-overlay: rgba(26, 35, 46, 0.45);
  position: relative;
  width: 100%;
}

.bcm-map__stage {
  position: relative;
  width: 100%;
  overflow: hidden;
}

.bcm-watermark {
  position: absolute;
  z-index: 0;
  color: var(--bcm-wm);
  font-weight: 700;
  font-size: clamp(3rem, 12vw, 7.5rem);
  letter-spacing: 0.04em;
  line-height: 1;
  pointer-events: none;
  user-select: none;
  white-space: nowrap;
}

.bcm-map__canvas {
  position: relative;
  z-index: 1;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.bcm-map__rotator {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bcm-map__svg-wrap {
  position: relative;
  width: 100%;
  max-width: 220px;
  margin: 0 auto;
}

.bcm-map__svg-wrap .bcm-svg,
.bcm-map__svg-wrap > svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.bcm-map__svg-wrap .bcm-region {
  fill: var(--bcm-fill);
  stroke: var(--bcm-stroke);
  stroke-width: 0.6;
  stroke-linejoin: round;
  cursor: default;
  transition: fill 0.2s ease, stroke 0.2s ease, filter 0.2s ease;
  vector-effect: non-scaling-stroke;
}

/* Regiones con sucursales: destacadas (acento Bitumix) */
.bcm-map__svg-wrap .bcm-region.has-branch {
  fill: var(--bcm-fill-active);
  stroke: var(--bcm-stroke-active);
  cursor: pointer;
}

.bcm-map__svg-wrap .bcm-region.has-branch.is-hovered,
.bcm-map__svg-wrap .bcm-region.has-branch:hover,
.bcm-map__svg-wrap .bcm-region.has-branch.is-active {
  fill: var(--bcm-hover);
  filter: brightness(1.05);
}

/* Regiones sin sucursales: hover sutil */
.bcm-map__svg-wrap .bcm-region:not(.has-branch).is-hovered,
.bcm-map__svg-wrap .bcm-region:not(.has-branch):hover {
  filter: brightness(1.25);
}

.bcm-map__svg-wrap .bcm-region.has-branch:focus-visible {
  outline: 2px solid var(--bcm-marker);
  outline-offset: 2px;
}

.bcm-map__subtitle {
  position: relative;
  z-index: 1;
  margin-top: 1.25rem;
  max-width: 28rem;
  color: var(--bcm-sub);
}

.bcm-map__subtitle-title {
  display: block;
  font-size: clamp(1rem, 2.5vw, 1.35rem);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin-bottom: 0.35rem;
}

.bcm-map__subtitle-text {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.45;
  opacity: 0.85;
}

/* —— Modal —— */
.bcm-modal[hidden] {
  display: none !important;
}

.bcm-modal {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.bcm-modal__overlay {
  position: absolute;
  inset: 0;
  background: var(--bcm-overlay);
  cursor: pointer;
}

.bcm-modal__dialog {
  position: relative;
  z-index: 1;
  width: min(100%, 400px);
  max-height: min(85vh, 640px);
  overflow: auto;
  background: var(--bcm-modal-bg);
  color: var(--bcm-modal-text);
  border-radius: 4px;
  padding: 1.75rem 1.5rem 1.5rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  animation: bcm-modal-in 0.22s ease;
}

@keyframes bcm-modal-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.bcm-modal__close {
  position: absolute;
  top: 0.5rem;
  right: 0.65rem;
  width: 2rem;
  height: 2rem;
  border: 0;
  background: transparent;
  color: var(--bcm-modal-text);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.7;
}

.bcm-modal__close:hover,
.bcm-modal__close:focus-visible {
  opacity: 1;
}

.bcm-modal__title {
  margin: 0 0 1rem;
  padding-right: 1.5rem;
  color: var(--bcm-modal-title);
  font-size: 1.2rem;
  font-weight: 700;
}

.bcm-modal__list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.bcm-branch {
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.bcm-branch:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.bcm-branch__name {
  margin: 0 0 0.4rem;
  color: var(--bcm-modal-title);
  font-size: 1.05rem;
  font-weight: 700;
}

.bcm-branch__address {
  margin: 0 0 0.55rem;
  white-space: pre-line;
  line-height: 1.45;
  font-size: 0.95rem;
}

.bcm-branch__phone {
  margin: 0 0 0.25rem;
  font-size: 0.95rem;
}

.bcm-branch__email a {
  color: var(--bcm-modal-title);
  text-decoration: none;
  display: block;
  font-size: 0.95rem;
  line-height: 1.4;
}

.bcm-branch__email a:hover {
  text-decoration: underline;
}

.bcm-modal__empty {
  margin: 0;
  font-size: 0.95rem;
  opacity: 0.8;
}

body.bcm-modal-open {
  overflow: hidden;
}

/* —— Mobile: mapa vertical + COBERTURA vertical —— */
@media (max-width: 767px) {
  .bcm-map__stage {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    align-items: center;
    column-gap: 0.5rem;
    min-height: 520px;
    padding: 0.5rem 0 1rem;
  }

  .bcm-map__canvas {
    grid-column: 1;
    grid-row: 1;
    justify-content: flex-start;
  }

  .bcm-map__svg-wrap {
    max-width: 160px;
    margin-left: 4%;
  }

  .bcm-watermark {
    grid-column: 2;
    grid-row: 1;
    position: relative;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    font-size: clamp(2.5rem, 14vw, 4.5rem);
    align-self: stretch;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-inline: 0.15rem;
  }

  .bcm-map__subtitle {
    grid-column: 1 / -1;
    grid-row: 2;
    margin: 1.5rem 1rem 0;
  }
}

/* —— Desktop: Chile horizontal (rotado -90°) —— */
@media (min-width: 768px) {
  .bcm-map__stage {
    min-height: 280px;
    padding: 2.5rem 0 1.5rem;
  }

  .bcm-watermark {
    top: 45%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: clamp(4rem, 11vw, 8rem);
    opacity: 0.95;
  }

  /*
   * Rotator reserva el espacio visual horizontal.
   * Dentro, el wrap (SVG vertical + markers) rota -90° (norte → izquierda).
   * Aspecto SVG ≈ 181:921.
   */
  .bcm-map__rotator {
    --bcm-map-len: min(88vw, 920px);
    --bcm-map-thick: calc(var(--bcm-map-len) * 181 / 921);
    width: var(--bcm-map-len);
    height: var(--bcm-map-thick);
  }

  .bcm-map__svg-wrap {
    max-width: none;
    width: var(--bcm-map-thick);
    height: var(--bcm-map-len);
    margin: 0;
    flex-shrink: 0;
    transform: rotate(-90deg);
    transform-origin: center center;
  }

  .bcm-map__svg-wrap > svg {
    width: 100%;
    height: 100%;
  }

  .bcm-map__markers {
    position: absolute;
    inset: 0;
  }

  .bcm-map__subtitle {
    margin-top: 0.75rem;
    margin-left: clamp(1rem, 6vw, 4rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  .bcm-modal__dialog {
    animation: none;
  }

  .bcm-map__svg-wrap .bcm-region {
    transition: none;
  }
}
