/* =========================================
   1. RESET (LIBERACIÓN DE SCROLL)
   ========================================= */
body, html {
    margin: 0; 
    padding: 0; 
    background-color: #ffffff; 
    font-family: 'Arial', sans-serif;
}

/* =========================================
   2. HEADER DEL ESPECIAL
   ========================================= */
.special-header {
    max-width: 900px; 
    margin: 60px auto 40px auto;
    padding: 0 20px;
    text-align: center;
}

.kicker { margin-bottom: 25px; display: flex; justify-content: center; align-items: center; }
.kicker img { height: 35px; width: auto; display: block; max-width: 100%; }

.headline {
    font-family: 'Georgia', 'Times New Roman', serif; 
    font-size: 76px; font-weight: 900; color: #111;
    line-height: 1.05; margin-top: 0; margin-bottom: 5px;
    letter-spacing: -1.5px; 
}

.subheadline {
    font-family: 'Georgia', 'Times New Roman', serif;
    font-size: 46px; font-weight: 400; color: #444;
    line-height: 1.15; margin-top: 0; margin-bottom: 30px;
    letter-spacing: -0.5px;
}

.intro-text {
    font-size: 18px; color: #444; line-height: 1.6;
    margin-bottom: 25px; max-width: 750px; margin-left: auto; margin-right: auto;
}

.header-divider { width: 50px; height: 1px; background-color: #333; margin: 30px auto 15px auto; }
.date-published { font-size: 14px; color: #444; letter-spacing: normal; }

.social-share-container { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 15px; }
.social-btn {
    display: flex; justify-content: center; align-items: center;
    width: 38px; height: 38px; border: 1px solid #333;
    border-radius: 4px; color: #333; text-decoration: none;
    background-color: transparent; transition: all 0.2s ease;
}
.social-btn:hover { background-color: #333; color: #ffffff; transform: translateY(-2px); }

/* =========================================
   3. TEXTO EDITORIAL & CAJAS DE INSTRUCCIÓN
   ========================================= */
.story-text { max-width: 700px; margin: 0 auto; padding: 0 20px; }
.story-text p { font-family: 'Arial', sans-serif; font-size: 18px; line-height: 1.6; color: #333; margin-bottom: 20px; }
.story-text h2 { font-family: 'Georgia', serif; font-size: 26px; font-weight: bold; color: #111; margin-top: 50px; margin-bottom: 20px; }

.story-image-container { margin: 50px auto; max-width: 900px; padding: 0 20px; box-sizing: border-box; }
.story-image { width: 100%; height: auto; display: block; border-radius: 4px; box-shadow: 0 4px 15px rgba(0,0,0,0.05); }
.story-image-caption { font-family: 'Arial', sans-serif; font-size: 13px; color: #777; margin-top: 12px; line-height: 1.4; text-align: left; border-bottom: 1px solid #eaeaea; padding-bottom: 10px; }

.instrucciones-caja {
    max-width: 650px; margin-top: 50px !important; margin: 10px auto 30px auto;
    background-color: #f9f9f9; border: 1px solid #eaeaea; border-left: 4px solid #111;
    padding: 15px 20px; border-radius: 0 4px 4px 0; font-family: 'Arial', sans-serif;
}
.instrucciones-titulo { color: #111; font-weight: 900; font-size: 15px; display: block; margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.5px; }
.instrucciones-caja ul { margin: 0; padding-left: 20px; }
.instrucciones-caja li { font-size: 14px; line-height: 1.5; margin-bottom: 8px; color: #444; }
.instrucciones-caja li:last-child { margin-bottom: 0; }
.instrucciones-caja li strong { color: #111; }

/* =========================================
   4. CONTENEDOR DEL INTERACTIVO (FASE 1)
   ========================================= */
.viz-container {
    position: relative; width: 100%; height: 860px; min-height: 860px; 
    background-color: transparent; overflow: hidden; margin: 10px 0 30px 0; 
}
#map { width: 100%; height: 100%; background-color: transparent !important; }

/* =========================================
   5. CONTROLES Y UI DEL MAPA
   ========================================= */
.ui-element {
    position: absolute; z-index: 3000; background: white;
    border: 1.5px solid #000; color: #000; font-weight: 900; text-transform: uppercase;
    box-shadow: 3px 3px 0px rgba(0,0,0,0.1);
}
.controls-container {
    top: 20px; left: 19%; display: flex; padding: 0; 
    border: 1.5px solid #ccc !important; border-radius: 4px; 
    overflow: hidden; box-shadow: 2px 2px 5px rgba(0,0,0,0.1) !important;
}
.control-btn {
    background: white; border: none; border-right: 1px solid #ccc; 
    padding: 8px 12px; font-size: 14px; cursor: pointer;
    transition: background-color 0.2s, opacity 0.2s, color 0.2s;
    color: #000; display: flex; justify-content: center; align-items: center;
}
.control-btn:last-child { border-right: none; }
.control-btn:disabled { opacity: 0.3; cursor: not-allowed; background-color: #fafafa; }
.control-btn.main-btn { font-weight: 900; width: 45px; font-size: 16px; background-color: #333; color: #fff; }
.control-btn:hover:not(:disabled) { background-color: #f0f0f0; }
.control-btn.main-btn:hover:not(:disabled) { background-color: #111; color: #fff; }

.year-label { top: 20px; left: 50%; transform: translateX(-50%); padding: 10px 20px; font-size: 18px; }

/* =========================================
   6. TARJETAS DE CANDIDATOS
   ========================================= */
.cand-info-container { display: flex; flex-direction: column; }
.cand-name { font-weight: 900; color: #000; text-transform: uppercase; line-height: 1; }
.cand-party { color: #666; text-transform: uppercase; font-weight: 400; letter-spacing: 1.5px; }
.cand-pct { font-weight: 900; display: flex; align-items: center; color: #000; }
.dot { border-radius: 3px; }

.candidate-big { position: absolute; z-index: 2500; top: 50%; transform: translateY(-50%); width: 250px; text-align: center; align-items: center; display: flex; flex-direction: column; }
.pos-left { left: 13%; } .pos-right { right: 13%; }
.candidate-big .photo { width: 170px; height: 170px; border-radius: 50%; background-color: transparent; border: 1.5px solid #d1d1d1; box-shadow: 0 6px 12px rgba(0,0,0,0.1); margin-bottom: 12px; }
.candidate-big .cand-info-container { align-items: center; text-align: center; }
.candidate-big .cand-name { font-size: 24px; margin-bottom: 4px; }
.candidate-big .cand-party { font-size: 12px; margin-bottom: 8px; }
.candidate-big .cand-pct { font-size: 32px; justify-content: center; }
.candidate-big .dot { width: 16px; height: 16px; margin: 0 12px; }

.bottom-legend-container { position: absolute; bottom: 60px; left: 50%; transform: translateX(-50%); z-index: 2500; display: flex; gap: 40px; flex-wrap: wrap; justify-content: center; }
.candidate-small { display: flex; align-items: center; background: rgba(255,255,255,0.8); padding: 5px 10px; border-radius: 4px; text-align: left; }
.candidate-small .photo { width: 50px; height: 50px; border-radius: 50%; background-color: transparent; border: 1px solid #d1d1d1; box-shadow: 0 2px 4px rgba(0,0,0,0.1); margin-right: 10px; }
.candidate-small .cand-info-container { align-items: flex-start; text-align: left; }
.candidate-small .cand-name { font-size: 16px; margin-bottom: 2px;}
.candidate-small .cand-party { font-size: 9px; margin-bottom: 4px;}
.candidate-small .cand-pct { font-size: 20px; justify-content: flex-start; }
.candidate-small .dot { width: 12px; height: 12px; margin-right: 8px; }

/* =========================================
   7. MAPA, POPUPS Y EXTRANJERO
   ========================================= */
.leaflet-container { background: transparent !important; }
.pex-globe-container { display: flex; flex-direction: column; align-items: center; cursor: pointer; }
.pex-globe { width: 60px; height: 60px; border-radius: 50%; background-image: url('fotos/mundo.png'); background-size: 115%; background-position: center; background-repeat: no-repeat; background-color: #eeeeee; border: 1px solid rgba(0, 0, 0, 0.15); box-shadow: 0 4px 8px rgba(0,0,0,0.2); margin-bottom: 5px; transition: background-color 0.4s ease-in-out !important; }
.pex-globe-container:hover .pex-globe { transform: scale(1.08); }
.pex-label { font-weight: 900; font-size: 11px; color: #333; text-transform: uppercase; text-align: center; letter-spacing: 1px; pointer-events: none; text-shadow: 1px 1px 0px rgba(255,255,255,0.8); }

.leaflet-popup-content-wrapper { border-radius: 0px; border: 1px solid #000; padding: 2px; }
.popup-region { font-weight: 900; text-transform: uppercase; font-size: 14px; border-bottom: 1px solid #eee; margin-bottom: 5px; padding-bottom: 3px; display: block; }
.popup-local-winner { font-weight: 900; font-size: 13px; color: #111; background-color: #f0f0f0; padding: 3px 5px; margin-bottom: 3px; border-radius: 3px; display: inline-block; }
.popup-historical-note { font-size: 12px; color: #555; font-style: italic; line-height: 1.3; padding-top: 5px; max-width: 180px; }
.popup-party { font-size: 10px; color: #666; display: block; margin-bottom: 2px; }
.popup-pct { font-size: 18px; font-weight: 900; display: flex; align-items: baseline; gap: 4px; }
.popup-pct-label { font-size: 10px; font-weight: 400; color: #444; }

path.leaflet-interactive { transition: fill 0.8s ease-in-out, stroke 0.8s ease-in-out !important; }

/* =========================================
   8. NOTAS DE CONTEXTO DINÁMICAS
   ========================================= */
.year-context-note {
    position: absolute; top: 70px; left: 50%; transform: translateX(-50%); z-index: 3500;
    background-color: rgba(255, 255, 255, 0.95); border-left: 4px solid #111; padding: 10px 15px;
    width: 90%; max-width: 600px; font-family: 'Arial', sans-serif; font-size: 13px; line-height: 1.5;
    color: #333; box-shadow: 0 4px 10px rgba(0,0,0,0.15); border-radius: 4px; text-align: left; display: none; 
}
.year-context-note strong { color: #000; font-weight: 900; display: block; margin-bottom: 4px; text-transform: uppercase; font-size: 11px; letter-spacing: 1px; }

/* =========================================
   9. COMBO VISUAL (FASE 2)
   ========================================= */
.combo-visual-container { display: flex; max-width: 1200px; margin: 40px auto; gap: 30px; padding: 0 20px; align-items: stretch; justify-content: center; }
.columna-mitad { flex: 1; min-width: 320px; display: flex; flex-direction: column; justify-content: flex-start; }
.anio-titulo { font-family: 'Georgia', serif; font-size: 22px; font-weight: bold; color: #333; margin-bottom: 15px; text-align: center; }
.mapa-impacto-box { width: 100%; height: 450px; background-color: transparent; z-index: 1; }
.grafico-wrapper { width: 100%; height: 400px; background-color: #fff; }
.columna-leyenda { flex: 0 0 160px; display: flex; flex-direction: column; justify-content: center; gap: 15px; }
.leyenda-item { display: flex; align-items: center; gap: 12px; cursor: pointer; font-family: 'Arial', sans-serif; font-size: 13px; font-weight: 900; color: #333; transition: opacity 0.2s ease, background-color 0.2s ease; padding: 6px; border-radius: 6px; }
.leyenda-item:hover { background-color: #f0f0f0; }
.leyenda-color { width: 24px; height: 24px; border-radius: 4px; border: 1px solid rgba(0,0,0,0.1); }

/* =========================================
   10. FASE 3: PARTICIPACIÓN
   ========================================= */
.participacion-wrapper { max-width: 1200px; margin: 0 auto 60px auto; }
.slider-container { width: 100%; max-width: 1100px; margin: 0 auto; padding: 0 20px; text-align: center; }
.fase3-title { font-family: 'Georgia', serif; font-size: 28px; font-weight: bold; color: #111; display: inline-block; margin-bottom: 15px; background-color: #f0f0f0; padding: 5px 15px; border-radius: 4px; }
.custom-slider { -webkit-appearance: none; appearance: none; width: 100%; height: 8px; border-radius: 4px; background: #d1d1d1; outline: none; margin-bottom: 20px; }
.custom-slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 24px; height: 24px; border-radius: 50%; background: #0047ab; cursor: pointer; box-shadow: 0 2px 5px rgba(0,0,0,0.2); transition: transform 0.1s; }
.custom-slider::-webkit-slider-thumb:hover { transform: scale(1.2); }
#mapa-fase3 { width: 100%; height: 500px; background-color: transparent !important; }
#mapa-fase3 path.leaflet-interactive { stroke: #444444 !important; stroke-width: 0.8px !important; transition: fill 0.4s ease !important; }

/* Ajustes de espaciado Fase 3 (Solo Escritorio) */
.fase3-combo { margin-top: 10px; margin-bottom: -75px; }
.source-fase3 { margin-top: 20px; }

/* =========================================
   11. FUENTE DE DATOS Y CRÉDITOS
   ========================================= */
.source-note { font-family: 'Arial', sans-serif; font-size: 12px; color: #888888; max-width: 1200px; margin: 10px auto 50px auto; padding: 0 20px; text-align: center; line-height: 1.4; }
.source-fase1 { position: absolute; bottom: 30px; left: 50%; transform: translateX(-50%); z-index: 3000; margin: 0; width: 90%; text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.9), -1px -1px 2px rgba(255, 255, 255, 0.9); }
.editor-note-fase1 { position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); z-index: 3000; width: 90%; text-align: center; font-family: 'Arial', sans-serif; font-size: 11px; color: #555; display: none; }

.special-credits-black { background-color: #111111; color: #ffffff; padding: 70px 20px; text-align: center; margin-top: 60px; }
.credits-logo-container { margin-bottom: 40px; }
.credits-logo-container img { height: 75px; width: auto; display: block; margin: 0 auto; filter: brightness(0) invert(1); }
.copyright-text { font-family: 'Arial', sans-serif; font-size: 11px; color: #777777; margin-top: 15px; letter-spacing: 0.5px; }
.credits-main-title { font-family: 'Georgia', 'Times New Roman', serif; font-size: 22px; font-weight: bold; text-transform: uppercase; letter-spacing: 2px; margin-top: 0; margin-bottom: 40px; color: #ffffff; }
.credit-block { margin-bottom: 25px; display: flex; flex-direction: column; align-items: center; }
.credit-role { font-family: 'Arial', sans-serif; font-size: 11px; font-weight: bold; text-transform: uppercase; color: #aaaaaa; margin-bottom: 5px; letter-spacing: 1.5px; }
.credit-name { font-family: 'Georgia', serif; font-size: 18px; color: #ffffff; }

/* =========================================
   12. MEDIA QUERIES (TABLETS Y MOVILES)
   ========================================= */

@media (max-width: 850px) {
    /* Ajustes generales de bloqueo */
    body, html { overflow-x: hidden; }

    /* Fase 2: Combo visual */
    .combo-visual-container { flex-direction: column; align-items: center; gap: 20px; margin: 20px auto; }
    .columna-mitad { width: 100%; min-width: 100%; }
    .mapa-impacto-box { height: 350px; }
    .grafico-wrapper { height: 300px; }
    .columna-leyenda { flex-direction: row; flex-wrap: wrap; width: 100%; justify-content: center; margin: 10px 0; gap: 8px; }
    .leyenda-item { flex: 0 0 auto; font-size: 11px; padding: 4px; }
    .leyenda-color { width: 16px; height: 16px; }

    /* Fase 3: Participación */
    #mapa-fase3 { height: 350px; margin-bottom: 20px; }
    .slider-container { padding: 0 10px; box-sizing: border-box; }
    .custom-slider { width: 95%; }
    .fase3-title { font-size: 20px; }
    .fase3-combo { margin-bottom: 10px !important; }
    .source-fase3 { margin-top: 95px !important; margin-bottom: -40px; }
}

@media (max-width: 768px) {
    /* Header y Textos */
    .headline { font-size: 40px; letter-spacing: -0.5px; line-height: 1.1; margin-top: 20px;}
    .subheadline { font-size: 24px; margin-bottom: 20px; }
    .intro-text { font-size: 16px; }
    .story-text p { font-size: 16px; }
    .special-header { margin-top: 30px; }
    
    /* Fase 1: Mapa Principal */
    .viz-container { height: 620px; min-height: 620px; margin: 20px 0 30px 0; }
    .controls-container { top: 10px; left: 50%; transform: translateX(-50%) scale(0.70); transform-origin: center top; width: max-content; }
    .year-label { top: 50px; left: 50%; transform: translateX(-50%); font-size: 12px; padding: 4px 10px; white-space: nowrap; }
    
    .candidate-big { width: 110px; top: auto; bottom: 80px; transform: translateY(0); }
    .pos-left { left: 0%; } .pos-right { right: 0%; }
    .candidate-big .photo { width: 65px; height: 65px; margin-bottom: 5px; }
    .candidate-big .cand-info-container { align-items: center; }
    .candidate-big .cand-name { font-size: 9px; text-align: center; line-height: 1.1; margin-bottom: 4px; }
    .candidate-big .cand-party { display: none; }
    .candidate-big .cand-pct { font-size: 16px; justify-content: center; display: flex; align-items: center; }
    .candidate-big .dot { width: 12px; height: 12px; border-radius: 2px; margin: 0 5px 0 0; } 

    .bottom-legend-container { gap: 10px; bottom: 35px; width: 100%; flex-wrap: nowrap; justify-content: center; }
    .candidate-small { padding: 0; background: transparent; flex-direction: column; text-align: center; width: 85px; }
    .candidate-small .photo { width: 35px; height: 35px; margin: 0 auto 3px auto;}
    .candidate-small .cand-info-container { align-items: center; text-align: center; }
    .candidate-small .cand-name { font-size: 8px; margin-bottom: 2px; line-height: 1.1; font-weight: 900;}
    .candidate-small .cand-party { display: none; }
    .candidate-small .cand-pct { font-size: 12px; justify-content: center; font-weight: 900;}
    .candidate-small .dot { display: none; } 
    
    .source-fase1 { bottom: 10px; font-size: 10px; }
    .editor-note-fase1 { bottom: 10px; }

    .pex-globe { width: 45px !important; height: 45px !important; border:1px solid rgba(0, 0, 0, 0.15) !important; margin-bottom: 2px; }
    .pex-label { font-size: 9px !important; line-height: 1.1; letter-spacing: 0px; }
    
    .year-context-note { top: 80px; font-size: 13px; padding: 10px 15px; }
    
    .instrucciones-caja { margin: 10px 20px 20px 20px; padding: 12px 15px; }
    .instrucciones-caja li { font-size: 13px; }

    /* Footer */
    .special-credits-black { padding: 40px 15px; }
    .credits-main-title { font-size: 18px; margin-bottom: 30px; }
    .credit-name { font-size: 16px; }
    .copyright-text { font-size: 9px; }
}