.hmie-map {
    --hmie-flow: #708a9c;
    --hmie-customer: #8db8ff;
    --hmie-market: #4dd6a0;
    --hmie-trading: #b9a5f4;
    margin-block: 2rem 1.25rem;
}

.hmie-map [hidden] {
    display: none !important;
}

.hmie-map__access { --quadrant-color: var(--hmie-customer); }
.hmie-map__markets { --quadrant-color: var(--hmie-market); }
.hmie-map__trading { --quadrant-color: var(--hmie-trading); }
.hmie-map__engine { --quadrant-color: var(--accent); }

.hmie-map__caption {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.25rem 1rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.hmie-map__hint {
    color: var(--muted);
    font-size: 0.875rem;
    font-weight: 400;
}

.hmie-map__canvas {
    position: relative;
}

.hmie-map__picture {
    display: block;
    width: 100%;
    height: auto;
    text-rendering: geometricPrecision;
}

.hmie-map__frame {
    fill: var(--surface);
    stroke: var(--line);
    stroke-width: 1.25;
}

.hmie-map__rule {
    stroke: var(--quadrant-color);
    stroke-width: 3;
}

.hmie-map__heading {
    fill: var(--quadrant-color);
    font-size: 20px;
    font-weight: 700;
}

.hmie-map__subtitle,
.hmie-map__node-caption {
    fill: var(--muted);
    font-size: 11px;
}

.hmie-map__node {
    fill: var(--surface-raised);
    stroke: var(--line);
}

.hmie-map__node-title {
    fill: var(--ink);
    font-size: 14px;
    font-weight: 700;
}

.hmie-map__line {
    fill: none;
    stroke: var(--hmie-flow);
    stroke-width: 1.45;
    stroke-linejoin: round;
}

.hmie-map__connections {
    pointer-events: none;
}

.hmie-map__line--external {
    stroke: var(--accent);
    stroke-width: 2;
}

.hmie-map__line--external.is-highlighted {
    stroke-width: 3;
}

.hmie-map__bridge {
    fill: none;
    stroke: var(--page);
    stroke-width: 6;
}

.hmie-map__connection-label {
    fill: var(--accent);
    stroke: var(--page);
    stroke-width: 4;
    stroke-linejoin: round;
    paint-order: stroke;
    font-size: 11px;
    font-weight: 700;
}

.hmie-map__targets {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.hmie-map__target {
    position: absolute;
    inset-inline-start: 1%;
    inset-block-start: 1.818%;
    width: 46%;
    height: 40.303%;
    padding: 0;
    color: var(--quadrant-color);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 0.625rem;
    cursor: zoom-in;
    pointer-events: auto;
}

.hmie-map__target[data-hmie-open="markets"],
.hmie-map__target[data-hmie-open="engine"] {
    inset-inline-start: 53%;
}

.hmie-map__target[data-hmie-open="trading"],
.hmie-map__target[data-hmie-open="engine"] {
    inset-block-start: 49.545%;
    height: 48.636%;
}

.hmie-map__target:hover {
    border-color: var(--quadrant-color);
}

.hmie-map__target-name {
    display: none;
}

.hmie-map__target-icon {
    position: absolute;
    inset-block-start: 0.65rem;
    inset-inline-end: 1rem;
    font-size: 1.15rem;
    font-weight: 700;
}

.hmie-map__sections:has(.hmie-map__detail:not([hidden])) {
    margin-top: 1rem;
}

.hmie-map__detail {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

.hmie-map__detail:not([hidden]) + .hmie-map__detail:not([hidden]) {
    margin-top: 0.5rem;
}

.hmie-map__detail > summary {
    padding: 0.75rem 1rem;
    color: var(--quadrant-color);
    cursor: pointer;
    font-weight: 700;
}

.hmie-map__detail-content {
    padding: clamp(1rem, 3vw, 1.75rem);
}

.hmie-map__detail-header {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1rem;
    align-items: center;
    margin-bottom: 1rem;
}

.hmie-map__detail-header h3 {
    color: var(--quadrant-color);
}

.hmie-map__back {
    min-height: 2.75rem;
    width: fit-content;
    cursor: pointer;
    font-size: 0.9rem;
}

.hmie-map__detail-intro {
    max-width: 75ch;
    color: var(--muted);
}

.hmie-map__detail-picture {
    width: min(100%, 43rem);
    margin: 1rem auto 0;
}

.hmie-map__stages {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.85rem;
    margin: 1rem 0 0;
}

.hmie-map__stages > div {
    min-width: 0;
    padding: 0.8rem 0.9rem;
    border: 1px solid var(--line);
    border-inline-start: 2px solid var(--quadrant-color);
    border-radius: 0.45rem;
    background: var(--surface-raised);
}

.hmie-map__stages dt {
    font-weight: 700;
}

.hmie-map__stages dd {
    margin: 0.25rem 0 0;
    color: var(--muted);
    font-size: 0.9375rem;
}

@media (max-width: 45rem) {
    .hmie-map__targets {
        position: static;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.5rem;
        margin-top: 0.7rem;
    }

    .hmie-map__target,
    .hmie-map__target[data-hmie-open] {
        position: relative;
        inset: auto;
        width: auto;
        height: auto;
        min-height: 2.75rem;
        padding: 0.6rem 1.45rem 0.6rem 0.65rem;
        background: var(--surface);
        border-color: var(--line);
        font-size: 0.875rem;
        text-align: start;
        line-height: 1.3;
    }

    .hmie-map__target-name {
        display: inline;
    }

    .hmie-map__target-icon {
        inset-block-start: 0.5rem;
        inset-inline-end: 0.45rem;
        font-size: 1rem;
    }

    .hmie-map__stages {
        grid-template-columns: 1fr;
    }
}

@media (prefers-reduced-motion: no-preference) {
    .hmie-map.is-interactive .hmie-map__detail:not([hidden]) {
        animation: hmie-zoom 180ms ease-out;
    }

    @keyframes hmie-zoom {
        from {
            opacity: 0.65;
            transform: translateY(4px);
        }

        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
}
