/* Radial energy-flow diagram (own dashboard subpage).
   The SVG layer and the HTML node layer share one coordinate grid: the SVG
   stretches to the box via preserveAspectRatio="none" and the node layer is
   positioned in percentages of the very same box, so both scale together. */

/* The box has to stay square: the node glyphs are sized off its width, while
   their positions scale with both axes, so a flatter box pulls them apart.
   Bounding the *width* by the height the viewport has left over keeps it square
   and free of scrolling — a max-height would let the browser flatten the box
   instead of shrinking it. The subtrahend is topbar + page, card and header. */
.energy-flow {
    position: relative;
    aspect-ratio: 1;
    width: 100%;
    max-width: calc(100vh - 13rem);
    margin: 0 auto;
}

.energy-flow-svg,
.energy-flow-nodes {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.energy-flow-nodes {
    pointer-events: none;
}

.energy-flow-edge {
    stroke-width: 3;
    stroke-linecap: round;
    opacity: 0.45;
}

.energy-flow-dot {
    position: absolute;
    width: 1.4%;
    aspect-ratio: 1;
    border-radius: 50%;
    left: var(--flow-x1);
    top: var(--flow-y1);
    transform: translate(-50%, -50%);
    animation-name: energy-flow-travel;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
}

@keyframes energy-flow-travel {
    0% {
        left: var(--flow-x1);
        top: var(--flow-y1);
        opacity: 0;
    }

    12% {
        opacity: 1;
    }

    88% {
        opacity: 1;
    }

    100% {
        left: var(--flow-x2);
        top: var(--flow-y2);
        opacity: 0;
    }
}

/* nodes and house are centred on their coordinate */
.energy-flow-house,
.energy-flow-node {
    position: absolute;
    aspect-ratio: 1;
    transform: translate(-50%, -50%);
    pointer-events: auto;
}

.energy-flow-house {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background-color: var(--color-primary-light-blue);
    border: 2px solid var(--color-primary-lighter-blue);
    color: var(--color-primary-darker-blue);
}

.energy-flow-house .sli-house {
    font-size: clamp(24px, 4.5vw, 48px);
}

.energy-flow-node-circle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background-color: var(--color-primary-white);
    border: 2px solid var(--flow-color);
    color: var(--flow-color);
}

.energy-flow-node-circle i {
    font-size: clamp(14px, 2.6vw, 26px);
}

.energy-flow-node.inactive .energy-flow-node-circle {
    color: var(--color-primary-midrange-grey);
    border-color: var(--color-primary-grey);
}

/* label block placed outside the ring, away from the house */
.energy-flow-node-text {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
    white-space: nowrap;
    line-height: 1.1;
}

.energy-flow-node-text.anchor-top {
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 0.35rem;
}

.energy-flow-node-text.anchor-bottom {
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 0.35rem;
}

.energy-flow-node-text.anchor-left {
    right: 100%;
    top: 50%;
    transform: translateY(-50%);
    align-items: flex-end;
    margin-right: 0.5rem;
}

.energy-flow-node-text.anchor-right {
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    align-items: flex-start;
    margin-left: 0.5rem;
}

.energy-flow-node-label {
    font-size: clamp(10px, 1.2vw, 13px);
    color: var(--color-primary-darker-grey);
}

.energy-flow-node-power {
    font-size: clamp(11px, 1.4vw, 15px);
    font-weight: 600;
    color: var(--color-primary-darker-grey);
}

.energy-flow-node.inactive .energy-flow-node-power {
    color: var(--color-primary-midrange-grey);
}

@media (prefers-reduced-motion: reduce) {
    .energy-flow-dot {
        animation: none;
        opacity: 0.8;
    }
}

@media (max-width: 768px) {
    .energy-flow-node-label {
        display: none;
    }
}