/* ==========================================================================
   Mapa Interactivo de Universidades Mineras - Estilos
   ========================================================================== */

/* Contenedor principal */
.mapa-container {
    position: relative;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    line-height: 0;
}

.mapa-container img.mapa-fondo {
    width: 100%;
    height: auto;
    display: block;
}

/* SVG overlay */
.mapa-svg-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
}

/* ── Marcadores/Pins (teardrop style) ── */

/* Área invisible de hover */
.marcador-ccaa .hit-area {
    fill: transparent;
    cursor: pointer;
}

/* Teardrop pin shape */
.marcador-ccaa .pin-teardrop {
    stroke: #ffffff;
    stroke-width: 2;
    cursor: pointer;
    filter: url(#pin-shadow);
    transition: transform 0.2s ease;
    transform-origin: 0 0;
}

/* Inner dot */
.marcador-ccaa .pin-inner {
    fill: #ffffff;
    pointer-events: none;
}

/* Pulse ring */
.marcador-ccaa .pulse-ring {
    fill: transparent;
    stroke-width: 2;
    opacity: 0;
    pointer-events: none;
    animation: pulse-anim 2.5s ease-out infinite;
}

@keyframes pulse-anim {
    0% { r: 10; opacity: 0.6; }
    100% { r: 30; opacity: 0; }
}

/* ── Pin type colors ── */

/* Grado y Máster - Verde */
.marcador-ccaa.tipo-grado_y_master .pin-teardrop { fill: #2D7D2D; }
.marcador-ccaa.tipo-grado_y_master .pulse-ring { stroke: #2D7D2D; }

/* Grado - Azul */
.marcador-ccaa.tipo-grado .pin-teardrop { fill: #1565C0; }
.marcador-ccaa.tipo-grado .pulse-ring { stroke: #1565C0; }

/* Máster - Magenta */
.marcador-ccaa.tipo-master .pin-teardrop { fill: #C2185B; }
.marcador-ccaa.tipo-master .pulse-ring { stroke: #C2185B; }

/* ── Hover / active states ── */
.marcador-ccaa:hover .pin-teardrop,
.marcador-ccaa.active .pin-teardrop {
    transform: scale(1.2);
}

.marcador-ccaa.tipo-grado_y_master:hover .pin-teardrop,
.marcador-ccaa.tipo-grado_y_master.active .pin-teardrop { fill: #1B5E1B; }

.marcador-ccaa.tipo-grado:hover .pin-teardrop,
.marcador-ccaa.tipo-grado.active .pin-teardrop { fill: #0D47A1; }

.marcador-ccaa.tipo-master:hover .pin-teardrop,
.marcador-ccaa.tipo-master.active .pin-teardrop { fill: #AD1457; }

.marcador-ccaa:hover .pulse-ring,
.marcador-ccaa.active .pulse-ring {
    animation: none;
    opacity: 0;
}

/* ── Tooltip ── */
.mapa-tooltip {
    position: absolute;
    z-index: 100;
    background: #ffffff;
    border-radius: 10px;
    padding: 20px 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    border-left: 4px solid #2D7D2D;
    max-width: 380px;
    min-width: 280px;
    pointer-events: none;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    line-height: 1.5;
}

.mapa-tooltip.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.mapa-tooltip .tooltip-ccaa {
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    font-size: 17px;
    color: #2D7D2D;
    margin: 0 0 12px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid #e0e0e0;
}

.mapa-tooltip .tooltip-uni {
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid #f0f0f0;
}

.mapa-tooltip .tooltip-uni:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.mapa-tooltip .uni-nombre {
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    font-size: 14px;
    color: #1d1d1d;
    margin: 0 0 2px 0;
}

.mapa-tooltip .uni-escuela {
    font-family: 'Montserrat', sans-serif;
    font-size: 12.5px;
    font-weight: 500;
    color: #555;
    margin: 0 0 6px 0;
    font-style: italic;
}

/* Contact info */
.mapa-tooltip .uni-contacto {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-bottom: 8px;
    font-family: 'Montserrat', sans-serif;
    font-size: 12px;
}

.mapa-tooltip .uni-contacto a {
    color: #444;
    text-decoration: none;
    transition: color 0.2s;
}

.mapa-tooltip .uni-contacto a:hover {
    color: #2D7D2D;
}

.mapa-tooltip .uni-tel::before { content: '\260E\FE0F '; }
.mapa-tooltip .uni-email-link::before { content: '\2709\FE0F '; }
.mapa-tooltip .uni-web-link::before { content: '\1F310 '; }

/* Titulaciones */
.mapa-tooltip .uni-tits {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 6px;
}

.mapa-tooltip .tit-item {
    font-family: 'Montserrat', sans-serif;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 6px;
    line-height: 1.3;
}

.mapa-tooltip .tit-grado {
    background: #e3f2fd;
    color: #1565C0;
    border-left: 3px solid #1565C0;
}

.mapa-tooltip .tit-master {
    background: #fce4ec;
    color: #C2185B;
    border-left: 3px solid #C2185B;
}

/* ── Leyenda del mapa ── */
.mapa-leyenda {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 24px;
    margin-top: 15px;
    flex-wrap: wrap;
    line-height: 1.5;
}

.mapa-leyenda-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Montserrat', sans-serif;
    font-size: 13px;
    font-weight: 600;
    color: #555;
}

.mapa-leyenda-pin {
    display: inline-block;
    width: 16px;
    height: 24px;
    clip-path: path('M 8,24 C 7,19 0,13 0,8 A 8,8 0 1,1 16,8 C 16,13 9,19 8,24 Z');
}

.mapa-leyenda-pin.pin-grado { background: #1565C0; }
.mapa-leyenda-pin.pin-master { background: #C2185B; }
.mapa-leyenda-pin.pin-grado_y_master { background: #2D7D2D; }

/* Instrucción */
.mapa-instruccion {
    text-align: center;
    font-family: 'Montserrat', sans-serif;
    font-size: 14px;
    color: #888;
    margin-top: 15px;
    line-height: 1.6;
}

/* ── Responsive ── */

/* Tablet */
@media (max-width: 980px) {
    .mapa-tooltip {
        max-width: 320px;
        min-width: 240px;
        padding: 16px 18px;
    }

    .mapa-tooltip .tooltip-ccaa {
        font-size: 15px;
    }

    .mapa-tooltip .uni-nombre {
        font-size: 13px;
    }

    .mapa-instruccion {
        font-size: 13px;
    }

    .mapa-leyenda {
        gap: 16px;
    }

    .mapa-leyenda-item {
        font-size: 12px;
    }
}

/* Móvil */
@media (max-width: 767px) {
    .mapa-tooltip {
        position: fixed;
        bottom: 20px;
        left: 50%;
        transform: translateX(-50%) translateY(20px);
        top: auto !important;
        max-width: calc(100vw - 40px);
        min-width: 260px;
        pointer-events: auto;
        border-radius: 12px;
        box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.2);
    }

    .mapa-tooltip.visible {
        transform: translateX(-50%) translateY(0);
    }

    .mapa-tooltip .tooltip-close {
        display: block;
    }

    .mapa-instruccion {
        font-size: 12px;
        margin-top: 10px;
    }

    .mapa-leyenda {
        gap: 12px;
        margin-top: 10px;
    }

    .mapa-leyenda-item {
        font-size: 11px;
        gap: 5px;
    }

    .mapa-leyenda-pin {
        width: 12px;
        height: 18px;
        clip-path: path('M 6,18 C 5,14 0,10 0,6 A 6,6 0 1,1 12,6 C 12,10 7,14 6,18 Z');
    }
}

/* ── Listado móvil de universidades ── */
.mapa-lista-movil {
    display: none;
}

@media (max-width: 767px) {
    .mapa-lista-movil {
        display: block;
        margin-top: 16px;
        line-height: 1.5;
    }

    .mapa-lista-titulo {
        font-family: 'Montserrat', sans-serif;
        font-weight: 700;
        font-size: 16px;
        color: #2D7D2D;
        text-align: center;
        margin-bottom: 12px;
    }

    /* CCAA item */
    .lista-ccaa-item {
        border: 1px solid #e0e0e0;
        border-radius: 10px;
        margin-bottom: 8px;
        overflow: hidden;
        background: #fff;
        box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    }

    .lista-ccaa-header {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 14px 16px;
        cursor: pointer;
        user-select: none;
        transition: background 0.2s;
    }

    .lista-ccaa-header:active {
        background: #f5f5f5;
    }

    /* Mini teardrop pin in list */
    .lista-ccaa-pin {
        flex-shrink: 0;
        width: 14px;
        height: 20px;
        clip-path: path('M 7,20 C 6,16 0,11 0,7 A 7,7 0 1,1 14,7 C 14,11 8,16 7,20 Z');
    }

    .lista-ccaa-pin.tipo-grado { background: #1565C0; }
    .lista-ccaa-pin.tipo-master { background: #C2185B; }
    .lista-ccaa-pin.tipo-grado_y_master { background: #2D7D2D; }

    .lista-ccaa-nombre {
        flex: 1;
        font-family: 'Montserrat', sans-serif;
        font-weight: 600;
        font-size: 14px;
        color: #1d1d1d;
    }

    .lista-ccaa-count {
        flex-shrink: 0;
        background: #f0f0f0;
        color: #666;
        font-family: 'Montserrat', sans-serif;
        font-size: 11px;
        font-weight: 700;
        width: 22px;
        height: 22px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .lista-ccaa-arrow {
        flex-shrink: 0;
        width: 10px;
        height: 10px;
        border-right: 2px solid #999;
        border-bottom: 2px solid #999;
        transform: rotate(45deg);
        transition: transform 0.25s ease;
    }

    .lista-ccaa-item.open .lista-ccaa-arrow {
        transform: rotate(-135deg);
    }

    /* Body (accordion) */
    .lista-ccaa-body {
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.35s ease;
    }

    .lista-ccaa-item.open .lista-ccaa-body {
        max-height: 2000px;
    }

    /* University card */
    .lista-uni-card {
        padding: 14px 16px;
        border-top: 1px solid #f0f0f0;
    }

    .lista-uni-nombre {
        font-family: 'Montserrat', sans-serif;
        font-weight: 700;
        font-size: 14px;
        color: #1d1d1d;
        margin: 0 0 2px 0;
    }

    .lista-uni-escuela {
        font-family: 'Montserrat', sans-serif;
        font-size: 12.5px;
        font-weight: 500;
        color: #555;
        margin: 0 0 8px 0;
        font-style: italic;
    }

    .lista-uni-contacto {
        display: flex;
        flex-direction: column;
        gap: 4px;
        margin-bottom: 10px;
        font-family: 'Montserrat', sans-serif;
        font-size: 12px;
    }

    .lista-uni-contacto a {
        color: #444;
        text-decoration: none;
    }

    .lista-uni-contacto a:active {
        color: #2D7D2D;
    }

    .lista-uni-tits {
        display: flex;
        flex-direction: column;
        gap: 4px;
    }

    /* Reuse tit-item styles from tooltip */
    .lista-uni-tits .tit-item {
        font-family: 'Montserrat', sans-serif;
        font-size: 12px;
        font-weight: 600;
        padding: 4px 10px;
        border-radius: 6px;
        line-height: 1.3;
    }

    .lista-uni-tits .tit-grado {
        background: #e3f2fd;
        color: #1565C0;
        border-left: 3px solid #1565C0;
    }

    .lista-uni-tits .tit-master {
        background: #fce4ec;
        color: #C2185B;
        border-left: 3px solid #C2185B;
    }
}

/* Botón cerrar (solo visible en móvil) */
.mapa-tooltip .tooltip-close {
    display: none;
    position: absolute;
    top: 10px;
    right: 12px;
    width: 24px;
    height: 24px;
    border: none;
    background: #f0f0f0;
    border-radius: 50%;
    font-size: 14px;
    line-height: 24px;
    text-align: center;
    color: #666;
    cursor: pointer;
    pointer-events: auto;
}

.mapa-tooltip .tooltip-close:hover {
    background: #e0e0e0;
    color: #333;
}
