@import url('https://fonts.googleapis.com/css2?family=Google+Sans:ital,wght@0,300;0,400;0,500;0,700;1,400&family=Plus+Jakarta+Sans:ital,wght@0,200;0,300;0,400;0,500;0,700;1,400&display=swap');

@font-face {
  font-family: 'M PLUS U Numbers';
  font-style: normal;
  font-weight: 300;
  src: url(https://fonts.gstatic.com/s/mplusu/v1/-W_gXJfyAgH86Tq6MsATZrf75i4iYyIxdEc-qg.ttf) format('truetype');
  unicode-range: U+30-39, U+2C, U+2E, U+25, U+2B, U+2D, U+2212;
}
@font-face {
  font-family: 'M PLUS U Numbers';
  font-style: normal;
  font-weight: 400;
  src: url(https://fonts.gstatic.com/s/mplusu/v1/-W_gXJfyAgH86Tq6MsATZrf75i4iYyIxKkc-qg.ttf) format('truetype');
  unicode-range: U+30-39, U+2C, U+2E, U+25, U+2B, U+2D, U+2212;
}
@font-face {
  font-family: 'M PLUS U Numbers';
  font-style: normal;
  font-weight: 500;
  src: url(https://fonts.gstatic.com/s/mplusu/v1/-W_gXJfyAgH86Tq6MsATZrf75i4iYyIxGEc-qg.ttf) format('truetype');
  unicode-range: U+30-39, U+2C, U+2E, U+25, U+2B, U+2D, U+2212;
}
@font-face {
  font-family: 'M PLUS U Numbers';
  font-style: normal;
  font-weight: 700;
  src: url(https://fonts.gstatic.com/s/mplusu/v1/-W_gXJfyAgH86Tq6MsATZrf75i4iYyIxzUA-qg.ttf) format('truetype');
  unicode-range: U+30-39, U+2C, U+2E, U+25, U+2B, U+2D, U+2212;
}

/* Variables de Diseño */
:root {
  --color-hueso: #f2f2f2;
  --color-ink: #1a1a1a;
  --color-terracota: #d96c5b;
  --color-salvia: #ff6e5f;
  --color-cobalto: #4a6984;
  --font-serif: 'M PLUS U Numbers', 'Google Sans', 'Plus Jakarta Sans', sans-serif;
  --font-sans: 'M PLUS U Numbers', 'Google Sans', 'Plus Jakarta Sans', sans-serif;
}

/* Reset y Base */
body {
  background-color: var(--color-hueso);
  color: var(--color-ink);
  font-family: var(--font-sans);
  overflow-x: hidden;
  cursor: auto; /* Show default cursor */
}

/* Tipografía Editorial */
.font-editorial-title {
  font-family: var(--font-serif);
  font-weight: 700;
}

.font-editorial-num {
  font-family: var(--font-serif);
}

/* Canvas Infinito: Sin tarjetas, flotando sobre el fondo */
.editorial-grid {
  grid-template-columns: repeat(12, minmax(0, 1fr));
}

.editorial-divider {
  border-top: 1px solid rgba(26, 26, 26, 0.08);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--color-hueso);
}
::-webkit-scrollbar-thumb {
  background: rgba(26, 26, 26, 0.15);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(26, 26, 26, 0.3);
}

/* Cursor Personalizado: Polígono Fluido */
#custom-cursor {
  position: fixed;
  top: 0;
  left: 0;
  width: 24px;
  height: 24px;
  background-color: rgba(26, 26, 26, 0.15); /* Gris oscuro translúcido */
  border: 1px solid rgba(26, 26, 26, 0.4);
  border-radius: 50%;
  pointer-events: none;
  z-index: 9999;
  transform: translate(-50%, -50%);
  transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1), 
              height 0.4s cubic-bezier(0.16, 1, 0.3, 1), 
              border-radius 0.4s cubic-bezier(0.16, 1, 0.3, 1),
              background-color 0.4s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0.4s cubic-bezier(0.16, 1, 0.3, 1),
              opacity 0.25s ease;
  opacity: 0;
  mix-blend-mode: multiply;
  will-change: transform, width, height, border-radius, background-color, border-color, opacity;
}

/* Hover de Cursor para abrazar elementos */
#custom-cursor.hovering-bar {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background-color: rgba(74, 105, 132, 0.2); /* Cobalto */
  border-color: rgba(74, 105, 132, 0.6);
}

#custom-cursor.hovering-map {
  width: 40px;
  height: 40px;
  border-radius: 35% 65% 55% 45% / 45% 55% 45% 55%; /* Forma orgánica */
  background-color: rgba(255, 110, 95, 0.25); /* Salvia -> ff6e5f */
  border-color: rgba(255, 110, 95, 0.7);
}

#custom-cursor.hovering-clickable {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: rgba(26, 26, 26, 0.8);
  border-color: rgba(26, 26, 26, 1);
}

/* Deshabilitar cursor personalizado en dispositivos táctiles */
@media (hover: none) and (pointer: coarse) {
  #custom-cursor {
    display: none !important;
  }
}

/* Texto base ligeramente más grande en móvil */
@media (max-width: 767px) {
  p.font-sans,
  p.font-serif,
  p {
    font-size: 0.9375rem; /* 15px en vez de 14px */
    line-height: 1.7;
  }
}

/* Gráfico ODS a ancho completo en móvil.
   Usa left:50% + translateX(-50%) en lugar de márgenes negativos
   porque body tiene overflow-x:hidden que bloquea el break-out clásico. */
.ods-fullwidth-mobile {
  position: relative;
  width: 100vw;
  left: 50%;
  transform: translateX(-50%);
}
@media (min-width: 768px) {
  .ods-fullwidth-mobile {
    position: static;
    width: 100%;
    left: auto;
    transform: none;
  }
}

/* Corchetes de Enfoque */
.focus-bracket {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 12px;
  transition: all 0.3s ease;
}

.focus-bracket::before,
.focus-bracket::after {
  content: '';
  position: absolute;
  top: 4px;
  bottom: 4px;
  width: 6px;
  border: 1px solid var(--color-ink);
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.19, 1, 0.22, 1), opacity 0.3s ease;
  pointer-events: none;
}

.focus-bracket::before {
  left: 2px;
  border-right: none;
  transform: translateX(4px);
}

.focus-bracket::after {
  right: 2px;
  border-left: none;
  transform: translateX(-4px);
}

.focus-bracket.active {
  color: var(--color-ink);
  font-weight: 600;
}

.focus-bracket.active::before {
  opacity: 1;
  transform: translateX(-2px);
}

.focus-bracket.active::after {
  opacity: 1;
  transform: translateX(2px);
}

/* Tooltip minimalista editorial */
.editorial-tooltip {
  position: absolute;
  z-index: 1000;
  background-color: var(--color-hueso);
  color: var(--color-ink);
  border: 1px solid rgba(26, 26, 26, 0.15);
  padding: 8px 12px;
  font-size: 11px;
  font-family: var(--font-sans);
  pointer-events: none;
  opacity: 0;
  transform: scale(0.95);
  transition: opacity 0.15s ease, transform 0.15s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

/* Hide scrollbar for Chrome, Safari and Opera */
.scrollbar-none::-webkit-scrollbar {
  display: none;
}
/* Hide scrollbar for IE, Edge and Firefox */
.scrollbar-none {
  -ms-overflow-style: none;  /* IE and Edge */
  scrollbar-width: none;  /* Firefox */
}

/* Texture Editorial (Noise/Grain) overlay */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
  opacity: 0.025; /* extremely sutil 2.5% opacity */
  pointer-events: none;
  z-index: 9999;
}

/* Custom premium toggle switch in very dark gray */
.switch-track {
  width: 38px;
  height: 20px;
  background-color: rgba(26, 26, 26, 0.15); /* Light gray unchecked */
  border-radius: 9999px;
  position: relative;
  transition: background-color 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-block;
  flex-shrink: 0;
}

.switch-thumb {
  width: 16px;
  height: 16px;
  background-color: #ffffff;
  border-radius: 50%;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

input:checked + .switch-track {
  background-color: #1a1a1a; /* Very dark gray (ink color) when checked */
}

input:checked + .switch-track .switch-thumb {
  transform: translateX(18px);
}

/* Animated switch pill in Hero */
@keyframes hero-switch-slide {
  0%, 100% {
    transform: translateX(0);
  }
  50% {
    transform: translateX(24px);
  }
}

.animate-hero-switch {
  animation: hero-switch-slide 2.2s ease-in-out infinite;
}

/* Contenedor de bloque */
.block-banner {
  scroll-margin-top: 7.5rem; /* Margen superior elegante al navegar */
}

/* Pastillas de Bloques (Banner Pills) - Animaciones y Estados */
.banner-pill {
  display: block;
  height: 12px;
  border-radius: 9999px;
  transition: width 0.7s cubic-bezier(0.16, 1, 0.3, 1), 
              background-color 0.7s cubic-bezier(0.16, 1, 0.3, 1),
              opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: width, background-color, opacity, transform;
}

.banner-pill:hover {
  transform: scale(1.1);
  opacity: 0.8;
}

/* Bloque 1 - Previous state (pre-activation / all unvisited) */
#bloque-1 .pill-1 { width: 24px; background-color: rgba(26, 26, 26, 0.2); }
#bloque-1 .pill-2 { width: 24px; background-color: rgba(26, 26, 26, 0.2); }
#bloque-1 .pill-3 { width: 24px; background-color: rgba(26, 26, 26, 0.2); }

/* Bloque 1 - Active (in-view) */
#bloque-1.in-view .pill-1 { width: 48px; background-color: rgba(26, 26, 26, 1); }
#bloque-1.in-view .pill-2 { width: 24px; background-color: rgba(26, 26, 26, 0.2); }
#bloque-1.in-view .pill-3 { width: 24px; background-color: rgba(26, 26, 26, 0.2); }

/* Bloque 2 - Previous state (pre-activation / Bloque 1 state) */
#bloque-2 .pill-1 { width: 48px; background-color: rgba(26, 26, 26, 1); }
#bloque-2 .pill-2 { width: 24px; background-color: rgba(26, 26, 26, 0.2); }
#bloque-2 .pill-3 { width: 24px; background-color: rgba(26, 26, 26, 0.2); }

/* Bloque 2 - Active (in-view) */
#bloque-2.in-view .pill-1 { width: 24px; background-color: rgba(26, 26, 26, 1); }
#bloque-2.in-view .pill-2 { width: 48px; background-color: rgba(26, 26, 26, 1); }
#bloque-2.in-view .pill-3 { width: 24px; background-color: rgba(26, 26, 26, 0.2); }

/* Bloque 3 - Previous state (pre-activation / Bloque 2 state) */
#bloque-3 .pill-1 { width: 24px; background-color: rgba(26, 26, 26, 1); }
#bloque-3 .pill-2 { width: 48px; background-color: rgba(26, 26, 26, 1); }
#bloque-3 .pill-3 { width: 24px; background-color: rgba(26, 26, 26, 0.2); }

/* Bloque 3 - Active (in-view) */
#bloque-3.in-view .pill-1 { width: 24px; background-color: rgba(26, 26, 26, 1); }
#bloque-3.in-view .pill-2 { width: 24px; background-color: rgba(26, 26, 26, 1); }
#bloque-3.in-view .pill-3 { width: 48px; background-color: rgba(26, 26, 26, 1); }

/* Modo Impresión Editorial (A4 Perfect Layout) */
@media print {
  @page {
    size: A4 portrait;
    margin: 1.6cm 1.2cm;
  }
  
  body {
    background-color: #ffffff !important;
    background-image: none !important;
    color: #1a1a1a !important;
    font-size: 11px;
    line-height: 1.5;
    cursor: default !important;
  }

  body::before {
    display: none !important;
  }

  /* Force printing color backgrounds/borders */
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Hide interactive elements */
  #custom-cursor,
  #preloader,
  .no-print,
  #timeline-wrapper,
  .filter-controls,
  button,
  select,
  header,
  footer {
    display: none !important;
  }

  /* Grid stacking */
  .grid {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 1.5rem !important;
  }

  /* Specific grids that shouldn't collapse */
  #kpi-grid {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 1rem !important;
  }

  .kpi {
    border-left: 2px solid rgba(26, 26, 26, 0.15) !important;
    border-bottom: none !important;
    padding-left: 0.75rem !important;
    margin-bottom: 0 !important;
  }

  /* Layout pages, sections, breaks */
  section {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    margin-bottom: 2.5rem !important;
    padding-top: 1rem !important;
    border-top: 1px solid rgba(26, 26, 26, 0.08) !important;
  }

  .editorial-divider {
    border-top: 1px solid rgba(26, 26, 26, 0.1) !important;
  }

  h1, h2, h3, h4, h5 {
    color: #1a1a1a !important;
    page-break-after: avoid !important;
    break-after: avoid !important;
  }

  /* Force printable chart heights */
  #chart-evolucion,
  #chart-age-ccaa,
  #chart-geo-pais,
  #chart-map,
  #chart-renta,
  #chart-instrumentos,
  #chart-ods {
    width: 100% !important;
    height: 300px !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  /* Tall ODS chart needs slightly more height to fit 17 items neatly */
  #chart-ods {
    height: 480px !important;
  }
  
  /* Make sure text elements have direct high contrast */
  p, span, div, strong, th, td, label {
    color: #1a1a1a !important;
  }
}
