/**
 * @file
 * Mapa de rutes aèries directes a Reus — estil amb els design tokens.
 */

.ra-wrap {
  position: relative;
  height: 620px;
  border: 1px solid rgb(var(--neutral-border, 206 206 206));
  border-radius: var(--radius-md, 2px);
  overflow: hidden;
  box-shadow: 0 10px 30px rgb(var(--brand-primary, 4 36 64) / 0.12);
}
.ra-wrap .leaflet-container { height: 100%; width: 100%; background: #dfe9e6; z-index: 1; }
#rutes-aeries-canvas { position: absolute; pointer-events: none; }
.ra-tiles { filter: saturate(0.72) brightness(1.06) contrast(0.92); }

/* ===== Barra superior dins del mapa ===== */
.ra-toolbar {
  position: absolute; top: 1rem; left: 1rem; right: 1rem; z-index: 20;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem;
  pointer-events: none;
}
.ra-panel {
  background: rgb(255 255 255 / 0.95);
  border: 1px solid rgb(var(--brand-primary, 4 36 64) / 0.12);
  box-shadow: 0 10px 30px rgb(var(--brand-primary, 4 36 64) / 0.12);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: var(--radius-sm, 2px);
  padding: 0.7rem 1.1rem;
  display: flex; align-items: center; gap: 0.9rem;
  pointer-events: auto;
}
.ra-panel__icon {
  width: 42px; height: 42px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  background: rgb(var(--brand-accent, 243 197 0));
  color: rgb(var(--on-accent, var(--brand-primary , 4 36 64)));
  border-radius: var(--radius-sm, 2px);
}
.ra-panel__title {
  font-family: 'Barlow', sans-serif; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: rgb(var(--brand-primary, 4 36 64));
  font-size: 1rem; line-height: 1; margin: 0;
  display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
}
.ra-panel__chip {
  background: rgb(var(--brand-primary, 4 36 64)); color: #fff;
  border-radius: var(--radius-sm, 2px);
  padding: 0.28rem 0.55rem; font-size: 0.64rem; font-weight: 700; letter-spacing: 0.05em;
}
.ra-panel__sub { color: rgb(var(--neutral-text-muted, 75 85 99)); font-size: 0.75rem; margin: 0.25rem 0 0; }

.ra-stats {
  background: rgb(var(--brand-primary, 4 36 64)); color: #fff;
  border-radius: var(--radius-sm, 2px);
  padding: 0.6rem 1rem; display: flex; align-items: center; gap: 1rem;
  pointer-events: auto;
}
.ra-stats__num { display: block; font-family: 'Barlow', sans-serif; font-size: 1.5rem; font-weight: 800; line-height: 1; color: rgb(var(--brand-accent, 243 197 0)); }
.ra-stats__lbl { font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.1em; font-weight: 600; color: rgb(255 255 255 / 0.78); }
.ra-stats__sep { width: 1px; height: 2rem; background: rgb(255 255 255 / 0.22); }
.ra-reset {
  background: rgb(var(--brand-accent, 243 197 0)); color: rgb(var(--on-accent, var(--brand-primary , 4 36 64)));
  border: 0; border-radius: var(--radius-pill, 2px); cursor: pointer;
  text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; font-size: 0.72rem;
  padding: 0.45rem 0.8rem; display: inline-flex; align-items: center; gap: 0.4rem;
  transition: filter 0.2s;
}
.ra-reset:hover { filter: brightness(1.06); }
.ra-reset.hidden { display: none; }
/* Variant flotant (sense toolbar): a dalt a l'esquerra del mapa */
.ra-reset--floating {
  position: absolute; top: 1rem; left: 1rem; z-index: 20;
  box-shadow: 0 8px 20px rgb(var(--brand-primary, 4 36 64) / 0.2);
}

/* ===== Controls Leaflet ===== */
.ra-wrap .leaflet-control-zoom { border: 0 !important; box-shadow: 0 8px 20px rgb(var(--brand-primary, 4 36 64) / 0.15) !important; }
.ra-wrap .leaflet-control-zoom a {
  color: rgb(var(--brand-primary, 4 36 64)) !important; background: #fff !important;
  border-color: rgb(var(--neutral-border, 206 206 206)) !important;
  border-radius: var(--radius-sm, 2px) !important; font-weight: 800;
}
.ra-wrap .leaflet-control-attribution { color: rgb(var(--neutral-text-muted, 75 85 99)); background: rgb(255 255 255 / 0.86) !important; }

/* ===== Marcadors de país ===== */
.ra-country {
  display: flex; align-items: center; gap: 4px; cursor: pointer;
  transition: transform 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.ra-country:hover { transform: translateY(-3px) scale(1.1); }
.ra-country__flag,
.ra-country__count {
  border-radius: 9999px; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 7px 20px rgb(var(--brand-primary, 4 36 64) / 0.18);
  transition: all 0.28s ease;
}
.ra-country__flag {
  width: 40px; height: 40px; background: #fff;
  border: 2px solid rgb(var(--brand-primary, 4 36 64));
  overflow: hidden;
}
.ra-country__flag .fi {
  width: 30px; height: 30px; border-radius: 50%;
  background-position: center; background-size: cover;
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.08);
}
.ra-country__count {
  width: 26px; height: 26px;
  background: rgb(var(--brand-accent, 243 197 0));
  border: 2px solid rgb(var(--brand-accent, 243 197 0));
  color: rgb(var(--on-accent, var(--brand-primary , 4 36 64)));
  font-size: 11px; font-weight: 900;
}
.ra-country:hover .ra-country__flag { background: rgb(var(--brand-primary, 4 36 64)); border-color: rgb(var(--brand-primary, 4 36 64)); }
.ra-country:hover .ra-country__count { filter: brightness(1.08); }

/* ===== Marcadors d'aeroport ===== */
.ra-airport {
  width: 30px; height: 30px;
  background: rgb(var(--brand-primary, 4 36 64));
  border: 2px solid #fff; color: #fff;
  font-weight: 900; border-radius: 50%; font-size: 9px; letter-spacing: 0.02em;
  box-shadow: 0 5px 14px rgb(var(--brand-primary, 4 36 64) / 0.24);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), background 0.25s, color 0.25s;
  white-space: nowrap;
}
.ra-airport:hover, .ra-airport.is-active {
  transform: translateY(-2px) scale(1.16);
  background: rgb(var(--brand-accent, 243 197 0));
  border-color: rgb(var(--brand-primary, 4 36 64));
  color: rgb(var(--on-accent, var(--brand-primary , 4 36 64)));
}

/* ===== Origen (REU) ===== */
.ra-origin-layer { overflow: visible !important; }
.ra-origin-wrap { position: relative; width: 22px; height: 22px; }
.ra-origin-pulse {
  width: 22px; height: 22px;
  background: rgb(var(--brand-accent, 243 197 0));
  border: 3px solid rgb(var(--brand-primary, 4 36 64));
  border-radius: 50%; position: relative;
  box-shadow: 0 0 0 5px rgb(var(--brand-accent, 243 197 0) / 0.26);
}
.ra-origin-pulse::after {
  content: ''; position: absolute; inset: -9px; border-radius: 50%;
  border: 2px solid rgb(var(--brand-accent, 243 197 0));
  animation: ra-pulse 1.8s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}
@keyframes ra-pulse { 0% { transform: scale(0.5); opacity: 1; } 100% { transform: scale(2.2); opacity: 0; } }
.ra-origin-label {
  position: absolute; right: 34px; bottom: 30px;
  background: rgb(var(--brand-primary, 4 36 64)); color: #fff;
  font-weight: 800; font-size: 11px; padding: 7px 10px;
  border-radius: var(--radius-sm, 2px);
  box-shadow: 0 8px 22px rgb(var(--brand-primary, 4 36 64) / 0.24);
  border-bottom: 4px solid rgb(var(--brand-accent, 243 197 0));
  white-space: nowrap; letter-spacing: 0.04em;
  display: flex; align-items: center; gap: 6px;
}

/* ===== Popups ===== */
.ra-popup-wrap .leaflet-popup-content-wrapper {
  background: #fff !important; color: rgb(var(--neutral-text-main, 40 40 40)) !important;
  border: 1px solid rgb(var(--brand-primary, 4 36 64) / 0.18);
  border-radius: var(--radius-sm, 2px) !important;
  padding: 6px !important;
  box-shadow: 0 14px 34px rgb(var(--brand-primary, 4 36 64) / 0.2);
}
.ra-popup-wrap .leaflet-popup-tip { background: #fff !important; border: 1px solid rgb(var(--brand-primary, 4 36 64) / 0.14); }
.ra-popup-wrap .leaflet-popup-close-button { color: rgb(var(--brand-primary, 4 36 64)) !important; font-size: 18px !important; }
.ra-popup { padding: 0.5rem; width: 15rem; font-family: 'Work Sans', sans-serif; }
.ra-popup__hd {
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid rgb(var(--neutral-border, 206 206 206));
  padding-bottom: 0.4rem; margin-bottom: 0.5rem;
}
.ra-popup__region { color: rgb(var(--brand-primary, 4 36 64)); font-weight: 700; font-size: 0.75rem; }
.ra-popup__code {
  background: rgb(var(--brand-accent, 243 197 0)); color: rgb(var(--on-accent, var(--brand-primary , 4 36 64)));
  font-weight: 900; padding: 3px 7px; font-size: 0.7rem; border-radius: var(--radius-sm, 2px);
}
.ra-popup__title {
  color: rgb(var(--brand-primary, 4 36 64)); font-family: 'Barlow', sans-serif;
  font-weight: 800; text-transform: uppercase; font-size: 1rem; line-height: 1.15; margin: 0 0 0.5rem;
}
.ra-popup__lbl {
  display: block; color: rgb(var(--neutral-text-muted, 75 85 99));
  font-size: 0.62rem; text-transform: uppercase; font-weight: 700; letter-spacing: 0.08em; margin-bottom: 0.4rem;
}
.ra-popup__airlines { display: flex; flex-direction: column; gap: 0.35rem; }
.leaflet-container a.ra-airline {
  display: flex; align-items: center; justify-content: space-between;
  background: rgb(var(--neutral-bg, 245 247 250)); color: rgb(var(--brand-primary, 4 36 64));
  border: 1px solid rgb(var(--neutral-border, 206 206 206));
  border-radius: var(--radius-sm, 2px);
  padding: 7px 9px; font-size: 12px; font-weight: 700; text-decoration: none; transition: 0.18s ease;
}
.leaflet-container a.ra-airline:hover { background: rgb(var(--brand-accent, 243 197 0)); border-color: rgb(var(--brand-accent, 243 197 0)); color: rgb(var(--on-accent, var(--brand-primary , 4 36 64))); }
.ra-airline__name, .ra-airline__go { display: inline-flex; align-items: center; gap: 5px; }
.ra-airline__go { font-size: 10px; }
/* .leaflet-container a pisa el color dels enllaços del popup: cal més especificitat. */
.leaflet-container a.ra-popup__all {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  margin-top: 9px; background: rgb(var(--brand-primary, 4 36 64)); color: #fff;
  border-radius: var(--radius-sm, 2px);
  padding: 8px 10px; font-size: 12px; font-weight: 700; text-decoration: none; transition: 0.18s ease;
}
.leaflet-container a.ra-popup__all:hover { background: rgb(var(--brand-secondary, 98 142 200)); color: #fff; }
.ra-popup__all .material-icons-outlined { color: rgb(var(--brand-accent, 243 197 0)); }

.ra-popup-wrap { animation: ra-popup-in 0.28s cubic-bezier(0.2, 0.8, 0.2, 1); transform-origin: bottom center; }
@keyframes ra-popup-in { from { opacity: 0; transform: translateY(8px) scale(0.96); } to { opacity: 1; transform: translateY(0) scale(1); } }
@media (prefers-reduced-motion: reduce) {
  .ra-origin-pulse::after, .ra-popup-wrap { animation: none !important; }
  .ra-country, .ra-airport { transition: none !important; }
}

@media (max-width: 700px) {
  .ra-wrap { height: 520px; }
  .ra-toolbar { top: 0.6rem; left: 0.6rem; right: 0.6rem; }
  .ra-panel { padding: 0.5rem 0.75rem; }
  .ra-panel__title { font-size: 0.82rem; }
  .ra-panel__chip { display: none; }
  .ra-stats { width: 100%; justify-content: center; }
}

/* Dins de la card de transport (columna més estreta) */
.comarribar-card .ra-wrap { height: 540px; }
@media (max-width: 700px) { .comarribar-card .ra-wrap { height: 480px; } }

/* ===== Companyies aèries: logos sota el mapa ===== */
.ra-airlines { margin-top: 1.25rem; }
.ra-airlines__lbl {
  display: block; margin-bottom: 0.75rem;
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
  color: rgb(var(--neutral-text-muted, 75 85 99));
}
.ra-airlines__row {
  display: flex; flex-wrap: wrap; align-items: stretch; gap: 0.75rem;
}
.ra-airlines__item {
  /* Els 6 logos es reparteixen tot l'ample del mapa, en una sola fila. */
  display: flex; align-items: center; justify-content: center;
  height: 62px; padding: 0.6rem 0.75rem; flex: 1 1 0; min-width: 0;
  background: #fff;
  border: 1px solid rgb(var(--neutral-border, 206 206 206));
  border-radius: var(--radius-sm, 2px);
  transition: border-color 0.25s, box-shadow 0.25s, transform 0.25s;
}
.ra-airlines__item:hover {
  border-color: rgb(var(--brand-accent, 243 197 0));
  box-shadow: 0 6px 16px rgb(var(--brand-primary, 4 36 64) / 0.12);
  transform: translateY(-2px);
}
.ra-airlines__item img { max-height: 30px; max-width: 100%; width: auto; height: auto; display: block; }
@media (max-width: 767px) {
  /* En mòbil: dues files de 3 */
  .ra-airlines__item { height: 48px; padding: 0.45rem 0.5rem; flex: 1 1 calc(33.333% - 0.5rem); }
  .ra-airlines__item img { max-height: 22px; }
  .ra-airlines__row { gap: 0.5rem; }
}
