/* ==========================================================================
   Sección KPI + organigrama (empresa.php)
   Fondo cosmos: puntos de estrella (sin anillos radiales), planeta lento y
   fundido inferior. Logo de fondo sutil: bordes difuminados, luz solar
   superior, motion blur y baja presencia visual.
   ========================================================================== */

.orbe-cosmos {
    --orbe-cosmos-deep: #020812;
    --orbe-cosmos-mid: #051428;
    --orbe-cosmos-top: #0a1f44;
    --orbe-planet-size: clamp(42rem, 118vw, 92rem);
    --orbe-planet-edge-mask: radial-gradient(
        circle at 50% 50%,
        #000 0%,
        #000 48%,
        rgba(0, 0, 0, .82) 58%,
        rgba(0, 0, 0, .42) 72%,
        rgba(0, 0, 0, .12) 84%,
        transparent 94%
    );

    position: relative;
    isolation: isolate;
    overflow: hidden;
    contain: layout paint;
    background: linear-gradient(180deg, var(--orbe-cosmos-top) 0%, var(--orbe-cosmos-mid) 38%, var(--orbe-cosmos-deep) 100%);
}

.orbe-cosmos__sky {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.orbe-cosmos__stars {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    pointer-events: none;
}

.orbe-cosmos__star-layer--far {
    animation: orbe-cosmos-twinkle 11s ease-in-out infinite alternate;
}

.orbe-cosmos__star-layer--mid {
    animation: orbe-cosmos-twinkle 16s ease-in-out infinite alternate-reverse;
}

.orbe-cosmos__star-layer--near {
    animation: orbe-cosmos-twinkle 8s ease-in-out infinite alternate;
}

@keyframes orbe-cosmos-twinkle {
    from { opacity: .45; }
    to { opacity: 1; }
}

.orbe-cosmos__brand {
    position: absolute;
    left: 50%;
    bottom: 0;
    width: var(--orbe-planet-size);
    aspect-ratio: 1 / 1;
    transform: translate(-50%, 50%);
    pointer-events: none;
    z-index: 0;
    opacity: .72;
    -webkit-mask-image: radial-gradient(
        ellipse 100% 100% at 50% 58%,
        #000 0%,
        #000 24%,
        rgba(0, 0, 0, .72) 40%,
        rgba(0, 0, 0, .28) 56%,
        transparent 74%
    );
    mask-image: radial-gradient(
        ellipse 100% 100% at 50% 58%,
        #000 0%,
        #000 24%,
        rgba(0, 0, 0, .72) 40%,
        rgba(0, 0, 0, .28) 56%,
        transparent 74%
    );
}

.orbe-cosmos__planet {
    position: relative;
    width: 100%;
    height: 100%;
    transform: rotateX(10deg) rotateZ(-8deg);
    transform-origin: 50% 50%;
}

.orbe-cosmos__planet-rotor {
    position: relative;
    width: 100%;
    height: 100%;
    transform-origin: 50% 50%;
    animation: orbe-cosmos-planet-spin 280s linear infinite;
    will-change: transform;
}

.orbe-cosmos__planet-face {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 50%;
    position: relative;
    z-index: 1;
    opacity: .2;
    filter: blur(1.5px);
    -webkit-mask-image: var(--orbe-planet-edge-mask);
    mask-image: var(--orbe-planet-edge-mask);
    animation: orbe-cosmos-planet-light 28s ease-in-out infinite alternate;
}

/* Capa de motion blur: halo difuso que acompaña la rotación. */
.orbe-cosmos__planet-face--trail {
    position: absolute;
    inset: 0;
    z-index: 0;
    opacity: .1;
    filter: blur(14px);
    transform: scale(1.045);
    -webkit-mask-image: radial-gradient(
        circle at 50% 50%,
        rgba(0, 0, 0, .95) 0%,
        rgba(0, 0, 0, .55) 52%,
        rgba(0, 0, 0, .18) 72%,
        transparent 88%
    );
    mask-image: radial-gradient(
        circle at 50% 50%,
        rgba(0, 0, 0, .95) 0%,
        rgba(0, 0, 0, .55) 52%,
        rgba(0, 0, 0, .18) 72%,
        transparent 88%
    );
    animation: orbe-cosmos-planet-trail-light 28s ease-in-out infinite alternate;
}

/* Luz solar fija en el borde superior (no rota con el isotipo). */
.orbe-cosmos__planet-sunlight {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    pointer-events: none;
    z-index: 2;
    background:
        radial-gradient(
            ellipse 68% 26% at 50% 4%,
            rgba(255, 238, 195, .52) 0%,
            rgba(255, 215, 145, .22) 38%,
            rgba(255, 195, 110, .06) 58%,
            transparent 78%
        ),
        linear-gradient(
            180deg,
            rgba(255, 250, 235, .18) 0%,
            rgba(255, 240, 210, .06) 14%,
            transparent 28%
        );
    mix-blend-mode: screen;
}

@keyframes orbe-cosmos-planet-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes orbe-cosmos-planet-light {
    0% { opacity: .14; }
    50% { opacity: .22; }
    100% { opacity: .17; }
}

@keyframes orbe-cosmos-planet-trail-light {
    0% { opacity: .07; }
    50% { opacity: .13; }
    100% { opacity: .09; }
}

/* Degradado inferior: funde el corte del planeta con el siguiente bloque. */
.orbe-cosmos__fade {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 42%;
    pointer-events: none;
    z-index: 1;
    background: linear-gradient(
        to bottom,
        transparent 0%,
        rgba(2, 8, 18, .35) 38%,
        rgba(2, 8, 18, .82) 72%,
        #020812 100%
    );
}

.orbe-cosmos__content {
    position: relative;
    z-index: 2;
}

/* KPI: tarjetas 2×2 en móvil/tablet; fila horizontal en desktop */
@media (max-width: 991.98px) {
    .orbe-cosmos--empresa {
        overflow: visible;
        contain: none;
    }

    .orbe-cosmos--empresa .orbe-organigrama-wrap,
    .orbe-cosmos--empresa .orbe-organigrama,
    .orbe-cosmos--empresa .orbe-organigrama__fit {
        overflow: visible;
        contain: none;
    }

    .orbe-cosmos--empresa.pb-15,
    .orbe-cosmos--empresa.pt-15 {
        padding-top: 2.25rem !important;
        padding-bottom: 2.5rem !important;
    }

    .orbe-cosmos--empresa .orbe-cosmos__brand {
        --orbe-planet-size: min(92vw, 36rem);
        opacity: 0.5;
    }

    .orbe-cosmos--empresa .orbe-cosmos__fade {
        height: 30%;
    }

    .orbe-kpi-grid {
        --bs-gutter-x: 0.65rem;
        --bs-gutter-y: 0.65rem;
        margin-bottom: 0.25rem;
    }

    .orbe-kpi-grid__item {
        display: flex;
        align-items: stretch;
    }

    .orbe-kpi-card {
        width: 100%;
        min-height: 100%;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center;
        gap: 0.35rem;
        text-align: center;
        padding: 0.75rem 0.5rem;
        border-radius: 0.5rem;
        background: rgba(8, 18, 32, 0.55);
        border: 1px solid rgba(170, 181, 195, 0.22);
        box-shadow: 0 4px 18px rgba(0, 0, 0, 0.18);
        backdrop-filter: blur(4px);
    }

    .orbe-kpi-card__value {
        margin: 0 !important;
    }

    .orbe-kpi-card__label {
        flex-grow: 0 !important;
        width: 100%;
    }

    .orbe-kpi-card .display-5 {
        font-size: clamp(1.75rem, 7.5vw, 2.25rem);
    }

    .orbe-kpi-card .fs-5 {
        font-size: clamp(0.62rem, 2.55vw, 0.78rem) !important;
        line-height: 1.3;
        letter-spacing: 0.03em;
    }
}

@media (min-width: 992px) {
    .orbe-kpi-grid.row {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        justify-content: stretch;
        align-items: stretch;
        margin-left: 0;
        margin-right: 0;
        gap: clamp(0.55rem, 1.1vw, 1.15rem);
    }

    .orbe-kpi-grid.row > * {
        width: auto !important;
        max-width: none !important;
        flex: none !important;
        padding-left: 0;
        padding-right: 0;
        min-width: 0;
    }

    .orbe-kpi-grid__item {
        display: flex;
        min-width: 0;
    }

    .orbe-kpi-card {
        gap: 0;
        width: 100%;
        min-width: 0;
    }

    .orbe-kpi-card__value {
        margin-right: 0.45rem !important;
        flex-shrink: 0;
    }

    .orbe-kpi-card__label {
        min-width: 0;
    }

    .orbe-kpi-card .display-5 {
        font-size: clamp(1.65rem, 2vw, 2.35rem);
    }

    .orbe-kpi-card .fs-5 {
        font-size: clamp(0.68rem, 0.78vw, 0.88rem) !important;
        line-height: 1.28;
        letter-spacing: 0.04em;
        overflow-wrap: anywhere;
    }
}

.orbe-cosmos .orbe-kpi-gloss {
    border-bottom-color: rgba(255, 255, 255, 0.32);
}

.orbe-cosmos .orbe-kpi-gloss:hover,
.orbe-cosmos .orbe-kpi-gloss:focus-visible {
    color: rgba(255, 255, 255, 0.88);
    border-bottom-color: rgba(var(--bs-primary-rgb), 0.85);
}

.tooltip.orbe-kpi-tooltip .tooltip-inner {
    max-width: 16rem;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    text-transform: none;
}

@media (max-width: 991.98px) {
    .orbe-cosmos {
        --orbe-planet-size: clamp(36rem, 145vw, 56rem);
    }

    .orbe-cosmos__planet {
        transform: rotateX(8deg) rotateZ(-6deg);
    }

    .orbe-cosmos__planet-face {
        opacity: .18;
        filter: blur(1.25px);
    }

    .orbe-cosmos__planet-face--trail {
        filter: blur(11px);
        opacity: .08;
    }
}

@media (prefers-reduced-motion: reduce) {
    .orbe-cosmos__stars .orbe-cosmos__star-layer,
    .orbe-cosmos__planet-rotor,
    .orbe-cosmos__planet-face {
        animation: none !important;
    }

    .orbe-cosmos__planet-face {
        opacity: .18;
    }

    .orbe-cosmos__planet-face--trail {
        opacity: .08;
    }
}
