/* =====================================================================
   Body Map – mapa muscular interactivo (tarea #57)
   Marca Workfit: carbón #313537 + lima #C2F858, tipografía Inter.
   El lima nunca va como texto sobre fondo claro: aquí siempre sobre carbón
   o de fondo con texto negro.
   Los trazados del SVG usan fill="currentColor": el color del músculo se
   controla con la propiedad "color".
   ===================================================================== */

.body-map-modal {
    --bm-lima: #C2F858;
    --bm-lima-hover: #B5F536;
    --bm-carbon: #313537;
    --bm-carbon-2: #3B4043;
    --bm-fondo: #1C1F21;
    --bm-panel: #26292B;
    --bm-borde: rgba(255, 255, 255, 0.08);
    --bm-borde-2: rgba(255, 255, 255, 0.16);
    --bm-txt: #F5F7F8;
    --bm-txt-2: #C3C9CD;
    --bm-txt-3: #8C959B;
    --bm-musculo: #4A5155;

    position: fixed;
    inset: 0;
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(10, 12, 13, 0.72);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    opacity: 0;
    visibility: hidden;
    transition: opacity .28s ease, visibility .28s ease;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--bm-txt);
}

.body-map-modal.active {
    opacity: 1;
    visibility: visible;
}

.body-map-container {
    position: relative;
    width: min(1080px, 100%);
    max-height: calc(100vh - 32px);
    display: flex;
    flex-direction: column;
    background:
        radial-gradient(120% 80% at 30% 0%, rgba(194, 248, 88, 0.07) 0%, rgba(194, 248, 88, 0) 55%),
        var(--bm-fondo);
    border: 1px solid var(--bm-borde);
    border-radius: 20px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
    overflow: hidden;
    transform: translateY(16px) scale(0.97);
    transition: transform .35s cubic-bezier(.2, .8, .2, 1);
}

.body-map-modal.active .body-map-container {
    transform: none;
}

/* ---------- Cabecera ---------- */
.bm-head {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 22px 24px 16px;
    border-bottom: 1px solid var(--bm-borde);
}

.bm-head-txt { flex: 1; min-width: 0; }

.bm-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #000;
    background: var(--bm-lima);
    border-radius: 999px;
    padding: 4px 12px;
}

.bm-head h2 {
    margin: 10px 0 4px;
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.01em;
    line-height: 1.2;
    color: var(--bm-txt);
}

.bm-head p {
    margin: 0;
    font-size: 14px;
    color: var(--bm-txt-3);
}

.body-map-close {
    flex: none;
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    border: 1px solid var(--bm-borde-2);
    background: transparent;
    color: var(--bm-txt-2);
    font-size: 18px;
    cursor: pointer;
    transition: background .2s, color .2s, transform .25s;
}

.body-map-close:hover {
    background: var(--bm-carbon-2);
    color: var(--bm-txt);
    transform: rotate(90deg);
}

/* ---------- Cuerpo ---------- */
.bm-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 20px;
    padding: 20px 24px;
}

.body-views {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin: 0;
}

.body-view {
    margin: 0;
    padding: 14px 10px 8px;
    border-radius: 16px;
    background: linear-gradient(180deg, var(--bm-panel) 0%, rgba(38, 41, 43, 0.4) 100%);
    border: 1px solid var(--bm-borde);
    text-align: center;
    min-width: 0;
}

.body-view figcaption {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--bm-txt-3);
    margin-bottom: 6px;
}

.body-svg-container {
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
}

.body-svg {
    display: block;
    width: 100%;
    height: auto;
    max-height: 60vh;
    overflow: visible;
}

/* ---------- Músculos ---------- */
.body-map-modal .muscle-group {
    color: var(--bm-musculo);
    cursor: pointer;
    outline: none;
    transform-box: fill-box;
    transform-origin: center;
    transition: color .2s ease, opacity .2s ease, filter .25s ease, transform .25s ease;
}

.body-map-modal .muscle-group path {
    stroke: rgba(0, 0, 0, 0.35);
    stroke-width: 1;
}

/* Entrada escalonada al abrir */
.body-map-modal.active .muscle-group {
    animation: bm-musculo-in .5s cubic-bezier(.2, .8, .2, 1) backwards;
    animation-delay: calc(var(--i, 0) * 35ms + 120ms);
}

.body-map-modal .muscle-group.zero {
    opacity: .45;
}

.body-map-modal .muscle-group:hover,
.body-map-modal .muscle-group.hover,
.body-map-modal .muscle-group:focus-visible {
    color: rgba(194, 248, 88, 0.75);
    opacity: 1;
    transform: scale(1.03);
    filter: drop-shadow(0 0 6px rgba(194, 248, 88, 0.45));
}

.body-map-modal .muscle-group.selected {
    color: var(--bm-lima);
    opacity: 1;
    animation: bm-latido 2.2s ease-in-out infinite;
}

.body-map-modal .muscle-group:focus-visible path {
    stroke: #fff;
    stroke-width: 3;
}

/* ---------- Panel lateral ---------- */
.bm-side {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-width: 0;
}

.muscle-info-panel {
    min-height: 150px;
    padding: 18px;
    border-radius: 16px;
    background: var(--bm-carbon);
    border: 1px solid var(--bm-borde);
    margin: 0;
    text-align: left;
}

.muscle-info.hidden,
.bm-placeholder.hidden {
    display: none;
}

.muscle-info.bm-pop {
    animation: bm-panel-in .25s ease both;
}

.bm-state {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--bm-txt-3);
    border: 1px solid var(--bm-borde-2);
    border-radius: 999px;
    padding: 2px 10px;
}

.bm-state.on {
    color: #000;
    background: var(--bm-lima);
    border-color: var(--bm-lima);
}

.muscle-name {
    margin: 10px 0 2px;
    font-size: 26px;
    font-weight: 800;
    line-height: 1.15;
    color: var(--bm-txt);
}

.muscle-exercises-count {
    font-size: 15px;
    font-weight: 700;
    color: var(--bm-lima);
}

.muscle-exercises-count.zero {
    color: var(--bm-txt-3);
}

.muscle-description {
    margin-top: 8px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--bm-txt-2);
}

.bm-placeholder {
    height: 100%;
    min-height: 114px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-align: center;
    color: var(--bm-txt-3);
    font-size: 14px;
}

.bm-placeholder i {
    font-size: 28px;
    color: var(--bm-lima);
    animation: bm-flota 1.8s ease-in-out infinite;
}

.bm-placeholder p { margin: 0; }

.bm-side h3 {
    margin: 0 0 8px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--bm-txt-3);
}

/* Vista previa de ejercicios del músculo elegido */
.bm-preview ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 8px;
}

.bm-preview li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 12px;
    background: var(--bm-panel);
    border: 1px solid var(--bm-borde);
    animation: bm-panel-in .3s ease both;
}

.bm-preview li:nth-child(2) { animation-delay: 40ms; }
.bm-preview li:nth-child(3) { animation-delay: 80ms; }
.bm-preview li:nth-child(4) { animation-delay: 120ms; }

.bm-preview img {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    object-fit: cover;
    flex: none;
    background: var(--bm-carbon-2);
}

.bm-preview b {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--bm-txt);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bm-preview li > div { min-width: 0; }

.bm-preview small {
    font-size: 12px;
    color: var(--bm-txt-3);
}

.bm-preview li.bm-skel {
    height: 62px;
    background: linear-gradient(90deg, var(--bm-panel) 0%, var(--bm-carbon-2) 50%, var(--bm-panel) 100%);
    background-size: 200% 100%;
    animation: bm-brillo 1.2s linear infinite;
}

/* Chips con todos los grupos */
.bm-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.bm-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 36px;
    padding: 0 6px 0 12px;
    border-radius: 999px;
    border: 1px solid var(--bm-borde-2);
    background: transparent;
    color: var(--bm-txt-2);
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background .2s, color .2s, border-color .2s;
}

.bm-chip b {
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    display: inline-grid;
    place-items: center;
    border-radius: 999px;
    background: var(--bm-carbon-2);
    color: var(--bm-txt);
    font-size: 12px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.bm-chip:hover,
.bm-chip.hover {
    border-color: var(--bm-lima);
    color: var(--bm-txt);
}

.bm-chip.selected {
    background: var(--bm-lima);
    border-color: var(--bm-lima);
    color: #000;
    font-weight: 700;
}

.bm-chip.selected b {
    background: #000;
    color: var(--bm-lima);
}

.bm-chip.zero { opacity: .55; }

.bm-chip:focus-visible,
.bm-btn:focus-visible,
.body-map-close:focus-visible {
    outline: 3px solid var(--bm-lima);
    outline-offset: 2px;
}

/* ---------- Pie ---------- */
.body-map-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 24px;
    margin: 0;
    border-top: 1px solid var(--bm-borde);
    background: rgba(0, 0, 0, 0.18);
}

.bm-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 46px;
    padding: 0 20px;
    border-radius: 12px;
    font: inherit;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: background .2s, color .2s, transform .15s, opacity .2s;
}

.bm-btn:active { transform: scale(.98); }

.bm-btn-ghost {
    background: transparent;
    border: 1px solid var(--bm-borde-2);
    color: var(--bm-txt-2);
}

.bm-btn-ghost:hover {
    background: var(--bm-carbon-2);
    color: var(--bm-txt);
}

.bm-btn-pri {
    background: var(--bm-lima);
    border: 1px solid var(--bm-lima);
    color: #000;
    min-width: 200px;
}

.bm-btn-pri:hover:not(:disabled) { background: var(--bm-lima-hover); }

.bm-btn-pri:disabled {
    background: var(--bm-carbon-2);
    border-color: var(--bm-carbon-2);
    color: var(--bm-txt-3);
    cursor: not-allowed;
}

/* ---------- Animaciones ---------- */
@keyframes bm-musculo-in {
    from { opacity: 0; transform: scale(.92); }
    to { opacity: 1; transform: none; }
}

@keyframes bm-latido {
    0%, 100% { filter: drop-shadow(0 0 4px rgba(194, 248, 88, 0.45)); }
    50% { filter: drop-shadow(0 0 14px rgba(194, 248, 88, 0.85)); }
}

@keyframes bm-panel-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

@keyframes bm-flota {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

@keyframes bm-brillo {
    from { background-position: 200% 0; }
    to { background-position: -200% 0; }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .bm-body {
        grid-template-columns: 1fr;
    }
    .muscle-info-panel { min-height: 0; }
}

@media (max-width: 600px) {
    .body-map-modal { padding: 0; align-items: flex-end; }
    .body-map-container {
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: 20px 20px 0 0;
        transform: translateY(40px);
    }
    .bm-head { padding: 16px 16px 12px; }
    .bm-head h2 { font-size: 20px; }
    .bm-body { padding: 14px 16px; gap: 14px; }
    .body-views { gap: 10px; }
    .body-svg { max-height: 44vh; }
    .body-map-actions { padding: 12px 16px; }
    .body-map-actions .bm-btn { flex: 1; }
    .bm-btn-pri { min-width: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .body-map-modal,
    .body-map-container,
    .body-map-modal .muscle-group,
    .muscle-info.bm-pop,
    .bm-preview li,
    .bm-placeholder i {
        animation: none !important;
        transition: none !important;
    }
}
