/* =========================================
   GLOBAL CONTAINER & BG
   ========================================= */
.structure {
  background: var(--bg-color, #0f2230); 
  color: #fff;
  padding: 110px 0;
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
}

.structure * {
  box-sizing: border-box;
}

/* Grid overlay (Toggled) */
.structure.has-grid::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.02) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(ellipse 80% 70% at 50% 40%, #000 30%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 80% 70% at 50% 40%, #000 30%, transparent 100%);
}

/* Glow overlay (Toggled) */
.structure.has-glow::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 15% 20%, rgba(0,137,166,.25), transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(124,179,66,.18), transparent 45%);
}

.structure > .container {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

/* =========================================
   TEXTS AND LAYOUT
   ========================================= */
.structure-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 60px;
  margin: 0;
  align-items: center;
}

/* REVEAL ANIMATION */
.structure-left {
  opacity: 0;
  transform: translateX(-35px);
  transition: opacity 0.8s cubic-bezier(0.22, 1, 0.36, 1), transform 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

.structure-left.visible {
  opacity: 1;
  transform: translateX(0);
}

/* Texts */
.structure .label {
  font-family: 'Poppins', sans-serif;
  font-size: var(--lbl-size, 13px);
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--label-color, #7fd8e0);
  text-transform: uppercase;
  display: block;
  margin-bottom: 14px;
}

.structure h2 {
  font-family: 'Poppins', sans-serif;
  font-size: var(--title-size, 34px);
  font-weight: 800;
  margin: 0 0 16px;
  color: var(--title-color, #fff);
  line-height: 1.25;
  word-break: break-word;
}

.structure-col p {
  font-family: 'Poppins', sans-serif;
  color: var(--text-color, #b9c8d2);
  font-size: var(--txt-size, 14px);
  line-height: 1.6;
  margin-top: 0;
  margin-bottom: 12px;
}

.structure-col h3 {
  font-family: 'Poppins', sans-serif;
  font-size: var(--sub-size, 18px);
  font-weight: 800;
  margin: 22px 0 8px;
  color: var(--subtitle-color, #fff);
  line-height: 1.35;
}

.region-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

.region-chip {
  padding: 8px 18px;
  border-radius: 20px;
  background: var(--chip-bg, rgba(255,255,255,.07));
  border: 1px solid var(--chip-border, rgba(255,255,255,.15));
  color: var(--chip-text, #dce8ee);
  font-family: 'Poppins', sans-serif;
  font-size: var(--chip-size, 12px);
  font-weight: 700;
  transition: transform 0.25s ease, background 0.25s ease, border-color 0.25s ease, color 0.25s ease, box-shadow 0.25s ease;
  cursor: default;
  -webkit-tap-highlight-color: transparent;
}

.region-chip:hover {
  transform: translateY(-2px);
  background: var(--chip-hover-bg, #0089A6);
  border-color: var(--chip-hover-bg, #0089A6);
  color: var(--chip-hover-text, #fff);
  box-shadow: 0 6px 18px rgba(0,137,166,0.35);
}

/* =========================================
   SVG CHART ANIMATIONS & STYLES
   ========================================= */
.hub-label {
  text-align: center;
  font-family: 'Poppins', sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--svg-label, rgba(255,255,255,.3));
  margin-bottom: 20px;
}

.hub-svg-wrapper {
  width: 100%;
  position: relative;
}

.hub-svg {
  width: 100%;
  height: auto;
  max-width: 500px;
  display: block;
  margin: 0 auto;
}

/* Dynamic SVG coloring */
.hub-svg .chart-lines { stroke: var(--svg-line, rgba(255,255,255,.18)); }
.hub-svg .fill-c1 { fill: var(--chart-c1, #0089A6); }
.hub-svg .fill-c2 { fill: var(--chart-c2, #f4941e); }
.hub-svg .chart-text { fill: var(--svg-text, #dce8ee); font-family: 'Poppins', sans-serif; }
.hub-svg .chart-main-text { font-family: 'Poppins', sans-serif; }

/* Initial Hidden States */
.hub-svg rect { opacity: 0; transform-box: fill-box; transform-origin: center; transform: scaleX(0.85); }
.hub-svg circle { opacity: 0; transform-box: fill-box; transform-origin: center; transform: scale(0); }
.hub-svg text { opacity: 0; }
.hub-svg g line { stroke-dasharray: 600; stroke-dashoffset: 600; } 

/* Trigger Animations via JS class */
.hub-svg.in-view rect { 
  animation-name: hubBoxIn; 
  animation-duration: 0.55s; 
  animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1); 
  animation-fill-mode: forwards; 
}
.hub-svg.in-view .anim-dot { 
  animation-name: hubDotIn; 
  animation-duration: 0.4s; 
  animation-timing-function: ease; 
  animation-fill-mode: forwards; 
}
.hub-svg.in-view text { 
  animation-name: hubTextIn; 
  animation-duration: 0.5s; 
  animation-timing-function: ease; 
  animation-fill-mode: forwards; 
}
.hub-svg.in-view g line { 
  animation-name: hubLineIn; 
  animation-duration: 0.8s; 
  animation-timing-function: ease; 
  animation-fill-mode: forwards; 
}

@keyframes hubBoxIn {
  from { opacity: 0; transform: scaleX(0.85); }
  to { opacity: 1; transform: scaleX(1); }
}
@keyframes hubDotIn {
  from { opacity: 0; transform: scale(0); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes hubTextIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes hubLineIn {
  to { stroke-dashoffset: 0; }
}

/* FIX PARA EDITOR HUBSPOT */
{% if is_in_editor %}
  .structure-left { opacity: 1 !important; transform: none !important; }
  .hub-svg rect, .hub-svg circle, .hub-svg text { opacity: 1 !important; transform: none !important; }
  .hub-svg g line { stroke-dashoffset: 0 !important; }
{% endif %}

/* =========================================
   RESPONSIVE DESIGN (TABLETS Y MÓVILES)
   ========================================= */

@media (max-width: 980px) {
  .structure {
    padding: 60px 0 70px;
  }

  .structure-grid {
    grid-template-columns: 1fr;
    gap: 40px;
  }

  /* Animación vertical en móvil para no desbordar */
  .structure-left {
    transform: translateY(24px);
  }

  .structure-left.visible {
    transform: translateY(0);
  }

  .hub-svg {
    margin-top: 10px;
  }
}

@media (max-width: 640px) {
  .structure {
    padding: 45px 0 55px;
  }

  .structure > .container {
    padding: 0 16px;
  }

  .structure h2 {
    font-size: clamp(24px, 6.5vw, 30px);
    margin-bottom: 14px;
  }

  .structure-col h3 {
    font-size: 17px;
    margin-top: 18px;
  }

  .region-chips {
    gap: 8px;
    margin-top: 18px;
  }

  .region-chip {
    padding: 7px 14px;
    font-size: 11.5px;
  }

  .hub-label {
    font-size: 10px;
    margin-bottom: 14px;
  }
}

/* En teléfonos estrechos (<500px), el diagrama mantiene un tamaño legible con scroll táctil suave */
@media (max-width: 500px) {
  .hub-svg-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 12px;
  }

  .hub-svg-wrapper::-webkit-scrollbar {
    height: 4px;
  }

  .hub-svg-wrapper::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
  }

  .hub-svg {
    min-width: 420px;
  }
}